summaryrefslogtreecommitdiff
path: root/.emacs
blob: 9037de1e110f5640c578b044f92621b4d97c1acd (plain)
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
149
;;; Emacs configuration for building a project

(require 'org)
(require 'ox-publish)
(require 'ox-latex)
;; (require 'org-webring)
(require 's)
(require 'simple-httpd)


(setq org-html-head-include-default-style nil)

(setq current-folder (file-truename "./"))

(defvar youtube-iframe-format
  ;; You may want to change your width and height.
  (concat "<iframe id=\"ivplayer\" type=\"text/html\""
          "src=\"https://youtube.host.w96k.dev/embed/%s\""
          " frameborder=\"0\""
          " allowfullscreen>%s</iframe>"))

(defvar local-video-format
  ;; You may want to change your width and height.
  (concat "<video controls>"
          "<source src=\"/public/videos/%s\"> Video are not supported </video>"))

(org-add-link-type
 "youtube"
 (lambda (handle)
   (browse-url
    (concat "https://invidiou.site/embed/"
            handle)))
 (lambda (path desc backend)
   (cl-case backend
     (html (format youtube-iframe-format
                   path (or desc "")))
     (latex (format "\href{%s}{%s}"
                    path (or desc "video"))))))

(org-add-link-type
 "video"
 (lambda (handle)
   (browse-url
    (concat "/"
            handle)))
 (lambda (path desc backend)
   (cl-case backend
     (html (format local-video-format
                   path (or desc "")))
     (latex (format "\href{%s}{%s}"
                    path (or desc "video"))))))

(setq org-publish-project-alist
      `(("blog"
         :components ("blog-content" "blog-styles")
         :base-directory current-folder)
        ("blog-styles"
         :base-directory ,(concat current-folder "public")
         :base-extension "jpg\\|webp\\|gif\\|svg\\|png\\|ico\\|css\\|txt\\|pdf\\|webm\\|mp4\\|mp3\\|flac\\|mov\\|html"
         :publishing-directory ,(concat current-folder "dist/public")
         :recursive t
         :publishing-function org-publish-attachment
         )
        ("blog-content"
         :base-directory ,(concat current-folder "content")
         :publishing-directory ,(concat current-folder "dist")
         :recursive t
         :publishing-function org-html-publish-to-html

         :html-doctype "html5"

         :with-title nil
         :with-author t
         :with-creator nil
         :with-date t
         :with-email t
         :with-footnotes t
         :html-preamble "
<div class=\"navbar\">
<a href=\"/\">~w96k</a>
<a href=\"/about.html\">About</a>
<a href=\"/articles.html\">Articles</a>
<a href=\"/digarden/\">Digital Garden</a>
<a href=\"/donate.html\">Donations</a>
</div>"

         :html-head "
<link rel=\"shortcut icon\" href=\"/public/favicon_w96k.ico\">
<link rel=\"stylesheet\" href=\"/public/css/custom.css\" type=\"text/css\"/>
"

         :html-container "article"
         :html-postamble "

      <p>w96k Ⓐ 2019-2022</p>

      <ul>
        <li>
          <a href=\"/digarden/20221023004637-errata.html\">
            Errata
          </a>
        </li>
        <li>
          <a href=\"/legal.html\">
            License
          </a>
        </li>
        <li>
          <a href=\"/sitemap.html\">
            Sitemap
          </a>
        </li>
     </ul>


    <p id=\"meta\">
      %C
    </p>"

         :section-numbers nil
         :with-sub-superscript nil

         ;; sitemap - list of blog articles
         :auto-sitemap t
         :sitemap-filename "sitemap.org"
         :sitemap-title "@w96k"
         :sitemap-sort-files chronologically)))

;; Don't ask for block evaluation
(setq org-confirm-babel-evaluate nil)

;; Set output folder
(setq httpd-root (concat current-folder "/dist/"))

;; Fix image width
(setq org-image-actual-width nil)

;; PDF output settings
(setq org-latex-listings 'minted)
(setq org-latex-tables-centered nil)
(add-to-list 'org-latex-packages-alist '("russian" "babel"))
(add-to-list 'org-latex-packages-alist '("" "minted"))
(add-to-list 'org-latex-packages-alist '("" "nopageno"))
(add-to-list 'org-latex-packages-alist '("utf8x" "inputenc"))
(add-to-list 'org-latex-packages-alist '("a4paper, margin=0.75in" "geometry"))

(setq org-src-fontify-natively t)