[help.gnome.org] Use an even simpler file for specifying the apps to build help for



commit 4f5f9606ae67fbad65993aa548c89621a453a8f6
Author: Shaun McCance <shaunm redhat com>
Date:   Thu Sep 2 21:51:04 2021 -0400

    Use an even simpler file for specifying the apps to build help for
    
    We had APPS.xml being read by the config script, and that was better
    than writing boilerplate git repos over and over. But we sitll had to
    manually track branches. No more. Now it's an even more minimal YAML
    file, and it's read by a Python script that can ask GitLab about
    branches. If you use standard GNOME branch names, it's automatic.

 APPS.xml     |  97 ------------------------------------------------
 APPS.yaml    | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configger.py |  69 ++++++++++++++++++++++++++++++++++
 configger.sh |  32 ----------------
 gnome.css    |   3 +-
 gnome.xsl    |  98 +++++++++++++++----------------------------------
 index.duck   |   2 +-
 pintail.cfg  |   5 ++-
 8 files changed, 223 insertions(+), 201 deletions(-)
---
diff --git a/APPS.yaml b/APPS.yaml
new file mode 100644
index 0000000..fc94f6f
--- /dev/null
+++ b/APPS.yaml
@@ -0,0 +1,118 @@
+# This file is read by configger.py to provide config data to Pintail.
+#
+# The top-level key is a group: core, games, or more. If you want to add more groups,
+# you'll have to edit gnome.xsl to pick them up. The second-level key is the app
+# identifier, which should almost certainly be name of the git repository. Here are
+# the keys you can specify for each app:
+#
+# stable:     The name of the stable branch. If you use standard GNOME branch names,
+#             configger.py can figure this out for you.
+# unstable:   The name of an unstable branch. configger.py can figure out whether
+#             you use main or master, if you use one of those. But if you build
+#             stable from main or master, you won't get a separate unstable build.
+# project:    The name of the GNOME GitLab project. Default is "GNOME".
+# repository: The repository to clone. You don't have to specify this for projects
+#             on GNOME GitLab. Note that configger.py can't do anything smart with
+#             projects hosted elsewhere, so you will have to specify branches if
+#             you specify a repository.
+# directory:  The directory where the help files are stored. Default is "help/C".
+# docbook:    If your document is in DocBook, the name of the DocBook file. This
+#             will probably be "index.docbook". You don't have to specify anything
+#             separate if your document is in Mallard.
+
+core:
+  # These are on apps.gnome.org
+  baobab:
+  cheese:
+  connections:
+  eog:
+  epiphany:
+  evince:
+  gedit:
+  gnome-boxes:
+  gnome-calculator:
+  gnome-clocks:
+  gnome-color-manager:
+  gnome-logs:
+  gnome-music:
+  gnome-photos:
+  gnome-terminal:
+  seahorse:
+  totem:
+  # These three aren't on apps.gnome.org
+  file-roller:
+  gnome-system-monitor:
+  simple-scan:
+games:
+  aisleriot:
+    docbook: index.docbook
+  five-or-more:
+  four-in-a-row:
+  gnome-chess:
+  gnome-klotski:
+    docbook: index.docbook
+  gnome-mahjongg:
+  gnome-mines:
+  gnome-nibbles:
+  gnome-robots:
+  gnome-sudoku:
+  gnome-taquin:
+  gnome-tetravex:
+  hitori:
+  iagno:
+  lightsoff:
+  quadrapassel:
+  swell-foop:
+  tali:
+more:
+  accerciser:
+  dasher:
+    docbook: index.docbook
+    directory: Data/Help/Gnome/C
+  daty:
+    project: World
+  deja-dup:
+    stable: main
+    project: World
+  d-feet:
+  easytag:
+  evolution:
+  geary:
+  ghex:
+    docbook: index.docbook
+  giggle:
+  glade:
+    docbook: index.docbook
+  gnome-commander:
+    docbook: index.docbook
+    directory: doc/C
+  gnome-dictionary:
+  gnome-documents:
+  gnome-nettool:
+  gnome-notes:
+  gnome-subtitles:
+    docbook: index.docbook
+  gnote:
+  gparted:
+    docbook: index.docbook
+  gthumb:
+    stable: gthumb-3-10
+  gtranslator:
+  gucharmap:
+  meld: 
+    stable: meld-3-20
+  metadata-cleaner:
+    repository: https://gitlab.com/rmnvgr/metadata-cleaner.git
+    stable: main
+  ocrfeeder:
+  orca:
+  pan:
+    docbook: index.docbook
+  pitivi:
+  plots:
+    repository: https://github.com/alexhuntley/Plots.git
+  polari:
+  recipes:
+  rhythmbox:
+  sound-juicer:
+    docbook: index.docbook
diff --git a/configger.py b/configger.py
new file mode 100755
index 0000000..104e6f7
--- /dev/null
+++ b/configger.py
@@ -0,0 +1,69 @@
+#!/bin/python3
+
+STABLE_BRANCHES = ('gnome-41', 'gnome-40')
+
+import json
+import os.path
+import sys
+import urllib.request
+import yaml
+
+icons = []
+apps = yaml.full_load(open('APPS.yaml'))
+appsxml = open('__pintail__/APPS.xml', 'w')
+appsxml.write('<apps>\n')
+for group in apps:
+    for app in apps[group]:
+        icon = '#default'
+        if os.path.exists(app + '.svg'):
+            icon = app + '.svg'
+        elif os.path.exists(app + '.png'):
+            icon = app + '.png'
+        if icon != '#default':
+            icons.append(icon)
+        appsxml.write('<app docid="{0}" group="{1}" icon="{2}"/>\n'
+                      .format(app, group, icon))
+        appdata = apps[group][app] or {}
+        directory = appdata.get('directory', 'help/C')
+        stable = appdata.get('stable', None)
+        unstable = appdata.get('unstable', None)
+        if 'repository' in appdata:
+            repository = appdata['repository']
+            if stable is None:
+                stable = 'main'
+        else:
+            if 'project' in appdata:
+                project = appdata['project']
+            else:
+                project = 'GNOME'
+            repository = 'https://gitlab.gnome.org/' + project + '/' + app + '.git'
+            if stable is None or unstable is None:
+                bfile = urllib.request.urlopen('https://gitlab.gnome.org/api/v4/projects/' +
+                                               project + '%2F' + app + '/repository/branches')
+                branches = json.load(bfile)
+                branches = [branch['name'] for branch in branches]
+                if unstable is None:
+                    unstable = 'main' if ('main' in branches) else 'master'
+                if stable is None:
+                    stable = unstable
+                    for trybranch in STABLE_BRANCHES:
+                        if trybranch in branches:
+                            stable = trybranch
+                            break
+        if stable == unstable:
+            unstable = None
+        print('[/' + app + '/]')
+        print('git_repository = ' + repository)
+        print('git_directory = ' + directory)
+        print('git_branch = ' + stable)
+        print('')
+        if unstable is not None:
+            print('[/unstable/' + app + '/]')
+            print('git_repository = ' + repository)
+            print('git_directory = ' + directory)
+            print('git_branch = ' + unstable)
+            print('')
+print('[/]')
+print('extra_files = ' + ' '.join(icons))
+appsxml.write('</apps>\n')
+appsxml.close()
diff --git a/gnome.css b/gnome.css
index 2feca82..0bef5c6 100644
--- a/gnome.css
+++ b/gnome.css
@@ -2,7 +2,8 @@ main {
   margin-top: 0;
 }
 body {
-  font-family: 'Source Sans Pro', sans-serif;
+  font-family: 'Cantarell', 'Source Sans Pro', sans-serif;
+  font-size: 14pt;
 }
 h1, h2, h3, h4, h5, h6, h7 {
   font-weight: 200;
diff --git a/gnome.xsl b/gnome.xsl
index 913fac1..dc63b1f 100644
--- a/gnome.xsl
+++ b/gnome.xsl
@@ -64,7 +64,7 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   <header class="gnome-header">
     <nav>
       <div class="pagewide">
-        <a id="home-link" class="gnome-navbar-brand" title="Go to home page" 
href="{$mal.site.root}{$rootlink}"><img 
src="https://www.gnome.org/wp-content/themes/gnome-grass/images/gnome-logo.svg"; alt="GNOME: The Free Software 
Desktop Project"/></a>
+        <a id="home-link" class="gnome-navbar-brand" title="Go to home page" 
href="{$mal.site.root}{$rootlink}"><img 
src="https://www.gnome.org/wp-content/uploads/2020/08/cropped-logo.png"; alt="GNOME: The Free Software Desktop 
Project"/></a>
       </div>
     </nav>
   </header>
@@ -78,8 +78,6 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 <xsl:template name="html.bottom.custom">
 </xsl:template>
 
-<xsl:variable name="_icons" select="concat(' ', normalize-space(document('__pintail__/ICONS.xml')), ' ')"/>
-
 <xsl:template match="mal:links[@type = 'gnome:documents']">
   <div class="links-tiles gnome-help">
     <div class="links-tile">
@@ -146,72 +144,36 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
     <div class="links-tile"/>
   </div>
 
-  <xsl:variable name="_appsxml" select="document('APPS.xml')"/>
   <xsl:variable name="_apps">
     <apps>
-      <xsl:for-each select="$mal.cache/*">
-        <xsl:variable name="node" select="."/>
-        <xsl:if test="substring(@id, string-length(@id) - 5) = '/index' and
-                      not(contains(substring-before(substring-after(@id, '/'), '/index'), '/')) ">
-          <xsl:variable name="docid" select="substring-before(substring-after(@id, '/'), '/index')"/>
-          <xsl:choose>
-            <xsl:when test="@id = '/index'"/>
-            <xsl:when test="@id = '/gnome-help/index'"/>
-            <xsl:when test="@id = '/system-admin-guide/index'"/>
-            <xsl:when test="@id = '/unstable/index'"/>
-            <xsl:otherwise>
-              <xsl:variable name="appnode" select="$_appsxml/apps/group/app[@id=$docid]"/>
-              <app docid="{$docid}" siteid="{@id}">
-                <xsl:attribute name="group">
-                  <xsl:choose>
-                    <xsl:when test="$appnode/parent::group/@id = 'core'">
-                      <xsl:text>core</xsl:text>
-                    </xsl:when>
-                    <xsl:when test="$appnode/parent::group/@id = 'games'">
-                      <xsl:text>games</xsl:text>
-                    </xsl:when>
-                    <xsl:otherwise>
-                      <xsl:text>other</xsl:text>
-                    </xsl:otherwise>
-                  </xsl:choose>
-                </xsl:attribute>
-                <xsl:attribute name="icon">
-                  <xsl:choose>
-                    <xsl:when test="contains($_icons, concat(' ', $docid, '.svg '))">
-                      <xsl:value-of select="concat($docid, '.svg')"/>
-                    </xsl:when>
-                    <xsl:when test="contains($_icons, concat(' ', $docid, '.png '))">
-                      <xsl:value-of select="concat($docid, '.png')"/>
-                    </xsl:when>
-                    <xsl:otherwise>
-                      <xsl:text>#default</xsl:text>
-                    </xsl:otherwise>
-                  </xsl:choose>
-                </xsl:attribute>
-                <xsl:variable name="title">
-                  <xsl:call-template name="mal.link.content">
-                    <xsl:with-param name="node" select="$node"/>
-                    <xsl:with-param name="xref" select="$node/@id"/>
-                    <xsl:with-param name="role" select="'text'"/>
-                  </xsl:call-template>
-                </xsl:variable>
-                <xsl:attribute name="sorttitle">
-                  <xsl:value-of select="translate(normalize-space($title),
-                                        'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
-                                        'abcdefghijklmnopqrstuvwxyz')"/>
-                </xsl:attribute>
-                <title>
-                  <xsl:value-of select="normalize-space($title)"/>
-                </title>
-                <xsl:if test="$node/mal:info/mal:desc">
-                  <desc>
-                    <xsl:value-of select="normalize-space($node/mal:info/mal:desc[1])"/>
-                  </desc>
-                </xsl:if>
-              </app>
-            </xsl:otherwise>
-          </xsl:choose>
-        </xsl:if>
+      <xsl:for-each select="document('__pintail__/APPS.xml')/apps/app">
+        <xsl:variable name="app" select="."/>
+        <xsl:variable name="siteid" select="concat('/', $app/@docid, '/index')"/>
+        <xsl:for-each select="$mal.cache/*[@id = $siteid]">
+          <xsl:variable name="node" select="."/>
+          <app docid="{$app/@docid}" siteid="{$siteid}" group="{$app/@group}" icon="{$app/@icon}">
+            <xsl:variable name="title">
+              <xsl:call-template name="mal.link.content">
+                <xsl:with-param name="node" select="$node"/>
+                <xsl:with-param name="xref" select="$node/@id"/>
+                <xsl:with-param name="role" select="'text'"/>
+              </xsl:call-template>
+            </xsl:variable>
+            <xsl:attribute name="sorttitle">
+              <xsl:value-of select="translate(normalize-space($title),
+                                    'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+                                    'abcdefghijklmnopqrstuvwxyz')"/>
+            </xsl:attribute>
+            <title>
+              <xsl:value-of select="normalize-space($title)"/>
+            </title>
+            <xsl:if test="$node/mal:info/mal:desc">
+              <desc>
+                <xsl:value-of select="normalize-space($node/mal:info/mal:desc[1])"/>
+              </desc>
+            </xsl:if>
+          </app>
+        </xsl:for-each>
       </xsl:for-each>
     </apps>
   </xsl:variable>
