|
|
|
@ -430,198 +430,6 @@ prompting for a timestamp rather than arcane config options.
|
|
|
|
|
(let ((org-use-effective-time current-prefix-arg))
|
|
|
|
|
(funcall #'org-todo nil)))
|
|
|
|
|
#+end_src
|
|
|
|
|
* org-roam static site generator
|
|
|
|
|
I'm using roam for this
|
|
|
|
|
- to take advantage of the SQLite stuff
|
|
|
|
|
- because some of the site is wiki-style
|
|
|
|
|
- and some of the wiki pages use roam-refs
|
|
|
|
|
#+begin_src elisp
|
|
|
|
|
(use-package org-roam
|
|
|
|
|
:straight (org-roam :type git
|
|
|
|
|
:host github
|
|
|
|
|
:repo "org-roam/org-roam"
|
|
|
|
|
:branch "main")
|
|
|
|
|
:bind (("C-c n l" . org-roam-buffer-toggle)
|
|
|
|
|
("C-c n i" . org-roam-node-insert)
|
|
|
|
|
("C-c n f" . org-roam-node-find)
|
|
|
|
|
("C-c n c" . org-roam-capture))
|
|
|
|
|
:init
|
|
|
|
|
<<org-roam-publish-defuns>>
|
|
|
|
|
:custom
|
|
|
|
|
(org-roam-directory (file-truename "~/nessus/"))
|
|
|
|
|
(org-roam-completion-everywhere t)
|
|
|
|
|
(org-link-frame-setup '((file . find-file)))
|
|
|
|
|
(org-cite-global-bibliography (list (file-truename "~/nessus/ref/refs.bib")))
|
|
|
|
|
(org-roam-capture-templates
|
|
|
|
|
'(("p" "Page" plain "\n%?"
|
|
|
|
|
:if-new (file+head "pages/${slug}.org" "#+title: ${title}")
|
|
|
|
|
:unnarrowed t)))
|
|
|
|
|
<<org-roam-publish-custom>>
|
|
|
|
|
:config
|
|
|
|
|
(org-roam-db-autosync-mode)
|
|
|
|
|
(add-to-list 'display-buffer-alist
|
|
|
|
|
'("\\*org-roam\\*"
|
|
|
|
|
(display-buffer-in-side-window)
|
|
|
|
|
(side . right)
|
|
|
|
|
(slot . 0)
|
|
|
|
|
(window-width . 0.33)
|
|
|
|
|
(window-parameters . ((no-other-window . t)
|
|
|
|
|
(no-delete-other-windows . t)))))
|
|
|
|
|
(require 'org-roam-export)
|
|
|
|
|
<<allow-citations-anywhere>>)
|
|
|
|
|
#+end_src
|
|
|
|
|
** Publishing
|
|
|
|
|
#+name: org-roam-publish-defuns
|
|
|
|
|
#+begin_src elisp :tangle no
|
|
|
|
|
(defun my/org-list-to-ul (lst)
|
|
|
|
|
(org-list-to-org (cons 'unordered (mapcar #'list lst))))
|
|
|
|
|
|
|
|
|
|
(defun my/org-html-css-link (stylesheet)
|
|
|
|
|
(format "<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/%s.css\" />" stylesheet))
|
|
|
|
|
|
|
|
|
|
(defun my/org-html-index (title files)
|
|
|
|
|
"Make index page"
|
|
|
|
|
(require 'org-roam-db)
|
|
|
|
|
(let ((files-titles (org-roam-db-query "select file,title from nodes"))
|
|
|
|
|
;; group files by tag
|
|
|
|
|
(tags-map
|
|
|
|
|
(-reduce (lambda(map elt)
|
|
|
|
|
(let ((found-cell (assoc (car elt) map)))
|
|
|
|
|
(if (not found-cell)
|
|
|
|
|
(cons elt map)
|
|
|
|
|
(setcdr found-cell (append (cdr elt) (cdr found-cell)))
|
|
|
|
|
map)))
|
|
|
|
|
(cons '()
|
|
|
|
|
(org-roam-db-query
|
|
|
|
|
"select tag,file from tags join nodes on nodes.id = tags.node_id")))))
|
|
|
|
|
(concat
|
|
|
|
|
(format "#+title: %s\n" title)
|
|
|
|
|
"* Tags\n"
|
|
|
|
|
(my/org-list-to-ul (map-apply #'my/org-html-index--make-tag-index tags-map))
|
|
|
|
|
"\n* All files\n"
|
|
|
|
|
(org-list-to-org files))))
|
|
|
|
|
|
|
|
|
|
(defun my/org-html-index--make-tag-index (tag files)
|
|
|
|
|
"Create the tag index file and return a link to it"
|
|
|
|
|
(let* ((filename (expand-file-name (format "index-tag-%s.org" tag)
|
|
|
|
|
org-roam-directory))
|
|
|
|
|
(file-count (length files))
|
|
|
|
|
(plurality (dired-plural-s file-count)))
|
|
|
|
|
(with-temp-file filename
|
|
|
|
|
(insert
|
|
|
|
|
(format "#+title: Index for tag :%s:\n" tag)
|
|
|
|
|
(my/org-list-to-ul
|
|
|
|
|
(mapcar (lambda(file)
|
|
|
|
|
(format "[[file:%s][%s]]" file (cadr (assoc file files-titles))))
|
|
|
|
|
files))))
|
|
|
|
|
(format "[[%s][%s]] (%d node%s)" filename tag file-count plurality)))
|
|
|
|
|
|
|
|
|
|
(defun my/org-html-format (contents _backend info)
|
|
|
|
|
"Uses format-all-buffer to format HTML. Formatter specified by :html-formatter option."
|
|
|
|
|
(let ((formatter (plist-get info :html-formatter)))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert contents)
|
|
|
|
|
(set-auto-mode t)
|
|
|
|
|
(let ((format-all-formatters `(("HTML" ,formatter))))
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(format-all-buffer)
|
|
|
|
|
(error (message "Formatter %s not found. Skipping..." formatter))))
|
|
|
|
|
(buffer-substring-no-properties (point-min) (point-max)))))
|
|
|
|
|
|
|
|
|
|
(defun my/org-html-p (info)
|
|
|
|
|
"Return nil if backend is not 'my/html"
|
|
|
|
|
(equal 'my/html (org-export-backend-name (plist-get info :back-end))))
|
|
|
|
|
|
|
|
|
|
(defun my/org-html--format-title (build-meta-info info)
|
|
|
|
|
"Advise `org-html--build-meta-info' to format title according to :html-title-format"
|
|
|
|
|
(when (my/org-html-p info)
|
|
|
|
|
(let* ((title (org-html-plain-text
|
|
|
|
|
(org-element-interpret-data (plist-get info :title)) info))
|
|
|
|
|
(title (format (plist-get info :html-title-format) title))
|
|
|
|
|
(info (append `(:title ,title) info)))
|
|
|
|
|
(funcall build-meta-info info))))
|
|
|
|
|
(advice-add 'org-html--build-meta-info :around #'my/org-html--format-title)
|
|
|
|
|
|
|
|
|
|
(require 'ox)
|
|
|
|
|
(org-export-define-derived-backend 'my/html 'html
|
|
|
|
|
:translate-alist '((src-block . pygments-org-html-code))
|
|
|
|
|
:filters-alist '((:filter-final-output . my/org-html-format))
|
|
|
|
|
:options-alist '((:html-formatter nil nil 'html-tidy)
|
|
|
|
|
(:html-title-format nil nil "%s")))
|
|
|
|
|
|
|
|
|
|
(defun my/nessus-delete-index (oldfile _newfile)
|
|
|
|
|
"When publishing the \"nessus\" project, delete index org files"
|
|
|
|
|
(when (string-match "/nessus/index" oldfile)
|
|
|
|
|
(message "Deleting index file %s" oldfile)
|
|
|
|
|
(delete-file oldfile)))
|
|
|
|
|
(add-hook 'org-publish-after-publishing-hook #'my/nessus-delete-index)
|
|
|
|
|
|
|
|
|
|
(defun my/publish-to-html (plist filename pub-dir)
|
|
|
|
|
(org-publish-org-to 'my/html filename ".html" plist pub-dir))
|
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
|
|
#+name: org-roam-publish-custom
|
|
|
|
|
#+begin_src elisp :tangle no
|
|
|
|
|
(org-publish-project-alist
|
|
|
|
|
`(("nessus-org"
|
|
|
|
|
:base-directory "~/nessus/"
|
|
|
|
|
:publishing-directory "~/nessus-pub/"
|
|
|
|
|
:publishing-function my/publish-to-html
|
|
|
|
|
:section-numbers nil
|
|
|
|
|
:with-author nil
|
|
|
|
|
:recursive t
|
|
|
|
|
|
|
|
|
|
:auto-sitemap t
|
|
|
|
|
:sitemap-title "Index"
|
|
|
|
|
:sitemap-filename "index.org"
|
|
|
|
|
:sitemap-function my/org-html-index
|
|
|
|
|
|
|
|
|
|
:html-doctype "html5"
|
|
|
|
|
:html-head-include-default-style nil
|
|
|
|
|
:html-formatter (html-tidy "--wrap" "90")
|
|
|
|
|
:html-head ,(mapconcat #'my/org-html-css-link '("style" "pygments") "\n")
|
|
|
|
|
:html-title-format "%s | Nessus City Sun Times"
|
|
|
|
|
:html-link-home "/index.html"
|
|
|
|
|
:html-html5-fancy t
|
|
|
|
|
:html-postamble nil)
|
|
|
|
|
|
|
|
|
|
("nessus-static"
|
|
|
|
|
:base-directory "~/nessus/static/"
|
|
|
|
|
:base-extension "css"
|
|
|
|
|
:publishing-directory "~/nessus-pub/static/"
|
|
|
|
|
:publishing-function org-publish-attachment)
|
|
|
|
|
|
|
|
|
|
("nessus"
|
|
|
|
|
:components ("nessus-static"
|
|
|
|
|
"nessus-org"))))
|
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
|
|
The following is from https://linevi.ch/en/org-pygments.html
|
|
|
|
|
#+name: org-roam-publish-config
|
|
|
|
|
#+begin_src elisp
|
|
|
|
|
(defvar pygments-path "pygmentize")
|
|
|
|
|
|
|
|
|
|
(defun pygments-org-html-code (code contents info)
|
|
|
|
|
;; Generating tmp file path.
|
|
|
|
|
;; Current date and time hash will ideally pass our needs.
|
|
|
|
|
(setq temp-source-file (format "/tmp/pygmentize-%s.txt"(md5 (current-time-string))))
|
|
|
|
|
;; Writing block contents to the file.
|
|
|
|
|
(with-temp-file temp-source-file (insert (org-element-property :value code)))
|
|
|
|
|
;; Exectuing the shell-command an reading an output
|
|
|
|
|
(shell-command-to-string (format "%s -l \"%s\" -f html %s"
|
|
|
|
|
pygments-path
|
|
|
|
|
(or (org-element-property :language code)
|
|
|
|
|
"")
|
|
|
|
|
temp-source-file)))
|
|
|
|
|
#+end_src
|
|
|
|
|
** Allow citations anywhere
|
|
|
|
|
`org-cite--allowed-p` doesn't let you insert a citation in a property, which is annoying
|
|
|
|
|
trying to fill out ROAM__REFS. I can't see why this exists at all.
|
|
|
|
|
|
|
|
|
|
#+name: allow-citations-anywhere
|
|
|
|
|
#+begin_src elisp :tangle no
|
|
|
|
|
(defun org-cite--allowed-p (x) t)
|
|
|
|
|
#+end_src
|
|
|
|
|
* Coding
|
|
|
|
|
** format-all
|
|
|
|
|
#+BEGIN_SRC elisp
|
|
|
|
@ -688,31 +496,6 @@ trying to fill out ROAM__REFS. I can't see why this exists at all.
|
|
|
|
|
#+begin_src elisp
|
|
|
|
|
(use-package projectile)
|
|
|
|
|
#+end_src
|
|
|
|
|
* SLIME
|
|
|
|
|
The SLIME connection and inferior lisp process are just a regular part
|
|
|
|
|
of emacs now, like the sandtrout to Leto II.
|
|
|
|
|
#+begin_src elisp
|
|
|
|
|
(use-package slime
|
|
|
|
|
:config
|
|
|
|
|
(require 'slime-autoloads)
|
|
|
|
|
;; everything uses sbcl except termux, which doesn't package it yet
|
|
|
|
|
(setq inferior-lisp-program (if (= (shell-command "which sbcl") 0) "sbcl" "ecl"))
|
|
|
|
|
(when (= slime-connection-counter 0)
|
|
|
|
|
(slime-start
|
|
|
|
|
:program-args (list "--load" (expand-file-name "slime-init.lisp" user-emacs-directory)))))
|
|
|
|
|
#+END_SRC
|
|
|
|
|
** slime-init.lisp
|
|
|
|
|
This file is loaded by slime
|
|
|
|
|
#+begin_src common-lisp :tangle .emacs.d/slime-init.lisp
|
|
|
|
|
(in-package :cl-user)
|
|
|
|
|
|
|
|
|
|
(defmacro add-responses (&rest responses)
|
|
|
|
|
`(progn
|
|
|
|
|
,@(let (res)
|
|
|
|
|
(dolist (sym responses res)
|
|
|
|
|
(push `(defparameter ,sym ',sym) res)))))
|
|
|
|
|
(add-responses noice omg wat ffs ook nvm wtf butwhy iyss)
|
|
|
|
|
#+end_src
|
|
|
|
|
* XMPP
|
|
|
|
|
#+begin_src elisp
|
|
|
|
|
(use-package jabber
|
|
|
|
@ -757,8 +540,3 @@ This file is loaded by slime
|
|
|
|
|
#+begin_src elisp
|
|
|
|
|
(when-user-file-exists "local-init.el" (load it))
|
|
|
|
|
#+end_src
|
|
|
|
|
* Geiser
|
|
|
|
|
#+begin_src elisp
|
|
|
|
|
(use-package geiser)
|
|
|
|
|
(use-package geiser-guile)
|
|
|
|
|
#+end_src
|
|
|
|
|