-# used in index page
-#refactor - move these numbers somewhere?
-INDEX_PAGE_SIZE = 30
-INDEX_AWARD_SIZE = 15
-INDEX_TAGS_SIZE = 25
-# used in tags list
-DEFAULT_PAGE_SIZE = 60
-# used in questions
-QUESTIONS_PAGE_SIZE = 30
-# used in answers
-ANSWERS_PAGE_SIZE = 10
-
-#system to display main content
-def _get_tags_cache_json():#service routine used by views requiring tag list in the javascript space
- """returns list of all tags in json format
- no caching yet, actually
- """
- tags = Tag.objects.filter(deleted=False).all()
- tags_list = []
- for tag in tags:
- dic = {'n': tag.name, 'c': tag.used_count}
- tags_list.append(dic)
- tags = simplejson.dumps(tags_list)
- return tags
+class QuestionListPaginatorContext(pagination.PaginatorContext):
+ def __init__(self, id='QUESTIONS_LIST', prefix='', default_pagesize=30):
+ super (QuestionListPaginatorContext, self).__init__(id, sort_methods=(
+ (_('active'), pagination.SimpleSort(_('active'), '-last_activity_at', _("most recently updated questions"))),
+ (_('newest'), pagination.SimpleSort(_('newest'), '-added_at', _("most recently asked questions"))),
+ (_('hottest'), pagination.SimpleSort(_('hottest'), '-extra_count', _("hottest questions"))),
+ (_('mostvoted'), pagination.SimpleSort(_('most voted'), '-score', _("most voted questions"))),
+ ), pagesizes=(15, 30, 50), default_pagesize=default_pagesize, prefix=prefix)
+
+class AnswerPaginatorContext(pagination.PaginatorContext):
+ def __init__(self, id='ANSWER_LIST', prefix='', default_pagesize=10):
+ super (AnswerPaginatorContext, self).__init__(id, sort_methods=(
+ (_('oldest'), pagination.SimpleSort(_('oldest answers'), ('-marked', 'added_at'), _("oldest answers will be shown first"))),
+ (_('newest'), pagination.SimpleSort(_('newest answers'), ('-marked', '-added_at'), _("newest answers will be shown first"))),
+ (_('votes'), pagination.SimpleSort(_('popular answers'), ('-marked', '-score', 'added_at'), _("most voted answers will be shown first"))),
+ ), default_sort=_('votes'), pagesizes=(5, 10, 20), default_pagesize=default_pagesize, prefix=prefix)
+
+class TagPaginatorContext(pagination.PaginatorContext):
+ def __init__(self):
+ super (TagPaginatorContext, self).__init__('TAG_LIST', sort_methods=(
+ (_('name'), pagination.SimpleSort(_('by name'), 'name', _("sorted alphabetically"))),
+ (_('used'), pagination.SimpleSort(_('by popularity'), '-used_count', _("sorted by frequency of tag use"))),
+ ), default_sort=_('used'), pagesizes=(30, 60, 120))
+
+
+def feed(request):
+ return RssQuestionFeed(
+ request,
+ Question.objects.filter_state(deleted=False).order_by('-last_activity_at'),
+ settings.APP_TITLE + _(' - ')+ _('latest questions'),
+ settings.APP_DESCRIPTION)(request)
+