Skip to content

Commit

Permalink
[#1126] First run at new homepage modules core extension
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin committed Jul 30, 2013
1 parent ba9f605 commit 3e7f690
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 160 deletions.
112 changes: 41 additions & 71 deletions ckan/public/base/less/homepage.less
@@ -1,26 +1,24 @@
.hero {
background: url("@{imagePath}/background-tile.png");
padding: 20px 0;
min-height: 0;
> .container {
position: relative;
padding-bottom: 0;
}
.search-giant {
margin-bottom: 10px;
input {
border-color: darken(@mastheadBackgroundColorEnd, 5);
}
.homepage {

[role=main] {
padding: 20px 0;
}
.page-heading {
font-size: 18px;
margin-bottom: 0;

.row {
position: relative;
}
.module-dark {

.module-search {
padding: 5px;
margin-bottom: 0;
color: @mastheadTextColor;
background: @layoutTrimBackgroundColor;
.search-giant {
margin-bottom: 10px;
input {
border-color: darken(@mastheadBackgroundColorEnd, 5);
}
}
.module-content {
.border-radius(3px 3px 0 0);
background-color: @mastheadBackgroundColor;
Expand All @@ -32,66 +30,38 @@
line-height: 40px;
}
}
}
.tags {
.clearfix();
padding: 5px 10px 10px 10px;
background-color: darken(@mastheadBackgroundColor, 10%);
.border-radius(0 0 3px 3px);
h3,
.tag {
display: block;
float: left;
margin: 5px 10px 0 0;
}
h3 {
font-size: @baseFontSize;
line-height: @baseLineHeight;
padding: 2px 8px;
.tags {
.clearfix();
padding: 5px 10px 10px 10px;
background-color: darken(@mastheadBackgroundColor, 10%);
.border-radius(0 0 3px 3px);
h3,
.tag {
display: block;
float: left;
margin: 5px 10px 0 0;
}
h3 {
font-size: @baseFontSize;
line-height: @baseLineHeight;
padding: 2px 8px;
}
}
}
}

.hero-primary,
.hero-secondary {
.makeColumn(6);
}

.hero-primary {
margin-left: 0; // Remove grid margin.
margin-bottom: 0;
}
.group-list {
margin: 0;
}

.hero-secondary {
position: absolute;
bottom: 0;
right: 0;
.hero-secondary-inner {
.slot2 {
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
}

.main.homepage {
padding-top: 20px;
padding-bottom: 20px;
border-top: 1px solid @layoutTrimBorderColor;
.module-heading .media-image {
margin-right: 15px;
max-height: 53px;
.box-shadow(0 0 0 2px rgba(255, 255, 255, 0.5));
}
.group-listing .box {
min-height: 275px;
}
.group-list {
margin-bottom: 0;
.dataset-content {
min-height: 70px;
.module-search {
bottom: 0;
left: 0;
right: 0;
}
}
.box .module {
margin-top: 0;
}

}
93 changes: 4 additions & 89 deletions ckan/templates/home/index.html
Expand Up @@ -3,98 +3,13 @@
{% 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="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 %}
{{ self.flash() }}
</div>
{% 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 added ckanext/homepage/__init__.py
Empty file.
24 changes: 24 additions & 0 deletions ckanext/homepage/plugin.py
@@ -0,0 +1,24 @@
import logging

import ckan.plugins as p

log = logging.getLogger(__name__)

class HomepagePlugin(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_featured_organization(self):
return

def get_featured_group(self):
return

def get_helpers(self):
return {
'get_featured_organization': self.get_featured_organization,
'get_featured_group': self.get_featured_group,
}
36 changes: 36 additions & 0 deletions ckanext/homepage/theme/templates/home/index.html
@@ -0,0 +1,36 @@
{% ckan_extends %}

{% block primary_content %}
<div role="main" class="hero">
<div class="container">
<div class="row">
<div class="span6 slot1">{{ self.homepage_slot_1() }}</div>
<div class="span6 slot2">{{ self.homepage_slot_2() }}</div>
</div>
</div>
</div>
<div role="main">
<div class="container">
<div class="row">
<div class="span6 slot3">{{ self.homepage_slot_3() }}</div>
<div class="span6 slot4">{{ self.homepage_slot_4() }}</div>
</div>
</div>
</div>
{% endblock %}

{% block homepage_slot_1 %}
{% snippet 'home/snippets/promoted.html', intro=g.site_intro_text %}
{% endblock %}

{% block homepage_slot_2 %}
{% snippet 'home/snippets/search.html', query=c.q, tags=h.get_facet_items_dict('tags', limit=3), placeholder=_('eg. Gold Prices') %}
{% endblock %}

{% block homepage_slot_3 %}
{% snippet 'home/snippets/featured_group.html', group=h.get_featured_group() %}
{% endblock %}

{% block homepage_slot_4 %}
{% snippet 'home/snippets/featured_organization.html', organization=h.get_featured_organization() %}
{% endblock %}
@@ -0,0 +1,3 @@
<div class="box">
{% snippet 'snippets/group_item.html', group=group, truncate=50, truncate_title=35 %}
</div>
@@ -0,0 +1,3 @@
<div class="box">
{% snippet 'snippets/organization_item.html', organization=organization, truncate=50, truncate_title=35 %}
</div>
20 changes: 20 additions & 0 deletions ckanext/homepage/theme/templates/home/snippets/promoted.html
@@ -0,0 +1,20 @@
<div class="module-content box">
<header>
{% if intro %}
{{ h.render_markdown(intro) }}
{% else %}
<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
{% endtrans %}
</p>
{% endif %}
</header>
<section class="featured media-overlay">
<h2 class="media-heading">{{ _("This is a featured section") }}</h2>
<a class="media-image" href="#">
<img src="http://placehold.it/420x220" alt="Placeholder" width="420" height="220" />
</a>
</section>
</div>
18 changes: 18 additions & 0 deletions ckanext/homepage/theme/templates/home/snippets/search.html
@@ -0,0 +1,18 @@
<div class="module module-search module-narrow module-shallow box">
<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="{{ query }}" autocomplete="off" placeholder="{{ placeholder }}" />
<button type="submit">
<i class="icon-search"></i>
<span>{{ _('Search') }}</span>
</button>
</div>
</form>
<div class="tags">
<h3>{{ _('Popular Tags') }}</h3>
{% 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>
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -173,6 +173,7 @@
[ckan.system_plugins]
domain_object_mods = ckan.model.modification:DomainObjectModificationExtension
homepage = ckanext.homepage.plugin:HomepagePlugin
[ckan.test_plugins]
routes_plugin=tests.ckantestplugins:RoutesPlugin
Expand Down

0 comments on commit 3e7f690

Please sign in to comment.