Skip to content

Commit

Permalink
Merge pull request #18 from datopian/feature/homepage-ui
Browse files Browse the repository at this point in the history
Showcase feeds  on home page and  image added on news feeds
  • Loading branch information
sagargg committed Jul 30, 2021
2 parents ec76dce + 9678244 commit b9288da
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 22 deletions.
75 changes: 68 additions & 7 deletions ckanext/opendatani/fanstatic/css/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -849,21 +849,15 @@ h6 {
.hierarchy-tree li a {
position: relative;
}

.hierarchy-tree-top li a span,
.hierarchy-tree li a span {
position: absolute;
right: 0;
top: 0;
background: #0c6db7;
padding: 4px 5px;
padding: 4px 10px;
color: #f6f7f8;
}

.hierarchy-tree-top a span {
padding: 4px 8px;
}

.media-grid .media-view {
border: none;
}
Expand Down Expand Up @@ -925,6 +919,7 @@ h6 {
margin-bottom: 1px;
}


.label {
text-shadow: none;
letter-spacing: normal;
Expand Down Expand Up @@ -1070,4 +1065,70 @@ h6 {

#no_content:after{
content: ''
}



/* Custom UI Homepage updates */
.latest-posts.thumbnails {
margin-top:30px;
}

.latest-posts.thumbnails li{
border: 1px solid #eee;
margin-left: 17px;
}

.latest-posts.thumbnails li .post{
padding:10px;
}

.sub-heading {
display:inline;
position: relative;
top: 6px;
}

.more-btn {
margin-left: 10px;
display:inline;
}

.col-7 {
width:70%;
float:left;
}

.col-3 {
width:30%;
float:left;
text-align:right;
}

.showcase-item {
padding: 30px 0;
border-bottom: 1px solid #e1e1e1;
}

.showcase-item p {
margin-top:10px;
color: #7d7d7d;
}

.showcase-item .btn {
position: relative;
top: 15px;
padding: 5px 25px;
}

.showcase-item span{
background-color: #eee;
font-size: 1.1em;
padding: 6px 15px;
font-weight: 600;
color: #7f7f7f;
}

.clearfix {
clear:both;
}
8 changes: 1 addition & 7 deletions ckanext/opendatani/fanstatic/less/_org-list.less
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,8 @@
right: 0;
top: 0;
background: @accent;
padding: 4px 5px;
padding: 4px 10px;
color: @lightgrey;
}
}
}

.hierarchy-tree-top {
a span {
padding: 4px 8px;
}
}
18 changes: 18 additions & 0 deletions ckanext/opendatani/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import ckan.lib.helpers as h
from ckan.plugins import toolkit
import ckan.authz as authz
import ckan.lib.dictization.model_dictize as model_dictize
from ckanext.showcase.model import ShowcasePackageAssociation


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -156,3 +158,19 @@ def verify_datasets_exist(org):
data_dict['q'] = 'organization:{0}'.format(org)

return toolkit.get_action('package_search')({}, data_dict).get('count') > 0


def get_showcase_List(limit):
q = model.Session.query(model.Package) \
.filter(model.Package.type == 'showcase') \
.filter(model.Package.state == 'active')

showcase_list = []
for pkg in q.limit(limit).all():
showcase_list.append(model_dictize.package_dictize(pkg, { 'model' : model }))

for idx, showcase in enumerate(showcase_list):
# get a list of package ids associated with showcase id
pkg_id_list = ShowcasePackageAssociation.get_package_ids_for_showcase(showcase['id'])
showcase_list[idx]['package_count'] = len(pkg_id_list)
return showcase_list
3 changes: 2 additions & 1 deletion ckanext/opendatani/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def get_helpers(self):
'package_list': package_list,
'ni_activity_list_to_text': helpers.activity_list_to_text,
'verify_datasets_exist': helpers.verify_datasets_exist,
'is_admin': helpers.is_admin
'is_admin': helpers.is_admin,
'showcase_list': helpers.get_showcase_List
}

# IRoutes
Expand Down
35 changes: 28 additions & 7 deletions ckanext/opendatani/templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,45 @@
</div>
<div role="main">
<div class="container">
<h2>Latest</h2>
<h2 class="sub-heading">Latest</h2> <a class="btn btn-primary more-btn" href="{{ h.url_for('blog_index') }}" title="{{ _('Blog') }}"><i class="icon-chevron-right"></i>{% trans %}More{% endtrans %}</a>

{% set posts = h.get_recent_blog_posts(3) %}
<ul class="latest-posts thumbnails">
{% for post in posts %}
<li class="span4">
<span class="post">
<h4><a href="{{ h.url_for(controller='ckanext.pages.controller:PagesController', action='blog_show', page='/' + post.name) }}">{{ post.title or post.name }}</a></h4>
<small class="date"> {{ h.render_datetime(post.publish_date) }} </small>
<span class="text">{{ h.markdown_extract(post.content) }}</span>
<a class="btn btn-primary" href="{{ h.url_for(controller='ckanext.pages.controller:PagesController', action='blog_show', page='/' + post.name) }}"><i class="icon-chevron-right"></i>{% trans %}More{% endtrans %}</a>
</span>
<img src="{{ post.image }}" />
<div class="post">
<h4><a href="{{ h.url_for(controller='ckanext.pages.controller:PagesController', action='blog_show', page='/' + post.name) }}">{{ post.title or post.name }}</a></h4>
<small class="date"> {{ h.render_datetime(post.publish_date) }} </small>
<span class="text">{{ h.markdown_extract(post.content) }}</span>
<a class="btn btn-primary" href="{{ h.url_for(controller='ckanext.pages.controller:PagesController', action='blog_show', page='/' + post.name) }}"><i class="icon-chevron-right"></i>{% trans %}More{% endtrans %}</a>
</div>
</li>
{% endfor %}
</ul>

</div>
</div>

<div role="main">
<div class="container">
<h2 class="sub-heading">Showcases</h2> <a class="btn btn-primary more-btn" href="{{ h.url_for('ckanext_showcase_index') }}" title="{{ _('Showcases') }}"><i class="icon-chevron-right"></i>{% trans %}More{% endtrans %}</a>

<div class="showcase-item">
{% for showcase in h.showcase_list(limit=3) %}
<div class="col-7">
<h4><a href="{{ h.url_for(controller='ckanext.showcase.controller:ShowcaseController', action='read', id=showcase.name) }}">{{ _(showcase.title) }}</a></h4>
</div>
<div class="col-3">
<a href="{{ h.url_for(controller='ckanext.showcase.controller:ShowcaseController', action='read', id=showcase.name) }}" class="btn btn-primary">View</a>
</div>
<div class="clearfix"></div>
<span>{{ _(showcase.package_count) }} Datasets</span>
<p>{{ _(showcase.notes | truncate(300)) }}</p>
{% endfor %}
</div>
</div>
</div>
{% snippet "home/snippets/twitter.html" %}

{% endblock %}
Expand Down

0 comments on commit b9288da

Please sign in to comment.