From fc26a4b3eaf68e2880a1d70fcd2b27f54f3de394 Mon Sep 17 00:00:00 2001 From: rick Date: Tue, 11 May 2010 02:15:57 +0000 Subject: [PATCH] Support for two new blocks of optional, user-defined sidebar content. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@209 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/settings/sidebar.py | 25 +++++++++---------- forum/skins/default/templates/questions.html | 4 +++ .../templates/sidebar/user_blocks.html | 9 +++++++ forum/templatetags/general_sidebar_tags.py | 19 +++++++++++++- 4 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 forum/skins/default/templates/sidebar/user_blocks.html diff --git a/forum/settings/sidebar.py b/forum/settings/sidebar.py index 179229f..394466b 100644 --- a/forum/settings/sidebar.py +++ b/forum/settings/sidebar.py @@ -1,39 +1,38 @@ from base import Setting, SettingSet from django.forms.widgets import Textarea -SIDEBAR_SET = SettingSet('sidebar', 'Sidebar content', "Enter contents to display in the sidebar. You can use markdown and some basic html tags.", 1000, True) +SIDEBAR_SET = SettingSet('sidebar', 'Sidebar content', "Enter contents to display in the sidebar. You can use markdown and some basic html tags.", 10, True) SIDEBAR_UPPER_SHOW = Setting('SIDEBAR_UPPER_SHOW', False, SIDEBAR_SET, dict( -label = "Include Upper Sidebar Block", -help_text = "Check if your pages should include the upper sidebar block.", +label = "Show Upper Block", +help_text = "Check if your pages should display the upper sidebar block.", required=False)) SIDEBAR_UPPER_TEXT = Setting('SIDEBAR_UPPER_TEXT', u""" -## Host your own OSQA at WebFaction +## [Try WebFaction](http://www.webfaction.com?affiliate=osqa) -We recommend WebFaction for hosting OSQA. Their affordable, -reliable servers have everything you need! +We recommend [**WebFaction**](http://www.webfaction.com?affiliate=osqa) +for hosting OSQA. Their affordable, reliable servers have everything you need! """, SIDEBAR_SET, dict( -label = "Sidebar (Upper)", +label = "Upper Block Content", help_text = " The upper sidebar block. ", widget=Textarea(attrs={'rows': '10'}))) SIDEBAR_LOWER_SHOW = Setting('SIDEBAR_LOWER_SHOW', False, SIDEBAR_SET, dict( -label = "Include Lower Sidebar Block", -help_text = "Check if your pages should include the lower sidebar block.", +label = "Show Lower Block", +help_text = "Check if your pages should display the lower sidebar block.", required=False)) - SIDEBAR_LOWER_TEXT = Setting('SIDEBAR_LOWER_TEXT', u""" ## Learn more about OSQA -The OSQA website and wiki are also great resources to help you -learn more about the OSQA open source Q&A system! +The [**OSQA website**](http://www.osqa.net/) and [**OSQA wiki**](http://wiki.osqa.net/) +are also great resources to help you learn more about the OSQA open source Q&A system! """, SIDEBAR_SET, dict( -label = "Sidebar (Lower)", +label = "Lower Block Content", help_text = " The lower sidebar block. ", widget=Textarea(attrs={'rows': '10'}))) \ No newline at end of file diff --git a/forum/skins/default/templates/questions.html b/forum/skins/default/templates/questions.html index 9eea455..f4f10ec 100644 --- a/forum/skins/default/templates/questions.html +++ b/forum/skins/default/templates/questions.html @@ -3,6 +3,7 @@ {% load question_list_tags %} {% load i18n %} {% load extra_tags %} +{% load general_sidebar_tags %} {% block title %}{% spaceless %}{{ page_title }}{% endspaceless %}{% endblock %} {% block content %} @@ -22,7 +23,10 @@ {% block sidebar %} {% question_list_count %} + {% sidebar_upper %} {% tag_selector %} {% question_list_related_tags questions %} + {% sidebar_lower %} + {% endblock %} diff --git a/forum/skins/default/templates/sidebar/user_blocks.html b/forum/skins/default/templates/sidebar/user_blocks.html new file mode 100644 index 0000000..4303e31 --- /dev/null +++ b/forum/skins/default/templates/sidebar/user_blocks.html @@ -0,0 +1,9 @@ +{% load markup %} + +{% if show %} +
+
+ {{ content|markdown }} +
+
+{% endif %} \ No newline at end of file diff --git a/forum/templatetags/general_sidebar_tags.py b/forum/templatetags/general_sidebar_tags.py index 445f0cb..5741d1b 100644 --- a/forum/templatetags/general_sidebar_tags.py +++ b/forum/templatetags/general_sidebar_tags.py @@ -1,5 +1,6 @@ from django import template from forum.models import Tag, Award +from forum import settings #todo: move to settings RECENT_TAGS_SIZE = 25 @@ -13,4 +14,20 @@ def recent_tags(): @register.inclusion_tag('sidebar/recent_awards.html') def recent_awards(): - return {'awards': Award.objects.order_by('-awarded_at')[:RECENT_AWARD_SIZE]} \ No newline at end of file + return {'awards': Award.objects.order_by('-awarded_at')[:RECENT_AWARD_SIZE]} + +@register.inclusion_tag('sidebar/user_blocks.html') +def sidebar_upper(): + return { + 'show': settings.SIDEBAR_UPPER_SHOW, + 'content': settings.SIDEBAR_UPPER_TEXT, + 'blockid': 'sidebar-upper' + } + +@register.inclusion_tag('sidebar/user_blocks.html') +def sidebar_lower(): + return { + 'show': settings.SIDEBAR_LOWER_SHOW, + 'content': settings.SIDEBAR_LOWER_TEXT, + 'blockid': 'sidebar-lower' + } -- 2.39.5