emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Advice on cleaning (DRYing) up my publishing list
@ 2014-01-03  9:48 Justin Gordon
  2014-01-03 21:37 ` Nick Dokos
  0 siblings, 1 reply; 2+ messages in thread
From: Justin Gordon @ 2014-01-03  9:48 UTC (permalink / raw)
  To: emacs-orgmode, Yoshinari Nomura

[-- Attachment #1: Type: text/plain, Size: 6507 bytes --]

Lisp gurus, here is my feeble attempt at DRYing out my
org-publish-project-alist.

I'm setting up an octopress publishing system for several blogs, so my list
might grow and I'd like to avoid duplication

* Please advise on how I may make this cleaner and clearer. Original is at
bottom.
* And is there a better way than using the publishing settings for things
like with-toc?
* Does recursive still work for 8.2?
* Would this be better done with some sort of macros?

Thanks so much in advance!



(setq my-common-octopress-settings
      '(:base-extension "org"
                        :with-toc nil
                        :with-sub-superscript nil
                        :recursive t
                        :publishing-function org-jekyll-publish-to-html
                        :headline-levels 4
                        :body-only t))

(setq my-static-directories '("about" "meta" "tips"))
(setq my-base-directory "~/a/railsonmaui-octopress/source")

(defun my-create-octopress-static (prj base-directory)
         (let* (
                (base-dir (concat base-directory "/" prj))
                (prj-list (append (list :base-directory base-dir
                                              :publishing-directory
base-dir)
                            my-common-octopress-settings))
                )
           (cons prj prj-list)))

(setq my-var (mapcar '(lambda (prj)
                        (my-create-octopress-static prj my-base-directory))
        my-static-directories))

(setq org-publish-project-alist
      (list
        ;; blog articles
        (cons "blog-org"  (append '(:base-directory
"~/a/railsonmaui-octopress/source/org_posts/"
                                                 :base-extension "org"
                                                 :publishing-directory
"~/a/railsonmaui-octopress/source/_posts/")
                               my-common-octopress-settings))
        (cons "blog-extra" '(:base-directory
"~/a/railsonmaui-octopress/source/org_posts/"
                                         :publishing-directory
"~/a/railsonmaui-octopress/source/"
                                         :base-extension
"css\\|pdf\\|png\\|jpg\\|gif\\|svg"
                                         :publishing-function
org-publish-attachment
                                         :recursive t
                                         :author nil
                                         ))
       (mapcar '(lambda (prj)
                        (my-create-octopress-static prj my-base-directory))
        my-static-directories)

        ;; all together
        (cons "blog" '(:components ("blog-org" "blog-extra about meta
tips")))
        )
      )




ORIGINAL
(setq org-publish-project-alist
      '(
        ("blog-org" .  (:base-directory "~/a/octopress/source/org_posts/"
                                        :base-extension "org"
                                        :publishing-directory
"~/a/octopress/source/_posts/"
                                        :table-of-contents nil
                                        :sub-superscript nil
                                        :recursive t
                                        :publishing-function
org-publish-org-to-octopress
                                        :headline-levels 4
                                        :html-extension "markdown"
                                        :octopress-extension "markdown"
                                        :body-only t))
        ("blog-extra" . (:base-directory "~/a/octopress/source/org_posts/"
                                         :publishing-directory
"~/a/octopress/source/"
                                         :base-extension
"css\\|pdf\\|png\\|jpg\\|gif\\|svg"
                                         :publishing-function
org-publish-attachment
                                         :recursive t
                                         :author nil
                                         ))
        ("about" .  (:base-directory "~/a/octopress/source/about/"
                                        :base-extension "org"
                                        :publishing-directory
"~/a/octopress/source/about/"
                                        :sub-superscript nil
                                        :table-of-contents nil
                                        :recursive t
                                        :publishing-function
org-publish-org-to-octopress
                                        :headline-levels 4
                                        :html-extension "markdown"
                                        :octopress-extension "markdown"
                                        :body-only t))
        ("meta" .  (:base-directory "~/a/octopress/source/meta/"
                                        :base-extension "org"
                                        :publishing-directory
"~/a/octopress/source/meta/"
                                        :sub-superscript nil
                                        :table-of-contents nil
                                        :recursive t
                                        :publishing-function
org-publish-org-to-octopress
                                        :headline-levels 4
                                        :html-extension "markdown"
                                        :octopress-extension "markdown"
                                        :body-only t))
        ("tips" .  (:base-directory "~/a/octopress/source/tips/"
                                        :base-extension "org"
                                        :publishing-directory
"~/a/octopress/source/tips/"
                                        :sub-superscript nil
                                        :table-of-contents nil
                                        :recursive t
                                        :publishing-function
org-publish-org-to-octopress
                                        :headline-levels 4
                                        :html-extension "markdown"
                                        :octopress-extension "markdown"
                                        :body-only t))

        ("blog" . (:components ("blog-org" "blog-extra about")))
))






-- 
Justin Gordon | 808-877-6461 | m: 808-281-7272
www.railsonmaui.com | twitter: @railsonmaui<https://twitter.com/railsonmaui>
 | sugarranchmaui.com <http://www.sugarranchmaui.com/> | Sugar Ranch
Blog<https://www.facebook.com/SugarRanch>

[-- Attachment #2: Type: text/html, Size: 9279 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Advice on cleaning (DRYing) up my publishing list
  2014-01-03  9:48 Advice on cleaning (DRYing) up my publishing list Justin Gordon
@ 2014-01-03 21:37 ` Nick Dokos
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Dokos @ 2014-01-03 21:37 UTC (permalink / raw)
  To: emacs-orgmode

Justin Gordon <justin.gordon@gmail.com> writes:

> Lisp gurus, here is my feeble attempt at DRYing out my org-publish-project-alist. 
>
> I'm setting up an octopress publishing system for several blogs, so my list might grow and I'd like to avoid duplication
>
> * Please advise on how I may make this cleaner and clearer. Original is at bottom.
> * And is there a better way than using the publishing settings for things like with-toc?
> * Does recursive still work for 8.2?
> * Would this be better done with some sort of macros?
>

Yes, instead of constructing list structure on the fly as you do below
(cons, append, list, etc.), check out ``Backquote'':

       (info "(elisp) Backquote")

-- 
Nick

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-03 21:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-03  9:48 Advice on cleaning (DRYing) up my publishing list Justin Gordon
2014-01-03 21:37 ` Nick Dokos

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).