emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Sebastian Rose <sebastian_rose@gmx.de>
To: "[emacs-orgmode]" <emacs-orgmode@gnu.org>
Subject: Patch for Sitemap: org-publish-org-index
Date: Thu, 05 Jun 2008 03:37:04 +0200	[thread overview]
Message-ID: <48474340.8010203@gmx.de> (raw)

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

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,

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

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
 

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

                 reply	other threads:[~2008-06-05  1:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=48474340.8010203@gmx.de \
    --to=sebastian_rose@gmx.de \
    --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).