Skip to content

Commit

Permalink
Merge pull request #1 from datacats/master
Browse files Browse the repository at this point in the history
Compatibility issues with CKAN 2.4 and other minor fixes
  • Loading branch information
MapsRus committed Feb 17, 2016
2 parents 166ba95 + c5271b2 commit d363aec
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 62 deletions.
50 changes: 40 additions & 10 deletions ckanext/surrey/fanstatic_library/css/surrey.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,44 @@ display: none;
}

.module-content.intro-text{
padding: 20px 25px 15px 25px;
background-color: #333333;
padding: 0px 25px 5px 25px;
color: #fff;
background: #363636 url("/base/images/bg.png");
font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;
font-size: 16px;
color: #ccdee3;
line-height: 145%;
font-weight: normal;
}

.intro-text header {
width: 450px;
float: right;
margin-right: 15px;
padding-top: 10px;
height: 130px;
line-height: 130px;
display: block;
}

.intro-text header a {
text-decoration: underline;
color: #fff;
}

.intro-text header a:hover {
text-decoration: none;
color: #fff;
}

.intro-text header p {
display: inline-block;
vertical-align: middle;
line-height: 140%;
}

.intro-image img {
margin-top: 20px;
}
.masonry .media-image, .masonry .media-heading {
display: block;
margin: auto;
Expand All @@ -39,7 +65,6 @@ text-align: center;


.module-content .featured {
margin-bottom: 10px;
width: 368px;
}

Expand Down Expand Up @@ -169,18 +194,23 @@ body {
background: #363636 url("/base/images/bg.png");
}

/*.resource-item .btn-group {
top: 5px;
}*/

.resource-item {
min-height: 48px;
margin-top: 12px;
margin-bottom: 12px;
min-height: 40px;
}

.resource-item .heading {
color: #000000;
font-size: 14px;
font-weight: bold;
margin-top: -8px;
display: block;
}

.resource-item .format-label {
top: 5px;


}

.attribution ul li {
Expand Down
2 changes: 1 addition & 1 deletion ckanext/surrey/licences.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"maintainer": "City of Surrey",
"status": "active",
"title": "Open Government License - City of Surrey",
"url": "http://www.surrey.ca/files/Open_Government_License_-_City_of_Surrey_v1.pdf"
"url": "http://data.surrey.ca/pages/open-government-licence-surrey"
},
{
"domain_content": false,
Expand Down
26 changes: 18 additions & 8 deletions ckanext/surrey/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
def format_date(date):
'''Take timestamp and return a formatted date Month, day Year.'''
mytime = time.strptime(date[:10], "%Y-%m-%d")
output = time.strftime("%B %d, %Y", mytime)
output = time.strftime("%B %d, %Y", mytime)
# Just return some example text.
return output
return output

def update_frequency():
frequency_list = (u"Yearly", u"Monthly", u"Weekly", u"Daily", u"Realtime", u"Punctual", u"Variable", u"Never")
Expand All @@ -17,13 +17,22 @@ def update_frequency():
def get_group_list():

groups = tk.get_action('group_list')(
data_dict={'all_fields': True})
data_dict={'all_fields': True})

return groups

def get_summary_list(num_packages):

list_without_summary = tk.get_action('package_search')(data_dict={'rows':num_packages,'sort':'metadata_modified desc'})['results']
list_with_summary = []
for package in list_without_summary:
list_with_summary.append(tk.get_action('package_show')(
data_dict={'id':package['name'],'include_tracking':True})
)
return list_with_summary

class SurreyFacetPlugin(plugins.SingletonPlugin):

plugins.implements(plugins.IFacets, inherit=True)

def dataset_facets(self, facets_dict, package_type):
Expand All @@ -32,7 +41,7 @@ def dataset_facets(self, facets_dict, package_type):
'groups': tk._('Categories'),
'tags': tk._('Tags'),
'res_format': tk._('Formats')
#'license_id': tk._('License'),
#'license_id': tk._('License'),
}
return default_facet_titles

Expand All @@ -42,12 +51,12 @@ def group_facets(self, facets_dict, group_type, package_type):
'groups': tk._('Categories'),
'tags': tk._('Tags'),
'res_format': tk._('Formats')
#'license_id': tk._('License'),
#'license_id': tk._('License'),
}
return default_facet_titles

