Skip to content

Commit

Permalink
Merge pull request #54 from CodeForAfrica/chore-upgrade-to-ckan-2.10
Browse files Browse the repository at this point in the history
CKAN 2.10 replace controllers & IRoutes with blueprints
  • Loading branch information
thepsalmist authored Jun 5, 2024
2 parents 2203a00 + 1d52438 commit d425dbf
Show file tree
Hide file tree
Showing 21 changed files with 21,240 additions and 10,360 deletions.
1 change: 1 addition & 0 deletions ckanext/openafrica/assets/css/bootstrap-3.min.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ckanext/openafrica/assets/css/bootstrap.min.css

Large diffs are not rendered by default.

11,210 changes: 11,210 additions & 0 deletions ckanext/openafrica/assets/css/main-3.css

Large diffs are not rendered by default.

20,107 changes: 9,867 additions & 10,240 deletions ckanext/openafrica/assets/css/main.css

Large diffs are not rendered by default.

90 changes: 83 additions & 7 deletions ckanext/openafrica/assets/css/openafrica_theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ body {
margin: 0px;
font-weight: 200;
font-size: 15px;
padding-bottom: 60px;
padding: 0;
/*This was to allow the main to flow down and show the breadcrumbs*/
}

Expand Down Expand Up @@ -402,6 +402,7 @@ a.button-bordered {
font-weight: bold;
margin: 0;
align-self: center;
white-space: nowrap;
}
.social-links .icons {
display: flex;
Expand Down Expand Up @@ -617,7 +618,7 @@ input.button {
padding: 10px 15px 10px 15px;
border-bottom: 1px solid #ccc;
position: relative;
min-height: 120px;
min-height: 150px;
height: auto;
list-style: none;
}
Expand Down Expand Up @@ -869,10 +870,6 @@ div.sort-datasets a {
height: auto;
}

.dataset-content {
height: auto;
}

.dataset-item .dataset-content div {
display: block;
}
Expand Down Expand Up @@ -1047,6 +1044,12 @@ div.sort-datasets a {
#email {
width: 16em;
}
.primary {
width: 100%
}
.secondary {
width: 100%
}
}

