changeset 27581:3aa6a8135557

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 30 Dec 2015 17:34:51 -0700
parents 34c3ea65d6d1
children 8f8f3b13252d
files mercurial/hgweb/webcommands.py tests/test-help.t
diffstat 2 files changed, 89 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Wed Dec 30 17:26:33 2015 -0700
+++ b/mercurial/hgweb/webcommands.py	Wed Dec 30 17:34:51 2015 -0700
@@ -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:
--- a/tests/test-help.t	Wed Dec 30 17:26:33 2015 -0700
+++ b/tests/test-help.t	Wed Dec 30 17:34:51 2015 -0700
@@ -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