Commits

Kevin Dunn committed aff3c16

Added a method to return HTML page name; updated timeouts in JS file.

Comments (0)

Files changed (4)

-__version__  = '0.13'
+__version__  = '0.14'

media/ucomment.js

 var COMMENT_BAR_WIDTH = parseInt(Y.one('#ucomment-border').getStyle('marginLeft'), 10);
 
 //The URL of the XHR resource to which we're POSTing comment data to and from:
-var sURI = document.location.protocol + '//' + document.location.host + '/';
+var sURI = '/'; //document.location.protocol + '//' + document.location.host + '/';
 
 // The horizontal bar that indicates to the user which node is being commented
 var highlightFloater;
 			method:  'POST',
 			on:      {complete: comment_counts_complete},
 			data:    comment_counts,
-			timeout: 10000,
+			timeout: 15000,
 			// async is important, especially for long pages.
 			sync:    false
 		};
 			method: 'POST',
 			on:  {complete: show_comment_HTML},
 			data: {'comment_root': comment_root, order: 'forward'},
-			timeout: 10000
+			timeout: 15000
 		};
 		var request = Y.io(sURI + XHR_COMMENT_HTML, cfg_get_html);
 	};
     url(r'^_search/(?P<search_terms>.*?)(?P<search_type>/+.*?){0,1}(?P<with_case>/+case=.*?){0,1}$',
      views.search_document, name='ucomment-search-document-GET'),
 
+    url(r'^_retrieve-page-name/$', views.retrieve_page_name, name='ucomment-retrieve-pagename'),
+
     # XHR path to the server: Javascript uses this to preview user's comment
     # before allowing it to be submitted.
     url(r'^_preview-comment/$', views.preview_comment, name='ucomment-preview-comment'),
                         'received; not handled; return 400.'))
         return HttpResponse(status=400)
 
+def retrieve_page_name(request):
+    """
+    Returns the page title given the page hyperlink in the request (POST), it .
+    """
+    if request.method == 'POST':
+        page_name = request.POST.get('_page_name_', '')
+        link_name = convert_web_name_to_link_name(page_name)
+        item = models.Page.objects.filter(link_name=link_name)
+        if not item:
+            # Requested the master_doc (main document)
+            if link_name == '':
+                toc_page = models.Page.objects.filter(is_toc=True).filter(\
+                                                                prev_link=None)
+                item = toc_page
+            #elif models.Page.objects.filter(link_name=link_name + '/index'):
+                ## To accommodate a peculiar Sphinx settings for PickleHTMLBuilder
+                ## It may lead to broken links for images that are included on
+                ## this page.
+                #item = models.Page.objects.filter(link_name=link_name + '/index')
+            else:
+                log_file.debug('NAME request: unknown page "%s"' % link_name)
+                return HttpResponse('', status=404)
+
+        page = item[0]
+        log_file.debug('NAME request = %s; returned %s' % (link_name, page_name))
+        return HttpResponse(page.html_title)
+    elif request.method == 'GET':
+        return HttpResponse('', status=404)
+    else:
+        log_file.info((request.method + ' method for comment counts '
+                        'received; not handled; return 400.'))
+        return HttpResponse(status=400)
+
+
 # Publishing update functions
 # ----------------------------
 def publish_update_document(request):
 
     By default the search is case-insensitive (``with_case`` is False).
     """
-    CONTEXT = 90
+    CONTEXT = 90   # characters around the search term
     if request.method == 'GET':
         search = str(search_terms)
         search_type = str(search_type).strip('/').upper()