Skip to content

Commit

Permalink
Merge branch '1433-front-end-papers'
Browse files Browse the repository at this point in the history
  • Loading branch information
garethrees committed Mar 16, 2023
2 parents 1db1164 + 1ef05bd commit 530bef9
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 1 deletion.
44 changes: 43 additions & 1 deletion app/assets/stylesheets/responsive/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,48 @@ p.locale-list-trigger {
}
}

.homepage-article-section {
padding: 2em 0;
border-bottom: 1px solid darken($color_light_grey, 7%);;
margin-bottom: 2rem;
.ar-content__headings {
text-align: center;
margin-bottom: 3rem;
h2 {
margin-bottom: 0;
margin-top: 0;
}
}
.col-2-grid {
margin-bottom: 3rem;
}
}

.article-grid__item {
display: flex;
flex-direction: row;
align-items: flex-start;
.item-content__img {
max-width: 25%;
object-fit: contain;
margin-right: 1rem;
}
.item-content__heading {
margin-top: 0;
font-size: 1.1em;
}
}

.col-2-grid {
display: grid;
column-gap: 4rem;
row-gap: 2rem;
padding: 0 0.9375rem; //same as foundation's screen-edge gutter;
@media (min-width: $main_menu-mobile_menu_cutoff ) {
grid-template-columns: repeat(2, 1fr);
}
}

.cta-button-wrapper {
text-align: center;
a.button {
Expand Down Expand Up @@ -2093,4 +2135,4 @@ $color_asktheeu_dark_green: #C4DDB9;
display: none;
visibility: hidden;
}
}
}
52 changes: 52 additions & 0 deletions lib/views/general/_frontpage_articles.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<% cache_if_caching_fragments("frontpage-research-papers-#{@locale}", expires_in: 1.hour) do %>
<%
begin
uri = 'https://research.mysociety.org/embed/foi/limit:10/format:json/'
response = quietly_try_to_open(uri, 5)

@research_articles =
if response.empty?
[]
else
JSON.parse(response).
with_indifferent_access[:items].
map { |item| item.slice(:title, :desc, :url, :thumbnail) }
end
end
%>
<% if @research_articles.any? %>
<div class="homepage-article-section" id="homepage-article">
<div class="row homepage-article-section__ar-contet">
<div class="ar-content__headings ">
<h2><%= _('Our Freedom of Information Research') %></h2>
</div>

<div class="ar-content__article-grid col-2-grid">
<% @research_articles.sample(6).each do |article| %>
<div class="article-grid__item">
<%= image_tag article[:thumbnail], alt: _('Cover for: {{article_title}}', article_title: article[:title]), class: 'item-content__img', loading: 'lazy' %>

<div class="article-grid__item-content">
<h3 class="item-content__heading">
<%= article[:title] %>
</h3>

<p>
<%= article[:desc] %>
</p>

<%= link_to _('Read article'), article[:url] %>
</div>
</div>
<% end %>
</div>

<div class="cta-button-wrapper">
<a class="button" href="<%= donation_url(utm_content: 'homepage donate', utm_campaign: 'wdtk-homepage-research-papers') %>">Donate now</a>
<span>to support our research or <a href="https://research.mysociety.org/section/foi">browse more</a></span>
</div>
</div>
</div>
<% end %>
<% end %>
1 change: 1 addition & 0 deletions lib/views/general/_frontpage_extra.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<%= render :partial => "frontpage_videos" %>
<%= render :partial => "frontpage_articles" %>

0 comments on commit 530bef9

Please sign in to comment.