class SurreyExtraPagesPlugin(plugins.SingletonPlugin):

plugins.implements(plugins.IRoutes, inherit=True)
plugins.implements(plugins.IConfigurer, inherit=True)

Expand Down Expand Up @@ -101,7 +110,8 @@ def update_config(self, config):
# Tell CKAN what custom template helper functions this plugin provides,
# see the ITemplateHelpers plugin interface.
def get_helpers(self):
return {'format_date': format_date, 'update_frequency': update_frequency, 'get_group_list': get_group_list}
return {'format_date': format_date, 'update_frequency': update_frequency,
'get_group_list': get_group_list,'get_summary_list':get_summary_list}


def is_fallback(self):
Expand Down
Binary file modified ckanext/surrey/public/images/homepage-graphic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ckanext/surrey/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
{{ super() }}
{% resource 'ckanext-surrey/css/surrey.css' %}
<link type="application/atom+xml" rel="alternate" href="{{ h.url('/', locale='default', qualified=true) }}feeds/dataset.atom"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
{% endblock %}
3 changes: 2 additions & 1 deletion ckanext/surrey/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
('search', _('Datasets')),
('related_dashboard', _('Apps & Visualizations')),
('suggest', _('Suggest a Dataset')),
('follow', _('Subscribe')),
('follow', _('Subscribe')),
('contact', _('Contact'))
)}}
<li><a href="/pages/city-of-surrey-geospatial-data-disclaimer">Disclaimer</a></li>
{% endblock %}
2 changes: 1 addition & 1 deletion ckanext/surrey/templates/home/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% ckan_extends %}
{% ckan_extends %}


{% block meta %}
Expand Down
8 changes: 4 additions & 4 deletions ckanext/surrey/templates/home/snippets/featured_popular.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{%
set output = h.get_action('package_search', {'rows': 5, 'sort': 'views_recent desc'})
set output = h.get_summary_list(5)
%}

<div class="box">
Expand All @@ -10,14 +10,14 @@ <h3 class="media-heading">Popular datasets</h3>
<p>Most viewed dataset during the last 14 days</p>
</div>
</header>

<ul id="popular-list" class="unstyled dataset-list">
{% for package in output.results %}
{% for package in output %}
<li class="dataset-item module-content">
<div class="dataset-content">
<h3 class="dataset-heading">{{ h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name)) }}</h3>
<div>{{package.tracking_summary.recent}} recent views</div></div></li>
{% endfor %}
{% endfor %}
</ul>

</section>
Expand Down
4 changes: 2 additions & 2 deletions ckanext/surrey/templates/home/snippets/promoted.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<h1 class="page-heading">{{ _("Welcome to CKAN") }}</h1>
<p>
{% trans %}This is a nice introductory paragraph about CKAN or the site
in general. We don't have any copy to go here yet but soon we will
in general. We don't have any copy to go here yet but soon we
{% endtrans %}
</p>
{% endif %}
</header>
<section class="featured media-overlay intro-image">
<h2 class="media-heading">{{ _("This is a featured section") }}</h2>
<a class="media-image" href="#">
<img src="{% url_for_static('/images/homepage-graphic.jpg') %}" width="368" height="109"/>
<img src="{% url_for_static('/images/homepage-graphic.jpg') %}" alt="Surrey open data banner" width="368" height="109"/>
</a>
</section>
</div>
2 changes: 1 addition & 1 deletion ckanext/surrey/templates/home/snippets/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h3>{{ _('Popular Tags') }}</h3>
{% endfor %}
</div>
<div class="search-by-cat">
<h3 class="heading">{{ _("Search By Category") }}</h1>
<h3 class="heading">{{ _("Search By Category") }}</h3>
<ul class="surrey-media-grid">

