summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-06-28 20:06:45 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-06-28 20:06:45 -0400
commit83a9206d4d551855495803d370967e4fadb34fff (patch)
treee89ae4ba9786654f27529ea49db431e0271d1bae
parent8eeaf1641d32993d0cb94c65127e7a80356ab3d2 (diff)
downloadaskbot-83a9206d4d551855495803d370967e4fadb34fff.tar.gz
askbot-83a9206d4d551855495803d370967e4fadb34fff.tar.bz2
askbot-83a9206d4d551855495803d370967e4fadb34fff.zip
inlined questions_list template into questions.html
-rw-r--r--README.rst (renamed from README)4
-rw-r--r--askbot/skins/default/templates/questions.html19
-rw-r--r--askbot/templatetags/extra_tags.py23
-rw-r--r--askbot/utils/colors.py2
-rw-r--r--askbot/views/readers.py6
5 files changed, 47 insertions, 7 deletions
diff --git a/README b/README.rst
index 1d9862dc..71482454 100644
--- a/README
+++ b/README.rst
@@ -1,3 +1,7 @@
+===================
+Askbot - Q&A forum
+===================
+
This is Askbot project - open source Q&A system, like StackOverflow, Yahoo Answers and some others
Demo site is http://askbot.org
diff --git a/askbot/skins/default/templates/questions.html b/askbot/skins/default/templates/questions.html
index a3c1ca1c..4db8cca8 100644
--- a/askbot/skins/default/templates/questions.html
+++ b/askbot/skins/default/templates/questions.html
@@ -175,7 +175,26 @@
<div id="listA">
{% get_current_language as LANGUAGE_CODE %}
{% cache 600 questions search_tags scope sort query context.page context.page_size LANGUAGE_CODE %}
+ {% comment %}
{% include "question_list.html" %}
+ {% endcomment %}
+ {% for question in questions.object_list %}
+ <div class="short-summary">
+ {% question_counter_widget question %}
+ <h2><a title="{{question.summary}}" href="{% url question id=question.id %}{{question.title|slugify}}">{{question.title}}</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 %}
+ &nbsp;<a href="{% url user_profile question.last_activity_by.id question.last_activity_by.username|slugify %}">{{ question.last_activity_by }}</a>&nbsp;{% get_score_badge question.last_activity_by %}
+ {% endif %}
+ </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>
+ {% endfor %}
+ </div>
+ </div>
+ {% endfor %}
{% endcache %}
{% comment %}todo: fix css here{% endcomment %}
{% if questions_count == 0 %}
diff --git a/askbot/templatetags/extra_tags.py b/askbot/templatetags/extra_tags.py
index 4a7367bc..ebe6dc7f 100644
--- a/askbot/templatetags/extra_tags.py
+++ b/askbot/templatetags/extra_tags.py
@@ -20,6 +20,7 @@ from django.core.urlresolvers import reverse
from askbot import skins
from askbot.utils import colors
from askbot.utils.functions import get_from_dict_or_object
+from askbot.templatetags import extra_filters
register = template.Library()
@@ -471,13 +472,18 @@ def fullmedia(url):
path = media(url)
return "%s%s" % (domain, path)
-@register.inclusion_tag("question_counter_widget.html")
+@register.inclusion_tag('question_counter_widget.html') #too slow
def question_counter_widget(question):
+ """returns colorized counter widget for a question
- view_count = get_from_dict_or_object(question,'view_count')
- answer_count = get_from_dict_or_object(question,'answer_count')
- vote_count = get_from_dict_or_object(question,'score')
- answer_accepted = get_from_dict_or_object(question,'answer_accepted')
+ .. versionchanged:: 0.6.6
+ switched from inclusion tag style to in-code template string
+ for the better speed of the front page rendering
+ """
+ view_count = get_from_dict_or_object(question, 'view_count')
+ answer_count = get_from_dict_or_object(question, 'answer_count')
+ vote_count = get_from_dict_or_object(question, 'score')
+ answer_accepted = get_from_dict_or_object(question, 'answer_accepted')
#background and foreground colors for each item
(views_fg, views_bg) = colors.get_counter_colors(
@@ -490,6 +496,8 @@ def question_counter_widget(question):
max_bg = askbot_settings.COLORS_VIEW_COUNTER_MAX_BG,
max_fg = askbot_settings.COLORS_VIEW_COUNTER_MAX_FG,
)
+ #views_fg = askbot_settings.COLORS_VIEW_COUNTER_EMPTY_FG
+ #views_bg = askbot_settings.COLORS_VIEW_COUNTER_EMPTY_BG
(answers_fg, answers_bg) = colors.get_counter_colors(
answer_count,
@@ -501,6 +509,8 @@ def question_counter_widget(question):
max_bg = askbot_settings.COLORS_ANSWER_COUNTER_MAX_BG,
max_fg = askbot_settings.COLORS_ANSWER_COUNTER_MAX_FG,
)
+ #answers_fg = askbot_settings.COLORS_ANSWER_COUNTER_EMPTY_FG
+ #answers_bg = askbot_settings.COLORS_ANSWER_COUNTER_EMPTY_BG
if answer_accepted:
#todo: maybe recalculate the foreground color too
answers_bg = askbot_settings.COLORS_ANSWER_COUNTER_ACCEPTED_BG
@@ -516,8 +526,9 @@ def question_counter_widget(question):
max_bg = askbot_settings.COLORS_VOTE_COUNTER_MAX_BG,
max_fg = askbot_settings.COLORS_VOTE_COUNTER_MAX_FG,
)
+ votes_fg = askbot_settings.COLORS_VOTE_COUNTER_EMPTY_FG
+ votes_fg = askbot_settings.COLORS_VOTE_COUNTER_EMPTY_BG
- #returns a dictionary with keys like 'votes_bg', etc
return locals()
class IsManyNode(template.Node):
diff --git a/askbot/utils/colors.py b/askbot/utils/colors.py
index 7385d06c..9ca8ba70 100644
--- a/askbot/utils/colors.py
+++ b/askbot/utils/colors.py
@@ -1,6 +1,8 @@
from askbot.deps.grapefruit import Color
+import keyedcache
import math
+@keyedcache.cache_function(length=6000)
def get_counter_colors(count, counter_max=10, empty_bg='white', empty_fg='black',
zero_bg='white', zero_fg='black',
min_bg='white', min_fg='black',
diff --git a/askbot/views/readers.py b/askbot/views/readers.py
index 592f8bd5..a0ac867c 100644
--- a/askbot/views/readers.py
+++ b/askbot/views/readers.py
@@ -140,7 +140,8 @@ def questions(request):
contributors = Question.objects.get_question_and_answer_contributors(questions.object_list)
#todo: organize variables by type
- return render_to_response('questions.html', {
+ before = datetime.datetime.now()
+ output = render_to_response('questions.html', {
'view_name': 'questions',
'active_tab': 'questions',
'questions' : questions,
@@ -168,6 +169,9 @@ def questions(request):
'base_url' : request.path + '?sort=%s&' % search_state.sort,#todo in T sort=>sort_method
'page_size' : search_state.page_size,#todo in T pagesize -> page_size
}}, context_instance=RequestContext(request))
+ after = datetime.datetime.now()
+ print 'time to render %s' % (after - before)
+ return output
def search(request): #generates listing of questions matching a search query - including tags and just words
"""redirects to people and tag search pages