rss playground

This commit is contained in:
Yann Esposito (Yogsototh) 2019-09-01 00:04:23 +02:00
parent 10344d3443
commit b60cb386b4
Signed by untrusted user who does not match committer: yogsototh
GPG Key ID: 7B19A4C650D59646
4 changed files with 30 additions and 70 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
_cache _cache
_site _site
src/posts/rss.org src/posts/rss.org
src/posts/posts.org src/posts/index.org
src/micro/rss.org src/micro/rss.org

View File

@ -25,7 +25,7 @@
(require 'org-element) (require 'org-element)
(require 'ox-rss) (require 'ox-rss)
(setq org-link-file-path-type 'relative) ;; (setq org-link-file-path-type 'relative)
(setq org-publish-timestamp-directory (setq org-publish-timestamp-directory
(concat (projectile-project-root) "_cache/")) (concat (projectile-project-root) "_cache/"))
@ -44,7 +44,7 @@
(mapconcat 'identity (mapconcat 'identity
(append (append
'("<a href=\"/index.html\">Home</a>" '("<a href=\"/index.html\">Home</a>"
"<a href=\"/posts/posts.html\">Posts</a>" "<a href=\"/posts/index.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)
@ -137,6 +137,16 @@
(menu '("<a href=\"#preamble\">↑ Top ↑</a>")) (menu '("<a href=\"#preamble\">↑ Top ↑</a>"))
"</div>")) "</div>"))
(defun date-format-entry (entry _style project)
"Return string for each ENTRY in PROJECT."
(cond ((not (directory-name-p entry))
(let* ((file (org-publish--expand-file-name entry project))
(title (org-publish-find-title entry project))
(date (format-time-string "%Y-%m-%d" (org-publish-find-date entry project))))
(format "- [%s] [[file:%s][%s]]\n" date file title)))
((eq style 'tree)
(file-name-nondirectory (directory-file-name entry)))))
(defun org-blog-sitemap-format-entry (sub entry _style project) (defun org-blog-sitemap-format-entry (sub entry _style project)
"Return string for each ENTRY in PROJECT." "Return string for each ENTRY in PROJECT."
(cond ((not (directory-name-p entry)) (cond ((not (directory-name-p entry))
@ -154,7 +164,7 @@
(goto-char 0) (goto-char 0)
(end-of-line) (end-of-line)
(forward-char) (forward-char)
(while (re-search-forward "^#\\+.*$" nil t) (while (re-search-forward "^#\\+\\(title\\|subtitle\\|options\\|keywords\\|date\\|email\\|author\\).*$" nil t)
(progn (progn
(replace-match "") (replace-match "")
(kill-line))) (kill-line)))
@ -187,8 +197,7 @@
(goto-char (point-min)) (goto-char (point-min))
(search-forward "<body>") (search-forward "<body>")
(insert (mapconcat 'identity (insert (mapconcat 'identity
'( '("<input id=\"light\">"
"<input id=\"light\">"
"<input id=\"raw\">" "<input id=\"raw\">"
"<input id=\"modern\">" "<input id=\"modern\">"
"<input id=\"dark\">" "<input id=\"dark\">"
@ -204,12 +213,8 @@
"<a href=\"#dark\">dark</a>" "<a href=\"#dark\">dark</a>"
"(<a href=\"#darkraw\">raw</a>)" "(<a href=\"#darkraw\">raw</a>)"
"</div>" "</div>"
"</div>" "</div>")
"<div class=\"main\">") "\n"))
"\n"))
(goto-char (point-max))
(search-backward "</body>")
(insert "\n</div>\n")
(save-buffer) (save-buffer)
(kill-buffer)) (kill-buffer))
file-path)) file-path))
@ -235,22 +240,16 @@ Return output file name."
(defalias 'org-blog-posts-sitemap-fn (defalias 'org-blog-posts-sitemap-fn
(apply-partially 'org-blog-sitemap-fn-descr posts-descr)) (apply-partially 'org-blog-sitemap-fn-descr posts-descr))
(defalias 'org-blog-micro-sitemap-fn
(apply-partially 'org-blog-sitemap-fn-descr micro-descr))
(defalias 'org-blog-sitemap-format-entry-posts (defalias 'org-blog-sitemap-format-entry-posts
(apply-partially 'org-blog-sitemap-format-entry "posts")) (apply-partially 'org-blog-sitemap-format-entry "posts"))
(defalias 'org-blog-sitemap-format-entry-micro
(apply-partially 'org-blog-sitemap-format-entry "micro"))
(defun donothing (_x _y _z) (defun donothing (_x _y _z)
nil) nil)
(setq org-publish-project-alist (setq org-publish-project-alist
`(("orgfiles" `(("orgfiles"
:base-directory ,base-dir :base-directory ,base-dir
:exclude ".*\\(drafts\\|posts\||micro\\)/.*" :exclude ".*drafts/.*\\|.*/rss.*"
:base-extension "org" :base-extension "org"
:publishing-directory ,publish-dir :publishing-directory ,publish-dir
:recursive t :recursive t
@ -273,32 +272,26 @@ Return output file name."
:base-directory ,posts-dir :base-directory ,posts-dir
:base-extension "org" :base-extension "org"
:publishing-directory "/dev/null" :publishing-directory "/dev/null"
:exclude "rss\\.org"
:recursive t :recursive t
:with-date t
:publishing-function donothing :publishing-function donothing
:auto-sitemap t :auto-sitemap t
:sitemap-filename "posts.org" :sitemap-filename "index.org"
:sitemap-title "Articles" :sitemap-title "Articles"
:sitemap-style list :sitemap-style list
:sitemap-sort-files anti-chronologically) :sitemap-sort-files anti-chronologically
:sitemap-format-entry date-format-entry
:sitemap-function org-blog-posts-sitemap-fn)
("posts" ("posts-rss"
:base-directory ,posts-dir :base-directory ,posts-dir
:base-extension "org" :base-extension "org"
:publishing-directory ,posts-publish-dir :publishing-directory "/dev/null"
:recursive t :recursive t
:publishing-function org-blog-publish-to-html :publishing-function donothing
:with-toc nil
:with-title nil :with-title nil
:with-date t :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 "rss.org" :sitemap-filename "rss.org"
:sitemap-title "Used For RSS" :sitemap-title "Used For RSS"
@ -307,32 +300,6 @@ Return output file name."
:sitemap-format-entry org-blog-sitemap-format-entry-posts :sitemap-format-entry org-blog-sitemap-format-entry-posts
:sitemap-function org-blog-posts-sitemap-fn) :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 "rss.org"
:sitemap-title "Micro Blog Posts"
:sitemap-style list
:sitemap-sort-files anti-chronologically
:sitemap-format-entry org-blog-sitemap-format-entry-micro
:sitemap-function org-blog-micro-sitemap-fn)
("assets" ("assets"
:base-directory ,assets-dir :base-directory ,assets-dir
:base-extension ".*" :base-extension ".*"
@ -350,12 +317,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 ("posts/rss.org" :include ("posts/rss.org")
"micro/rss.org")
:section-numbers nil :section-numbers nil
:table-of-contents nil) :table-of-contents nil)
("blog" :components ("orgfiles" "posts" "posts-index" "micro" "assets" "rss")))) ("blog" :components ("posts-rss" "posts-index" "orgfiles" "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

@ -1,6 +0,0 @@
#+TITLE: Articles
- [[file:rss.org][Used For RSS]]
- [[file:project-el/index.org][Autoload Script by project]]
- [[file:troll-2/index.org][Troll 2]]
- [[file:new-blog.org][New Blog]]

View File

@ -2,7 +2,7 @@
#+SUBTITLE: fast, secure, easy autoload #+SUBTITLE: fast, secure, easy autoload
#+AUTHOR: Yann Esposito #+AUTHOR: Yann Esposito
#+EMAIL: yann@esposito.host #+EMAIL: yann@esposito.host
#+DATE: [2019-08-17 Sat] #+DATE: [2019-08-18 Sun]
#+KEYWORDS: programming, blog, org-mode #+KEYWORDS: programming, blog, org-mode
#+OPTIONS: auto-id:t #+OPTIONS: auto-id:t