Skip to content

Commit

Permalink
[update][l]: Research theme Section
Browse files Browse the repository at this point in the history
  • Loading branch information
sneha-sharma12 committed Aug 21, 2024
1 parent 9bfd571 commit bf0edea
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 45 deletions.
65 changes: 65 additions & 0 deletions ckanext/ubdc/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10505,6 +10505,71 @@ h4 small {
.homepage .newsletter .wrap div p {
font-weight: 300;
}
.homepage .theme {
background-image: url("../../../base/images/research-left.png"), url("../../../base/images/research-right.png");
background-position: left bottom, right bottom;
background-repeat: no-repeat, no-repeat;
background-size: 18%;
background-color: #ffffff;
border-bottom-style: none;
flex-direction: column;
justify-content: center;
padding: 5rem;
border-bottom: 1px solid #dfe1e7;
}
.homepage .theme .wrap .row {
margin-bottom: 20px;
}
.homepage .theme .block {
display: flex;
flex-wrap: wrap;
margin: 2rem 8rem;
}
.homepage .theme .panel {
height: 100px;
margin: 1.5rem 0rem;
border-radius: 12px;
}
.homepage .theme .panel .panel-body {
padding: 0.5rem;
}
.homepage .theme .panel .panel-body .media {
padding: 10px;
}
.homepage .theme .panel .panel-body .media .media-left img {
height: 70px;
}
.homepage .theme .panel .panel-body .media .media-body {
text-align: left;
padding-left: 0.5rem;
position: relative;
}
.homepage .theme .panel .panel-body .media .media-body .explore-btn {
border: 1px solid #c1c7d0;
position: absolute;
bottom: 0;
font-weight: 400;
border-radius: 8px;
padding: 5px 10px;
font-size: 14px;
text-transform: capitalize;
}
.homepage .theme .panel .panel-body .media .media-body .explore-btn:hover {
background-color: transparent;
}
.homepage .theme .panel .panel-body .media .media-heading {
font-size: 16px;
font-weight: 700;
color: #000000;
cursor: default;
}
.homepage .theme .panel .media-body {
text-align: left;
padding-left: 1rem;
}
.homepage .theme .explore-btn {
margin-top: 10px; /* Space above the button */
}
.homepage .stats {
background: url("../../../base/images/stats.png");
background-repeat: no-repeat;
Expand Down
19 changes: 19 additions & 0 deletions ckanext/ubdc/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,22 @@ def get_data_providers():
group_list = h.get_featured_organizations(limit)

return group_list


@cached(cache=TTLCache(maxsize=1024, ttl=86400))
def get_featured_groups(size=10):
# Get the data provider only when they have the image to show on homepage
group_list = []
try:

context = {"model": model, "session": model.Session}
group_list = get_action("group_list")(
context, {"all_fields": True, "limit": size}
)
except:
# Fallback to get_featured_organizations which already exists
group_list = []
limit = tk.config.get("organization_list_size_homepage", 50)
group_list = h.get_featured_organizations(limit)

return group_list
3 changes: 2 additions & 1 deletion ckanext/ubdc/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def get_helpers(self):
"get_cookie_control_config": helpers.get_cookie_control_config,
"get_field_to_question": helpers.get_field_to_question,
"get_data_providers": helpers.get_data_providers,
"get_newsletter_link": helpers.get_newsletter_link
"get_newsletter_link": helpers.get_newsletter_link,
"get_featured_groups": helpers.get_featured_groups,
}

# IValidators
Expand Down
Binary file added ckanext/ubdc/public/base/images/icons/education.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/ubdc/public/base/images/icons/governance.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/ubdc/public/base/images/research-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions ckanext/ubdc/public/base/scss/_homepage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,77 @@
}
}

.theme {
background-image: url("#{$imagePath}/research-left.png"), url("#{$imagePath}/research-right.png");
background-position: left bottom, right bottom;
background-repeat: no-repeat, no-repeat;
background-size: 18%;
background-color: #ffffff;
border-bottom-style: none;
flex-direction: column;
justify-content: center;
padding: 5rem;
border-bottom: 1px solid #dfe1e7;

.wrap .row {
margin-bottom: 20px;
}

.block {
display: flex;
flex-wrap: wrap;
margin: 2rem 8rem;
}

.panel {
height: 100px;
margin: 1.5rem 0rem;
border-radius: 12px;
.panel-body {
padding: 0.5rem;
.media {
padding: 10px;
.media-left {
img {
height: 70px;
}
}
.media-body {
text-align: left;
padding-left: 0.5rem;
position: relative;
.explore-btn {
border: 1px solid #c1c7d0;
position: absolute;
bottom: 0;
font-weight: 400;
border-radius: 8px;
padding: 5px 10px;
font-size: 14px;
text-transform: capitalize;
&:hover {
background-color: transparent;
}
}
}
.media-heading {
font-size: 16px;
font-weight: 700;
color: #000000;
cursor: default;
}
}
}
.media-body {
text-align: left;
padding-left: 1rem;
}
}
.explore-btn {
margin-top: 10px; /* Space above the button */
}
}

