Browse Source

Finish up the preamble section and tag/category collection

org
Sameer Rahmani 2 weeks ago
parent
commit
dc4b171c16
13 changed files with 306 additions and 968 deletions
  1. +2
    -1
      .gitignore
  2. +1
    -0
      Makefile
  3. +194
    -17
      build.el
  4. +0
    -800
      build/html/assets/styles/dark.css
  5. +0
    -20
      build/html/assets/styles/main.css
  6. +0
    -63
      build/html/index.html
  7. +0
    -32
      build/html/sitemap.html
  8. +1
    -1
      config.org
  9. +82
    -11
      lisp/ox-template.el
  10. +9
    -15
      orgs/index.org
  11. +5
    -0
      orgs/sitemap.inc
  12. +11
    -7
      templates/blog.html
  13. +1
    -1
      templates/tags.html

+ 2
- 1
.gitignore View File

@@ -4,4 +4,5 @@ _site
_tmp/
*~
.cask/
*.elc
*.elc
build/

+ 1
- 0
Makefile View File

@@ -1,5 +1,6 @@
clean:
rm -rf build
rm -rf ./orgs/index.org ./orgs/categories/index.org ./orgs/tags/index.org
rm -rf `find . -iname "*~"`

dev-build:


+ 194
- 17
build.el View File

