Last active
February 22, 2022 18:56
-
-
Save jhilker98/0c048e871644ee0b987b395871baba6e to your computer and use it in GitHub Desktop.
broken version of broken-thrones publish - unable to export images in file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (setq user-emacs-directory (file-truename "./.emacs.d/")) | |
| (defvar bootstrap-version) | |
| (let ((bootstrap-file | |
| (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) | |
| (bootstrap-version 5)) | |
| (unless (file-exists-p bootstrap-file) | |
| (with-current-buffer | |
| (url-retrieve-synchronously | |
| "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" | |
| 'silent 'inhibit-cookies) | |
| (goto-char (point-max)) | |
| (eval-print-last-sexp))) | |
| (load bootstrap-file nil 'nomessage)) | |
| (straight-use-package 'use-package) | |
| (setq straight-use-package-by-default t) | |
| (use-package ox-slimhtml) | |
| (use-package htmlize) | |
| (use-package esxml | |
| ;:straight (:host github :repo "tali713/esxml") | |
| :ensure t) | |
| (use-package org-roam | |
| :custom | |
| (org-roam-directory (file-truename "./org/")) | |
| (org-roam-db-location "./.org-roam.db")) | |
| (setq make-backup-files nil) | |
| ;(straight-freeze-versions) | |
| (setq org-id-link-to-org-use-id t) | |
| ;; (org-roam-db-autosync-mode) | |
| (setq org-id-extra-files (org-roam-list-files)) | |
| (defvar site-attachments | |
| (regexp-opt '("jpg" "jpeg" "gif" "png" "svg" | |
| "ico" "cur" "css" "js" "woff" "html" "pdf")) | |
| "File types that are published as static files.") | |
| (setq jh/site-title "Broken Thrones" ;; site title | |
| jh/site-url "https://brokenthrones.jhilker.com" ;; site url for production | |
| jh/site-tagline "A world of historical fantasy awaits." ;; site tagline | |
| jh/site-banner "/img/brokenthronesbanner.png") ;; banner for index | |
| (setq org-publish-use-timestamps-flag t | |
| org-publish-timestamp-directory "./.org-cache/" | |
| org-export-with-section-numbers nil | |
| org-export-use-babel nil | |
| org-export-with-smart-quotes t | |
| org-export-with-sub-superscripts nil | |
| org-export-with-tags 'not-in-toc | |
| org-export-with-toc t | |
| org-html-link-use-abs-url t) | |
| (defun get-article-output-path (org-file pub-dir) | |
| (let ((article-dir (concat pub-dir | |
| (downcase | |
| (file-name-as-directory | |
| (file-name-sans-extension | |
| (file-name-nondirectory org-file))))))) | |
| (if (string-match "\\/index.org$" org-file) | |
| pub-dir | |
| (progn | |
| (unless (file-directory-p article-dir) | |
| (make-directory article-dir t)) | |
| article-dir)))) | |
| (defun jh/org-html-header () | |
| (concat | |
| (esxml-to-xml | |
| `(header ((class . "z-10 items-center bg-gray-200 grid-in-header")) | |
| (div ((class . "flex items-center justify-between h-[52px] 2xl:h-[62px]")) | |
| (nav ((class . "items-center hidden h-full space-x-3 lg:flex")) | |
| (a ((class . "block h-full p-3 2xl:p-4 transition duration-100 hover:bg-gray-400") | |
| (href . "/")) "Home"))))))) | |
| (defun jh/org-html-fixed-sidebar () | |
| (concat | |
| (esxml-to-xml | |
| `(aside ((class . "flex-col items-center hidden bg-slate-300 grid-in-sidebar lg:flex")) | |
| (span ((class . "p-2 font-semibold uppercase")) "Broken Thrones Wiki") | |
| (img ((src . "/img/jhilker.jpg") | |
| (class . "object-cover rounded-full h-44 w-44 object-right"))) | |
| (p ((class . "p-2 mx-auto mt-2 text-sm text-center text-gray-700")) ,jh/site-tagline))))) | |
| (defun jh/org-html-template (content info) | |
| "Returns the HTML template for my site" | |
| (concat | |
| "<!-- " (org-export-data (org-export-get-date info "%Y-%m-%d") info) " -->\n" | |
| "<!DOCTYPE html>" | |
| (esxml-to-xml | |
| `(head () | |
| (title () ,(concat (org-export-data (plist-get info :title) info) " - Broken Thrones")) | |
| (link ((rel . "stylesheet") | |
| (href . "/css/style.css"))) | |
| (body () | |
| (div ((class . "grid h-screen grid-areas-mobile grid-rows-layout lg:grid-areas-desktop grid-cols-layout")) | |
| ,(jh/org-html-header) | |
| ,(jh/org-html-fixed-sidebar) | |
| (main ((class . "px-3 grid-in-main prose max-w-none prose-slate")) ,content))))))) | |
| (org-export-define-derived-backend 'wiki-html | |
| 'slimhtml | |
| :translate-alist | |
| '((template . jh/org-html-template))) | |
| (defun org-html-publish-to-html (plist filename pub-dir) | |
| "Publish an org file to HTML, using the FILENAME as the output directory." | |
| (let ((article-path (get-article-output-path filename pub-dir))) | |
| (cl-letf (((symbol-function 'org-export-output-file-name) | |
| (lambda (extension &optional subtreep pub-dir) | |
| (concat article-path "index" extension)))) | |
| (org-publish-org-to 'wiki-html | |
| filename | |
| (concat "." (or (plist-get plist :html-extension) | |
| "html")) | |
| plist | |
| article-path)))) | |
| (setq org-publish-project-alist | |
| (list | |
| (list "org:content" | |
| :recursive t | |
| :base-extension "org" | |
| :base-directory "./org" | |
| :publishing-function '(org-html-publish-to-html) | |
| :publishing-directory "./public" | |
| :with-timestamps t) | |
| (list "org:static" | |
| :recursive t | |
| :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|woff\\|woff2\\|svg" | |
| :base-directory "./org" | |
| :publishing-function '(org-publish-attachment) | |
| :publishing-directory "./public" | |
| :with-timestamps t) | |
| (list "org" :components '("org:static" "org:content")) | |
| (list "site:static" | |
| :recursive t | |
| :base-directory "./static" | |
| :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|woff\\|woff2\\|svg" | |
| :publishing-directory "./public" | |
| :publishing-function '(org-publish-attachment)))) | |
| (defun jh/publish-org () | |
| (org-publish "org" t)) | |
| (defun jh/publish-assets () | |
| (org-publish "site:static" t)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment