From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Rose Subject: Sitemap patch - better version Date: Mon, 16 Jun 2008 01:31:44 +0200 Message-ID: <4855A660.8060904@gmx.de> Reply-To: sebastian_rose@gmx.de Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070605090103010203010300" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K81gk-0002fA-Fe for emacs-orgmode@gnu.org; Sun, 15 Jun 2008 19:31:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K81gi-0002eW-SI for emacs-orgmode@gnu.org; Sun, 15 Jun 2008 19:31:10 -0400 Received: from [199.232.76.173] (port=59025 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K81gi-0002eP-L0 for emacs-orgmode@gnu.org; Sun, 15 Jun 2008 19:31:08 -0400 Received: from mail.gmx.net ([213.165.64.20]:34933) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1K81gi-0001rY-4M for emacs-orgmode@gnu.org; Sun, 15 Jun 2008 19:31:08 -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. --------------070605090103010203010300 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hello again, this is a reworked version of the last patch I sent for the function org-publish-org-index. It addresses a weekness of the former patch: * foodir/ + bardir/ - somefile * g instead of * g * foodir/bardir/ + somefile Note that foodir/ is empty. Indentation should now correct in all cases. The sitemap now lists the files in alphabetical order. M-x org-version RET Org-mode version 6.04c Sorry, could not pull the current version (git repo not reachable). Diff was created using git-diff org-publish.el --------------070605090103010203010300 Content-Type: text/x-patch; name="org-publish.el.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="org-publish.el.patch" diff --git a/lisp/org-publish.el b/lisp/org-publish.el index 54d489c..2c3ff7b 100644 --- a/lisp/org-publish.el +++ b/lisp/org-publish.el @@ -583,8 +583,10 @@ 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)) + (files (nreverse (org-publish-get-base-files project exclude-regexp))) (index-filename (concat dir (or index-filename "index.org"))) (index-title (or (plist-get project-plist :index-title) (concat "Index for project " (car project)))) @@ -597,15 +599,34 @@ 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= localdir dir) + (setq indent-str (make-string 2 ? )) + (let ((subdirs + (split-string + (directory-file-name + (file-name-directory + (file-relative-name localdir dir))) "/")) + (subdir "")) + (setq indent-str (make-string 2 ? )) + (dolist (d subdirs) + (setq subdir (concat subdir d "/")) + (insert (concat indent-str " + [[file:" subdir "][" d "/]]\n")) + (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 --------------070605090103010203010300 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== --------------070605090103010203010300 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 --------------070605090103010203010300--