[library-web/responsive] get a snippet from getting-started docs onto the frontpage



commit 3b03b349a84a233abffe56dd431e0b8989a846ef
Author: FrÃdÃric PÃters <fpeters 0d be>
Date:   Thu Jan 31 18:41:28 2013 +0100

    get a snippet from getting-started docs onto the frontpage

 data/xslt/dev_indexes.xsl |   16 ++++++++++++++++
 src/lgo.py                |    4 ++++
 src/modtypes/mallard.py   |   11 +++++++++++
 3 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/data/xslt/dev_indexes.xsl b/data/xslt/dev_indexes.xsl
index d186b5a..367dbe4 100644
--- a/data/xslt/dev_indexes.xsl
+++ b/data/xslt/dev_indexes.xsl
@@ -33,6 +33,7 @@ along with libgo; if not, write to the Free Software Foundation, Inc.,
 <!-- This gets set on the command line ... -->
 <xsl:param name="libgo.lang" select="''"/>
 <xsl:param name="libgo.debug" select="false()"/>
+<xsl:param name="libgo.basedir" select="''"/>
 
 <xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
 <xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
@@ -44,6 +45,17 @@ doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>
 
 <xsl:namespace-alias stylesheet-prefix="html" result-prefix="#default"/>
 
+  <!-- identity -->
+  <xsl:template match="a" mode="copy">
+    <html:a href="gnome-devel-getting-started/unstable/{ href}"><xsl:apply-templates mode="copy"/></html:a>
+  </xsl:template>
+  <xsl:template match="node()|@*" mode="copy">
+    <xsl:copy>
+      <xsl:apply-templates select="node()|@*" mode="copy"/>
+    </xsl:copy>
+  </xsl:template>
+
+
 <xsl:template name="footer">
 <div id="footer">
 <p>
@@ -753,6 +765,10 @@ div.body-sidebar { width: 100%; }
 
 <h2><xsl:call-template name="gettext"><xsl:with-param name="lang" select="@lang"/><xsl:with-param name="msgid" select="'getting-started'"/></xsl:call-template></h2>
 
+
+<xsl:apply-templates select="document(concat($libgo.basedir, '/gnome-devel-getting-started/unstable/_raw_index.html.en'))//div[ class = 'contents']" mode="copy"/>
+
+
 <p><xsl:call-template name="gettext"><xsl:with-param name="lang" select="@lang"/><xsl:with-param name="msgid" select="'welcome-to-gnome-devcenter'"/></xsl:call-template></p>
 
 <h2><xsl:call-template name="gettext"><xsl:with-param name="lang" select="@lang"/><xsl:with-param name="msgid" select="'get-ready-for-dev'"/></xsl:call-template></h2>
diff --git a/src/lgo.py b/src/lgo.py
index 2fe9d28..1a1ff7b 100755
--- a/src/lgo.py
+++ b/src/lgo.py
@@ -761,6 +761,10 @@ class Lgo(App):
             cmd.insert(-2, '--stringparam')
             cmd.insert(-2, 'libgo.baseref')
             cmd.insert(-2, self.config.baseref)
+        if self.config.output_dir:
+            cmd.insert(-2, '--stringparam')
+            cmd.insert(-2, 'libgo.basedir')
+            cmd.insert(-2, self.config.output_dir)
 
         logging.debug('executing %s' % ' '.join(cmd))
         rc = subprocess.call(cmd)
diff --git a/src/modtypes/mallard.py b/src/modtypes/mallard.py
index efa00d2..1d927e1 100644
--- a/src/modtypes/mallard.py
+++ b/src/modtypes/mallard.py
@@ -386,6 +386,17 @@ class MallardModule(DocModule):
                 if rc != 0:
                     logging.warn('%s failed with error %d' % (' '.join(cmd), rc))
 
+                if doc_page == 'index.page':
+                    # extract the contents of the index page to a raw html
+                    # snippet, that can be used later by the xsl document()
+                    # function
+                    import html5lib
+                    import lxml.html
+                    tmpdoc = html5lib.parse(open(os.path.join(web_output_dir, filename)),
+                                    treebuilder='lxml', namespaceHTMLElements=False)
+                    raw_tmpdoc = lxml.html.tostring(tmpdoc.xpath("//div[ class='contents']")[0])
+                    file(os.path.join(web_output_dir, '_raw_' + filename), 'w').write(raw_tmpdoc)
+
             # remove static files that were copied to the lang directory
             for filename in copied_files:
                 try:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]