refactor contact

This commit is contained in:
Óscar Nájera 2020-06-01 21:16:28 +02:00
parent edfe13f3af
commit 5e34c09388

View file

@ -52,20 +52,25 @@
:translate-alist '((headline . org-hugocv-headline) :translate-alist '((headline . org-hugocv-headline)
(inner-template . org-hugocv-inner-template))) (inner-template . org-hugocv-inner-template)))
(defvar recognized-social-networks (setq org-hugocv--recognized-social-networks
'((:url "https://www.github.com" '((:url "https://www.github.com/"
:icon "fa-github") :icon "fa-github")
(:url "https://www.gitlab.com" (:url "https://www.gitlab.com/"
:icon "fa-gitlab") :icon "fa-gitlab")
(:url "https://www.linkedin.com/in" (:url "https://www.linkedin.com/in/"
:icon "fa-linkedin") :icon "fa-linkedin")
(:url "https://twitter.com" (:url "https://twitter.com/"
:icon "fa-twitter") :icon "fa-twitter")
(:url "https://facebook.com" (:url "https://facebook.com/"
:icon "fa-facebook") :icon "fa-facebook")
(:url "https://www.instagram.com" (:url "https://www.instagram.com/"
:icon "fa-instagram"))) :icon "fa-instagram")))
(defun org-hugocv--crop-edges (x)
"String is <X> so remove first and last chars."
(let ((le (- (length x) 1)))
(substring x 1 le)))
(defun org-hugocv--format-cventry (headline contents info) (defun org-hugocv--format-cventry (headline contents info)
"Format HEADLINE as as cventry. "Format HEADLINE as as cventry.
CONTENTS holds the contents of the headline. INFO is a plist used CONTENTS holds the contents of the headline. INFO is a plist used
@ -94,7 +99,7 @@ contents)))
(let* ((nw-handle (string-trim handle)) (let* ((nw-handle (string-trim handle))
(icon-wrap (if (org-string-nw-p icon) (icon-wrap (if (org-string-nw-p icon)
(format "<i class=\"fa %s\"> %s</i>" icon nw-handle) nw-handle))) (format "<i class=\"fa %s\"> %s</i>" icon nw-handle) nw-handle)))
(format "<a href=\"%s/%s\">%s</a>" url nw-handle icon-wrap))) (format "<a href=\"%s%s\">%s</a>" url nw-handle icon-wrap)))
(defun org-hugocv--unknown-social-channels (headline contents info) (defun org-hugocv--unknown-social-channels (headline contents info)
(let ((icon (org-export-data (org-element-property :ICON headline) info)) (let ((icon (org-export-data (org-element-property :ICON headline) info))
@ -146,10 +151,11 @@ holding export options."
(let ((email (and (plist-get info :with-email) (let ((email (and (plist-get info :with-email)
(org-export-data (plist-get info :email) info)))) (org-export-data (plist-get info :email) info))))
(when (org-string-nw-p email) (when (org-string-nw-p email)
(format "<li class=\"fa fa-envelope\"><a href=\"mailto:%s\"> %s</a></li>\n" email email))) (social-entry "fa-envelope" "mailto:" email)))
;; homepage ;; homepage
(let ((homepage (org-export-data (plist-get info :homepage) info))) (let ((homepage (org-hugocv--crop-edges (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))) (when (org-string-nw-p homepage)
(social-entry "fa-globe" "" homepage)))
"</ul>\n\n" "</ul>\n\n"
(org-hugo-inner-template contents info))) (org-hugo-inner-template contents info)))