+(setq org-export-time-stamp-file nil)
+(setq org-rss-use-entry-url-as-guid nil)
+
+(defun my-org-get-all-filetags ()
+ "Get list of filetags from all org-files in my-blog-posts-folder."
+ (let ((files (directory-files my-blog-posts-folder t nil nil nil))
+ tagslist x)
+ (save-window-excursion
+ (while (setq x (pop files))
+ (set-buffer (find-file-noselect x))
+ (mapc
+ (lambda (y)
+ (let ((tagfiles (assoc y tagslist)))
+ (if tagfiles
+ (setcdr tagfiles (cons x (cdr tagfiles)))
+ (add-to-list 'tagslist (list y x)))))
+ (my-org-get-filetags)))
+ tagslist)))
+
+(defun my-org-get-filetags ()
+ "Get list of filetags for current buffer"
+ (let ((ftags org-file-tags)
+ x)
+ (mapcar
+ (lambda (x)
+ (org-no-properties x))
+ ftags)))
+
+(defun my-blog-create-tags-files (plist)
+ "Create org files for each tag defined in FILETAGS in posts, storing them in my-blog-tags-folder."
+ (let* ((tagfolder (file-name-concat
+ (plist-get (cdr (assoc "landing" org-publish-project-alist)) :base-directory)))
+ (postfolder (file-name-concat
+ (plist-get (cdr (assoc "posts" org-publish-project-alist)) :base-directory)))
+ (relpostfolder (file-relative-name postfolder tagfolder)))
+ (unless (file-directory-p my-blog-tags-folder) (make-directory my-blog-tags-folder))
+ (with-temp-file (file-name-concat tagfolder "tag-index.org")
+ (insert (concat "#+mustache-template: " (file-name-concat my-blog-mustache-folder "tags-index.mustache") "\n"))
+ (insert (concat "#+TITLE: Blog - All tags\n"))
+ (insert "#+OPTIONS: ^:nil\n") ; do not use underscores as subscript
+ (insert "\n")
+ (dolist (tag (sort (my-org-get-all-filetags) (lambda (x y) (string-lessp (car x) (car y))) ))
+ (insert (concat "- [[file:" (file-name-concat relpostfolder (concat "tag-" (car tag) ".org")) "][" (car tag) "]]\n")))))
+ (dolist (tag (my-org-get-all-filetags))
+ (with-temp-file (file-name-concat my-blog-tags-folder (concat "tag-" (car tag) ".org"))
+ (insert (concat "#+mustache-template: " (file-name-concat my-blog-mustache-folder "tags.mustache") "\n"))
+ (insert (concat "#+TITLE: " (car tag) "\n"))
+ (insert "#+OPTIONS: ^:nil\n") ; do not use underscores as subscript
+ (insert "\n")
+ (insert (concat "# " (car tag) "\n\n"))
+ (dolist (tagfile (my-blog-sort-article-list (cdr tag) plist))
+ (let ((relpath (file-relative-name tagfile my-blog-posts-folder)));;not used
+ (message (concat "Processing " tagfile))
+ (insert (concat "- " (format "%s - [[file:%s][%s]]" ;;the date and filename are added after the entry
+ (format-time-string (car org-time-stamp-custom-formats) (org-publish-find-date tagfile plist))
+ relpath
+ (org-publish-find-title tagfile plist))
+ "\n")))))))
+ ;(my-org-publish-sitemap-default-entry tagfile nil plist) "\n")))))))