From: Robert Klein <roklein@roklein.de>
To: emacs-orgmode@gnu.org
Cc: Peter Davis <pfd@pfdstudio.com>, Rasmus <rasmus@gmx.us>
Subject: HTML/images zipped projects
Date: Tue, 07 Jul 2015 20:25:11 +0200 (CEST) [thread overview]
Message-ID: <20150707.202511.1894713262739236530.roklein@roklein.de> (raw)
Hello,
I looked further into this and now have a way to create archives of
projects. I provide two functions for use in projects preparation and
completion functions (for a project of component projects the former
is to be used in the first projects preparation function and the
latter in the last projects completion function. (See below)
For single file export (cf. the ox-htmlzip example I sent earlier) I
have some ideas, but haven't implemented them yet (Vaidheeswaran C's
comment about epub being close to zip hit a nerve, so I'll take a shot
at extending it to an epub exporter..
Best regards
Robert
** Archiving Projects
When archiving project you face some issues not present when archiving a
single export.
A export project you want to archive often may be a project composed of
two or more subprojects, e.g. one to publish to HTML, one to PDF and one
to copy the PDF files as well as css files and images created outside of
org to the `publishing-directory'.
As all those files end up in the `publishing-directory' the way
presented here happens before the first project in the components list
is published (clean-up, preparation) and after the last project (removal
of old archive, creation of new one).
To get a multi-project project archive, you call
rk/ox-publish--create-archive-prepare from the preparation-function of
the first project in `:components' project and
rk/ox-publish--create-archive-complete from the completion-function of
the last project.
#+begin_src emacs-lisp
(defun rk/ox-publish--create-archive-prepare (&optional
delete-pubdir
delete-timestamps
project-list)
"Prepares the creation of an archive of publishing projects.
To get a archive cleaned up of old files not longer part of the
project set DELETE-PUBDIR to `t'.
To be sure everything gets published anew, set DELETE-TIMESTAMPS
to `t' and provide ad s PROJECT-LIST a list of projects
publishing the material for the archive."
(let ((pubdir (plist-get project-plist :publishing-directory)))
(when (and delete-timestamps project-list)
(mapc (function (lambda (project)
(let ((cache-file
(concat "~/.org-timestamps/"
project ".cache")))
(when (file-exists-p cache-file)
(delete-file cache-file)))))
project-list))
(when delete-pubdir
;; try to only shoot yourself in the foot, not in the head
(if (not (equal (file-truename "~/")
(file-truename pubdir)))
(when (file-exists-p pubdir)
(delete-directory pubdir t))))))
(defun rk/ox-publish--create-archive-complete (&optional archive
archiver-program
archiver-options)
"Creates archive ARCHIVE from published project(s).
If ARCHIVE is nil, the ARCHIVE name will be the name of the
publishing-directory plus `.zip'. The archive is stored in the
same directory the publishing directory is in.
The default archive format is zip.
A optional ARCHIVER-COMMAND (and ARCHIVER-OPTIONS) has to follow
the syntax
ARCHIVER-COMMAND ARCHIVER-OPTIONS archive-file files/dirs
Examples for some archive formats:
| format | ARHCIVER-COMMAND | ARCHIVER-OPTIONS | needs programs |
|---------+------------------+------------------+----------------+
| zip | zip | -r | zip |
| tar.gz | tar | -zcvf | tar, gzip |
| tar.bz2 | tar | -jcvf | tar, bzip2 |
| tar.xz | tar | -Jcvf | tar, xz |
| tar.Z | tar | -Zcvf | tar, compress |
| 7z | 7z | a | 7z |"
(let* ((pubdir (plist-get project-plist :publishing-directory))
(zip-program (or archiver-program "zip"))
(zip-options (if archiver-program archiver-options "-r"))
(zip-file (or archive
(concat pubdir ".zip")))
(default-directory (file-truename (concat pubdir "/../")))
(zip-command (concat zip-program " "
zip-options " "
zip-file " "
(file-name-nondirectory pubdir) " ")))
(when (file-exists-p zip-file)
(delete-file zip-file))
(message "Archiving: %s\n" zip-command)
(shell-command zip-command)))
#+end_src
next reply other threads:[~2015-07-07 18:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 18:25 Robert Klein [this message]
2015-07-07 19:02 ` HTML/images zipped projects Rasmus
2015-07-08 1:53 ` Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150707.202511.1894713262739236530.roklein@roklein.de \
--to=roklein@roklein.de \
--cc=emacs-orgmode@gnu.org \
--cc=pfd@pfdstudio.com \
--cc=rasmus@gmx.us \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).