diff options
43 files changed, 732 insertions, 1196 deletions
diff --git a/askbot/middleware/view_log.py b/askbot/middleware/view_log.py index d3e2d2f1..25e9f37f 100644 --- a/askbot/middleware/view_log.py +++ b/askbot/middleware/view_log.py @@ -4,13 +4,13 @@ from askbot.views.readers import questions as questions_view from askbot.views.commands import vote from django.views.static import serve from askbot.views.writers import delete_comment, question_comments, answer_comments -from askbot.views.readers import question_revisions, answer_revisions +from askbot.views.readers import revisions #todo: the list is getting bigger and bigger - maybe there is a better way to #trigger reset of sarch state? IGNORED_VIEWS = (serve, vote, delete_comment, question_comments, answer_comments, - question_revisions, answer_revisions) + revisions) class ViewLog(object): """must be modified only in this middlware diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index 10a76018..9958c2ed 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -35,6 +35,9 @@ from askbot.startup_tests import run_startup_tests run_startup_tests() +def get_model(model_name): + return models.get_model('askbot', model_name) + User.add_to_class( 'status', models.CharField( @@ -1936,4 +1939,6 @@ __all__ = [ #'AuthKeyUserAssociation', 'User', + + 'get_model' ] diff --git a/askbot/models/answer.py b/askbot/models/answer.py index 9f48e720..f025a0b7 100644 --- a/askbot/models/answer.py +++ b/askbot/models/answer.py @@ -9,7 +9,8 @@ from askbot.models import content from askbot.models.question import Question from askbot import const from askbot.utils.slug import slugify - +from askbot.utils import markup +from askbot.utils.html import sanitize_html class AnswerManager(models.Manager): def create_new( @@ -206,6 +207,10 @@ class AnswerRevision(ContentRevision): def get_question_title(self): return self.answer.question.title + def as_html(self): + markdowner = markup.get_parser() + return sanitize_html(markdowner.convert(self.text)) + class Meta(ContentRevision.Meta): db_table = u'answer_revision' ordering = ('-revision',) diff --git a/askbot/models/base.py b/askbot/models/base.py index c54d344d..dcd94ab9 100644 --- a/askbot/models/base.py +++ b/askbot/models/base.py @@ -193,6 +193,12 @@ class ContentRevision(models.Model): abstract = True app_label = 'askbot' + def as_html(self): + """should return html representation of + the revision + """ + raise NotImplementedError() + class AnonymousContent(models.Model): """ diff --git a/askbot/models/question.py b/askbot/models/question.py index 82fa60d1..5f914bd5 100644 --- a/askbot/models/question.py +++ b/askbot/models/question.py @@ -17,6 +17,8 @@ from askbot.models import content from askbot import const from askbot.utils.lists import LazyList from askbot.utils.slug import slugify +from askbot.utils import markup +from askbot.utils.html import sanitize_html #todo: too bad keys are duplicated see const sort methods QUESTION_ORDER_BY_MAP = { @@ -47,6 +49,7 @@ class QuestionManager(models.Manager): #summary field is denormalized in .save() call ) if question.wiki: + #DATED COMMENT #todo: this is confusing - last_edited_at field #is used as an indicator whether question has been edited #in template askbot/skins/default/templates/post_contributor_info.html @@ -314,9 +317,6 @@ class Question(content.Content, DeletableContent): return LazyList(get_data) - def get_tag_names(self): - return self.tagnames.split(' ') - def get_similarity(self, other_question = None): """return number of tags in the other question that overlap with the current question (self) @@ -521,18 +521,18 @@ class Question(content.Content, DeletableContent): if initial_addition: tags = Tag.objects.get_or_create_multiple( - self.tagname_list(), + self.get_tag_names(), self.author ) self.tags.add(*tags) Tag.objects.update_use_counts(tags) - def tagname_list(self): + def get_tag_names(self): """Creates a list of Tag names from the ``tagnames`` attribute.""" - return [name for name in self.tagnames.split(u' ')] + return self.tagnames.split(u' ') def tagname_meta_generator(self): - return u','.join([unicode(tag) for tag in self.tagname_list()]) + return u','.join([unicode(tag) for tag in self.get_tag_names()]) def get_absolute_url(self): return '%s%s' % ( @@ -660,6 +660,9 @@ class FavoriteQuestion(models.Model): def __unicode__(self): return '[%s] favorited at %s' %(self.user, self.added_at) +QUESTION_REVISION_TEMPLATE = ('<h3>%(title)s</h3>\n' + '<div class="text">%(html)s</div>\n' + '<div class="tags">%(tags)s</div>') class QuestionRevision(ContentRevision): """A revision of a Question.""" question = models.ForeignKey(Question, related_name='revisions') @@ -677,6 +680,15 @@ class QuestionRevision(ContentRevision): #print 'in QuestionRevision.get_absolute_url()' return reverse('question_revisions', args=[self.question.id]) + def as_html(self): + markdowner = markup.get_parser() + return QUESTION_REVISION_TEMPLATE % { + 'title': self.title, + 'html': sanitize_html(markdowner.convert(self.text)), + 'tags': ' '.join(['<a class="post-tag">%s</a>' % tag + for tag in self.tagnames.split(' ')]), + } + def save(self, **kwargs): """Looks up the next available revision number.""" if not self.revision: diff --git a/askbot/skins/default/media/style/style.css b/askbot/skins/default/media/style/style.css index cbdceba9..d1d6ca2c 100755 --- a/askbot/skins/default/media/style/style.css +++ b/askbot/skins/default/media/style/style.css @@ -1630,10 +1630,6 @@ span.form-error { /*修订记录*/ -#revisions { - width: 950px; -} - .revision { margin: 10px 0 10px 0; width: 100%; diff --git a/askbot/skins/default/templates/base.jinja.html b/askbot/skins/default/templates/base.jinja.html index 3051f1f7..6cf23a26 100644 --- a/askbot/skins/default/templates/base.jinja.html +++ b/askbot/skins/default/templates/base.jinja.html @@ -6,15 +6,15 @@ {% load i18n %} <html xmlns="http://www.w3.org/1999/xhtml"> <head> - <title>{% block title %}{% endblock %} - {{ settings.APP_TITLE }}</title> + <title>{% block title %}{% endblock %} - {{ settings.APP_TITLE|escape }}</title> {% spaceless %} {% block meta %}{% endblock %} {% block meta_description %} - <meta name="description" content="{{settings.APP_DESCRIPTION}}" /> + <meta name="description" content="{{settings.APP_DESCRIPTION|escape}}" /> {% endblock %} {% endspaceless %} <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <meta name="keywords" content="{%block keywords%}{%endblock%},{{settings.APP_KEYWORDS}}" /> + <meta name="keywords" content="{%block keywords%}{%endblock%},{{settings.APP_KEYWORDS|escape}}" /> {% if settings.GOOGLE_SITEMAP_CODE %} <meta name="google-site-verification" content="{{settings.GOOGLE_SITEMAP_CODE}}" /> {% endif %} diff --git a/askbot/skins/default/templates/base_content.jinja.html b/askbot/skins/default/templates/base_content.jinja.html index 492e9136..a2895c33 100644 --- a/askbot/skins/default/templates/base_content.jinja.html +++ b/askbot/skins/default/templates/base_content.jinja.html @@ -2,11 +2,11 @@ <!-- base_content.html --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> - <title>{% block title %}{% endblock %} - {{ settings.APP_TITLE }}</title> + <title>{% block title %}{% endblock %} - {{ settings.APP_TITLE|escape }}</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <meta name="keywords" content="{%block keywords%}{%endblock%},{{settings.APP_KEYWORDS}}" /> + <meta name="keywords" content="{%block keywords%}{%endblock%},{{settings.APP_KEYWORDS|escape}}" /> {% block meta_description %} - <meta name="description" content="{{settings.APP_DESCRIPTION}}" /> + <meta name="description" content="{{settings.APP_DESCRIPTION|escape}}" /> {% endblock %} {% if settings.GOOGLE_SITEMAP_CODE %} <meta name="google-site-verification" content="{{ settings.GOOGLE_SITEMAP_CODE }}" /> diff --git a/askbot/skins/default/templates/html.list b/askbot/skins/default/templates/html.list index 477f2080..ddb3f444 100644 --- a/askbot/skins/default/templates/html.list +++ b/askbot/skins/default/templates/html.list @@ -1,37 +1,34 @@ ==todo== +question_retag.html - todo debug 404.html 500.html +paginator.html - still used in questions ajax + +==unused== +notarobot.html +user_recent.html +question_counter_widget.html +email_base.html question_list.html -question_retag.html questions_ajax.html question_summary_list_roll.html -reopen.html -revisions_answer.html -revisions_question.html -tags.html -user_edit.html -user_email_subscriptions.html user_favorites.html +users_questions.html user_footer.html -user_info.html -user_moderate.html -user_recent.html -user_reputation.html user_responses.html users.html -users_questions.html -user_stats.html -user_votes.html -pagesize.html -paginator.html -notarobot.html -post_contributor_info.html - -==unused== -question_counter_widget.html -email_base.html ==done== +user_info.html +user_reputation.html +user_moderate.html +user_votes.html +user_stats.html +user_email_subscriptions.html +user_edit.html +tags.html +revisions.html +reopen.html question_edit.html privacy.html tag_selector.jinja.html diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html index 96c95fb1..f3ec824a 100644 --- a/askbot/skins/default/templates/macros.html +++ b/askbot/skins/default/templates/macros.html @@ -121,6 +121,8 @@ {%- macro post_contributor_info(post, contributor_type, is_wiki) -%} <div class='post-update-info'> +{# there is a whole bunch of trickery here, probably indicative of +poor design of the data or methods on data objects #} {% if contributor_type=="original_author" %} {% if is_wiki %} <p>{% trans %}community wiki{% endtrans %}</p> @@ -149,7 +151,16 @@ {{ user_score_and_badge_summary(post.author) }}</p> {% endif %} {% else %} - {% if post.last_edited_at %} + {% if post.__class__.__name__ in ('Question', 'Answer') %} + {% set last_edited_at = post.last_edited_at %} + {% set original_author = post.author %} + {% set update_author = post.last_edited_by %} + {% elif post.__class__.__name__ in ('QuestionRevision', 'AnswerRevision') %} + {% set last_edited_at = post.revised_at %} + {% set original_author = None %}{# fake value to force display widget in the revision views #} + {% set update_author = post.author %} + {% endif %} + {% if last_edited_at %} <p style="line-height:12px;"> <a {% if post.__class__.__name__ == 'Question' %} @@ -157,12 +168,12 @@ {% else %} href="{% url answer_revisions post.id %}" {% endif %} - >{% trans %}updated{% endtrans %} <strong>{{ post.last_edited_at|diff_date }}</strong></a> + >{% trans %}updated{% endtrans %} <strong>{{ last_edited_at|diff_date }}</strong></a> </p> - {% if post.author != post.last_edited_by or is_wiki %} - {{ gravatar(post.last_edited_by, 32) }} - <p style="float:left">{{post.last_edited_by.get_profile_link()}}<br/> - {{ user_score_and_badge_summary(post.last_edited_by) }}</p> + {% if original_author != display_author or is_wiki %} + {{ gravatar(update_author, 32) }} + <p style="float:left">{{update_author.get_profile_link()}}<br/> + {{ user_score_and_badge_summary(update_author) }}</p> {% endif %} {% endif %} {% endif %} diff --git a/askbot/skins/default/templates/pagesize.html b/askbot/skins/default/templates/pagesize.html deleted file mode 100644 index 5fb28e20..00000000 --- a/askbot/skins/default/templates/pagesize.html +++ /dev/null @@ -1,27 +0,0 @@ -<!-- template pagesize.html --> -{% spaceless %} -{% load i18n %} -{% if is_paginated %} -<div class="paginator"> - <span class="text">{% trans "posts per page" %}</span> - {% ifequal page_size 10 %} - <span class="curr">10</span> - {% else %} - <span class="page"><a href="{{base_url}}page_size=10">10</a></span> - {% endifequal %} - - {% ifequal page_size 30 %} - <span class="curr">30</span> - {% else %} - <span class="page"><a href="{{base_url}}page_size=30">30</a></span> - {% endifequal %} - - {% ifequal page_size 50 %} - <span class="curr">50</span> - {% else %} - <span class="page"><a href="{{base_url}}page_size=50">50</a></span> - {% endifequal %} -</div> -{% endif %} -{% endspaceless %} -<!-- end template pagesize.html --> diff --git a/askbot/skins/default/templates/post_contributor_info.html b/askbot/skins/default/templates/post_contributor_info.html deleted file mode 100644 index 260a0590..00000000 --- a/askbot/skins/default/templates/post_contributor_info.html +++ /dev/null @@ -1,51 +0,0 @@ -{% load i18n %} -{% load smart_if %} -{% load extra_tags %} -<div class='post-update-info'> -{% ifequal contributor_type "original_author" %} - {% if wiki %} - <p>{% trans "community wiki" %}</p> - <p> - {% blocktrans count post.revisions.all|length as rev_count %}{{rev_count}} revision{% plural %}{{rev_count}} revisions{% endblocktrans %} - </p> - <p>{{post.author.get_profile_link}}</p> - {% else %} - <p style="line-height:12px;"> - {% ifequal post_type "question" %} - {% trans "asked" %} - {% else %} - {% ifequal post_type "answer" %} - {% trans "answered" %} - {% else %} - {% trans "posted" %} - {% endifequal %} - {% endifequal %} - {% ifequal post_type "revision" %} - <strong>{% diff_date post.revised_at %}</strong> - {% else %} - <strong>{% diff_date post.added_at %}</strong> - {% endifequal %} - </p> - {% gravatar post.author 32 %} - <p>{{post.author.get_profile_link}}<br/> - {% get_score_badge post.author %}</p> - {% endif %} -{% else %} - {% if post.last_edited_at %} - <p style="line-height:12px;"> - {% ifequal post_type 'question' %} - <a href="{% url question_revisions post.id %}"> - {% else %} - <a href="{% url answer_revisions post.id %}"> - {% endifequal %} - {% trans "updated" %} <strong>{% diff_date post.last_edited_at %}</strong> - </a> - </p> - {% if post.author != post.last_edited_by or wiki %} - {% gravatar post.last_edited_by 32 %} - <p style="float:left">{{post.last_edited_by.get_profile_link}}<br/> - {% get_score_badge post.last_edited_by %}</p> - {% endif %} - {% endif %} -{% endifequal %} -</div> diff --git a/askbot/skins/default/templates/question.html b/askbot/skins/default/templates/question.html index bdaade04..a79e687f 100644 --- a/askbot/skins/default/templates/question.html +++ b/askbot/skins/default/templates/question.html @@ -132,7 +132,7 @@ <div id="question-controls" class="post-controls"> {#todo: here we have important case to reset search state #} <div id="question-tags" class="tags"> - {% for tag in question.tagname_list() %} + {% for tag in question.get_tag_names() %} <a href="{% url questions %}?tags={{tag|urlencode}}&start_over=true" class="post-tag" title="{% trans %}see questions tagged '{{tag}}'{% endtrans %}" rel="tag">{{ tag }}</a> diff --git a/askbot/skins/default/templates/question_list.html b/askbot/skins/default/templates/question_list.html index 3f5d701b..95e4834a 100644 --- a/askbot/skins/default/templates/question_list.html +++ b/askbot/skins/default/templates/question_list.html @@ -60,7 +60,7 @@ {% endif %} </div> <div class="tags"> - {% for tag in question.tagname_list %} + {% for tag in question.get_tag_names %} <a href="{% url questions %}?tags={{tag|urlencode}}" title="{% blocktrans %}see questions tagged '{{ tag }}'{%endblocktrans %}" rel="tag">{{ tag }}</a> {% endfor %} </div> diff --git a/askbot/skins/default/templates/question_retag.html b/askbot/skins/default/templates/question_retag.html index 97f723fb..90eaef37 100644 --- a/askbot/skins/default/templates/question_retag.html +++ b/askbot/skins/default/templates/question_retag.html @@ -1,18 +1,16 @@ -{% extends "base.html" %} +{% extends "base.jinja.html" %} <!-- question_retag.html --> -{% load extra_tags %} -{% load i18n %} -{% block title %}{% spaceless %}{% trans "Change tags" %}{% endspaceless %}{% endblock %} +{% block title %}{% spaceless %}{% trans %}Change tags{% endtrans %}{% endspaceless %}{% endblock %} {% block forejs %} - <script type='text/javascript' src='{% media "/js/com.cnprog.editor.js" %}'></script> - <script type='text/javascript' src='{% media "/js/com.cnprog.post.js" %}'></script> - <script type='text/javascript' src='{% media "/js/jquery.validate.pack.js" %}'></script> + <script type='text/javascript' src='{{"/js/com.cnprog.editor.js"|media}}'></script> + <script type='text/javascript' src='{{"/js/com.cnprog.post.js"|media}}'></script> + <script type='text/javascript' src='{{"/js/jquery.validate.pack.js"|media}}'></script> <script type="text/javascript"> $().ready(function(){ $("#nav_questions").attr('className',"on"); //Tags autocomplete action - var tags = {{ tags|safe }}; + var tags = {{ tags }}; $("#id_tags").autocomplete(tags, { minChars: 1, matchContains: true, @@ -36,8 +34,8 @@ }, messages: { tags: { - required: "{% trans "tags are required" %}", - maxlength: "{% trans "up to 5 tags, less than 20 characters each" %} + required: "{% trans %}tags are required{% endtrans %}", + maxlength: "{% trans %}up to 5 tags, less than 20 characters each{% endtrans %}" } } @@ -50,57 +48,47 @@ {% block content %} <div id="main-bar" class="headNormal"> - {% trans "Change tags" %} [<a href="{{ question.get_absolute_url }}">{% trans "back" %}</a>] + {% trans %}Change tags{% endtrans %} [<a href="{{ question.get_absolute_url() }}">{% trans %}back{% endtrans %}</a>] </div> <div id="main-body" class="ask-body"> <div id="askform"> <form id="fmretag" action="{% url retag_question question.id %}" method="post" > <h3> - {{ question.get_question_title }} + {{ question.get_question_title() }} </h3> <div id="description" class="edit-content-html"> - {{ question.html|safe }} + {{ question.html }} </div> <div class="form-item"> - <strong>{{ form.tags.label_tag }}:</strong> <span class="form-error"></span><br/> + <strong>{{ form.tags.label_tag() }}:</strong> <span class="form-error"></span><br/> {{ form.tags }} {{ form.tags.errors }} <div class="title-desc"> {{ form.tags.help_text }} </div> </div> <div class="error" ></div> - <input type="submit" value="{% trans "Retag" %}" class="submit" /> - <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);" /> + <input type="submit" value="{% trans %}Retag{% endtrans %}" class="submit" /> + <input type="button" value="{% trans %}Cancel{% endtrans %}" class="submit" onclick="history.back(-1);" /> </form> </div> -</div> {% endblock %} {% block sidebar %} <div class="boxC"> - <p class="subtitle">{% trans "Why use and modify tags?" %}</p> + <p class="subtitle">{% trans %}Why use and modify tags?{% endtrans %}</p> <ul class="list-item"> <li> - {% trans "tags help us keep Questions organized" %} - </li> - {% comment %} - <li> - 修改完整问题需要用户的积分达到一定条件(比如:积分 >= 3000分,自己发布的问题除外),而用户积分达到比较低的时候,就可以修改问题的标签(比如:积分 >= 500, 这里指所有问题的标签)。 - </li> - {% endcomment %} <li> - {% trans "tag editors receive special awards from the community" %} + {% trans %}tag editors receive special awards from the community{% endtrans %} </li> </ul> <p class='info-box-follow-up-links'> <a href="{% url faq %}">faq »</a> </p> </div> - {% endblock %} - {% block endjs %} {% endblock %} <!-- end question_retag.html --> diff --git a/askbot/skins/default/templates/question_summary_list_roll.html b/askbot/skins/default/templates/question_summary_list_roll.html index f2432a24..04297c68 100644 --- a/askbot/skins/default/templates/question_summary_list_roll.html +++ b/askbot/skins/default/templates/question_summary_list_roll.html @@ -48,7 +48,7 @@ {% endifequal %} <div class="tags"> - {% for tag in question.tagname_list %} + {% for tag in question.get_tag_names %} <a href="{% url questions %}?tags={{tag|urlencode}}" title="{% blocktrans %}see questions tagged '{{ tag }}'{% endblocktrans %}" rel="tag">{{ tag }}</a> {% endfor %} </div> diff --git a/askbot/skins/default/templates/questions.html b/askbot/skins/default/templates/questions.html index d35336aa..30aa9ee6 100644 --- a/askbot/skins/default/templates/questions.html +++ b/askbot/skins/default/templates/questions.html @@ -1,12 +1,7 @@ -{% extends "base.html" %} +{% extends "base.jinja.html" %} <!-- questions.html --> -{% load extra_tags %} -{% load i18n %} -{% load humanize %} -{% load extra_filters %} -{% load smart_if %} -{% load cache %} -{% block title %}{% spaceless %}{% trans "Questions" %}{% endspaceless %}{% endblock %} +{% import "macros.html" as macros %} +{% block title %}{% spaceless %}{% trans %}Questions{% endtrans %}{% endspaceless %}{% endblock %} {% block forejs %} <script type="text/javascript"> var tags = {{ tags_autocomplete|safe }}; @@ -22,97 +17,88 @@ Hilite.debug_referrer = location.href; }); </script> - <script type='text/javascript' src='{% media "/js/com.cnprog.editor.js" %}'></script> - <script type='text/javascript' src='{% media "/js/com.cnprog.tag_selector.js" %}'></script> + <script type='text/javascript' src='{{"/js/com.cnprog.editor.js"|media}}'></script> + <script type='text/javascript' src='{{"/js/com.cnprog.tag_selector.js"|media}}'></script> {% endblock %} {% block content %} -{% get_current_language as LANGUAGE_CODE %} -{% cache 600 "scope_sort_tabs" search_tags request.user scope sort query context.page context.page_size LANGUAGE_CODE %} +{% cache 600 "scope_sort_tabs" search_tags request.user scope sort query context.page context.page_size language_code %} <div class="tabBar"> <div class="tabsC"> - <span class="label">{% trans "In:" %}</span> - <a id="all" class="off" href="?scope=all" title="{% trans "see all questions" %}">{% trans "all" %}</a> - <a id="unanswered" class="off" href="?scope=unanswered&sort=coldest" title="{% trans "see unanswered questions" %}">{% trans "unanswered" %}</a> - {% if request.user.is_authenticated %} - <a id="favorite" class="off" href="?scope=favorite" title="{% trans "see your favorite questions" %}">{% trans "favorite" %}</a> + <span class="label">{% trans %}In:{% endtrans %}</span> + <a id="all" class="off" href="?scope=all" title="{% trans %}see all questions{% endtrans %}">{% trans %}all{% endtrans %}</a> + <a id="unanswered" class="off" href="?scope=unanswered&sort=coldest" title="{% trans %}see unanswered questions{% endtrans %}">{% trans %}unanswered{% endtrans %}</a> + {% if request.user.is_authenticated() %} + <a id="favorite" class="off" href="?scope=favorite" title="{% trans %}see your favorite questions{% endtrans %}">{% trans %}favorite{% endtrans %}</a> {% endif %} </div> <div class="tabsA"> - <span class="label">{% trans "Sort by:" %}</span> + <span class="label">{% trans %}Sort by:{% endtrans %}</span> {% if sort == "oldest" %} <a id="oldest" href="?sort=latest" class="off" - title="{% trans "click to see the newest questions" %}">{% trans "oldest" %}</a> + title="{% trans %}click to see the newest questions{% endtrans %}">{% trans %}oldest{% endtrans %}</a> + {% elif sort == "latest" %} + <a id="latest" + href="?sort=oldest" + class="off" + title="{% trans %}click to see the oldest questions{% endtrans %}">{% trans %}newest{% endtrans %}</a> {% else %} - {% if sort == "latest" %} - <a id="latest" - href="?sort=oldest" - class="off" - title="{% trans "click to see the oldest questions" %}">{% trans "newest" %}</a> - {% else %} - <a id="latest" - href="?sort=latest" - class="off" - title="{% trans "click to see the newest questions" %}">{% trans "newest" %}</a> - {% endif %} + <a id="latest" + href="?sort=latest" + class="off" + title="{% trans %}click to see the newest questions{% endtrans %}">{% trans %}newest{% endtrans %}</a> {% endif %} {% if sort == "inactive" %} <a id="inactive" href="?sort=active" class="off" - title="{% trans "click to see the most recently updated questions" %}">{% trans "inactive" %}</a> + title="{% trans %}click to see the most recently updated questions{% endtrans %}">{% trans %}inactive{% endtrans %}</a> + {% elif sort == "active" %} + <a id="active" + href="?sort=inactive" + class="off" + title="{% trans %}click to see the least recently updated questions{% endtrans %}">{% trans %}active{% endtrans %}</a> {% else %} - {% if sort == "active" %} - <a id="active" - href="?sort=inactive" - class="off" - title="{% trans "click to see the least recently updated questions" %}">{% trans "active" %}</a> - {% else %} - <a id="active" - href="?sort=active" - class="off" - title="{% trans "click to see the most recently updated questions" %}">{% trans "active" %}</a> - {% endif %} + <a id="active" + href="?sort=active" + class="off" + title="{% trans %}click to see the most recently updated questions{% endtrans %}">{% trans %}active{% endtrans %}</a> {% endif %} {% if sort == "coldest" %} <a id="coldest" href="?sort=hottest" class="off" - title="{% trans "click to see hottest questions" %}">{% trans "less answers" %}</a> + title="{% trans %}click to see hottest questions{% endtrans %}">{% trans %}less answers{% endtrans %}</a> + {% elif sort == "hottest" %} + <a id="hottest" + href="?sort=coldest" + class="off" + title="{% trans %}click to see coldest questions{% endtrans %}">{% trans %}more answers{% endtrans %}</a> {% else %} - {% if sort == "hottest" %} - <a id="hottest" - href="?sort=coldest" - class="off" - title="{% trans "click to see coldest questions" %}">{% trans "more answers" %}</a> - {% else %} - <a id="hottest" - href="?sort=hottest" - class="off" - title="{% trans "click to see hottest questions" %}">{% trans "more answers" %}</a> - {% endif %} + <a id="hottest" + href="?sort=hottest" + class="off" + title="{% trans %}click to see hottest questions{% endtrans %}">{% trans %}more answers{% endtrans %}</a> {% endif %} {% if sort == "leastvoted" %} <a id="leastvoted" href="?sort=mostvoted" class="off" - title="{% trans "click to see most voted questions" %}">{% trans "unpopular" %}</a> + title="{% trans %}click to see most voted questions{% endtrans %}">{% trans %}unpopular{% endtrans %}</a> + {% elif sort == "mostvoted" %} + <a id="mostvoted" + href="?sort=leastvoted" + class="off" + title="{% trans %}click to see least voted questions{% endtrans %}">{% trans %}popular{% endtrans %}</a> {% else %} - {% if sort == "mostvoted" %} - <a id="mostvoted" - href="?sort=leastvoted" - class="off" - title="{% trans "click to see least voted questions" %}">{% trans "popular" %}</a> - {% else %} - <a id="mostvoted" - href="?sort=mostvoted" - class="off" - title="{% trans "click to see most voted questions" %}">{% trans "popular" %}</a> - {% endif %} + <a id="mostvoted" + href="?sort=mostvoted" + class="off" + title="{% trans %}click to see most voted questions{% endtrans %}">{% trans %}popular{% endtrans %}</a> {% endif %} </div> </div> @@ -122,62 +108,54 @@ <p style="float:right;margin:3px 3px 0 0;"> (<a style="text-decoration:none;" href="{{settings.APP_URL}}/feeds/rss/" - title="{% trans "subscribe to the questions feed" %}" + title="{% trans %}subscribe to the questions feed{% endtrans %}" ><img style="vertical-align:middle;" - alt="{% trans "subscribe to the questions feed" %}" - src="{% media "/images/feed-icon-small.png" %}"/> {% trans "rss feed" %}</a>) + alt="{% trans %}subscribe to the questions feed{% endtrans %}" + src="{{"/images/feed-icon-small.png"|media}}"/> {% trans %}rss feed{% endtrans %}</a>) </p> <p id="question-count" class="search-result-summary"> {% if author_name or search_tags or query %} - {% blocktrans count questions_count as cnt with questions_count|intcomma as q_num %} + {% trans cnt=questions_count, q_num=questions_count|intcomma %} {{q_num}} question found - {% plural %} + {% pluralize %} {{q_num}} questions found - {% endblocktrans %} + {% endtrans %} {% else %} - {% blocktrans count questions_count as cnt with questions_count|intcomma as q_num %}{{q_num}} question{% plural %}{{q_num}} questions{% endblocktrans %} + {% trans cnt=questions_count, q_num=questions_count|intcomma %}{{q_num}} question{% pluralize %}{{q_num}} questions{% endtrans %} + {% endif %} + {% if author_name %} + {% trans %}with {{author_name}}'s contributions{% endtrans %} + {% endif %} + {% if search_tags %}{% if author_name %}, {% endif %} + {% trans %}tagged{% endtrans %} + "{{ search_tags|join('", "') }}" {% endif %} - {% joinitems using ', ' %} - {% if author_name %} - {% blocktrans %}with {{author_name}}'s contributions{% endblocktrans %} - {% endif %} - {% separator %} - {% if search_tags %} - {% trans "tagged" %} - "{{ search_tags|join:"\", \"" }}" - {% endif %} - {% endjoinitems %} </p> {% if author_name or search_tags or query %} - <p class="search-tips">{% trans "Search tips:" %} - {% ifmany query search_tags author_name %} - {% joinitems using ', ' ' or ' %} - {% if author_name %} - <a href="{% url questions %}?reset_author=true">{% trans "reset author" %}</a> - {% endif %} - {% separator %} - {% if search_tags %} - <a href="{% url questions %}?reset_tags=true">{% trans "reset tags" %}</a> - {% endif %} - {% separator %} - {% ifmany query search_tags author_name %} - <a href="{% url questions %}?start_over=true">{% trans "start over" %}</a> - {% endifmany %} - {% endjoinitems %} + <p class="search-tips">{% trans %}Search tips:{% endtrans %} + {% if reset_method_count > 1 %} + {% if author_name %} + <a href="{% url questions %}?reset_author=true">{% trans %}reset author{% endtrans %}</a> + {% endif %} + {% if search_tags %}{% if author_name and query %}, {% elif author_name %}{% trans %} or {% endtrans %}{% endif %} + <a href="{% url questions %}?reset_tags=true">{% trans %}reset tags{% endtrans %}</a> + {% endif %} + {% if query %}{% trans %} or {% endtrans %} + <a href="{% url questions %}?start_over=true">{% trans %}start over{% endtrans %}</a> + {% endif %} {% else %} - <a href="{% url questions %}?start_over=true">{% trans "start over" %}</a> - {% endifmany %} - {% trans " - to expand, or dig in by adding more tags and revising the query." %} + <a href="{% url questions %}?start_over=true">{% trans %}start over{% endtrans %}</a> + {% endif %} + {% trans %} - to expand, or dig in by adding more tags and revising the query.{% endtrans %} </p> {% else %} - <p class="search-tips">{% trans "Search tip:" %} {% trans "add tags and a query to focus your search" %}</p> + <p class="search-tips">{% trans %}Search tip:{% endtrans %} {% trans %}add tags and a query to focus your search{% endtrans %}</p> {% endif %} </div> {% endif %} <div id="listA"> -{% get_current_language as LANGUAGE_CODE %} -{% cache 60 questions search_tags scope sort query context.page context.page_size LANGUAGE_CODE %} +{% cache 60 "questions" questions search_tags scope sort query context.page context.page_size language_code %} {% for question in questions.object_list %} <div class="short-summary"> <div class="counts"> @@ -191,12 +169,9 @@ {% endif %} >{{question.score|humanize_counter}}</span> <div> - {% blocktrans count question.score as cnt %}vote{% plural %}votes{% endblocktrans %} + {% trans cnt=question.score %}vote{% pluralize %}votes{% endtrans %} </div> </div > - {% comment %} - <div {% if question.answer_accepted %}title="{% trans "this answer has been accepted to be correct" %}"{% endif %} class="status {% if question.answer_accepted %}answered-accepted{% endif %} {% ifequal question.answer_count 0 %}unanswered{% endifequal %}{% ifnotequal question.answer_count 0 %}answered{% endifnotequal %}"> - {% endcomment %} <div class="votes"> <span class="item-count" @@ -211,7 +186,7 @@ {% endif %} >{{question.answer_count|humanize_counter}}</span> <div> - {% blocktrans count question.answer_count as cnt %}answer{% plural %}answers{% endblocktrans %} + {% trans cnt=question.answer_count %}answer{% pluralize %}answers{% endtrans %} </div> </div> <div class="votes"> @@ -223,108 +198,101 @@ {% endif %} >{{question.view_count|humanize_counter}}</span> <div> - {% blocktrans count question.view_count as cnt %}view{% plural %}views{% endblocktrans %} + {% trans cnt=question.view_count %}view{% pluralize %}views{% endtrans %} </div> </div> </div> - <h2><a title="{{question.summary}}" href="{% url question id=question.id %}{{question.title|slugify}}">{{question.title}}</a></h2> + <h2><a title="{{question.summary|escape}}" href="{{ question.get_absolute_url() }}">{{question.title|escape}}</a></h2> <div class="userinfo"> - <span class="relativetime" title="{{question.last_activity_at}}">{% diff_date question.last_activity_at %}</span> - {% if question.last_activity_by %} - <a href="{% url user_profile question.last_activity_by.id question.last_activity_by.username|slugify %}">{{ question.last_activity_by }}</a> {% get_score_badge question.last_activity_by %} - {% endif %} + <span class="relativetime" title="{{question.last_activity_at}}">{{ question.last_activity_at|diff_date }}</span> + <a href="{% url user_profile question.last_activity_by.id, question.last_activity_by.username|slugify %}">{{question.last_activity_by.username}}</a> + {{macros.user_score_and_badge_summary(question.last_activity_by)}} </div> <div class="tags"> - {% for tag in question.tagname_list %} - <a href="{% url questions %}?tags={{tag|urlencode}}" title="{% blocktrans %}see questions tagged '{{ tag }}'{%endblocktrans %}" rel="tag">{{ tag }}</a> + {% for tag in question.get_tag_names() %} + <a href="{% url questions %}?tags={{tag|urlencode}}" title="{% trans %}see questions tagged '{{ tag }}'{% endtrans %}" rel="tag">{{ tag }}</a> {% endfor %} </div> </div> {% endfor %} {% endcache %} - {% comment %}todo: fix css here{% endcomment %} + {# comment todo: fix css here #} {% if questions_count == 0 %} - {% comment %}todo: add tips to widen selection{% endcomment%} + {# todo: add tips to widen selection #} <p class="evenMore" style="padding-top:30px;text-align:center;"> {% if scope == "unanswered" %} - {% trans "There are no unanswered questions here" %} + {% trans %}There are no unanswered questions here{% endtrans %} {% endif %} {% if scope == "favorite" %} - {% trans "No favorite questions here. " %} - {% trans "Please start (bookmark) some questions when you visit them" %} + {% trans %}No favorite questions here. {% endtrans %} + {% trans %}Please start (bookmark) some questions when you visit them{% endtrans %} {% endif %} </p> {% if query or search_tags or author_name %} <p class="evenMore" style="text-align:center"> - {% trans "You can expand your search by " %} - {% ifmany query search_tags author_name %} - {% joinitems using ', ' ' or ' %} - {% if author_name %} - <a href="{% url questions %}?reset_author=true">{% trans "resetting author" %}</a> - {% endif %} - {% separator %} - {% if search_tags %} - <a href="{% url questions %}?reset_tags=true">{% trans "resetting tags" %}</a> - {% endif %} - {% separator %} - {% ifmany query search_tags author_name %} - <a href="{% url questions %}?start_over=true">{% trans "starting over" %}</a> - {% endifmany %} - {% endjoinitems %} + {% trans %}You can expand your search by {% endtrans %} + {% if reset_method_count > 1 %} + {% if author_name %} + <a href="{% url questions %}?reset_author=true">{% trans %}resetting author{% endtrans %}</a> + {% endif %} + {% if search_tags %}{% if author_name and query %}, {% elif author_name %}{% trans %} or {% endtrans %}{% endif %} + <a href="{% url questions %}?reset_tags=true">{% trans %}resetting tags{% endtrans %}</a> + {% endif %} + {% if query %}{% trans %} or {% endtrans %} + <a href="{% url questions %}?start_over=true">{% trans %}starting over{% endtrans %}</a> + {% endif %} {% else %} - <a href="{% url questions %}?start_over=true">{% trans "starting over" %}</a> - {% endifmany %} + <a href="{% url questions %}?start_over=true">{% trans %}starting over{% endtrans %}</a> + {% endif %} </p> {% endif %} <p class="evenMore" style="text-align:center"> - <a href="{% url ask %}">{% trans "Please always feel free to ask your question!" %}</a> + <a href="{% url ask %}">{% trans %}Please always feel free to ask your question!{% endtrans %}</a> </p> {% else %} <p class="evenMore" style="padding-left:9px"> - {% trans "Did not find what you were looking for?" %} - <a href="{% url ask %}">{% trans "Please, post your question!" %}</a> + {% trans %}Did not find what you were looking for?{% endtrans %} + <a href="{% url ask %}">{% trans %}Please, post your question!{% endtrans %}</a> </p> {% endif %} </div> -<script type="text/javascript" src="{% media "/js/live_search.js" %}"></script> +<script type="text/javascript" src="{{"/js/live_search.js"|media}}"></script> {% endblock %} {% block tail %} - {% if questions_count > 10 %}{%comment%}todo: remove magic number{%endcomment%} - <div id="pager" class="pager">{% cnprog_paginator context %}</div> - <div class="pagesize">{% cnprog_pagesize context %}</div> + {% if questions_count > 10 %}{# todo: remove magic number #} + <div id="pager" class="pager">{{ macros.paginator(context|setup_paginator) }}</div> + <div class="pagesize">{{ macros.pagesize_switch(context) }}</div> {% endif %} {% endblock %} {% block sidebar %} {% if contributors %} - {% get_current_language as LANGUAGE_CODE %} - {% cache 600 contributors search_tags scope sort query context.page context.page_size LANGUAGE_CODE %} + {% cache 600 "contributors" contributors search_tags scope sort query context.page context.page_size language_code %} <div id="contrib-users" class="boxC"> - <h3 class="subtitle">{% trans "Contributors" %}</h3> + <h3 class="subtitle">{% trans %}Contributors{% endtrans %}</h3> {% spaceless %} {% for person in contributors %} - {% gravatar person 48 %} + {{ macros.gravatar(person,48) }} {% endfor %} {% endspaceless %} </div> {% endcache %} {% endif %} - {% if request.user.is_authenticated %} - {% include "tag_selector.html" %} + {% if request.user.is_authenticated() %} + {% include "tag_selector.jinja.html" %} {% endif %} {% if tags %} - {% get_current_language as LANGUAGE_CODE %} - {% cache 600 tags search_tags scope sort query context.page context.page_size LANGUAGE_CODE %} + {% cache 600 "tags" tags search_tags scope sort query context.page context.page_size language_code %} <div class="boxC"> - <h3 class="subtitle">{% trans "Related tags" %}</h3> + <h3 class="subtitle">{% trans %}Related tags{% endtrans %}</h3> <div id="related-tags" class="tags"> {% for tag in tags %} <a rel="tag" - title="{% blocktrans with tag.name as tag_name %}see questions tagged '{{ tag_name }}'{% endblocktrans %}" + title="{% trans tag_name=tag.name %}see questions tagged '{{ tag_name }}'{% endtrans %}" href="{% url questions %}?tags={{tag.name|urlencode}}">{{ tag.name }}</a> <span class="tag-number">× {{ tag.used_count|intcomma }}</span> <br /> diff --git a/askbot/skins/default/templates/questions.jinja.html b/askbot/skins/default/templates/questions.jinja.html deleted file mode 100644 index aa5b3436..00000000 --- a/askbot/skins/default/templates/questions.jinja.html +++ /dev/null @@ -1,305 +0,0 @@ -{% extends "base.jinja.html" %} -<!-- questions.html --> -{% import "macros.html" as macros %} -{% block title %}{% spaceless %}{% trans %}Questions{% endtrans %}{% endspaceless %}{% endblock %} -{% block forejs %} - <script type="text/javascript"> - var tags = {{ tags_autocomplete|safe }}; - $().ready(function(){ - var sort_tab_id = "{{ sort }}"; - $("#"+sort_tab_id).attr('className',"on"); - var scope_tab_id = "{{ scope }}"; - $("#"+scope_tab_id).attr('className',"on"); - var on_tab = '#nav_questions'; - $(on_tab).attr('className','on'); - Hilite.exact = false; - Hilite.elementid = "listA"; - Hilite.debug_referrer = location.href; - }); - </script> - <script type='text/javascript' src='{{"/js/com.cnprog.editor.js"|media}}'></script> - <script type='text/javascript' src='{{"/js/com.cnprog.tag_selector.js"|media}}'></script> -{% endblock %} -{% block content %} -{% cache 600 "scope_sort_tabs" search_tags request.user scope sort query context.page context.page_size language_code %} -<div class="tabBar"> - <div class="tabsC"> - <span class="label">{% trans %}In:{% endtrans %}</span> - <a id="all" class="off" href="?scope=all" title="{% trans %}see all questions{% endtrans %}">{% trans %}all{% endtrans %}</a> - <a id="unanswered" class="off" href="?scope=unanswered&sort=coldest" title="{% trans %}see unanswered questions{% endtrans %}">{% trans %}unanswered{% endtrans %}</a> - {% if request.user.is_authenticated() %} - <a id="favorite" class="off" href="?scope=favorite" title="{% trans %}see your favorite questions{% endtrans %}">{% trans %}favorite{% endtrans %}</a> - {% endif %} - </div> - <div class="tabsA"> - <span class="label">{% trans %}Sort by:{% endtrans %}</span> - {% if sort == "oldest" %} - <a id="oldest" - href="?sort=latest" - class="off" - title="{% trans %}click to see the newest questions{% endtrans %}">{% trans %}oldest{% endtrans %}</a> - {% elif sort == "latest" %} - <a id="latest" - href="?sort=oldest" - class="off" - title="{% trans %}click to see the oldest questions{% endtrans %}">{% trans %}newest{% endtrans %}</a> - {% else %} - <a id="latest" - href="?sort=latest" - class="off" - title="{% trans %}click to see the newest questions{% endtrans %}">{% trans %}newest{% endtrans %}</a> - {% endif %} - - {% if sort == "inactive" %} - <a id="inactive" - href="?sort=active" - class="off" - title="{% trans %}click to see the most recently updated questions{% endtrans %}">{% trans %}inactive{% endtrans %}</a> - {% elif sort == "active" %} - <a id="active" - href="?sort=inactive" - class="off" - title="{% trans %}click to see the least recently updated questions{% endtrans %}">{% trans %}active{% endtrans %}</a> - {% else %} - <a id="active" - href="?sort=active" - class="off" - title="{% trans %}click to see the most recently updated questions{% endtrans %}">{% trans %}active{% endtrans %}</a> - {% endif %} - - {% if sort == "coldest" %} - <a id="coldest" - href="?sort=hottest" - class="off" - title="{% trans %}click to see hottest questions{% endtrans %}">{% trans %}less answers{% endtrans %}</a> - {% elif sort == "hottest" %} - <a id="hottest" - href="?sort=coldest" - class="off" - title="{% trans %}click to see coldest questions{% endtrans %}">{% trans %}more answers{% endtrans %}</a> - {% else %} - <a id="hottest" - href="?sort=hottest" - class="off" - title="{% trans %}click to see hottest questions{% endtrans %}">{% trans %}more answers{% endtrans %}</a> - {% endif %} - - {% if sort == "leastvoted" %} - <a id="leastvoted" - href="?sort=mostvoted" - class="off" - title="{% trans %}click to see most voted questions{% endtrans %}">{% trans %}unpopular{% endtrans %}</a> - {% elif sort == "mostvoted" %} - <a id="mostvoted" - href="?sort=leastvoted" - class="off" - title="{% trans %}click to see least voted questions{% endtrans %}">{% trans %}popular{% endtrans %}</a> - {% else %} - <a id="mostvoted" - href="?sort=mostvoted" - class="off" - title="{% trans %}click to see most voted questions{% endtrans %}">{% trans %}popular{% endtrans %}</a> - {% endif %} - </div> -</div> -{% endcache %} -{% if questions_count > 0 %} - <div style="clear:both"> - <p style="float:right;margin:3px 3px 0 0;"> - (<a style="text-decoration:none;" - href="{{settings.APP_URL}}/feeds/rss/" - title="{% trans %}subscribe to the questions feed{% endtrans %}" - ><img - style="vertical-align:middle;" - alt="{% trans %}subscribe to the questions feed{% endtrans %}" - src="{{"/images/feed-icon-small.png"|media}}"/> {% trans %}rss feed{% endtrans %}</a>) - </p> - <p id="question-count" class="search-result-summary"> - {% if author_name or search_tags or query %} - {% trans cnt=questions_count, q_num=questions_count|intcomma %} - {{q_num}} question found - {% pluralize %} - {{q_num}} questions found - {% endtrans %} - {% else %} - {% trans cnt=questions_count, q_num=questions_count|intcomma %}{{q_num}} question{% pluralize %}{{q_num}} questions{% endtrans %} - {% endif %} - {% if author_name %} - {% trans %}with {{author_name}}'s contributions{% endtrans %} - {% endif %} - {% if search_tags %}{% if author_name %}, {% endif %} - {% trans %}tagged{% endtrans %} - "{{ search_tags|join('", "') }}" - {% endif %} - </p> - {% if author_name or search_tags or query %} - <p class="search-tips">{% trans %}Search tips:{% endtrans %} - {% if reset_method_count > 1 %} - {% if author_name %} - <a href="{% url questions %}?reset_author=true">{% trans %}reset author{% endtrans %}</a> - {% endif %} - {% if search_tags %}{% if author_name and query %}, {% elif author_name %}{% trans %} or {% endtrans %}{% endif %} - <a href="{% url questions %}?reset_tags=true">{% trans %}reset tags{% endtrans %}</a> - {% endif %} - {% if query %}{% trans %} or {% endtrans %} - <a href="{% url questions %}?start_over=true">{% trans %}start over{% endtrans %}</a> - {% endif %} - {% else %} - <a href="{% url questions %}?start_over=true">{% trans %}start over{% endtrans %}</a> - {% endif %} - {% trans %} - to expand, or dig in by adding more tags and revising the query.{% endtrans %} - </p> - {% else %} - <p class="search-tips">{% trans %}Search tip:{% endtrans %} {% trans %}add tags and a query to focus your search{% endtrans %}</p> - {% endif %} - </div> -{% endif %} -<div id="listA"> -{% cache 60 "questions" questions search_tags scope sort query context.page context.page_size language_code %} - {% for question in questions.object_list %} - <div class="short-summary"> - <div class="counts"> - <div class="votes"> - <span - class="item-count" - {% if question.score == 0 %} - style="background:{{settings.COLORS_VOTE_COUNTER_EMPTY_BG}};color:{{settings.COLORS_VOTE_COUNTER_EMPTY_FG}}" - {% else %} - style="background:{{settings.COLORS_VOTE_COUNTER_MIN_BG}};color:{{settings.COLORS_VOTE_COUNTER_MIN_FG}}" - {% endif %} - >{{question.score|humanize_counter}}</span> - <div> - {% trans cnt=question.score %}vote{% pluralize %}votes{% endtrans %} - </div> - </div > - <div class="votes"> - <span - class="item-count" - {% if question.answer_count == 0 %} - style="background:{{settings.COLORS_ANSWER_COUNTER_EMPTY_BG}};color:{{settings.COLORS_ANSWER_COUNTER_EMPTY_FG}}" - {% else %} - {% if question.answer_accepted %} - style="background:{{settings.COLORS_ANSWER_COUNTER_ACCEPTED_BG}};color:{{settings.COLORS_ANSWER_COUNTER_ACCEPTED_FG}}" - {% else %} - style="background:{{settings.COLORS_ANSWER_COUNTER_MIN_BG}};color:{{settings.COLORS_ANSWER_COUNTER_MIN_FG}}" - {% endif %} - {% endif %} - >{{question.answer_count|humanize_counter}}</span> - <div> - {% trans cnt=question.answer_count %}answer{% pluralize %}answers{% endtrans %} - </div> - </div> - <div class="votes"> - <span class="item-count" - {% if question.view_count == 0 %} - style="background:{{settings.COLORS_VIEW_COUNTER_EMPTY_BG}};color:{{settings.COLORS_VIEW_COUNTER_EMPTY_FG}}" - {% else %} - style="background:{{settings.COLORS_VIEW_COUNTER_MIN_BG}};color:{{settings.COLORS_VIEW_COUNTER_MIN_FG}}" - {% endif %} - >{{question.view_count|humanize_counter}}</span> - <div> - {% trans cnt=question.view_count %}view{% pluralize %}views{% endtrans %} - </div> - </div> - </div> - <h2><a title="{{question.summary|escape}}" href="{{ question.get_absolute_url() }}">{{question.title|escape}}</a></h2> - <div class="userinfo"> - <span class="relativetime" title="{{question.last_activity_at}}">{{ question.last_activity_at|diff_date }}</span> - <a href="{% url user_profile question.last_activity_by.id, question.last_activity_by.username|slugify %}">{{question.last_activity_by.username}}</a> - {{macros.user_score_and_badge_summary(question.last_activity_by)}} - </div> - <div class="tags"> - {% for tag in question.tagname_list() %} - <a href="{% url questions %}?tags={{tag|urlencode}}" title="{% trans %}see questions tagged '{{ tag }}'{% endtrans %}" rel="tag">{{ tag }}</a> - {% endfor %} - </div> - </div> - {% endfor %} -{% endcache %} - {# comment todo: fix css here #} - {% if questions_count == 0 %} - {# todo: add tips to widen selection #} - <p class="evenMore" style="padding-top:30px;text-align:center;"> - {% if scope == "unanswered" %} - {% trans %}There are no unanswered questions here{% endtrans %} - {% endif %} - {% if scope == "favorite" %} - {% trans %}No favorite questions here. {% endtrans %} - {% trans %}Please start (bookmark) some questions when you visit them{% endtrans %} - {% endif %} - </p> - {% if query or search_tags or author_name %} - <p class="evenMore" style="text-align:center"> - {% trans %}You can expand your search by {% endtrans %} - {% if reset_method_count > 1 %} - {% if author_name %} - <a href="{% url questions %}?reset_author=true">{% trans %}resetting author{% endtrans %}</a> - {% endif %} - {% if search_tags %}{% if author_name and query %}, {% elif author_name %}{% trans %} or {% endtrans %}{% endif %} - <a href="{% url questions %}?reset_tags=true">{% trans %}resetting tags{% endtrans %}</a> - {% endif %} - {% if query %}{% trans %} or {% endtrans %} - <a href="{% url questions %}?start_over=true">{% trans %}starting over{% endtrans %}</a> - {% endif %} - {% else %} - <a href="{% url questions %}?start_over=true">{% trans %}starting over{% endtrans %}</a> - {% endif %} - </p> - {% endif %} - <p class="evenMore" style="text-align:center"> - <a href="{% url ask %}">{% trans %}Please always feel free to ask your question!{% endtrans %}</a> - </p> - {% else %} - <p class="evenMore" style="padding-left:9px"> - {% trans %}Did not find what you were looking for?{% endtrans %} - <a href="{% url ask %}">{% trans %}Please, post your question!{% endtrans %}</a> - </p> - {% endif %} -</div> -<script type="text/javascript" src="{{"/js/live_search.js"|media}}"></script> -{% endblock %} - - {% block tail %} - {% if questions_count > 10 %}{# todo: remove magic number #} - <div id="pager" class="pager">{{ macros.paginator(context|setup_paginator) }}</div> - <div class="pagesize">{{ macros.pagesize_switch(context) }}</div> - {% endif %} - {% endblock %} - -{% block sidebar %} - {% if contributors %} - {% cache 600 "contributors" contributors search_tags scope sort query context.page context.page_size language_code %} - <div id="contrib-users" class="boxC"> - <h3 class="subtitle">{% trans %}Contributors{% endtrans %}</h3> - {% spaceless %} - {% for person in contributors %} - {{ macros.gravatar(person,48) }} - {% endfor %} - {% endspaceless %} - </div> - {% endcache %} - {% endif %} - - {% if request.user.is_authenticated() %} - {% include "tag_selector.jinja.html" %} - {% endif %} - - {% if tags %} - {% cache 600 "tags" tags search_tags scope sort query context.page context.page_size language_code %} - <div class="boxC"> - <h3 class="subtitle">{% trans %}Related tags{% endtrans %}</h3> - <div id="related-tags" class="tags"> - {% for tag in tags %} - <a - rel="tag" - title="{% trans tag_name=tag.name %}see questions tagged '{{ tag_name }}'{% endtrans %}" - href="{% url questions %}?tags={{tag.name|urlencode}}">{{ tag.name }}</a> - <span class="tag-number">× {{ tag.used_count|intcomma }}</span> - <br /> - {% endfor %} - </div> - </div> - {% endcache %} - {% endif %} -{% endblock %} -<!-- end questions.html --> diff --git a/askbot/skins/default/templates/questions_ajax.html b/askbot/skins/default/templates/questions_ajax.html index 83e4d09f..d2df8015 100644 --- a/askbot/skins/default/templates/questions_ajax.html +++ b/askbot/skins/default/templates/questions_ajax.html @@ -64,7 +64,7 @@ {% endif %} </div> <div class="tags"> - {% for tag in question.tagname_list %} + {% for tag in question.get_tag_names %} <a href="{% url questions %}?tags={{tag|urlencode}}" title="{% blocktrans %}see questions tagged '{{ tag }}'{%endblocktrans %}" rel="tag">{{ tag }}</a> {% endfor %} </div> diff --git a/askbot/skins/default/templates/reopen.html b/askbot/skins/default/templates/reopen.html index 75bc026a..a2617150 100644 --- a/askbot/skins/default/templates/reopen.html +++ b/askbot/skins/default/templates/reopen.html @@ -1,9 +1,6 @@ -{% extends "base_content.html" %} +{% extends "base.jinja.html" %} <!-- reopen.html --> -{% load extra_tags %} -{% load i18n %} -{% load humanize %} -{% block title %}{% spaceless %}{% trans "Reopen question" %}{% endspaceless %}{% endblock %} +{% block title %}{% spaceless %}{% trans %}Reopen question{% endtrans %}{% endspaceless %}{% endblock %} {% block forejs %} <script type="text/javascript"> $().ready(function(){ @@ -13,34 +10,32 @@ {% endblock %} {% block content %} <div id="main-bar" class="headNormal"> - {% trans "Reopen question" %} + {% trans %}Reopen question{% endtrans %} </div> <div id="main-body" style="width:100%"> - <p>{% trans "Title" %}: - <a href="{{ question.get_absolute_url }}"> - <span class="big">{{ question.get_question_title }}</span> + <p>{% trans %}Title{% endtrans %}: + <a href="{{ question.get_absolute_url() }}"> + <span class="big">{{ question.get_question_title() }}</span> </a> </p> - <p>{% blocktrans %}This question has been closed by + <p>{% trans %}This question has been closed by <a href="{{closed_by_profile_url}}">{{closed_by_username}}</a> - {% endblocktrans %} + {% endtrans %} </p> <p> - {% trans "Close reason:" %} "<strong>{{question.get_close_reason_display}}</strong>". + {% trans %}Close reason:{% endtrans %} "<strong>{{question.get_close_reason_display()}}</strong>". </p> <p> - {% trans "When:" %} {% diff_date question.closed_at %} + {% trans %}When:{% endtrans %} {{question.closed_at|diff_date}} </p> <p> - {% trans "Reopen this question?" %} + {% trans %}Reopen this question?{% endtrans %} </p> <form id="fmclose" action="{% url reopen question.id %}" method="post" > <div id="" style="padding:20px 0 20px 0"> - <input type="submit" value="{% trans "Reopen this question" %}" class="submit" /> - <input id="btBack" type="button" value="{% trans "Cancel" %}" class="submit" /> - + <input type="submit" value="{% trans %}Reopen this question{% endtrans %}" class="submit" /> + <input id="btBack" type="button" value="{% trans %}Cancel{% endtrans %}" class="submit" /> </div> - </form> </div> {% endblock %} diff --git a/askbot/skins/default/templates/revisions.html b/askbot/skins/default/templates/revisions.html new file mode 100644 index 00000000..0ed0e959 --- /dev/null +++ b/askbot/skins/default/templates/revisions.html @@ -0,0 +1,99 @@ +{% extends "base.jinja.html" %} +{% import "macros.html" as macros %} +<!-- revisions.html --> +{% block title %}{% spaceless %}{% trans %}Revision history{% endtrans %}{% endspaceless %}{% endblock %} +{% block forejs %} + <script type='text/javascript' src='{{"/js/com.cnprog.editor.js"|media}}'></script> + <script type='text/javascript' src='{{"/js/com.cnprog.post.js"|media}}'></script> + <script type="text/javascript"> + //todo - take this out into .js file + $().ready(function(){ + $("#nav_questions").attr('className',"on"); + $('div.revision div[id^=rev-header-]').bind('click', function(){ + var revId = this.id.substr(11); + toggleRev(revId); + + }); + lanai.highlightSyntax(); + }); + + function toggleRev(id) { + var arrow = $("#rev-arrow-" + id); + var visible = arrow.attr("src").indexOf("hide") > -1; + var path = mediaUrl( + "media/images/expander-arrow-" + + (visible ? "show" : "hide") + + ".gif" + + "?v={{settings.MEDIA_RESOURCE_REVISION}}" + ); + arrow.attr("src", path); + $("#rev-body-" + id).slideToggle("fast"); + } + + </script> +{% endblock %} + +{% block content %} +<div id="main-bar" class="headNormal"> + {% trans %}Revision history{% endtrans %} [<a href="{{ post.get_absolute_url() }}">{% trans %}back{% endtrans %}</a>] +</div> +<div id="revisions"> +{% for revision in revisions %} + <div class="revision"> + <div + id="rev-header-{{ revision.revision }}" + class="header {% if post.author_id == revision.author_id %}author{% endif %}" + > + <div class="header-controls"> + <table width="100%"> + <tr> + <td width="20" style="vertical-align:middle"> + <img + id="rev-arrow-{{ revision.revision }}" + src="{{"/images/expander-arrow-show.gif"|media}}" + alt="{% trans %}click to hide/show revision{% endtrans %}" + /> + </td> + <td width="30px" style="vertical-align:middle"> + <span + class="revision-number" + title="{% trans number=revision.revision %}revision {{number}}{% endtrans %}">{{ revision.revision }}</span></td> + <td width="200px" style="vertical-align:middle"> + {% if revision.summary %} + <div class="summary"> + <span>{{ revision.summary }}</span> + </div> + {% endif %} + {% if request.user|can_edit_post(post) %} + <a href="{% url edit_answer post.id %}?revision={{ revision.revision }}">{% trans %}edit{% endtrans %}</a> + {% endif %} + </td> + <td align="right"> + <div class="revision-mark" > + {% if revision.revision == 1 %} + {% set contributor_type = "original_author" %} + {% else %} + {% set contributor_type = "last_updater" %} + {% endif %} + {{ macros.post_contributor_info( + revision, + contributor_type, + False) + }} + </div> + </td> + </tr> + </table> + </div> + </div> + <div id="rev-body-{{ revision.revision }}" class="answerbody"> + {{ revision.diff }} + </div> + </div> +{% endfor %} +</div> +{% endblock %} + +{% block endjs %} +{% endblock %} +<!-- end revisions.html --> diff --git a/askbot/skins/default/templates/revisions_answer.html b/askbot/skins/default/templates/revisions_answer.html deleted file mode 100644 index 92eafe6a..00000000 --- a/askbot/skins/default/templates/revisions_answer.html +++ /dev/null @@ -1,83 +0,0 @@ -{% extends "base_content.html" %} -<!-- revisions_answer.html --> -{% load i18n %} -{% load extra_tags %} -{% load extra_filters %} -{% load humanize %} -{% block title %}{% spaceless %}{% trans "Revision history" %}{% endspaceless %}{% endblock %} -{% block forejs %} - <script type='text/javascript' src='{% media "/js/com.cnprog.editor.js" %}'></script> - <script type='text/javascript' src='{% media "/js/com.cnprog.post.js" %}'></script> - <script type="text/javascript"> - //todo - take this out into .js file - $().ready(function(){ - $("#nav_questions").attr('className',"on"); - $('div.revision div[id^=rev-header-]').bind('click', function(){ - var revId = this.id.substr(11); - toggleRev(revId); - - }); - lanai.highlightSyntax(); - }); - - function toggleRev(id) { - var arrow = $("#rev-arrow-" + id); - var visible = arrow.attr("src").indexOf("hide") > -1; - - var path = $.i18n._('/') + "media/images/expander-arrow-" + - (visible ? "show" : "hide") + ".gif" + "?v={{settings.MEDIA_RESOURCE_REVISION}}"; - arrow.attr("src", path); - $("#rev-body-" + id).slideToggle("fast"); - } - - </script> -{% endblock %} - -{% block content %} -<div id="main-bar" class="headNormal"> - {% trans "Revision history" %} [<a href="{{ post.get_absolute_url }}">{% trans "back" %}</a>] -</div> -<div id="main-body" class=""> - <div id="revisions"> - {% for revision in revisions %} - <div class="revision"> - <div id="rev-header-{{ revision.revision }}" class="header {% ifequal post.author_id revision.author_id %}author{% endifequal %}"> - <div class="header-controls"> - <table width="100%"> - <tr> - <td width="20" style="vertical-align:middle"><img id="rev-arrow-{{ revision.revision }}" - src="{% media "/images/expander-arrow-show.gif" %}" - alt="{% trans "click to hide/show revision" %}"/> - </td> - <td width="30px" style="vertical-align:middle"><span class="revision-number" title="{% trans "revision" %} {{ revision.revision }}">{{ revision.revision }}</span></td> - <td width="200px" style="vertical-align:middle"> - {% if revision.summary %} - <div class="summary"><span>{{ revision.summary }}</span></div> - {% endif %} - {% if request.user|can_edit_post:post %} - <a href="{% url edit_answer post.id %}?revision={{ revision.revision }}">{% trans "edit" %}</a> - {% endif %} - - </td> - <td align="right"> - <div class="revision-mark" > - {% post_contributor_info revision %} - </div> - </td> - </tr> - - </table> - </div> - </div> - <div id="rev-body-{{ revision.revision }}" class="answerbody"> - {{ revision.diff|safe }} - </div> - </div> - {% endfor %} - </div> -</div> -{% endblock %} - -{% block endjs %} -{% endblock %} -<!-- end revisions_answer.html --> diff --git a/askbot/skins/default/templates/tags.html b/askbot/skins/default/templates/tags.html index 6627db32..91184aa0 100644 --- a/askbot/skins/default/templates/tags.html +++ b/askbot/skins/default/templates/tags.html @@ -1,9 +1,7 @@ -{% extends "base.html" %} +{% extends "base.jinja.html" %} +{% import "macros.html" as macros %} <!-- tags.html --> -{% load i18n %} -{% load extra_tags %} -{% load humanize %} -{% block title %}{% spaceless %}{% trans "Tag list" %}{% endspaceless %}{% endblock %} +{% block title %}{% spaceless %}{% trans %}Tag list{% endtrans %}{% endspaceless %}{% endblock %} {% block forejs %} <script type="text/javascript"> /*<![CDATA[*/ @@ -27,19 +25,19 @@ {% block content %} <!-- Tabs --> <div class="tabBar"> - <div class="headUsers">{% trans "Tag list" %}</div> + <div class="headUsers">{% trans %}Tag list{% endtrans %}</div> <div class="tabsA"> - <a id="sort_name" href="{% url tags %}?sort=name" class="off" title="{% trans "sorted alphabetically" %}">{% trans "by name" %}</a> - <a id="sort_used" href="{% url tags %}?sort=used" class="off" title="{% trans "sorted by frequency of tag use" %}">{% trans "by popularity" %}</a> + <a id="sort_name" href="{% url tags %}?sort=name" class="off" title="{% trans %}sorted alphabetically{% endtrans %}">{% trans %}by name{% endtrans %}</a> + <a id="sort_used" href="{% url tags %}?sort=used" class="off" title="{% trans %}sorted by frequency of tag use{% endtrans %}">{% trans %}by popularity{% endtrans %}</a> </div> </div> <div id="searchtags"> <p> {% if stag %} - {% blocktrans %}All tags matching '<span class="darkred"><strong>{{ stag }}</strong></span>'{% endblocktrans %}: + {% trans %}All tags matching '<span class="darkred"><strong>{{ stag }}</strong></span>'{% endtrans %}: {% endif %} {% if not tags.object_list %} - <span>{% trans "Nothing found" %}</span> + <span>{% trans %}Nothing found{% endtrans %}</span> {% endif %} </p> {% if tags.object_list %} @@ -47,12 +45,11 @@ {% for tag in tags.object_list %} <li> <a href="{% url questions %}?tags={{tag|urlencode}}" - title="{% blocktrans %}see questions tagged '{{ tag }}'{% endblocktrans %}" rel="tag"> + title="{% trans %}see questions tagged '{{ tag }}'{% endtrans %}" rel="tag"> {{ tag }} </a> <span class="tag-number">× {{ tag.used_count|intcomma }}</span> <br/> - </li> {% endfor %} </ul> @@ -62,7 +59,7 @@ {% endblock %} {% block tail %} <div class="pager"> - {% cnprog_paginator context %} + {{macros.paginator(paginator_context)}} </div> {% endblock %} <!-- end tags.html --> diff --git a/askbot/skins/default/templates/user_edit.html b/askbot/skins/default/templates/user_edit.html index 01f2da9e..42a5e269 100644 --- a/askbot/skins/default/templates/user_edit.html +++ b/askbot/skins/default/templates/user_edit.html @@ -1,9 +1,7 @@ -{% extends "base_content.html" %} +{% extends "base_content.jinja.html" %} +{% import "macros.html" as macros %} <!-- user_edit.html --> -{% load extra_tags %} -{% load humanize %} -{% load i18n %} -{% block title %}{% spaceless %}{% trans "Edit user profile" %}{% endspaceless %}{% endblock %} +{% block title %}{% spaceless %}{% trans %}Edit user profile{% endtrans %}{% endspaceless %}{% endblock %} {% block forejs %} <script type="text/javascript"> $().ready(function(){ @@ -16,28 +14,27 @@ {% endblock %} {% block content %} <div id="main-bar" class="headNormal"> - {{ request.user.username }} - {% trans "edit profile" %} + {{ request.user.username }} - {% trans %}edit profile{% endtrans %} </div> <div id="main-body" style="width:100%;padding-top:10px"> <form name="" action="{% url edit_user request.user.id %}" method="post"> <div id="left" style="float:left;width:180px"> {% if request.user.email %} - {% gravatar request.user 128 %} + {{ macros.gravatar(request.user, 128) }} {% else %} - <img src="{% media "/images/nophoto.png" %}"> + <img src="{{"/images/nophoto.png"|media}}"> {% endif %} - <h1><a href="{% url faq %}#gravatar">change picture</a><h1> + <h1><a href="{% url faq %}#gravatar">{% trans %}change picture{% endtrans %}</a><h1> </div> - <div id="askform" style="float:right;width:750px;text-align:left;"> - <h2>{% trans "Registered user" %}</h2> + <h2>{% trans %}Registered user{% endtrans %}</h2> <table class="user-details"> <tr> <th width="100px"></th> <th></th> </tr> <tr style="height:35px"> - <td>{% trans "Screen Name" %}:</td> + <td>{% trans %}Screen Name{% endtrans %}:</td> <td> {% if settings.EDITABLE_SCREEN_NAME %} {{ form.username }} @@ -47,7 +44,7 @@ <span class="form-error"></span> {{ form.username.errors }} </td> </tr> <tr style="height:35px"> - <td>{{ form.email.label_tag }}:</td> + <td>{{ form.email.label_tag() }}:</td> <td>{{ form.email }} <span class="form-error"></span> {{ form.email.errors }} </td> </tr> <tr style="height:35px"> @@ -55,19 +52,19 @@ <td class="title-desc">{{ form.email.help_text }}</td> </tr> <tr style="height:35px"> - <td>{{ form.realname.label_tag }}:</td> + <td>{{ form.realname.label_tag() }}:</td> <td>{{ form.realname }} <span class="form-error"></span> {{ form.realname.errors }} </td> </tr> <tr style="height:35px"> - <td>{{ form.website.label_tag }}:</td> + <td>{{ form.website.label_tag() }}:</td> <td>{{ form.website }} <span class="form-error"></span> {{ form.website.errors }} </td> </tr> <tr style="height:35px"> - <td>{{ form.city.label_tag }}:</td> + <td>{{ form.city.label_tag() }}:</td> <td>{{ form.city }} <span class="form-error"></span> {{ form.city.errors }} </td> </tr> <tr style="height:35px"> - <td>{{ form.birthday.label_tag }}:</td> + <td>{{ form.birthday.label_tag() }}:</td> <td>{{ form.birthday }} <span class="form-error"></span> {{ form.birthday.errors }} </td> </tr> <tr style="height:35px"> @@ -79,18 +76,16 @@ </td> </tr> <tr> - <td style="vertical-align:top">{{ form.about.label_tag }}:</td> + <td style="vertical-align:top">{{ form.about.label_tag() }}:</td> <td>{{ form.about }} <span class="form-error"></span> {{ form.about.errors }} </td> </tr> - </table> <div style="margin:30px 0 60px 0"> - <input type="submit" value="{% trans "Update" %}" class="submit" > - <input id="cancel" type="button" value="{% trans "Cancel" %}" class="submit" > + <input type="submit" value="{% trans %}Update{% endtrans %}" class="submit" > + <input id="cancel" type="button" value="{% trans %}Cancel{% endtrans %}" class="submit" > </div> </div> </form> - </div> {% endblock %} <!-- end user_edit.html --> diff --git a/askbot/skins/default/templates/user_favorites.html b/askbot/skins/default/templates/user_favorites.html index 9db01e9a..458cd620 100644 --- a/askbot/skins/default/templates/user_favorites.html +++ b/askbot/skins/default/templates/user_favorites.html @@ -1,8 +1,6 @@ -{% extends "user.html" %} +{% extends "user.jinja.html" %} <!-- user_favorites.html --> -{% load extra_tags %} -{% load humanize %} {% block usercontent %} - {% include "users_questions.html" %} +{% include "users_questions.html" %} {% endblock %} <!-- end user_favorites.html --> diff --git a/askbot/skins/default/templates/user_info.html b/askbot/skins/default/templates/user_info.html index 4699cb18..7c8d4eac 100644 --- a/askbot/skins/default/templates/user_info.html +++ b/askbot/skins/default/templates/user_info.html @@ -1,41 +1,37 @@ <!-- user_info.html --> -{% load extra_tags %} -{% load extra_filters %} -{% load humanize %} -{% load smart_if %} -{% load i18n %} +{% import "macros.html" as macros %} <table class="user-info-table"> <tr> <td width="180" style="vertical-align:middle;text-align:center;"> <table width="100%"> <tr> <td> - {% gravatar view_user 128 %} + {{ macros.gravatar(view_user, 128) }} {% if request.user == view_user %} - <h1><a href="{% url faq %}#gravatar">{% trans "change picture" %}</a></h1> + <h1><a href="{% url faq %}#gravatar">{% trans %}change picture{% endtrans %}</a></h1> {% endif %} </td> </tr> <tr> <td align="center"> <div class="scoreNumber">{{view_user.reputation|intcomma}}</div> - <p><b style="color:#777;">{% trans "reputation" %}</b></p> + <p><b style="color:#777;">{% trans %}reputation{% endtrans %}</b></p> </td> </tr> </table> </td> <td width="360" style="vertical-align: top;"> <table class="user-details"> - {% if request.user|can_view_user_edit:view_user %} + {% if request.user|can_view_user_edit(view_user) %} <tr> <td class="user-profile-tool-links" align="left" colspan="2"> {% if request.user == view_user %} <a href="{% url user_signin %}?next={% url user_signin %}"> - {% trans "manage login methods" %} + {% trans %}manage login methods{% endtrans %} </a> | {% endif %} - <a href="{% url users %}{{ view_user.id }}/{% trans "edit/" %}"> - {% trans "update profile" %} + <a href="{% url edit_user view_user.id %}"> + {% trans %}update profile{% endtrans %} </a> </td> </tr> @@ -47,53 +43,55 @@ </tr> {% if view_user.real_name %} <tr> - <td>{% trans "real name" %}</td> + <td>{% trans %}real name{% endtrans %}</td> <td><b>{{view_user.real_name}}</b></td> </tr> {% endif %} <tr> - <td>{% trans "member for" %}</td> - <td><strong>{% diff_date view_user.date_joined %}</strong></td> + <td>{% trans %}member for{% endtrans %}</td> + <td><strong>{{ view_user.date_joined|diff_date }}</strong></td> </tr> {% if view_user.last_seen %} <tr> - <td>{% trans "last seen" %}</td> - <td><strong title="{{ view_user.last_seen }}">{% diff_date view_user.last_seen %}</strong></td> + <td>{% trans %}last seen{% endtrans %}</td> + <td><strong title="{{ view_user.last_seen }}">{{view_user.last_seen|diff_date}}</strong></td> </tr> {% endif %} {% if view_user.website %} <tr> - <td>{% trans "user website" %}</td> + <td>{% trans %}user website{% endtrans %}</td> <td><a rel="nofollow" target="_blank" href="{{view_user.website}}">{{view_user.website}}</a></td> </tr> {% endif %} {% if view_user.location %} <tr> - <td>{% trans "location" %}</td> + <td>{% trans %}location{% endtrans %}</td> <td>{{view_user.location}}</td> </tr> {% endif %} {% if view_user.date_of_birth%} <tr> - <!--todo - redo this with blocktrans --> - <td>{% trans "age" %}</td> - <td>{% get_age view_user.date_of_birth %} {% trans "age unit" %}</td> + <!--todo - redo this with whole sentence translation --> + <td>{% trans %}age{% endtrans %}</td> + <td>{{view_user.date_of_birth|get_age}} {% trans %}age unit{% endtrans %}</td> </tr> {% endif %} - <!-- + {# + <!-- {% if votes_today_left %} <tr> <td>{% trans "todays unused votes" %}</td> <td><strong class="darkred">{{ votes_today_left }}</strong> {% trans "votes left" %}</td> </tr> {% endif %} - --> + --> + #} </table> </td> <td width="380"> <div class="user-about"> {% if view_user.about %} - {{view_user.about|safe|linebreaks}} + {{view_user.about|linebreaks}} {% endif %} </div> </td> diff --git a/askbot/skins/default/templates/user_moderate.html b/askbot/skins/default/templates/user_moderate.html index 5edff0c2..168fe661 100644 --- a/askbot/skins/default/templates/user_moderate.html +++ b/askbot/skins/default/templates/user_moderate.html @@ -1,65 +1,63 @@ -{% extends "user.html" %} +{% extends "user.jinja.html" %} <!-- user_moderate.html --> -{% load i18n %} -{% load smart_if %} {% block usercontent %} {% if request.user != view_user %} - <h3>{% blocktrans with view_user.username as username and view_user.get_status_display as status %}{{username}}'s current status is "{{status}}"{% endblocktrans %} + <h3>{% trans username=view_user.username, status=view_user.get_status_display() %}{{username}}'s current status is "{{status}}"{% endtrans %} </h3> {% if user_status_changed %} - <p class="action-status"><span>{% trans "User status changed" %}</span></p> + <p class="action-status"><span>{% trans %}User status changed{% endtrans %}</span></p> {% endif %} <form method="post"> <input type="hidden" name="sort" value="moderate"/> <table class="form-as-table"> - {{ change_user_status_form.as_table }} + {{ change_user_status_form.as_table() }} </table> - <input type="submit" class="submit" name="change_status" value="{% trans "Save" %}" /> + <input type="submit" class="submit" name="change_status" value="{% trans %}Save{% endtrans %}" /> </form> {% endif %} <hr/> <h3> {% if request.user == view_user %} - {% blocktrans with view_user.reputation as reputation %}Your current reputation is {{reputation}} points{% endblocktrans %} + {% trans reputation=view_user.reputation %}Your current reputation is {{reputation}} points{% endtrans %} {% else %} - {% blocktrans with view_user.reputation as reputation %}User's current reputation is {{reputation}} points{% endblocktrans %} + {% trans reputation=view_user.reputation %}User's current reputation is {{reputation}} points{% endtrans %} {% endif %} </h3> {% if user_rep_changed %} - <p class="action-status"><span>{% trans "User reputation changed" %}</span></p> + <p class="action-status"><span>{% trans %}User reputation changed{% endtrans %}</span></p> {% endif %} <form method="post"> <input type="hidden" name="sort" value="moderate"/> <table class="form-as-table"> - {{ change_user_reputation_form.as_table }} + {{ change_user_reputation_form.as_table() }} </table> - <input type="submit" class="submit" name="subtract_reputation" value="{% trans "Subtract" %}" /> - <input type="submit" class="submit" name="add_reputation" value="{% trans "Add" %}" /> + <input type="submit" class="submit" name="subtract_reputation" value="{% trans %}Subtract{% endtrans %}" /> + <input type="submit" class="submit" name="add_reputation" value="{% trans %}Add{% endtrans %}" /> </form> {% if request.user != view_user %} <hr/> -<h3>{% blocktrans with view_user.username as username %}Send message to {{username}}{% endblocktrans %}</h3> -<p>{% trans "An email will be sent to the user with 'reply-to' field set to your email address. Please make sure that your address is entered correctly." %}</p> +<h3>{% trans username=view_user.username %}Send message to {{username}}{% endtrans %}</h3> +<p>{% trans %}An email will be sent to the user with 'reply-to' field set to your email address. Please make sure that your address is entered correctly.{% endtrans %}</p> {% if message_sent %} - <p class="action-status"><span>{% trans "Message sent" %}</span></p> + <p class="action-status"><span>{% trans %}Message sent{% endtrans %}</span></p> {% endif %} <form method="post"> <input type="hidden" name="sort" value="moderate"/> <div class="form-row-vertical"> <label for="id_subject_line">{{ send_message_form.subject_line.label}}</label> {% if send_message_form.subject_line.errors %} - <p class="error">{{send_message_form.subject_line.errors|join:', '}}</p> + <p class="error">{{send_message_form.subject_line.errors|join(', ')}}</p> {% endif %} {{ send_message_form.subject_line}} </div> <div class="form-row-vertical"> <label for="id_body_text">{{ send_message_form.body_text.label}}</label> {% if send_message_form.body_text.errors %} - <p class="error">{{send_message_form.body_text.errors|join:', '}}</p> + <p class="error">{{send_message_form.body_text.errors|join(', ')}}</p> {% endif %} {{ send_message_form.body_text}} </div> - <input type="submit" class="submit" name="send_message" value="{% trans "Send message" %}" /> + <input type="submit" class="submit" name="send_message" value="{% trans %}Send message{% endtrans %}" /> </form> {% endif %} {% endblock %} diff --git a/askbot/skins/default/templates/user_recent.html b/askbot/skins/default/templates/user_recent.html index 78347993..e6cde5ed 100644 --- a/askbot/skins/default/templates/user_recent.html +++ b/askbot/skins/default/templates/user_recent.html @@ -1,23 +1,20 @@ -{% extends "user.html" %} +{% extends "user.jinja.html" %} <!-- user_recent.html --> -{% load extra_tags %} -{% load humanize %} -{% load i18n %} {% block usercontent %} <div style="padding-top:5px;font-size:13px;"> {% for act in activities %} <div style="clear:both;line-height:20px" > - <div style="width:180px;float:left">{% diff_date act.time 3 %}</div> + <div style="width:180px;float:left">{{ act.time|diff_date(3) }}</div> <div style="width:150px;float:left"> <span class="user-action-{{ act.type_id }}">{{ act.type }}</span> </div> <div style="float:left;overflow:hidden;"> - {% ifequal act.type_id 7 %} - <a href="{{act.badge.get_absolute_url}}" title="{{ act.badge.get_type_display }} : {% trans act.badge.description %}" class="medal"><span class="badge{{ act.badge.type }}">●</span> {% trans act.badge.name %}</a> + {% if act.type_id==7 %} + <a href="{{act.badge.get_absolute_url()}}" title="{{ act.badge.get_type_display() }} : {% trans description=act.badge.description %}{{description}}{% endtrans %}" class="medal"><span class="badge{{ act.badge.type }}">●</span> {% trans name=act.badge.name %}{{name}}{% endtrans %}</a> {% else %} - <span class="post-type-{{ act.type_id }}"><a href="{{ act.title_link }}">{{ act.title }}</a></span> - {% if act.summary %}<span class="revision-summary">{{ act.summary }}</span>{% endif %} - {% endifequal %} + <span class="post-type-{{ act.type_id }}"><a href="{{ act.title_link }}">{{ act.title|escape }}</a></span> + {% if act.summary %}<span class="revision-summary">{{ act.summary|escape }}</span>{% endif %} + {% endif %} <div style="height:5px"></div> </div> </div> diff --git a/askbot/skins/default/templates/user_reputation.html b/askbot/skins/default/templates/user_reputation.html index e7eff2ee..3dd6e014 100644 --- a/askbot/skins/default/templates/user_reputation.html +++ b/askbot/skins/default/templates/user_reputation.html @@ -1,14 +1,8 @@ -{% extends "user.html" %} +{% extends "user.jinja.html" %} <!-- user_reputation.html --> -{% load extra_tags %} -{% load extra_filters %} -{% load humanize %} -{% load i18n %} -{% load smart_if %} {% block userjs %} - <script type='text/javascript' src='{% media "/js/excanvas.min.js" %}'></script> - <script type='text/javascript' src='{% media "/js/jquery.flot.min.js" %}'></script> - + <script type='text/javascript' src='{{"/js/excanvas.min.js"|media}}'></script> + <script type='text/javascript' src='{{"/js/jquery.flot.min.js"|media}}'></script> <script type="text/javascript"> $().ready(function(){ var d = {{ reps }}; @@ -19,24 +13,23 @@ lines: { show: true } }); }); - </script> {% endblock %} {% block usercontent %} <div class="karma-summary"> <div id="diagram" class="karma-diagram"></div> {% if view_user.id == user.id %} - <h3>{% trans "Your karma change log." %}</h3> + <h3>{% trans %}Your karma change log.{% endtrans %}</h3> {% else %} - <h3>{% blocktrans with view_user.username as user_name %}{{user_name}}'s karma change log{% endblocktrans %}</h3> + <h3>{% trans user_name=view_user.username %}{{user_name}}'s karma change log{% endtrans %}</h3> {% endif %} <div class="karma-details"> {% for rep in reputation %} <p> <span class="karma-gained">{{ rep.positive }}</span> <span class="karma-lost">{{ rep.negative }}</span> - {{ rep.get_explanation_snippet|safe }} - <span class="small">({% diff_date rep.reputed_at %})</span> + {{ rep.get_explanation_snippet() }} + <span class="small">({{rep.reputed_at|diff_date}})</span> </p> {% endfor %} </div> diff --git a/askbot/skins/default/templates/user_responses.html b/askbot/skins/default/templates/user_responses.html index 2d96112b..432a74c7 100644 --- a/askbot/skins/default/templates/user_responses.html +++ b/askbot/skins/default/templates/user_responses.html @@ -1,7 +1,8 @@ -{% extends "user.html" %} +{% extends "user.jinja.html" %} +{% import "macros.html" as macros %} <!-- user_responses.html --> -{% comment %} +{# This template accepts a list of response list they are a generalized form of any response and @@ -12,11 +13,7 @@ response_type - type of response response_url - link to the question response_title - title of the question response_snippet - abbreviated content of the response -{% endcomment %} - -{% load extra_tags %} -{% load humanize %} -{% load i18n %} +#} {% block usercontent %} <div style="padding-top:5px;font-size:13px;"> @@ -24,14 +21,14 @@ response_snippet - abbreviated content of the response <div style="clear:both;line-height:18px;margin-bottom:15px;"> <div> <div style="float:left; display:inline-block; text-align: center; width: 54px; padding: 3px;overflow:hidden;"> - {% gravatar response.user 48 %} + {{ macros.gravatar(response.user, 48) }} </div> - <a style="font-size:12px" href="{{ response.user.get_absolute_url }}">{{ response.user.username }}</a> + <a style="font-size:12px" href="{{ response.user.get_absolute_url() }}">{{ response.user.username }}</a> <a style="text-decoration:none;" href="{{ response.response_url }}"> {{ response.response_type }} - ({% diff_date response.timestamp 3 "True" %}):<br/> - <strong>"{{ response.response_title }}"</strong> - {{ response.response_snippet|safe }} + ({{ response.timestamp|diff_date(3, True) }}):<br/> + <strong>"{{ response.response_title|escape}}"</strong> + {{ response.response_snippet }} </a> </div> </div> diff --git a/askbot/skins/default/templates/user_stats.html b/askbot/skins/default/templates/user_stats.html index 23d8ddb8..67d9a4d2 100644 --- a/askbot/skins/default/templates/user_stats.html +++ b/askbot/skins/default/templates/user_stats.html @@ -1,19 +1,15 @@ -{% extends "user.html" %} +{% extends "user.jinja.html" %} <!-- user_stats.html --> -{% load i18n %} -{% load extra_tags %} -{% load extra_filters %} -{% load humanize %} {% block usercontent %} {% include "user_info.html" %} <a name="questions"></a> {% spaceless %} - <h2>{% blocktrans count questions|length as counter %}<span class="count">{{counter}}</span> Question{% plural %}<span class="count">{{counter}}</span> Questions{% endblocktrans %}</h2> + <h2>{% trans counter=questions|length %}<span class="count">{{counter}}</span> Question{% pluralize %}<span class="count">{{counter}}</span> Questions{% endtrans %}</h2> {% endspaceless %} {% include "users_questions.html" %} <a name="answers"></a> {% spaceless %} - <h2>{% blocktrans count answered_questions|length as counter %}<span class="count">{{counter}}</span> Answer{% plural %}<span class="count">{{counter}}</span> Answers{% endblocktrans %}</h2> + <h2>{% trans counter=answered_questions|length %}<span class="count">{{counter}}</span> Answer{% pluralize %}<span class="count">{{counter}}</span> Answers{% endtrans %}</h2> {% endspaceless %} <div class="user-stats-table"> {% for answered_question in answered_questions %} @@ -21,7 +17,7 @@ <a title="{{answered_question.summary|collapse}}" href="{% url question answered_question.id %}{{answered_question.title|slugify}}#{{answered_question.answer_id}}"> <span class="answer-votes {% if answered_question.accepted %}answered-accepted{% endif %}" - title="{% blocktrans with answered_question.answer_score as answer_score %}the answer has been voted for {{ answer_score }} times{% endblocktrans %} {% if answered_question.accepted %}{% trans "this answer has been selected as correct" %}{%endif%}"> + title="{% trans answer_score=answered_question.answer_score %}the answer has been voted for {{ answer_score }} times{% endtrans %} {% if answered_question.accepted %}{% trans %}this answer has been selected as correct{% endtrans %}{%endif%}"> {{ answered_question.answer_score }} </span> </a> @@ -31,7 +27,7 @@ {% endspaceless %} {% if answered_question.comment_count %} <span> - {% blocktrans count answered_question.comment_count as comment_count %}({{comment_count}} comment){% plural %}the answer has been commented {{comment_count}} times{% endblocktrans %} + {% trans comment_count=answered_question.comment_count %}({{comment_count}} comment){% pluralize %}the answer has been commented {{comment_count}} times{% endtrans %} </span> {% endif %} </div> @@ -41,19 +37,18 @@ <br/> <a name="votes"></a> {% spaceless %} - <h2>{% blocktrans count total_votes as cnt %}<span class="count">{{cnt}}</span> Vote{% plural %}<span class="count">{{cnt}}</span> Votes {% endblocktrans %}</h2> + <h2>{% trans cnt=total_votes %}<span class="count">{{cnt}}</span> Vote{% pluralize %}<span class="count">{{cnt}}</span> Votes {% endtrans %}</h2> {% endspaceless %} <div class="user-stats-table"> <table> <tr> <td width="60"> - <img style="cursor: default;" src="{% media "/images/vote-arrow-up-on.png" %}" alt="{% trans "thumb up" %}" /> - <span title="{% trans "user has voted up this many times" %}" class="vote-count">{{up_votes}}</span> - + <img style="cursor: default;" src="{{"/images/vote-arrow-up-on.png"|media}}" alt="{% trans %}thumb up{% endtrans %}" /> + <span title="{% trans %}user has voted up this many times{% endtrans %}" class="vote-count">{{up_votes}}</span> </td> <td width="60"> - <img style="cursor: default;" src="{% media "/images/vote-arrow-down-on.png" %}" alt="{% trans "thumb down" %}" /> - <span title="{% trans "user voted down this many times" %}" class="vote-count">{{down_votes}}</span> + <img style="cursor: default;" src="{{"/images/vote-arrow-down-on.png"|media}}" alt="{% trans %}thumb down{% endtrans %}" /> + <span title="{% trans %}user voted down this many times{% endtrans %}" class="vote-count">{{down_votes}}</span> </td> </tr> @@ -61,18 +56,18 @@ </div> <a name="tags"></a> {% spaceless %} - <h2>{% blocktrans count user_tags|length as counter %}<span class="count">{{counter}}</span> Tag{% plural %}<span class="count">{{counter}}</span> Tags{% endblocktrans %}</h2> + <h2>{% trans counter=user_tags|length %}<span class="count">{{counter}}</span> Tag{% pluralize %}<span class="count">{{counter}}</span> Tags{% endtrans %}</h2> {% endspaceless %} <div class="user-stats-table"> <table class="tags"> <tr> <td width="180" valign="top"> - {% for tag in user_tags%} + {% for tag in user_tags %} <a rel="tag" - title="{% blocktrans with tag.name as tag_name %}see other questions with {{view_user}}'s contributions tagged '{{ tag_name }}' {% endblocktrans %}" + title="{% trans tag_name=tag.name %}see other questions with {{view_user}}'s contributions tagged '{{ tag_name }}' {% endtrans %}" href="{% url questions %}?tags={{tag|urlencode}}&author={{view_user.id}}&start_over=true">{{tag.name}}</a> <span class="tag-number">× {{ tag.user_tag_usage_count|intcomma }}</span><br/> - {% if forloop.counter|divisibleby:"10" %} + {% if loop.index is divisibleby 10 %} </td> <td width="180" valign="top"> {% endif %} @@ -83,15 +78,15 @@ </div> <a name="badges"></a> {% spaceless %} - <h2>{% blocktrans count total_awards as counter %}<span class="count">{{counter}}</span> Badge{% plural %}<span class="count">{{counter}}</span> Badges{% endblocktrans %}</h2> + <h2>{% trans counter=total_awards %}<span class="count">{{counter}}</span> Badge{% pluralize %}<span class="count">{{counter}}</span> Badges{% endtrans %}</h2> {% endspaceless %} <div class="user-stats-table"> <table> <tr> <td width="180" style="line-height:35px"> - {% for award in awards %}{% comment %}todo: translate badge name properly{% endcomment %} - <a href="{% url badge award.id %}{{award.name}}" title="{% trans award.description %}" class="medal"><span class="badge{{ award.type }}">●</span> {% trans award.name %}</a><span class="tag-number"> × {{ award.count|intcomma }}</span><br/> - {% if forloop.counter|divisibleby:"6" %} + {% for award in awards %}{# todo: translate badge name properly #} + <a href="{% url badge award.id %}{{award.name}}" title="{% trans description=award.description %}{{description}}{% endtrans %}" class="medal"><span class="badge{{ award.type }}">●</span> {% trans name=award.name %}{{name}}{% endtrans %}</a><span class="tag-number"> × {{ award.count|intcomma }}</span><br/> + {% if loop.index is divisibleby 3 %} </td> <td width="180" style="line-height:35px"> {% endif %} diff --git a/askbot/skins/default/templates/user_votes.html b/askbot/skins/default/templates/user_votes.html index 5a8f9316..9b738cd9 100644 --- a/askbot/skins/default/templates/user_votes.html +++ b/askbot/skins/default/templates/user_votes.html @@ -1,30 +1,25 @@ -{% extends "user.html" %} +{% extends "user.jinja.html" %} <!-- user_votes.html --> -{% load extra_tags %} -{% load extra_filters %} -{% load humanize %} -{% load i18n %} - {% block usercontent %} <div style="padding-top:5px;font-size:13px;"> {% for vote in votes %} <div style="clear:both;line-height:20px" > - <div style="width:150px;float:left">{% diff_date vote.voted_at 3 %}</div> + <div style="width:150px;float:left">{{vote.voted_at|diff_date(3)}}</div> <div style="width:30px;float:left"> - {% ifequal vote.vote 1 %} - <img src="{% media "/images/vote-arrow-up-on.png" %}" title="{% trans "upvote" %}"> + {% if vote.vote==1 %} + <img src="{{"/images/vote-arrow-up-on.png"|media}}" title="{% trans %}upvote{% endtrans %}"> {% else %} - <img src="{% media "/images/vote-arrow-down-on.png" %}" title="{% trans "downvote" %}"> - {% endifequal %} + <img src="{{"/images/vote-arrow-down-on.png"|media}}" title="{% trans %}downvote{% endtrans %}"> + {% endif %} </div> <div style="float:left;overflow:hidden;width:750px"> - {% ifequal vote.answer_id 0 %} - <span class="question-title-link"><a href="{% url question vote.question_id %}{{ vote.title|slugify }}">{{ vote.title }}</a></span> + {% if vote.answer_id==0 %} + <span class="question-title-link"><a href="{% url question vote.question_id %}{{ vote.title|slugify }}">{{ vote.title|escape }}</a></span> {% else %} - <span class="answer-title-link" ><a href="{% url question vote.question_id %}{{ vote.title|slugify }}#{{ vote.answer_id }}">{{ vote.title }}</a></span> - {% endifequal %} + <span class="answer-title-link" ><a href="{% url question vote.question_id %}{{ vote.title|slugify }}#{{ vote.answer_id }}">{{ vote.title|escape}}</a></span> + {% endif %} <div style="height:5px"></div> - </div> + </div> </div> {% endfor %} </div> diff --git a/askbot/skins/default/templates/users.html b/askbot/skins/default/templates/users.html index f3ccd6e9..61ac7b57 100644 --- a/askbot/skins/default/templates/users.html +++ b/askbot/skins/default/templates/users.html @@ -1,12 +1,10 @@ -{% extends "base.html" %} +{% extends "base.jinja.html" %} +{% import "macros.html" as macros %} <!-- users.html --> -{% load extra_tags %} -{% load humanize %} -{% load i18n %} -{% block title %}{% spaceless %}{% trans "Users" %}{% endspaceless %}{% endblock %} +{% block title %}{% spaceless %}{% trans %}Users{% endtrans %}{% endspaceless %}{% endblock %} {% block forejs %} <script type="text/javascript"> - //todo move javascript out + //todo move javascript out $().ready(function(){ $("#nav_users").attr('className',"on"); $("#type-user").attr('checked',true); @@ -21,43 +19,40 @@ {% endblock %} {% block content %} <div class="tabBar"> - <div class="headUsers">{% trans "Users" %}</div> + <div class="headUsers">{% trans %}Users{% endtrans %}</div> <div class="tabsA"> - <a id="sort_reputation" href="{% url users %}?sort=reputation" class="off" title="{% trans "reputation" %}">{% trans "reputation" %}</a> - <a id="sort_newest" href="{% url users %}?sort=newest" class="off" title="{% trans "recent" %}">{% trans "recent" %}</a> - <a id="sort_last" href="{% url users %}?sort=last" class="off" title="{% trans "oldest" %}">{% trans "oldest" %}</a> - <a id="sort_user" href="{% url users %}?sort=user" class="off" title="{% trans "by username" %}">{% trans "by username" %}</a> + <a id="sort_reputation" href="{% url users %}?sort=reputation" class="off" title="{% trans %}reputation{% endtrans %}">{% trans %}reputation{% endtrans %}</a> + <a id="sort_newest" href="{% url users %}?sort=newest" class="off" title="{% trans %}recent{% endtrans %}">{% trans %}recent{% endtrans %}</a> + <a id="sort_last" href="{% url users %}?sort=last" class="off" title="{% trans %}oldest{% endtrans %}">{% trans %}oldest{% endtrans %}</a> + <a id="sort_user" href="{% url users %}?sort=user" class="off" title="{% trans %}by username{% endtrans %}">{% trans %}by username{% endtrans %}</a> </div> </div> <div id="main-body" style="width:100%"> - <p> + <p> {% if suser %} - {% blocktrans %}users matching query {{suser}}:{% endblocktrans %} + {% trans %}users matching query {{suser}}:{% endtrans %} {% endif %} - {% if not users.object_list %} - <span>{% trans "Nothing found." %}</span> + <span>{% trans %}Nothing found.{% endtrans %}</span> {% endif %} </p> <div class="userList"> <table class="list-table"> - <tr> + <tr> <td class="list-td"> {% for user in users.object_list %} - <div class="user"> <ul> - <li class="thumb">{% gravatar user 32 %}</li> - <li><a href="{% url user_profile user.id user.username|slugify %}">{{user.username}}</a></li> - <li>{% get_score_badge user %}</li> + <li class="thumb">{{ macros.gravatar(user, 32) }}</li> + <li><a href="{% url user_profile user.id, user.username|slugify %}">{{user.username}}</a></li> + <li>{{ macros.user_score_and_badge_summary(user) }}</li> </ul> </div> - {% if forloop.counter|divisibleby:"7" %} + {% if loop.index is divisibleby 7 %} </td> <td> {% endif %} - {% endfor %} </td> </tr> @@ -67,7 +62,7 @@ {% endblock %} {% block tail %} <div class="pager"> - {% cnprog_paginator context %} + {{ macros.paginator(paginator_context) }} </div> {% endblock %} <!-- end users.html --> diff --git a/askbot/skins/default/templates/users_questions.html b/askbot/skins/default/templates/users_questions.html index 074bd60c..4ef829a0 100644 --- a/askbot/skins/default/templates/users_questions.html +++ b/askbot/skins/default/templates/users_questions.html @@ -1,25 +1,22 @@ <!-- users_questions.html --> -{% load extra_tags %} -{% load extra_filters %} -{% load humanize %} -{% load i18n %} +{% import "macros.html" as macros %} <div class="user-stats-table"> {% for question in questions %} {% if question.favourite_count %} {% if question.favorited_myself %} <div class="favorites-count"> <img - title="{% blocktrans count question.favorite_count as cnt %}this questions was selected as favorite {{question.favourite_count}} time{% plural %}this questions was selected as favorite {{cnt}} times{% endblocktrans %}" - alt="{% trans "thumb-up on" %}" - src="{% media "/images/vote-favorite-on.png" %}"/> + title="{% trans cnt=question.favorite_count %}this questions was selected as favorite {{cnt}} time{% pluralize %}this questions was selected as favorite {{cnt}} times{% endtrans %}" + alt="{% trans %}thumb-up on{% endtrans %}" + src="{{"/images/vote-favorite-on.png"|media}}"/> <div><b>{{question.favourite_count|intcomma}}</b></div> </div> {% else %} <div class="favorites-count-off"> <img - title="{% blocktrans count question.favorite_count as cnt %}this questions was selected as favorite {{question.favourite_count}} time{% plural %}this questions was selected as favorite {{cnt}} times{% endblocktrans %}" - alt="{% trans "thumb-up off" %}" - src="{% media "/images/vote-favorite-off.png" %}"/> + title="{% trans cnt=question.favorite_count %}this questions was selected as favorite {{cnt}} time{% pluralize %}this questions was selected as favorite {{cnt}} times{% endtrans %}" + alt="{% trans %}thumb-up off{% endtrans %}" + src="{{"/images/vote-favorite-off.png"|media}}"/> <div><b>{{question.favourite_count|intcomma}}</b></div> </div> {% endif %} @@ -34,16 +31,16 @@ style="background:{{settings.COLORS_VOTE_COUNTER_MIN_BG}};color:{{settings.COLORS_VOTE_COUNTER_MIN_FG}}" >{{question.score|humanize_counter}}</span> <div> - {% blocktrans count question.score as cnt %} + {% trans cnt=question.score %} vote - {% plural %} + {% pluralize %} votes - {% endblocktrans %} + {% endtrans %} </div> </div > - {% comment %} - <div {% if question.answer_accepted %}title="{% trans "this answer has been accepted to be correct" %}"{% endif %} class="status {% if question.answer_accepted %}answered-accepted{% endif %} {% ifequal question.answer_count 0 %}unanswered{% endifequal %}{% ifnotequal question.answer_count 0 %}answered{% endifnotequal %}"> - {% endcomment %} + {# + <div {% if question.answer_accepted %}title="{% trans %}this answer has been accepted to be correct{% endtrans %}"{% endif %} class="status {% if question.answer_accepted %}answered-accepted{% endif %} {% if question.answer_count==0 %}unanswered{% endif %}{% if question.answer_count!=0 %}answered{% endif %}"> + #} <div class="votes"> <span class="item-count" @@ -54,11 +51,11 @@ {% endif %} >{{question.answer_count|humanize_counter}}</span> <div> - {% blocktrans count question.answer_count as cnt %} + {% trans cnt=question.answer_count %} answer - {% plural %} + {% pluralize %} answers - {% endblocktrans %} + {% endtrans %} </div> </div> <div class="votes"> @@ -66,26 +63,36 @@ style="background:{{settings.COLORS_VIEW_COUNTER_MIN_BG}};color:{{settings.COLORS_VIEW_COUNTER_MIN_FG}}" >{{question.view_count|humanize_counter}}</span> <div> - {% blocktrans count question.view_count as cnt %} + {% trans cnt=question.view_count %} view - {% plural %} + {% pluralize %} views - {% endblocktrans %} + {% endtrans %} </div> </div> </div> - <h2><a title="{{question.summary}}" href="{% url question id=question.id %}{{question.title|slugify}}">{{question.title}}</a></h2> + <h2><a title="{{question.summary|escape}}" href="{% url question id=question.id %}{{question.title|slugify}}">{{question.title|escape}}</a></h2> <div class="tags"> - {% convert2tagname_list question %} - {% for tag in question.tagnames %} - <!--todo - move trans below to blocktrans --> - <a href="{% url questions %}?tags={{tag|urlencode}}" title="{% blocktrans %}see questions tagged '{{ tag }}'{% endblocktrans %}" rel="tag">{{ tag }}</a> + {% for tag in question.tagnames|split(' ') %} + <!--todo - move trans below to trans --> + <a href="{% url questions %}?tags={{tag|urlencode}}" title="{% trans %}see questions tagged '{{ tag }}'{% endtrans %}" rel="tag">{{ tag }}</a> {% endfor %} </div> <div class="started"> - <span class="relativetime" title="{{question.last_activity_at}}">{% diff_date question.last_activity_at %}</span> + <span class="relativetime" title="{{question.last_activity_at}}">{{question.last_activity_at|diff_date}}</span> {% if question.la_username %} - <a href="{% url users %}{{question.la_user_id}}/{{question.la_username}}">{{question.la_username}}</a> {% get_score_badge_by_details question.la_user_reputation question.la_user_gold question.la_user_silver question.la_user_bronze%} + <a + href="{% url users %}{{question.la_user_id}}/{{question.la_username}}" + >{{question.la_username}}</a> + {{ macros.user_score_and_badge_summary( + { + 'reputation': question.la_user_reputaion, + 'gold': question.la_user_gold, + 'silver': question.la_user_silver, + 'bronze': question.la_user_bronze, + } + ) + }} {% endif %} </div> </div> diff --git a/askbot/templatetags/extra_filters_jinja.py b/askbot/templatetags/extra_filters_jinja.py index 8fd44ab2..70fd6650 100644 --- a/askbot/templatetags/extra_filters_jinja.py +++ b/askbot/templatetags/extra_filters_jinja.py @@ -1,4 +1,6 @@ import logging +import datetime +import time from coffin import template as coffin_template from django.core import exceptions as django_exceptions from django.utils.translation import ugettext as _ @@ -21,6 +23,19 @@ def collapse(input): return ' '.join(input.split()) @register.filter +def split(string, separator): + return string.split(separator) + +@register.filter +def get_age(birthday): + current_time = datetime.datetime(*time.localtime()[0:6]) + year = birthday.year + month = birthday.month + day = birthday.day + diff = current_time - datetime.datetime(year,month,day,0,0,0) + return diff.days / 365 + +@register.filter def media(url): """media filter - same as media tag, but to be used as a filter in jinja templates @@ -57,6 +72,12 @@ register.filter( ) register.filter( + name = 'linebreaks', + filter_func = defaultfilters.linebreaks, + jinja2_only = True + ) + +register.filter( name = 'default_if_none', filter_func = defaultfilters.default_if_none, jinja2_only = True diff --git a/askbot/templatetags/extra_tags.py b/askbot/templatetags/extra_tags.py index 085701e3..c39bfe5c 100644 --- a/askbot/templatetags/extra_tags.py +++ b/askbot/templatetags/extra_tags.py @@ -124,18 +124,6 @@ def cnprog_paginator(context): "extend_url" : extend_url } -@register.inclusion_tag("pagesize.html") -def cnprog_pagesize(context): - """ - display the pagesize selection boxes for paginator - """ - if (context["is_paginated"]): - return { - "base_url": context["base_url"], - "page_size" : context["page_size"], - "is_paginated": context["is_paginated"] - } - @register.inclusion_tag("post_contributor_info.html") def post_contributor_info(post,contributor_type='original_author'): """contributor_type: original_author|last_updater @@ -268,15 +256,6 @@ def get_user_vote_image(dic, key, arrow): return '' @register.simple_tag -def get_age(birthday): - current_time = datetime.datetime(*time.localtime()[0:6]) - year = birthday.year - month = birthday.month - day = birthday.day - diff = current_time - datetime.datetime(year,month,day,0,0,0) - return diff.days / 365 - -@register.simple_tag def get_total_count(up_count, down_count): return up_count + down_count @@ -297,11 +276,6 @@ def format_number(value): m = re.match(pattern, strValue) return first + result -@register.simple_tag -def convert2tagname_list(question): - question['tagnames'] = [name for name in question['tagnames'].split(u' ')] - return '' - diff_date = register.simple_tag(functions.diff_date) @register.simple_tag diff --git a/askbot/tests/email_alert_tests.py b/askbot/tests/email_alert_tests.py index c54f8ad2..416cab06 100644 --- a/askbot/tests/email_alert_tests.py +++ b/askbot/tests/email_alert_tests.py @@ -705,7 +705,7 @@ class FeedbackTests(utils.AskbotTestCase): } response = client.post(reverse('feedback'), data) self.assertEquals(response.status_code, 200) - self.assertEquals(response.template[0].name, 'feedback.html') + self.assertEquals(response.template.name, 'feedback.html') def test_mail_moderators(self): """tests askbot.mail_moderators() diff --git a/askbot/tests/page_load_tests.py b/askbot/tests/page_load_tests.py index ee5d304f..bcdfa199 100644 --- a/askbot/tests/page_load_tests.py +++ b/askbot/tests/page_load_tests.py @@ -57,7 +57,7 @@ class PageLoadTests(PageLoadTestCase): self.assertEqual(response.status_code, 200) self.failUnless(len(response.redirect_chain) == 1) self.failUnless(response.redirect_chain[0][0].endswith('/questions/')) - self.assertEquals(response.template.name, 'questions.jinja.html') + self.assertEquals(response.template.name, 'questions.html') def proto_test_non_user_urls(self): """test all reader views thoroughly @@ -66,7 +66,7 @@ class PageLoadTests(PageLoadTestCase): self.try_url('sitemap') self.try_url('feeds', kwargs={'url':'rss'}) - self.try_url('about', template='about.html') + self.try_url('about', template='about.jinja.html') self.try_url('privacy', template='privacy.html') self.try_url('logout', template='logout.html') self.try_url('user_signin', template='authopenid/signin.html') @@ -77,73 +77,73 @@ class PageLoadTests(PageLoadTestCase): self.try_url('badges', template='badges.html') self.try_url( 'answer_revisions', - template='revisions_answer.html', + template='revisions.html', kwargs={'id':38} ) #todo: test different sort methods and scopes self.try_url( 'questions', - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'start_over':'true'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'scope':'unanswered'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'scope':'all'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'scope':'favorite'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'scope':'unanswered', 'sort':'latest'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'scope':'unanswered', 'sort':'oldest'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'scope':'unanswered', 'sort':'active'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'scope':'unanswered', 'sort':'inactive'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'sort':'hottest'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'sort':'coldest'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'sort':'mostvoted'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'questions', data={'sort':'leastvoted'}, - template='questions.jinja.html' + template='questions.html' ) self.try_url( 'question', @@ -166,7 +166,7 @@ class PageLoadTests(PageLoadTestCase): self.try_url( 'question_revisions', kwargs={'id':17}, - template='revisions_question.html' + template='revisions.html' ) self.try_url('users', template='users.html') #todo: really odd naming conventions for sort methods diff --git a/askbot/urls.py b/askbot/urls.py index 52a4e647..c8c1185e 100644 --- a/askbot/urls.py +++ b/askbot/urls.py @@ -56,7 +56,8 @@ urlpatterns = patterns('', ), url( r'^%s(?P<id>\d+)/%s$' % (_('answers/'), _('revisions/')), - app.readers.answer_revisions, + app.readers.revisions, + kwargs = {'object_name': 'Answer'}, name='answer_revisions' ), url( @@ -101,7 +102,8 @@ urlpatterns = patterns('', ), url( r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('revisions/')), - app.readers.question_revisions, + app.readers.revisions, + kwargs = {'object_name': 'Question'}, name='question_revisions' ), url( diff --git a/askbot/views/commands.py b/askbot/views/commands.py index 4c57f05f..6681f23c 100644 --- a/askbot/views/commands.py +++ b/askbot/views/commands.py @@ -346,15 +346,15 @@ def reopen(request, id):#re-open question request.user.assert_can_reopen_question(question) closed_by_profile_url = question.closed_by.get_profile_url() closed_by_username = question.closed_by.username - return render_to_response( - 'reopen.html', - { - 'question' : question, - 'closed_by_profile_url': closed_by_profile_url, - 'closed_by_username': closed_by_username, - }, - context_instance=RequestContext(request) - ) + data = { + 'question' : question, + 'closed_by_profile_url': closed_by_profile_url, + 'closed_by_username': closed_by_username, + } + context = RequestContext(request, data) + template = ENV.get_template('reopen.html') + return HttpResponse(template.render(context)) + except exceptions.PermissionDenied, e: request.user.message_set.create(message = unicode(e)) return HttpResponseRedirect(question.get_absolute_url()) diff --git a/askbot/views/readers.py b/askbot/views/readers.py index 73c1b2d0..5579983e 100644 --- a/askbot/views/readers.py +++ b/askbot/views/readers.py @@ -18,7 +18,6 @@ from django.template import loader from django.template import defaultfilters from django.utils.html import * from django.utils import simplejson -from django.db.models import Q from django.utils.translation import ugettext as _ from django.utils import translation from django.core.urlresolvers import reverse @@ -347,7 +346,7 @@ def questions(request): return HttpResponse(simplejson.dumps(output), mimetype='application/json') else: #before = datetime.datetime.now() - template = ENV.get_template('questions.jinja.html') + template = ENV.get_template('questions.html') response = HttpResponse(template.render(template_context)) #after = datetime.datetime.now() #print after - before @@ -399,24 +398,29 @@ def tags(request):#view showing a listing of available tags - plain list except (EmptyPage, InvalidPage): tags = objects_list.page(objects_list.num_pages) - return render_to_response('tags.html', { - "view_name":"tags", - "active_tab": "tags", - "tags" : tags, - "stag" : stag, - "tab_id" : sortby, - "keywords" : stag, - "context" : { - 'is_paginated' : is_paginated, - 'pages': objects_list.num_pages, - 'page': page, - 'has_previous': tags.has_previous(), - 'has_next': tags.has_next(), - 'previous': tags.previous_page_number(), - 'next': tags.next_page_number(), - 'base_url' : reverse('tags') + '?sort=%s&' % sortby - } - }, context_instance=RequestContext(request)) + paginator_data = { + 'is_paginated' : is_paginated, + 'pages': objects_list.num_pages, + 'page': page, + 'has_previous': tags.has_previous(), + 'has_next': tags.has_next(), + 'previous': tags.previous_page_number(), + 'next': tags.next_page_number(), + 'base_url' : reverse('tags') + '?sort=%s&' % sortby + } + paginator_context = extra_tags.cnprog_paginator(paginator_data) + data = { + 'view_name':'tags', + 'active_tab': 'tags', + 'tags' : tags, + 'stag' : stag, + 'tab_id' : sortby, + 'keywords' : stag, + 'paginator_context' : paginator_context + } + context = RequestContext(request, data) + template = ENV.get_template('tags.html') + return HttpResponse(template.render(context)) def question(request, id):#refactor - long subroutine. display question body, answers and comments """view that displays body of the question and @@ -564,57 +568,24 @@ def question(request, id):#refactor - long subroutine. display question body, an template = ENV.get_template('question.html') return HttpResponse(template.render(context)) -QUESTION_REVISION_TEMPLATE = ('<h1>%(title)s</h1>\n' - '<div class="text">%(html)s</div>\n' - '<div class="tags">%(tags)s</div>') -def question_revisions(request, id): - post = get_object_or_404(Question, id=id) - revisions = list(post.revisions.all()) - revisions.reverse() - markdowner = markup.get_parser() - for i, revision in enumerate(revisions): - revision.html = QUESTION_REVISION_TEMPLATE % { - 'title': revision.title, - 'html': sanitize_html(markdowner.convert(revision.text)), - 'tags': ' '.join(['<a class="post-tag">%s</a>' % tag - for tag in revision.tagnames.split(' ')]), - } - if i > 0: - revisions[i].diff = htmldiff(revisions[i-1].html, revision.html) - else: - revisions[i].diff = QUESTION_REVISION_TEMPLATE % { - 'title': revisions[0].title, - 'html': sanitize_html(markdowner.convert(revisions[0].text)), - 'tags': ' '.join(['<a class="post-tag">%s</a>' % tag - for tag in revisions[0].tagnames.split(' ')]), - } - revisions[i].summary = _('initial version') - return render_to_response('revisions_question.html', { - 'view_name':'question_revisions', - 'active_tab':'questions', - 'post': post, - 'revisions': revisions, - }, context_instance=RequestContext(request)) - -ANSWER_REVISION_TEMPLATE = ('<div class="text">%(html)s</div>') -def answer_revisions(request, id): - post = get_object_or_404(Answer, id=id) +def revisions(request, id, object_name=None): + assert(object_name in ('Question', 'Answer')) + post = get_object_or_404(get_model(object_name), id=id) revisions = list(post.revisions.all()) revisions.reverse() - markdowner = markup.get_parser() for i, revision in enumerate(revisions): - revision.html = ANSWER_REVISION_TEMPLATE % { - 'html': sanitize_html(markdowner.convert(revision.text)) - } - if i > 0: - revisions[i].diff = htmldiff(revisions[i-1].html, revision.html) + revision.html = revision.as_html() + if i == 0: + revision.diff = revisions[i].html + revision.summary = _('initial version') else: - revisions[i].diff = revisions[i].text - revisions[i].summary = _('initial version') - return render_to_response('revisions_answer.html', { - 'view_name':'answer_revisions', - 'active_tab':'questions', - 'post': post, - 'revisions': revisions, - }, context_instance=RequestContext(request)) - + revision.diff = htmldiff(revisions[i-1].html, revision.html) + data = { + 'view_name':'answer_revisions', + 'active_tab':'questions', + 'post': post, + 'revisions': revisions, + } + context = RequestContext(request, data) + template = ENV.get_template('revisions.html') + return HttpResponse(template.render(context)) diff --git a/askbot/views/users.py b/askbot/views/users.py index f368c6d6..4db7641a 100644 --- a/askbot/views/users.py +++ b/askbot/views/users.py @@ -34,6 +34,7 @@ from askbot import models from askbot import exceptions from askbot.models import signals from askbot.skins.loaders import ENV +from askbot.templatetags import extra_tags question_type = ContentType.objects.get_for_model(models.Question) answer_type = ContentType.objects.get_for_model(models.Answer) @@ -110,27 +111,28 @@ def users(request): except (EmptyPage, InvalidPage): users_page = objects_list.page(objects_list.num_pages) - return render_to_response( - 'users.html', - { - 'active_tab': 'users', - 'users' : users_page, - 'suser' : suser, - 'keywords' : suser, - 'tab_id' : sortby, - 'context' : { - 'is_paginated' : is_paginated, - 'pages': objects_list.num_pages, - 'page': page, - 'has_previous': users_page.has_previous(), - 'has_next': users_page.has_next(), - 'previous': users_page.previous_page_number(), - 'next': users_page.next_page_number(), - 'base_url' : base_url - } - }, - context_instance=RequestContext(request) - ) + paginator_data = { + 'is_paginated' : is_paginated, + 'pages': objects_list.num_pages, + 'page': page, + 'has_previous': users_page.has_previous(), + 'has_next': users_page.has_next(), + 'previous': users_page.previous_page_number(), + 'next': users_page.next_page_number(), + 'base_url' : base_url + } + paginator_context = extra_tags.cnprog_paginator(paginator_data) + data = { + 'active_tab': 'users', + 'users' : users_page, + 'suser' : suser, + 'keywords' : suser, + 'tab_id' : sortby, + 'paginator_context' : paginator_context + } + template = ENV.get_template('users.html') + context = RequestContext(request, data) + return HttpResponse(template.render(context)) def user_moderate(request, subject): """user subview for moderation @@ -208,24 +210,23 @@ def user_moderate(request, subject): moderator = moderator, subject = subject ) - return render_to_response( - 'user_moderate.html', - { - 'active_tab': 'users', - 'tab_name': 'moderation', - 'tab_description': _('moderate this user'), - 'page_title': _('moderate user'), - 'view_user': subject, - 'change_user_status_form': user_status_form, - 'change_user_reputation_form': user_rep_form, - 'send_message_form': send_message_form, - 'message_sent': message_sent, - 'email_error_message': email_error_message, - 'user_rep_changed': user_rep_changed, - 'user_status_changed': user_status_changed - }, - context_instance=RequestContext(request) - ) + data = { + 'active_tab': 'users', + 'tab_name': 'moderation', + 'tab_description': _('moderate this user'), + 'page_title': _('moderate user'), + 'view_user': subject, + 'change_user_status_form': user_status_form, + 'change_user_reputation_form': user_rep_form, + 'send_message_form': send_message_form, + 'message_sent': message_sent, + 'email_error_message': email_error_message, + 'user_rep_changed': user_rep_changed, + 'user_status_changed': user_status_changed + } + context = RequestContext(request, data) + template = ENV.get_template('user_moderate.html') + return HttpResponse(template.render(context)) #non-view function def set_new_email(user, new_email, nomessage=False): @@ -272,15 +273,14 @@ def edit_user(request, id): return HttpResponseRedirect(user.get_profile_url()) else: form = forms.EditUserForm(user) - return render_to_response( - 'user_edit.html', - { - 'active_tab': 'users', - 'form' : form, - 'gravatar_faq_url' : reverse('faq') + '#gravatar', - }, - context_instance=RequestContext(request) - ) + data = { + 'active_tab': 'users', + 'form' : form, + 'gravatar_faq_url' : reverse('faq') + '#gravatar', + } + context = RequestContext(request, data) + template = ENV.get_template('user_edit.html') + return HttpResponse(template.render(context)) def user_stats(request, user): @@ -416,28 +416,27 @@ def user_stats(request, user): else: user_status = _('Registered User') - return render_to_response( - 'user_stats.html', - { - 'active_tab':'users', - 'tab_name' : 'stats', - 'tab_description' : _('user profile'), - 'page_title' : _('user profile overview'), - 'view_user' : user, - 'user_status_for_display': user.get_status_display(soft = True), - 'questions' : questions, - 'answered_questions' : answered_questions, - 'up_votes' : up_votes, - 'down_votes' : down_votes, - 'total_votes': up_votes + down_votes, - 'votes_today_left': votes_total-votes_today, - 'votes_total_per_day': votes_total, - 'user_tags' : user_tags[:const.USER_VIEW_DATA_SIZE], - 'awards': awards, - 'total_awards' : total_awards, - }, - context_instance=RequestContext(request) - ) + data = { + 'active_tab':'users', + 'tab_name' : 'stats', + 'tab_description' : _('user profile'), + 'page_title' : _('user profile overview'), + 'view_user' : user, + 'user_status_for_display': user.get_status_display(soft = True), + 'questions' : questions, + 'answered_questions' : answered_questions, + 'up_votes' : up_votes, + 'down_votes' : down_votes, + 'total_votes': up_votes + down_votes, + 'votes_today_left': votes_total-votes_today, + 'votes_total_per_day': votes_total, + 'user_tags' : user_tags[:const.USER_VIEW_DATA_SIZE], + 'awards': awards, + 'total_awards' : total_awards, + } + context = RequestContext(request, data) + template = ENV.get_template('user_stats.html') + return HttpResponse(template.render(context)) def user_recent(request, user): @@ -700,40 +699,17 @@ def user_recent(request, user): activities.sort(lambda x,y: cmp(y.time, x.time)) - return render_to_response('user_recent.html', - { - 'active_tab': 'users', - "tab_name" : 'recent', - "tab_description" : _('recent user activity'), - "page_title" : _('profile - recent activity'), - "view_user" : user, - "activities" : activities[:const.USER_VIEW_DATA_SIZE] - }, context_instance=RequestContext(request)) - -#class Response: -# """class that abstracts any kind of response -# answer, comment, mention, post edits, etc. -# """ -# def __init__( -# self, type, title, question_id, -# answer_id, time, username, -# user_id, content): -# -# self.type = type -# self.title = title -# self.titlelink = reverse( -# 'question', -# args=[question_id]) \ -# + u'%s#%s' % (slugify(title), -# answer_id -# ) -# self.time = time -# self.userlink = reverse('users') + u'%s/%s/' % (user_id, username) -# self.username = username -# self.content = u'%s ...' % strip_tags(content)[:300] - -# def __unicode__(self): -# return u'%s %s' % (self.type, self.titlelink) + data = { + 'active_tab': 'users', + 'tab_name' : 'recent', + 'tab_description' : _('recent user activity'), + 'page_title' : _('profile - recent activity'), + 'view_user' : user, + 'activities' : activities[:const.USER_VIEW_DATA_SIZE] + } + context = RequestContext(request, data) + template = ENV.get_template('user_recent.html') + return HttpResponse(template.render(context)) @owner_or_moderator_required def user_responses(request, user): @@ -766,18 +742,17 @@ def user_responses(request, user): response_list.sort(lambda x,y: cmp(y['timestamp'], x['timestamp'])) - return render_to_response( - 'user_responses.html', - { - 'active_tab':'users', - 'tab_name' : 'responses', - 'tab_description' : _('comments and answers to others questions'), - 'page_title' : _('profile - responses'), - 'view_user' : user, - 'responses' : response_list[:const.USER_VIEW_DATA_SIZE], - }, - context_instance=RequestContext(request) - ) + data = { + 'active_tab':'users', + 'tab_name' : 'responses', + 'tab_description' : _('comments and answers to others questions'), + 'page_title' : _('profile - responses'), + 'view_user' : user, + 'responses' : response_list[:const.USER_VIEW_DATA_SIZE], + } + context = RequestContext(request, data) + template = ENV.get_template('user_responses.html') + return HttpResponse(template.render(context)) @owner_or_moderator_required def user_votes(request, user): @@ -832,14 +807,17 @@ def user_votes(request, user): votes.extend(answer_votes) votes.sort(lambda x,y: cmp(y['voted_at'], x['voted_at'])) - return render_to_response('user_votes.html', { + data = { 'active_tab':'users', - "tab_name" : 'votes', - "tab_description" : _('user vote record'), - "page_title" : _('profile - votes'), - "view_user" : user, - "votes" : votes[:const.USER_VIEW_DATA_SIZE] - }, context_instance=RequestContext(request)) + 'tab_name' : 'votes', + 'tab_description' : _('user vote record'), + 'page_title' : _('profile - votes'), + 'view_user' : user, + 'votes' : votes[:const.USER_VIEW_DATA_SIZE] + } + context = RequestContext(request, data) + template = ENV.get_template('user_votes.html') + return HttpResponse(template.render(context)) def user_reputation(request, user): reputes = models.Repute.objects.filter(user=user).order_by('-reputed_at') @@ -868,15 +846,18 @@ def user_reputation(request, user): reps = ','.join(rep_list) reps = '[%s]' % reps - return render_to_response('user_reputation.html', { - 'active_tab':'users', - "tab_name": 'reputation', - "tab_description": _('user reputation in the community'), - "page_title": _('profile - user reputation'), - "view_user": user, - "reputation": reputes, - "reps": reps - }, context_instance=RequestContext(request)) + data = { + 'active_tab':'users', + 'tab_name': 'reputation', + 'tab_description': _('user reputation in the community'), + 'page_title': _('profile - user reputation'), + 'view_user': user, + 'reputation': reputes, + 'reps': reps + } + context = RequestContext(request, data) + template = ENV.get_template('user_reputation.html') + return HttpResponse(template.render(context)) def user_favorites(request, user): questions = models.Question.objects.extra( @@ -920,14 +901,17 @@ def user_favorites(request, user): 'la_user_bronze', 'la_user_reputation') - return render_to_response('user_favorites.html',{ + data = { 'active_tab':'users', - "tab_name" : 'favorites', - "tab_description" : _('users favorite questions'), - "page_title" : _('profile - favorite questions'), - "questions" : questions[:const.USER_VIEW_DATA_SIZE], - "view_user" : user - }, context_instance=RequestContext(request)) + 'tab_name' : 'favorites', + 'tab_description' : _('users favorite questions'), + 'page_title' : _('profile - favorite questions'), + 'questions' : questions[:const.USER_VIEW_DATA_SIZE], + 'view_user' : user + } + context = RequestContext(request, data) + template = ENV.get_template('user_favorites.html') + return HttpResponse(template.render(context)) @owner_or_moderator_required def user_email_subscriptions(request, user): diff --git a/askbot/views/writers.py b/askbot/views/writers.py index 46df6a3d..294c5e2a 100644 --- a/askbot/views/writers.py +++ b/askbot/views/writers.py @@ -200,12 +200,15 @@ def retag_question(request, id): return HttpResponseRedirect(question.get_absolute_url()) else: form = forms.RetagQuestionForm(question) - return render_to_response('question_retag.html', { + data = { 'active_tab': 'questions', 'question': question, 'form' : form, 'tags' : _get_tags_cache_json(), - }, context_instance=RequestContext(request)) + } + context = RequestContext(request, data) + template = ENV.get_template('question_retag.html') + return HttpResponse(template.render(context)) except exceptions.PermissionDenied, e: request.user.message_set.create(message = unicode(e)) return HttpResponseRedirect(question.get_absolute_url()) |