From 0232b09c814daedf58008afeb30c620fca9fdd3c Mon Sep 17 00:00:00 2001 From: Dibyashanu Pati <> Date: Sun, 2 Mar 2025 13:50:52 +0530 Subject: [PATCH] organized scripts --- build_exocortex.sh | 18 +++++ ...e_union_of_countable_sets_is_countable.org | 2 +- copy-pics.sh | 19 +++++ copy_latex_images.sh | 28 +++++++ create-site.el | 52 ------------- create.sh | 56 ++------------ ox-hugo-exocortex.el | 73 +++++++++++++++++++ 7 files changed, 146 insertions(+), 102 deletions(-) create mode 100755 build_exocortex.sh create mode 100755 copy-pics.sh create mode 100755 copy_latex_images.sh create mode 100644 ox-hugo-exocortex.el diff --git a/build_exocortex.sh b/build_exocortex.sh new file mode 100755 index 0000000..d0073e4 --- /dev/null +++ b/build_exocortex.sh @@ -0,0 +1,18 @@ +#This script creates the exocortex + +# start clean +rm -rf ./public/exocortex-hugo-md/public/* +rm -rf ./public/exocortex-hugo-md/content/ + +# create hugo md files using ox-hugo +emacs -Q --batch -l ox-hugo-exocortex.el + +# build create html files from hugo markdown files using quartz +cd ./public/exocortex-hugo-md/ +npx quartz build +cd ../../ + +# copy the generated folder to the main public site +rsync -avi --delete ./public/exocortex-hugo-md/public/ ./public/cosmicflow-html/exocortex/ + +echo "exocortex created" diff --git a/content/countable_union_of_countable_sets_is_countable.org b/content/countable_union_of_countable_sets_is_countable.org index b04fc06..6126656 100644 --- a/content/countable_union_of_countable_sets_is_countable.org +++ b/content/countable_union_of_countable_sets_is_countable.org @@ -168,7 +168,7 @@ Then Since $S: \mathbb{N} \times \mathbb{N} \rightarrow \mathbb{N}$ is both injective and surjective, it is a bijection, we are done. -* An Interesting Applications +* An Interesting Application *The set of finite subsets of $\mathbb{N}$ is countable.* Let $A_i$ be set of all subsets of $\mathbb{N}$ containing $i$ elements, that is with cardinality $i$. diff --git a/copy-pics.sh b/copy-pics.sh new file mode 100755 index 0000000..e659504 --- /dev/null +++ b/copy-pics.sh @@ -0,0 +1,19 @@ +# Set the source and destination directories +src_dir="./public/cosmicflow-html" +src_pics_dir="./assets/pics/" + +# Loop through each subdirectory +for dir in "$src_dir"/*; do + if [ -d "$dir" ]; then + dir_name=$(basename "$dir") + dst_pics_dir="${src_dir}/${dir_name}/pics" + + # Create the destination subdirectory if it doesn't exist + if [ ! -d "$dst_pics_dir" ]; then + mkdir -p "$dst_pics_dir" + fi + + # Use rsync to copy files starting with the subdirectory name as prefix + rsync -av --include="$dir_name*" --exclude="*" "${src_pics_dir}/" "${dst_pics_dir}/" + fi +done diff --git a/copy_latex_images.sh b/copy_latex_images.sh new file mode 100755 index 0000000..dedc313 --- /dev/null +++ b/copy_latex_images.sh @@ -0,0 +1,28 @@ +## The purpose of this script is to copy all latex images to the appropriate subdirectories + + +rsync -avi ./content/ltximg ./public/cosmicflow-html/ + +# Set the source and destination directories +src_dir="./public/cosmicflow-html" +src_ltximg_dir="./public/cosmicflow-html/ltximg" + +# Loop through each subdirectory +for dir in "$src_dir"/*; do + if [ -d "$dir" ]; then + dir_name=$(basename "$dir") + dst_ltximg_dir="${src_dir}/${dir_name}/ltximg" + echo "$dir_name" + # Create the destination subdirectory if it doesn't exist + if [ ! -d "$dst_ltximg_dir" ]; then + mkdir -p "$dst_ltximg_dir" + fi + + # Use rsync to copy files starting with the subdirectory name as prefix + rsync -av --include="$dir_name*" --exclude="*" "${src_ltximg_dir}/" "${dst_ltximg_dir}/" + fi +done + +rm -rf ./public/cosmicflow-html/ltximg/ltximg + +echo "Successfully copied latex images." diff --git a/create-site.el b/create-site.el index 0790235..9624b1c 100755 --- a/create-site.el +++ b/create-site.el @@ -28,58 +28,6 @@ (package-install 'htmlize) (package-install 'ox-gemini) -;; ox-hugo for exocortex notes -(use-package ox-hugo - :ensure t ;Auto-install the package from Melpa - :pin melpa ;`package-archives' should already have ("melpa" . "https://melpa.org/packages/") - :after ox - :config - (setq org-hugo-base-dir "~/projects/cosmicflow.space/public/exocortex-hugo-md" ) - (setq org-hugo-default-section-directory "./") - ) -(setq org-roam-directory "~/projects/thought_garden/") - -;; modified this function from https://github.com/kaushalmodi/ox-hugo/discussions/585#discussioncomment-2335203 -(defun ox-hugo/export-all (&optional org-files-root-dir dont-recurse) - "Export all Org files (including nested) under ORG-FILES-ROOT-DIR. - -All valid post subtrees in all Org files are exported using -`org-hugo-export-wim-to-md'. - -If optional arg ORG-FILES-ROOT-DIR is nil, all Org files in -current buffer's directory are exported. - -If optional arg DONT-RECURSE is nil, all Org files in -ORG-FILES-ROOT-DIR in all subdirectories are exported. Else, only -the Org files directly present in the current directory are -exported. If this function is called interactively with -\\[universal-argument] prefix, DONT-RECURSE is set to non-nil. - -Example usage in Emacs Lisp: (ox-hugo/export-all \"~/org\")." - (interactive) - (let* ((org-files-root-dir (or org-files-root-dir default-directory)) - (dont-recurse (or dont-recurse (and current-prefix-arg t))) - (search-path (file-name-as-directory (expand-file-name org-files-root-dir))) - (org-files (if dont-recurse - (directory-files search-path :full "\.org$") - (directory-files-recursively search-path "\.org$"))) - (num-files (length org-files)) - (cnt 1)) - (if (= 0 num-files) - (message (format "No Org files found in %s" search-path)) - (progn - (message (format (if dont-recurse - "[ox-hugo/export-all] Exporting %d files from %S .." - "[ox-hugo/export-all] Exporting %d files recursively from %S ..") - num-files search-path)) - (dolist (org-file org-files) - (with-current-buffer (find-file-noselect org-file) - (message (format "[ox-hugo/export-all file %d/%d] Exporting %s" cnt num-files org-file)) - (org-hugo-export-wim-to-md :all-subtrees) - (setq cnt (1+ cnt)))) - (message "Done!"))))) -(ox-hugo/export-all org-roam-directory) - ;; Load the publishing system (require 'ox-publish) (use-package ox-gemini) diff --git a/create.sh b/create.sh index 8e78aca..053e8dd 100755 --- a/create.sh +++ b/create.sh @@ -1,59 +1,17 @@ #!/usr/bin/env sh +# start with a clean slate rm -rf ./public/cosmicflow-html/ -rm -rf ./public/exocortex-hugo-md/content/ -rm -rf ./public/exocortex-hugo-md/public/* # generate the html and gemini versions of the site using org-publish emacs -Q --batch -l create-site.el -rsync -avi ./content/ltximg ./public/cosmicflow-html/ -#sync exocortex notes -cd ./public/exocortex-hugo-md/ -npx quartz build -cd ../../ +# run script to copy the generated latex images to the appropiate subdirectories +./copy_latex_images.sh -rsync -avi --delete ./public/exocortex-hugo-md/public/ ./public/cosmicflow-html/exocortex/ +# Generate the exocortex +./build_exocortex.sh -# Set the source and destination directories -src_dir="./public/cosmicflow-html" -src_ltximg_dir="./public/cosmicflow-html/ltximg" +# Copy relavent pics to blog subdirectories +./copy-pics.sh -# Loop through each subdirectory -for dir in "$src_dir"/*; do - if [ -d "$dir" ]; then - dir_name=$(basename "$dir") - dst_ltximg_dir="${src_dir}/${dir_name}/ltximg" - - # Create the destination subdirectory if it doesn't exist - if [ ! -d "$dst_ltximg_dir" ]; then - mkdir -p "$dst_ltximg_dir" - fi - - # Use rsync to copy files starting with the subdirectory name as prefix - rsync -av --include="$dir_name*" --exclude="*" "${src_ltximg_dir}/" "${dst_ltximg_dir}/" - fi -done - -# Set the source and destination directories -src_dir="./public/cosmicflow-html" -src_pics_dir="./assets/pics/" - -# Loop through each subdirectory -for dir in "$src_dir"/*; do - if [ -d "$dir" ]; then - dir_name=$(basename "$dir") - dst_pics_dir="${src_dir}/${dir_name}/pics" - - # Create the destination subdirectory if it doesn't exist - if [ ! -d "$dst_pics_dir" ]; then - mkdir -p "$dst_pics_dir" - fi - - # Use rsync to copy files starting with the subdirectory name as prefix - rsync -av --include="$dir_name*" --exclude="*" "${src_pics_dir}/" "${dst_pics_dir}/" - fi -done - - -# rm -rf ./content/ltximg/ diff --git a/ox-hugo-exocortex.el b/ox-hugo-exocortex.el new file mode 100644 index 0000000..fe16f8f --- /dev/null +++ b/ox-hugo-exocortex.el @@ -0,0 +1,73 @@ +;; ox-hugo for exocortex notes + +;; Set the package installation directory so that packages aren't stored in the +;; ~/.emacs.d/elpa path. +(require 'package) +(setq package-user-dir (expand-file-name "./.packages")) +(setq package-archives '(("melpa" . "https://melpa.org/packages/") + ("melpa-stable" . "https://stable.melpa.org/packages/") + ("elpa" . "https://elpa.gnu.org/packages/"))) + +;; Initialize the package system +(package-initialize) +(unless package-archive-contents + (package-refresh-contents)) + +;; Install use-package +(unless (package-installed-p 'use-package) + (package-install 'use-package)) +(require 'use-package) + + +(use-package ox-hugo + :ensure t ;Auto-install the package from Melpa + :pin melpa ;`package-archives' should already have ("melpa" . "https://melpa.org/packages/") + :after ox + :config + (setq org-hugo-base-dir "~/projects/cosmicflow.space/public/exocortex-hugo-md" ) + (setq org-hugo-default-section-directory "./") + ) +(setq org-roam-directory "~/projects/thought_garden/") + +;; modified this function from https://github.com/kaushalmodi/ox-hugo/discussions/585#discussioncomment-2335203 +(defun ox-hugo/export-all (&optional org-files-root-dir dont-recurse) + "Export all Org files (including nested) under ORG-FILES-ROOT-DIR. + +All valid post subtrees in all Org files are exported using +`org-hugo-export-wim-to-md'. + +If optional arg ORG-FILES-ROOT-DIR is nil, all Org files in +current buffer's directory are exported. + +If optional arg DONT-RECURSE is nil, all Org files in +ORG-FILES-ROOT-DIR in all subdirectories are exported. Else, only +the Org files directly present in the current directory are +exported. If this function is called interactively with +\\[universal-argument] prefix, DONT-RECURSE is set to non-nil. + +Example usage in Emacs Lisp: (ox-hugo/export-all \"~/org\")." + (interactive) + (let* ((org-files-root-dir (or org-files-root-dir default-directory)) + (dont-recurse (or dont-recurse (and current-prefix-arg t))) + (search-path (file-name-as-directory (expand-file-name org-files-root-dir))) + (org-files (if dont-recurse + (directory-files search-path :full "\.org$") + (directory-files-recursively search-path "\.org$"))) + (num-files (length org-files)) + (cnt 1)) + (if (= 0 num-files) + (message (format "No Org files found in %s" search-path)) + (progn + (message (format (if dont-recurse + "[ox-hugo/export-all] Exporting %d files from %S .." + "[ox-hugo/export-all] Exporting %d files recursively from %S ..") + num-files search-path)) + (dolist (org-file org-files) + (with-current-buffer (find-file-noselect org-file) + (message (format "[ox-hugo/export-all file %d/%d] Exporting %s" cnt num-files org-file)) + (org-hugo-export-wim-to-md :all-subtrees) + (setq cnt (1+ cnt)))) + (message "Done!"))))) +(ox-hugo/export-all org-roam-directory) + +(message "exocortex markdown created")