@property
def summary(self):
- content = strip_tags(self.html)[:SUMMARY_LENGTH]
+ content = strip_tags(self.html)
# Remove multiple spaces.
content = re.sub(' +',' ', content)
- # Remove line breaks. We don't need them at all.
- content = content.replace("\n", '')
+ # Replace line breaks with a space, we don't need them at all.
+ content = content.replace("\n", ' ')
+
+ # Truncate and all an ellipsis if length greater than summary length.
+ content = (content[:SUMMARY_LENGTH] + '...') if len(content) > SUMMARY_LENGTH else content
return content
label = _("Summary Length"),
help_text = _("The number of characters that are going to be displayed in order to get the content summary.")))
+SHOW_SUMMARY_ON_QUESTIONS_LIST = Setting('SHOW_SUMMARY_ON_QUESTIONS_LIST', False, VIEW_SET, dict(
+label = _("Question summary on questions list?"),
+help_text = _("Choose whether to show the question summary on questions list"),
+required=False))
+
# Tag settings
RECENT_TAGS_SIZE = Setting('RECENT_TAGS_SIZE', 25, VIEW_SET, dict(
label = _("Recent tags block size"),
</div>\r
\r
<div class="question-summary-wrapper">\r
- <h2><a title="{{ question.summary }}" href="{{ question.get_absolute_url }}">{{question.headline}}</a></h2>\r
+ <h2><a {% if not question_summary %}title="{{ question.summary }}"{% endif %} href="{{ question.get_absolute_url }}">{{question.headline}}</a></h2>\r
+ {% if question_summary %}\r
+ <div class="summary">\r
+ {{ question.summary }}\r
+ </div>\r
+ {% endif %}\r
<div class="userinfo">\r
<span class="relativetime" title="{{question.last_activity_at}}">{% diff_date question.last_activity_at %}</span>\r
{% if question.last_activity_by %}{% user_signature question.last_activity_by signature_type %}{% endif %}\r
{{ questions.paginator.sort_tabs }}\r
</div>\r
<div id="listA">{% for question in questions.paginator.page %}\r
- {% question_list_item question %}\r
+ {% if show_summary %}\r
+ {% question_list_item question question_summary=yes %}\r
+ {% else %}\r
+ {% question_list_item question %}\r
+ {% endif %}\r
{% endfor %}</div>\r
{% endblock %}\r
\r
def render(self, context):\r
return self.template.render(template.Context({\r
'question': self.question.resolve(context),\r
+ 'question_summary': self.options.get('question_summary', 'no' ) == 'yes',\r
'favorite_count': self.options.get('favorite_count', 'no') == 'yes',\r
'signature_type': self.options.get('signature_type', 'lite'),\r
}))\r
@decorators.render('questions.html', 'questions', _('questions'), weight=0)
def questions(request):
- return question_list(request, Question.objects.all(), _('questions'))
+ return question_list(request,
+ Question.objects.all(),
+ _('questions'))
@decorators.render('questions.html')
def tag(request, tag):
allowIgnoreTags=True,
feed_url=None,
paginator_context=None,
+ show_summary=None,
feed_sort=('-added_at',),
feed_req_params_exclude=(_('page'), _('pagesize'), _('sort')),
extra_context={}):
+ if show_summary is None:
+ show_summary = bool(settings.SHOW_SUMMARY_ON_QUESTIONS_LIST)
+
questions = initial.filter_state(deleted=False)
if request.user.is_authenticated() and allowIgnoreTags:
'page_title' : page_title,
'tab' : 'questions',
'feed_url': feed_url,
+ 'show_summary' : show_summary,
}
context.update(extra_context)