forked from mirrors/org-cv
Compare commits
3 commits
master
...
socialbloc
Author | SHA1 | Date | |
---|---|---|---|
|
5e34c09388 | ||
|
edfe13f3af | ||
|
0a20ce2b00 |
1 changed files with 55 additions and 26 deletions
81
ox-hugocv.el
81
ox-hugocv.el
|
@ -47,14 +47,29 @@
|
||||||
(:homepage "HOMEPAGE" nil nil parse)
|
(:homepage "HOMEPAGE" nil nil parse)
|
||||||
(:address "ADDRESS" nil nil newline)
|
(:address "ADDRESS" nil nil newline)
|
||||||
(:photo "PHOTO" nil nil parse)
|
(: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)
|
(:with-email nil "email" t t)
|
||||||
)
|
)
|
||||||
:translate-alist '((headline . org-hugocv-headline)
|
:translate-alist '((headline . org-hugocv-headline)
|
||||||
(inner-template . org-hugocv-inner-template)))
|
(inner-template . org-hugocv-inner-template)))
|
||||||
|
|
||||||
|
(setq org-hugocv--recognized-social-networks
|
||||||
|
'((: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://twitter.com/"
|
||||||
|
:icon "fa-twitter")
|
||||||
|
(:url "https://facebook.com/"
|
||||||
|
:icon "fa-facebook")
|
||||||
|
(:url "https://www.instagram.com/"
|
||||||
|
: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.
|
||||||
|
@ -80,6 +95,36 @@ as a communication channel."
|
||||||
contents)))
|
contents)))
|
||||||
|
|
||||||
|
|
||||||
|
(defun social-entry (icon url handle)
|
||||||
|
(let* ((nw-handle (string-trim handle))
|
||||||
|
(icon-wrap (if (org-string-nw-p icon)
|
||||||
|
(format "<i class=\"fa %s\"> %s</i>" icon nw-handle) nw-handle)))
|
||||||
|
(format "<a href=\"%s%s\">%s</a>" url nw-handle icon-wrap)))
|
||||||
|
|
||||||
|
(defun org-hugocv--unknown-social-channels (headline contents info)
|
||||||
|
(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))))
|
||||||
|
|
||||||
|
(defun org-hugocv--pick-social-network (channel contents)
|
||||||
|
(-any (lambda (network)
|
||||||
|
(when (string-match-p channel (plist-get network :url))
|
||||||
|
(social-entry (plist-get network :icon)
|
||||||
|
(plist-get network :url)
|
||||||
|
contents)))
|
||||||
|
recognized-social-networks))
|
||||||
|
|
||||||
|
(defun org-hugocv--format-socialchannels (headline contents info)
|
||||||
|
(let* ((channel (downcase (org-export-data (org-element-property :title headline) info)))
|
||||||
|
(entry (org-hugocv--pick-social-network channel contents)))
|
||||||
|
(cond (entry entry)
|
||||||
|
((org-element-property :URL headline)
|
||||||
|
(org-hugocv--unknown-social-channels headline contents info))
|
||||||
|
((org-export-with-backend 'hugo headline contents info)))))
|
||||||
|
|
||||||
;;;; Headline
|
;;;; Headline
|
||||||
(defun org-hugocv-headline (headline contents info)
|
(defun org-hugocv-headline (headline contents info)
|
||||||
|
@ -87,12 +132,14 @@ contents)))
|
||||||
CONTENTS is the contents of the headline. INFO is a plist used
|
CONTENTS is the contents of the headline. INFO is a plist used
|
||||||
as a communication channel."
|
as a communication channel."
|
||||||
(unless (org-element-property :footnote-section-p headline)
|
(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"))))
|
(or (org-string-nw-p env) "block"))))
|
||||||
(cond
|
(cond
|
||||||
;; is a cv entry
|
;; is a cv entry
|
||||||
((equal environment "cventry")
|
((equal environment "cventry")
|
||||||
(org-hugocv--format-cventry headline contents info))
|
(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))))))
|
((org-export-with-backend 'hugo headline contents info))))))
|
||||||
|
|
||||||
(defun org-hugocv-inner-template (contents info)
|
(defun org-hugocv-inner-template (contents info)
|
||||||
|
@ -104,29 +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 media
|
(social-entry "fa-globe" "" homepage)))
|
||||||
(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"
|
"</ul>\n\n"
|
||||||
(org-hugo-inner-template contents info)))
|
(org-hugo-inner-template contents info)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue