-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.el
executable file
·148 lines (123 loc) · 4.11 KB
/
publish.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
;;; publish.el --- Build fluxharmonic.com
;; Copyright (C) 2021 David Wilson <david@fluxharmonic.com>
;; Author: David Wilson <david@fluxharmonic.com>
;; Maintainer: David Wilson <david@fluxharmonic.com>
;; URL: https://github.com/FluxHarmonic/FluxHarmonic.github.io
;; Version: 0.0.1
;; Package-Requires: ((emacs "26.1"))
;; Keywords: hypermedia, blog, feed, rss
;; 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 Docs License as published by
;; the Free Software Foundation, either version 3 of the License, 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 Docs License for more details.
;;
;; You should have received a copy of the GNU General Docs License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;; Usage:
;; emacs -Q --script ./publish.el
;; Make sure to set PROD=true to generate for the real site!
;; Initialize package sources
(require 'package)
;; Set the package installation directory so that packages aren't stored in the
;; ~/.emacs.d/elpa path.
(setq package-user-dir (expand-file-name "./.packages"))
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("elpa" . "https://elpa.gnu.org/packages/")))
;; Initialize the package system
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
;; Install and load weblorg
(unless (package-installed-p 'weblorg)
(package-install 'weblorg))
(require 'weblorg)
(defvar yt-iframe-format
;; TODO: Create CSS Classes for responsive video display
(concat "<div class=\"embed-responsive embed-responsive-16by9\">"
" <iframe class=\"embed-responsive-item\" src=\"https://www.youtube.com/embed/%s\" allowfullscreen></iframe>"
" </div>"))
(org-link-set-parameters
"yt"
:follow
(lambda (handle)
(browse-url
(concat "https://www.youtube.com/watch?v="
handle)))
:export
(lambda (path desc backend channel)
(when (eq backend 'html)
(format yt-iframe-format
path (or desc "")))))
;; Configure the site
(setq flux-site (weblorg-site
:name "flux"
:base-url (if (string= (getenv "PROD") "true")
"https://fluxharmonic.com"
"http://localhost:8080")))
;; Customize ox-html export
(setq org-export-with-toc nil
org-export-with-section-numbers nil)
;; Home page
(weblorg-route
:name "index"
:site flux-site
:input-pattern "content/index.org"
:template "post.html"
:output "public/index.html"
:url "/")
;; Live page
(weblorg-route
:name "live"
:site flux-site
:input-pattern "content/live.org"
:template "post.html"
:output "public/live/index.html"
:url "/live/")
;; Misc pages
(weblorg-route
:name "pages"
:site flux-site
:input-pattern "content/pages/*.org"
:template "post.html"
:output "public/{{ slug }}/index.html"
:url "/{{ slug }}/")
;; Live streams
(weblorg-route
:name "streams"
:site flux-site
:input-pattern "content/live-streams/*.org"
:template "post.html"
:output "public/live-streams/{{ slug }}/index.html"
:url "/live-streams/{{ slug }}/")
;; Live streams index page
(weblorg-route
:name "streams-index"
:site flux-site
:input-pattern "content/live-streams/*.org"
:input-aggregate #'weblorg-input-aggregate-all-desc
:template "post-index.html"
:output "public/live-streams/index.html"
:url "/live-streams/index.html")
;; Live streams RSS feed
(weblorg-route
:name "streams-feed"
:input-pattern "content/live-streams/*.org"
:input-aggregate #'weblorg-input-aggregate-all-desc
:template "feed.xml"
:output "public/live-streams/rss.xml"
:url "public/live-streams/rss.xml")
;; Static site assets like images, fonts, etc
(weblorg-copy-static
:output "public/static/{{ file }}"
:url "/static/{{ file }}"
:site flux-site)
;; Export the site
(weblorg-export)
;; Copy the CNAME file
(copy-file "CNAME" "public/CNAME" t)