From 3ea00177df09075523ddea3c66a6713a59020a29 Mon Sep 17 00:00:00 2001 From: Frieder Schlesier Date: Thu, 5 Jan 2023 19:49:36 +0100 Subject: [PATCH] progress on publishing org-roam --- .spacemacs | 29 ++++------- publish.el | 124 ++++++++++++++++++++++++++++++++++++++++++++ spacemacs-custom.el | 74 ++++++-------------------- 3 files changed, 151 insertions(+), 76 deletions(-) create mode 100644 publish.el diff --git a/.spacemacs b/.spacemacs index a4b1ea0..542fec0 100644 --- a/.spacemacs +++ b/.spacemacs @@ -55,9 +55,10 @@ This function should only modify configuration layer settings." 'rust-analyzer) markdown (org :variables - org-enable-roam-support t) + org-enable-roam-support t + org-enable-roam-ui t) plantuml - python + (python :variables python-backend 'lsp python-lsp-server 'mspyls) (rust :variables rust-backend 'lsp) shell ;; shell-scripts @@ -76,7 +77,8 @@ This function should only modify configuration layer settings." ;; spell-checking ;; syntax-checking ;; version-control - treemacs) + ;; treemacs + ) ;; List of additional packages that will be installed without being wrapped @@ -596,25 +598,14 @@ you should place your code here." (when (file-exists-p "~/dotfiles/spacemacs-custom.el") (load-file "~/dotfiles/spacemacs-custom.el") ) + (when (file-exists-p "~/dotfiles/publish.el") + (load-file "~/dotfiles/publish.el") + ) ) ) ;; Do not write anything past this comment. This is where Emacs will ;; auto-generate custom variable definitions. -(custom-set-variables - ;; custom-set-variables was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(package-selected-packages - (quote - (company-auctex auctex flycheck-pos-tip pos-tip flycheck docker json-mode tablist docker-tramp json-snatcher json-reformat unfill mwim web-mode tagedit slim-mode scss-mode sass-mode pug-mode less-css-mode helm-css-scss haml-mode emmet-mode company-web web-completion-data go-guru go-eldoc company-go go-mode yaml-mode smeargle orgit org-projectile org-category-capture org-present org-pomodoro alert log4e gntp org-mime org-download mmm-mode markdown-toc markdown-mode magit-gitflow htmlize helm-gitignore helm-company helm-c-yasnippet gnuplot gitignore-mode gitconfig-mode gitattributes-mode git-timemachine git-messenger git-link git-gutter-fringe+ git-gutter-fringe fringe-helper git-gutter+ git-gutter gh-md fuzzy evil-magit magit magit-popup git-commit ghub treepy let-alist graphql with-editor diff-hl company-statistics company auto-yasnippet yasnippet ac-ispell auto-complete dockerfile-mode ws-butler winum which-key volatile-highlights vi-tilde-fringe uuidgen use-package toc-org spaceline powerline restart-emacs request rainbow-delimiters popwin persp-mode pcre2el paradox spinner org-plus-contrib org-bullets open-junk-file neotree move-text macrostep lorem-ipsum linum-relative link-hint indent-guide hydra hungry-delete hl-todo highlight-parentheses highlight-numbers parent-mode highlight-indentation helm-themes helm-swoop helm-projectile helm-mode-manager helm-make projectile pkg-info epl helm-flx helm-descbinds helm-ag google-translate golden-ratio flx-ido flx fill-column-indicator fancy-battery eyebrowse expand-region exec-path-from-shell evil-visualstar evil-visual-mark-mode evil-unimpaired evil-tutor evil-surround evil-search-highlight-persist evil-numbers evil-nerd-commenter evil-mc evil-matchit evil-lisp-state smartparens evil-indent-plus evil-iedit-state iedit evil-exchange evil-escape evil-ediff evil-args evil-anzu anzu evil goto-chg undo-tree eval-sexp-fu highlight elisp-slime-nav dumb-jump f dash s diminish define-word column-enforce-mode clean-aindent-mode bind-map bind-key auto-highlight-symbol auto-compile packed aggressive-indent adaptive-wrap ace-window ace-link ace-jump-helm-line helm avy helm-core popup async)))) -(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - ) (defun dotspacemacs/emacs-custom-settings () "Emacs custom settings. This is an auto-generated function, do not modify its content directly, use @@ -626,8 +617,10 @@ This function is called at the very end of Spacemacs initialization." ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(evil-want-Y-yank-to-eol nil) + '(org-agenda-files + '("/home/fschl/Documents/Org/tasks.org" "/home/fschl/Documents/Org/journal.org" "/home/fschl/Documents/Org/private.org" "/home/fschl/Documents/Org/projects.org" "/home/fschl/Documents/Org/birthdays.org")) '(package-selected-packages - '(all-the-icons-gnus all-the-icons-completion all-the-icons-dired dap-mode lsp-docker bui company-auctex auctex flycheck-pos-tip pos-tip flycheck docker json-mode tablist docker-tramp json-snatcher json-reformat unfill mwim web-mode tagedit slim-mode scss-mode sass-mode pug-mode less-css-mode helm-css-scss haml-mode emmet-mode company-web web-completion-data go-guru go-eldoc company-go go-mode yaml-mode smeargle orgit org-projectile org-category-capture org-present org-pomodoro alert log4e gntp org-mime org-download mmm-mode markdown-toc markdown-mode magit-gitflow htmlize helm-gitignore helm-company helm-c-yasnippet gnuplot gitignore-mode gitconfig-mode gitattributes-mode git-timemachine git-messenger git-link git-gutter-fringe+ git-gutter-fringe fringe-helper git-gutter+ git-gutter gh-md fuzzy evil-magit magit magit-popup git-commit ghub treepy let-alist graphql with-editor diff-hl company-statistics company auto-yasnippet yasnippet ac-ispell auto-complete dockerfile-mode ws-butler winum which-key volatile-highlights vi-tilde-fringe uuidgen use-package toc-org spaceline powerline restart-emacs request rainbow-delimiters popwin persp-mode pcre2el paradox spinner org-plus-contrib org-bullets open-junk-file neotree move-text macrostep lorem-ipsum linum-relative link-hint indent-guide hydra hungry-delete hl-todo highlight-parentheses highlight-numbers parent-mode highlight-indentation helm-themes helm-swoop helm-projectile helm-mode-manager helm-make projectile pkg-info epl helm-flx helm-descbinds helm-ag google-translate golden-ratio flx-ido flx fill-column-indicator fancy-battery eyebrowse expand-region exec-path-from-shell evil-visualstar evil-visual-mark-mode evil-unimpaired evil-tutor evil-surround evil-search-highlight-persist evil-numbers evil-nerd-commenter evil-mc evil-matchit evil-lisp-state smartparens evil-indent-plus evil-iedit-state iedit evil-exchange evil-escape evil-ediff evil-args evil-anzu anzu evil goto-chg undo-tree eval-sexp-fu highlight elisp-slime-nav dumb-jump f dash s diminish define-word column-enforce-mode clean-aindent-mode bind-map bind-key auto-highlight-symbol auto-compile packed aggressive-indent adaptive-wrap ace-window ace-link ace-jump-helm-line helm avy helm-core popup async)) + '(org-roam simple-httpd websocket org-roam-ui all-the-icons-gnus all-the-icons-completion all-the-icons-dired dap-mode lsp-docker bui company-auctex auctex flycheck-pos-tip pos-tip flycheck docker json-mode tablist docker-tramp json-snatcher json-reformat unfill mwim web-mode tagedit slim-mode scss-mode sass-mode pug-mode less-css-mode helm-css-scss haml-mode emmet-mode company-web web-completion-data go-guru go-eldoc company-go go-mode yaml-mode smeargle orgit org-projectile org-category-capture org-present org-pomodoro alert log4e gntp org-mime org-download mmm-mode markdown-toc markdown-mode magit-gitflow htmlize helm-gitignore helm-company helm-c-yasnippet gnuplot gitignore-mode gitconfig-mode gitattributes-mode git-timemachine git-messenger git-link git-gutter-fringe+ git-gutter-fringe fringe-helper git-gutter+ git-gutter gh-md fuzzy evil-magit magit magit-popup git-commit ghub treepy let-alist graphql with-editor diff-hl company-statistics company auto-yasnippet yasnippet ac-ispell auto-complete dockerfile-mode ws-butler winum which-key volatile-highlights vi-tilde-fringe uuidgen use-package toc-org spaceline powerline restart-emacs request rainbow-delimiters popwin persp-mode pcre2el paradox spinner org-plus-contrib org-bullets open-junk-file neotree move-text macrostep lorem-ipsum linum-relative link-hint indent-guide hydra hungry-delete hl-todo highlight-parentheses highlight-numbers parent-mode highlight-indentation helm-themes helm-swoop helm-projectile helm-mode-manager helm-make projectile pkg-info epl helm-flx helm-descbinds helm-ag google-translate golden-ratio flx-ido flx fill-column-indicator fancy-battery eyebrowse expand-region exec-path-from-shell evil-visualstar evil-visual-mark-mode evil-unimpaired evil-tutor evil-surround evil-search-highlight-persist evil-numbers evil-nerd-commenter evil-mc evil-matchit evil-lisp-state smartparens evil-indent-plus evil-iedit-state iedit evil-exchange evil-escape evil-ediff evil-args evil-anzu anzu evil goto-chg undo-tree eval-sexp-fu highlight elisp-slime-nav dumb-jump f dash s diminish define-word column-enforce-mode clean-aindent-mode bind-map bind-key auto-highlight-symbol auto-compile packed aggressive-indent adaptive-wrap ace-window ace-link ace-jump-helm-line helm avy helm-core popup async)) '(warning-suppress-types '((use-package) ((evil-collection))))) (custom-set-faces ;; custom-set-faces was added by Custom. diff --git a/publish.el b/publish.el new file mode 100644 index 0000000..1755ffb --- /dev/null +++ b/publish.el @@ -0,0 +1,124 @@ +(require 'package) +(setq package-archives '(("melpa" . "https://melpa.org/packages/") + ("elpa" . "https://elpa.gnu.org/packages/"))) + +(package-initialize) +(unless package-archive-contents + (package-refresh-contents)) + +(setq org-export-with-broken-links 'mark) + +(package-install 'htmlize) +(require 'htmlize) + +(package-install 'simple-httpd) +(package-install 'websocket) +(package-install 'org-roam) +(package-install 'org-roam-ui) +(package-install 'f) + +(require 'org-roam) +(require 'org-roam-ui) +(require 'ox-publish) + +(setq org-export-html-coding-system 'utf-8-unix) +(setq org-html-doctype "html5") +(defvar fschlde-html-head "") +(setq fschlde-html-footer " ") + +;; following two funcs are taken from +;; https://www.orgroam.com/manual.html#How-do-I-publish-my-notes-with-an-Internet_002dfriendly-graph_003f +;; sitemap function for my roam-publish +(defun roam-sitemap (title list) + (concat "#+OPTIONS: ^:nil author:nil html-postamble:nil\n" + "#+SETUPFILE: ./simple_inline.theme\n" + "#+TITLE: " title "\n\n" + (org-list-to-org list) "\nfile:sitemap.svg")) + +(setq my-publish-time 0) ; see the next section for context + +;; +(defun roam-publication-wrapper (plist filename pubdir) + (org-roam-graph) + (org-html-publish-to-html plist filename pubdir) + (setq my-publish-time (cadr (current-time)))) + +(defun org-roam-custom-link-builder (node) + (let ((file (org-roam-node-file node))) + (concat (file-name-base file) ".html"))) + +(setq org-roam-graph-link-builder 'org-roam-custom-link-builder) + +(add-hook 'org-roam-graph-generation-hook + (lambda (dot svg) (if (< (- (cadr (current-time)) my-publish-time) 5) + (progn (copy-file svg "~/projects/blog-fschlde/braindump/sitemap.svg" 't) + (kill-buffer (file-name-nondirectory svg)) + (setq my-publish-time 0))))) + + +(setq org-publish-project-alist + '(("website" + :components ("org-journal", "project-notes", "org-sites", "blog-rss", "blog-images")) + ("org-journal" + :base-directory "~/Documents/Org/" + :base-extension "org" + :publishing-directory "~/projects/blog-fschlde/reads/" + :recursive nil + :publishing-function org-html-publish-to-html + + :headline-levels 4 + :with-author t + :with-creator nil + :with-date t + + :with-toc t + :with-drawers nil + + :html-link-home "/" + :html-head nil ;; cleans up anything that would have been in there. + ;; :html-head-extra ,my-blog-extra-head + :html-head-include-default-style nil + :html-head-include-scripts nil + + ;; :html-preamble my-blog-header + ;; :html-postamble ,my-blog-footer + ) + ("project-notes" + :base-directory "~/projects/" + :base-extension "org" + :publishing-directory "~/projects/blog-fschlde/projects/" + :recursive nil + :publishing-function org-html-publish-to-html + :headline-levels 4) + ("org-sites" + :base-directory "~/projects/fschlde-static/" + :base-extension "org\\|css\\|js\\|ico\\|png\\|html" + :publishing-directory "~/projects/blog-fschlde/" + :recursive t + :publishing-function org-publish-attachment + + :html-link-home "/" + ;; :html-head ,fschlde-html-head ;; cleans up anything that would have been in there. + :html-head-include-default-style nil + :html-head-include-scripts nil + :with-drawers nil + :with-creator nil + + ;; :html-head-extra fschlde-html-head + ;; :html-postamble fschlde-html-footer + :headline-levels 4) + ("roam" + :base-directory "~/org-roam/" + :auto-sitemap t + :recursive nil + :base-extension "org" + :exclude ".stversions/\\|.stfolder" + :sitemap-function roam-sitemap + :sitemap-title "Roam notes" + :publishing-function roam-publication-wrapper + :publishing-directory "~/projects/blog-fschlde/braindump/" + :section-number nil + :table-of-contents nil + :style "") + ) + ) diff --git a/spacemacs-custom.el b/spacemacs-custom.el index d1b756b..bc66ca7 100644 --- a/spacemacs-custom.el +++ b/spacemacs-custom.el @@ -1,65 +1,23 @@ - (setq org-roam-directory (file-truename "~/org-roam")) (org-roam-db-autosync-mode) -(require 'ox-publish) + (require 'org-projectile) -(setq org-export-html-coding-system 'utf-8-unix) -(setq org-html-doctype "html5") -(defvar fschlde-html-head "") -(setq fschlde-html-footer " ") -(setq org-publish-project-alist - '(("website" - :components ("org-journal", "project-notes", "org-sites", "blog-rss", "blog-images")) - ("org-journal" - :base-directory "~/Documents/Org/" - :base-extension "org" - :publishing-directory "~/projects/blog-fschlde/reads/" - :recursive nil - :publishing-function org-html-publish-to-html - :headline-levels 4 - :with-author t - :with-creator nil - :with-date t +(eval-after-load 'ox '(require 'ox-koma-letter)) +(eval-after-load 'ox-koma-letter + '(progn + (add-to-list 'org-latex-classes + '("my-letter" + "\\documentclass\{scrlttr2\} + \\usepackage[english]{babel} + \\setkomavar{frombank}{(1234)\\,567\\,890} + \[DEFAULT-PACKAGES] + \[PACKAGES] + \[EXTRA]")) - :with-toc t - :with-drawers nil + (setq org-koma-letter-default-class "my-letter"))) - :html-link-home "/" - :html-head nil ;; cleans up anything that would have been in there. - ;; :html-head-extra ,my-blog-extra-head - :html-head-include-default-style nil - :html-head-include-scripts nil - ;; :html-preamble my-blog-header - ;; :html-postamble ,my-blog-footer - ) - ("project-notes" - :base-directory "~/projects/" - :base-extension "org" - :publishing-directory "~/projects/blog-fschlde/projects/" - :recursive nil - :publishing-function org-html-publish-to-html - :headline-levels 4) - ("org-sites" - :base-directory "~/projects/fschlde-static/" - :base-extension "org" - :publishing-directory "~/projects/fschlde-static/" - :recursive t - :publishing-function org-html-publish-to-html - - :html-link-home "/" - ;; :html-head ,fschlde-html-head ;; cleans up anything that would have been in there. - :html-head-include-default-style nil - :html-head-include-scripts nil - :with-drawers nil - :with-creator nil - - ;; :html-head-extra fschlde-html-head - ;; :html-postamble fschlde-html-footer - :headline-levels 4) - ) - ) (setq org-default-notes-file "~/Documents/Org/tasks.org") (setq org-agenda-files (quote ("~/Documents/Org/tasks.org" @@ -117,6 +75,6 @@ ) ) -(setq org-ref-default-bibliography '("~/Documents/WHZ/MA/latex/references.bib") - org-ref-pdf-directory "~/Documents/WHZ/MA/references/" - org-ref-bibliography-notes "~/Documents/WHZ/MA/notes.org") +(setq org-ref-default-bibliography '("~/Documents/references/references.bib") + org-ref-pdf-directory "~/Documents/references/" + org-ref-bibliography-notes "~/Documents/references/notes.org")