[snowy] Update Note view and XSLT to work specifically on a 'note-content' element.
- From: Sanford Armstrong <sharm src gnome org>
- To: svn-commits-list gnome org
- Subject: [snowy] Update Note view and XSLT to work specifically on a 'note-content' element.
- Date: Mon, 18 May 2009 14:20:09 -0400 (EDT)
commit 5767aca2c2f0cc0cd1e1a777634bf3b708589f18
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date: Mon May 18 11:19:14 2009 -0700
Update Note view and XSLT to work specifically on a 'note-content' element.
---
data/note2xhtml.xsl | 21 ++++-----------------
notes/views.py | 5 +++--
2 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/data/note2xhtml.xsl b/data/note2xhtml.xsl
index f107127..838e864 100644
--- a/data/note2xhtml.xsl
+++ b/data/note2xhtml.xsl
@@ -16,7 +16,7 @@
<xsl:param name="newline" select="'
'" />
<xsl:template match="/">
- <xsl:apply-templates select="tomboy:note"/>
+ <xsl:apply-templates select="tomboy:note-content"/>
</xsl:template>
<xsl:template match="text()">
@@ -40,26 +40,13 @@
</xsl:choose>
</xsl:template>
-<xsl:template match="tomboy:note">
- <xsl:apply-templates select="tomboy:text"/>
-</xsl:template>
-
-<xsl:template match="tomboy:text">
- <div class="note"
- id="{/tomboy:note/tomboy:title}">
- <a name="#{/tomboy:note/tomboy:title}" />
+<xsl:template match="tomboy:note-content">
+ <div class="note">
<xsl:apply-templates select="node()" />
</div>
-
- <xsl:if test="$export-linked and ((not($export-linked-all) and /tomboy:note/tomboy:title/text() = $root-note) or $export-linked-all)">
- <xsl:for-each select=".//link:internal/text()">
- <!-- Load in the linked note's XML for processing. -->
- <xsl:apply-templates select="document(.)/node()"/>
- </xsl:for-each>
- </xsl:if>
</xsl:template>
-<xsl:template match="tomboy:note/tomboy:text/*[1]/text()[1]">
+<xsl:template match="tomboy:note-content/*[1]/text()[1]">
<h1><xsl:value-of select="substring-before(., $newline)"/></h1>
<xsl:value-of select="substring-after(., $newline)"/>
</xsl:template>
diff --git a/notes/views.py b/notes/views.py
index b5603a0..90944e0 100644
--- a/notes/views.py
+++ b/notes/views.py
@@ -57,9 +57,10 @@ def note_detail(request, username, note_id, slug='',
# libxml2 doesn't munge encodings, so forcibly encode to UTF-8
# http://mail.gnome.org/archives/xml/2004-February/msg00363.html
- doc = libxml2.parseDoc(note.content.encode('UTF-8'))
+ # TODO: Check note.content_version so we can hypothetically apply different XSLT
+ content_to_parse = '<note-content version="1.0" xmlns:link="http://beatniksoftware.com/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size" xmlns="http://beatniksoftware.com/tomboy">' + note.content + '</note-content>'
+ doc = libxml2.parseDoc(content_to_parse.encode('UTF-8'))
result = style.applyStylesheet(doc, None)
-
# libxml2 doesn't munge encodings, so forcibly decode from UTF-8
body = unicode(style.saveResultToString(result), 'UTF-8')
finally:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]