@media (max-width: 540px) {
Expand Down Expand Up @@ -1244,13 +1247,15 @@ label {

@media (min-width: 979px) {
.nav-collapse.collapse {
display: block;
display: flex;
justify-content: space-between;
}
}

.navbar .nav > li {
float: left;
}

.navbar .nav {
float: none;
position: relative;
Expand All @@ -1259,11 +1264,24 @@ label {
float: left;
margin: 17px 10px 0 0;
}
@media (max-width: 979px) {
.navbar .nav {
display: flex;
flex-direction: column;
}
.nav-collapse, .nav-collapse.collapse {
overflow: visible;
}
/* .collapse:not(.show) {
display: block;
} */
}
.wrapper {
margin-bottom: 20px;
}
.wrapper:before {
width: 19%;
display: none;
}

.navbar .nav > li > a {
Expand Down Expand Up @@ -1348,3 +1366,61 @@ label {
.footer-links ul {
padding: 0;
}
.homepage .module-search .search-input {
display: inline-block;
}
.homepage .module-search {
border: none;
}
.module-content {
border-bottom: none;
}
.navbar-inner {
width: 100%;
}

.hide {
display: none;
}

.navbar-fixed-top .container {
max-width: 100% !important;
}

.dataset-resources li a {
background-color: #856A00;
color: #ffffff;
}

.dataset-content {
height: auto;
/* display: flex; */
}
.dataset-item .dataset-content .dataset-heading .label {
color: #FFF;
padding: 3px 8px 4px;
}

.pull-right {
float: right;
}

.pull-left {
float: left;
}
.btn-danger-serious {
border: 1px solid #d43f3a !important;
margin: 0 5px 5px 5px;
}
.dropdown-menu > li > a {
display: block;
padding: 3px 20px;
clear: both;
font-weight: 400;
color: #333333;
white-space: nowrap;
text-decoration: none;
}
.container {
padding-bottom: 8px;
}
6 changes: 6 additions & 0 deletions ckanext/openafrica/assets/js/bootstrap-3.min.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions ckanext/openafrica/assets/js/bootstrap.min.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions ckanext/openafrica/blueprint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from flask import Blueprint
from ckan.plugins.toolkit import render

openafrica = Blueprint("openafrica", __name__)

def static_path(path):
def render_path():
return render(path)

return render_path

rules = [
("/about/terms-and-conditions", "toc", static_path("home/about/toc.html")),
("/about/accessibility", "accessibility", static_path("home/about/accessibility.html")),
("/about/code-of-conduct", "coc", static_path("home/about/coc.html")),
("/about/moderation-policy", "moderation", static_path("home/about/moderation.html")),
("/about/faq", "faq", static_path("home/about/faq.html")),
("/about/privacy", "privacy", static_path("home/about/privacy.html")),
("/about/contact-us", "contact", static_path("home/about/contact.html"))
]

for rule in rules:
openafrica.add_url_rule(*rule)

49 changes: 0 additions & 49 deletions ckanext/openafrica/controller.py

This file was deleted.

50 changes: 11 additions & 39 deletions ckanext/openafrica/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@

import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
from . import blueprint


class OpenAfricaPlugin(plugins.SingletonPlugin):
u"""
openAFRICA templating plugin.
"""
plugins.implements(plugins.IConfigurer)
plugins.implements(plugins.IRoutes, inherit=True)
plugins.implements(plugins.ITemplateHelpers)
plugins.implements(plugins.IConfigurer, inherit=True)
plugins.implements(plugins.ITemplateHelpers, inherit=True)
plugins.implements(plugins.IBlueprint)

def update_config(self, config):
u"""
Expand All @@ -42,45 +43,16 @@ def update_config(self, config):
"""
toolkit.add_template_directory(config, 'templates')
toolkit.add_public_directory(config, 'public')
# toolkit.add_resource('fanstatic', 'openafrica')
toolkit.add_resource('assets', 'openafrica')

def before_map(self, map):
u"""
Called before the routes map is generated. ``before_map`` is before any
other mappings are created so can override all other mappings.
:param map: Routes map object
:returns: Modified version of the map object
# IBlueprint
def get_blueprint(self):
"""
map.connect('/about/terms-and-conditions',
controller='ckanext.openafrica.controller:CustomPageController',
action='toc')
map.connect('/about/accessibility',
controller='ckanext.openafrica.controller:CustomPageController',
action='accessibility')
map.connect('/about/code-of-conduct',
controller='ckanext.openafrica.controller:CustomPageController',
action='coc')
map.connect('/about/moderation-policy',
controller='ckanext.openafrica.controller:CustomPageController',
action='moderation')
map.connect('/about/faq',
controller='ckanext.openafrica.controller:CustomPageController',
action='faq')
map.connect('/about/privacy',
controller='ckanext.openafrica.controller:CustomPageController',
action='privacy')
map.connect('/about/contact-us',
controller='ckanext.openafrica.controller:CustomPageController',
action='contact')
map.connect('/about/suggest-a-dataset',
controller='ckanext.openafrica.controller:CustomPageController',
action='suggest_a_dataset')
map.connect('/atlas-for-africa',
controller='ckanext.openafrica.controller:CustomPageController',
action='atlas')
return map
CKAN uses Flask Blueprints to extend urls
:return:
"""
return blueprint.openafrica


def get_helpers(self):
u"""
Expand Down
2 changes: 1 addition & 1 deletion ckanext/openafrica/templates/dataset-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{% block flash %}
<div class="flash-messages">
{% block flash_inner %}
{% for message in h.flash.pop_messages() | list %}
{% for message in h.flash.pop_messages | list %}
<div class="alert fade in {{ message.category }}">
{{ h.literal(message) }}
</div>
Expand Down
23 changes: 14 additions & 9 deletions ckanext/openafrica/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,31 @@
<!-- Be sure to leave the brand out there if you want it shown -->
{% block header_logo %}
{% if g.site_logo %}
<a class="logo brand" href="{{ h.url('home') }}"><img src="{{ g.site_logo }}" alt="{{ g.site_title }}"
<a class="logo brand" href="{{ h.url_for('home.index') }}"><img src="{{ g.site_logo }}" alt="{{ g.site_title }}"
title="{{ g.site_title }}" /></a>
{% else %}
<a class="brand" href="{{ h.url('home') }}"><img
<a class="brand" href="{{ h.url_for('home.index') }}"><img
src="https://cloud.githubusercontent.com/assets/877919/14067805/7e3ff5ae-f476-11e5-88eb-059d88816232.png"
alt="{{ g.site_title }}" title="{{ g.site_title }}" /></a>
{% endif %}
{% endblock %}

<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<a class="btn btn-navbar" onclick="toggleNavbar()" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>


<!-- Everything you want hidden at 940px or less, place within here -->
<div class="nav-collapse collapse" style="height: auto;">
<ul class="nav">
<div class="nav-collapse collapse">
<ul class="nav" style="flex: 1;">
<li><a href="/dataset">Datasets</a></li>
<li><a href="/organization">Organisations</a></li>
<li><a href="/group">Groups</a></li>
<li><a href="/about">About</a></li>
{% if h.is_plugin_enabled('datarequests') %}
{% if g.user %}
{% if current_user.is_authenticated %}
<li><a href="/datarequest">{{_('Data Requests')}}</a></li>
{% else %}
<li><a href="/user/login?came_from=/datarequest">{{_('Data Requests')}}</a></li>
Expand All @@ -53,7 +52,7 @@
<li><a href="{{ h.url_for(controller='admin', action='index') }}">Admin</a></li>
{% endif %}
<li>
<a href="{{ h.url_for(controller='dashboard', action='index') }}">Control Panel</a>
<a href="{{ h.url_for(controller='dashboard', action='datasets') }}">Control Panel</a>
</li>
<li><a href="{{ h.url_for(controller='user', action='edit', id=c.userobj.name) }}">Options</a></li>
<li><a href="{{ h.url_for('/user/_logout') }}">Logout</a></li>
Expand All @@ -67,9 +66,15 @@
</div>
</div>
</div>
<script>
function toggleNavbar() {
var navCollapse = document.querySelector('.nav-collapse');
navCollapse.classList.toggle('show');
}
</script>
</div>
{% endblock %}
{%- block scripts %}
{% asset 'openafrica/openafrica-bootstrap-js' %}
{% asset 'openafrica/openafrica_bootstrap-js' %}
{{ super() }}
{% endblock -%}
2 changes: 1 addition & 1 deletion ckanext/openafrica/templates/home/about/accessibility.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% block breadcrumb_content %}
<li >{% link_for _('About'), controller='home', action='about' %}</li>
<li class="active">{% link_for _('Accessibility'), controller='ckanext.openafrica.controller:CustomPageController', action='accessibility' %}</li>
<li class="active">{% link_for _('Accessibility'), named_route='openafrica.accessibility' %}</li>
{% endblock %}

{% block primary %}
Expand Down
2 changes: 1 addition & 1 deletion ckanext/openafrica/templates/home/about/coc.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% block breadcrumb_content %}
<li >{% link_for _('About'), controller='home', action='about' %}</li>
<li class="active">{% link_for _('Code of Conduct'), controller='ckanext.openafrica.controller:CustomPageController', action='coc' %}</li>
<li class="active">{% link_for _('Code of Conduct'), named_route='openafrica.coc' %}</li>
{% endblock %}

{% block primary %}
Expand Down
Loading

0 comments on commit d425dbf

Please sign in to comment.