{% for group in groups %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h3>{{ _('Details') }}</h3>
<tbody>
{% if pkg_dict.metadata_created %}
<tr>
<th scope="row" class="dataset-label">{{ _('Creation Date') }}</th>
<th scope="row" class="dataset-label">{{ _('First Published Date') }}</th>
<td class="dataset-details" property="dc:issued">{{ h.format_date(pkg_dict.metadata_created) }}</td>
</tr>
{% endif %}
Expand Down Expand Up @@ -57,7 +57,7 @@ <h3>{{ _('Details') }}</h3>

{% if pkg_dict.update_frequency %}
<tr>
<th scope="row" class="dataset-label">{{ _("Update Frequency") }}</th>
<th scope="row" class="dataset-label">{{ _("Data Update Frequency") }}</th>
<td class="dataset-details">{{ pkg_dict.update_frequency}}</td>
</tr>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{ form.input('attribute_details', label=_('Attribute details'), id='field-attribute_details', placeholder=_('...'), value=data.attribute_details, error=errors.attribute_details, classes=['control-medium']) }}

<div class="control-group">
<label class="control-label" for="field-update_frequency">{{ _("Update Frequency") }}</label>
<label class="control-label" for="field-update_frequency">{{ _("Data Update Frequency") }}</label>
<div class="controls">
<select id="field-update_frequency" name="update_frequency">
{% for update_frequency in h.update_frequency() %}
Expand Down
49 changes: 18 additions & 31 deletions ckanext/surrey/templates/package/snippets/resource_item.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
{% ckan_extends %}

{% set geo_formats = [ 'csv', 'json', 'geojson', 'kml', 'kmz', 'shp', 'dwg', 'fgdb'] %}
{% set geo_formats = [ 'csv', 'json', 'geojson', 'kml', 'kmz', 'shp', 'dwg', 'fgdb', 'sid', 'tiff', 'geotiff', 'tif', 'geotif'] %}

{% block resource_item_title %}
<span class="heading" href="{{ url }}" title="{{ res.name or res.description }}">
{{ h.resource_display_name(res) | truncate(50) }}<span class="format-label" property="dc:format" data-format="{{ res.format.lower() or 'data' }}">{{ res.format }}</span>
{{ h.popular('views', res.tracking_summary.total, min=10) }}
</span>
{% endblock %}

{% block resource_item_explore_links %}
{% if res.can_be_previewed %}
<li>
<a href="{{ url }}">
<i class="icon-bar-chart"></i>
{{ _('Preview') }}
</a>
</li>
{% endif %}
{% if pkg.is_geospatial == "1" and res.format.lower() in geo_formats %}
<li>
<a href="/preview.html?layername={{ pkg.name }}&dataformat={{ res.format.lower() }}">
<i class="icon-download"></i>
{{ _('Download via Map') }}
</a>
</li>
{% endif %}
<li>
<a href="{{ res.url }}" class="resource-url-analytics" target="_blank">
<i class="icon-download"></i>
{{ _('Download') }}
</a>
</li>
{% if can_edit %}
<li>
<a href="{{ h.url_for(controller='package', action='resource_edit', id=pkg.name, resource_id=res.id) }}">
<i class="icon-edit"></i>
{{ _('Edit') }}
</a>
</li>
{% endif %}
{{ super() }}
{% if pkg.is_geospatial == "1" and res.format.lower() in geo_formats %}
<li>
<a href="/preview.html?layername={{ pkg.name }}&dataformat={{ res.format.lower() }}">
<i class="icon-download"></i>
{{ _('Download via Map') }}
</a>
</li>
{% endif %}
{% endblock %}
14 changes: 14 additions & 0 deletions ckanext/surrey/templates/user/new.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{% ckan_extends %}


{% block primary_content %}
<article class="module">
<div class="module-content">
<h1 class="page-heading">
{% block page_heading %}{{ _('Register for an Account') }}{% endblock %}
</h1>

<p style="padding-bottom: 20px">Personal Information is collected for the purposes of accessing data sets, suggesting data sets, and/or subscribing to email updates . The City of Surrey is collecting this information under s.26 (c) of the Freedom of Information and Protection of Privacy Act. For questions regarding the collection of personal information, please contact Sean Simpson, GIS Manager at <a href="mailto:[email protected]">[email protected]</a> or at 604-591-4730.</p>
{{ c.form | safe }}
</div>
</article>
{% endblock %}

{% block secondary_content %}
<section class="module module-narrow module-shallow">
<h2 class="module-heading">{{ _('Why Sign Up?') }}</h2>
Expand Down

0 comments on commit d363aec

Please sign in to comment.