# HG changeset patch # User neko259 # Date 2014-03-26 16:49:16 # Node ID 582b2d8513e203b66a526105a47c77dfa9218708 # Parent dd314494cb51e57783614b1b278fa863c0ec42fb Removed tag popularity ratings, they are too slow. Added API to get tag popularity. diff --git a/boards/mdx_neboard.py b/boards/mdx_neboard.py --- a/boards/mdx_neboard.py +++ b/boards/mdx_neboard.py @@ -1,6 +1,5 @@ -from django.core.urlresolvers import reverse import markdown -from markdown.inlinepatterns import Pattern +from markdown.inlinepatterns import Pattern, SubstituteTagPattern from markdown.util import etree import boards @@ -179,7 +178,8 @@ neboard_extension = make_extension() def markdown_extended(markup): - return markdown.markdown(markup, [neboard_extension], safe_mode=True) + return markdown.markdown(markup, [neboard_extension, 'nl2br'], + safe_mode=True) formatters = [ QuotePattern, diff --git a/boards/templates/boards/tags.html b/boards/templates/boards/tags.html --- a/boards/templates/boards/tags.html +++ b/boards/templates/boards/tags.html @@ -13,7 +13,7 @@
{% if all_tags %} {% for tag in all_tags %} -
+ diff --git a/boards/urls.py b/boards/urls.py --- a/boards/urls.py +++ b/boards/urls.py @@ -79,5 +79,7 @@ urlpatterns = patterns('', name='get_thread'), url(r'^api/add_post/(?P\w+)/$', api.api_add_post, name='add_post'), + url(r'api/get_tag_popularity/(?P\w+)$', api.get_tag_popularity, + name='get_tag_popularity'), ) diff --git a/boards/views/api.py b/boards/views/api.py --- a/boards/views/api.py +++ b/boards/views/api.py @@ -218,6 +218,15 @@ def api_get_post(request, post_id): return HttpResponse(content=json) +def get_tag_popularity(request, tag_name): + tag = get_object_or_404(Tag, name=tag_name) + + json_data = [] + json_data['popularity'] = tag.get_popularity() + + return HttpResponse(content=json.dumps(json_data)) + + # TODO Add pub time and replies def _get_post_data(post_id, format_type=DIFF_TYPE_JSON, request=None, include_last_update=False):