.stats {
background: url("#{$imagePath}/stats.png");
background-repeat: no-repeat;
Expand Down
2 changes: 1 addition & 1 deletion ckanext/ubdc/templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% snippet "home/snippets/stats.html"%}
{% snippet "home/snippets/latest.html"%}
{% snippet "home/snippets/popular.html"%}
{# {% snippet "home/snippets/themes.html"%} #}
{% snippet "home/snippets/themes.html"%}
{% snippet "home/snippets/providers.html"%}
{% snippet "home/snippets/features.html"%}
{% snippet "home/snippets/newsletter.html"%}
Expand Down
84 changes: 41 additions & 43 deletions ckanext/ubdc/templates/home/snippets/themes.html
Original file line number Diff line number Diff line change
@@ -1,57 +1,55 @@
<section class="themes hidden">
<section class="theme">
<div class="container">
<div class="wrap">
<!-- Centered Heading -->
<div class="row">
<div class="col-md-12">
<div class="title">
<h3>- {{ _('Research Themes') }} - </h3>
</div>
<div class="col-12 text-center">
<h1>Research Themes</h1>
</div>
</div>
<div class="row">
{% set themes = h.get_featured_groups(6) %}
{% for theme in themes %}
{% set url = h.url_for('group' ~ '.read', id=theme.name) %}

<div class="col-md-4 col">
<div class="item">
{% if loop.index < 4 %} <div class="media">
<div class="count">{{theme.package_count}}</div>
<div class="media-body media-right">
<h4 class="media-heading">{{ theme.title }}</h4>
<p>
{{ theme.description | truncate(80) }}
</p>
<a href="{{url}}" class="btn btn-primary">SEE DATASETS</a>
<!-- Dataset Cards -->
<div class="row block">
{% for theme in h.get_featured_groups(5) %}
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-body">
<div class="media">
<div class="media-left">
{% if loop.index == 1 %}
<img src="/base/images/icons/bus.png" alt="Bus" />
{% elif loop.index == 2 %}
<img src="/base/images/icons/home.png" alt="Home" />
{% elif loop.index == 3 %}
<img src="/base/images/icons/bag.png" alt="Bag" />
{% elif loop.index == 4 %}
<img src="/base/images/icons/leaf.png" alt="Leaf" />
{% elif loop.index == 5 %}
<img src="/base/images/icons/leaf.png" alt="Leaf" />
{% elif loop.index == 6 %}
<img src="/base/images/icons/leaf.png" alt="Leaf" />
{% endif %}
</div>
<div class="media-right media-middle">
<img class="ml-3"
src="{{theme.image_display_url or h.url_for_static('/base/images/placeholder-group.png') }}"
alt="Generic placeholder image">
<div class="media-body">
<h4 class="media-heading">
{% set title = theme.title %}
{% set trimmed_text = title|trim %}
{% if trimmed_text|length > 20 %}
{{ trimmed_text[:20] ~ "..." }}
{% else %}
{{ trimmed_text }}
{% endif %}
</h4>
<a href="/research-themes/{{ theme.name }}" class="btn btn-default btn-sm explore-btn">
Explore Research Theme <span class="arrow"></span>
</a>
</div>
</div>
{% else %}
<div class="media">
<div class="count">{{theme.package_count}} Datasets</div>
<div class="media-left media-middle">
<img class="ml-3"
src="{{theme.image_display_url or h.url_for_static('/base/images/placeholder-group.png') }}"
alt="Generic placeholder image">
</div>
<div class="media-body media-left">
<h4 class="media-heading">{{ theme.title }}</h4>
<p>
{{ theme.description | truncate(80) }}
</p>
<a href="{{ url }}" class="btn btn-primary">SEE DATASETS</a>
</div>
</div>
</div>
{% endif %}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
<p class="more"><a href="/group">See more →</a> </p>
</div>
</div>
</section>
</section>

0 comments on commit bf0edea

Please sign in to comment.