emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jambunathan K <kjambunathan@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-odt: Include mimetype in the exported odt file
Date: Wed, 27 Jul 2011 02:54:12 +0530	[thread overview]
Message-ID: <81aac0burn.fsf@gmail.com> (raw)

[-- Attachment #1: 0001-org-odt-Include-mimetype-in-the-exported-odt-file.patch --]
[-- Type: text/plain, Size: 3188 bytes --]

From 3530d2b3bd5b903e9b568a6412573faa79862d36 Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@gmail.com>
Date: Wed, 27 Jul 2011 02:50:48 +0530
Subject: [PATCH] org-odt: Include mimetype in the exported odt file

* contrib/lisp/org-odt.el (org-export-odt-save-list): Add the
file "mimetype".
(org-odt-init-outfile): Write contents of "mimetype".
(org-odt-save-as-outfile): Include "mimetype" file in the
exported file.
(org-export-odt-mimetype-lines): Removed.

This change knocks of an error while validating against
http://tools.services.openoffice.org/odfvalidator/.
---
 contrib/lisp/org-odt.el |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el
index b7e5a70..bab7590 100644
--- a/contrib/lisp/org-odt.el
+++ b/contrib/lisp/org-odt.el
@@ -1091,7 +1091,7 @@ MAY-INLINE-P allows inlining it as an image."
 
 ;; xml files generated on-the-fly
 (defconst org-export-odt-save-list
-  '("META-INF/manifest.xml" "content.xml" "meta.xml" "styles.xml"))
+  '("mimetype" "META-INF/manifest.xml" "content.xml" "meta.xml" "styles.xml"))
 
 ;; xml files that are copied
 (defconst org-export-odt-nosave-list '())
@@ -1262,6 +1262,10 @@ MAY-INLINE-P allows inlining it as an image."
       (save-excursion
 	(insert (mapconcat 'identity (cdr org-export-odt-meta-lines) "\n"))))
 
+    ;; mimetype
+    (with-current-buffer (find-file-noselect mimetype-file t)
+      (insert "application/vnd.oasis.opendocument.text"))
+
     ;; styles file
     ;; (copy-file org-export-odt-styles-file styles-file t)
 
@@ -1273,9 +1277,6 @@ MAY-INLINE-P allows inlining it as an image."
 	  (append org-export-odt-save-list org-export-odt-nosave-list)))
     content-file))
 
-(defconst org-export-odt-mimetype-lines
-  '("application/vnd.oasis.opendocument.text"))
-
 (defconst org-odt-manifest-file-entry-tag
   "<manifest:file-entry manifest:media-type=\"%s\" manifest:full-path=\"%s\"/>")
 
@@ -1319,23 +1320,22 @@ MAY-INLINE-P allows inlining it as an image."
 
     (let* ((target-name (file-name-nondirectory target))
 	   (target-dir (file-name-directory target))
-	   (cmd (format "zip -rmTq %s %s" target-name ".")))
+	   (cmds `(("zip" "-mX0" ,target-name "mimetype")
+		   ("zip" "-rmTq" ,target-name "."))))
       (when (file-exists-p target)
 	;; FIXME: If the file is locked this throws a cryptic error
 	(delete-file target))
 
       (let ((coding-system-for-write 'no-conversion) exitcode)
-	(message "Creating odt file using \"%s\"" cmd)
-	(setq exitcode
-	      (apply 'call-process
-		     "zip"
-		     nil
-		     nil
-		     nil
-		     (append (list "-rmTq") (list target-name "."))))
-
-	(or (zerop exitcode)
-	    (error "Unable to create odt file (%S)" exitcode)))
+	(message "Creating odt file...")
+	(mapc
+	 (lambda (cmd)
+	   (message "Running %s" (mapconcat 'identity cmd " "))
+	   (setq exitcode
+		 (apply 'call-process (car cmd) nil nil nil (cdr cmd)))
+	   (or (zerop exitcode)
+	       (error "Unable to create odt file (%S)" exitcode)))
+	 cmds))
 
       ;; move the file from outdir to target-dir
       (rename-file target-name target-dir)
-- 
1.7.2.3


[-- Attachment #2: Type: text/plain, Size: 6 bytes --]



-- 

             reply	other threads:[~2011-07-26 21:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-26 21:24 Jambunathan K [this message]
2011-07-27 12:42 ` [PATCH] org-odt: Include mimetype in the exported odt file Bastien

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=81aac0burn.fsf@gmail.com \
    --to=kjambunathan@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).