emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Sitemap patch - better version
@ 2008-06-15 23:31 Sebastian Rose
  0 siblings, 0 replies; only message in thread
From: Sebastian Rose @ 2008-06-15 23:31 UTC (permalink / raw)
  To: [emacs-orgmode]

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

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

[-- Attachment #2: org-publish.el.patch --]
[-- Type: text/x-patch, Size: 2341 bytes --]

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
 

[-- Attachment #3: sebastian_rose.vcf --]
[-- Type: text/x-vcard, Size: 499 bytes --]

begin:vcard
fn:Sebastian Rose
n:Rose;Sebastian
email;internet:sebastian_rose@gmx.de
title:Fachinformatiker/Anwendendungsentwicklung
tel;cell:+49 173 / 83 93 417
note;quoted-printable:Entwicklung  von Internetanwendungen und Programmen  mit  freien  Werkzeu=
	gen  und Bibliotheken.=0D=0A=
	=0D=0A=
	PHP, Java, C/C++,  Bash,  Perl,  Apache, MySQL,  PostgreSQL, xt::commerce=
	, Typo3, Server,  Netzwerk,  Desktop, Datenbank, gtkmm=0D=0A=
	
x-mozilla-html:FALSE
version:2.1
end:vcard


[-- Attachment #4: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-15 23:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-15 23:31 Sitemap patch - better version Sebastian Rose

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