Skip to content

Commit

Permalink
feat: refactor denote flow
Browse files Browse the repository at this point in the history
  • Loading branch information
xhcoding committed May 19, 2024
1 parent de4ecd5 commit a28d1ea
Showing 1 changed file with 73 additions and 38 deletions.
111 changes: 73 additions & 38 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,9 @@ ref: https://github.com/manateelazycat/auto-save
:defer t
:bind ("C-j" . rime-force-enable)
:init
(setq rime--module-path
(expand-file-name (concat "librime-emacs" module-file-suffix) my-lib-dir))
(when sys-is-windows
(setq rime--module-path
(expand-file-name (concat "librime-emacs" module-file-suffix) my-lib-dir))
(setq rime-share-data-dir (expand-file-name "rime-data" my-etc-dir)))

(defun my-*require-rime(&rest _)
Expand Down Expand Up @@ -716,7 +716,9 @@ ref: https://github.com/manateelazycat/auto-save
(fixed-pitch
((t (:inherit default))))
:config
(set-fontset-font t 'emoji (font-spec :family "Segoe UI Symbol"))
(set-fontset-font t 'symbol (font-spec :family "Segoe UI Symbol"))

(set-fontset-font t 'emoji (font-spec :family "Segoe UI Emoji"))

(set-fontset-font t 'chinese-gbk (font-spec :family "微软雅黑"))

Expand Down Expand Up @@ -2315,31 +2317,49 @@ ref:https://github.com/manateelazycat/toggle-one-window
*** denote

#+begin_src elisp
(use-package denote
:ban minimal?
:straight t
:custom
(denote-directory my-notes-dir)
:config
(defun denote-blog ()
"Create blog for publish."
(declare (interactive-only t))
(interactive)
(let ((denote-directory my-blogs-org-dir)
(denote-prompts '(title))
(denote-org-front-matter
"#+title: %1$s
,#+date: %2$s
,#+author: xhcoding
,#+identifier: %4$s
,#+hugo_locale: zh
,#+hugo_tags: %3$s
,#+hugo_categories: %3$s
,#+hugo_draft: true

"
))
(call-interactively #'denote-open-or-create))))
(use-package denote
:ban minimal?
:straight t
:custom
(denote-directory my-notes-dir)
:config
(defun denote-blog ()
"Create blog for publish."
(declare (interactive-only t))
(interactive)
(let ((denote-directory my-blogs-org-dir)
(denote-prompts '(title))
(denote-org-front-matter
"#+title: %1$s
,#+date: %2$s
,#+author: xhcoding
,#+identifier: %4$s
,#+hugo_locale: zh
,#+hugo_tags: %3$s
,#+hugo_categories: %3$s
,#+hugo_draft: false

"
))
(call-interactively #'denote-open-or-create)))

(defun denote-blog-image-insert (file)
"Insert image file to blog."
(declare (interactive-only t))
(interactive "fImage file: ")
(let* ((blog-file-title (denote-retrieve-filename-title (buffer-file-name)))
(blog-image-dir (concat (expand-file-name blog-file-title my-blogs-image-dir) "/"))
(blog-image-ext (concat "." (file-name-extension file)))
(blog-default-image-title (concat blog-file-title (format-time-string "-%H%M%S")))
(blog-image-title (read-string "Image title: " "" nil blog-default-image-title))
(blog-image-new-name (denote-format-file-name blog-image-dir (denote-get-identifier) nil blog-image-title blog-image-ext nil)))

(unless (file-directory-p blog-image-dir)
(make-directory blog-image-dir t))
(copy-file file blog-image-new-name)
(org-insert-link "" (concat "file:" blog-image-new-name) "")
))
)

#+end_src

Expand All @@ -2353,7 +2373,7 @@ ref:https://github.com/manateelazycat/toggle-one-window
(defconst my-hugo-root-dir (expand-file-name "/mnt/d/Blog"))
(defconst my-hugo-root-dir (expand-file-name "~/Blog"))))

(defconst my-hugo-image-url "https://images.xhcoding.cn/blog/")
(defconst my-hugo-image-url "https://images.xhcoding.cn/blog")

(defconst my-hugo-post-url "https://xhcoding.cn/post/")

Expand Down Expand Up @@ -2386,21 +2406,23 @@ ref:https://github.com/manateelazycat/toggle-one-window
(cond
((and (string-equal type "file") (my-hugo--blogs-image-path-p raw-path))
(progn
(let* ((image-url (my-blog--convert-image-url raw-path))
(let* ((image-url (my-hugo--image-path-to-url raw-path))
(new-link (org-element-put-property link :path image-url )))
`(,new-link ,desc ,info))))
(t `(,link ,desc ,info))
)))

(advice-add #'org-hugo-link :filter-args #'my-hugo*convert-path-to-url)

;; ;; front matter author => authors
;; (defun my-blog*convert-author-to-authors(front-matter)
;; "Convert author to authors."
;; (let ((ret (replace-regexp-in-string "author" "authors" front-matter)))
;; ret))
(defun my/hugo-export-all-blogs ()
"Export all blogs."
(interactive)
(dolist (file (directory-files my-blogs-org-dir))
(when (string-equal "org" (file-name-extension file))
(with-temp-buffer
(find-file (expand-file-name file my-blogs-org-dir))
(org-hugo-export-to-md)))))

;; (advice-add #'org-hugo--get-front-matter :filter-return #'my-blog*convert-author-to-authors)
)

(use-package easy-hugo
Expand Down Expand Up @@ -2431,6 +2453,7 @@ ref:https://github.com/manateelazycat/toggle-one-window

#+begin_src elisp
(use-package org-download
:disabled t
:ban minimal?
:straight t
:after org
Expand Down Expand Up @@ -2503,6 +2526,7 @@ ref:https://github.com/manateelazycat/toggle-one-window
#+begin_src elisp
(use-package eaf
:ban minimal?
:disabled t
:straight (emacs-application-framework :type git :host github :repo "emacs-eaf/emacs-application-framework"
:files ("*")
:build nil)
Expand Down Expand Up @@ -2535,6 +2559,7 @@ ref:https://github.com/manateelazycat/toggle-one-window

#+begin_src elisp
(use-package popweb
:disabled t
:ban minimal?
:straight (popweb :type git :host github :repo "manateelazycat/popweb" :build nil)
:commands (popweb-dict-eudic-input popweb-import-browser-cookies)
Expand Down Expand Up @@ -2563,17 +2588,20 @@ ref:https://github.com/manateelazycat/toggle-one-window

#+begin_src elisp
(use-package websocket
:disabled t
:ban minimal?
:straight t
:defer t)

(use-package websocket-bridge
:disabled t
:ban minimal?
:straight (websocket-bridge :type git :host github :repo "ginqi7/websocket-bridge")
:defer t)


(use-package dictionary-overlay
:disabled t
:ban minimal?
:straight (dictionary-overlay :type git :host github :repo "ginqi7/dictionary-overlay"
:build nil)
Expand All @@ -2592,6 +2620,7 @@ Wanderlust + offlineimap3 + mu

#+begin_src emacs-lisp
(use-package wl
:disabled t
:ban minimal?
:straight (wanderlust)
:defer t
Expand Down Expand Up @@ -2670,7 +2699,7 @@ Wanderlust + offlineimap3 + mu

#+begin_src emacs-lisp
(when full?

(defun my-*require-wanderlust (&rest _)
(require 'wl))

Expand All @@ -2681,6 +2710,7 @@ Wanderlust + offlineimap3 + mu

#+begin_src emacs-lisp
(use-package alert-toast
:disabled t
:ban minimal?
:straight t
:after wl
Expand Down Expand Up @@ -2755,6 +2785,7 @@ Wanderlust + offlineimap3 + mu

#+begin_src elisp
(use-package tex
:disabled t
:ban minimal?
:straight (auctex)
:defer t
Expand All @@ -2772,6 +2803,11 @@ Wanderlust + offlineimap3 + mu
:straight t
:defer t)

(use-package websocket
:ban minimal?
:straight t
:defer t)

(use-package aichat
:ban minimal?
:defer t
Expand Down Expand Up @@ -2948,4 +2984,3 @@ Wanderlust + offlineimap3 + mu
(load (expand-file-name "config.el" my-private-dir)))

#+end_src

0 comments on commit a28d1ea

Please sign in to comment.