Huge updates

This commit is contained in:
2026-03-08 13:03:34 +00:00
parent 56b9342fd2
commit d391094ad6
58 changed files with 3084 additions and 771 deletions

View File

@@ -70,6 +70,7 @@
<script src=\"/assets/scripts/search.js\" defer></script>
<script src=\"/assets/scripts/svg-pan-zoom.min.js\" defer></script>
<script src=\"/assets/scripts/gallery-init.js\" defer></script>
<script src=\"/assets/scripts/sitemap-interactive.js\" defer></script>
"
)
@@ -91,7 +92,6 @@
(defvar z-preamble
"
<a href=\"https://notes.zainezq.com\"> <img src=\"/assets/images/1_to_2.svg\" alt=\"Web Site Logo\" class=\"web-logo\" /> </a>
<div class=\"banner-header\">
<a href=\"/\"> <img src=\"/assets/images/gr.png\" alt=\"Site Logo\" class=\"banner-logo\" /> </a>
<nav>
@@ -99,8 +99,7 @@
<a href=\"/blogs/2026/2026-list.html \">2026 | </a>
<a href=\"/blogs/blogs-list.html\">Blogs | </a>
<a href=\"/posts/career/career-list.html\">Career | </a>
<a href=\"/home/services.html\">Services</a>
<a href=\"https://zone.zainezq.com\">Dashboard</a>
<input type=\"search\\\" id=\"search-input\" placeholder=\"Search…\" aria-label=\"Search notes\" />
<button id=\"search-btn\" aria-label=\"Search\">🔍</button>
@@ -215,56 +214,60 @@ A file has comments if:
(add-to-list 'org-export-filter-body-functions
#'z/org-html-insert-comments-into-body)
(defun z/lima--ensure-sitemap-file (project)
"Ensure the sitemap source file exists under the project's base directory."
(let* ((base-dir (file-name-as-directory
(org-publish-property :base-directory project)))
(fname (or (org-publish-property :sitemap-filename project)
"lima-list.org"))
(title (or (org-publish-property :sitemap-title project)
"Lima"))
(sitemap-path (expand-file-name fname base-dir)))
;; If file missing or you want to always regenerate, write header.
(unless (file-exists-p sitemap-path)
(with-temp-file sitemap-path
(insert "#+TITLE: " title "\n"
"#+OPTIONS: toc:nil num:nil\n\n")))))
(defun z/lima-sitemap-format-entry (entry style project)
"Format sitemap ENTRY for lima, ensuring .html links."
"Format sitemap entry for Lima; skip dirs, keep nested paths, and prefix /lima/."
(let* ((file (if (listp entry) (car entry) entry))
(title (org-publish-find-title file project))
(base (file-name-base file)))
(format "[[file:%s.html][%s]]"
base
(or title base))))
(base-dir (file-name-as-directory
(org-publish-property :base-directory project)))
;; Ensure we work with an absolute file path under base-dir
(abs (if (file-name-absolute-p file)
file
(expand-file-name file base-dir))))
;; Skip directories
(unless (file-directory-p abs)
(let* ((rel (file-relative-name abs base-dir)) ;; guaranteed no “…/..” backtracking now
(rel-noext (file-name-sans-extension rel))
(title (org-publish-find-title abs project)))
(format "[[file:%s.html][%s]]"
rel-noext
(or title (file-name-nondirectory rel-noext)))))))
;; (defun z/publish-lima-file (plist filename pub-dir)
;; "Publish Org or Markdown file from lima directory."
;; (let* ((ext (file-name-extension filename))
;; (base (file-name-base filename))
;; (output-file (expand-file-name
;; (concat base ".html")
;; pub-dir)))
;; ;; Ensure output directory exists
;; (make-directory pub-dir t)
;; (cond
;; ;; ORG FILES
;; ((string= ext "org")
;; (org-publish-org-to 'z-html filename ".html" plist pub-dir))
;; ;; MARKDOWN FILES
;; ((string= ext "md")
;; (message "Converting %s → %s" filename output-file)
;; (let ((exit-code
;; (call-process
;; "pandoc"
;; nil
;; "*pandoc-output*"
;; t
;; filename
;; "-o"
;; output-file
;; "--standalone")))
;; (unless (eq exit-code 0)
;; (error "Pandoc failed with exit code %s" exit-code)))))))
(defun z/copy-neighbor-attachments (source-dir pub-dir)
"Copy sibling directories named .attachments.* from SOURCE-DIR to PUB-DIR."
(let ((dirs (directory-files source-dir t "^\\.attachments\\..+")))
(dolist (d dirs)
(when (file-directory-p d)
(let* ((target (expand-file-name (file-name-nondirectory d) pub-dir)))
(make-directory target t)
;; copy-directory: (DIRECTORY NEWNAME &optional KEEP-TIME PARENTS COPY-CONTENTS)
(copy-directory d target t t t))))))
(defun z/publish-lima-file (plist filename pub-dir)
"Publish Org or Markdown file from lima directory."
(let* ((ext (file-name-extension filename))
(base (file-name-base filename)))
(let* ((ext (downcase (or (file-name-extension filename) "")))
(base (file-name-base filename))
(src-dir (file-name-directory filename)))
(cond
;; ORG FILES
;; ORG FILES (publish as-is)
((string= ext "org")
;; Ensure sibling .attachments.* are published
(z/copy-neighbor-attachments src-dir pub-dir)
(org-publish-org-to 'z-html filename ".html" plist pub-dir))
;; MARKDOWN FILES
@@ -272,45 +275,52 @@ A file has comments if:
(let* ((temp-org
(expand-file-name
(concat base ".org")
(make-temp-file "lima-build-" t)))) ;; temp directory
(make-temp-file "lima-build-" t))))
;; Convert Markdown → Org
(call-process
"pandoc"
nil nil nil
filename
"-f" "markdown"
"-t" "org"
"-o" temp-org)
;; Convert Markdown → Org with pandoc
(call-process "pandoc" nil nil nil
filename "-f" "markdown" "-t" "org" "-o" temp-org)
;; Ensure title exists
(with-temp-buffer
(insert-file-contents temp-org)
(goto-char (point-min))
(unless (re-search-forward "^#\\+TITLE:" nil t)
(goto-char (point-min))
(insert "#+TITLE: " base "\n\n"))
(write-region (point-min) (point-max) temp-org))
;; Ensure #+TITLE exists
;; Ensure front matter at top of temp-org
(with-temp-buffer
(insert-file-contents temp-org)
;; Build values
(let* ((title base)
(slug base)
(date (format-time-string "<%Y-%m-%d %a %H:%M>")))
(goto-char (point-min))
;; Insert front matter
;; (Always ensure they are at the absolute top)
(insert "#+TITLE: " title "\n"
"#+OPTIONS: num:nil\n"
"#+DATE: " date "\n"
"#+COMMENTS: t\n"
"#+SLUG: " slug "\n\n"))
;; Write back to file
(write-region (point-min) (point-max) temp-org))
;; Ensure sibling .attachments.* are published
(z/copy-neighbor-attachments src-dir pub-dir)
;; Publish using ORIGINAL base name
(let ((output-file
(expand-file-name
(concat base ".html")
pub-dir)))
(org-publish-org-to
'z-html
temp-org
".html"
plist
pub-dir)
(let ((output-file (expand-file-name (concat base ".html") pub-dir)))
(org-publish-org-to 'z-html temp-org ".html" plist pub-dir)
;; temp-org base may differ; normalize to requested base
(let ((generated (expand-file-name
(concat (file-name-base temp-org) ".html")
pub-dir)))
(when (and (file-exists-p generated)
(not (string-equal generated output-file)))
(rename-file generated output-file t))))))
;; Rename to correct base if needed
(let ((generated
(expand-file-name
(concat (file-name-base temp-org) ".html")
pub-dir)))
(when (file-exists-p generated)
(rename-file generated output-file t)))))))))
(t
;; Default: treat as attachment
(org-publish-attachment plist filename pub-dir)))))
(setq org-html-htmlize-output-type 'css)
@@ -496,8 +506,8 @@ A file has comments if:
:html-validation-link nil
:html-preamble ,z-preamble
:html-postamble ,z-postamble
:auto-sitemap t
:sitemap-filename "lima-list.org"
:auto-sitemap t
:sitemap-title "Lima"
:sitemap-style list
:sitemap-sort-files anti-chronologically