diff --git a/build.el b/build.el index 5fa1fe4..15bba60 100644 --- a/build.el +++ b/build.el @@ -10,23 +10,61 @@ org-html-head-include-scripts nil) (setq site-nav - "") + "
+ + + aner@zakobar.com + + + + linkedin.com/in/aner-zakobar + +
") + +(setq blog-nav + "
+ ← aner.zakobar.com +
") + +(defun things-extract-keyword (file keyword) + "Extract #+KEYWORD: value from FILE, or nil if absent/empty." + (with-temp-buffer + (insert-file-contents file) + (goto-char (point-min)) + (when (re-search-forward + (concat "^#\\+" keyword ":[ \t]*\\(.*\\)$") nil t) + (let ((v (string-trim (match-string 1)))) + (unless (string= v "") v))))) + +(defun things-generate-page (_project) + "Scan things/ and write content/generated/things-body.org." + (let* ((things-dir "./things") + (gen-dir "./content/generated") + (files (when (file-directory-p things-dir) + (file-expand-wildcards (concat things-dir "/*.org") t)))) + (make-directory gen-dir t) + (with-temp-file (concat gen-dir "/things-body.org") + (insert "#+BEGIN_EXPORT html\n
\n") + (dolist (file files) + (let* ((title (things-extract-keyword file "THINGS_TITLE")) + (desc (things-extract-keyword file "THINGS_DESC")) + (path (things-extract-keyword file "THINGS_PATH")) + ) + (when (and title desc path) + (insert + (concat + "
\n" + "
\n" + "

" title "

\n" + "

" desc "

