diff options
| author | Matt Kosarek <matt.kosarek@canonical.com> | 2026-03-11 17:49:05 -0400 |
|---|---|---|
| committer | Matt Kosarek <matt.kosarek@canonical.com> | 2026-03-11 17:49:05 -0400 |
| commit | 77b0f69d0c6e555349dd491d7ca209924d119e61 (patch) | |
| tree | 095cf20002f5df752c04c20af4366588bd7ba32b /create-update-post.el | |
| parent | c929a29c728c6799a3f83f5ad5c1c6f99ed516d4 (diff) | |
Diffstat (limited to 'create-update-post.el')
| -rw-r--r-- | create-update-post.el | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/create-update-post.el b/create-update-post.el deleted file mode 100644 index 1a572b9..0000000 --- a/create-update-post.el +++ /dev/null @@ -1,86 +0,0 @@ -(defun mk/blog/create-update-post () - "Create a new 'Update' post for today in the _posts folder." - (interactive) - (let* ((date (current-time)) - (month-name (downcase (format-time-string "%b" date))) - (day (format-time-string "%d" date)) - (year (format-time-string "%Y" date)) - (full-month (format-time-string "%B" date)) - (weekday (format-time-string "%a" date)) - (time (format-time-string "%H:%M" date)) - (filename (format "%s_%s_%s.org" month-name day year)) - (project-root (locate-dominating-file default-directory ".git")) - (posts-dir (expand-file-name "_posts" project-root)) - (filepath (expand-file-name filename posts-dir)) - (uuid (org-id-uuid)) - (org-date (format "<%s-%s-%s %s %s>" year (format-time-string "%m" date) day weekday time)) - (title (format "Update %s %s, %s" full-month day year))) - - ;; Check if file already exists - (if (file-exists-p filepath) - (message "Post file already exists: %s" filepath) - - ;; Create the file with the template - (with-temp-file filepath - (insert ":PROPERTIES:\n") - (insert (format ":ID: %s\n" uuid)) - (insert ":END:\n") - (insert "\n") - (insert (format "#+TITLE: %s\n" title)) - (insert (format "#+DATE: %s\n" org-date)) - (insert "#+filetags: :update:\n") - (insert "\n") - (insert "* What have I been up to?\n") - (insert "\n")) - - ;; Open the file - (find-file filepath) - (goto-char (point-max)) - (message "Created new update post: %s" filepath)))) - -(defun mk/blog/create-regular-post () - "Create a new regular blog post with a custom title in the _posts folder." - (interactive) - (let* ((title (read-string "Post title: ")) - (date (current-time)) - (year (format-time-string "%Y" date)) - (month (format-time-string "%m" date)) - (day (format-time-string "%d" date)) - (month-name (downcase (format-time-string "%b" date))) - (weekday (format-time-string "%a" date)) - (time (format-time-string "%H:%M" date)) - (filename-base (replace-regexp-in-string "[^a-z0-9_]+" "_" (downcase title))) - (filename (format "%s_%s_%s.org" month-name day year)) - (project-root (locate-dominating-file default-directory ".git")) - (posts-dir (expand-file-name "_posts" project-root)) - (filepath (expand-file-name filename posts-dir)) - (uuid (org-id-uuid)) - (org-date (format "<%s-%s-%s %s %s>" year month day weekday time))) - - ;; Check if file already exists - (if (file-exists-p filepath) - (message "Post file already exists: %s" filepath) - - ;; Create the file with the template - (with-temp-file filepath - (insert ":PROPERTIES:\n") - (insert (format ":ID: %s\n" uuid)) - (insert ":END:\n") - (insert (format "#+TITLE: %s\n" title)) - (insert (format "#+DATE: %s\n" org-date)) - (insert "#+filetags: :TODO:\n") - (insert "\n") - (insert "\n") - (insert "\n") - (insert "* Introduction\n") - (insert ":PROPERTIES:\n") - (insert (format ":ID: %s\n" (org-id-uuid))) - (insert ":END:\n") - (insert "\n")) - - ;; Open the file - (find-file filepath) - (goto-char (point-max)) - (message "Created new regular post: %s" filepath)))) - -(provide 'create-update-post) |
