From f2b5d8dbd116204fb282997cd2b800a303ae4a16 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Sun, 7 Jul 2019 18:11:45 +0200 Subject: [PATCH] mostly working now --- src/archive.org | 2 +- src/assets/css/minimalist.css | 5 +- src/index.org | 228 +++++++++++++++------------ src/posts/2019-07-04-org-publish.org | 147 ++++------------- 4 files changed, 163 insertions(+), 219 deletions(-) diff --git a/src/archive.org b/src/archive.org index d494551..5b8039b 100644 --- a/src/archive.org +++ b/src/archive.org @@ -2,5 +2,5 @@ #+begin_archive -@@html:
  • @@ @@html:@@ jul 06, 2019 @@html:@@ [[file:posts/2019-07-04-org-publish.org][Static blog with org-mode]] @@html:@@ @@html:
  • @@ +@@html:
  • @@ @@html:@@ Jul 05, 2019 @@html:@@ [[file:posts/2019-07-04-org-publish.org][org-publish]] @@html:@@ @@html:
  • @@ #+end_archive diff --git a/src/assets/css/minimalist.css b/src/assets/css/minimalist.css index 820ff5c..ea74a87 100644 --- a/src/assets/css/minimalist.css +++ b/src/assets/css/minimalist.css @@ -42,12 +42,13 @@ hr { line-height: 0; overflow: hidden; border: 0; - margin-bottom: 20px; + margin: 20px 0; } hr:after { content: "----------------------------------------------------------------------------------------------------"; font-family: monospace; position: absolute; + opacity: 0.3; top: 0; left: 0; font-size: 14px; @@ -120,3 +121,5 @@ h6 { color: #859900;} img { max-width: 100%; max-height: 800px; margin: 20px auto; } +footer { font-size: 0.8em; opacity: 0.5; } +footer:hover { opacity: 1; } diff --git a/src/index.org b/src/index.org index 3a0447f..2216efc 100644 --- a/src/index.org +++ b/src/index.org @@ -1,127 +1,153 @@ -* Code magic :noexport: +* Code magic :noexport: #+TITLE: her.esy.fun #+AUTHOR: Yann Esposito #+EMAIL: yann.esposito@gmail.com +#+DATE: 2019-07-04 #+KEYWORDS: programming #+DESCRIPTION: #+LANGUAGE: en #+LANG: en -#+CREATOR: Spacemacs, org-mode (Emacs 26.1, Org mode 9.2.3) #+OPTIONS: H:6 #+begin_src elisp :results none - (require 'org) - (require 'ox-publish) - (require 'ox-html) - (require 'org-element) - (require 'ox-rss) + (require 'org) + (require 'ox-publish) + (require 'ox-html) + (require 'org-element) + (require 'ox-rss) - (defun org-blog-prepare (project-plist) - "With help from `https://github.com/howardabrams/dot-files'. - Touch `index.org' to rebuilt it. - Argument `PROJECT-PLIST' contains information about the current project." - (let* ((base-directory (plist-get project-plist :base-directory)) - (buffer (find-file-noselect (expand-file-name "index.org" base-directory) t))) - (with-current-buffer buffer - (set-buffer-modified-p t) - (save-buffer 0)) - (kill-buffer buffer))) + (defun org-blog-prepare (project-plist) + "With help from `https://github.com/howardabrams/dot-files'. + Touch `index.org' to rebuilt it. + Argument `PROJECT-PLIST' contains information about the current project." + (let* ((base-directory (plist-get project-plist :base-directory)) + (buffer (find-file-noselect (expand-file-name "index.org" base-directory) t))) + (with-current-buffer buffer + (set-buffer-modified-p t) + (save-buffer 0)) + (kill-buffer buffer))) - (defvar org-blog-head - " - ") + (defvar org-blog-head + " + + + ") - (defun org-blog-preamble (_plist) - "Pre-amble for whole blog." - "Programing Heresy") + (defun org-blog-preamble (_plist) + "Pre-amble for whole blog." + "Programing Heresy") - (defun org-blog-postamble (_plist) - "Post-amble for whole blog." - "
    - Home - - Posts") + (defun menu () + "Blog menu" + "Home - + Posts") - (defun org-blog-sitemap-format-entry (entry _style project) - "Return string for each ENTRY in PROJECT." - (when (s-starts-with-p "posts/" entry) - (format "@@html:@@ %s @@html:@@ [[file:%s][%s]] @@html:@@" - (format-time-string "%h %d, %Y" - (org-publish-find-date entry project)) - entry - (org-publish-find-title entry project)))) + (defun get-from-info (info k) + (let ((i (car (plist-get info k)))) + (when (and i (stringp i)) + i))) - (defun org-blog-sitemap-function (title list) - "Return sitemap using TITLE and LIST returned by `org-blog-sitemap-format-entry'." - (concat "#+TITLE: " title "\n\n" - "\n#+begin_archive\n" - (mapconcat (lambda (li) - (format "@@html:
  • @@ %s @@html:
  • @@" (car li))) - (seq-filter #'car (cdr list)) - "\n") - "\n#+end_archive\n")) + (defun org-blog-postamble (info) + "Post-amble for whole blog." + (concat "")) - (setq base-dir (concat (projectile-project-root) "src")) - (setq publish-dir (concat (projectile-project-root) "_site")) - (setq assets-dir (concat base-dir "/assets")) - (setq publish-assets-dir (concat publish-dir "/assets")) - (setq rss-dir base-dir) - (setq publish-rss-dir publish-dir) - (setq domainname "https://her.esy.fun") - (setq org-publish-project-alist - `(("orgfiles" - :base-directory ,base-dir - :exclude ".*drafts/.*" - :base-extension "org" + (defun org-blog-sitemap-format-entry (entry _style project) + "Return string for each ENTRY in PROJECT." + (when (s-starts-with-p "posts/" entry) + (format "@@html:@@ %s @@html:@@ [[file:%s][%s]] @@html:@@" + (format-time-string "%h %d, %Y" + (org-publish-find-date entry project)) + entry + (org-publish-find-title entry project)))) - :publishing-directory ,publish-dir + (defun org-blog-sitemap-function (title list) + "Return sitemap using TITLE and LIST returned by `org-blog-sitemap-format-entry'." + (concat "#+TITLE: " title "\n\n" + "\n#+begin_archive\n" + (mapconcat (lambda (li) + (format "@@html:
  • @@ %s @@html:
  • @@" (car li))) + (seq-filter #'car (cdr list)) + "\n") + "\n#+end_archive\n")) - :recursive t - :preparation-function org-blog-prepare - :publishing-function org-html-publish-to-html + (setq base-dir (concat (projectile-project-root) "src")) + (setq publish-dir (concat (projectile-project-root) "_site")) + (setq assets-dir (concat base-dir "/assets")) + (setq publish-assets-dir (concat publish-dir "/assets")) + (setq rss-dir base-dir) + (setq publish-rss-dir publish-dir) + (setq domainname "https://her.esy.fun") + (setq org-publish-project-alist + `(("orgfiles" + :base-directory ,base-dir + :exclude ".*drafts/.*" + :base-extension "org" - :with-toc nil - :with-title 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 + :publishing-directory ,publish-dir - :auto-sitemap t - :sitemap-filename "archive.org" - :sitemap-title "Blog Posts" - :sitemap-style list - :sitemap-sort-files anti-chronologically - :sitemap-format-entry org-blog-sitemap-format-entry - :sitemap-function org-blog-sitemap-function) + :recursive t + :preparation-function org-blog-prepare + :publishing-function org-html-publish-to-html - ("assets" - :base-directory ,assets-dir - :base-extension ".*" - :publishing-directory ,publish-assets-dir - :publishing-function org-publish-attachment - :recursive t) + :with-toc nil + :with-title 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 - ("rss" - :base-directory ,rss-dir - :base-extension "org" - :html-link-home ,domainname - :html-link-use-abs-url t - :rss-extension "xml" - :publishing-directory ,publish-rss-dir - :publishing-function (org-rss-publish-to-rss) - :exclude ".*" - :include ("archive.org") - :section-numbers nil - :table-of-contents nil) + :auto-sitemap t + :sitemap-filename "archive.org" + :sitemap-title "Blog Posts" + :sitemap-style list + :sitemap-sort-files anti-chronologically + :sitemap-format-entry org-blog-sitemap-format-entry + :sitemap-function org-blog-sitemap-function) - ("blog" :components ("orgfiles" "assets" "rss")))) + ("assets" + :base-directory ,assets-dir + :base-extension ".*" + :publishing-directory ,publish-assets-dir + :publishing-function org-publish-attachment + :recursive t) - ;; add target=_blank and rel="noopener noreferrer" to all links by default + ("rss" + :base-directory ,rss-dir + :base-extension "org" + :html-link-home ,domainname + :html-link-use-abs-url t + :rss-extension "xml" + :publishing-directory ,publish-rss-dir + :publishing-function (org-rss-publish-to-rss) + :exclude ".*" + :include ("archive.org") + :section-numbers nil + :table-of-contents nil) + + ("blog" :components ("orgfiles" "assets" "rss")))) + + ;; 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) "Add target=\"_blank\" to external links." (when (and @@ -146,5 +172,3 @@ With a lot more minimalism in mind. With [[http://orgmode.org][org-mode]] - -TEST diff --git a/src/posts/2019-07-04-org-publish.org b/src/posts/2019-07-04-org-publish.org index 8b53223..60d20b5 100644 --- a/src/posts/2019-07-04-org-publish.org +++ b/src/posts/2019-07-04-org-publish.org @@ -1,129 +1,46 @@ #+TITLE: Static blog with org-mode #+AUTHOR: Yann Esposito #+EMAIL: yann.esposito@gmail.com -#+KEYWORDS: programming, blog +#+KEYWORDS: programming, blog, org-mode -[[https://her.esy.fun][her.esy.fun]] +This is the first article using my new blog system. -This is a new take on my personal blog. -With a lot more minimalism in mind. +Each time I try different things. -Fully done with [[https://orgmode.org][=org-mode=]]. +A long time ago, I used PHP for my first website. +I used include and took care of XHTML pages validation. +Then I used [[http://nanoc.ws][nanoc]], a ruby static website. +Then I switched to [[https://jaspervdj.be/hakyll/][hakyll]] because I wanted to switch to a Haskell's written tool. +Now I'll try to use emacs [[http://orgmode.org][org-mode]]. -* Code magic +So the article is a classical, Why?, How? -Here is how I publish this website in emacs using org-mode. -I just eval that code and then do a simple `org-publish` for the blog. +* Why? -And that's it. +Everything started when I was hired in a place where I was given a terrible +keyboard. +After a few weeks I started to feel a lot of pain in both my wrists. +So I started to go from classical IDE to being able to use vim +correctly[fn:vim]. -#+begin_src elisp :results none - (require 'org) - (require 'ox-publish) - (require 'ox-html) - (require 'org-element) - (require 'ox-rss) +Then I started to work in Clojure and I heard that emacs might certainly be a +better fit for LISP dialiects. +But, I couldn't switch to an editor without vim keybindings support because they +are so great once you're used to them. +But miracle it was about the time [[http://spacemacs.org][spacemacs]] appeared and I switched. +It was really impressive how well the vim keybindings worked so well. +Even most of the advanced vim features I used to use worked like a charm. - (defun org-blog-prepare (project-plist) - "With help from `https://github.com/howardabrams/dot-files'. - Touch `index.org' to rebuilt it. - Argument `PROJECT-PLIST' contains information about the current project." - (let* ((base-directory (plist-get project-plist :base-directory)) - (buffer (find-file-noselect (expand-file-name "index.org" base-directory) t))) - (with-current-buffer buffer - (set-buffer-modified-p t) - (save-buffer 0)) - (kill-buffer buffer))) +The first benefit of emacs is you can configure emacs with elisp. +Which unlike vimscript looks like a correct language to work with. - (defvar org-blog-head - " - ") +One unexpected benefit of emacs was [[http://orgmode.org][org-mode]]. +I always heard good things about it but it took me a while to really get it and +to understand why it is so great. - (defun org-blog-preamble (_plist) - "Pre-amble for whole blog." - "Programming Heresy") +If you don't know anything about org-mode, it is many things. +First imagine a Markdown but more TODO list oriented. +But along with this, emacs has a lot of helper functions to work with those +org-mode files. - (defun org-blog-postamble (_plist) - "Post-amble for whole blog." - "
    - Home - - Posts") - - (defun org-blog-sitemap-format-entry (entry _style project) - "Return string for each ENTRY in PROJECT." - (when (s-starts-with-p "posts/" entry) - (format (concat "@@html:" - "" - "@@ %s @@html:@@ [[file:%s][%s]] @@html:@@") - (format-time-string "%Y-%m-%d" - (org-publish-find-date entry project)) - entry - (org-publish-find-title entry project)))) - - (defun org-blog-sitemap-function (title list) - "Return sitemap using TITLE and LIST returned by `org-blog-sitemap-format-entry'." - (concat "#+TITLE: " title "\n\n" - "\n#+begin_archive\n" - (mapconcat (lambda (li) - (format "@@html:
  • @@ %s @@html:
  • @@" (car li))) - (seq-filter #'car (cdr list)) - "\n") - "\n#+end_archive\n")) - - (setq rootdir (projectile-project-root)) - - (setq org-publish-project-alist - `(("orgfiles" - :base-directory (concat rootdir "/src/") - :exclude ".*drafts/.*" - :base-extension "org" - - :publishing-directory (concat rootdir "/_site/") - - :recursive t - :preparation-function org-blog-prepare - :publishing-function org-html-publish-to-html - - :with-toc nil - :with-title 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 - :sitemap-filename "archive.org" - :sitemap-title "Blog Posts" - :sitemap-style list - :sitemap-sort-files anti-chronologically - :sitemap-format-entry org-blog-sitemap-format-entry - :sitemap-function org-blog-sitemap-function) - - ("assets" - :base-directory (concat rootdir "/src/assets/") - :base-extension ".*" - :publishing-directory (concat rootdir "/_site/assets/") - :publishing-function org-publish-attachment - :recursive t) - - ("rss" - :base-directory (concat rootdir "/src/") - :base-extension "org" - :html-link-home "https://her.esy.fun/" - :html-link-use-abs-url t - :rss-extension "xml" - :publishing-directory (concat rootdir "/") - :publishing-function (org-rss-publish-to-rss) - :exclude ".*" - :include ("archive.org") - :section-numbers nil - :table-of-contents nil) - - ("blog" :components ("orgfiles" "assets" "rss")))) -#+end_src +[fn:vim] I wrote this article to help people use vim: [[http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/][learn vim progressively]]