From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Klein Subject: HTML/images zipped projects Date: Tue, 07 Jul 2015 20:25:11 +0200 (CEST) Message-ID: <20150707.202511.1894713262739236530.roklein@roklein.de> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCXYX-0000wk-Qa for emacs-orgmode@gnu.org; Tue, 07 Jul 2015 14:25:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCXYU-0004Lc-G6 for emacs-orgmode@gnu.org; Tue, 07 Jul 2015 14:25:21 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:63579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCXYU-0004LK-6C for emacs-orgmode@gnu.org; Tue, 07 Jul 2015 14:25:18 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: Peter Davis , Rasmus 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