summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo Fitoria <adolfo.fitoria@gmail.com>2011-10-18 13:27:49 -0300
committerAdolfo Fitoria <adolfo.fitoria@gmail.com>2011-10-18 13:27:49 -0300
commitf15f8789bbf00ed99aa24e2a3a1f402aa4caf830 (patch)
treea5bed0351248013a4e61e96f7177b4e1c9aa2d14
parent522dee8c232d27c7944ec6eac89bc014cc18f2fe (diff)
downloadaskbot-f15f8789bbf00ed99aa24e2a3a1f402aa4caf830.tar.gz
askbot-f15f8789bbf00ed99aa24e2a3a1f402aa4caf830.tar.bz2
askbot-f15f8789bbf00ed99aa24e2a3a1f402aa4caf830.zip
Questions in livesearch are rendered on server side now.
TODO: Fix documentation paths
-rw-r--r--askbot/doc/source/customizing-skin-in-askbot.rst36
-rw-r--r--askbot/skins/common/media/js/live_search.js46
-rw-r--r--askbot/skins/default/templates/main_page/content.html16
-rw-r--r--askbot/skins/default/templates/main_page/questions_loop.html (renamed from askbot/skins/default/templates/main_page/ajax_questions.html)13
-rw-r--r--askbot/views/readers.py22
5 files changed, 44 insertions, 89 deletions
diff --git a/askbot/doc/source/customizing-skin-in-askbot.rst b/askbot/doc/source/customizing-skin-in-askbot.rst
index 125d3b16..92680e52 100644
--- a/askbot/doc/source/customizing-skin-in-askbot.rst
+++ b/askbot/doc/source/customizing-skin-in-askbot.rst
@@ -217,36 +217,36 @@ The general template layout is controlled by a few files described below:
+------------------------------------+------------------------------------------------------+
| two_column_body.html | This is a base layout for two column style pages. |
+------------------------------------+------------------------------------------------------+
-| blocks/answer_edit_tips.html | Contains text displayed as "Answer Edit Tips" in the |
+| widgets/answer_edit_tips.html | Contains text displayed as "Answer Edit Tips" in the |
| | answer edit page. |
+------------------------------------+------------------------------------------------------+
-| blocks/ask_form.html | Contains the form to ask a question. |
+| widgets/ask_form.html | Contains the form to ask a question. |
+------------------------------------+------------------------------------------------------+
-| blocks/bottom_scripts.html | Contains javascript calls and some javascript |
+| widgets/bottom_scripts.html | Contains javascript calls and some javascript |
| | functions needed for askbot this is included at the |
| | bottom of every page. |
+------------------------------------+------------------------------------------------------+
-| blocks/editor_data.html | Contains data necessary for the post editor this is |
+| widgets/editor_data.html | Contains data necessary for the post editor this is |
| | included in block endjs. |
+------------------------------------+------------------------------------------------------+
-| blocks/footer.html | Contains the html displayed on the footer. |
+| widgets/footer.html | Contains the html displayed on the footer. |
+------------------------------------+------------------------------------------------------+
-| blocks/header.html | Contains the header section of the web. Normaly |
+| widgets/header.html | Contains the header section of the web. Normaly |
| | includes the site logo and navitation tools. |
+------------------------------------+------------------------------------------------------+
-| blocks/mandatory_tags_js.html | Javascript functions for mandatory tags. |
+| widgets/mandatory_tags_js.html | Javascript functions for mandatory tags. |
+------------------------------------+------------------------------------------------------+
-| blocks/paginator.html | Renders the paginator in the main page. |
+| widgets/paginator.html | Renders the paginator in the main page. |
+------------------------------------+------------------------------------------------------+
-| blocks/question_edit_tips.html | Contains text displayed as "Question Edit Tips" in |
+| widgets/question_edit_tips.html | Contains text displayed as "Question Edit Tips" in |
| | the question edit page. |
+------------------------------------+------------------------------------------------------+
-| blocks/secondary_header.html | Containter for the search bar section. |
+| widgets/secondary_header.html | Containter for the search bar section. |
+------------------------------------+------------------------------------------------------+
-| blocks/system_messages.html | Containter for notification messages in the top of |
+| widgets/system_messages.html | Containter for notification messages in the top of |
| | the page. |
+------------------------------------+------------------------------------------------------+
-| blocks/user_navigation.html | User links to login/logout. |
+| widgets/user_navigation.html | User links to login/logout. |
+------------------------------------+------------------------------------------------------+
Widgets
@@ -258,7 +258,7 @@ widgets folder and are called from several places in the templates.
+----------------------------+------------------------------+--------------------------------+
| Widget name | Used in | Description |
+============================+==============================+================================+
-| ask_button.html | blocks/secondary_header.html | Just the "ask a question" |
+| ask_button.html | widgets/secondary_header.html | Just the "ask a question" |
| | | button |
+----------------------------+------------------------------+--------------------------------+
| answer_controls.html | question.html | Answer operation links, edit |
@@ -267,11 +267,11 @@ widgets folder and are called from several places in the templates.
| contributors.html | main_page/sidebar.html | Widget to display contributors |
| | | avatars. |
+----------------------------+------------------------------+--------------------------------+
-| logo.html | blocks/header.html | Contains the site logo. |
+| logo.html | widgets/header.html | Contains the site logo. |
+----------------------------+------------------------------+--------------------------------+
-| main_menu.html | blocks/secondary_header.html | Contains the main menu html |
+| main_menu.html | widgets/secondary_header.html| Contains the main menu html |
+----------------------------+------------------------------+--------------------------------+
-| meta_nav.html | blocks/header.html | Widget for the me logo. |
+| meta_nav.html | widgets/header.html | Widget for the me logo. |
+----------------------------+------------------------------+--------------------------------+
| question_controls.html | question.html | Question operation links, edit |
| | | report as spam and more. |
@@ -281,7 +281,7 @@ widgets folder and are called from several places in the templates.
| related_tags.html | main_page/sidebar.html | Question operation links, edit |
| | | report as spam and more. |
+----------------------------+------------------------------+--------------------------------+
-| search_bar.html | blocks/secondary_header.html | Contains the search bar. |
+| search_bar.html | widgets/secondary_header.html| Contains the search bar. |
+----------------------------+------------------------------+--------------------------------+
| share_buttons.html | question.html | Widget to show the social |
| | | sharing buttons. |
@@ -289,7 +289,7 @@ widgets folder and are called from several places in the templates.
| tag_selector.html | main_page/sidebar.html | Contains the tag selector for |
| | | search. |
+----------------------------+------------------------------+--------------------------------+
-| user_navigation.html | blocks/header.html | User navigation links like |
+| user_navigation.html | widgets/header.html | User navigation links like |
| | | login, logout. |
+----------------------------+------------------------------+--------------------------------+
diff --git a/askbot/skins/common/media/js/live_search.js b/askbot/skins/common/media/js/live_search.js
index cf56328f..b9db65bb 100644
--- a/askbot/skins/common/media/js/live_search.js
+++ b/askbot/skins/common/media/js/live_search.js
@@ -206,45 +206,6 @@ var liveSearch = function(){
return tags_html;
};
- var render_question = function(question){
- var entry_html =
- '<div class="short-summary">' +
- '<div class="counts">' +
- render_counter(
- question['views'],
- question['views_word'],
- 'views',
- question['views_class']
- ) +
- render_counter(
- question['answers'],
- question['answers_word'],
- 'answers',
- question['answers_class']
- ) +
- render_counter(
- question['votes'],
- question['votes_word'],
- 'votes',
- question['votes_class']
- ) +
- '<div style="clear:both"></div>' +
- render_user_info(question) +
- '</div>' +
- render_title(question) +
- render_tags(question['tags'], true, false) +
- '</div>';
- return entry_html;
- };
-
- var render_question_list = function(questions){
- var output = '';
- for (var i=0; i<questions.length; i++){
- output += render_question(questions[i]);
- }
- return output;
- };
-
var render_faces = function(faces){
if (faces.length === 0){
return;
@@ -427,15 +388,12 @@ var liveSearch = function(){
};
var render_main_page_result = function(data, text_status, xhr){
- var start_date = new Date();
- var epoc_time = start_date.getTime();
- console.debug(epoc_time);
var old_list = $('#' + q_list_sel);
var new_list = $('<div></div>').hide();
if (data['questions'].length > 0){
old_list.stop(true);
- new_list.html(render_question_list(data['questions']));
+ new_list.html(data['questions']);
//old_list.hide();
old_list.after(new_list);
//old_list.remove();
@@ -456,8 +414,6 @@ var liveSearch = function(){
new_list.fadeIn(400);
});
}
- var end_date = new Date();
- console.debug(end_date.getTime() - epoc_time);
}
var try_again = function(){
diff --git a/askbot/skins/default/templates/main_page/content.html b/askbot/skins/default/templates/main_page/content.html
index 9b00e63b..07a50c77 100644
--- a/askbot/skins/default/templates/main_page/content.html
+++ b/askbot/skins/default/templates/main_page/content.html
@@ -1,17 +1,3 @@
-{% import "macros.html" as macros %}
<div id="question-list">
-{% cache 0 "questions" questions search_tags scope sort query context.page context.page_size language_code %}
- {% for question in questions.object_list %}
- {{macros.question_summary(question)}}
- {% endfor %}
-{% endcache %}
-{# comment todo: fix css here #}
-{% if questions_count == 0 %}
- {% include "main_page/nothing_found.html" %}
-{% else %}
- <div class="evenMore">
- {% trans %}Did not find what you were looking for?{% endtrans %}
- <a href="{% url ask %}">{% trans %}Please, post your question!{% endtrans %}</a>
- </div>
-{% endif %}
+ {% include "main_page/questions_loop.html" %}
</div>
diff --git a/askbot/skins/default/templates/main_page/ajax_questions.html b/askbot/skins/default/templates/main_page/questions_loop.html
index d00ed19f..1a920516 100644
--- a/askbot/skins/default/templates/main_page/ajax_questions.html
+++ b/askbot/skins/default/templates/main_page/questions_loop.html
@@ -5,7 +5,12 @@
{% endfor %}
{% endcache %}
{# comment todo: fix css here #}
-<div class="evenMore">
- {% trans %}Did not find what you were looking for?{% endtrans %}
- <a href="{% url ask %}">{% trans %}Please, post your question!{% endtrans %}</a>
-</div>
+{% if questions_count == 0 %}
+ {% include "main_page/nothing_found.html" %}
+{% else %}
+ <div class="evenMore">
+ {% trans %}Did not find what you were looking for?{% endtrans %}
+ <a href="{% url ask %}">{% trans %}Please, post your question!{% endtrans %}</a>
+ </div>
+{% endif %}
+
diff --git a/askbot/views/readers.py b/askbot/views/readers.py
index 92addc29..eabef3c8 100644
--- a/askbot/views/readers.py
+++ b/askbot/views/readers.py
@@ -144,11 +144,12 @@ def questions(request):
}
if q_count > search_state.page_size:
- paginator_tpl = get_template('blocks/paginator.html', request)
+ paginator_tpl = get_template('main_page/paginator.html', request)
#todo: remove this patch on context after all templates are moved to jinja
paginator_context['base_url'] = request.path + '?sort=%s&' % search_state.sort
data = {
- 'paginator_context': extra_tags.cnprog_paginator(paginator_context)
+ 'context': extra_tags.cnprog_paginator(paginator_context),
+ 'questions_count': q_count
}
paginator_html = paginator_tpl.render(Context(data))
else:
@@ -195,13 +196,20 @@ def questions(request):
for contributor in contributors:
ajax_data['faces'].append(extra_tags.gravatar(contributor, 48))
- import time
- start_time = time.time()
#we render the template
#from django.template import RequestContext
- partial_template = render_into_skin('main_page/ajax_questions.html', {'questions': page}, request)
- ajax_data['rendered_questions'] = partial_template
- print time.time() - start_time
+ questions_tpl = get_template('main_page/questions_loop.html', request)
+ #todo: remove this patch on context after all templates are moved to jinja
+ data = {
+ 'questions': page,
+ 'questions_count': q_count,
+ 'context': paginator_context,
+ 'language_code': translation.get_language(),
+ 'query': search_state.query,
+ }
+
+ questions_html = questions_tpl.render(Context(data))
+ ajax_data['questions'] = questions_html.replace('\n','')
return HttpResponse(
simplejson.dumps(ajax_data),
mimetype = 'application/json'