Skip to content

Commit

Permalink
[#1126] First working version of row/column based homepage off of sim…
Browse files Browse the repository at this point in the history
…ple JSON config
  • Loading branch information
johnmartin committed Jul 24, 2013
1 parent 0a339db commit d44132b
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 91 deletions.
95 changes: 4 additions & 91 deletions ckan/templates/home/index.html
Expand Up @@ -3,98 +3,11 @@
{% block subtitle %}{{ _("Welcome") }}{% endblock %}

{% block maintag %}{% endblock %}
{% block toolbar %}{% endblock %}

{% block content %}
<div role="main" class="hero">
<div id="content" class="container">
{{ self.flash() }}
{{ self.primary_content() }}
</div>
</div>
<div class="main homepage">
<div class="container">
{{ self.secondary_content() }}
</div>
</div>
{% endblock %}

{% block primary_content %}
<div class="hero-primary module module-popup">
<div class="module-content box">
{% block home_primary %}
<header>
{% if g.site_intro_text %}
{{ h.render_markdown(g.site_intro_text) }}
{% else %}
{% block home_primary_content %}
<h1 class="page-heading">{% block home_primary_heading %}{{ _("Welcome to CKAN") }}{% endblock %}</h1>
<p>
{% block home_primary_text %}
{% 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
{% endtrans %}
{% endblock %}
</p>
{% endblock %}
{% endif %}
</header>
{% endblock %}

{% block home_image %}
<section class="featured media-overlay">
<h2 class="media-heading">{% block home_image_caption %}{{ _("This is a featured section") }}{% endblock %}</h2>
{% block home_image_content %}
<a class="media-image" href="#">
<img src="http://placehold.it/420x220" alt="Placeholder" width="420" height="220" />
</a>
{% endblock %}
</section>
{% endblock %}
</div>
</div>
<div class="hero-secondary">
<div class="hero-secondary-inner">
{% block home_secondary_content %}
<div class="module module-shallow module-narrow module-dark info box">
{% block home_search %}
<form class="module-content search-form" method="get" action="{% url_for controller='package', action='search' %}">
<h3 class="heading">{{ _("Search Your Data") }}</h3>
<div class="search-input control-group search-giant">
<input type="text" class="search" name="q" value="{{ c.q }}" autocomplete="off" placeholder="{{ _('eg. Gold Prices') }}" />
<button type="submit">
<i class="icon-search"></i>
<span>{{ _('Search') }}</span>
</button>
</div>
</form>
{% endblock %}
{% block home_tags %}
<div class="tags">
<h3>{{ _('Popular Tags') }}</h3>
{% set tags = h.get_facet_items_dict('tags', limit=3) %}
{% for tag in tags %}
<a class="tag" href="{% url_for controller='package', action='search', tags=tag.name %}">{{ h.truncate(tag.display_name, 22) }}</a>
{% endfor %}
</div>
{% endblock %}
</div>
{% endblock %}
</div>
<div role="main" class="homepage">
{{ self.flash() }}
{% block primary_content %}{% endblock %}
</div>
{% endblock %}

{% block secondary_content %}
<div class="row group-listing">
{% for group in c.group_package_stuff %}
<div class="span6">
<div class="box">
{% snippet 'snippets/group_item.html', group=group.group_dict, truncate=50, truncate_title=35 %}
</div>
</div>
{% endfor %}
</div>
{% endblock %}

{# Remove the toolbar. #}

{% block toolbar %}{% endblock %}
Empty file.
18 changes: 18 additions & 0 deletions ckanext/content_module/plugin.py
@@ -0,0 +1,18 @@
import logging

import ckan.plugins as p

log = logging.getLogger(__name__)

class ContentModulePlugin(p.SingletonPlugin):
p.implements(p.IConfigurer, inherit=True)
p.implements(p.IConfigurable, inherit=True)

def update_config(self, config):
p.toolkit.add_template_directory(config, 'theme/templates')

# def get_helpers(self):
# return {
# 'featured_organizations': self.featured_orgs,
# 'featured_groups': self.featured_groups,
# }
6 changes: 6 additions & 0 deletions ckanext/content_module/theme/templates/admin/base.html
@@ -0,0 +1,6 @@
{% ckan_extends %}

{% block content_primary_nav %}
{{ super() }}
{{ h.build_nav_icon('ckanadmin_homepage', _('Homepage')) }}
{% endblock %}
@@ -0,0 +1,3 @@
<div class="carousel">

</div>
@@ -0,0 +1,3 @@
<header>
{{ module.config.message }}
</header>
20 changes: 20 additions & 0 deletions ckanext/content_module/theme/templates/content_module/search.html
@@ -0,0 +1,20 @@
<div class="module module-shallow module-narrow module-dark box">
<form class="module-content search-form" method="get" action="{% url_for controller='package', action='search' %}">
<h3 class="heading">{{ module.config.title }}</h3>
{{ config }}
<div class="search-input control-group search-giant">
<input type="text" class="search" name="q" value="" autocomplete="off" placeholder="{{ module.config.placeholder }}" />
<button type="submit">
<i class="icon-search"></i>
<span>{{ _('Search') }}</span>
</button>
</div>
</form>
<div class="tags">
<h3>{{ _('Popular Tags') }}</h3>
{% set tags = h.get_facet_items_dict('tags', limit=module.config.limit) %}
{% for tag in tags %}
<a class="tag" href="{% url_for controller='package', action='search', tags=tag.name %}">{{ h.truncate(tag.display_name, 22) }}</a>
{% endfor %}
</div>
</div>
42 changes: 42 additions & 0 deletions ckanext/content_module/theme/templates/home/index.html
@@ -0,0 +1,42 @@
{% ckan_extends %}

{# imagine this is set via the controller really... #}
{% set content_bands = [
{
"type": "hero",
"columns": [
[
{ "type": "intro", "config": { "message": g.site_intro_text or "Test" } },
{ "type": "carousel", "config": false },
],
[
{ "type": "search", "config": {
"limit": 3,
"title": _("Search Your Data"),
"placeholder": _("eg. Gold Prices")
} },
]
]
},
] %}

{% block primary_content %}

{% for band in content_bands %}
<div class="band {{ band.type }}">
<div class="container">
<div class="row">
{% for column in band.columns %}
{% set column_size = ( 12 / loop.length )|int %}
<div class="span{{ column_size }}">
{% for module in column %}
{% snippet 'content_module/'~module.type~'.html', module=module %}
{% endfor %}
</div>
{% endfor %}
</div>
</div>
</div>
{% endfor %}

{% endblock %}
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -173,6 +173,7 @@
[ckan.system_plugins]
domain_object_mods = ckan.model.modification:DomainObjectModificationExtension
content_module = ckanext.content_module.plugin:ContentModulePlugin
[babel.extractors]
ckan = ckan.lib.extract:extract_ckan
Expand Down

0 comments on commit d44132b

Please sign in to comment.