\n" + "
\n" + "
\n"))))) + (insert "
\n#+END_EXPORT\n")))) + +(defun site-prepare (project) + "Run all site preparation steps." + (blog-generate-listings project) + (things-generate-page project)) (defun blog-extract-title (file) "Extract #+TITLE: value from FILE." @@ -77,24 +115,29 @@ (concat "*[[" link "][" title "]]* — " date "\n\n" excerpt "\n\n" - "[[" link "][Read more →]]\n\n" - "-----\n\n"))))) + "[[" link "][Read more →]]\n\n"))))) (make-directory gen-dir t) (with-temp-file (concat gen-dir "/recent-posts.org") - (dolist (file (seq-take files 3)) - (insert (funcall make-entry file)))) + (let ((first t)) + (dolist (file (seq-take files 3)) + (unless first (insert "-----\n\n")) + (insert (funcall make-entry file)) + (setq first nil)))) (with-temp-file (concat gen-dir "/all-posts.org") - (dolist (file files) - (insert (funcall make-entry file)))))) + (let ((first t)) + (dolist (file files) + (unless first (insert "-----\n\n")) + (insert (funcall make-entry file)) + (setq first nil)))))) (setq org-publish-project-alist `(("site-pages" :base-directory "./content" :base-extension "org" :publishing-directory "./public" :recursive t - :exclude "generated/" + :exclude "generated/\\|blog/" :publishing-function org-html-publish-to-html - :preparation-function blog-generate-listings + :preparation-function site-prepare :html-head-include-default-style nil :html-head-include-scripts nil :html-head "" @@ -106,6 +149,23 @@ :section-numbers nil :with-toc nil) + ("site-blog" + :base-directory "./content/blog" + :base-extension "org" + :publishing-directory "./public/blog" + :recursive nil + :publishing-function org-html-publish-to-html + :html-head-include-default-style nil + :html-head-include-scripts nil + :html-head "" + :html-preamble ,blog-nav + :html-postamble nil + :with-author nil + :with-creator nil + :with-timestamps nil + :section-numbers nil + :with-toc nil) + ("site-static" :base-directory "./static" :base-extension "css\\|js\\|png\\|jpg\\|jpeg\\|gif\\|svg\\|ico\\|woff2\\|woff\\|ttf" @@ -114,6 +174,6 @@ :publishing-function org-publish-attachment) ("site" - :components ("site-pages" "site-static")))) + :components ("site-pages" "site-blog" "site-static")))) (org-publish "site" t) diff --git a/content/about.org b/content/about.org deleted file mode 100644 index 2887961..0000000 --- a/content/about.org +++ /dev/null @@ -1,6 +0,0 @@ -#+TITLE: About -#+DESCRIPTION: About me - -* General Background - -I was born. I grew up. I learned to code. I learned basic linear algebra. I made this site. This about sums it up. diff --git a/content/blog.org b/content/blog.org deleted file mode 100644 index 8e700ca..0000000 --- a/content/blog.org +++ /dev/null @@ -1,6 +0,0 @@ -#+TITLE: Blog -#+DESCRIPTION: All blog posts - -* All Posts - -#+INCLUDE: generated/all-posts.org diff --git a/content/index.org b/content/index.org index 9c27f64..341b96c 100644 --- a/content/index.org +++ b/content/index.org @@ -1,9 +1,10 @@ #+TITLE: Aner Zakobar's Personal Waste of Bits #+DESCRIPTION: Personal website -* Recent Blog Posts - -#+INCLUDE: generated/recent-posts.org +* Things +#+INCLUDE: generated/things-body.org +* Blog +#+INCLUDE: generated/all-posts.org diff --git a/content/projects.org b/content/projects.org deleted file mode 100644 index 586aa26..0000000 --- a/content/projects.org +++ /dev/null @@ -1,10 +0,0 @@ -#+TITLE: Projects -#+DESCRIPTION: About me - -* Embedding Golf - -Look at the embedding golf - -* Around the world look - -Look around the world diff --git a/flake.lock b/flake.lock index 7c144fd..6f5b366 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,41 @@ { "nodes": { + "ar-globe-explorer": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1778763816, + "narHash": "sha256-V1CZ3p0nEtPtp9gDBgaR3csBlD1rcQiNDlEma/iOjmE=", + "owner": "anerisgreat", + "repo": "ar-world-border-viewer", + "rev": "8e2ed6cd72fa69ccb690dfcefeddf11ef27b6762", + "type": "github" + }, + "original": { + "owner": "anerisgreat", + "repo": "ar-world-border-viewer", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -34,10 +70,47 @@ "type": "github" } }, + "nixpkgs-python": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1733319315, + "narHash": "sha256-cFQBdRmtIZFVjr2P6NkaCOp7dddF93BC0CXBwFZFaN0=", + "owner": "cachix", + "repo": "nixpkgs-python", + "rev": "01263eeb28c09f143d59cd6b0b7c4cc8478efd48", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "nixpkgs-python", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1719253556, + "narHash": "sha256-A/76RFUVxZ/7Y8+OMVL1Lc8LRhBxZ8ZE2bpMnvZ1VpY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fc07dc3bdf2956ddd64f24612ea7fc894933eb2e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { + "ar-globe-explorer": "ar-globe-explorer", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "word-embedding-golf": "word-embedding-golf" } }, "systems": { @@ -54,6 +127,27 @@ "repo": "default", "type": "github" } + }, + "word-embedding-golf": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-python": "nixpkgs-python" + }, + "locked": { + "lastModified": 1778780013, + "narHash": "sha256-iG8zEn8Qe2dWnxr3zRTWGJaO8yQbfJRaqllckDObMnM=", + "owner": "anerisgreat", + "repo": "word-embedding-golf", + "rev": "1fc4dd0324d0988bd6e4590e7cd625657d31e496", + "type": "github" + }, + "original": { + "owner": "anerisgreat", + "repo": "word-embedding-golf", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 22b04bb..1ffb227 100644 --- a/flake.nix +++ b/flake.nix @@ -5,15 +5,15 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; - # Sub-projects: uncomment and replace URLs when ready - # project-a = { - # url = "path:/path/to/project-a"; - # inputs.nixpkgs.follows = "nixpkgs"; - # }; - # project-b = { - # url = "path:/path/to/project-b"; - # inputs.nixpkgs.follows = "nixpkgs"; - # }; + word-embedding-golf = { + url = "github:anerisgreat/word-embedding-golf"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + ar-globe-explorer = { + url = "github:anerisgreat/ar-world-border-viewer"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { self, nixpkgs, flake-utils, ... } @ inputs: @@ -21,9 +21,9 @@ let pkgs = import nixpkgs { inherit system; }; - # Sub-project outputs — uncomment when inputs above are added - # subProjectA = inputs.project-a.packages.${system}.default; - # subProjectB = inputs.project-b.packages.${system}.default; + wordEmbeddingGolfPkg = inputs.word-embedding-golf.packages.${system}.default; + + arGlobeExplorerPkg = inputs.ar-globe-explorer.packages.${system}.default; site = pkgs.stdenv.mkDerivation { name = "personal-site"; @@ -40,9 +40,19 @@ installPhase = '' cp -r public/. $out/ - # Sub-project integration: when adding a sub-project, add lines like: - # mkdir -p $out/project-a - # cp -r /. $out/project-a/ + mkdir -p $out/word-embedding-golf + cp -r ${wordEmbeddingGolfPkg}/. $out/word-embedding-golf/ + + mkdir -p $out/ar-globe-explorer + cp -r ${arGlobeExplorerPkg}/. $out/ar-globe-explorer/ + + # Inject a "back to site" banner into all sub-project HTML pages + BANNER='
← aner.zakobar.com
' + for dir in $out/word-embedding-golf $out/ar-globe-explorer; do + find "$dir" -name "*.html" | while IFS= read -r f; do + sed -i -E "s|]*)>|$BANNER|" "$f" + done + done ''; }; @@ -95,6 +105,47 @@ ''; }; + new-thing = pkgs.writeShellApplication { + name = "new-thing"; + runtimeInputs = [ pkgs.coreutils pkgs.gnused ]; + excludeShellChecks = [ "SC2001" ]; + text = '' + if [ $# -lt 3 ]; then + echo "Usage: new-thing \"Title\" \"flake-url\" \"Short description\"" + exit 1 + fi + title="$1" + flake_url="$2" + desc="$3" + slug=$(echo "$title" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-//;s/-$//') + camel=$(echo "$slug" | sed 's/-\([a-z]\)/\u\1/g') + filename="things/''${slug}.org" + mkdir -p things + cat > "$filename" <