Skip to content

Commit

Permalink
Issue #6 show static pages in landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Cordero committed Apr 25, 2014
1 parent 5e4f0a2 commit cceaa0e
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 10 deletions.
17 changes: 13 additions & 4 deletions webapp/core/views.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.http import Http404
from django.shortcuts import render_to_response
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext, TemplateDoesNotExist
from django.views.decorators.csrf import ensure_csrf_cookie
from .models import Page

@ensure_csrf_cookie
def home(request):
def home(request):
# Render template without any argument
return render_to_response('index.html', context_instance=RequestContext(request))
pages = Page.objects.all().values('title', 'slug')
return render_to_response(
'index.html', {'pages': pages }, context_instance=RequestContext(request))

def partial(request, partial_name=None):
def partial(request, partial_name=None):
template_name = 'partials/' + partial_name + '.html';
try:
return render_to_response(template_name, context_instance=RequestContext(request))
Expand All @@ -19,3 +22,9 @@ def partial(request, partial_name=None):

def embed(request):
return render_to_response('embed.html', context_instance=RequestContext(request))


def pages(request, slug):
page = get_object_or_404(Page, slug__iexact=slug)
return render_to_response(
'static_page.html', {'page': page }, context_instance=RequestContext(request))
7 changes: 7 additions & 0 deletions webapp/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@
<div class="col links">
<a href="#/about">[[about]]</a>
</div>
{% with cached_pages=pages %}
{% for page in cached_pages %}
<div class="col links">
<a href="#/{{page.slug}}">[[{{page.title}}]]</a>
</div>
{% endfor %}
{% endwith %}
</div>
<div class="col-sm-offset-2 col-sm-3 col-md-3 col-md-offset-1 col">
<a href="http://knightfoundation.org" target="_blank">
Expand Down
90 changes: 90 additions & 0 deletions webapp/templates/static_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{% extends "base.html" %}
{% load staticfiles %}
{% load compress %}

{% block extracss %}
{% compress css %}
<link rel="stylesheet" type="text/less" href="{% static 'less/base.less' %}" media="all">
{% endcompress %}
{% endblock %}

{% block extrajs %}
{% compress js %}
<script type="text/javascript" src="{% static 'js/vendor/bootstrap-select.custom.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/bootstrap.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/d3.v3.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/fuse.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/masonry.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/messageformat.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/underscore-min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/modernizr.custom.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/imagesloaded.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/angular/angular.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/angular/angular-cookies.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/angular/angular-resource.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/angular/angular-translate.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/angular/angular-translate-handler-log.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/angular/angular-translate-loader-static-files.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/angular/ui-bootstrap-custom-tpls-0.5.0.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/angular/restangular.js' %}"></script>
<script type="text/javascript" src="{% static 'js/vendor/angular/angular-masonry.min.js' %}"></script>

<script type="text/coffeescript" src="{% static 'coffee/app.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/controllers/CardsCtrl.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/controllers/ContributeCtrl.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/controllers/FilterCtrl.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/controllers/LanguageCtrl.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/controllers/HeaderCtrl.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/controllers/PageCtrl.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/controllers/ScaleCtrl.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/controllers/TabsCtrl.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/controllers/StaticPageCtrl.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/directives/ScalePoints.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/directives/SelectPicker.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/directives/StickToTop.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/filters.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/services/Currency.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/services/Filters.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/services/Languages.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/services/Meta.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/services/Page.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/services/Search.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/services/Comprehension.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/services/Humanize.coffee' %}"></script>
<script type="text/coffeescript" src="{% static 'coffee/services/Share.coffee' %}"></script>
{% endcompress %}
{% endblock %}

{% block content %}
{% include "partials/header.html" %}
<div ng-view id="content" class="container" ng-class="{loading: loading, home : getContentClass()}">
{{ page.content }}
</div>
<footer>
<div class="container">
<div class="row">
<div class="col-sm-1 col-md-2">
{% include "partials/languages.html" %}
<div class="col links">
<a href="#/about">[[about]]</a>
</div>
</div>
<div class="col-sm-offset-2 col-sm-3 col-md-3 col-md-offset-1 col">
<a href="http://knightfoundation.org" target="_blank">
<img src="{% static 'img/knight-logo.png' %}" />
</a>
</div>
<div class="col-sm-3 col-md-3 col">
<a href="http://okfn.org" target="_blank">
<img src="{% static 'img/okfn-logo.png' %}" />
</a>
</div>
<div class="col-sm-3 col-md-3 col">
<a href="http://jplusplus.org" target="_blank">
<img src="{% static 'img/jpp-logo.png' %}" />
</a>
</div>
</div>
</div>
</footer>
{% endblock %}
13 changes: 7 additions & 6 deletions webapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
# Last mod : 08-Aug-2013
# -----------------------------------------------------------------------------
# This file is part of Spending Stories.
#
#
# Spending Stories is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# Spending Stories is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with Spending Stories. If not, see <http://www.gnu.org/licenses/>.

Expand All @@ -32,16 +32,17 @@

admin.autodiscover()

urlpatterns = patterns('',
urlpatterns = patterns('',
# Our main views URL, see webapp.core.urls
# url(r'^', include('webapp.core.urls')),
# API & API documentation urls
url(r'^$', 'webapp.core.views.home', name='home'),
# API & API documentation urls
url(r'^$', 'webapp.core.views.home', name='home'),
url(r'^api/', include('webapp.api.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^partial/(?P<partial_name>([a-zA-Z0-9_\-/]+))\.html$', 'webapp.core.views.partial', name='partial'),
url(r'^redactor/', include('redactor.urls')),
url(r'^embed', 'webapp.core.views.embed'),
url(r'^(?P<slug>([a-zA-Z0-9_\-/]+))/$', 'webapp.core.views.pages'),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # serving media folder in debug mode

0 comments on commit cceaa0e

Please sign in to comment.