Skip to content

Commit

Permalink
feat: move datahub stats into footer (#10)
Browse files Browse the repository at this point in the history
* temporary change

* next fix: width

* next fix: width

* Fix in datahub stats margin-bottom

* Fix in subscribe section stats margin-bottom

* Return to former footer logo section

* a bit of customization for datahub stats

* a bit of customization for datahub stats

* Small fix for insights.html

---------

Co-authored-by: toavina <toavina@fjelltopp.org>
  • Loading branch information
A-Souhei and toavina authored Aug 30, 2024
1 parent 0da859a commit c36403a
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 55 deletions.
74 changes: 65 additions & 9 deletions ckanext/fjelltopp_theme/assets/css/fjelltopp-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,6 @@ p.learn-more a {
color: config.$light;
}

@media (max-width: map-get(map-get($breakpoints, md), max)) {
.big-search-form #field-giant-search {
max-width: 279px;
}
}

.promoted-breadcrumbs .toolbar {
height: 170px;
}
Expand Down Expand Up @@ -387,8 +381,6 @@ $data-hub-stats-margin-left: 24px;
$data-hub-stats-margin-right: 24px;
$data-hub-stats-height: 374px;
.data-hub-stats {
margin-top: 48px;
height: 374px;
.insight-small-rect {
background-color: config.$light;
padding: 19px;
Expand Down Expand Up @@ -429,6 +421,7 @@ $data-hub-stats-height: 374px;
}
}


@media only screen and (min-width: map-get(map-get($breakpoints, sm), min)) {
.insight-small-rect:last-child {
margin-left: $data-hub-stats-margin-left;
Expand Down Expand Up @@ -477,6 +470,67 @@ $data-hub-stats-height: 374px;
}
}


.footer-stats-section .data-hub-stats {
padding-top: 64px;
padding-bottom: 64px;
height: 400px;

.row {
--bs-gutter-x: 0 !important;
}
.insight-small-rect {
background-color: config.$primary;
border: config.$light 1px solid;
color: config.$primary25;
p:first-child {
@include apply-font-style(700, 18px, 24px, config.$primary25);
}
.number span {
@include apply-font-style(400, 36px, inherit, config.$light);
}
}
}


.subscribe .container {
padding: 64px 0 0;
}

footer.site-footer .subscribe > .container > .highlight-box > .row > div:first-child {
max-width: 100% !important;
}

footer.site-footer .data-hub-stats > .row:last-child {
margin-bottom: 0;
}

footer.site-footer .data-hub-stats {
margin-left: 0;
height: auto;
width: auto;
padding: 64px 0 0;
}

.big-search-form .search-form {
margin-bottom: 0;
.input-group {
width: 100%;
}
}
.search-form {
padding-bottom: 0;
border-bottom: 0;
}

.big-search-form .lens-btn {
background-color: config.$secondary;
}

.site-footer .footer-subscribe-section {
margin-bottom: 64px;
}

/* group box (group page?) template update might be needed as well TODO */
.group-box {
background: config.$light;
Expand Down Expand Up @@ -834,6 +888,8 @@ H2.dataset-heading a {
}
}



/* footer */
.big-footer {
background: config.$primary;
Expand Down Expand Up @@ -954,7 +1010,7 @@ a.footer-link:hover,
}

