[library-web] display icons in index pages, when possible
- From: Frederic Peters <fpeters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [library-web] display icons in index pages, when possible
- Date: Wed, 29 Jan 2014 08:26:04 +0000 (UTC)
commit c90107d1a1e93bc0705a5a52749fb7e20cac5f56
Author: Frédéric Péters <fpeters 0d be>
Date: Tue Jan 28 23:24:42 2014 +0000
display icons in index pages, when possible
data/skin/lgo2010.css | 10 ++++++++++
data/xslt/dev_indexes.xsl | 4 ++--
data/xslt/help_indexes.xsl | 4 ++--
data/xslt/indexes.xsl | 4 ++--
src/document.py | 4 ++++
src/modtypes/mallard.py | 8 ++++++++
6 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/data/skin/lgo2010.css b/data/skin/lgo2010.css
index 3943db0..6956452 100644
--- a/data/skin/lgo2010.css
+++ b/data/skin/lgo2010.css
@@ -479,3 +479,13 @@ br + br {
.docbook-legal-stuff > div dt {
font-size: 100%;
}
+
+img.application-icon {
+ padding-right: 1ex;
+ position: relative;
+ top: 0.8ex;
+}
+
+h1 img.application-icon {
+ top: 0.4ex;
+}
diff --git a/data/xslt/dev_indexes.xsl b/data/xslt/dev_indexes.xsl
index 8204bb7..7c036cc 100644
--- a/data/xslt/dev_indexes.xsl
+++ b/data/xslt/dev_indexes.xsl
@@ -191,6 +191,7 @@ $lang]"/>
<xsl:if test="keywords/keyword[. = 'upcoming-deprecation']">
<xsl:attribute name="class">upcoming-deprecation</xsl:attribute>
</xsl:if>
+<xsl:if test="@icon"><img class="application-icon" alt=""><xsl:attribute name="src"><xsl:value-of
select="@icon"/></xsl:attribute></img></xsl:if>
<a lang="{ lang}">
<xsl:attribute name="href">
<xsl:if test="@path"><xsl:value-of select="@path"/></xsl:if>
@@ -298,8 +299,7 @@ doctype-system="http://www.w3.org/TR/html4/loose.dtd">
<div id="container" class="two_columns">
<div class="container_12">
<div class="page_title">
- <h1 class="article title"><a href="{ path}"
- lang="{ lang}"><xsl:value-of select="title"/></a></h1>
+ <h1 class="article title"><xsl:if test="@icon"><img class="application-icon" alt=""><xsl:attribute
name="src"><xsl:value-of select="@icon"/></xsl:attribute></img></xsl:if><a href="{ path}" lang="{
lang}"><xsl:value-of select="title"/></a></h1>
</div>
<div class="content">
<xsl:if test="abstract">
diff --git a/data/xslt/help_indexes.xsl b/data/xslt/help_indexes.xsl
index bf10e3a..5bab40a 100644
--- a/data/xslt/help_indexes.xsl
+++ b/data/xslt/help_indexes.xsl
@@ -191,6 +191,7 @@ $lang]"/>
<xsl:if test="keywords/keyword[. = 'upcoming-deprecation']">
<xsl:attribute name="class">upcoming-deprecation</xsl:attribute>
</xsl:if>
+<xsl:if test="@icon"><img class="application-icon" alt=""><xsl:attribute name="src"><xsl:value-of
select="@icon"/></xsl:attribute></img></xsl:if>
<a lang="{ lang}">
<xsl:attribute name="href">
<xsl:if test="@path"><xsl:value-of select="@path"/></xsl:if>
@@ -295,8 +296,7 @@ doctype-system="http://www.w3.org/TR/html4/loose.dtd">
<div id="container" class="two_columns">
<div class="container_12">
<div class="page_title">
- <h1 class="article title"><a href="{ path}"
- lang="{ lang}"><xsl:value-of select="title"/></a></h1>
+ <h1 class="article title"><xsl:if test="@icon"><img class="application-icon" alt=""><xsl:attribute
name="src"><xsl:value-of select="@icon"/></xsl:attribute></img></xsl:if><a href="{ path}" lang="{
lang}"><xsl:value-of select="title"/></a></h1>
</div>
<div class="content">
<xsl:if test="abstract">
diff --git a/data/xslt/indexes.xsl b/data/xslt/indexes.xsl
index faf21fd..78af38c 100644
--- a/data/xslt/indexes.xsl
+++ b/data/xslt/indexes.xsl
@@ -191,6 +191,7 @@ $lang]"/>
<xsl:if test="keywords/keyword[. = 'upcoming-deprecation']">
<xsl:attribute name="class">upcoming-deprecation</xsl:attribute>
</xsl:if>
+<xsl:if test="@icon"><img class="application-icon" alt=""><xsl:attribute name="src"><xsl:value-of
select="@icon"/></xsl:attribute></img></xsl:if>
<a lang="{ lang}">
<xsl:attribute name="href">
<xsl:if test="@path"><xsl:value-of select="@path"/></xsl:if>
@@ -295,8 +296,7 @@ doctype-system="http://www.w3.org/TR/html4/loose.dtd">
<div id="container" class="two_columns">
<div class="container_12">
<div class="page_title">
- <h1 class="article title"><a href="{ path}"
- lang="{ lang}"><xsl:value-of select="title"/></a></h1>
+ <h1 class="article title"><xsl:if test="@icon"><img class="application-icon" alt=""><xsl:attribute
name="src"><xsl:value-of select="@icon"/></xsl:attribute></img></xsl:if><a href="{ path}" lang="{
lang}"><xsl:value-of select="title"/></a></h1>
</div>
<div class="content">
<xsl:if test="abstract">
diff --git a/src/document.py b/src/document.py
index 491ad9b..c4f2c4d 100644
--- a/src/document.py
+++ b/src/document.py
@@ -52,6 +52,7 @@ class Document:
title = None # indexed on language, most recent version
abstract = None # indexed on language, most recent version
href = None # for external docs, indexed on language
+ icon = None # optional path to icon
languages = None # list of available languages
versions = None # list of available versions
@@ -154,6 +155,9 @@ class Document:
if self.single_page_alternative:
doc.set('single_page_alternative', 'true')
+ if self.icon:
+ doc.set('icon', self.icon)
+
assert_elementtree_node(doc)
return doc
diff --git a/src/modtypes/mallard.py b/src/modtypes/mallard.py
index 3d51d13..5c34254 100644
--- a/src/modtypes/mallard.py
+++ b/src/modtypes/mallard.py
@@ -62,6 +62,7 @@ class MallardPage:
title = None
info_nodes = None
sections = None
+ icon_path = None
def __init__(self, filename):
self.info_nodes = []
@@ -101,6 +102,10 @@ class MallardPage:
if desc_tag is not None:
self.desc = plain_text(desc_tag)
+ icon_tag = tree.find('{%s}title/{%s}media' % (MAL_NS, MAL_NS))
+ if icon_tag is not None:
+ self.icon_path = icon_tag.attrib.get('src')
+
# unfortunately ElementText on RHEL 6.5 doesn't support attribute
# lookup, so we do your own loop.
# title_text = tree.find("{%s}info/{%s}title[ type='text']" % (MAL_NS, MAL_NS))
@@ -317,6 +322,9 @@ class MallardModule(DocModule):
doc.title[lang] = mallard_page.title
if mallard_page.desc is not None:
doc.abstract[lang] = mallard_page.desc
+ if mallard_page.icon_path is not None:
+ doc.icon = os.path.join(app.get_module_web_path(self, True),
+ mallard_page.icon_path)
if mtime > max(self.mtime_tarball, self.mtime_xslt_files):
logging.debug('using already generated doc (lang: %s)' % lang)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]