Skip to content

Commit

Permalink
Merge pull request #6 from datopian/new-homepage
Browse files Browse the repository at this point in the history
New homepage implementation
  • Loading branch information
virgoaugustine committed Apr 5, 2022
2 parents 4cc37e7 + f8c90c2 commit bdb56c1
Show file tree
Hide file tree
Showing 19 changed files with 9,422 additions and 392 deletions.
1,797 changes: 1,796 additions & 1 deletion ckanext/nhs/fanstatic/css/nhs.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ckanext/nhs/fanstatic/css/nhs.min.css

Large diffs are not rendered by default.

7,307 changes: 7,306 additions & 1 deletion ckanext/nhs/fanstatic/css/nhsuk.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ckanext/nhs/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ def get_latest_themes():

return themes

def get_themes():
context = {}
themes = _get_action('organization_list', context, {'all_fields': True})
return themes

def get_latest_datasets():
context = {}
data_dict = {
Expand All @@ -130,6 +135,7 @@ def get_latest_datasets():
def get_latest_resources():
private_resource_dict= '%\\\\"level\\\\": \\\\"public\\\\"%'
j_statement = join(model.Resource, model.Package, model.Package.id == model.Resource.package_id)
foi_group = model.Group.get('freedom-of-information-disclosure-log')
sql = select([
model.Resource.id,
model.Resource.name,
Expand All @@ -147,6 +153,7 @@ def get_latest_resources():
.where(
and_(model.Package.state == 'active',
model.Package.private == False,
model.Package.owner_org != foi_group.id,
model.Resource.state == 'active',
text("resource.extras ILIKE \'%s\' or resource.extras ILIKE \'%s\' " % (private_resource_dict, '%{level: public}%' ))
)
Expand Down
1 change: 1 addition & 0 deletions ckanext/nhs/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def get_helpers(self):
'get_dataset_data_dictionary': helpers.get_dataset_data_dictionary,
'get_resource_data_dictionary': helpers.get_resource_data_dictionary,
'get_latest_themes': helpers.get_latest_themes,
'get_themes': helpers.get_themes,
'get_latest_datasets': helpers.get_latest_datasets,
'get_latest_resources': helpers.get_latest_resources,
'get_cookie_control_config': helpers.get_cookie_control_config,
Expand Down
Binary file added ckanext/nhs/public/images/hero003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ckanext/nhs/public/images/nhs-hero-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions ckanext/nhs/templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<footer class="footer">
<div class="container">
<div class="nhsuk-width-container">
<div class="row">
<div class="col-md-8 col-sm-12">
<div class="row">
Expand Down Expand Up @@ -65,4 +65,4 @@
</div>
</div>
</div>
</footer>
</footer>
160 changes: 78 additions & 82 deletions ckanext/nhs/templates/header.html
Original file line number Diff line number Diff line change
@@ -1,99 +1,95 @@
{% block header_wrapper %} {% block header_account %}
<div class="account-masthead" role="navigation" aria-label="Admin Navigation">
<div class="container">
{% block header_account_container_content %} {% if c.userobj %}
<div class="account avatar authed" data-module="me" data-me="{{ c.userobj.id }}">
<ul class="list-unstyled">
{% block header_account_logged %} {% if c.userobj.sysadmin %}
<li>
<a href="{{ h.url_for(controller='admin', action='index') }}" title="{{ _('Sysadmin settings') }}">
<i class="fa fa-gavel" aria-hidden="true"></i>
<span class="text">{{ _('Admin') }}</span>
</a>
</li>
{% endif %}
<li>
<a href="{{ h.url_for('user.read', id=c.userobj.name) }}" class="image" title="{{ _('View profile') }}">
<div class="container">
{% block header_account_container_content %} {% if c.userobj %}
<div class="account avatar authed" data-module="me" data-me="{{ c.userobj.id }}">
<ul class="list-unstyled">
{% block header_account_logged %} {% if c.userobj.sysadmin %}
<li>
<a href="{{ h.url_for(controller='admin', action='index') }}" title="{{ _('Sysadmin settings') }}">
<i class="fa fa-gavel" aria-hidden="true"></i>
<span class="text">{{ _('Admin') }}</span>
</a>
</li>
{% endif %}
<li>
<a href="{{ h.url_for('user.read', id=c.userobj.name) }}" class="image" title="{{ _('View profile') }}">
{{ h.gravatar((c.userobj.email_hash if c and c.userobj else ''), size=22) }}
<span class="username">{{ c.userobj.display_name }}</span>
</a>
</li>
{% set new_activities = h.new_activities() %}
<li class="notifications {% if new_activities > 0 %}notifications-important{% endif %}">
{% set notifications_tooltip = ngettext('Dashboard (%(num)d new item)', 'Dashboard (%(num)d new items)', new_activities)
%}
<a href="{{ h.url_for('dashboard.index') }}" title="{{ notifications_tooltip }}">
<i class="fa fa-tachometer" aria-hidden="true"></i>
<span class="text">{{ _('Dashboard') }}</span>
<span class="badge">{{ new_activities }}</span>
</a>
</li>
{% block header_account_settings_link %}
<li>
<a href="{{ h.url_for('user.edit', id=c.userobj.name) }}" title="{{ _('Edit settings') }}">
<i class="fa fa-cog" aria-hidden="true"></i>
<span class="text">{{ _('Settings') }}</span>
</a>
</li>
{% endblock %} {% block header_account_log_out_link %}
<li>
<a href="{{ h.url_for('/user/_logout') }}" title="{{ _('Log out') }}">
<i class="fa fa-sign-out" aria-hidden="true"></i>
<span class="text">{{ _('Log out') }}</span>
</a>
</li>
{% endblock %} {% endblock %}
</ul>
</li>
{% set new_activities = h.new_activities() %}
<li class="notifications {% if new_activities > 0 %}notifications-important{% endif %}">
{% set notifications_tooltip = ngettext('Dashboard (%(num)d new item)', 'Dashboard (%(num)d new items)', new_activities) %}
<a href="{{ h.url_for('dashboard.index') }}" title="{{ notifications_tooltip }}">
<i class="fa fa-tachometer" aria-hidden="true"></i>
<span class="text">{{ _('Dashboard') }}</span>
<span class="badge">{{ new_activities }}</span>
</a>
</li>
{% block header_account_settings_link %}
<li>
<a href="{{ h.url_for('user.edit', id=c.userobj.name) }}" title="{{ _('Edit settings') }}">
<i class="fa fa-cog" aria-hidden="true"></i>
<span class="text">{{ _('Settings') }}</span>
</a>
</li>
{% endblock %} {% block header_account_log_out_link %}
<li>
<a href="{{ h.url_for('/user/_logout') }}" title="{{ _('Log out') }}">
<i class="fa fa-sign-out" aria-hidden="true"></i>
<span class="text">{{ _('Log out') }}</span>
</a>
</li>
{% endblock %} {% endblock %}
</ul>
</div>
{% endif %} {% endblock %}
</div>
{% endif %} {% endblock %}
</div>
</div>
{% endblock %}
<header class="navbar navbar-static-top masthead" aria-label="Main Navigation">
{% block header_debug %} {% if g.debug and not g.debug_supress_header %}
<div class="debug">Controller : {{ c.controller }}<br/>Action : {{ c.action }}</div>
{% endif %} {% endblock %}
<div class="container">
<div class="navbar-right">
<button data-target="#main-navigation-toggle" data-toggle="collapse" class="navbar-toggle collapsed" type="button" aria-label="Show/Hide Main Menu">
{% block header_debug %} {% if g.debug and not g.debug_supress_header %}
<div class="debug">Controller : {{ c.controller }}<br/>Action : {{ c.action }}</div>
{% endif %} {% endblock %}
<div class="nhsuk-width-container">
<div class="navbar-right">
<button data-target="#main-navigation-toggle" data-toggle="collapse" class="navbar-toggle collapsed" type="button" aria-label="Show/Hide Main Menu">
<span class="fa fa-bars"></span>
</button>
</div>
</div>

<div class="navbar-topgroup">
<div class="nav-infotext">
<p>{{ g.site_title }}</p>
</div>
<div class="navbar-topgroup">
<hgroup class="{{ g.header_class }} navbar-left">
<div class="nhsuk-header__logo custom-header">
<a href="/" aria-label="NHS Open Data Portal Homepage">
<svg class="nhsuk-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 16">
<path class="nhsuk-logo__background" fill="#005eb8" d="M0 0h40v16H0z"></path>
<path class="nhsuk-logo__text" fill="#fff" d="M3.9 1.5h4.4l2.6 9h.1l1.8-9h3.3l-2.8 13H9l-2.7-9h-.1l-1.8 9H1.1M17.3 1.5h3.6l-1 4.9h4L25 1.5h3.5l-2.7 13h-3.5l1.1-5.6h-4.1l-1.2 5.6h-3.4M37.7 4.4c-.7-.3-1.6-.6-2.9-.6-1.4 0-2.5.2-2.5 1.3 0 1.8 5.1 1.2 5.1 5.1 0 3.6-3.3 4.5-6.4 4.5-1.3 0-2.9-.3-4-.7l.8-2.7c.7.4 2.1.7 3.2.7s2.8-.2 2.8-1.5c0-2.1-5.1-1.3-5.1-5 0-3.4 2.9-4.4 5.8-4.4 1.6 0 3.1.2 4 .6"></path>
</svg>
<span class="nhsuk-organisation-name">Open Data Portal</span>
<span class="nhsuk-organisation-descriptor">Business Services Authority</span>
</a>
</div>

<hgroup class="{{ g.header_class }} navbar-left">
{% block header_logo %} {% if g.site_logo %}
<a class="logo" href="{{ h.url_for('home.index') }}"><img src="/images/nhs-logo.png" alt="NHS Business Services Authority" title="{{ g.site_title }}" /></a>
{% else %}
<h1>
<a href="{{ h.url_for('home.index') }}">{{ g.site_title }}</a>
</h1>
{% if g.site_description %}
<h2>{{ g.site_description }}</h2>{% endif %} {% endif %} {% endblock %}
</hgroup>

<p class="clearfix"></p>
</div>
<div class="collapse navbar-collapse" id="main-navigation-toggle">
{% block header_site_navigation %}
<nav class="section navigation" role="navigation" aria-label="Main Menu">
<ul class="nav nav-pills">
{% block header_site_navigation_tabs %} {{ h.build_nav_main( ('search', _('Datasets')), ('theme_index', _('Themes')) ) }} {% endblock %}
<li><a href="/pages/about">About</a></li>
<li><a href="https://wh1.snapsurveys.com/s.asp?k=159361358492" title="Tell us what you think of our Open Data Portal" target="_blank">Feedback Survey</a></li>
{% if c.userobj %}
</hgroup>

{% else %}
<li>{% link_for _('Admin Log on'), named_route='user.login' %}</li>
{% endif %}
</ul>
</nav>
{% endblock %}
<p class="clearfix" style="margin-bottom:10px;"></p>
</div>
<div class="collapse navbar-collapse" id="main-navigation-toggle">
{% block header_site_navigation %}
<nav class="section navigation" role="navigation" aria-label="Main Menu">
<ul class="nav nav-pills">
<li><a href={{h.url_for( 'home.index')}} title="Go to Home">Home</a></li>
<li><a href={{h.url_for( 'search')}} title="Go to Data">Data</a></li>
<li><a href="/pages/news" title="Go to News">News</a></li>
<li><a href="/pages/documentation" title="Go to Documentation">Documentation</a></li>
<li><a href="/pages/about" title="Go to About">About</a></li>
<li><a href="/pages/contact" title="Go to Contact" class="visible-sm visible-xs">Get in touch</a></li>
</ul>
</nav>
{% endblock %}
</div>
</div>
</div>
</header>
{% endblock %}
90 changes: 30 additions & 60 deletions ckanext/nhs/templates/home/layout1.html
Original file line number Diff line number Diff line change
@@ -1,64 +1,34 @@
<div class="container searchbar" id="content" role="search">
<div class="row">
<div class="col-lg-7 col-md-9">
<div class="block">
<h1>Search Datasets</h1>
{% block search %}
{% snippet 'home/snippets/search.html' %}
{% endblock %}
</div>
<main>
<div class="survey" id="survey">
{% block survey%} {% snippet 'home/snippets/feedback.html' %} {% endblock %}
</div>
<div class="hero" role="search">
{% block hero%} {% snippet 'home/snippets/hero.html' %} {% endblock %}
</div>
</div>

</div>

<div role="main">
<div class="container">
<div class="row row2">
<div class="col-md-11 col1">
{# Note: this featured_group block is used as an example in the theming
tutorial in the docs! If you change this code, be sure to check
whether you need to update the docs. #}
{# Start template block example. #}
</div>
<div class="col-md-11 col2">
<h2 class="section-heading" id="new-datasets">Latest Updates</h2>
<div class="themes">
{%block themes %} {% snippet 'home/snippets/themes.html' %} {% endblock %}
</div>
<div class="latest-info">
{%block latest_info %} {% snippet 'home/snippets/latest_info.html'%} {% endblock %}
</div>
<div class="newsletter">
{%block newsletter %} {% snippet 'home/snippets/newsletter.html'%} {% endblock %}
</div>
</main>

<div class="custom-card m-b-60">
<!-- Resources -->
{% for resource in h.get_latest_resources() %}
<div class="single-list">
<a href="/dataset/{{resource['package_id']}}/resource/{{resource['id']}}">
{% if resource['extras']['title'] %}
{% set resouce_title = resource['extras']['title'] %}
{% elif resource['name'] %}
{% set resouce_title = resource['name'] %}
{% else %}
{% set resouce_title = 'Untitled resource' %}
{% endif %}
{{ resouce_title }}
</a>
{% set resource_datetime = resource['created'] %}
{% if resource['last_modified'] %}
{% set resource_datetime = resource['last_modified'] %}
{% endif %}
<p> <small> {% snippet 'snippets/local_friendly_datetime.html', datetime_obj=resource_datetime %}</small></p>
<p>{{h.render_markdown(resource['description'])}}</p>
</div>
{% endfor %}
</div>
<script>
window.onscroll = function() {
myFunction()
};
var header = document.getElementById("survey");
var sticky = header.offsetTop;

<div class="nhsuk-action-link">
<a class="nhsuk-action-link__link" href="{{ h.url_for('search') }}">
<svg class="nhsuk-icon nhsuk-icon__arrow-right-circle custom-arrow" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true">
<path d="M0 0h24v24H0z" fill="none"></path>
<path d="M12 2a10 10 0 0 0-9.95 9h11.64L9.74 7.05a1 1 0 0 1 1.41-1.41l5.66 5.65a1 1 0 0 1 0 1.42l-5.66 5.65a1 1 0 0 1-1.41 0 1 1 0 0 1 0-1.41L13.69 13H2.05A10 10 0 1 0 12 2z"></path>
</svg>
<span class="nhsuk-action-link__text">Go To Datasets</span>
</a>
</div>

</div>
</div>
</div>
</div>
function myFunction() {
if (window.pageYOffset > sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}
}
</script>
4 changes: 4 additions & 0 deletions ckanext/nhs/templates/home/snippets/feedback.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="nhsuk-width-container feedback">
<strong class="nhsuk-tag">BETA</strong>
<span class="nhsuk-u-font-size-24">Your feedback is important to us! Help us serve you better by filling out our <u><a href="https://wh1.snapsurveys.com/s.asp?k=159361358492" target="_blank" title="Short Survey on what you think about NHS Open Data Portal" class="nhsuk-u-font-size-24">short survey</a></u>!</span>
</div>
25 changes: 25 additions & 0 deletions ckanext/nhs/templates/home/snippets/hero.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<a href="/pages/contact" class="contact-button hidden-xs hidden-sm">
Get in touch
</a>



<div class="nhsuk-width-container ">
<div class="hero-content">
<h1 class="nhsuk-u-margin-bottom-3">Welcome to the Open Data Portal</h1>
<p>This is the home of data we release to the public. Built using open source tools. It lets you:
</p>
<ul class="nhsuk-list nhsuk-list--bullet" style="padding-left: 20px;">
<li>
filter and download datasets
</li>
<li>
view the metadata and data in a single place.
</li>
</ul>

<div class="">
{% block search %} {% snippet 'home/snippets/search.html' %} {% endblock %}
</div>
</div>
</div>
17 changes: 17 additions & 0 deletions ckanext/nhs/templates/home/snippets/latest_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% set resources= h.get_latest_resources() %}

<div class="nhsuk-width-container">
<h1 class="nhsuk-u-margin-top-5">Latest Information</h1>
<ul class="nhsuk-grid-row aligned-row">
{% for resource in resources%} {% if resource['extras']['title'] %} {% set resource_title = resource['extras']['title'] %} {% elif resource['name'] %} {% set resource_title = resource['name'] %} {% else %} {% set resource_title = 'Untitled resource' %}
{% endif %} {% set resource_datetime = resource['created'] %} {% if resource['last_modified'] %} {% set resource_datetime = resource['last_modified'] %} {% endif %}
<li class="nhsuk-grid-column-one-half info-item nhsuk-u-margin-top-3">
<h2 class="nhsuk-u-margin-bottom-2"><a class="nhsuk-u-font-size-32" href="/dataset/{{resource['package_id']}}/resource/{{resource['id']}}" aria-label="View {{resource['name']}}">{{resource_title}}</a></h2>
<small class="automatic-local-datetime" data-datetime="{{ h.render_datetime(resource_datetime,date_format='%Y-%m-%d') }}">
{{ h.render_datetime(resource_datetime, date_format='%Y-%m-%d')}}
</small>
</li>
{% endfor %}

</ul>
</div>
13 changes: 13 additions & 0 deletions ckanext/nhs/templates/home/snippets/newsletter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="nhsuk-width-container">
<h1 class="nhsuk-u-margin-bottom-5">
Stay up to date with the latest news from NHS Business<br/> Services Authority - Open Data
</h1>
<p class="nhsuk-u-margin-bottom-5 nhsuk-u-font-size-32">Get the latest information straight to your inbox by subscribing</p>
<svg class="nhsuk-icon nhsuk-icon__arrow-right-circle" viewBox="0 0 105 106" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M52.3518 0.494141C39.3367 0.493977 26.7856 5.32818 17.1333 14.0589C7.481 22.7896 1.41576 34.7943 0.114258 47.7441H61.2243L40.4868 27.0066C39.6267 26.0023 39.1772 24.7104 39.2283 23.3891C39.2793 22.0678 39.8271 20.8144 40.7621 19.8794C41.697 18.9444 42.9504 18.3967 44.2717 18.3457C45.593 18.2946 46.8849 18.7441 47.8893 19.6041L77.6043 49.2666C78.0963 49.7547 78.4869 50.3354 78.7534 50.9751C79.02 51.6149 79.1572 52.3011 79.1572 52.9941C79.1572 53.6872 79.02 54.3734 78.7534 55.0132C78.4869 55.6529 78.0963 56.2336 77.6043 56.7216L47.8893 86.3841C46.9056 87.362 45.575 87.9108 44.188 87.9108C42.801 87.9108 41.4704 87.362 40.4868 86.3841C39.5089 85.4005 38.9601 84.0699 38.9601 82.6829C38.9601 81.2959 39.5089 79.9653 40.4868 78.9816L61.2243 58.2441H0.114258C1.13022 68.3529 5.05744 77.9497 11.4196 85.8706C17.7818 93.7916 26.3055 99.6964 35.9572 102.869C45.6088 106.041 55.9736 106.345 65.7945 103.744C75.6155 101.142 84.4706 95.747 91.2859 88.2125C98.1013 80.6779 102.584 71.3277 104.191 61.2959C105.797 51.264 104.458 40.9816 100.337 31.6955C96.2151 22.4095 89.4876 14.5188 80.9702 8.98053C72.4528 3.44224 62.5114 0.494268 52.3518 0.494141V0.494141Z" fill="white"/>
</svg>
<a class="subscribe-text" href="https://nhs.us12.list-manage.com/subscribe?u=73c3d4c9798efad92c827e730&id=f1f210e16c">
Subscribe to the Open Data Newsletter
</a>

</div>
Loading

0 comments on commit bdb56c1

Please sign in to comment.