From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Rose Subject: Patch for Sitemap: org-publish-org-index Date: Thu, 05 Jun 2008 03:37:04 +0200 Message-ID: <48474340.8010203@gmx.de> Reply-To: sebastian_rose@gmx.de Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070701030302060805080507" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K44Ov-0007ub-Pj for emacs-orgmode@gnu.org; Wed, 04 Jun 2008 21:36:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K44Ou-0007uF-6E for emacs-orgmode@gnu.org; Wed, 04 Jun 2008 21:36:25 -0400 Received: from [199.232.76.173] (port=53270 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K44Ou-0007uB-4M for emacs-orgmode@gnu.org; Wed, 04 Jun 2008 21:36:24 -0400 Received: from mail.gmx.net ([213.165.64.20]:36309) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1K44Ot-0006r6-IG for emacs-orgmode@gnu.org; Wed, 04 Jun 2008 21:36:23 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "[emacs-orgmode]" This is a multi-part message in MIME format. --------------070701030302060805080507 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, the creation of the sitemap was not working for my project when publishing. There were two bugs: * The title of the page was made from index-file-name and a broken link. * When publishing recursively, the links to files were not working (missing relative path) The appended patch (in horror-lisp :-) fixes these two bugs. I diffed against the current git version (using 'git-diff lisp/org-publish.el'). Additionally subdirectories get an extra link with a '/' appended. The files and directories in subdirectories are indented, so the tree structure of the published project is visible. I know the code looks terrible, but it works just fine here. Regards, --------------070701030302060805080507 Content-Type: text/x-patch; name="org-publish.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="org-publish.diff" diff --git a/lisp/org-publish.el b/lisp/org-publish.el index 54d489c..40553f1 100644 --- a/lisp/org-publish.el +++ b/lisp/org-publish.el @@ -583,6 +583,8 @@ Default for INDEX-FILENAME is 'index.org'." (let* ((project-plist (cdr project)) (dir (file-name-as-directory (plist-get project-plist :base-directory))) + (localdir (file-name-directory dir)) + (indent-str (make-string 2 ? )) (exclude-regexp (plist-get project-plist :exclude)) (files (org-publish-get-base-files project exclude-regexp)) (index-filename (concat dir (or index-filename "index.org"))) @@ -597,15 +599,35 @@ Default for INDEX-FILENAME is 'index.org'." (with-temp-buffer (insert (concat index-title "\n\n")) (while (setq file (pop files)) - (let ((fn (file-name-nondirectory file))) + (let ((fn (file-name-nondirectory file)) + (link (file-relative-name file dir)) + (oldlocal localdir)) ;; index shouldn't index itself - (unless (string= fn ifn) - (insert (concat " + [[file:" fn "][" + (unless (string= fn ifn) + (setq localdir (concat (file-name-as-directory dir) (file-name-directory link))) + (unless (string= localdir oldlocal) + (if (string= (file-name-directory (directory-file-name localdir)) + (file-name-directory (directory-file-name oldlocal))) + (progn ; next subdir, same parent + (setq indent-str (make-string (- (length indent-str) 2) ? )) + (insert (concat indent-str " + [[file:" (file-relative-name localdir dir) + "][" (file-relative-name localdir dir) "]]\n")) + (setq indent-str (make-string (+ (length indent-str) 2) ? ))) + (if (> (length localdir) (length oldlocal)) + (progn ; entering deeper subdir + (insert (concat indent-str " + [[file:" (file-relative-name localdir dir) + "][" (file-relative-name localdir dir) "]]\n")) + (setq indent-str (make-string (+ (length indent-str) 2) ? ))) + ; up directory + (setq indent-str (make-string (- (length indent-str) 2) ? ))))) + (insert (concat indent-str " + [[file:" link "][" (file-name-sans-extension fn) "]]\n"))))) (write-file index-filename) (kill-buffer (current-buffer))))) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Interactive publishing functions --------------070701030302060805080507 Content-Type: text/x-vcard; charset=utf-8; name="sebastian_rose.vcf" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="sebastian_rose.vcf" YmVnaW46dmNhcmQNCmZuOlNlYmFzdGlhbiBSb3NlDQpuOlJvc2U7U2ViYXN0aWFuDQplbWFp bDtpbnRlcm5ldDpzZWJhc3RpYW5fcm9zZUBnbXguZGUNCnRpdGxlOkZhY2hpbmZvcm1hdGlr ZXIvQW53ZW5kZW5kdW5nc2VudHdpY2tsdW5nDQp0ZWw7Y2VsbDorNDkgMTczIC8gODMgOTMg NDE3DQpub3RlO3F1b3RlZC1wcmludGFibGU6RW50d2lja2x1bmcgIHZvbiBJbnRlcm5ldGFu d2VuZHVuZ2VuIHVuZCBQcm9ncmFtbWVuICBtaXQgIGZyZWllbiAgV2Vya3pldT0NCglnZW4g IHVuZCBCaWJsaW90aGVrZW4uPTBEPTBBPQ0KCT0wRD0wQT0NCglQSFAsIEphdmEsIEMvQysr LCAgQmFzaCwgIFBlcmwsICBBcGFjaGUsIE15U1FMLCAgUG9zdGdyZVNRTCwgeHQ6OmNvbW1l cmNlPQ0KCSwgVHlwbzMsIFNlcnZlciwgIE5ldHp3ZXJrLCAgRGVza3RvcCwgRGF0ZW5iYW5r LCBndGttbT0wRD0wQT0NCgkNCngtbW96aWxsYS1odG1sOkZBTFNFDQp2ZXJzaW9uOjIuMQ0K ZW5kOnZjYXJkDQoNCg== --------------070701030302060805080507 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --------------070701030302060805080507--