Commits

Georg Brandl committed 1b0ef69

Fix a few smaller issues. Add JS and CSS for all pages.

Comments (0)

Files changed (4)

sphinx/builders/websupport.py

     def init_translator_class(self):
         self.translator_class = WebSupportTranslator
 
+    def prepare_writing(self, docnames):
+        PickleHTMLBuilder.prepare_writing(self, docnames)
+        self.globalcontext['no_search_suffix'] = True
+
     def write_doc(self, docname, doctree):
         destination = StringOutput(encoding='utf-8')
         doctree.settings = self.docsettings
         for item in ['sidebar', 'relbar', 'script', 'css']:
             if hasattr(template_module, item):
                 doc_ctx[item] = getattr(template_module, item)()
+        if 'script' not in self.globalcontext:
+            self.globalcontext['script'] = doc_ctx['script']
+        if 'css' not in self.globalcontext:
+            self.globalcontext['css'] = doc_ctx['css']
 
         if not outfilename:
             outfilename = path.join(self.outdir, 'pickles',

sphinx/themes/basic/static/websupport.js

           ul.data('empty', false);
         }
         insertComment(data.comment);
+        var ao = $('#ao' + (node_id || parent_id));
+        ao.find('img').attr({'src': opts.commentBrightImage});
       },
       error: function(request, textStatus, error) {
         form.find('textarea,input').removeAttr('disabled');
   function showError(message) {
     $(document.createElement('div')).attr({'class': 'popup-error'})
       .append($(document.createElement('div'))
-               .attr({'class': 'error-header'}).text(message))
+               .attr({'class': 'error-message'}).text(message))
       .appendTo('body')
       .fadeIn("slow")
       .delay(2000)
     });
   };
 
-  var opts = jQuery.extend({
+  var opts = {
     processVoteURL: '/_process_vote',
     addCommentURL: '/_add_comment',
     getCommentsURL: '/_get_comments',
     downArrowPressed: '/static/_static/down-pressed.png',
     voting: false,
     moderator: false
-  }, COMMENT_OPTIONS);
+  };
+
+  if (typeof COMMENT_OPTIONS != "undefined") {
+    opts = jQuery.extend(opts, COMMENT_OPTIONS);
+  }
 
   var replyTemplate = '\
     <li>\
     </li>';
 
   var commentTemplate = '\
-    <div  id="cd<%id%>" class="spxcdiv">\
+    <div  id="cd<%id%>" class="sphinx-comment-div">\
       <div class="vote">\
         <div class="arrow">\
           <a href="#" id="uv<%id%>" class="vote">\
 })(jQuery);
 
 $(document).ready(function() {
-  $('.spxcmt').comment();
+  $('.sphinx-has-comment').comment();
 
   /** Highlight search words in search results. */
   $("div.context").each(function() {

sphinx/websupport/__init__.py

         docpath = path.join(self.datadir, 'pickles', docname)
         if path.isdir(docpath):
             infilename = docpath + '/index.fpickle'
+            if not docname:
+                docname = 'index'
+            else:
+                docname += '/index'
         else:
             infilename = docpath + '.fpickle'
 
             f.close()
 
         comment_opts = self._make_comment_options(username, moderator)
-        comment_metadata = self.storage.get_metadata(docname, moderator)
+        comment_meta = self._make_metadata(
+            self.storage.get_metadata(docname, moderator))
 
-        document['script'] = '\n'.join([comment_opts,
-                                        self._make_metadata(comment_metadata),
-                                        document['script']])
+        document['script'] = comment_opts + comment_meta + document['script']
         return document
 
     def get_search_results(self, q):
                 'username': username,
                 'moderator': moderator,
             })
-        return '\n'.join([
-            '<script type="text/javascript">',
-            'var COMMENT_OPTIONS = %s;' % dump_json(rv),
-            '</script>'
-        ])
+        return '''\
+        <script type="text/javascript">
+        var COMMENT_OPTIONS = %s;
+        </script>
+        ''' % dump_json(rv)
 
     def _make_metadata(self, data):
-        return '\n'.join([
-            '<script type="text/javascript">',
-            'var COMMENT_METADATA = %s;' % dump_json(data),
-            '</script>'
-        ])
+        return '''\
+        <script type="text/javascript">
+        var COMMENT_METADATA = %s;
+        </script>
+        ''' % dump_json(data)

sphinx/writers/websupport.py

 
     def __init__(self, builder, *args, **kwargs):
         HTMLTranslator.__init__(self, builder, *args, **kwargs)
-        self.comment_class = 'spxcmt'
+        self.comment_class = 'sphinx-has-comment'
 
     def dispatch_visit(self, node):
         if is_commentable(node):