@@ -5,10 +5,14 @@
;;; Commentary:
;;; Code:
(require 'org)
(require 'seq)
(require 'ox-html)
(require 'ox-latex)
(require 'ox-publish)
(require 'dracula-theme)
(require 'lisp/ox-template)
(require 'lisp/utils)


(setq debug-on-error t)

@@ -21,15 +25,116 @@
(defvar project-root nil
"Root directory of the website source code.")


(defvar orgs-files-dir "/orgs/"
"Path to the directory containing all the renderable org files.")


(defun from-root (path)
"Return the full path of the given PATH in the project root."
(concat project-root path))


(defun prod-p ()
"Return non-nil if we're in development mode."
(when (getenv "LXHOME_PROD")
t))
(defun all-org-files ()
"Return a list of all the org files in the orgs directory."
(mapcar (lambda (x) x)
(split-string
(shell-command-to-string (format "find %s -iname \"*.org\"" org-directory))
"\n" t)))

(comment
(all-org-files))


(defun get-all-tags ()
"Return a list of all the tags in the org files."
(seq-reduce
;; all-tags is in (tags . tags->files) form
(lambda (all-tags file)
(with-temp-buffer
(insert-file-contents file)
(let ((tags (mapcar #'car (org-get-buffer-tags))))
(seq-reduce
(lambda (result tag)
(let ((tag-list (car result))
(tag->file (cdr result)))
(cons
;; Tag list
(if (member tag tag-list) tag-list (sort (cons tag tag-list) 'string<))
;; tag->file
(cons (cons tag
;; Current value of the the given tag (all the files
;; that contain that tag)
(append (list file) (cdr (assoc tag tag->file))))
tag->file))))
tags
all-tags))))
(all-org-files)
'()))


(defun get-all-posts ()
"Return all the post org files.
Not pages."
(let ((files (all-org-files)))
(seq-reduce
(lambda (result file)
(let ((is-page? (string= (get-file-global-props file "PAGE") "true")))
(if (not is-page?)
;; It's a post
(cons
(list
;; This is not effecient since we parse the file
;; on each query, but who cares :D ?
(->epoch (get-file-global-props file "DATE"))
(get-file-global-props file "TITLE")
(replace-regexp-in-string "\\.org" ".html"
(file-name-nondirectory file)))
result)
result)))
files
'())))


(defun get-all-sorted-posts ()
"Return all posts in sorted order."
(sort
(get-all-posts)
(lambda (x y) (> (car x) (car y)))))


(comment
(get-all-sorted-posts))


(defun get-all-categories ()
"Return all the categories of the org files."
(seq-reduce
;; all-cats is in (cats . cat->files) form
(lambda (all-cats file)
(let ((is-page? (string= (get-file-global-props file "PAGE") "true"))
(cat (get-file-global-props file "CATEGORY"))
(cat-list (car all-cats))
(cat->file (cdr all-cats)))

(if (not is-page?)
(cons
;; Category list
(if (member cat cat-list) cat-list (sort (cons cat cat-list) 'string<))
;; cat->file
(cons (cons cat
;; Current value of the the given cat (all the files
;; under that category)
(append (list file) (cdr (assoc cat cat->file))))
cat->file))
all-cats)))
(all-org-files)
'()))


(comment
(get-file-global-props "./orgs/essays/serene-blah.org" "CATEGORY")
(get-all-categories))


(defun extra-headers ()
@@ -38,6 +143,42 @@
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"))


(defun category-org-list ()
"Return a list of links to the categories in org format."
(let ((categories (get-all-categories)))
(mapconcat
(lambda (cat)
(let ((count (length (cdr (assoc cat (cdr categories))))))
(format " - [[//categories/%s.html][%s(%s)]]" cat cat count)))
(car categories)
"\n")))


(defun tags-org-list ()
"Return a list of links to the tags in org format."
(let ((tags (get-all-tags)))
(mapconcat
(lambda (tag)
(let ((count (length (cdr (assoc tag (cdr tags))))))
(format " - [[//tags/%s.html][%s(%s)]]" tag tag count)))
(car tags)
"\n")))


(defun latest-org-list (base-url)
"Return a list of links (using BASE-URL) to the tags in org format."
(let ((posts (get-all-sorted-posts)))
(mapconcat
(lambda (post)
(format " - [[%s/essays/%s][%s]]" base-url (nth 2 post) (nth 1 post)))
posts
"\n")))


(comment
(latest-org-list))


(defun main ()
"The entry point to the build script."

@@ -46,37 +187,63 @@
(load-theme 'dracula t)
(enable-theme 'dracula)


(setq project-root (car command-line-args-left))

;; We will use the org-agenda to extract all the tags
(setq org-directory (from-root orgs-files-dir))
(setq org-agenda-files (all-org-files))

(setf user-full-name author-name)
(setf user-mail-address author-email)


;; Disable default header links (top, next)
(setf org-html-home/up-format "")
(setf org-html-link-up "")
(setf org-html-link-home "")
(setf org-html-scripts "")

(let ((html-build-dir (from-root "/build/html/")))
(let ((build-dir (from-root "/build/"))
(base-url (if (prod-p) "https://lxsameer.com" "http://localhost:3003")))
(copy-template (from-root "/templates/index.org")
(from-root "/orgs/index.org")
(latest-org-list base-url))

(copy-template (from-root "/templates/categories.org")
(from-root "/orgs/categories/index.org")
(category-org-list))

(copy-template (from-root "/templates/tags.org")
(from-root "/orgs/tags/index.org")
(tags-org-list))

(setq org-html-preamble #'preamble-fn)


(setq org-publish-project-alist
`(("lxsameer.com"
:base-directory ,(from-root "/orgs")
:root-directory ,project-root
:recursive t
:base-extension "org"
:publishing-directory ,(from-root "/build/html")
:publishing-directory ,build-dir
;; Exclude the blog archive index autogenerated below
;; Note that the regexp is relative to :base-directory
;; :exclude "^index.org"
:section-numbers nil
:with-author t
:with-drawers t
:with-properties t
:with-tags t
:with-timestamps t
:with-toc nil
:with-date nil
:base-url ,(if (prod-p) "https://lxsameer.com" "http://localhost:3003")
:base-url ,base-url
:html-link-home "/"
:html-head-extra ,(extra-headers)
:html-template ,(from-root "/templates/blog.html")
:html-headline-template ,(from-root "/templates/tags.html")
:html-page-preamble-template ,(from-root "/templates/page-preamble.html")
:html-post-preabmle-template ,(from-root "/templates/post-preamble.html")
:html-tags-template ,(from-root "/templates/tags.html")
:publishing-function org-html-publish-to-templated-html
:auto-sitemap t
:htmlized-source t
@@ -84,12 +251,14 @@
:sitemap-style list
:sitemap-title "lxsameer's nest"
:sitemap-filename "sitemap.inc"
:sitemap-sort-files anti-chronologically)
:sitemap-sort-files anti-chronologically
:html-format-headline-function headline-format
:makeindex nil)

("org->html"
:base-directory ,(from-root "/orgs")
:base-extension "org"
:publishing-directory ,html-build-dir
:publishing-directory ,build-dir
:recursive t
:publishing-function org-html-publish-to-html
:headline-levels 4
@@ -101,18 +270,26 @@
:html-head-extra ,(extra-headers)
:makeindex nil)

("pdfs"
:base-directory ,(from-root "/orgs")
:root-directory ,project-root
:recursive t
:base-extension "org"
:publishing-directory ,build-dir
:publishing-function)


("statics"
:base-directory ,project-root
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|svg"
:publishing-directory ,html-build-dir
:publishing-directory ,build-dir
:recursive t
:publishing-function org-publish-attachment)
("build" :components ("lxsameer.com" "statics")))))

(org-publish-project "build" t nil)
(message "Build complete."))
("build" :components ("lxsameer.com" "statics"))))

(org-publish-project "build" t nil))

(message "Build complete."))


(provide 'build)


+ 0
- 800
build/html/assets/styles/dark.css View File

@@ -1,800 +0,0 @@
/**
* Forced dark theme version
*/

:root {
--background-body: #202b38;
--background: #161f27;
--background-alt: #1a242f;
--selection: #1c76c5;
--text-main: #dbdbdb;
--text-bright: #fff;
--text-muted: #a9b1ba;
--links: #41adff;
--focus: #0096bfab;
--border: #526980;
--code: #ffbe85;
--animation-duration: 0.1s;
--button-hover: #324759;
--scrollbar-thumb: var(--button-hover);
--scrollbar-thumb-hover: rgb(65, 92, 115);
--form-placeholder: #a9a9a9;
--form-text: #fff;
--variable: #d941e2;
--highlight: #efdb43;
--select-arrow: url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23efefef'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E");
}

html {
scrollbar-color: #324759 #202b38;
scrollbar-color: var(--scrollbar-thumb) var(--background-body);
scrollbar-width: thin;
}

body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
line-height: 1.4;
max-width: 800px;
margin: 20px auto;
padding: 0 10px;
word-wrap: break-word;
color: #dbdbdb;
color: var(--text-main);
background: #202b38;
background: var(--background-body);
text-rendering: optimizeLegibility;
}

button {
transition:
background-color 0.1s linear,
border-color 0.1s linear,
color 0.1s linear,
box-shadow 0.1s linear,
transform 0.1s ease;
transition:
background-color var(--animation-duration) linear,
border-color var(--animation-duration) linear,
color var(--animation-duration) linear,
box-shadow var(--animation-duration) linear,
transform var(--animation-duration) ease;
}

input {
transition:
background-color 0.1s linear,
border-color 0.1s linear,
color 0.1s linear,
box-shadow 0.1s linear,
transform 0.1s ease;
transition:
background-color var(--animation-duration) linear,
border-color var(--animation-duration) linear,
color var(--animation-duration) linear,
box-shadow var(--animation-duration) linear,
transform var(--animation-duration) ease;
}

textarea {
transition:
background-color 0.1s linear,
border-color 0.1s linear,
color 0.1s linear,
box-shadow 0.1s linear,
transform 0.1s ease;
transition:
background-color var(--animation-duration) linear,
border-color var(--animation-duration) linear,
color var(--animation-duration) linear,
box-shadow var(--animation-duration) linear,
transform var(--animation-duration) ease;
}

h1 {
font-size: 2.2em;
margin-top: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
margin-bottom: 12px;
margin-top: 24px;
}

h1 {
color: #fff;
color: var(--text-bright);
}

h2 {
color: #fff;
color: var(--text-bright);
}

h3 {
color: #fff;
color: var(--text-bright);
}

h4 {
color: #fff;
color: var(--text-bright);
}

h5 {
color: #fff;
color: var(--text-bright);
}

h6 {
color: #fff;
color: var(--text-bright);
}

strong {
color: #fff;
color: var(--text-bright);
}

h1,
h2,
h3,
h4,
h5,
h6,
b,
strong,
th {
font-weight: 600;
}

q::before {
content: none;
}

q::after {
content: none;
}

blockquote {
border-left: 4px solid #0096bfab;
border-left: 4px solid var(--focus);
margin: 1.5em 0;
padding: 0.5em 1em;
font-style: italic;
}

q {
border-left: 4px solid #0096bfab;
border-left: 4px solid var(--focus);
margin: 1.5em 0;
padding: 0.5em 1em;
font-style: italic;
}

blockquote > footer {
font-style: normal;
border: 0;
}

blockquote cite {
font-style: normal;
}

address {
font-style: normal;
}

a[href^='mailto\:']::before {
content: '📧 ';
}

a[href^='tel\:']::before {
content: '📞 ';
}

a[href^='sms\:']::before {
content: '💬 ';
}

mark {
background-color: #efdb43;
background-color: var(--highlight);
border-radius: 2px;
padding: 0 2px 0 2px;
color: #000;
}

button,
select,
input[type='submit'],
input[type='button'],
input[type='checkbox'],
input[type='range'],
input[type='radio'] {
cursor: pointer;
}

input:not([type='checkbox']):not([type='radio']),
select {
display: block;
}

input {
color: #fff;
color: var(--form-text);
background-color: #161f27;
background-color: var(--background);
font-family: inherit;
font-size: inherit;
margin-right: 6px;
margin-bottom: 6px;
padding: 10px;
border: none;
border-radius: 6px;
outline: none;
}

button {
color: #fff;
color: var(--form-text);
background-color: #161f27;
background-color: var(--background);
font-family: inherit;
font-size: inherit;
margin-right: 6px;
margin-bottom: 6px;
padding: 10px;
border: none;
border-radius: 6px;
outline: none;
}

textarea {
color: #fff;
color: var(--form-text);
background-color: #161f27;
background-color: var(--background);
font-family: inherit;
font-size: inherit;
margin-right: 6px;
margin-bottom: 6px;
padding: 10px;
border: none;
border-radius: 6px;
outline: none;
}

select {
color: #fff;
color: var(--form-text);
background-color: #161f27;
background-color: var(--background);
font-family: inherit;
font-size: inherit;
margin-right: 6px;
margin-bottom: 6px;
padding: 10px;
border: none;
border-radius: 6px;
outline: none;
}

input[type='checkbox'],
input[type='radio'] {
height: 1em;
width: 1em;
}

input[type='radio'] {
border-radius: 100%;
}

input {
vertical-align: top;
}

label {
vertical-align: middle;
margin-bottom: 4px;
display: inline-block;
}

input:not([type='checkbox']):not([type='radio']),
input[type='range'],
select,
button,
textarea {
-webkit-appearance: none;
}

textarea {
display: block;
margin-right: 0;
box-sizing: border-box;
resize: vertical;
}

textarea:not([cols]) {
width: 100%;
}

textarea:not([rows]) {
min-height: 40px;
height: 140px;
}

select {
background: #161f27 url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23efefef'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E") calc(100% - 12px) 50% / 12px no-repeat;
background: var(--background) var(--select-arrow) calc(100% - 12px) 50% / 12px no-repeat;
padding-right: 35px;
}

select::-ms-expand {
display: none;
}

select[multiple] {
padding-right: 10px;
background-image: none;
overflow-y: auto;
}

button,
input[type='submit'],
input[type='button'] {
padding-right: 30px;
padding-left: 30px;
}

button:hover {
background: #324759;
background: var(--button-hover);
}

input[type='submit']:hover {
background: #324759;
background: var(--button-hover);
}

input[type='button']:hover {
background: #324759;
background: var(--button-hover);
}

input:focus {
box-shadow: 0 0 0 2px #0096bfab;
box-shadow: 0 0 0 2px var(--focus);
}

select:focus {
box-shadow: 0 0 0 2px #0096bfab;
box-shadow: 0 0 0 2px var(--focus);
}

button:focus {
box-shadow: 0 0 0 2px #0096bfab;
box-shadow: 0 0 0 2px var(--focus);
}

textarea:focus {
box-shadow: 0 0 0 2px #0096bfab;
box-shadow: 0 0 0 2px var(--focus);
}

input[type='checkbox']:active,
input[type='radio']:active,
input[type='submit']:active,
input[type='button']:active,
input[type='range']:active,
button:active {
transform: translateY(2px);
}

input:disabled,
select:disabled,
button:disabled,
textarea:disabled {
cursor: not-allowed;
opacity: 0.5;
}

::-moz-placeholder {
color: #a9a9a9;
color: var(--form-placeholder);
}

:-ms-input-placeholder {
color: #a9a9a9;
color: var(--form-placeholder);
}

::-ms-input-placeholder {
color: #a9a9a9;
color: var(--form-placeholder);
}

::placeholder {
color: #a9a9a9;
color: var(--form-placeholder);
}

fieldset {
border: 1px #0096bfab solid;
border: 1px var(--focus) solid;
border-radius: 6px;
margin: 0;
margin-bottom: 12px;
padding: 10px;
}

legend {
font-size: 0.9em;
font-weight: 600;
}

input[type='range'] {
margin: 10px 0;
padding: 10px 0;
background: transparent;
}

input[type='range']:focus {
outline: none;
}

input[type='range']::-webkit-slider-runnable-track {
width: 100%;
height: 9.5px;
-webkit-transition: 0.2s;
transition: 0.2s;
background: #161f27;
background: var(--background);
border-radius: 3px;
}

input[type='range']::-webkit-slider-thumb {
box-shadow: 0 1px 1px #000, 0 0 1px #0d0d0d;
height: 20px;
width: 20px;
border-radius: 50%;
background: #526980;
background: var(--border);
-webkit-appearance: none;
margin-top: -7px;
}

input[type='range']:focus::-webkit-slider-runnable-track {
background: #161f27;
background: var(--background);
}

input[type='range']::-moz-range-track {
width: 100%;
height: 9.5px;
-moz-transition: 0.2s;
transition: 0.2s;
background: #161f27;
background: var(--background);
border-radius: 3px;
}

input[type='range']::-moz-range-thumb {
box-shadow: 1px 1px 1px #000, 0 0 1px #0d0d0d;
height: 20px;
width: 20px;
border-radius: 50%;
background: #526980;
background: var(--border);
}

input[type='range']::-ms-track {
width: 100%;
height: 9.5px;
background: transparent;
border-color: transparent;
border-width: 16px 0;
color: transparent;
}

input[type='range']::-ms-fill-lower {
background: #161f27;
background: var(--background);
border: 0.2px solid #010101;
border-radius: 3px;
box-shadow: 1px 1px 1px #000, 0 0 1px #0d0d0d;
}

input[type='range']::-ms-fill-upper {
background: #161f27;
background: var(--background);
border: 0.2px solid #010101;
border-radius: 3px;
box-shadow: 1px 1px 1px #000, 0 0 1px #0d0d0d;
}

input[type='range']::-ms-thumb {
box-shadow: 1px 1px 1px #000, 0 0 1px #0d0d0d;
border: 1px solid #000;
height: 20px;
width: 20px;
border-radius: 50%;
background: #526980;
background: var(--border);
}

input[type='range']:focus::-ms-fill-lower {
background: #161f27;
background: var(--background);
}

input[type='range']:focus::-ms-fill-upper {
background: #161f27;
background: var(--background);
}

a {
text-decoration: none;
color: #41adff;
color: var(--links);
}

a:hover {
text-decoration: underline;
}

code {
background: #161f27;
background: var(--background);
color: #ffbe85;
color: var(--code);
padding: 2.5px 5px;
border-radius: 6px;
font-size: 1em;
}

samp {
background: #161f27;
background: var(--background);
color: #ffbe85;
color: var(--code);
padding: 2.5px 5px;
border-radius: 6px;
font-size: 1em;
}

time {
background: #161f27;
background: var(--background);
color: #ffbe85;
color: var(--code);
padding: 2.5px 5px;
border-radius: 6px;
font-size: 1em;
}

pre > code {
padding: 10px;
display: block;
overflow-x: auto;
}

var {
color: #d941e2;
color: var(--variable);
font-style: normal;
font-family: monospace;
}

kbd {
background: #161f27;
background: var(--background);
border: 1px solid #526980;
border: 1px solid var(--border);
border-radius: 2px;
color: #dbdbdb;
color: var(--text-main);
padding: 2px 4px 2px 4px;
}

img,
video {
max-width: 100%;
height: auto;
}

hr {
border: none;
border-top: 1px solid #526980;
border-top: 1px solid var(--border);
}

table {
border-collapse: collapse;
margin-bottom: 10px;
width: 100%;
table-layout: fixed;
}

table caption {
text-align: left;
}

td,
th {
padding: 6px;
text-align: left;
vertical-align: top;
word-wrap: break-word;
}

thead {
border-bottom: 1px solid #526980;
border-bottom: 1px solid var(--border);
}

tfoot {
border-top: 1px solid #526980;
border-top: 1px solid var(--border);
}

tbody tr:nth-child(even) {
background-color: #1a242f;
background-color: var(--background-alt);
}

::-webkit-scrollbar {
height: 10px;
width: 10px;
}

::-webkit-scrollbar-track {
background: #161f27;
background: var(--background);
border-radius: 6px;
}

::-webkit-scrollbar-thumb {
background: #324759;
background: var(--scrollbar-thumb);
border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
background: rgb(65, 92, 115);
background: var(--scrollbar-thumb-hover);
}

::-moz-selection {
background-color: #1c76c5;
background-color: var(--selection);
color: #fff;
color: var(--text-bright);
}

::selection {
background-color: #1c76c5;
background-color: var(--selection);
color: #fff;
color: var(--text-bright);
}

details {
display: flex;
flex-direction: column;
align-items: flex-start;
background-color: #1a242f;
background-color: var(--background-alt);
padding: 10px 10px 0;
margin: 1em 0;
border-radius: 6px;
overflow: hidden;
}

details[open] {
padding: 10px;
}

details > :last-child {
margin-bottom: 0;
}

details[open] summary {
margin-bottom: 10px;
}

summary {
display: list-item;
background-color: #161f27;
background-color: var(--background);
padding: 10px;
margin: -10px -10px 0;
cursor: pointer;
outline: none;
}

summary:hover,
summary:focus {
text-decoration: underline;
}

details > :not(summary) {
margin-top: 0;
}

summary::-webkit-details-marker {
color: #dbdbdb;
color: var(--text-main);
}

footer {
border-top: 1px solid #526980;
border-top: 1px solid var(--border);
padding-top: 10px;
color: #a9b1ba;
color: var(--text-muted);
}

body > footer {
margin-top: 40px;
}

@media print {
body,
pre,
code,
summary,
details,
button,
input,
textarea {
background-color: #fff;
}

button,
input,
textarea {
border: 1px solid #000;
}

body,
h1,
h2,
h3,
h4,
h5,
h6,
pre,
code,
button,
input,
textarea,
footer,
summary,
strong {
color: #000;
}

summary::marker {
color: #000;
}

summary::-webkit-details-marker {
color: #000;
}

tbody tr:nth-child(even) {
background-color: #f2f2f2;
}

a {
color: #00f;
text-decoration: underline;
}
}

/*# sourceMappingURL=dark.css.map */

+ 0
- 20
build/html/assets/styles/main.css View File

@@ -1,20 +0,0 @@
.row {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
}

body {
margin: 20px auto;
max-width: 800px;
padding: 0 10px;
background: var(--background-body);
}


pre.src {
background: #1a242f;
padding: 10px 20px;
border-radius: 2px;
}

+ 0
- 63
build/html/index.html View File

@@ -1,63 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://localhost:3003//html/assets/styles/dark.css?1">
<link rel="stylesheet" href="http://localhost:3003/html/assets/styles/main.css?1">
</head>
<body>

<header>
<h1>lxsameer's nest</h1>
<nav>
<a href="#">HOME</a> | <a href="#">GPG</a>
</nav>
</header>

<div id="content">
<div class="column" id="outline-container-org9b85153" class="outline-2">
<h2 id="org9b85153">Welcome&#xa0;&#xa0;&#xa0;<div class="tags">
<h5>(ABD BD)</h5>
</div>
</h2>
<div class="outline-text-2" id="text-org9b85153">
<p>
blha bbasd asds asd a asd <code>asdasd</code> somer `asdasd` sadasd <b>asdasD</b> asdasd <i>asdasd</i> asdasd.
ads ad asd asd as dasd asd
</p>
<ul class="org-ul">
<li>list a</li>
<li class="off"><code>[&#xa0;]</code> asdasdasd</li>
<li class="on"><code>[X]</code> asdasd</li>
</ul>
</div>
<div id="outline-container-orgc886b6f" class="outline-3">
<h3 id="orgc886b6f"><span class="todo TODO">TODO</span> asdasdasdsad&#xa0;&#xa0;&#xa0;<div class="tags">
<h5>(ABD)</h5>
</div>
</h3>
<div class="outline-text-3" id="text-orgc886b6f">
<div class="org-src-container">
<pre class="src src-java" id="orgb44f00d"><span style="color: #ff00ff; font-weight: bold;">class</span> <span style="color: brightmagenta;">Blah</span>() {
<span style="color: brightmagenta;">int</span> <span style="color: #00ff00; font-weight: bold;">main</span>() {
<span style="color: #ff00ff; font-weight: bold;">return</span> 0;
}
}
</pre>
</div>
</div>
</div>
</div class="column">

</div>

<footer>
<span>© 2010-2021 Sameer Rahmani</span><br/>
<span>Built with <a href="https://www.gnu.org/software/emacs/">Emacs Lisp</a> and <a href="https://orgmode.org/">org-mode</a>.</span><br/>
<span><a href="https://devheroes.codes/lxsameer/lxhome">https://devheroes.codes/lxsameer/lxhome</a></span>
</footer>

</div>
</body>
</html>

+ 0
- 32
build/html/sitemap.html View File

@@ -1,32 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://localhost:3003//html/assets/styles/dark.css?1">
<link rel="stylesheet" href="http://localhost:3003/html/assets/styles/main.css?1">
</head>
<body>

<header>
<h1>lxsameer's nest</h1>
<nav>
<a href="#">HOME</a> | <a href="#">GPG</a>
</nav>
</header>

<div id="content">
<ul class="org-ul">
<li><a href="index.html">blah</a></li>
</ul>

</div>

<footer>
<span>© 2010-2021 Sameer Rahmani</span><br/>
<span>Built with <a href="https://www.gnu.org/software/emacs/">Emacs Lisp</a> and <a href="https://orgmode.org/">org-mode</a>.</span><br/>
<span><a href="https://devheroes.codes/lxsameer/lxhome">https://devheroes.codes/lxsameer/lxhome</a></span>
</footer>

</div>
</body>
</html>

+ 1
- 1
config.org View File

@@ -1,7 +1,7 @@
#+AUTHOR: Sameer Rahmani
#+EMAIL: lxsameer@gnu.org
#+LANGUAGE: en
#+OPTIONS: toc:2
#+OPTIONS: toc:nil <:t
#+options: html5-fancy:t tex:t
#+html_doctype: html5
#+HTML_CONTAINER: div class="column"


+ 82
- 11
lisp/ox-template.el View File

@@ -21,18 +21,13 @@
;; We ensure the org infrastructure
(require 'org)
(require 'seq)
(require 'ox-publish)
(require 'mustache)
(require 'htmlize)
(require 'pp)
(require 'ht)
(advice-add 'org-html--tags :override 'org-html-tag-template)
(defun org-html-tag-template (tags info)
(message "<<<<<<<<<<<< %s" tags)
(let ((template (plist-get info :html-headline-template))
(ctx (ht ("tags" (format "%s" tags))
("base-url" (plist-get info :base-url)))))
(mustache-render (use-html template) ctx)))
(require 'lisp/utils)
(defun use-html (path-to-template)
@@ -42,16 +37,91 @@
(buffer-string)))
(defun render-tags (tags)
"Return a string representing TAGS html."
(if tags
(mapconcat (lambda (x) (format "<a href=\"/tags/%s.html\" class=\"tag-link\">#%s</a>" x x))
tags
" | ")
""))
(defun preamble-fn (info)
"Return a string for the header section of pages using INFO plist."
(let* ((file (plist-get info :input-file))
(page-template (or (plist-get info :html-page-preamble-template) "page-preamble.html"))
(post-template (or (plist-get info :html-post-preabmle-template) "post-preamble.html"))
(is-page? (string= (get-file-global-props file "PAGE") "true"))
(tags (get-file-tags file)))
(let ((title (get-file-global-props file "TITLE"))
(date (get-file-global-props file "DATE")))
(when (not title)
(message "'#+TITLE' is missing from '%s'" file)
(error "'#+TITLE' is missing from '%s'" file))
(if is-page?
(mustache-render (use-html page-template)
(ht ("title" title)))
(progn
(mustache-render (use-html post-template)
(ht
("title" title)
("date" (or date ""))
("tags" (render-tags tags)))))))))
(defun org-html-render-tag-template (tags info)
"Render the given TAGS and INFO using the :html-headline-template."
(let ((template (plist-get info :html-tags-template))
(ctx (ht ("tags" (format "%s" tags))
("base-url" (plist-get info :base-url)))))
(if (null tags)
""
(mustache-render (use-html template) ctx))))
;; Replace org-html--tags with our impelementation if the
;; `:html-headline-template' configuration exists
(advice-add 'org-html--tags :around 'org-html-tag-template)
(defun org-html-tag-template (orig-fn &rest args)
"Decide whether to run ORIG-FN with ARGS or the org-html-render-tag-template.
It looks for `:html-tags-template' in the info and if i exists it will
call `org-html-render-tag-template' otherwise will call ORIG-FN."
(let ((template (plist-get (cadr args) :html-tags-template)))
(if template
(apply #'org-html-render-tag-template args)
(apply orig-fn args))))
(org-export-define-derived-backend 'templated-html 'html
:translate-alist '(;;(headline . templated-html-headline-fn)
(template . templated-html-template-fn)))
:translate-alist '((template . templated-html-template-fn)))
(defun headline-format (todo todo-type priority text tags info)
"Format the headline using TODO TODO-TYPE PRIORITY TEXT TAGS and INFO."
(let ((todo (org-html--todo todo info))
(priority (org-html--priority priority info))
;; We don't care about the tags here since we put the in the preamble
(tags nil))
(concat todo (and todo " ")
priority (and priority " ")
text
(and tags "&#xa0;&#xa0;&#xa0;") tags)))
(defun render-template (template-name contents info)
"Render the given template TEMPLATE-NAME using CONTENTS and INFO."
(let ((ctx (ht ("content" contents)
("head" (plist-get info :html-head-extra))
("base-url" (plist-get info :base-url)))))
("base-url" (plist-get info :base-url))
("preamble" (org-html--build-pre/postamble 'preamble info))
("postamble" (org-html--build-pre/postamble 'postamble info)))))
(mustache-render (use-html template-name) ctx)))
@@ -62,6 +132,7 @@
(render-template template contents info)
(org-html-template contents info))))
(defun org-html-publish-to-templated-html (plist filename pub-dir)
"Publish an org file to HTML.


+ 9
- 15
orgs/index.org View File

@@ -2,23 +2,17 @@
#+OPTIONS: toc:nil
#+EXPORT_FILE_NAME: index.html
#+TAGS: ABD(a) BD(c) ASDK(k)
#+DATE: 2021-02-11
#+CATEGORY: blah
#+TITLE: blah
#+PAGE: true

* Welcome :ABD:BD:
#+CATEGORY: WELCO
:PROPERTIES:
:BLAH: s
:END:
blha bbasd asds asd a asd =asdasd= somer `asdasd` sadasd *asdasD* asdasd /asdasd/ asdasd.
ads ad asd asd as dasd asd
- list a
- [ ] asdasdasd
- [X] asdasd
** TODO asdasdasdsad :ABD:
SCHEDULED: <2021-02-08 Mon>

#+NAME: src1
#+BEGIN_SRC java
class Blah() {
int main() {
return 0;
}
}
#+END_SRC
- [[http://localhost:3003/essays/serene-blah.html][Serene blah]]
- [[http://localhost:3003/essays/javascript-blah.html][javascript blah]]
- [[http://localhost:3003/essays/theindex.html][Index]]

+ 5
- 0
orgs/sitemap.inc View File

@@ -1,3 +1,8 @@
#+TITLE: lxsameer's nest

- [[file:theindex.org][Index]]
- [[file:essays/javascript-blah.org][javascript blah]]
- [[file:tags/index.org][index]]
- [[file:categories/index.org][index]]
- [[file:essays/serene-blah.org][Serene blah]]
- [[file:index.org][blah]]

+ 11
- 7
templates/blog.html View File

@@ -2,21 +2,25 @@
<html lang="en">
<head>
{{{head}}}
<link rel="stylesheet" href="{{base-url}}//html/assets/styles/dark.css?1">
<link rel="stylesheet" href="{{base-url}}/html/assets/styles/main.css?1">
<link rel="stylesheet" href="{{base-url}}/assets/styles/dark.css?1">
<link rel="stylesheet" href="{{base-url}}/assets/styles/main.css?1">
</head>
<body>

<header>
<h1>lxsameer's nest</h1>
<nav>
<a href="#">HOME</a> | <a href="#">GPG</a>
<nav style="text-align: center;">
<a href="/">HOME</a> | <a href="#">GPG</a> | <a href="/categories/">Categories</a> | <a href="/tags/">Tags</a>
</nav>
<hr/>
</header>

<div id="content">
<article>
{{{preamble}}}
</article>

<main id="content">
{{{content}}}
</div>
</main>

<footer>
<span>© 2010-2021 Sameer Rahmani</span><br/>


+ 1
- 1
templates/tags.html View File

@@ -1,3 +1,3 @@
<div class="tags">
<h5>{{tags}}</h5>
<span>{{tags}}</span>
</div>

Loading…
Cancel
Save