[tomboy-list] Export All Notes to HTML

Pedro pedro100 at gmail.com
Tue Dec 30 10:36:00 PST 2008


In theory you wouldn't need to migrate to C# in order to wrap it into
an addin. However I find it rather confusing to use assemblies in
multiple languages.

This looks cool.
Could you host the script somewhere one can download it? Sending it by
email breaks indentation and therefore code integrity.



On Mon, Dec 29, 2008 at 1:03 AM, mengzhuo li <muziwind at yahoo.com.cn> wrote:
> i send a patch before. i think it may solve the request.
> look http://bugzilla.gnome.org/show_bug.cgi?id=554569
>
> --- 08年12月27日,周六, David H. Vree <david.h.vree at gmail.com> 写道:
>
> 发件人: David H. Vree <david.h.vree at gmail.com>
> 主题: Re: [tomboy-list] Export All Notes to HTML
> 收件人: tomboy-list at lists.beatniksoftware.com
> 日期: 2008,1227,周六,3:02下午
>
> Sandy Armstrong wrote:
>
> When I am done, I believe I'll have an export-all to HTML and PDF
> that will create a well-named file for each note and put then into a
> directory named after the notebook.  It's really the start of a
> Tomboy archival utility....
>
>
> I'd really like to see the Export to HTML add-in updated to handle
> this.  See this bug:
>
> http://bugzilla.gnome.org/show_bug.cgi?id=356871
>
> Really, you should be able to select any set of notes, or a notebook, or
> all notes, and export them.  It should be pretty easy to update the
> existing add-in to do this, and then everybody can benefit from having
> it right in the Tomboy UI.
>
> I should think it would be pretty easy to decouple the XSL/HTML part of
> this from the rest of it, and make pluggable export backends for people
> who want PDF or other formats.
>
> Anyway, whatever you end up doing, looking forward to seeing it!
>
> Best,
> Sandy
>
>
> Sandy,
>
> I am sorry I didn't have time to fix the issues with the add-in.  Instead, I
> hammered out a small python script that uses dbus, to do an HTML dump of all
> notes in all notebooks.  It has numerous issues I'd like to fix, but I was
> desperate to have a solution by year end, so I stopped working as soon as it
> did what I needed.  The script depends on having the add-in's xslt file
> available.
>
> At any rate, here is the source in case somebody else wants to improve it or
> migrate it to the C# add-in.  If I get time, I'll try to do this myself next
> year.
>
> Thanks for your help,
> Dave
>
>
> #!/usr/bin/env python
> import sys, dbus, gobject, time, dbus.glib, os, re
>
> # TO DO:
> # strip periods out of file names (use a better approach that is easier to
> understand than re)
> # make subdirectories for each notebook instead of prepending notebook name
> # take xslt as another command line argument (or look in current
> directory....)
> # fix interfile links to point to other files (do this in the xslt file)
> # add an option to also make pdfs
> # have better archive directory default...make it if it doesn't
> exist...prompt?
>
>
> # Get tomboy dbus interface object
> bus = dbus.SessionBus()
> obj = bus.get_object("org.gnome.Tomboy", "/org/gnome/Tomboy/RemoteControl")
> tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")
>
> # Set archive directory
> if len(sys.argv) > 1: archive_directory = " ".join(sys.argv[1:])
> else: archive_directory = "~/"
>
> # Loop through all the notes
> all_notes = tomboy.ListAllNotes()
> for note in all_notes:
>
>     # Get source filename
>     note_filename = "~/." + note[7:] + ".note"
>     #print note_filename
>
>     # Get title
>     note_title = tomboy.GetNoteTitle(note)
>     #print note_title
>
>     # Get notebook name
>     note_notebook = "Unfiled"
>     note_tags = tomboy.GetTagsForNote(note)   # Notebook name is stored as a
> special tag
>     for tag in note_tags:
>         # See if this tag is the "notebook" tag, if so capitalize all words
> in notebook name and strip odd characters
>         if tag[0:16] == "system:notebook:" : note_notebook =
> tag[16:].title().replace(" ","").replace("-","")
>     #print note_notebook
>
>     # Create filesystem safe filename based on notebook name and note title
> (replace illegal characters with underscore)
>     badchars= re.compile(r'[^A-Za-z0-9_. ]+|^\.|\.$|^ | $|^$')    # These
> are characters that should not be used in a file name
>     note_archive_filename = note_notebook + "-" + badchars.sub('_',
> note_title).replace(" ", "_")[0:40] + ".html"    # Limit file name to 40
> chars
>     note_archive_filename = os.path.join(archive_directory,
> note_archive_filename)
>     print note_archive_filename
>
>     # Run original note through XSL transformation to make HTML file
>     os.system("xsltproc ~/ExportToHtml.xsl " + note_filename + " > \"" +
> note_archive_filename + "\"")
>
>
> _______________________________________________
> Tomboy-list mailing list
> Tomboy-list at lists.beatniksoftware.com
> http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com
>
> ________________________________
> 好玩贺卡等你发,邮箱贺卡全新上线!
> _______________________________________________
> Tomboy-list mailing list
> Tomboy-list at lists.beatniksoftware.com
> http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com
>
>


More information about the Tomboy-list mailing list