summaryrefslogtreecommitdiffstats
path: root/site/cleopatra/org.org
diff options
context:
space:
mode:
authorThomas Letan <lthms@soap.coffee>2021-03-28 00:03:41 +0100
committerThomas Letan <lthms@soap.coffee>2021-03-28 14:19:29 +0200
commit495f9db0606b0ed09e6fac59dc32de4cdc8c0087 (patch)
tree82ea5c5e247c664de247a0f3818f393ffdb00067 /site/cleopatra/org.org
parentRelease of coqffi 1.0.0~beta4 (diff)
2021 Spring redesign
Diffstat (limited to 'site/cleopatra/org.org')
-rw-r--r--site/cleopatra/org.org183
1 files changed, 103 insertions, 80 deletions
diff --git a/site/cleopatra/org.org b/site/cleopatra/org.org
index acfd432..829272b 100644
--- a/site/cleopatra/org.org
+++ b/site/cleopatra/org.org
@@ -1,54 +1,30 @@
-* Author Guidelines
-
-* Under the Hood
+#+TITLE: Authoring Content with ~org-mode~
-#+BEGIN_SRC emacs-lisp :tangle scripts/packages.el
-(use-package lua-mode :ensure t :defer t)
-(use-package rust-mode :ensure t :defer t)
-(use-package sass-mode :ensure t :defer t)
-(use-package haskell-mode :ensure t :defer t)
-(use-package toml-mode :ensure t :defer t)
-(use-package json-mode :ensure t :defer t)
-(use-package proof-general :ensure t :defer t)
-(use-package tuareg :ensure t :defer t)
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp :tangle scripts/export-org.el
-(cleopatra:configure)
+#+SERIES: ../cleopatra.html
+#+SERIES_PREV: ./coq.html
+#+SERIES_NEXT: ./literate-programming.html
-(setq org-html-doctype "html5")
-(setq org-html-html5-fancy t)
-
-(org-babel-do-load-languages
- 'org-babel-load-languages
- '((shell . t)
- (dot . t)))
+#+BEGIN_EXPORT html
+<nav id="generate-toc"></nav>
+<div id="history">site/cleopatra/org.org</div>
+#+END_EXPORT
-(setq org-html-htmlize-output-type nil)
-(setq org-export-with-toc nil)
-
-(add-to-list 'org-entities-user
- '("im" "\\(" nil "<span class=\"imath\">" "" "" ""))
-(add-to-list 'org-entities-user
- '("mi" "\\)" nil "</span>" "" "" ""))
+* Author Guidelines
-(org-html-export-to-html nil nil nil t)
-#+END_SRC
+* Implementation
-#+BEGIN_SRC makefile :tangle org.mk
+#+begin_src makefile :tangle org.mk
EMACS := cleopatra-emacs
-ORG_POSTS := $(shell find site/ -name "*.org")
-ORG_HTML := $(ORG_POSTS:.org=.html)
+ORG_IN := $(shell find site/ -name "*.org")
+ORG_OUT := $(ORG_IN:.org=.html)
org-prebuild : .emacs
-org-build : ${ORG_HTML}
+org-build : ${ORG_OUT}
-theme-build : site/style/org.sass
soupault-build : org-build
-org-build : literate-programming-build
-ARTIFACTS += ${ORG_HTML}
+ARTIFACTS += ${ORG_OUT}
CONFIGURE += .emacs
EXPORT := --batch \
@@ -68,44 +44,91 @@ INIT := --batch --load="${ROOT}/scripts/packages.el" \
.emacs org.mk
@cleopatra echo Exporting "$*.org"
@${EMACS} $< ${EXPORT}
-#+END_SRC
-
-#+BEGIN_SRC sass :tangle site/style/org.sass
-#text-footnotes
- max-width : 35rem
-
-.footpara
- display: inline
- margin-left: .2em
-
-.section-number-2:after,
-.section-number-3:after
- content: ". "
-
-.section-number-4,
-.section-number-5,
-.section-number-6
- display: none
-
-dl
- dd p
- margin-top: 0
-
-.footnotes
- font-size : 1rem
-
-.org-literate-programming
- .org-src-tangled-to:before
- content: "\f054"
- font : normal normal normal 11px/1 ForkAwesome
-
- .org-src-tangled-to,
- padding-left : 2rem
-
- .org-src-tangled-to,
- .org-src-name
- font-family : 'Fira Code', monospace
- font-size : 70%
- font-weight: bold
- color : #444
-#+END_SRC
+#+end_src
+
+#+begin_src emacs-lisp :tangle scripts/packages.el
+(use-package ox-tufte :ensure t)
+#+end_src
+
+#+begin_src emacs-lisp :tangle scripts/export-org.el
+(cleopatra:configure)
+
+(org-babel-do-load-languages
+ 'org-babel-load-languages
+ '((dot . t)
+ (shell . t)))
+
+(setq org-export-with-toc nil
+ org-html-htmlize-output-type nil
+ org-export-with-section-numbers nil)
+
+(add-to-list 'org-entities-user
+ '("im" "\\(" nil "<span class=\"imath\">" "" "" ""))
+(add-to-list 'org-entities-user
+ '("mi" "\\)" nil "</span>" "" "" ""))
+
+(defun with-keyword (keyword k)
+ "Look-up for keyword KEYWORD, and call continuation K with its value."
+ (pcase (org-collect-keywords `(,keyword))
+ (`((,keyword . ,kw))
+ (when kw (funcall k (string-join kw " "))))))
+
+(defun get-keyword (keyword)
+ "Look-up for keyword KEYWORD, and returns its value"
+ (with-keyword keyword (lambda (x) x)))
+
+(defun get-org-title (path)
+ "Fetch the title of an Org file whose path is PATH."
+ (with-temp-buffer
+ (find-file-read-only path)
+ (get-keyword "TITLE")))
+
+(defun insert-title ()
+ "Insert the title of the article."
+ (with-keyword
+ "TITLE"
+ (lambda (title)
+ (insert
+ (format "\n\n@@html:<h1>@@ %s @@html:</h1>@@\n\n" title)))))
+
+(defun insert-series ()
+ "Insert the series root link."
+ (with-keyword
+ "SERIES"
+ (lambda (series)
+ (insert "\n\n#+attr_html: :class series\n")
+ (insert series))))
+
+(defun insert-series-prev ()
+ "Insert the series previous article link."
+ (with-keyword
+ "SERIES_PREV"
+ (lambda (series-prev)
+ (insert "\n\n#+attr_html: :class series-prev\n")
+ (insert series-prev))))
+
+(defun insert-series-next ()
+ "Insert the series next article link."
+ (with-keyword
+ "SERIES_NEXT"
+ (lambda (series-next)
+ (insert "\n\n#+attr_html: :class series-next\n")
+ (insert series-next))))
+
+(defun insert-nav ()
+ "Insert the navigation links."
+ (when (get-keyword "SERIES")
+ (insert "\n\n#+begin_nav\n")
+ (insert-series)
+ (insert-series-prev)
+ (insert-series-next)
+ (insert "\n\n#+end_nav\n")))
+
+(beginning-of-buffer)
+(insert-nav)
+(insert-title)
+
+(let ((outfile (org-export-output-file-name ".html"))
+ (org-html-footnotes-section "<!-- %s --><!-- %s -->"))
+ (org-export-to-file 'tufte-html outfile nil nil nil t))
+#+end_src