From 83eae49326617638c01edca77c2adabbe3456b39 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Thu, 27 Jan 2011 21:51:47 -0500 Subject: split main page into blocks --- askbot/skins/default/media/js/live_search.js | 2 +- askbot/skins/default/templates/main_page.html | 24 ++ .../skins/default/templates/main_page/content.html | 17 ++ .../default/templates/main_page/headline.html | 50 ++++ .../default/templates/main_page/javascript.html | 27 +++ .../default/templates/main_page/nothing_found.html | 31 +++ .../default/templates/main_page/paginator.html | 7 + .../skins/default/templates/main_page/sidebar.html | 35 +++ .../skins/default/templates/main_page/tab_bar.html | 86 +++++++ askbot/skins/default/templates/questions.html | 259 --------------------- askbot/tests/page_load_tests.py | 31 ++- askbot/views/readers.py | 2 +- 12 files changed, 292 insertions(+), 279 deletions(-) create mode 100644 askbot/skins/default/templates/main_page.html create mode 100644 askbot/skins/default/templates/main_page/content.html create mode 100644 askbot/skins/default/templates/main_page/headline.html create mode 100644 askbot/skins/default/templates/main_page/javascript.html create mode 100644 askbot/skins/default/templates/main_page/nothing_found.html create mode 100644 askbot/skins/default/templates/main_page/paginator.html create mode 100644 askbot/skins/default/templates/main_page/sidebar.html create mode 100644 askbot/skins/default/templates/main_page/tab_bar.html delete mode 100644 askbot/skins/default/templates/questions.html diff --git a/askbot/skins/default/media/js/live_search.js b/askbot/skins/default/media/js/live_search.js index 965002f9..57621cd1 100644 --- a/askbot/skins/default/media/js/live_search.js +++ b/askbot/skins/default/media/js/live_search.js @@ -3,7 +3,7 @@ $(document).ready(function(){ var query = $('input#keywords'); var prev_text = $.trim(query.val()); var running = false; - var q_list_sel = 'listA';//id of question listing div + var q_list_sel = 'question-list';//id of question listing div var refresh_x_button = function(){ if ($.trim(query.val()).length > 0){ diff --git a/askbot/skins/default/templates/main_page.html b/askbot/skins/default/templates/main_page.html new file mode 100644 index 00000000..d0cddc68 --- /dev/null +++ b/askbot/skins/default/templates/main_page.html @@ -0,0 +1,24 @@ +{% extends "two_column_body.html" %} +{# + this template is split into several + blocks that are included here + the blocks are within directory templates/main_page + relative to the skin directory + + there is no html markup in this file +#} + +{% block title %}{% spaceless %}{% trans %}Questions{% endtrans %}{% endspaceless %}{% endblock %} +{% block content %} + {% include "main_page/tab_bar.html" %} + {% include "main_page/headline.html" %} + {% include "main_page/content.html" %} + {% include "main_page/paginator.html" %} +{% endblock %} +{% block sidebar %} + {% include "main_page/sidebar.html" %} +{% endblock %} +{% block endjs %} + {% include "main_page/javascript.html" %} +{% endblock %} + diff --git a/askbot/skins/default/templates/main_page/content.html b/askbot/skins/default/templates/main_page/content.html new file mode 100644 index 00000000..72128cdc --- /dev/null +++ b/askbot/skins/default/templates/main_page/content.html @@ -0,0 +1,17 @@ +{% import "macros.html" as macros %} +
+{% 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 %} +

+ {% trans %}Did not find what you were looking for?{% endtrans %} + {% trans %}Please, post your question!{% endtrans %} +

+{% endif %} +
diff --git a/askbot/skins/default/templates/main_page/headline.html b/askbot/skins/default/templates/main_page/headline.html new file mode 100644 index 00000000..ec6944d6 --- /dev/null +++ b/askbot/skins/default/templates/main_page/headline.html @@ -0,0 +1,50 @@ +{% if questions_count > 0 %} +
+

+ ({% trans %}rss feed{% endtrans %}) +

+

+ {% if search_tags %} + {% trans cnt=questions_count, q_num=questions_count|intcomma %}{{q_num}} question, tagged{% pluralize %}{{q_num}} questions, tagged{% 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 %} +

+ {% spaceless %} +
+ {% if search_tags %} + {% for tag in search_tags %} + {{tag}} + + {% endfor %} + {% endif %} +
+ {% endspaceless %} + {% if author_name or search_tags or query %} +

{% trans %}Search tips:{% endtrans %} + {% if reset_method_count > 1 %} + {% if author_name %} + {% trans %}reset author{% endtrans %} + {% endif %} + {% if search_tags %}{% if author_name and query %}, {% elif author_name %}{% trans %} or {% endtrans %}{% endif %} + {% trans %}reset tags{% endtrans %} + {% endif %} + {% if query %}{% trans %} or {% endtrans %} + {% trans %}start over{% endtrans %} + {% endif %} + {% else %} + {% trans %}start over{% endtrans %} + {% endif %} + {% trans %} - to expand, or dig in by adding more tags and revising the query.{% endtrans %} +

+ {% else %} +

{% trans %}Search tip:{% endtrans %} {% trans %}add tags and a query to focus your search{% endtrans %}

+ {% endif %} +
+{% endif %} diff --git a/askbot/skins/default/templates/main_page/javascript.html b/askbot/skins/default/templates/main_page/javascript.html new file mode 100644 index 00000000..4f123004 --- /dev/null +++ b/askbot/skins/default/templates/main_page/javascript.html @@ -0,0 +1,27 @@ + + +{% if request.user.is_authenticated() %} + +{% endif %} + diff --git a/askbot/skins/default/templates/main_page/nothing_found.html b/askbot/skins/default/templates/main_page/nothing_found.html new file mode 100644 index 00000000..bc58fc27 --- /dev/null +++ b/askbot/skins/default/templates/main_page/nothing_found.html @@ -0,0 +1,31 @@ +{# todo: add tips to widen selection #} +

+{% 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 %} +

+{% if query or search_tags or author_name %} +

+ {% trans %}You can expand your search by {% endtrans %} + {% if reset_method_count > 1 %} + {% if author_name %} + {% trans %}resetting author{% endtrans %} + {% endif %} + {% if search_tags %}{% if author_name and query %}, {% elif author_name %}{% trans %} or {% endtrans %}{% endif %} + {% trans %}resetting tags{% endtrans %} + {% endif %} + {% if query %}{% trans %} or {% endtrans %} + {% trans %}starting over{% endtrans %} + {% endif %} + {% else %} + {% trans %}starting over{% endtrans %} + {% endif %} +

+{% endif %} +

+{% trans %}Please always feel free to ask your question!{% endtrans %} +

diff --git a/askbot/skins/default/templates/main_page/paginator.html b/askbot/skins/default/templates/main_page/paginator.html new file mode 100644 index 00000000..4a77060f --- /dev/null +++ b/askbot/skins/default/templates/main_page/paginator.html @@ -0,0 +1,7 @@ +{% import "macros.html" as macros %} +{% if questions_count > 10 %}{# todo: remove magic number #} +
+ {{ macros.paginator(context|setup_paginator, position='left') }} + {{ macros.pagesize_switch(context, position='right') }} +
+{% endif %} diff --git a/askbot/skins/default/templates/main_page/sidebar.html b/askbot/skins/default/templates/main_page/sidebar.html new file mode 100644 index 00000000..5ea9af4f --- /dev/null +++ b/askbot/skins/default/templates/main_page/sidebar.html @@ -0,0 +1,35 @@ +{% import "macros.html" as macros %} +{% if contributors %} + {% cache 600 "contributors" contributors search_tags scope sort query context.page context.page_size language_code %} +
+

{% trans %}Contributors{% endtrans %}

+ {% spaceless %} + {% for person in contributors %} + {{ macros.gravatar(person,48) }} + {% endfor %} + {% endspaceless %} +
+ {% endcache %} +{% endif %} + +{% if request.user.is_authenticated() %} + {% include "blocks/tag_selector.html" %} +{% endif %} + +{% if tags %} + {% cache 0 "tags" tags search_tags scope sort query context.page context.page_size language_code %} +
+

{% trans %}Related tags{% endtrans %}

+ +
+ {% endcache %} +{% endif %} diff --git a/askbot/skins/default/templates/main_page/tab_bar.html b/askbot/skins/default/templates/main_page/tab_bar.html new file mode 100644 index 00000000..2921da88 --- /dev/null +++ b/askbot/skins/default/templates/main_page/tab_bar.html @@ -0,0 +1,86 @@ +{% import "macros.html" as macros %} +{% cache 600 "scope_sort_tabs" search_tags request.user scope sort query context.page context.page_size language_code %} +
+
+ {% trans %}In:{% endtrans %} + {% trans %}all{% endtrans %} + {% trans %}unanswered{% endtrans %} + {% if request.user.is_authenticated() %} + {% trans %}favorite{% endtrans %} + {% endif %} +
+
+ {% trans %}Sort by:{% endtrans %} + {% if show_sort_by_relevance %} + {% set asc_relevance_tooltip = _('most relevant questions') %} + {% set desc_relevance_tooltip = _('click to see most relevant questions') %} + {% set relevance_label = _('relevance') %} + {% if query %} + {{relevance_label}} ▼ + {% else %} + href="?sort=relevance-desc" + class="off" + title="{{desc_relevance_tooltip}}">{{relevance_label}} + {% endif %} + + {% endif %} + + {% endif %} + {{macros.reversible_sort_button( + button_sort_criterium = 'age', + label = _('by date'), + asc_tooltip = _('click to see the oldest questions'), + desc_tooltip = _('click to see the newest questions'), + current_sort_method = sort + ) + }} + {{macros.reversible_sort_button( + button_sort_criterium = 'activity', + label = _('by activity'), + asc_tooltip = _('click to see the least recently updated questions'), + desc_tooltip = _('click to see the most recently updated questions'), + current_sort_method = sort + ) + }} + {{macros.reversible_sort_button( + button_sort_criterium = 'answers', + label = _('by answers'), + asc_tooltip = _('click to see the least answered questions'), + desc_tooltip = _('click to see the most answered questions'), + current_sort_method = sort + ) + }} + {{macros.reversible_sort_button( + button_sort_criterium = 'votes', + label = _('by votes'), + asc_tooltip = _('click to see least voted questions'), + desc_tooltip = _('click to see most voted questions'), + current_sort_method = sort + ) + }} +
+
+{% endcache %} diff --git a/askbot/skins/default/templates/questions.html b/askbot/skins/default/templates/questions.html deleted file mode 100644 index 138b30c8..00000000 --- a/askbot/skins/default/templates/questions.html +++ /dev/null @@ -1,259 +0,0 @@ -{% extends "two_column_body.html" %} - -{% import "macros.html" as macros %} -{% block title %}{% spaceless %}{% trans %}Questions{% endtrans %}{% endspaceless %}{% endblock %} -{% block content %} -{% cache 600 "scope_sort_tabs" search_tags request.user scope sort query context.page context.page_size language_code %} -
-
- {% trans %}In:{% endtrans %} - {% trans %}all{% endtrans %} - {% trans %}unanswered{% endtrans %} - {% if request.user.is_authenticated() %} - {% trans %}favorite{% endtrans %} - {% endif %} -
-
- {% trans %}Sort by:{% endtrans %} - {% if show_sort_by_relevance %} - {% set asc_relevance_tooltip = _('most relevant questions') %} - {% set desc_relevance_tooltip = _('click to see most relevant questions') %} - {% set relevance_label = _('relevance') %} - {% if query %} - {{relevance_label}} ▼ - {% else %} - href="?sort=relevance-desc" - class="off" - title="{{desc_relevance_tooltip}}">{{relevance_label}} - {% endif %} - - {% endif %} - - {% endif %} - {{macros.reversible_sort_button( - button_sort_criterium = 'age', - label = _('by date'), - asc_tooltip = _('click to see the oldest questions'), - desc_tooltip = _('click to see the newest questions'), - current_sort_method = sort - ) - }} - {{macros.reversible_sort_button( - button_sort_criterium = 'activity', - label = _('by activity'), - asc_tooltip = _('click to see the least recently updated questions'), - desc_tooltip = _('click to see the most recently updated questions'), - current_sort_method = sort - ) - }} - {{macros.reversible_sort_button( - button_sort_criterium = 'answers', - label = _('by answers'), - asc_tooltip = _('click to see the least answered questions'), - desc_tooltip = _('click to see the most answered questions'), - current_sort_method = sort - ) - }} - {{macros.reversible_sort_button( - button_sort_criterium = 'votes', - label = _('by votes'), - asc_tooltip = _('click to see least voted questions'), - desc_tooltip = _('click to see most voted questions'), - current_sort_method = sort - ) - }} -
-
-{% endcache %} -{% if questions_count > 0 %} -
-

- ({% trans %}rss feed{% endtrans %}) -

-

- {% if search_tags %} - {% trans cnt=questions_count, q_num=questions_count|intcomma %}{{q_num}} question, tagged{% pluralize %}{{q_num}} questions, tagged{% 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 %} -

- {% spaceless %} -
- {% if search_tags %} - {% for tag in search_tags %} - {{tag}} - - {% endfor %} - {% endif %} -
- {% endspaceless %} - {% if author_name or search_tags or query %} -

{% trans %}Search tips:{% endtrans %} - {% if reset_method_count > 1 %} - {% if author_name %} - {% trans %}reset author{% endtrans %} - {% endif %} - {% if search_tags %}{% if author_name and query %}, {% elif author_name %}{% trans %} or {% endtrans %}{% endif %} - {% trans %}reset tags{% endtrans %} - {% endif %} - {% if query %}{% trans %} or {% endtrans %} - {% trans %}start over{% endtrans %} - {% endif %} - {% else %} - {% trans %}start over{% endtrans %} - {% endif %} - {% trans %} - to expand, or dig in by adding more tags and revising the query.{% endtrans %} -

- {% else %} -

{% trans %}Search tip:{% endtrans %} {% trans %}add tags and a query to focus your search{% endtrans %}

- {% endif %} -
-{% endif %} -
-{% 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 %} - {# todo: add tips to widen selection #} -

- {% 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 %} -

- {% if query or search_tags or author_name %} -

- {% trans %}You can expand your search by {% endtrans %} - {% if reset_method_count > 1 %} - {% if author_name %} - {% trans %}resetting author{% endtrans %} - {% endif %} - {% if search_tags %}{% if author_name and query %}, {% elif author_name %}{% trans %} or {% endtrans %}{% endif %} - {% trans %}resetting tags{% endtrans %} - {% endif %} - {% if query %}{% trans %} or {% endtrans %} - {% trans %}starting over{% endtrans %} - {% endif %} - {% else %} - {% trans %}starting over{% endtrans %} - {% endif %} -

- {% endif %} -

- {% trans %}Please always feel free to ask your question!{% endtrans %} -

- {% else %} -

- {% trans %}Did not find what you were looking for?{% endtrans %} - {% trans %}Please, post your question!{% endtrans %} -

- {% endif %} -
-{% if questions_count > 10 %}{# todo: remove magic number #} -
- {{ macros.paginator(context|setup_paginator, position='left') }} - {{ macros.pagesize_switch(context, position='right') }} -
-{% endif %} -{% endblock %} -{% block sidebar %} - {% if contributors %} - {% cache 600 "contributors" contributors search_tags scope sort query context.page context.page_size language_code %} -
-

{% trans %}Contributors{% endtrans %}

- {% spaceless %} - {% for person in contributors %} - {{ macros.gravatar(person,48) }} - {% endfor %} - {% endspaceless %} -
- {% endcache %} - {% endif %} - - {% if request.user.is_authenticated() %} - {% include "blocks/tag_selector.html" %} - {% endif %} - - {% if tags %} - {% cache 0 "tags" tags search_tags scope sort query context.page context.page_size language_code %} -
-

{% trans %}Related tags{% endtrans %}

- -
- {% endcache %} - {% endif %} -{% endblock %} -{% block endjs %} - - - {% if request.user.is_authenticated() %} - - {% endif %} - -{% endblock %} - diff --git a/askbot/tests/page_load_tests.py b/askbot/tests/page_load_tests.py index a4ef2547..33bcf933 100644 --- a/askbot/tests/page_load_tests.py +++ b/askbot/tests/page_load_tests.py @@ -56,7 +56,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.html') + self.assertEquals(response.template.name, 'main_page.html') def proto_test_non_user_urls(self): """test all reader views thoroughly @@ -82,67 +82,62 @@ class PageLoadTests(PageLoadTestCase): #todo: test different sort methods and scopes self.try_url( 'questions', - template='questions.html' + template='main_page.html' ) self.try_url( 'questions', data={'start_over':'true'}, - template='questions.html' + template='main_page.html' ) self.try_url( 'questions', data={'scope':'unanswered'}, - template='questions.html' - ) - self.try_url( - 'questions', - data={'scope':'all'}, - template='questions.html' + template='main_page.html' ) self.try_url( 'questions', data={'scope':'favorite'}, - template='questions.html' + template='main_page.html' ) self.try_url( 'questions', data={'scope':'unanswered', 'sort':'age-desc'}, - template='questions.html' + template='main_page.html' ) self.try_url( 'questions', data={'scope':'unanswered', 'sort':'age-asc'}, - template='questions.html' + template='main_page.html' ) self.try_url( 'questions', data={'scope':'unanswered', 'sort':'activity-desc'}, - template='questions.html' + template='main_page.html' ) self.try_url( 'questions', data={'scope':'unanswered', 'sort':'activity-asc'}, - template='questions.html' + template='main_page.html' ) self.try_url( 'questions', data={'sort':'answers-desc'}, - template='questions.html' + template='main_page.html' ) self.try_url( 'questions', data={'sort':'answers-asc'}, - template='questions.html' + template='main_page.html' ) self.try_url( 'questions', data={'sort':'votes-desc'}, - template='questions.html' + template='main_page.html' ) self.try_url( 'questions', data={'sort':'votes-asc'}, - template='questions.html' + template='main_page.html' ) self.try_url( 'question', diff --git a/askbot/views/readers.py b/askbot/views/readers.py index 27fbfe78..a2f5584c 100644 --- a/askbot/views/readers.py +++ b/askbot/views/readers.py @@ -302,7 +302,7 @@ def questions(request): #ajax request is handled in a separate branch above #before = datetime.datetime.now() - template = ENV.get_template('questions.html') + template = ENV.get_template('main_page.html') response = HttpResponse(template.render(template_context)) #after = datetime.datetime.now() #print after - before -- cgit v1.2.3-1-g7c22