Commits

Anonymous committed 97febde

Initial prototype for a JS-based doc index - hoping to make a single page and a semi-smart menu...

Comments (0)

Files changed (1)

t5437/t5437-protocol_api-r7194.diff

  class AbstractRPCHandler(Component):
      implements(IXMLRPCHandler)
      abstract = True
+diff --git a/trunk/tracrpc/htdocs/rpc.css b/trunk/tracrpc/htdocs/rpc.css
+new file mode 100644
+--- /dev/null
++++ b/trunk/tracrpc/htdocs/rpc.css
+@@ -0,0 +1,11 @@
++#rpc-toc {
++    display: none;
++}
++#rpc-toc.wiki-toc h4 {
++    text-align: center;
++}
++#rpc-toc ul {
++    margin: 0;
++    padding: 0.3em 0.15em;;
++    list-style-type: none;
++}
+diff --git a/trunk/tracrpc/htdocs/rpc.js b/trunk/tracrpc/htdocs/rpc.js
+new file mode 100644
+--- /dev/null
++++ b/trunk/tracrpc/htdocs/rpc.js
+@@ -0,0 +1,20 @@
++(function($) {
++    $(document).ready(function () {
++        // Attempt at making a simple sidebar navigation menu...
++        $('#content').prepend('<div id="rpc-toc" class="wiki-toc"><h4>Page Contents</h4><ul />');
++        $('#rpc-toc').css('float', 'left').css('width', '15em');
++        $("#content").find("h2[id],h3[id]").each(function(index, item) {
++            var elem = $('<li><a href="#' + this.id + '" title="'
++                     + $(item).text().replace(/^\s+|\s+$/g, '')
++                     + '">' + this.id + '</a></li>');
++            if (this.tagName == 'H2') elem.css('padding-top', '0.5em');
++            if (this.tagName == 'H3') elem.css('padding-left', '1.2em');
++            $('#rpc-toc ul').append(elem);
++        });
++        $('#rpc-toc').toggle();
++        $('.wikipage').css('margin-left', '17em');
++        
++        // Add anchors to headings
++        $("#content").find("h2,h3").addAnchor("Link here");
++    });
++})(jQuery);
 diff --git a/trunk/tracrpc/json_rpc.py b/trunk/tracrpc/json_rpc.py
 new file mode 100644
 --- /dev/null
 rename to trunk/tracrpc/templates/rpc_api.html
 --- a/trunk/tracrpc/templates/xmlrpclist.html
 +++ b/trunk/tracrpc/templates/rpc_api.html
-@@ -7,103 +7,49 @@
+@@ -7,106 +7,49 @@
    <xi:include href="layout.html" />
    <xi:include href="macros.html" />
    <head>
 -        </dl>
 +      <div class="wikipage searchable">
 +        <h1>Remote Procedure Call (RPC) Interface</h1>
-+        <h2>RPC exported functions</h2>
++        <h2 id="Functions">RPC exported functions</h2>
 +  
 +        <div id="searchable">
 +          <dl py:for="key in sorted(rpc.functions)" py:with="namespace = rpc.functions[key]">
 -        </ul>
 -      </div>
 -      
-       <script type="text/javascript">
-         addHeadingLinks(document.getElementById("searchable"));
-       </script>
+-      <script type="text/javascript">
+-        addHeadingLinks(document.getElementById("searchable"));
+-      </script>
+     </div>
+   </body>
+ </html>
 diff --git a/trunk/tracrpc/templates/rpc_main.html b/trunk/tracrpc/templates/rpc_main.html
 new file mode 100644
 --- /dev/null
 +++ b/trunk/tracrpc/templates/rpc_main.html
-@@ -0,0 +1,79 @@
+@@ -0,0 +1,102 @@
 +<!DOCTYPE html
 +    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 +    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 +          can even implement another protocol in a plugin and install 
 +          it at any time.
 +        </p>
-+        <h2>Protocol reference:</h2>
++        <h2 id="Protocols">Protocol reference:</h2>
 +        <p>Below you will find a detailed description of all the RPC 
 +          protocols installed in this environment. This includes 
 +          supported content types as well as target URLs for 
 +          and Body for POST request):</p>
 +        <div class="help">
 +          <py:for each="protocol in rpc.protocols">
-+            <h3>${protocol[0]}</h3>
++            <h3 id="${protocol[0]}">${protocol[0]}</h3>
 +            <div>
 +              ${wiki_to_html(context, expand_docs(protocol[1], locals()['__data__']))}
 +            </div>
 +          </py:for>
-+          <p>
-+            <strong>Note:</strong>
-+            See <a href="${req.abs_href.rpc('api')}">RPC API Reference</a> 
-+            for help on signatures and return values of available methods.
-+          </p>
++
++        <h2 id="Methods">RPC exported functions</h2>
++  
++        <div id="searchable">
++          <dl py:for="key in sorted(rpc.functions)" py:with="namespace = rpc.functions[key]">
++            <dt>
++              <h3 id="${'xmlrpc.' + to_unicode(namespace.namespace)}">
++                ${namespace.namespace} - ${namespace.description}
++              </h3>
++            </dt>
++            <dd>
++              <table class="listing tickets">
++                <thead>
++                  <tr>
++                    <th style="width:40%">Function</th>
++                    <th style="width:45%">Description</th>
++                    <th style="width:15%">Permission required</th>
++                  </tr>
++                </thead>
++                <tbody py:for="idx, function in enumerate(namespace.methods)">
++                  <tr class="${'color3-' + (idx % 2 == 0 and 'even' or 'odd')}">
++                    <td style="padding-left:4em;text-indent:-4em">${function[0]}</td>
++                    <td>${function[1]}</td>
++                    <td>${function[2] or "By resource"}</td>
++                  </tr>
++                </tbody>
++              </table>
++            </dd>
++          </dl>
++        </div>
++
 +        </div>
 +      </div>
-+      <script type="text/javascript">
-+        addHeadingLinks(document.getElementById("content"));
-+      </script>
 +    </div>
 +  </body>
 +</html>
 diff --git a/trunk/tracrpc/web_ui.py b/trunk/tracrpc/web_ui.py
 --- a/trunk/tracrpc/web_ui.py
 +++ b/trunk/tracrpc/web_ui.py
-@@ -6,305 +6,144 @@
+@@ -6,305 +6,145 @@
  (c) 2009      ::: www.CodeResort.com - BV Network AS (simon-code@bvnetwork.no)
  """
  
 +                raise Exception('%s: %s\n%s' % (method.name,
 +                                                str(e), out.getvalue()))
 +        add_stylesheet(req, 'common/css/wiki.css')
++        add_stylesheet(req, 'tracrpc/rpc.css')
++        add_script(req, 'tracrpc/rpc.js')
 +        self._rpc_ctxtnav(req)
 +        try:
 +            # Paths of the form `/rpc/<pageid>`
  
      # ITemplateProvider
      def get_htdocs_dirs(self):
-         return []
-+#        yield ('rpc', resource_filename(__name__, 'htdocs'))
+-        return []
++        yield ('tracrpc', resource_filename(__name__, 'htdocs'))
  
      def get_templates_dirs(self):
 -        return [resource_filename(__name__, 'templates')]