fixing rss

This commit is contained in:
Yann Esposito (Yogsototh) 2019-08-31 14:21:03 +02:00
parent 18d8c222c9
commit 7053582656
Signed by untrusted user who does not match committer: yogsototh
GPG Key ID: 7B19A4C650D59646
5 changed files with 1277 additions and 35 deletions

View File

@ -1,16 +1,22 @@
;; sign it with ;; sign it with
;; gpg --local-user yann@esposito.host --output project.el.sig --detach-sign project.el ;; gpg --local-user yann@esposito.host --output project.el.sig --detach-sign project.el
(setq domainname "https://her.esy.fun") (defvar domainname "https://her.esy.fun")
(setq base-dir (concat (projectile-project-root) "src")) (defvar base-dir (concat (projectile-project-root) "src"))
(setq publish-dir (concat (projectile-project-root) "_site")) (defvar publish-dir (concat (projectile-project-root) "_site"))
(setq assets-dir (concat base-dir "/")) (defvar assets-dir (concat base-dir "/"))
(setq publish-assets-dir (concat publish-dir "/")) (defvar publish-assets-dir (concat publish-dir "/"))
(setq rss-dir base-dir) (defvar posts-dir (concat base-dir "/posts"))
(setq rss-title "Subscribe to articles") (defvar posts-publish-dir (concat publish-dir "/posts"))
(setq publish-rss-dir publish-dir) (defvar micro-dir (concat base-dir "/micro"))
(setq css-path "/css/minimalist.css") (defvar micro-publish-dir (concat publish-dir "/micro"))
(setq author-name "Yann Esposito") (defvar rss-dir base-dir)
(setq author-email "yann@esposito.host") (defvar rss-title "Subscribe to articles")
(defvar posts-descr "Articles")
(defvar micro-descr "Short micro blog entries à la twitter/mastodon")
(defvar publish-rss-dir publish-dir)
(defvar css-path "/css/minimalist.css")
(defvar author-name "Yann Esposito")
(defvar author-email "yann@esposito.host")
(require 'org) (require 'org)
(require 'ox-publish) (require 'ox-publish)
@ -26,7 +32,7 @@
(concat (concat
"<link rel=\"stylesheet\" type=\"text/css\" href=\"" css-path "\"/>" "<link rel=\"stylesheet\" type=\"text/css\" href=\"" css-path "\"/>"
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">" "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
"<link rel=\"alternative\" type=\"application/rss+xml\" title=\"" rss-title "\" href=\"/archives.xml\" />" "<link rel=\"alternative\" type=\"application/rss+xml\" title=\"" rss-title "\" href=\"/posts.xml\" />"
"<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\">")) "<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\">"))
(defun menu (lst) (defun menu (lst)
@ -36,7 +42,7 @@
(mapconcat 'identity (mapconcat 'identity
(append (append
'("<a href=\"/index.html\">Home</a>" '("<a href=\"/index.html\">Home</a>"
"<a href=\"/archive.html\">Posts</a>" "<a href=\"/posts.html\">Posts</a>"
"<a href=\"/slides.html\">Slides</a>" "<a href=\"/slides.html\">Slides</a>"
"<a href=\"/about-me.html\">About</a>") "<a href=\"/about-me.html\">About</a>")
lst) lst)
@ -131,26 +137,31 @@
(defun org-blog-sitemap-format-entry (entry _style project) (defun org-blog-sitemap-format-entry (entry _style project)
"Return string for each ENTRY in PROJECT." "Return string for each ENTRY in PROJECT."
(when (s-starts-with-p "posts/" entry) (cond ((not (directory-name-p entry))
(format (concat "@@html:<span class=\"archive-item\">" (let* ((file (org-publish--expand-file-name entry project))
"<span class=\"archive-date\">@@ %s: @@html:</span>@@" (title (org-publish-find-title entry project))
" [[file:%s][%s]]" (date (format-time-string "%Y-%m-%d" (org-publish-find-date entry project)))
" @@html:</span>@@") (link (concat (file-name-sans-extension entry) ".html")))
(format-time-string "%Y-%m-%d" (org-publish-find-date entry project)) (with-temp-buffer
entry (insert (format "* [[file:%s][%s]]\n" file title))
(org-publish-find-title entry project)))) (org-set-property "RSS_PERMALINK" link)
(org-set-property "PUBDATE" date)
(org-id-get-create)
(insert-file-contents file)
(buffer-string))))
((eq style 'tree)
(file-name-nondirectory (directory-file-name entry)))))
(defun org-blog-sitemap-function (title list) (defun org-blog-sitemap-fn-descr (descr title list)
"Return sitemap using TITLE and LIST returned by `org-blog-sitemap-format-entry'." "Return sitemap using TITLE and LIST returned by `org-blog-sitemap-format-entry'."
(concat "#+TITLE: " title "\n" (concat "#+TITLE: " title "\n"
"#+AUTHOR: " author-name "\n" "#+AUTHOR: " author-name "\n"
"#+EMAIL: " author-email "\n" "#+EMAIL: " author-email "\n"
"\n#+begin_archive\n" "#+DESCRIPTION: " descr "\n"
(mapconcat (lambda (li) (mapconcat (lambda (li)
(format "@@html:<li>@@ %s @@html:</li>@@" (car li))) (format "* %s" (car li)))
(seq-filter #'car (cdr list)) (seq-filter #'car (cdr list))
"\n") "\n")))
"\n#+end_archive\n"))
(defun org-blog-publish-to-html (plist filename pub-dir) (defun org-blog-publish-to-html (plist filename pub-dir)
"Same as `org-html-publish-to-html' but modifies html before finishing." "Same as `org-html-publish-to-html' but modifies html before finishing."
@ -204,16 +215,20 @@ Return output file name."
dst-file)) dst-file))
(copy-file filename dst-file t))))) (copy-file filename dst-file t)))))
(defalias 'org-blog-posts-sitemap-fn
(apply-partially 'org-blog-sitemap-fn-descr posts-descr))
(defalias 'org-blog-micro-sitemap-fn
(apply-partially 'org-blog-sitemap-fn-descr micro-descr))
(setq org-publish-project-alist (setq org-publish-project-alist
`(("orgfiles" `(("orgfiles"
:base-directory ,base-dir :base-directory ,base-dir
:exclude ".*drafts/.*" :exclude ".*(drafts|posts|micro)/.*"
:base-extension "org" :base-extension "org"
:publishing-directory ,publish-dir :publishing-directory ,publish-dir
:recursive t :recursive t
:publishing-function org-blog-publish-to-html :publishing-function org-blog-publish-to-html
:with-toc nil :with-toc nil
:with-title nil :with-title nil
:with-date t :with-date t
@ -226,14 +241,59 @@ Return output file name."
:html-head-extra ,org-blog-head :html-head-extra ,org-blog-head
:html-preamble org-blog-preamble :html-preamble org-blog-preamble
:html-postamble org-blog-postamble :html-postamble org-blog-postamble
:auto-sitemap nil)
("posts"
:base-directory ,posts-dir
:base-extension "org"
:publishing-directory ,posts-publish-dir
:recursive t
:publishing-function org-blog-publish-to-html
:with-toc nil
:with-title nil
:with-date t
:section-numbers nil
:html-doctype "html5"
:html-html5-fancy t
:html-head-include-default-style nil
:html-head-include-scripts nil
:htmlized-source t
:html-head-extra ,org-blog-head
:html-preamble org-blog-preamble
:html-postamble org-blog-postamble
:auto-sitemap t :auto-sitemap t
:sitemap-filename "archive.org" :sitemap-filename "posts.org"
:sitemap-title "Blog Posts" :sitemap-title "Blog Posts"
:sitemap-style list :sitemap-style list
:sitemap-sort-files anti-chronologically :sitemap-sort-files anti-chronologically
:sitemap-format-entry org-blog-sitemap-format-entry :sitemap-format-entry org-blog-sitemap-format-entry
:sitemap-function org-blog-sitemap-function) :sitemap-function org-blog-posts-sitemap-fn)
("micro"
:base-directory ,micro-dir
:base-extension "org"
:publishing-directory ,micro-publish-dir
:recursive t
:publishing-function org-blog-publish-to-html
:with-toc nil
:with-title nil
:with-date t
:section-numbers nil
:html-doctype "html5"
:html-html5-fancy t
:html-head-include-default-style nil
:html-head-include-scripts nil
:htmlized-source t
:html-head-extra ,org-blog-head
:html-preamble org-blog-preamble
:html-postamble org-blog-postamble
:auto-sitemap t
:sitemap-filename "micro.org"
:sitemap-title "Micro Blog Posts"
:sitemap-style list
:sitemap-sort-files anti-chronologically
:sitemap-format-entry org-blog-sitemap-format-entry
:sitemap-function org-blog-micro-sitemap-fn)
("assets" ("assets"
:base-directory ,assets-dir :base-directory ,assets-dir
@ -252,11 +312,11 @@ Return output file name."
:publishing-directory ,publish-rss-dir :publishing-directory ,publish-rss-dir
:publishing-function (org-rss-publish-to-rss) :publishing-function (org-rss-publish-to-rss)
:exclude ".*" :exclude ".*"
:include ("archive.org") :include ("posts/posts.org" "micro/micro.org")
:section-numbers nil :section-numbers nil
:table-of-contents nil) :table-of-contents nil)
("blog" :components ("orgfiles" "assets" "rss")))) ("blog" :components ("orgfiles" "posts" "assets" "rss"))))
;; add target=_blank and rel="noopener noreferrer" to all links by default ;; add target=_blank and rel="noopener noreferrer" to all links by default
(defun my-org-export-add-target-blank-to-http-links (text backend info) (defun my-org-export-add-target-blank-to-http-links (text backend info)

View File

@ -8,7 +8,6 @@
#+OPTIONS: H:5 #+OPTIONS: H:5
#+STARTUP: showeverything #+STARTUP: showeverything
Welcome to my personal website. Welcome to my personal website.
- [[file:archive.org][articles]] - [[file:archive.org][articles]]

11
src/micro/ping.org Normal file
View File

@ -0,0 +1,11 @@
#+TITLE: Ping
#+KEYWORDS: social
#+AUTHOR: Yann Esposito
#+EMAIL: yann@esposito.host
#+DESCRIPTION:
#+LANGUAGE: en
#+LANG: en
#+OPTIONS: H:5 auto-id:t
#+STARTUP: showeverything
Ping!

View File

@ -1,5 +1,5 @@
#+TITLE: New Blog #+TITLE: New Blog
#+SUBTITLE: Meta Post (not really related to Donal Knuth) #+SUBTITLE: Meta Post (not really related to Donald Knuth)
#+AUTHOR: Yann Esposito #+AUTHOR: Yann Esposito
#+EMAIL: yann@esposito.host #+EMAIL: yann@esposito.host
#+DATE: [2019-08-17 Sat] #+DATE: [2019-08-17 Sat]

1172
src/posts/posts.org Normal file

File diff suppressed because it is too large Load Diff