Skip to content

Commit

Permalink
Merge branch 'feature-2375-demo-theme' of github.com:okfn/ckan into f…
Browse files Browse the repository at this point in the history
…eature-2375-demo-theme
  • Loading branch information
aron committed Jun 12, 2012
2 parents a5886dd + c06abf8 commit 3bdea58
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 24 deletions.
4 changes: 2 additions & 2 deletions ckan/controllers/home.py
Expand Up @@ -8,7 +8,7 @@
from ckan.lib.base import *
from ckan.lib.helpers import url_for

CACHE_PARAMETER = '__cache'
CACHE_PARAMETERS = ['__cache','__no_cache__']

class HomeController(BaseController):
repo = model.repo
Expand Down Expand Up @@ -41,7 +41,7 @@ def index(self):
data_dict = {
'q':'*:*',
'facet.field':g.facets,
'rows':10,
'rows':4,
'start':0,
'sort':'views_recent desc',
'fq': 'capacity:"public"'
Expand Down
4 changes: 2 additions & 2 deletions ckan/controllers/package.py
Expand Up @@ -22,7 +22,7 @@
import ckan.rating
import ckan.misc
import ckan.lib.accept as accept
from home import CACHE_PARAMETER
from home import CACHE_PARAMETERS

from ckan.lib.plugins import lookup_package_plugin

Expand Down Expand Up @@ -450,7 +450,7 @@ def new(self, data=None, errors=None, error_summary=None):
return self._save_new(context)

data = data or clean_dict(unflatten(tuplize_dict(parse_params(
request.params, ignore_keys=[CACHE_PARAMETER]))))
request.params, ignore_keys=CACHE_PARAMETERS))))
c.resources_json = json.dumps(data.get('resources',[]))

errors = errors or {}
Expand Down
8 changes: 6 additions & 2 deletions ckan/controllers/user.py
Expand Up @@ -286,7 +286,8 @@ def login(self):
g.openid_enabled = False

if not c.user:
c.login_handler = h.url_for(self._get_repoze_handler('login_handler_path'))
came_from = request.params.get('came_from', '')
c.login_handler = h.url_for(self._get_repoze_handler('login_handler_path'), came_from=came_from)
return render('user/login.html')
else:
return render('user/logout_first.html')
Expand All @@ -295,6 +296,7 @@ def logged_in(self):
# we need to set the language via a redirect
lang = session.pop('lang', None)
session.save()
came_from = request.params.get('came_from', '')
if c.user:
context = {'model': model,
'user': c.user}
Expand All @@ -304,13 +306,15 @@ def logged_in(self):
user_dict = get_action('user_show')(context,data_dict)

h.flash_success(_("%s is now logged in") % user_dict['display_name'])
if came_from:
return h.redirect_to(str(came_from))
return self.me(locale=lang)
else:
err = _('Login failed. Bad username or password.')
if g.openid_enabled:
err += _(' (Or if using OpenID, it hasn\'t been associated with a user account.)')
h.flash_error(err)
h.redirect_to(locale=lang, controller='user', action='login')
h.redirect_to(locale=lang, controller='user', action='login', came_from=came_from)

def logout(self):
# save our language in the session so we don't lose it
Expand Down
15 changes: 13 additions & 2 deletions ckan/lib/jinja_tags.py
Expand Up @@ -6,6 +6,11 @@


class BaseExtension(Extension):
''' Base class for creating custom jinja2 tags.
parse expects a tag of the format
{% tag_name args, kw %}
after parsing it will call _call(args, kw) which must be defined. '''

def parse(self, parser):
stream = parser.stream
tag = stream.next()
Expand Down Expand Up @@ -37,7 +42,7 @@ class SnippetExtension(BaseExtension):
{% snippet <template_name> [, <keyword>=<value>].. %}
This is mostly magic..
see lib.helpers.snippet() for more details.
'''

tags = set(['snippet'])
Expand All @@ -50,7 +55,10 @@ def _call(cls, args, kwargs):

class UrlForExtension(BaseExtension):
''' Custom url_for tag
{% url_for <params> %}
see lib.helpers.url_for() for more details.
'''

tags = set(['url_for'])
Expand All @@ -62,7 +70,10 @@ def _call(cls, args, kwargs):

class LinkForExtension(BaseExtension):
''' Custom link_for tag
{% url_for <params> %}
{% link_for <params> %}
see lib.helpers.nav_link() for more details.
'''

tags = set(['link_for'])
Expand Down
4 changes: 2 additions & 2 deletions ckan/templates/home/index.html
Expand Up @@ -40,7 +40,7 @@ <h2 class="heading">{{ _("This is a featured section") }}</h2>
<div class="secondary">
<div class="secondary-inner">
<div class="module module-dark info">
<form class="dataset-search content clearfix" method="get">
<form class="dataset-search content clearfix" method="get" action="{% url_for controller='package', action='search' %}">
<h3 class="heading">{{ _("Search Your Data") }}</h3>
<span class="control-group search-giant">
<input type="text" class="search" name="q" value="{{ c.q }}" autocomplete="off" results="0" placeholder="{{ _('eg. Gold Prices') }}" />
Expand All @@ -57,7 +57,7 @@ <h3 class="heading">{{ _("Search Your Data") }}</h3>

{% block secondary_content %}
<div class="">
{% snippet 'snippets/package_grid.html', packages=c.datasets[:4] %}
{% snippet 'snippets/package_grid.html', packages=c.datasets %}
</div>
{% endblock %}

Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/package/read.html
Expand Up @@ -75,7 +75,7 @@ <h3>Data and Resources</h3>

{{ h.snippet('snippets/related.html', pkg=c.pkg) }}

{{ h.snippet('snippets/license.html', pkg=c.pkg, pkg_dict=c.pkg_dict) }}
{{ h.snippet('snippets/license.html', pkg_dict=c.pkg_dict) }}

{{ h.snippet('snippets/disqus_trackback.html') }}
{% endblock %}
17 changes: 15 additions & 2 deletions ckan/templates/snippets/license.html
@@ -1,6 +1,19 @@
{% if pkg.license_id %}
{% if pkg_dict.license_id %}
<section class="module info license">
<h2 class="heading"><i class="ckan-icon ckan-icon-large-lock"></i> License</h2>
<p class="content">{{ h.snippet('snippets/license.html', dataset=pkg_dict) }}</p>
<p class="content">
{% if 'license_url' in pkg_dict %}
<a href="{{ pkg_dict.license_url }}" rel="dc:rights">{{ pkg_dict.license_title }}</a>
{% else %}
<span property="dc:rights">{{ pkg_dict.license_title }}</span>
{% endif %}
{% if pkg_dict.isopen %}
<a href="http://opendefinition.org/okd/" title="This dataset satisfies the Open Definition.">
<img class="open-data" src="http://assets.okfn.org/images/ok_buttons/od_80x15_blue.png" alt="[Open Data]" />
</a>
{% else %}
<span class="closed">{{ h.icon('lock') }}</span>
{% endif %}
</p>
</section>
{% endif %}
11 changes: 0 additions & 11 deletions ckan/templates/snippets/license_text.html

This file was deleted.

0 comments on commit 3bdea58

Please sign in to comment.