.footer-search-section .lens-btn {
background-color: config.$primary10;
background-color: config.$primary65;
border: 0;
border-radius: 0 4px 4px 0;
padding-left: 36px;
Expand Down
27 changes: 16 additions & 11 deletions ckanext/fjelltopp_theme/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def get_featured_datasets():
return datasets[:3]


def get_datahub_stats(**kwargs):
def get_datahub_stats(config_data):
stats = toolkit.h.get_site_statistics()

total_datasets = {'label': 'Total datasets', 'value': stats['dataset_count']}
org = {'label': 'Teams', 'value': stats['organization_count']}
org = {'label': 'Organization', 'value': stats['organization_count']}
group = {'label': 'Categories', 'value': stats['group_count']}

now = datetime.now()
Expand All @@ -63,20 +63,25 @@ def get_datahub_stats(**kwargs):
active_users = len([user for user in users_list if user['state'] == 'active'])
active_users = {'label': 'Users', 'value': active_users}

valid_values = []
for key, value in kwargs.items():
if isinstance(value, dict) and \
'label' in value and isinstance(value['label'], str) and \
'value' in value and isinstance(value['value'], float):
valid_values.append(value)

return [
datahub_stats = [
total_datasets,
datasets_updated_this_week,
active_users,
org,
group,
] + valid_values
]

valid_values = []
for value in config_data:
if isinstance(value, dict) and \
'label' in value and isinstance(value['label'], str) and \
'value' in value and isinstance(value['value'], (float, int)):
if value['label'][0] == '-' and any(d['label'] == value['label'][1:] for d in datahub_stats): # if there is a '-' before the label we'll remove it from list
datahub_stats = [d for d in datahub_stats if d['label'] != value['label'][1:]]
else:
valid_values.append(value)

return datahub_stats + valid_values


def get_activity_stream_limit():
Expand Down
53 changes: 33 additions & 20 deletions ckanext/fjelltopp_theme/templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
{% ckan_extends %}

{% block footer_content %}
<div class="row footer-search-section">
<div class="col-xs-12 col-sm-9 col-lg-6">
<h2>{{ _('Search all datasets') }}</h2>
{% snippet 'snippets/search_input.html', placeholder='Search' %}
</div>
</div>

<div class="col-xs-6 col-sm-3 col-lg-2 footer-links">
{% block footer_logo_section %}
<a href="https://fjelltopp.org" target="_blank"><img class="footer-logo" src="/images/{% block footer_logo %}logo-white.png{% endblock %}" alt=""/></a>
{% endblock %}
</div>


<div class="row">
<div class="col-xs-12 col-sm-9 col-lg-12 footer-links">
{% block footer_nav %}
{% snippet 'snippets/footer_links.html', copyrights_owner='Fjelltopp', devs='<a class="hide-text" target="_blank" href="https://fjelltopp.org">Fjelltopp</a>' %}
{% endblock %}
</div>
<div class="row footer-search-section">
<div class="col-lg-6 col-sm-9 col-xs-12">
<h2>{{ _('Search all datasets') }}</h2>
{% snippet 'snippets/search_input.html', placeholder='Search' %}
</div>
</div>


<div class="row footer-stats-section">
<div class="col-lg-6 col-sm-9 col-xs-12">
{% snippet 'snippets/datahub_stats.html' %}
</div>
</div>

<div class="row footer-subscribe-section">
<div class="col-lg-6 col-sm-9 col-xs-12">
{% snippet 'snippets/subscribe_to_updates.html' %}
</div>
</div>

<div class="col-xs-6 col-sm-3 col-lg-2 footer-links">
{% block footer_logo_section %}
<a href="https://fjelltopp.org" target="_blank"><img class="footer-logo" src="/images/{% block footer_logo %}logo-white.png{% endblock %}" alt=""/></a>
{% endblock %}
</div>


<div class="row">
<div class="col-xs-12 col-sm-9 col-lg-12 footer-links">
{% block footer_nav %}
{% snippet 'snippets/footer_links.html', copyrights_owner='Fjelltopp', devs='<a class="hide-text" target="_blank" href="https://fjelltopp.org">Fjelltopp</a>' %}
{% endblock %}
</div>

{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{'label': 'Insight 3', 'image': 'insight_img_3.png'},
] %}

{% set default_stats = h.get_datahub_stats(more = {'label': 'Something else', 'value': 0}) %}
{% set default_stats = h.get_datahub_stats(config_data = [{'label': 'Something else', 'value': 0}]) %}

{% set labels = labels | default(default_labels) %}
{% set stats = stats | default(default_stats) %}
Expand Down
9 changes: 0 additions & 9 deletions ckanext/fjelltopp_theme/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,3 @@
{% endblock %}

{% endblock %}

{% block footer %}
<div class="big-footer {% if c.userobj %}connected{% endif %}">
{% snippet 'snippets/subscribe_to_updates.html' %}

{{ super() }}
</div>

{% endblock %}
22 changes: 22 additions & 0 deletions ckanext/fjelltopp_theme/templates/snippets/datahub_stats.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% set default_stats = h.get_datahub_stats(config_data = [{'label': 'Something else', 'value': 0}]) %}

{% set stats = stats | default(default_stats) %}

{% block data_rect %}
<div class="data-hub-stats col-lg-6 col-sm-12 col-xs-12">
{% for i in range(0, stats|length, 2) %}
<div class="row">
{% for j in range(i, i+2) %}
{% if j < stats|length %}
<div class="insight-small-rect col-lg-6 col-sm-6 col-xs-12">
<p>{{ stats[j]['label'] }}</p>
<div class="number">
<span>{{ stats[j]['value'] }}</span>
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@
{% block contents %}
<h2>{{ _('Subscribe to updates') }}</h2>
<div class="subtext">{% block subtext %}{{ _('Create an account to receive notifications by email whenever new documents are posted.') }}{% endblock %}</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-3">
<div class="col-xs-12 col-sm-12 col-md-12">
<a class="register" href="{{ h.url_for("/user/register") }}">{{ _('Create an account') }}</a>
</div>
<div class="col-xs-12 col-sm-6 col-md-9">
<span class="login">or <a href="{{ h.url_for("/user/login") }}">{{ _('log in') }}</a></span>
</div>
</div>
{% endblock %}
</div>
</div>
Expand Down

0 comments on commit c36403a

Please sign in to comment.