Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions springboard_iogt/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def main(global_config, **settings):
config.add_route('personae', '/persona/')
config.add_route('skip_persona_selection', '/persona/skip/')
config.add_route('select_persona', '/persona/{slug}/')
config.add_route('about', '/about/')
config.add_tween('springboard_iogt.views.persona_tween_factory')
config.scan('.views')
config.scan('.events')
Expand Down
9 changes: 9 additions & 0 deletions springboard_iogt/static/other/about-eng_GB.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"title": "About Internet of Good Things",
"description": "",
"content": "Internet of Good Things (IoGT) is a set of mobile-ready web based resources and applications that bring good to your life. The IoGT initiative is delivering value added information and lifesaving recommendations directly on mobile phones at no cost to the end user",
"language": "eng_GB",
"image": null,
"image_host": null,
"slug": "about"
}
3 changes: 1 addition & 2 deletions springboard_iogt/templates/base.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@

<div id="footer">
<div>&copy; {% trans %}The Internet of Good Things{% endtrans %}</div>
{# TODO flat page links for About #}
<div><span><a href="#">{{ _('About Internet of Good Things') }}</a></span></div>
<div><span><a href="{{ 'about'|route_url }}">{{ _('About Internet of Good Things') }}</a></span></div>
</div>

</body>
Expand Down
19 changes: 14 additions & 5 deletions springboard_iogt/templates/flat_page.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
<div>
<div class="articles">

<div class="h1">
{{page.title}}
</div>
<div class="article">
{% set has_image = page.image_host and page.image %}
<div class="head{% if not has_image %} no-pic{% endif %}">
<div class="h2">{{page.title}}</div>
{% if has_image %}
<div class="img">
<a href="{{'flat_page'|route_url(slug=page.slug)}}">
<img alt="{{page.title}}" src="{{page.image_host}}{{page.image|thumbor(140)}}"/>
</a>
</div>
{% endif %}
<div class="meta">{{page.description|markdown}}</div>
</div>
<div>{{page.content|markdown}}</div>

<div class="detail">
<p>{{page.content|markdown}}</p>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion springboard_iogt/templates/molecules/page_listing.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<img alt="{{ page.title }}" src="{{ page.image_host }}{{ page.image|thumbor(140) }}" srcset="{{page.image_host}}{{page.image|thumbor(320)}} 320w" sizes="100vw" />
</a>
{% endif %}
<p>{{ page.description|markdown }}</p>
<div>{{ page.description|markdown }}</div>
<div class="clr"></div>
{%- endmacro %}

Expand Down
2 changes: 1 addition & 1 deletion springboard_iogt/templates/page.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{% endif %}
<div class="meta">{{page.description|markdown}}</div>
</div>
<p>{{page.content|markdown}}</p>
<div>{{page.content|markdown}}</div>

{% if page.linked_pages %}
{% set linked_pages = all_pages.filter(uuid__in=page.linked_pages) %}
Expand Down
7 changes: 7 additions & 0 deletions springboard_iogt/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ def test_language_visibility(self):
html = app.get('/does/not/exist/', expect_errors=True).html
self.assertFalse(html.find('div', class_='lang'))

def test_about(self):
app = self.mk_app(self.workspace, main=main)
response = app.get('/about/')
self.assertEqual(response.status_int, 200)
response = app.get('/about/?_LOCALE_=swa_TZ', expect_errors=True)
self.assertEqual(response.status_int, 404)

@patch('unicore.google.tasks.pageview.delay')
def test_ga_page_titles(self, mock_task):
app = self.mk_app(
Expand Down
20 changes: 20 additions & 0 deletions springboard_iogt/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import json
import pkg_resources

from pyramid.view import view_config
from pyramid.httpexceptions import HTTPFound, HTTPNotFound

from unicore.content.models import Page

from springboard.views.base import SpringboardViews

from springboard.utils import ga_context
Expand Down Expand Up @@ -87,3 +92,18 @@ def content_section(self):
raise HTTPNotFound

return self.context(section=ContentSection(slug))

@ga_context(lambda context: {'dt': 'About', })
@view_config(route_name='about',
renderer='springboard_iogt:templates/flat_page.jinja2')
def about(self):
filename = pkg_resources.resource_filename(
'springboard_iogt',
'static/other/about-%s.json' % (self.language, ))

try:
with open(filename) as f:
page = Page(json.load(f))
return self.context(page=page)
except IOError:
raise HTTPNotFound