Patchwork [6,of,8,v2] hgweb: support rendering sub-topic indexes

login
register
mail settings
Submitter Eric Sumner
Date Jan. 1, 2016, 6:36 p.m.
Message ID <3aa6a8135557080db225.1451673406@waste.org>
Download mbox | patch
Permalink /patch/12461/
State Accepted
Headers show

Comments

Eric Sumner - Jan. 1, 2016, 6:36 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1451522091 25200
#      Wed Dec 30 17:34:51 2015 -0700
# Node ID 3aa6a8135557080db2256f3a9055d5b12692ea45
# Parent  34c3ea65d6d1d55c9188c3de4ec885ca8905c205
hgweb: support rendering sub-topic indexes

If the requested topic name is the name of a sub-topic, we now render
an index of topics within that sub-topic.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1256,6 +1256,19 @@ 
         return tmpl('helptopics', topics=topics, earlycommands=earlycommands,
                     othercommands=othercommands, title='Index')
 
+    # Render an index of sub-topics.
+    if topicname in helpmod.subtopics:
+        topics = []
+        for entries, summary, _doc in helpmod.subtopics[topicname]:
+            topics.append({
+                'topic': '%s.%s' % (topicname, entries[0]),
+                'basename': entries[0],
+                'summary': summary,
+            })
+
+        return tmpl('helptopics', topics=topics, title=topicname,
+                    subindex=True)
+
     u = webutil.wsgiui()
     u.verbose = True
     try:
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -2631,6 +2631,82 @@ 
   </html>
   
 
+Sub-topic indexes rendered properly
+
+  $ get-with-headers.py 127.0.0.1:$HGPORT "help/internals"
+  200 Script output follows
+  
+  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
+  <head>
+  <link rel="icon" href="/static/hgicon.png" type="image/png" />
+  <meta name="robots" content="index, nofollow" />
+  <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
+  <script type="text/javascript" src="/static/mercurial.js"></script>
+  
+  <title>Help: internals</title>
+  </head>
+  <body>
+  
+  <div class="container">
+  <div class="menu">
+  <div class="logo">
+  <a href="https://mercurial-scm.org/">
+  <img src="/static/hglogo.png" alt="mercurial" /></a>
+  </div>
+  <ul>
+  <li><a href="/shortlog">log</a></li>
+  <li><a href="/graph">graph</a></li>
+  <li><a href="/tags">tags</a></li>
+  <li><a href="/bookmarks">bookmarks</a></li>
+  <li><a href="/branches">branches</a></li>
+  </ul>
+  <ul>
+  <li><a href="/help">help</a></li>
+  </ul>
+  </div>
+  
+  <div class="main">
+  <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
+  <form class="search" action="/log">
+  
+  <p><input name="rev" id="search1" type="text" size="30" /></p>
+  <div id="hint">Find changesets by keywords (author, files, the commit message), revision
+  number or hash, or <a href="/help/revsets">revset expression</a>.</div>
+  </form>
+  <table class="bigtable">
+  <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
+  
+  <tr><td>
+  <a href="/help/internals.bundles">
+  bundles
+  </a>
+  </td><td>
+  container for exchange of repository data
+  </td></tr>
+  <tr><td>
+  <a href="/help/internals.changegroups">
+  changegroups
+  </a>
+  </td><td>
+  representation of revlog data
+  </td></tr>
+  
+  
+  
+  
+  
+  </table>
+  </div>
+  </div>
+  
+  <script type="text/javascript">process_dates()</script>
+  
+  
+  </body>
+  </html>
+  
+
   $ killdaemons.py
 
 #endif