Social becomes a section instead of document property

First it changes the entries to categories. That is CV_ENV is now category
for everything. Then cventry continues to behave as before, but CATEGORY
social comes in.

For the moment it creates a formatted block
This commit is contained in:
Óscar Nájera 2020-05-21 13:56:04 +02:00
parent 30e93ab103
commit 0a20ce2b00

View file

@ -47,9 +47,6 @@
(:homepage "HOMEPAGE" nil nil parse)
(:address "ADDRESS" nil nil newline)
(:photo "PHOTO" nil nil parse)
(:gitlab "GITLAB" nil nil parse)
(:github "GITHUB" nil nil parse)
(:linkedin "LINKEDIN" nil nil parse)
(:with-email nil "email" t t)
)
:translate-alist '((headline . org-hugocv-headline)
@ -80,6 +77,42 @@ as a communication channel."
contents)))
(defun social-entry (icon url handle)
(let* ((nw-handle (string-trim handle))
(icon-wrap (if (org-string-nw-p icon) (concat (format "<i class=\"fa %s\"> " icon) "%s</i>") "%s"))
(link-wrap (format "<a href=\"%s/%s\">%s</a>" url nw-handle icon-wrap))
)
(format link-wrap nw-handle)))
(defun org-hugocv--format-socialchannels (headline contents info)
(let* ((channel (downcase (org-export-data (org-element-property :title headline) info)))
(entry (-any (lambda (network) (when (string-match-p channel (plist-get network :url))
(social-entry (plist-get network :icon) (plist-get network :url) contents)))
'((:url "https://www.github.com" :icon "fa-github")
(:url "https://www.gitlab.com" :icon "fa-gitlab")
(:url "https://www.linkedin.com/in" :icon "fa-linkedin")
(:url "https://www.linkedin.com/in" :icon "fa-linkedin")
(:url "https://twitter.com" :icon "fa-twitter")
(:url "https://facebook.com" :icon "fa-facebook")
(:url "https://www.instagram.com" :icon "fa-instagram"))
)))
(cond
(entry entry)
((org-element-property :URL headline)
(let ((icon (org-export-data (org-element-property :ICON headline) info))
(url (org-export-data (org-element-property :URL headline) info))
(handle (org-export-data contents info))
)
(concat (if (org-string-nw-p icon)
""
(concat (org-export-data (org-element-property :title headline) info) " : "))
(social-entry icon url handle))))
((org-export-with-backend 'hugo headline contents info)))
))
;;;; Headline
(defun org-hugocv-headline (headline contents info)
@ -87,12 +120,14 @@ contents)))
CONTENTS is the contents of the headline. INFO is a plist used
as a communication channel."
(unless (org-element-property :footnote-section-p headline)
(let ((environment (let ((env (org-element-property :CV_ENV headline)))
(let ((environment (let ((env (org-export-get-category headline info)))
(or (org-string-nw-p env) "block"))))
(cond
;; is a cv entry
((equal environment "cventry")
(org-hugocv--format-cventry headline contents info))
((equal environment "social")
(org-hugocv--format-socialchannels headline contents info))
((org-export-with-backend 'hugo headline contents info))))))
(defun org-hugocv-inner-template (contents info)
@ -108,25 +143,6 @@ holding export options."
;; homepage
(let ((homepage (org-export-data (plist-get info :homepage) info)))
(when (org-string-nw-p homepage) (format "<li class=\"fa fa-globe\"><a href=\"https://%s\"> %s</a></li>\n" homepage homepage)))
;; social media
(mapconcat (lambda (social-network)
(let ((network (org-export-data
(plist-get info (car social-network))
info)))
(when (org-string-nw-p network)
(format "<li class=\"fa fa-%s\"><a href=\"https://%s/%s\"> %s</a></li>\n"
(nth 1 social-network)
(nth 2 social-network)
network
network))))
'((:github "github" "www.github.com")
(:gitlab "gitlab" "www.gitlab.com")
(:linkedin "linkedin" "www.linkedin.com/in"))
"")
"</ul>\n\n"
(org-hugo-inner-template contents info)))