Skip to content

Commit a28d1ea

Browse files
committed
feat: refactor denote flow
1 parent de4ecd5 commit a28d1ea

File tree

1 file changed

+73
-38
lines changed

1 file changed

+73
-38
lines changed

README.org

Lines changed: 73 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,9 @@ ref: https://github.com/manateelazycat/auto-save
676676
:defer t
677677
:bind ("C-j" . rime-force-enable)
678678
:init
679-
(setq rime--module-path
680-
(expand-file-name (concat "librime-emacs" module-file-suffix) my-lib-dir))
681679
(when sys-is-windows
680+
(setq rime--module-path
681+
(expand-file-name (concat "librime-emacs" module-file-suffix) my-lib-dir))
682682
(setq rime-share-data-dir (expand-file-name "rime-data" my-etc-dir)))
683683

684684
(defun my-*require-rime(&rest _)
@@ -716,7 +716,9 @@ ref: https://github.com/manateelazycat/auto-save
716716
(fixed-pitch
717717
((t (:inherit default))))
718718
:config
719-
(set-fontset-font t 'emoji (font-spec :family "Segoe UI Symbol"))
719+
(set-fontset-font t 'symbol (font-spec :family "Segoe UI Symbol"))
720+
721+
(set-fontset-font t 'emoji (font-spec :family "Segoe UI Emoji"))
720722

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

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

23172319
#+begin_src elisp
2318-
(use-package denote
2319-
:ban minimal?
2320-
:straight t
2321-
:custom
2322-
(denote-directory my-notes-dir)
2323-
:config
2324-
(defun denote-blog ()
2325-
"Create blog for publish."
2326-
(declare (interactive-only t))
2327-
(interactive)
2328-
(let ((denote-directory my-blogs-org-dir)
2329-
(denote-prompts '(title))
2330-
(denote-org-front-matter
2331-
"#+title: %1$s
2332-
,#+date: %2$s
2333-
,#+author: xhcoding
2334-
,#+identifier: %4$s
2335-
,#+hugo_locale: zh
2336-
,#+hugo_tags: %3$s
2337-
,#+hugo_categories: %3$s
2338-
,#+hugo_draft: true
2339-
2340-
"
2341-
))
2342-
(call-interactively #'denote-open-or-create))))
2320+
(use-package denote
2321+
:ban minimal?
2322+
:straight t
2323+
:custom
2324+
(denote-directory my-notes-dir)
2325+
:config
2326+
(defun denote-blog ()
2327+
"Create blog for publish."
2328+
(declare (interactive-only t))
2329+
(interactive)
2330+
(let ((denote-directory my-blogs-org-dir)
2331+
(denote-prompts '(title))
2332+
(denote-org-front-matter
2333+
"#+title: %1$s
2334+
,#+date: %2$s
2335+
,#+author: xhcoding
2336+
,#+identifier: %4$s
2337+
,#+hugo_locale: zh
2338+
,#+hugo_tags: %3$s
2339+
,#+hugo_categories: %3$s
2340+
,#+hugo_draft: false
2341+
2342+
"
2343+
))
2344+
(call-interactively #'denote-open-or-create)))
2345+
2346+
(defun denote-blog-image-insert (file)
2347+
"Insert image file to blog."
2348+
(declare (interactive-only t))
2349+
(interactive "fImage file: ")
2350+
(let* ((blog-file-title (denote-retrieve-filename-title (buffer-file-name)))
2351+
(blog-image-dir (concat (expand-file-name blog-file-title my-blogs-image-dir) "/"))
2352+
(blog-image-ext (concat "." (file-name-extension file)))
2353+
(blog-default-image-title (concat blog-file-title (format-time-string "-%H%M%S")))
2354+
(blog-image-title (read-string "Image title: " "" nil blog-default-image-title))
2355+
(blog-image-new-name (denote-format-file-name blog-image-dir (denote-get-identifier) nil blog-image-title blog-image-ext nil)))
2356+
2357+
(unless (file-directory-p blog-image-dir)
2358+
(make-directory blog-image-dir t))
2359+
(copy-file file blog-image-new-name)
2360+
(org-insert-link "" (concat "file:" blog-image-new-name) "")
2361+
))
2362+
)
23432363

23442364
#+end_src
23452365

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

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

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

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

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

2397-
;; ;; front matter author => authors
2398-
;; (defun my-blog*convert-author-to-authors(front-matter)
2399-
;; "Convert author to authors."
2400-
;; (let ((ret (replace-regexp-in-string "author" "authors" front-matter)))
2401-
;; ret))
2417+
(defun my/hugo-export-all-blogs ()
2418+
"Export all blogs."
2419+
(interactive)
2420+
(dolist (file (directory-files my-blogs-org-dir))
2421+
(when (string-equal "org" (file-name-extension file))
2422+
(with-temp-buffer
2423+
(find-file (expand-file-name file my-blogs-org-dir))
2424+
(org-hugo-export-to-md)))))
24022425

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

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

24322454
#+begin_src elisp
24332455
(use-package org-download
2456+
:disabled t
24342457
:ban minimal?
24352458
:straight t
24362459
:after org
@@ -2503,6 +2526,7 @@ ref:https://github.com/manateelazycat/toggle-one-window
25032526
#+begin_src elisp
25042527
(use-package eaf
25052528
:ban minimal?
2529+
:disabled t
25062530
:straight (emacs-application-framework :type git :host github :repo "emacs-eaf/emacs-application-framework"
25072531
:files ("*")
25082532
:build nil)
@@ -2535,6 +2559,7 @@ ref:https://github.com/manateelazycat/toggle-one-window
25352559

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

25642589
#+begin_src elisp
25652590
(use-package websocket
2591+
:disabled t
25662592
:ban minimal?
25672593
:straight t
25682594
:defer t)
25692595

25702596
(use-package websocket-bridge
2597+
:disabled t
25712598
:ban minimal?
25722599
:straight (websocket-bridge :type git :host github :repo "ginqi7/websocket-bridge")
25732600
:defer t)
25742601

25752602

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

25932621
#+begin_src emacs-lisp
25942622
(use-package wl
2623+
:disabled t
25952624
:ban minimal?
25962625
:straight (wanderlust)
25972626
:defer t
@@ -2670,7 +2699,7 @@ Wanderlust + offlineimap3 + mu
26702699

26712700
#+begin_src emacs-lisp
26722701
(when full?
2673-
2702+
26742703
(defun my-*require-wanderlust (&rest _)
26752704
(require 'wl))
26762705

@@ -2681,6 +2710,7 @@ Wanderlust + offlineimap3 + mu
26812710

26822711
#+begin_src emacs-lisp
26832712
(use-package alert-toast
2713+
:disabled t
26842714
:ban minimal?
26852715
:straight t
26862716
:after wl
@@ -2755,6 +2785,7 @@ Wanderlust + offlineimap3 + mu
27552785

27562786
#+begin_src elisp
27572787
(use-package tex
2788+
:disabled t
27582789
:ban minimal?
27592790
:straight (auctex)
27602791
:defer t
@@ -2772,6 +2803,11 @@ Wanderlust + offlineimap3 + mu
27722803
:straight t
27732804
:defer t)
27742805

2806+
(use-package websocket
2807+
:ban minimal?
2808+
:straight t
2809+
:defer t)
2810+
27752811
(use-package aichat
27762812
:ban minimal?
27772813
:defer t
@@ -2948,4 +2984,3 @@ Wanderlust + offlineimap3 + mu
29482984
(load (expand-file-name "config.el" my-private-dir)))
29492985

29502986
#+end_src
2951-

0 commit comments

Comments
 (0)