mirror of
https://gitlab.com/Titan-C/org-cv.git
synced 2024-11-14 18:48:30 +00:00
try time window
time window
This commit is contained in:
parent
2100516ffc
commit
0b433116d1
4 changed files with 65 additions and 51 deletions
58
org-cv-utils.el
Normal file
58
org-cv-utils.el
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
;;; org-cv-utils.el --- Common utility functions for CV exporters -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; Copyright (C) 2018 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
;; Author: Oscar Najera <hi AT oscarnajera.com DOT com>
|
||||||
|
;; Keywords: org, wp, tex
|
||||||
|
|
||||||
|
;; This file is not part of GNU Emacs.
|
||||||
|
|
||||||
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation; either version 3, or (at your option)
|
||||||
|
;; any later version.
|
||||||
|
;;
|
||||||
|
;; This program is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU General Public License for more details.
|
||||||
|
;;
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||||
|
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
;; Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
;;
|
||||||
|
;; This library implements some utility functions
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
(require 'org)
|
||||||
|
|
||||||
|
(defun org-cv-utils-org-timestamp-to-shortdate (date_str)
|
||||||
|
"Format orgmode timestamp DATE_STR into a short form date.
|
||||||
|
Other strings are just returned unmodified
|
||||||
|
|
||||||
|
e.g. <2002-08-12 Mon> => Aug 2012
|
||||||
|
today => today"
|
||||||
|
(if (string-match (org-re-timestamp 'active) date_str)
|
||||||
|
(let* ((abbreviate 't)
|
||||||
|
(dte (org-parse-time-string date_str))
|
||||||
|
(month (nth 4 dte))
|
||||||
|
(year (nth 5 dte))) ;;'(02 07 2015)))
|
||||||
|
(concat
|
||||||
|
(calendar-month-name month abbreviate) " " (number-to-string year)))
|
||||||
|
date_str))
|
||||||
|
|
||||||
|
(defun org-cv-utils--format-time-window (from-date to-date)
|
||||||
|
"Join date strings in a time window.
|
||||||
|
FROM-DATE -- TO-DATE
|
||||||
|
in case TO-DATE is nil return Present"
|
||||||
|
(concat
|
||||||
|
(org-cv-utils-org-timestamp-to-shortdate from-date)
|
||||||
|
" -- "
|
||||||
|
(if (not to-date) "Present"
|
||||||
|
(org-cv-utils-org-timestamp-to-shortdate to-date))))
|
||||||
|
|
||||||
|
(provide 'org-cv-utils)
|
||||||
|
;;; org-cv-utils ends here
|
21
ox-altacv.el
21
ox-altacv.el
|
@ -30,6 +30,7 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'cl-lib)
|
(require 'cl-lib)
|
||||||
(require 'ox-latex)
|
(require 'ox-latex)
|
||||||
|
(require 'org-cv-utils)
|
||||||
|
|
||||||
;; Install a default set-up for altacv export.
|
;; Install a default set-up for altacv export.
|
||||||
(unless (assoc "altacv" org-latex-classes)
|
(unless (assoc "altacv" org-latex-classes)
|
||||||
|
@ -188,18 +189,6 @@ holding export options."
|
||||||
"\\end{document}")))
|
"\\end{document}")))
|
||||||
|
|
||||||
|
|
||||||
(defun org-altacv-timestamp-to-shortdate (date_str)
|
|
||||||
"Format orgmode timestamp DATE_STR into a short form date.
|
|
||||||
|
|
||||||
e.g. <2002-08-12 Mon> => Aug 2012"
|
|
||||||
(let* ((abbreviate 't)
|
|
||||||
(dte (org-parse-time-string date_str))
|
|
||||||
(month (nth 4 dte))
|
|
||||||
(year (nth 5 dte)));;'(02 07 2015)))
|
|
||||||
(concat (calendar-month-name month abbreviate)
|
|
||||||
" "
|
|
||||||
(number-to-string year))))
|
|
||||||
|
|
||||||
(defun org-altacv--format-cventry (headline contents info)
|
(defun org-altacv--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
|
||||||
|
@ -209,15 +198,11 @@ as a communication channel."
|
||||||
(to-date (org-element-property :TO headline))
|
(to-date (org-element-property :TO headline))
|
||||||
(employer (org-element-property :EMPLOYER headline))
|
(employer (org-element-property :EMPLOYER headline))
|
||||||
(location (or (org-element-property :LOCATION headline) ""))
|
(location (or (org-element-property :LOCATION headline) ""))
|
||||||
(divider (if (org-export-last-sibling-p headline info) "" "\\divider")))
|
(divider (if (org-export-last-sibling-p headline info) "\n" "\\divider")))
|
||||||
(format "\n\\cvevent{%s}{%s}{%s}{%s}%s\n%s"
|
(format "\n\\cvevent{%s}{%s}{%s}{%s}%s\n%s"
|
||||||
title
|
title
|
||||||
employer
|
employer
|
||||||
(concat (org-altacv-timestamp-to-shortdate from-date)
|
(org-cv-utils--format-time-window from-date to-date)
|
||||||
" -- "
|
|
||||||
(if (not to-date)
|
|
||||||
"Present"
|
|
||||||
(org-moderncv-timestamp-to-shortdate to-date)))
|
|
||||||
location contents divider)))
|
location contents divider)))
|
||||||
|
|
||||||
|
|
||||||
|
|
18
ox-hugocv.el
18
ox-hugocv.el
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'ox-hugo)
|
(require 'ox-hugo)
|
||||||
|
(require 'org-cv-utils)
|
||||||
|
|
||||||
;;; User-Configurable Variables
|
;;; User-Configurable Variables
|
||||||
|
|
||||||
|
@ -54,17 +55,6 @@
|
||||||
:translate-alist '((headline . org-hugocv-headline)
|
:translate-alist '((headline . org-hugocv-headline)
|
||||||
(inner-template . org-hugocv-inner-template)))
|
(inner-template . org-hugocv-inner-template)))
|
||||||
|
|
||||||
(defun org-hugocv-timestamp-to-shortdate (date_str)
|
|
||||||
"Format orgmode timestamp DATE_STR into a short form date.
|
|
||||||
|
|
||||||
e.g. <2002-08-12 Mon> => Aug 2012"
|
|
||||||
(let* ((abbreviate 't)
|
|
||||||
(dte (org-parse-time-string date_str))
|
|
||||||
(month (nth 4 dte))
|
|
||||||
(year (nth 5 dte)));;'(02 07 2015)))
|
|
||||||
(concat (calendar-month-name month abbreviate)
|
|
||||||
" "
|
|
||||||
(number-to-string year))))
|
|
||||||
|
|
||||||
(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.
|
||||||
|
@ -90,11 +80,7 @@ as a communication channel."
|
||||||
(concat (make-string (+ loffset level) ?#) " " title)
|
(concat (make-string (+ loffset level) ?#) " " title)
|
||||||
employer
|
employer
|
||||||
location
|
location
|
||||||
(concat (org-hugocv-timestamp-to-shortdate from-date)
|
(org-cv-utils--format-time-window from-date to-date)
|
||||||
" -- "
|
|
||||||
(if (not to-date)
|
|
||||||
"Present"
|
|
||||||
(org-moderncv-timestamp-to-shortdate to-date)))
|
|
||||||
contents)))
|
contents)))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'cl-lib)
|
(require 'cl-lib)
|
||||||
(require 'ox-latex)
|
(require 'ox-latex)
|
||||||
|
(require 'org-cv-utils)
|
||||||
|
|
||||||
;; Install a default set-up for moderncv export.
|
;; Install a default set-up for moderncv export.
|
||||||
(unless (assoc "moderncv" org-latex-classes)
|
(unless (assoc "moderncv" org-latex-classes)
|
||||||
|
@ -178,18 +179,6 @@ holding export options."
|
||||||
"\\end{document}")))
|
"\\end{document}")))
|
||||||
|
|
||||||
|
|
||||||
(defun org-moderncv-timestamp-to-shortdate (date_str)
|
|
||||||
"Format orgmode timestamp DATE_STR into a short form date.
|
|
||||||
|
|
||||||
e.g. <2002-08-12 Mon> => Aug 2012"
|
|
||||||
(let* ((abbreviate 't)
|
|
||||||
(dte (org-parse-time-string date_str))
|
|
||||||
(month (nth 4 dte))
|
|
||||||
(year (nth 5 dte))) ;;'(02 07 2015)))
|
|
||||||
(concat (calendar-month-name month abbreviate)
|
|
||||||
" "
|
|
||||||
(number-to-string year))))
|
|
||||||
|
|
||||||
(defun org-moderncv--format-cventry (headline contents info)
|
(defun org-moderncv--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
|
||||||
|
@ -201,11 +190,7 @@ as a communication channel."
|
||||||
(location (or (org-element-property :LOCATION headline) ""))
|
(location (or (org-element-property :LOCATION headline) ""))
|
||||||
(note (or (org-element-property :NOTE headline) "")))
|
(note (or (org-element-property :NOTE headline) "")))
|
||||||
(format "\\cventry{\\textbf{%s}}{%s}{%s}{%s}{%s}{%s}\n"
|
(format "\\cventry{\\textbf{%s}}{%s}{%s}{%s}{%s}{%s}\n"
|
||||||
(concat (org-moderncv-timestamp-to-shortdate from-date)
|
(org-cv-utils--format-time-window from-date to-date)
|
||||||
" -- "
|
|
||||||
(if (not to-date)
|
|
||||||
"Present"
|
|
||||||
(org-moderncv-timestamp-to-shortdate to-date)))
|
|
||||||
title employer location note contents)))
|
title employer location note contents)))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue