emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* HTML/images zipped projects
@ 2015-07-07 18:25 Robert Klein
  2015-07-07 19:02 ` Rasmus
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Klein @ 2015-07-07 18:25 UTC (permalink / raw)
  To: emacs-orgmode; +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

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

* Re: HTML/images zipped projects
  2015-07-07 18:25 HTML/images zipped projects Robert Klein
@ 2015-07-07 19:02 ` Rasmus
  2015-07-08  1:53   ` Eric Abrahamsen
  0 siblings, 1 reply; 3+ messages in thread
From: Rasmus @ 2015-07-07 19:02 UTC (permalink / raw)
  To: emacs-orgmode

Robert Klein <roklein@roklein.de> writes:

> 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..

BTW: do you know that ox-odt already zips files?  Perhaps you want to take
a look at it and see if its approach is useful and can be generalized for
your need.

Rasmus

-- 
Vote for proprietary math!

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

* Re: HTML/images zipped projects
  2015-07-07 19:02 ` Rasmus
@ 2015-07-08  1:53   ` Eric Abrahamsen
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Abrahamsen @ 2015-07-08  1:53 UTC (permalink / raw)
  To: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:

> Robert Klein <roklein@roklein.de> writes:
>
>> 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..
>
> BTW: do you know that ox-odt already zips files?  Perhaps you want to take
> a look at it and see if its approach is useful and can be generalized for
> your need.

Last year I started work on an "epub-mode", for editing epubs. I got
distracted and haven't worked on it much, but the zipping/unzipping is
in place, so maybe you could borrow that. When I finally finish it I was
planning on writing an integrated Org exporter, but who knows when that
will happen!

https://github.com/girzel/epub-mode

Eric

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

end of thread, other threads:[~2015-07-08  1:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-07 18:25 HTML/images zipped projects Robert Klein
2015-07-07 19:02 ` Rasmus
2015-07-08  1:53   ` Eric Abrahamsen

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).