@@ -250,7 +212,7 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   <section class="gnome-apps">
     <h2>And more...</h2>
     <div class="links-tiles">
-      <xsl:for-each select="$apps/app[@group='other']">
+      <xsl:for-each select="$apps/app[@group='more']">
         <xsl:sort select="@sorttitle"/>
         <xsl:call-template name="_tile">
           <xsl:with-param name="app" select="."/>
diff --git a/index.duck b/index.duck
index 4fdcb4e..b412672 100644
--- a/index.duck
+++ b/index.duck
@@ -1,4 +1,4 @@
-= GNOME ♥ Help
+= Learn GNOME
   [.gnome-front-page]
 @title[link] GNOME
 
diff --git a/pintail.cfg b/pintail.cfg
index ceaf977..202415a 100644
--- a/pintail.cfg
+++ b/pintail.cfg
@@ -1,10 +1,11 @@
 [pintail]
-configger = configger.sh
+site_root = https://people.gnome.org/~shaunm/help.gnome.org/
+config_script = configger.py
 link_extension =
 custom_xsl = gnome.xsl
 custom_css = gnome.css
 plugins = pintail.git pintail.docbook
-#translation_provider = pintail.itstool.ItstoolTranslationProvider
+translation_provider = pintail.itstool.ItstoolTranslationProvider
 itstool_batch_dirs = True
 
 [local]


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