summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-10-01 02:21:05 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-10-01 02:21:05 -0400
commit8914980b7fa0b319d6bdfc7327d502c4e215ef56 (patch)
treed76419fe550ab4c77ce2ca863978fdae178cd936
parente3d2a247c94cfc88e18aa1cbce3ec53e2e27da6e (diff)
downloadaskbot-8914980b7fa0b319d6bdfc7327d502c4e215ef56.tar.gz
askbot-8914980b7fa0b319d6bdfc7327d502c4e215ef56.tar.bz2
askbot-8914980b7fa0b319d6bdfc7327d502c4e215ef56.zip
some more templates converted to jinja2
-rw-r--r--askbot/models/__init__.py5
-rw-r--r--askbot/skins/default/templates/base_content.jinja.html2
-rw-r--r--askbot/skins/default/templates/email_base.html13
-rw-r--r--askbot/skins/default/templates/feedback.html31
-rw-r--r--askbot/skins/default/templates/html.list29
-rw-r--r--askbot/skins/default/templates/instant_notification.html34
-rw-r--r--askbot/skins/default/templates/logout.html13
-rw-r--r--askbot/skins/default/templates/macros.html50
-rw-r--r--askbot/skins/default/templates/privacy.html11
-rw-r--r--askbot/skins/default/templates/question.html459
-rw-r--r--askbot/skins/default/templates/question_edit.html57
-rw-r--r--askbot/skins/default/templates/question_edit_tips.html4
-rw-r--r--askbot/skins/default/templates/questions.jinja.html2
-rw-r--r--askbot/skins/default/templates/user_email_subscriptions.html2
-rw-r--r--askbot/skins/default/templates/users_questions.html8
-rw-r--r--askbot/templatetags/extra_filters_jinja.py7
-rw-r--r--askbot/templatetags/extra_tags.py5
-rw-r--r--askbot/views/meta.py15
-rw-r--r--askbot/views/readers.py39
-rw-r--r--askbot/views/writers.py7
20 files changed, 437 insertions, 356 deletions
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py
index 6e84bd42..10a76018 100644
--- a/askbot/models/__init__.py
+++ b/askbot/models/__init__.py
@@ -5,7 +5,7 @@ import datetime
from django.core.urlresolvers import reverse
from askbot.search.indexer import create_fulltext_indexes
from django.db.models import signals as django_signals
-from django.template import loader, Context
+from django.template import Context
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
from django.contrib.auth.models import User
@@ -1540,7 +1540,8 @@ def send_instant_notifications_about_activity_in_post(
if update_activity.activity_type not in acceptable_types:
return
- template = loader.get_template('instant_notification.html')
+ from askbot.skins.loaders import ENV
+ template = ENV.get_template('instant_notification.html')
update_type_map = const.RESPONSE_ACTIVITY_TYPE_MAP_FOR_TEMPLATES
update_type = update_type_map[update_activity.activity_type]
diff --git a/askbot/skins/default/templates/base_content.jinja.html b/askbot/skins/default/templates/base_content.jinja.html
index 163aafa0..492e9136 100644
--- a/askbot/skins/default/templates/base_content.jinja.html
+++ b/askbot/skins/default/templates/base_content.jinja.html
@@ -11,7 +11,7 @@
{% if settings.GOOGLE_SITEMAP_CODE %}
<meta name="google-site-verification" content="{{ settings.GOOGLE_SITEMAP_CODE }}" />
{% endif %}
- <link rel="shortcut icon" href="{"/images/favicon.gif"|media}}" />
+ <link rel="shortcut icon" href="{{"/images/favicon.gif"|media}}" />
<link href="{{"/style/style.css"|media}}" rel="stylesheet" type="text/css" />
{% spaceless %}
{% block forestyle %}{% endblock %}
diff --git a/askbot/skins/default/templates/email_base.html b/askbot/skins/default/templates/email_base.html
index 6d9bbea2..406041e4 100644
--- a/askbot/skins/default/templates/email_base.html
+++ b/askbot/skins/default/templates/email_base.html
@@ -1,14 +1,11 @@
-{% load extra_filters %}
-{% load extra_tags %}
-{% load i18n %}
-
+{# this template is not used yet #}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <link href="{% fullmedia "/style/style.css" %}" rel="stylesheet" type="text/css" />
+ <link href="{{"/style/style.css"|fullmedia}}" rel="stylesheet" type="text/css" />
</head>
<body>
- <a href="{% fullurl index %}">
- <img src="{% fullmedia "/images/logo.png" %}" title="{% trans "home" %}" alt="{{settings.APP_TITLE}} logo"/>
+ <a href="{{settings.APP_URL}}{% url index %}">
+ <img src="{{"/images/logo.png"|fullmedia}}" title="{% trans %}home{% endtrans %}" alt="{{settings.APP_TITLE}} logo"/>
</a>
<br />
<p>{{ settings.APP_TITLE }}</p>
@@ -23,4 +20,4 @@
<div class="spacer3"></div>
</div>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/askbot/skins/default/templates/feedback.html b/askbot/skins/default/templates/feedback.html
index 4bf31d2d..8b76fbd7 100644
--- a/askbot/skins/default/templates/feedback.html
+++ b/askbot/skins/default/templates/feedback.html
@@ -1,36 +1,33 @@
-{% extends "base.html" %}
-<!-- template about.html -->
-{% load i18n %}
-{% load extra_tags %}
-{% load humanize %}
-{% block title %}{% spaceless %}{% trans "Feedback" %}{% endspaceless %}{% endblock %}
+{% extends "base.jinja.html" %}
+<!-- template feedback.html -->
+{% block title %}{% spaceless %}{% trans %}Feedback{% endtrans %}{% endspaceless %}{% endblock %}
{% block forejs %}
{% endblock %}
{% block content %}
<div class="headNormal">
-{% trans "Give us your feedback!" %}
+{% trans %}Give us your feedback!{% endtrans %}
</div>
<div class="content">
<form method="post" action="{% url feedback %}" accept-charset="utf-8">
- {% if user.is_authenticated %}
+ {% if user.is_authenticated() %}
<p class="message">
- {% blocktrans with user.username as user_name %}
+ {% trans user_name=user.username %}
<span class='big strong'>Dear {{user_name}}</span>, we look forward to hearing your feedback.
Please type and send us your message below.
- {% endblocktrans %}
+ {% endtrans %}
<p>
{% else %}
<p class="message">
- {% blocktrans %}
+ {% trans %}
<span class='big strong'>Dear visitor</span>, we look forward to hearing your feedback.
Please type and send us your message below.
- {% endblocktrans %}
+ {% endtrans %}
</p>
<div class="form-row"><label>{{form.name.label}}</label><br/>{{form.name}}</div>
<div class="form-row">
<label>{{form.email.label}}
{% if form.errors.email %}
- <span class='red'>(please enter a valid email)</span>
+ <span class='red'>{% trans %}(please enter a valid email){% endtrans %}</span>
{% endif %}
</label><br/>{{form.email}}
</div>
@@ -38,7 +35,7 @@
<div class="form-row">
<label>{{form.message.label}}
{% if form.errors.message %}
- <span class="red">{% trans "(this field is required)" %}</span>
+ <span class="red">{% trans %}(this field is required){% endtrans %}</span>
</label>
{% endif %}
<br/>
@@ -46,10 +43,10 @@
</div>
{{form.next}}
<div class="submit-row">
- <input type="submit" class="submit" value="{% trans "Send Feedback" %}"/>&nbsp;
- <input type="submit" class="submit" name="cancel" value="{% trans "Cancel" %}"/>
+ <input type="submit" class="submit" value="{% trans %}Send Feedback{% endtrans %}"/>&nbsp;
+ <input type="submit" class="submit" name="cancel" value="{% trans %}Cancel{% endtrans %}"/>
</div>
</form>
</div>
{% endblock %}
-<!-- end template about.html -->
+<!-- end template feedback.html -->
diff --git a/askbot/skins/default/templates/html.list b/askbot/skins/default/templates/html.list
index 9a315a9a..477f2080 100644
--- a/askbot/skins/default/templates/html.list
+++ b/askbot/skins/default/templates/html.list
@@ -1,20 +1,6 @@
==todo==
404.html
500.html
-email_base.html
-feedback.html
-instant_notification.html
-logout.html
-macros.html
-notarobot.html
-pagesize.html
-paginator.html
-post_contributor_info.html
-privacy.html
-question_counter_widget.html
-question_edit.html
-question_edit_tips.html
-question.html
question_list.html
question_retag.html
questions_ajax.html
@@ -36,8 +22,18 @@ 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==
+question_edit.html
+privacy.html
tag_selector.jinja.html
questions.jinja.html
ask_form.jinja.html
@@ -55,3 +51,8 @@ edit_user_email_feeds_form.html
user.html
user_tabs.html
faq.html
+feedback.html
+instant_notification.html
+macros.html
+question_edit_tips.html
+question.html
diff --git a/askbot/skins/default/templates/instant_notification.html b/askbot/skins/default/templates/instant_notification.html
index 86556fda..92799a96 100644
--- a/askbot/skins/default/templates/instant_notification.html
+++ b/askbot/skins/default/templates/instant_notification.html
@@ -1,44 +1,42 @@
-{% load i18n %}
-{% load smart_if %}
-{% blocktrans %}<p>Dear {{receiving_user_name}},</p>{% endblocktrans %}
+{% trans %}<p>Dear {{receiving_user_name}},</p>{% endtrans %}
{% if update_type == 'question_comment' %}
-{% blocktrans %}
+{% trans %}
<p>{{update_author_name}} left a <a href="{{post_url}}">new comment</a>:</p>
-{% endblocktrans %}
+{% endtrans %}
{% endif %}
{% if update_type == 'answer_comment' %}
-{% blocktrans %}
+{% trans %}
<p>{{update_author_name}} left a <a href="{{post_url}}">new comment</a></p>
-{% endblocktrans %}
+{% endtrans %}
{% endif %}
{% if update_type == 'new_answer' %}
-{% blocktrans %}
+{% trans %}
<p>{{update_author_name}} answered a question
<a href="{{post_url}}">{{origin_post_title}}</a></p>
-{% endblocktrans %}
+{% endtrans %}
{% endif %}
{% if update_type == 'new_question' %}
-{% blocktrans %}
+{% trans %}
<p>{{update_author_name}} posted a new question
<a href="{{post_url}}">{{origin_post_title}}</a></p>
-{% endblocktrans %}
+{% endtrans %}
{% endif %}
{%if update_type == 'answer_update' %}
-{% blocktrans %}
+{% trans %}
<p>{{update_author_name}} updated an answer to the question
<a href="{{post_url}}">{{origin_post_title}}</a></p>
-{% endblocktrans %}
+{% endtrans %}
{% endif %}
{% if update_type == 'question_update' %}
-{% blocktrans %}
+{% trans %}
<p>{{update_author_name}} updated a question
<a href="{{post_url}}">{{origin_post_title}}</a></p>
-{% endblocktrans %}
+{% endtrans %}
{% endif %}
<p></p>
-{% blocktrans %}
+{% trans %}
<div>{{content_preview}}</div>
<p>Please note - you can easily <a href="{{user_subscriptions_url}}">change</a>
how often you receive these notifications or unsubscribe. Thank you for your interest in our forum!</p>
-{% endblocktrans %}
-{% trans "<p>Sincerely,<br/>Forum Administrator</p>" %}
+{% endtrans %}
+{% trans %}<p>Sincerely,<br/>Forum Administrator</p>{% endtrans %}
diff --git a/askbot/skins/default/templates/logout.html b/askbot/skins/default/templates/logout.html
index c8273a39..297e1862 100644
--- a/askbot/skins/default/templates/logout.html
+++ b/askbot/skins/default/templates/logout.html
@@ -1,9 +1,6 @@
-{% extends "base_content.html" %}
+{% extends "base_content.jinja.html" %}
<!-- template logout.html -->
-{% load extra_tags %}
-{% load humanize %}
-{% load i18n %}
-{% block title %}{% spaceless %}{% trans "Logout" %}{% endspaceless %}{% endblock %}
+{% block title %}{% spaceless %}{% trans %}Logout{% endtrans %}{% endspaceless %}{% endblock %}
{% block forejs %}
<script type="text/javascript">
var sign_out = function(){
@@ -32,11 +29,11 @@
{% endblock %}
{% block content %}
<div class="headNormal">
- {% trans "Logout" %}
+ {% trans %}Logout{% endtrans %}
</div>
<div id="main-body" style="width:100%">
- <p>{% trans "As a registered user you can login with your OpenID, log out of the site or permanently remove your account." %}</p>
- <input id="btLogout" type="button" class="submit" value="{% trans "Logout now" %}"><!-- style="width:150px">-->
+ <p>{% trans %}As a registered user you can login with your OpenID, log out of the site or permanently remove your account.{% endtrans %}</p>
+ <input id="btLogout" type="button" class="submit" value="{% trans %}Logout now{% endtrans %}"><!-- style="width:150px">-->
</div>
{% if settings.FACEBOOK_KEY and settings.FACEBOOK_SECRET %}
<div id="fb-root"></div>
diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html
index 31db81d8..96c95fb1 100644
--- a/askbot/skins/default/templates/macros.html
+++ b/askbot/skins/default/templates/macros.html
@@ -118,3 +118,53 @@
/></a>
{% endspaceless %}
{%- endmacro -%}
+
+{%- macro post_contributor_info(post, contributor_type, is_wiki) -%}
+<div class='post-update-info'>
+{% if contributor_type=="original_author" %}
+ {% if is_wiki %}
+ <p>{% trans %}community wiki{% endtrans %}</p>
+ <p>
+ {% trans rev_count=post.revisions.all()|length %}{{rev_count}} revision{% pluralize %}{{rev_count}} revisions{% endtrans %}
+ </p>
+ <p>{{post.author.get_profile_link()}}</p>
+ {% else %}
+ <p style="line-height:12px;">
+ {# todo: access to class names needs to be removed here #}
+ {% if post.__class__.__name__=="Question" %}
+ {% trans %}asked{% endtrans %}
+ {% elif post.__class__.name__=="Answer" %}
+ {% trans %}answered{% endtrans %}
+ {% else %}
+ {% trans %}posted{% endtrans %}
+ {% endif %}
+ {% if post.__class__.__name__ in ('QuestionRevision', 'AnswerRevision') %}
+ <strong>{{post.revised_at|diff_date}}</strong>
+ {% else %}
+ <strong>{{post.added_at|diff_date}}</strong>
+ {% endif %}
+ </p>
+ {{ gravatar(post.author, 32) }}
+ <p>{{post.author.get_profile_link()}}<br/>
+ {{ user_score_and_badge_summary(post.author) }}</p>
+ {% endif %}
+{% else %}
+ {% if post.last_edited_at %}
+ <p style="line-height:12px;">
+ <a
+ {% if post.__class__.__name__ == 'Question' %}
+ href="{% url question_revisions post.id %}"
+ {% else %}
+ href="{% url answer_revisions post.id %}"
+ {% endif %}
+ >{% trans %}updated{% endtrans %} <strong>{{ post.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>
+ {% endif %}
+ {% endif %}
+{% endif %}
+</div>
+{%- endmacro -%}
diff --git a/askbot/skins/default/templates/privacy.html b/askbot/skins/default/templates/privacy.html
index fe074491..309a5c68 100644
--- a/askbot/skins/default/templates/privacy.html
+++ b/askbot/skins/default/templates/privacy.html
@@ -1,17 +1,14 @@
-{% extends "base_content.html" %}
+{% extends "base_content.jinja.html" %}
<!-- privacy.html -->
-{% load extra_tags %}
-{% load i18n %}
-{% load humanize %}
-{% block title %}{% spaceless %}{% trans "Privacy policy" %}{% endspaceless %}{% endblock %}
+{% block title %}{% spaceless %}{% trans %}Privacy policy{% endtrans %}{% endspaceless %}{% endblock %}
{% block forejs %}
{% endblock %}
{% block content %}
<div class="headNormal">
- {% trans "Privacy policy" %}
+ {% trans %}Privacy policy{% endtrans %}
</div>
<div id="main-body" style="width:100%">
- {{settings.FORUM_PRIVACY|safe}}
+ {{settings.FORUM_PRIVACY}}
</div>
{% endblock %}
<!-- end privacy.html -->
diff --git a/askbot/skins/default/templates/question.html b/askbot/skins/default/templates/question.html
index 73a43d14..bdaade04 100644
--- a/askbot/skins/default/templates/question.html
+++ b/askbot/skins/default/templates/question.html
@@ -1,20 +1,15 @@
-{% extends "base.html" %}
+{% extends "base.jinja.html" %}
+{% import "macros.html" as macros %}
<!-- question.html -->
-{% load extra_tags %}
-{% load extra_filters %}
-{% load smart_if %}
-{% load humanize %}
-{% load i18n %}
-{% load cache %}
-{% block title %}{% spaceless %}{{ question.get_question_title }}{% endspaceless %}{% endblock %}
+{% block title %}{% spaceless %}{{ question.get_question_title() }}{% endspaceless %}{% endblock %}
{% block meta_description %}
<meta name="description" content="{{question.summary}}" />
{% endblock %}
-{% block keywords %}{{question.tagname_meta_generator}}{% endblock %}
+{% block keywords %}{{question.tagname_meta_generator()}}{% endblock %}
{% block forejs %}
- <link rel="canonical" href="{{settings.APP_URL}}{{question.get_absolute_url}}" />
+ <link rel="canonical" href="{{settings.APP_URL}}{{question.get_absolute_url()}}" />
{% if not question.closed %}
- <script type='text/javascript' src='{% media "/js/com.cnprog.editor.js" %}'></script>
+ <script type='text/javascript' src='{{"/js/com.cnprog.editor.js"|media}}'></script>
<script type='text/javascript'>
{% if settings.ENABLE_MATHJAX or settings.MARKUP_CODE_FRIENDLY %}
var codeFriendlyMarkdown = true;
@@ -22,12 +17,12 @@
var codeFriendlyMarkdown = false;
{% endif %}
</script>
- <script type='text/javascript' src='{% media "/js/wmd/showdown.js" %}'></script>
- <script type='text/javascript' src='{% media "/js/wmd/wmd.js" %}'></script>
- <link rel="stylesheet" type="text/css" href="{% media "/js/wmd/wmd.css" %}" />
+ <script type='text/javascript' src='{{"/js/wmd/showdown.js"|media}}'></script>
+ <script type='text/javascript' src='{{"/js/wmd/wmd.js"|media}}'></script>
+ <link rel="stylesheet" type="text/css" href="{{"/js/wmd/wmd.css"|media}}" />
{% endif %}
- <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.post.js"|media}}'></script>
+ <script type='text/javascript' src='{{"/js/jquery.validate.pack.js"|media}}'></script>
<script type="text/javascript">
// define reputation needs for comments
@@ -52,15 +47,14 @@
captureLength: 5, callback: lanai.highlightSyntax});
var display = true;
- var txt = "[{% trans "hide preview" %}]";
+ var txt = "[{% trans %}hide preview{% endtrans %}]";
$('#pre-collapse').text(txt);
$('#pre-collapse').bind('click', function(){
- txt = display ? "[{% trans "show preview" %}]" : "[{% trans "hide preview" %}]";
+ txt = display ? "[{% trans %}show preview{% endtrans %}]" : "[{% trans %}hide preview{% endtrans %}]";
display = !display;
$('#previewer').toggle();
$('#pre-collapse').text(txt);
});
-
setupFormValidation("#fmanswer", CPValidator.getQuestionFormRules(), CPValidator.getQuestionFormMessages());
}
@@ -69,7 +63,7 @@
{% block content %}
<div class="headNormal">
- <a href="{{ question.get_absolute_url }}">{{ question.get_question_title }}</a>
+ <a href="{{ question.get_absolute_url() }}">{{ question.get_question_title() }}</a>
</div>
<div id="main-body" class="">
<div id="askform">
@@ -79,53 +73,52 @@
<div class="vote-buttons">
{% if question_vote %}
<img id="question-img-upvote-{{ question.id }}" class="question-img-upvote"
- {% if question_vote.is_upvote %}
- src="{% media "/images/vote-arrow-up-on.png" %}"
+ {% if question_vote.is_upvote() %}
+ src="{{"/images/vote-arrow-up-on.png"|media}}"
{% else %}
- src="{% media "/images/vote-arrow-up.png" %}"
+ src="{{"/images/vote-arrow-up.png"|media}}"
{% endif %}
- alt="{% trans "i like this post (click again to cancel)" %}"
- title="{% trans "i like this post (click again to cancel)" %}" />
+ alt="{% trans %}i like this post (click again to cancel){% endtrans %}"
+ title="{% trans %}i like this post (click again to cancel){% endtrans %}" />
<div id="question-vote-number-{{ question.id }}" class="vote-number"
- title="{% trans "current number of votes" %}">
+ title="{% trans %}current number of votes{% endtrans %}">
{{ question.score }}
</div>
<img id="question-img-downvote-{{ question.id }}" class="question-img-downvote"
- {% if question_vote.is_downvote %}
- src="{% media "/images/vote-arrow-down-on.png" %}"
+ {% if question_vote.is_downvote() %}
+ src="{{"/images/vote-arrow-down-on.png"|media}}"
{% else %}
- src="{% media "/images/vote-arrow-down.png" %}"
+ src="{{"/images/vote-arrow-down.png"|media}}"
{% endif %}
- alt="{% trans "i dont like this post (click again to cancel)" %}"
- title="{% trans "i dont like this post (click again to cancel)" %}" />
-
+ alt="{% trans %}i dont like this post (click again to cancel){% endtrans %}"
+ title="{% trans %}i dont like this post (click again to cancel){% endtrans %}" />
{% else %}
<img id="question-img-upvote-{{ question.id }}" class="question-img-upvote"
- alt="{% trans "i like this post (click again to cancel)" %}"
- src="{% media "/images/vote-arrow-up.png" %}"
- title="{% trans "i like this post (click again to cancel)" %}" />
+ alt="{% trans %}i like this post (click again to cancel){% endtrans %}"
+ src="{{"/images/vote-arrow-up.png"|media}}"
+ title="{% trans %}i like this post (click again to cancel){% endtrans %}" />
<div id="question-vote-number-{{ question.id }}" class="vote-number"
- title="{% trans "current number of votes" %}">
+ title="{% trans %}current number of votes{% endtrans %}">
{{ question.score }}
</div>
<img id="question-img-downvote-{{ question.id }}" class="question-img-downvote"
- src="{% media "/images/vote-arrow-down.png" %}"
- alt="{% trans "i dont like this post (click again to cancel)" %}"
- title="{% trans "i dont like this post (click again to cancel)" %}" />
+ src="{{"/images/vote-arrow-down.png"|media}}"
+ alt="{% trans %}i dont like this post (click again to cancel){% endtrans %}"
+ title="{% trans %}i dont like this post (click again to cancel){% endtrans %}" />
{% endif %}
{% if favorited %}
- <img class="question-img-favorite" src="{% media "/images/vote-favorite-on.png" %}"
- alt="{% trans "mark this question as favorite (click again to cancel)" %}"
- title="{% trans "mark this question as favorite (click again to cancel)" %}" />
+ <img class="question-img-favorite" src="{{"/images/vote-favorite-on.png"|media}}"
+ alt="{% trans %}mark this question as favorite (click again to cancel){% endtrans %}"
+ title="{% trans %}mark this question as favorite (click again to cancel){% endtrans %}" />
<div id="favorite-number" class="favorite-number my-favorite-number">
{{ question.favourite_count }}
</div>
{% else %}
- <img class="question-img-favorite" src="{% media "/images/vote-favorite-off.png" %}"
- alt="{% trans "remove favorite mark from this question (click again to restore mark)" %}"
- title="{% trans "remove favorite mark from this question (click again to restore mark)" %}" />
+ <img class="question-img-favorite" src="{{"/images/vote-favorite-off.png"|media}}"
+ alt="{% trans %}remove favorite mark from this question (click again to restore mark){% endtrans %}"
+ title="{% trans %}remove favorite mark from this question (click again to restore mark){% endtrans %}" />
<div id="favorite-number" class="favorite-number">
- {% ifnotequal question.favourite_count 0 %}{{ question.favourite_count }}{% endifnotequal %}
+ {% if question.favourite_count != 0 %}{{ question.favourite_count }}{% endif %}
</div>
{% endif %}
@@ -134,71 +127,79 @@
<td>
<div id="item-right">
<div class="question-body">
- {{ question.html|safe }}
+ {{question.html}}
</div>
<div id="question-controls" class="post-controls">
- {% comment %}todo: here we have important case to reset search state{% endcomment %}
+ {#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.tagname_list() %}
<a href="{% url questions %}?tags={{tag|urlencode}}&amp;start_over=true"
class="post-tag"
- title="{% blocktrans %}see questions tagged '{{tag}}'{% endblocktrans %}" rel="tag">{{ tag }}</a>
+ title="{% trans %}see questions tagged '{{tag}}'{% endtrans %}" rel="tag">{{ tag }}</a>
{% endfor %}
</div>
- {% joinitems using '<span class="action-link-separator">|</span>' %}
- {% if request.user|can_edit_post:question %}
+ {% set pipe=joiner('<span class="action-link-separator">|</span>') %}
+ {% if request.user|can_edit_post(question) %}{{ pipe() }}
<span class="action-link">
- <a href="{% url edit_question question.id %}">{% trans 'edit' %}</a>
+ <a href="{% url edit_question question.id %}">{% trans %}edit{% endtrans %}</a>
+ </span>
+ {% else %}
+ {% if request.user|can_retag_question(question) %}
+ <span class="action-link">
+ <a href="{% url retag_question question.id %}">{% trans %}retag{% endtrans %}</a>
</span>
- {% else %}
- {% if request.user|can_retag_question:question %}
- <span class="action-link">
- <a href="{% url retag_question question.id %}">{% trans 'retag' %}</a>
- </span>
- {% endif %}
- {% endif %}
- {% separator %}
- {% if question.closed %}
- {% if request.user|can_reopen_question:question %}
- <span class="action-link"><a href="{% url reopen question.id %}">{% trans "reopen" %}</a></span>
- {% endif %}
- {% else %}
- {% if request.user|can_close_question:question %}
- <span class="action-link"><a href="{% url close question.id %}">{% trans "close" %}</a></span>
{% endif %}
+ {% endif %}
+ {% if question.closed %}
+ {% if request.user|can_reopen_question(question) %}{{ pipe() }}
+ <span class="action-link"><a href="{% url reopen question.id %}">{% trans %}reopen{% endtrans %}</a></span>
{% endif %}
- {% separator %}
- {% if request.user|can_flag_offensive:question %}
- <span id="question-offensive-flag-{{ question.id }}" class="offensive-flag"
- title="{% trans "report as offensive (i.e containing spam, advertising, malicious text, etc.)" %}">
- <a>{% trans "flag offensive" %}</a>
- {% if request.user|can_see_offensive_flags:question %}
- <span class="darkred">{% if question.offensive_flag_count %}({{ question.offensive_flag_count }}){% endif %}</span>
- {% endif %}
- </span>
+ {% else %}
+ {% if request.user|can_close_question(question) %}{{ pipe() }}
+ <span class="action-link"><a href="{% url close question.id %}">{% trans %}close{% endtrans %}</a></span>
{% endif %}
- {% separator %}
- {% if request.user|can_delete_post:question %}
- <span class="action-link"><a id="question-delete-link-{{question.id}}">{% trans "delete" %}</a></span>
+ {% endif %}
+ {% if request.user|can_flag_offensive(question) %}{{ pipe() }}
+ <span id="question-offensive-flag-{{ question.id }}" class="offensive-flag"
+ title="{% trans %}report as offensive (i.e containing spam, advertising, malicious text, etc.){% endtrans %}">
+ <a>{% trans %}flag offensive{% endtrans %}</a>
+ {% if request.user|can_see_offensive_flags(question) %}
+ <span class="darkred">{% if question.offensive_flag_count > 0 %}({{ question.offensive_flag_count }}){% endif %}</span>
{% endif %}
- {% endjoinitems %}
+ </span>
+ {% endif %}
+ {% if request.user|can_delete_post(question) %}{{ pipe() }}
+ <span class="action-link"><a id="question-delete-link-{{question.id}}">{% trans %}delete{% endtrans %}</a></span>
+ {% endif %}
</div>
<div class="post-update-info-container">
- {% post_contributor_info question "original_author" %}
- {% post_contributor_info question "last_updater" %}
+ {{
+ macros.post_contributor_info(
+ question,
+ "original_author",
+ question.wiki
+ )
+ }}
+ {{
+ macros.post_contributor_info(
+ question,
+ "last_updter",
+ question.wiki
+ )
+ }}
</div>
{% spaceless %}
<div class="comments-container" id="comments-container-question-{{question.id}}">
- {% for comment in question.get_comments|slice:":5" %}
+ {% for comment in question.get_comments()[:5] %}
<div class="comment" id="comment-{{comment.id}}">
- {{comment.html|safe}}
- - <a class="comment-user" href="{{comment.user.get_profile_url}}">{{comment.user}}</a>
+ {{comment.html}}
+ - <a class="comment-user" href="{{comment.user.get_profile_url()}}">{{comment.user.username}}</a>
{% spaceless %}
- <span class="comment-age">&nbsp;({% diff_date comment.added_at %})</span>
- {% if request.user|can_delete_comment:comment %}
+ <span class="comment-age">&nbsp;({{comment.added_at|diff_date}})</span>
+ {% if request.user|can_delete_comment(comment) %}
<img class="delete-icon"
- src="{% media "/images/close-small.png" %}"
- title="{% trans "delete this comment" %}"/>
+ src="{{"/images/close-small.png"|media}}"
+ title="{% trans %}delete this comment{% endtrans %}"/>
{% endif %}
{% endspaceless %}
</div>
@@ -206,32 +207,31 @@
</div>
{% endspaceless %}
<div class="post-comments" style="margin-bottom:20px">
- <input id="can-post-comments-question-{{question.id}}" type="hidden" value="{{ request.user|can_post_comment:question }}"/>
- {% if request.user|can_post_comment:question or question.comment_count > 5 %}
+ <input id="can-post-comments-question-{{question.id}}" type="hidden" value="{{ request.user|can_post_comment(question) }}"/>
+ {% if request.user|can_post_comment(question) or question.comment_count > 5 %}
<a id="comments-link-question-{{question.id}}" class="comments-link">
- {% if request.user|can_post_comment:question %}
- {% trans "add comment" %}
+ {% if request.user|can_post_comment(question) %}
+ {% trans %}add comment{% endtrans %}
{% endif %}
{% if question.comment_count > 5 %}
- {% if request.user|can_post_comment:question %}/
- {% blocktrans count question.get_comments|slice:"5:"|length as counter %}see <strong>{{counter}}</strong> more{% plural %}see <strong>{{counter}}</strong> more{% endblocktrans %}
+ {% if request.user|can_post_comment(question) %}/
+ {% trans counter=question.get_comments()[5:]|length %}see <strong>{{counter}}</strong> more{% pluralize %}see <strong>{{counter}}</strong> more{% endtrans %}
{% else %}
- {% blocktrans count question.get_comments|slice:"5:"|length as counter %}see <strong>{{counter}}</strong> more comment{% plural %}see <strong>{{counter}}</strong> more comments
- {% endblocktrans %}
+ {% trans counter=question.get_comments()[5:]|length %}see <strong>{{counter}}</strong> more comment{% pluralize %}see <strong>{{counter}}</strong> more comments
+ {% endtrans %}
{% endif %}
{% endif %}</a>
{% endif %}
</div>
</div>
-
</td>
</tr>
</table>
{% if question.closed %}
<div class="question-status" style="margin-bottom:15px">
- <h3>{% blocktrans with question.get_close_reason_display as close_reason %}The question has been closed for the following reason "{{ close_reason }}" by{% endblocktrans %}
- <a href="{{ question.closed_by.get_profile_url }}">{{ question.closed_by.username }}</a>
- {% blocktrans with question.closed_at as closed_at %}close date {{closed_at}}{% endblocktrans %}</h3>
+ <h3>{% trans close_reason=question.get_close_reason_display() %}The question has been closed for the following reason "{{ close_reason }}" by{% endtrans %}
+ <a href="{{ question.closed_by.get_profile_url() }}">{{ question.closed_by.username }}</a>
+ {% trans closed_at=question.closed_at %}close date {{closed_at}}{% endtrans %}</h3>
</div>
{% endif %}
{% if answers %}
@@ -239,53 +239,68 @@
<div class="tabBar">
<a name="sort-top"></a>
<div class="headUsers">
- {% blocktrans count answers|length as counter %}
+ {% trans counter=answers|length %}
{{counter}} Answer:
- {% plural %}
+ {% pluralize %}
{{counter}} Answers:
- {% endblocktrans %}
+ {% endtrans %}
</div>
<div class="tabsA">
<a id="oldest" href="{% url question question.id %}?sort=oldest#sort-top"
- title="{% trans "oldest answers will be shown first" %}">{% trans "oldest answers" %}</a>
+ title="{% trans %}oldest answers will be shown first{% endtrans %}">{% trans %}oldest answers{% endtrans %}</a>
<a id="latest" href="{% url question question.id %}?sort=latest#sort-top"
- title="{% trans "newest answers will be shown first" %}">{% trans "newest answers" %}</a>
+ title="{% trans %}newest answers will be shown first{% endtrans %}">{% trans %}newest answers{% endtrans %}</a>
<a id="votes" href="{% url question question.id %}?sort=votes#sort-top"
- title="{% trans "most voted answers will be shown first" %}">{% trans "popular answers" %}</a>
+ title="{% trans %}most voted answers will be shown first{% endtrans %}">{% trans %}popular answers{% endtrans %}</a>
</div>
</div>
- {% cnprog_paginator context %}
+ {{ macros.paginator(paginator_context) }}
{% for answer in answers %}
<a name="{{ answer.id }}"></a>
- <div id="answer-container-{{ answer.id }}" class="answer {% if answer.accepted %}accepted-answer{% endif %} {% ifequal answer.author_id question.author_id %} answered-by-owner{% endifequal %} {% if answer.deleted %}deleted{% endif %}">
+ <div id="answer-container-{{ answer.id }}" class="answer {% if answer.accepted %}accepted-answer{% endif %} {% if answer.author_id==question.author_id %} answered-by-owner{% endif %} {% if answer.deleted %}deleted{% endif %}">
<table style="width:100%;">
<tr>
<td style="width:30px;vertical-align:top">
<div class="vote-buttons">
<img id="answer-img-upvote-{{ answer.id }}" class="answer-img-upvote"
- src="{% blockmedia %}/images/vote-arrow-up{% get_user_vote_image user_answer_votes answer.id 1 %}.png{% endblockmedia %}"
- alt="{% trans "i like this answer (click again to cancel)" %}"
- title="{% trans "i like this answer (click again to cancel)" %}"/>
- <div id="answer-vote-number-{{ answer.id }}" class="vote-number" title="{% trans "current number of votes" %}">
+ {% if user_answer_votes[answer.id] == 1 %}
+ src="{{"/images/vote-arrow-up-on.png"|media}}"
+ {% else %}
+ src="{{"/images/vote-arrow-up.png"|media}}"
+ {% endif %}
+ alt="{% trans %}i like this answer (click again to cancel){% endtrans %}"
+ title="{% trans %}i like this answer (click again to cancel){% endtrans %}"/>
+ <div id="answer-vote-number-{{ answer.id }}" class="vote-number" title="{% trans %}current number of votes{% endtrans %}">
{{ answer.score }}
</div>
<img id="answer-img-downvote-{{ answer.id }}" class="answer-img-downvote"
- src="{% blockmedia %}/images/vote-arrow-down{% get_user_vote_image user_answer_votes answer.id -1 %}.png{% endblockmedia %}"
- alt="{% trans "i dont like this answer (click again to cancel)" %}"
- title="{% trans "i dont like this answer (click again to cancel)" %}" />
-
+ {% if user_answer_votes[answer.id] == -1 %}
+ src="{{"/images/vote-arrow-down-on.png"|media}}"
+ {% else %}
+ src="{{"/images/vote-arrow-down.png"|media}}"
+ {% endif %}
+ alt="{% trans %}i dont like this answer (click again to cancel){% endtrans %}"
+ title="{% trans %}i dont like this answer (click again to cancel){% endtrans %}" />
{% if request.user == question.author %}
<img id="answer-img-accept-{{ answer.id }}" class="answer-img-accept"
- src="{% blockmedia %}/images/vote-accepted{% if answer.accepted %}-on{% endif %}.png{% endblockmedia %}"
- alt="{% trans "mark this answer as favorite (click again to undo)" %}"
- title="{% trans "mark this answer as favorite (click again to undo)" %}" />
+ {% if answer.accepted %}
+ src="{{"/images/vote-accepted-on.png"|media}}"
+ {% else %}
+ src="{{"/images/vote-accepted.png"|media}}"
+ {% endif %}
+ alt="{% trans %}mark this answer as favorite (click again to undo){% endtrans %}"
+ title="{% trans %}mark this answer as favorite (click again to undo){% endtrans %}" />
{% else %}
{% if answer.accepted %}
<img id="answer-img-accept-{{ answer.id }}" class="answer-img-accept"
- src="{% blockmedia %}/images/vote-accepted{% if answer.accepted %}-on{% endif %}.png{% endblockmedia %}"
- alt="{% blocktrans with question.author.username as question_author %}{{question_author}} has selected this answer as correct{% endblocktrans %}"
- title="{% blocktrans with question.author.username as question_author %}{{question_author}} has selected this answer as correct{% endblocktrans %}"
+ {% if answer.accepted %}
+ src="{{"/images/vote-accepted-on.png"|media}}"
+ {% else %}
+ src="{{"/images/vote-accepted.png"|media}}"
+ {% endif %}
+ alt="{% trans question_author=question.author.username %}{{question_author}} has selected this answer as correct{% endtrans %}"
+ title="{% trans questsion_author=question.author.username%}{{question_author}} has selected this answer as correct{% endtrans %}"
{% endif %}
{% endif %}
</div>
@@ -293,141 +308,146 @@
<td>
<div class="item-right">
<div class="answer-body">
- {{ answer.html|safe }}
+ {{ answer.html }}
</div>
<div class="answer-controls post-controls">
- {% joinitems using '<span class="action-link-separator">|</span>' %}
- <span class="linksopt">
- <a href="#{{ answer.id }}" title="{% trans "answer permanent link" %}">
- {% trans "permanent link" %}
- </a>
- </span>
- {% separator %}
- {% if request.user|can_edit_post:answer %}
- <span class="action-link"><a href="{% url edit_answer answer.id %}">{% trans 'edit' %}</a></span>
+ {% set pipe=joiner('<span class="action-link-separator">|</span>') %}
+ <span class="linksopt">{{ pipe() }}
+ <a
+ href="#{{ answer.id }}"
+ title="{% trans %}answer permanent link{% endtrans %}">
+ {% trans %}permanent link{% endtrans %}
+ </a>
+ </span>
+ {% if request.user|can_edit_post(answer) %}{{ pipe() }}
+ <span class="action-link"><a href="{% url edit_answer answer.id %}">{% trans %}edit{% endtrans %}</a></span>
+ {% endif %}
+ {% if request.user|can_flag_offensive(answer) %}{{ pipe() }}
+ <span id="answer-offensive-flag-{{ answer.id }}" class="offensive-flag"
+ title="{% trans %}report as offensive (i.e containing spam, advertising, malicious text, etc.){% endtrans %}">
+ <a>{% trans %}flag offensive{% endtrans %}</a>
+ {% if request.user|can_see_offensive_flags(answer) %}
+ <span class="darkred">{% if answer.offensive_flag_count > 0 %}({{ answer.offensive_flag_count }}){% endif %}</span>
{% endif %}
- {% separator %}
- {% if request.user|can_flag_offensive:answer %}
- <span id="answer-offensive-flag-{{ answer.id }}" class="offensive-flag"
- title="{% trans "report as offensive (i.e containing spam, advertising, malicious text, etc.)" %}">
- <a>{% trans "flag offensive" %}</a>
- {% if request.user|can_see_offensive_flags:answer %}
- <span class="darkred">{% if answer.offensive_flag_count %}({{ answer.offensive_flag_count }}){% endif %}</span>
- {% endif %}
+ </span>
+ {% endif %}
+ {% if request.user|can_delete_post(answer) %}{{ pipe() }}
+ {% spaceless %}
+ <span class="action-link">
+ <a id="answer-delete-link-{{answer.id}}">
+ {% if answer.deleted %}{% trans %}undelete{% endtrans %}{% else %}{% trans %}delete{% endtrans %}{% endif %}</a>
</span>
- {% endif %}
- {% separator %}
- {% if request.user|can_delete_post:answer %}
- {% spaceless %}
- <span class="action-link">
- <a id="answer-delete-link-{{answer.id}}">
- {% if answer.deleted %}{% trans "undelete" %}{% else %}{% trans "delete" %}{% endif %}</a>
- </span>
- {% endspaceless %}
- {% endif %}
- {% endjoinitems %}
+ {% endspaceless %}
+ {% endif %}
</div>
<div class="post-update-info-container">
- {% post_contributor_info answer "original_author" %}
- {% post_contributor_info answer "last_updater" %}
+ {{
+ macros.post_contributor_info(
+ answer,
+ "original_author",
+ answer.wiki
+ )
+ }}
+ {{
+ macros.post_contributor_info(
+ answer,
+ "last_updater",
+ answer.wiki
+ )
+ }}
</div>
{% spaceless %}
<div class="comments-container" id="comments-container-answer-{{answer.id}}">
- {% for comment in answer.get_comments|slice:":5" %}
+ {% for comment in answer.get_comments()[:5] %}
<div id="comment-{{comment.id}}" class="comment">
- {{comment.html|safe}}
- - <a class="comment-user" href="{{comment.user.get_profile_url}}">{{comment.user}}</a>
- {% spaceless %}
- <span class="comment-age">&nbsp;({% diff_date comment.added_at %})</span>
- {% if request.user|can_delete_comment:comment %}
+ {{comment.html}}
+ - <a class="comment-user" href="{{comment.user.get_profile_url()}}">{{comment.user}}</a>
+ <span class="comment-age">&nbsp;({{comment.added_at|diff_date}})</span>
+ {% if request.user|can_delete_comment(comment) %}
<img class="delete-icon"
- src="{% media "/images/close-small.png" %}"
- title="{% trans "delete this comment" %}"/>
+ src="{{"/images/close-small.png"|media}}"
+ title="{% trans %}delete this comment{% endtrans %}"/>
{% endif %}
- {% endspaceless %}
</div>
{% endfor %}
</div>
{% endspaceless %}
<div class="post-comments" style="margin-bottom:20px">
- <input id="can-post-comments-answer-{{answer.id}}" type="hidden" value="{{ request.user|can_post_comment:answer}}"/>
- {% if request.user|can_post_comment:answer or answer.comment_count > 5 %}
+ <input
+ id="can-post-comments-answer-{{answer.id}}"
+ type="hidden"
+ value="{{ request.user|can_post_comment(answer)}}"
+ />
+ {% if request.user|can_post_comment(answer) or answer.comment_count > 5 %}
<a id="comments-link-answer-{{answer.id}}" class="comments-link">
- {% if request.user|can_post_comment:answer %}
- {% trans "add comment" %}
+ {% if request.user|can_post_comment(answer) %}
+ {% trans %}add comment{% endtrans %}
{% endif %}
{% if answer.comment_count > 5 %}
- {% if request.user|can_post_comment:answer %}/
- {% blocktrans count answer.get_comments|slice:"5:"|length as counter %}see <strong>{{counter}}</strong> more{% plural %}see <strong>{{counter}}</strong> more{% endblocktrans %}
+ {% if request.user|can_post_comment(answer) %}/
+ {% trans counter=answer.get_comments()[5:]|length %}see <strong>{{counter}}</strong> more{% pluralize %}see <strong>{{counter}}</strong> more{% endtrans %}
{% else %}
- {% blocktrans count answer.get_comments|slice:"5:"|length as counter %}see <strong>{{counter}}</strong> more comment{% plural %} see <strong>{{counter}}</strong> more comments{% endblocktrans %}
+ {% trans counter=answer.get_comments()[5:]|length %}see <strong>{{counter}}</strong> more comment{% pluralize %} see <strong>{{counter}}</strong> more comments{% endtrans %}
{% endif %}
{% endif %}</a>
{% endif %}
</div>
</div>
-
</td>
</tr>
</table>
</div>
{% endfor %}
<div class="paginator-container-left">
- {% cnprog_paginator context %}
+ {{ macros.paginator(paginator_context) }}
</div>
{% endif %}
<form id="fmanswer" action="{% url answer question.id %}" method="post">
- {% if request.user.is_authenticated %}
+ {% if request.user.is_authenticated() %}
<p style="padding-left:3px">
{{ answer.email_notify }}
<label for="question-subscribe-updates">
- {% ifequal request.user.get_q_sel_email_feed_frequency 'n' %}
- {% trans "Notify me once a day when there are any new answers" %}
- {% else %}
- {% ifequal request.user.get_q_sel_email_feed_frequency 'd' %}
- {% trans "Notify me once a day when there are any new answers" %}
- {% else %}
- {% ifequal request.user.get_q_sel_email_feed_frequency 'w' %}
- {% trans "Notify me weekly when there are any new answers" %}
- {% endifequal %}
- {% endifequal %}
- {% endifequal %}
+ {% if request.user.get_q_sel_email_feed_frequency()=='n' %}
+ {% trans %}Notify me once a day when there are any new answers{% endtrans %}
+ {% elif request.user.get_q_sel_email_feed_frequency()=='d' %}
+ {% trans %}Notify me once a day when there are any new answers{% endtrans %}
+ {% elif request.user.get_q_sel_email_feed_frequency()=='w' %}
+ {% trans %}Notify me weekly when there are any new answers{% endtrans %}
+ {% endif %}
</label>
- {% blocktrans with request.user.get_profile_url as profile_url %}You can always adjust frequency of email updates from your {{profile_url}}{% endblocktrans %}
+ {% trans profile_url=request.user.get_profile_url() %}You can always adjust frequency of email updates from your {{profile_url}}{% endtrans %}
</p>
{% else %}
<p style="padding-left:3px">
<input class="nomargin" type="checkbox" disabled="disabled" />
- <label>{% trans "once you sign in you will be able to subscribe for any updates here" %}</label>
+ <label>{% trans %}once you sign in you will be able to subscribe for any updates here{% endtrans %}</label>
</p>
{% endif %}
<div style="clear:both">
</div>
-
{% if not question.closed %}
<div style="padding:10px 0 0 0;">
{% spaceless %}
<div class="headNormal">
{% if answers %}
- {% trans "Your answer" %}
+ {% trans %}Your answer{% endtrans %}
{% else %}
- {% trans "Be the first one to answer this question!" %}
+ {% trans %}Be the first one to answer this question!{% endtrans %}
{% endif %}
</div>
{% endspaceless %}
</div>
- {% if not request.user.is_authenticated %}
- <div class="message">{% trans "you can answer anonymously and then login" %}</div>
+ {% if not request.user.is_authenticated() %}
+ <div class="message">{% trans %}you can answer anonymously and then login{% endtrans %}</div>
{% else %}
<p class="message">
- {% ifequal request.user question.author %}
- {% trans "answer your own question only to give an answer" %}
+ {% if request.user==question.author %}
+ {% trans %}answer your own question only to give an answer{% endtrans %}
{% else %}
- {% trans "please only give an answer, no discussions" %}
- {% endifequal %}
+ {% trans %}please only give an answer, no discussions{% endtrans %}
+ {% endif %}
</p>
{% endif %}
-
<div id="description" class="" >
<div id="wmd-button-bar" class="wmd-panel"></div>
{{ answer.text }}
@@ -435,9 +455,11 @@
<table width="100%">
<tr>
<td>
- <span id="pre-collapse"
- title="{% trans "Toggle the real time Markdown editor preview" %}">
- {% trans "toggle preview" %}
+ <span
+ id="pre-collapse"
+ title="{% trans %}Toggle the real time Markdown editor preview{% endtrans %}"
+ >
+ {% trans %}toggle preview{% endtrans %}
</span>
</td>
{% if settings.WIKI_ON %}
@@ -445,26 +467,25 @@
{{ answer.wiki }}
<span style="font-weight:normal;cursor:help"
title="{{answer.wiki.help_text}}">
- {{ answer.wiki.label_tag }}
+ {{ answer.wiki.label_tag() }}
</span>
</td>
{% endif %}
</tr>
-
- </table>
+ </table>
</div>
<div id="previewer" class="wmd-preview"></div>
{{ answer.text.errors }}
</div>
<p><span class="form-error"></span></p>
<input type="submit"
- {% if user.is_anonymous %}
- value="{% trans "Login/Signup to Post Your Answer" %}"
+ {% if user.is_anonymous() %}
+ value="{% trans %}Login/Signup to Post Your Answer{% endtrans %}"
{% else %}
{% if user == question.author %}
- value="{% trans "Answer Your Own Question" %}"
+ value="{% trans %}Answer Your Own Question{% endtrans %}"
{% else %}
- value="{% trans "Answer the question" %}"
+ value="{% trans %}Answer the question{% endtrans %}"
{% endif %}
{% endif %}
class="submit" style="float:left"/>
@@ -475,49 +496,45 @@
{% endblock %}
{% block sidebar %}
-{% get_current_language as LANGUAGE_CODE %}
-{% cache 600 questions_tags question.id LANGUAGE_CODE %}
+{% cache 600 "questions_tags" questions_tags question.id language_code %}
<div class="boxC">
<p>
- {% trans "Question tags" %}:
+ {% trans %}Question tags{% endtrans %}:
</p>
<p class="tags" >
{% for tag in tags %}
<a href="{% url questions %}?tags={{tag.name|urlencode}}&amp;start_over=true"
- 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 %}"
rel="tag">{{ tag.name }}</a>
<span class="tag-number">&#215;{{ tag.used_count|intcomma }}</span><br/>
{% endfor %}
</p>
<p>
- {% trans "question asked" %}: <strong title="{{ question.added_at }}">{% diff_date question.added_at %}</strong>
+ {% trans %}question asked{% endtrans %}: <strong title="{{ question.added_at }}">{{question.added_at|diff_date}}</strong>
</p>
<p>
- {% trans "question was seen" %}: <strong>{{ question.view_count|intcomma }} {% trans "times" %}</strong>
+ {% trans %}question was seen{% endtrans %}: <strong>{{ question.view_count|intcomma }} {% trans %}times{% endtrans %}</strong>
</p>
<p>
- {% trans "last updated" %}: <strong title="{{ question.last_activity_at }}">{% diff_date question.last_activity_at %}</strong>
+ {% trans %}last updated{% endtrans %}: <strong title="{{ question.last_activity_at }}">{{question.last_activity_at|diff_date}}</strong>
</p>
</div>
{% endcache %}
{% if similar_questions.data %}
- {% cache 1800 related_questions question.id LANGUAGE_CODE %}
+ {% cache 1800 "related_questions" related_questions question.id language_code %}
<div class="boxC">
- <h3 class="subtitle">{% trans "Related questions" %}</h3>
+ <h3 class="subtitle">{% trans %}Related questions{% endtrans %}</h3>
<div class="questions-related">
- {% for question in similar_questions.data %}
+ {% for question in similar_questions.data() %}
<p>
- <a href="{{ question.get_absolute_url }}">{{ question.get_question_title }}</a>
+ <a href="{{ question.get_absolute_url() }}">{{ question.get_question_title() }}</a>
</p>
{% endfor %}
-
</div>
</div>
{% endcache %}
{% endif %}
-
{% endblock %}
-
{% block endjs %}
{% endblock %}
<!-- end question.html -->
diff --git a/askbot/skins/default/templates/question_edit.html b/askbot/skins/default/templates/question_edit.html
index 47f6f349..7a01b48e 100644
--- a/askbot/skins/default/templates/question_edit.html
+++ b/askbot/skins/default/templates/question_edit.html
@@ -1,13 +1,10 @@
-{% extends "base.html" %}
+{% extends "base.jinja.html" %}
<!-- question_edit.html -->
-{% load i18n %}
-{% load extra_tags %}
-{% load smart_if %}
-{% block title %}{% spaceless %}{% trans "Edit question" %}{% endspaceless %}{% endblock %}
+{% block title %}{% spaceless %}{% trans %}Edit question{% 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'>
{% if settings.ENABLE_MATHJAX or settings.MARKUP_CODE_FRIENDLY %}
var codeFriendlyMarkdown = true;
@@ -15,9 +12,9 @@
var codeFriendlyMarkdown = false;
{% endif %}
</script>
- <script type='text/javascript' src='{% media "/js/wmd/showdown.js" %}'></script>
- <script type='text/javascript' src='{% media "/js/wmd/wmd.js" %}'></script>
- <link rel="stylesheet" type="text/css" href="{% media "/js/wmd/wmd.css" %}" />
+ <script type='text/javascript' src='{{"/js/wmd/showdown.js"|media}}'></script>
+ <script type='text/javascript' src='{{"/js/wmd/wmd.js"|media}}'></script>
+ <link rel="stylesheet" type="text/css" href="{{"/js/wmd/wmd.css"|media}}" />
<script type="text/javascript">
//todo move javascript out
$().ready(function(){
@@ -30,17 +27,17 @@
//toggle preview of editor
var display = true;
- var txt = "[{% trans "hide preview" %}]";
+ var txt = "[{% trans %}hide preview{% endtrans %}]";
$('#pre-collapse').text(txt);
$('#pre-collapse').bind('click', function(){
- txt = display ? "[{% trans "show preview" %}]" : "[{% trans "hide preview" %}]";
+ txt = display ? "[{% trans %}show preview{% endtrans %}]" : "[{% trans %}hide preview{% endtrans %}]";
display = !display;
$('#previewer').toggle();
$('#pre-collapse').text(txt);
});
//Tags autocomplete action
- var tags = {{ tags|safe }};
+ var tags = {{ tags }};
$("#id_tags").autocomplete(tags, {
matchContains: true,
max: 20,
@@ -68,24 +65,23 @@
});
</script>
{% endblock %}
-
{% block content %}
<div id="main-bar" class="headNormal">
- {% trans "Edit question" %} [<a href="{{ question.get_absolute_url }}">{% trans "back" %}</a>]
+ {% trans %}Edit question{% endtrans %} [<a href="{{ question.get_absolute_url() }}">{% trans %}back{% endtrans %}</a>]
</div>
<div id="main-body" class="ask-body">
<div id="askform">
<form id="fmedit" action="{% url edit_question question.id %}" method="post" >
- <label for="id_revision" ><strong>{% trans "revision" %}:</strong></label> <br/>
- {% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul }}{% endif %}
+ <label for="id_revision" ><strong>{% trans %}revision{% endtrans %}:</strong></label> <br/>
+ {% if revision_form.revision.errors %}{{ revision_form.revision.errors.as_ul() }}{% endif %}
<div style="vertical-align:middle">
- {{ revision_form.revision }} <input type="submit" style="display:none"
+ {{ revision_form.revision }} <input type="submit" style="display:none"
id="select_revision" name="select_revision"
- value="{% trans "select revision"%}">
+ value="{% trans %}select revision{% endtrans %}">
</div>
<div class="form-item">
- <label for="id_title" ><strong>{{ form.title.label_tag }}:</strong></label> <span class="form-error"></span><br/>
- {{ form.title }} {{ form.title.errors }}
+ <label for="id_title" ><strong>{{ form.title.label_tag() }}:</strong></label> <span class="form-error"></span><br/>
+ {{ form.title }} {{ form.title.errors }}
<div class="title-desc">
{{ form.title.help_text }}
</div>
@@ -98,34 +94,33 @@
<table width="100%">
<tr>
<td>
- <span id="pre-collapse" title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
+ <span id="pre-collapse" title="{% trans %}Toggle the real time Markdown editor preview{% endtrans %}">{% trans %}toggle preview{% endtrans %}</span>
</td>
- {% if settings.WIKI_ON %}
+ {% if settings.WIKI_ON and 'wiki' in form %}
<td style="text-align:right;">
- {{ form.wiki }} <span style="color:#000;cursor:help" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag }} </span>
+ {{ form.wiki }} <span style="color:#000;cursor:help" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag() }} </span>
</td>
{% endif %}
</tr>
-
- </table>
+ </table>
</div>
<div id="previewer" class="wmd-preview"></div>
</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>
- <strong>{{ form.summary.label_tag }}</strong> <br/>
+ <strong>{{ form.summary.label_tag() }}</strong> <br/>
{{ form.summary }} {{ form.summary.errors }}
<div class="title-desc">
{{ form.summary.help_text }}
</div>
<div class="error" ></div>
- <input type="submit" value="{% trans "Save edit" %}" class="submit" />&nbsp;
- <input type="button" value="{% trans "Cancel" %}" class="submit" onclick="history.back(-1);" />
+ <input type="submit" value="{% trans %}Save edit{% endtrans %}" class="submit" />&nbsp;
+ <input type="button" value="{% trans %}Cancel{% endtrans %}" class="submit" onclick="history.back(-1);" />
</form>
</div>
</div>
diff --git a/askbot/skins/default/templates/question_edit_tips.html b/askbot/skins/default/templates/question_edit_tips.html
index 1817c5e8..2c239115 100644
--- a/askbot/skins/default/templates/question_edit_tips.html
+++ b/askbot/skins/default/templates/question_edit_tips.html
@@ -1,6 +1,6 @@
<!-- question_edit_tips.html -->
<div class="boxC">
- <p class="subtitle darkred">{% trans %}question tips{% endtrans %}</p>
+ <h3>{% trans %}question tips{% endtrans %}</h3>
<div>
<ul class="list-item">
<li> <b>{% trans %}please ask a relevant question{% endtrans %}</b>
@@ -19,7 +19,7 @@
</div>
<div class="boxC">
- <p class="subtitle">{% trans %}Markdown tips{% endtrans %}</p>
+ <h3>{% trans %}Markdown tips{% endtrans %}</h3>
<ul class="list-item">
{% if settings.MARKDUP_CODE_FRIENDLY or settings.ENABLE_MATHJAX %}
<li>
diff --git a/askbot/skins/default/templates/questions.jinja.html b/askbot/skins/default/templates/questions.jinja.html
index aa68cb9f..aa5b3436 100644
--- a/askbot/skins/default/templates/questions.jinja.html
+++ b/askbot/skins/default/templates/questions.jinja.html
@@ -202,7 +202,7 @@
</div>
</div>
</div>
- <h2><a title="{{question.summary}}" href="{{ question.get_absolute_url() }}">{{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}}">{{ 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>
diff --git a/askbot/skins/default/templates/user_email_subscriptions.html b/askbot/skins/default/templates/user_email_subscriptions.html
index 252b2893..4c2c9cce 100644
--- a/askbot/skins/default/templates/user_email_subscriptions.html
+++ b/askbot/skins/default/templates/user_email_subscriptions.html
@@ -2,7 +2,7 @@
<!-- user_email_subscriptions.html -->
{% block usercontent %}
<h2>{% trans %}Email subscription settings{% endtrans %}</h2>
- <p class="message">{% trans %}email subscription settings info{% endtrans %} </p>
+ <p class="message">{% trans %}email subscription settings info{% endtrans %}</p>
<div>
{% if action_status %}
<p class="action-status"><span>{{action_status}}</span></p>
diff --git a/askbot/skins/default/templates/users_questions.html b/askbot/skins/default/templates/users_questions.html
index 6f987558..074bd60c 100644
--- a/askbot/skins/default/templates/users_questions.html
+++ b/askbot/skins/default/templates/users_questions.html
@@ -8,14 +8,16 @@
{% if question.favourite_count %}
{% if question.favorited_myself %}
<div class="favorites-count">
- <img title="{% trans "this questions was selected as favorite" %} {{question.favourite_count}} {% trans "number of times" %}"
+ <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" %}"/>
+ src="{% media "/images/vote-favorite-on.png" %}"/>
<div><b>{{question.favourite_count|intcomma}}</b></div>
</div>
{% else %}
<div class="favorites-count-off">
- <img title="{% trans "this question was selected as favorite" %}{{question.favourite_count}} {% trans "number of times" %}"
+ <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" %}"/>
<div><b>{{question.favourite_count|intcomma}}</b></div>
diff --git a/askbot/templatetags/extra_filters_jinja.py b/askbot/templatetags/extra_filters_jinja.py
index 6f8c14af..8fd44ab2 100644
--- a/askbot/templatetags/extra_filters_jinja.py
+++ b/askbot/templatetags/extra_filters_jinja.py
@@ -31,6 +31,13 @@ def media(url):
else:
return ''
+@register.filter
+def fullmedia(url):
+ domain = askbot_settings.APP_URL
+ #protocol = getattr(settings, "PROTOCOL", "http")
+ path = media(url)
+ return "%s%s" % (domain, path)
+
diff_date = register.filter(functions.diff_date)
setup_paginator = register.filter(functions.setup_paginator)
diff --git a/askbot/templatetags/extra_tags.py b/askbot/templatetags/extra_tags.py
index be7a2561..085701e3 100644
--- a/askbot/templatetags/extra_tags.py
+++ b/askbot/templatetags/extra_tags.py
@@ -446,7 +446,10 @@ def fullmedia(url):
@register.inclusion_tag('question_counter_widget.html') #too slow
def question_counter_widget(question):
- """returns colorized counter widget for a question
+ """todo: maybe worth trying again. it could have been too slow
+ because of all the calls to the askbot_settings
+
+ returns colorized counter widget for a question
.. versionchanged:: 0.6.6
switched from inclusion tag style to in-code template string
diff --git a/askbot/views/meta.py b/askbot/views/meta.py
index 5942b277..6b2564a4 100644
--- a/askbot/views/meta.py
+++ b/askbot/views/meta.py
@@ -50,11 +50,15 @@ def feedback(request):
form = FeedbackForm(initial={'next':get_next_url(request)})
data['form'] = form
- return render_to_response('feedback.html', data, context_instance=RequestContext(request))
+ context = RequestContext(request, data)
+ template = ENV.get_template('feedback.html')
+ return HttpResponse(template.render(context))
feedback.CANCEL_MESSAGE=_('We look forward to hearing your feedback! Please, give it next time :)')
def privacy(request):
- return render_to_response('privacy.html', {'view_name':'privacy'}, context_instance=RequestContext(request))
+ context = RequestContext(request, {'view_name':'privacy'})
+ template = ENV.get_template('privacy.html')
+ return HttpResponse(template.render(context))
def logout(request):#refactor/change behavior?
#currently you click logout and you get
@@ -64,10 +68,13 @@ def logout(request):#refactor/change behavior?
#however it might be a little annoying
#why not just show a message: you are logged out of forum, but
#if you really want to log out -> go to your openid provider
- return render_to_response('logout.html', {
+ data = {
'view_name':'logout',
'next' : get_next_url(request),
- }, context_instance=RequestContext(request))
+ }
+ context = RequestContext(request, data)
+ template = ENV.get_template('logout.html')
+ return HttpResponse(template.render(context))
def badges(request):#user status/reputation system
badges = Badge.objects.all().order_by('name')
diff --git a/askbot/views/readers.py b/askbot/views/readers.py
index 934be675..73c1b2d0 100644
--- a/askbot/views/readers.py
+++ b/askbot/views/readers.py
@@ -143,14 +143,14 @@ def questions(request):
contributors = Question.objects.get_question_and_answer_contributors(questions.object_list)
paginator_context = {
- 'is_paginated' : True,
+ 'is_paginated' : (objects_list.count > search_state.page_size),
'pages': objects_list.num_pages,
'page': search_state.page,
'has_previous': questions.has_previous(),
'has_next': questions.has_next(),
'previous': questions.previous_page_number(),
'next': questions.next_page_number(),
- 'base_url' : request.path + '?sort=%s&' % search_state.sort,#todo in T sort=>sort_method
+ 'base_url' : request.path + '?sort=%s&amp;' % search_state.sort,#todo in T sort=>sort_method
'page_size' : search_state.page_size,#todo in T pagesize -> page_size
}
@@ -166,6 +166,8 @@ def questions(request):
}
paginator_tpl = loader.get_template('paginator.html')
+ #todo: remove this patch on context after all templates are moved to jinja
+ paginator_context['base_url'] = request.path + '?sort=%s&' % search_state.sort
paginator_html = paginator_tpl.render(
Context(
extra_tags.cnprog_paginator(
@@ -529,7 +531,20 @@ def question(request, id):#refactor - long subroutine. display question body, an
#get response notifications
request.user.visit_question(question)
- return render_to_response('question.html', {
+ paginator_data = {
+ 'is_paginated' : (objects_list.count > ANSWERS_PAGE_SIZE),
+ 'pages': objects_list.num_pages,
+ 'page': page,
+ 'has_previous': page_objects.has_previous(),
+ 'has_next': page_objects.has_next(),
+ 'previous': page_objects.previous_page_number(),
+ 'next': page_objects.next_page_number(),
+ 'base_url' : request.path + '?sort=%s&amp;' % view_id,
+ 'extend_url' : "#sort-top"
+ }
+ paginator_context = extra_tags.cnprog_paginator(paginator_data)
+
+ data = {
'view_name': 'question',
'active_tab': 'questions',
'question' : question,
@@ -542,18 +557,12 @@ def question(request, id):#refactor - long subroutine. display question body, an
'tab_id' : view_id,
'favorited' : favorited,
'similar_questions' : question.get_similar_questions(),
- 'context' : {
- 'is_paginated' : True,
- 'pages': objects_list.num_pages,
- 'page': page,
- 'has_previous': page_objects.has_previous(),
- 'has_next': page_objects.has_next(),
- 'previous': page_objects.previous_page_number(),
- 'next': page_objects.next_page_number(),
- 'base_url' : request.path + '?sort=%s&' % view_id,
- 'extend_url' : "#sort-top"
- }
- }, context_instance=RequestContext(request))
+ 'language_code': translation.get_language(),
+ 'paginator_context' : paginator_context
+ }
+ context = RequestContext(request, data)
+ 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'
diff --git a/askbot/views/writers.py b/askbot/views/writers.py
index 4ef00809..46df6a3d 100644
--- a/askbot/views/writers.py
+++ b/askbot/views/writers.py
@@ -248,13 +248,16 @@ def edit_question(request, id):
revision_form = forms.RevisionForm(question, latest_revision)
form = forms.EditQuestionForm(question, latest_revision)
- return render_to_response('question_edit.html', {
+ data = {
'active_tab': 'questions',
'question': question,
'revision_form': revision_form,
'form' : form,
'tags' : _get_tags_cache_json()
- }, context_instance=RequestContext(request))
+ }
+ context = RequestContext(request, data)
+ template = ENV.get_template('question_edit.html')
+ return HttpResponse(template.render(context))
except exceptions.PermissionDenied, e:
request.user.message_set.create(message = unicode(e))