Skip to content

Commit

Permalink
[#509] Add Sidebar for General Pages
Browse files Browse the repository at this point in the history
* Refactor the Newest Community & Documents blocks into include-able
  templates.

Closes #509
  • Loading branch information
prikhi committed Jun 9, 2015
1 parent 49adfae commit c639112
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% load communities_tags %}
{% community_newest_communities limit=limit|default:3 as newest_communities %}
<div id="newest-communities" class="list-group">
{% for community in newest_communities %}
<div class="list-group-item">
{% community_blurb community show_picture=False truncate_description_at=truncate_description_at|default:25 %}
</div>
{% endfor %}
</div>
9 changes: 9 additions & 0 deletions fec/core/static/css/fec.css
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,12 @@ ul#root-category-tabs {
h3#related-documents-sidebar-header {
margin-top: 0;
}



/* Pages */

/* Remove the Top Margin from the First Sidebar Header */
h3#newest-communities-pages-sidebar {
margin-top: 0;
}
15 changes: 15 additions & 0 deletions fec/core/templates/pages/page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% overextends "pages/page.html" %}

{% load i18n %}


{% block right_panel %}

<h3 class="text-center" id="newest-communities-pages-sidebar">
{% trans "Newest Communities" %}</h3>
{% include "communities/includes/newest_communities_list_group.html" with limit=5 truncate_description_at=18 %}

<h3 class="text-center">{% trans "Newest Documents" %}</h3>
{% include "documents/includes/newest_documents_list_group.html" with limit=5 %}

{% endblock %}
17 changes: 2 additions & 15 deletions fec/documents/templates/documents/includes/category_sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,12 @@
Display the Newest Documents and Top Categories
{% endcomment %}

{% load documents_tags keyword_tags %}
{% load documents_tags %}


<!-- Newest Documents Widget -->
<h3 class="text-center" id="newest-documents-sidebar-header">Newest Documents</h3>
<ul class="list-group">
{% documents_newest as newest_documents %}
{% for document in newest_documents %}
<li class="list-group-item">
<a href="{{ document.get_absolute_url }}">{{ document.title }}</a>
<small>
by
<a href="{{ document.community.get_absolute_url }}">{{ document.community }}</a>
in
<a href="{{ document.category.get_absolute_url }}">{{ document.category.title }}</a>
</small>
</li>
{% endfor %}
</ul>
{% include "documents/includes/newest_documents_list_group.html" %}

<!-- Top Categories -->
{% include "documents/includes/top_categories_list_group.html" %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% load documents_tags %}

<ul class="list-group">
{% documents_newest limit=limit|default:3 as newest_documents %}
{% for document in newest_documents %}
<li class="list-group-item">
<a href="{{ document.get_absolute_url }}">{{ document.title }}</a>
<small>
by
<a href="{{ document.community.get_absolute_url }}">{{ document.community }}</a>
in
<a href="{{ document.category.get_absolute_url }}">{{ document.category.title }}</a>
</small>
</li>
{% endfor %}
</ul>
6 changes: 3 additions & 3 deletions fec/documents/templatetags/documents_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def category_breadcrumbs(category, is_active=False):


@register.assignment_tag
def documents_newest():
"""Return the 5 newest Documents."""
return Document.objects.all().order_by('-created')[:3]
def documents_newest(limit=3):
"""Return the newest Documents."""
return Document.objects.all().order_by('-created')[:limit]


@register.assignment_tag
Expand Down
12 changes: 2 additions & 10 deletions fec/homepage/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{% extends "site.html" %}
{% load communities_tags blog_tags mezzanine_tags i18n %}
{% load blog_tags mezzanine_tags i18n %}

{% block meta_title %}Home{% endblock %}

{% block content %}


<div class="container">
<h1 class="hidden">{% trans "The Federation of Egalitarian Communities" %}</h1>
{% include 'includes/messages.html' %}
Expand Down Expand Up @@ -36,14 +35,7 @@ <h4 class="homepage-heading">{{ homepage_content.content_title }}</h4>
{% if homepage_content.show_newest_communities %}
<div class="col-md-12 col-sm-6">
<h4 class="homepage-heading">{% trans "Our Newest Communities" %}</h4>
{% community_newest_communities limit=3 as newest_communities %}
<div id="newest-communities" class="list-group">
{% for community in newest_communities %}
<div class="list-group-item">
{% community_blurb community show_picture=False truncate_description_at=25 %}
</div>
{% endfor %}
</div>
{% include "communities/includes/newest_communities_list_group.html" %}
</div>
{% endif %}

Expand Down

0 comments on commit c639112

Please sign in to comment.