From 83a9206d4d551855495803d370967e4fadb34fff Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Mon, 28 Jun 2010 20:06:45 -0400 Subject: inlined questions_list template into questions.html --- README | 10 ---------- README.rst | 14 ++++++++++++++ askbot/skins/default/templates/questions.html | 19 +++++++++++++++++++ askbot/templatetags/extra_tags.py | 23 +++++++++++++++++------ askbot/utils/colors.py | 2 ++ askbot/views/readers.py | 6 +++++- 6 files changed, 57 insertions(+), 17 deletions(-) delete mode 100644 README create mode 100644 README.rst diff --git a/README b/README deleted file mode 100644 index 1d9862dc..00000000 --- a/README +++ /dev/null @@ -1,10 +0,0 @@ -This is Askbot project - open source Q&A system, like StackOverflow, Yahoo Answers and some others - -Demo site is http://askbot.org - -All documentation is in the directory askbot/doc - -askbot-devel repository is open to anyone who wants to help develop Askbot - just drop us a note - -Askbot is based on code of CNPROG, originally created by Mike Chen -and Sailing Cai and some code written for OSQA diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..71482454 --- /dev/null +++ b/README.rst @@ -0,0 +1,14 @@ +=================== +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 + +All documentation is in the directory askbot/doc + +askbot-devel repository is open to anyone who wants to help develop Askbot - just drop us a note + +Askbot is based on code of CNPROG, originally created by Mike Chen +and Sailing Cai and some code written for OSQA 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 @@
{% 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 %} +
+ {% question_counter_widget question %} +

{{question.title}}

+
+ {% diff_date question.last_activity_at %} + {% if question.last_activity_by %} +  {{ question.last_activity_by }} {% get_score_badge question.last_activity_by %} + {% endif %} +
+
+ {% for tag in question.tagname_list %} + + {% endfor %} +
+
+ {% 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 -- cgit v1.2.3-1-g7c22