Skip to content

Commit b398dba

Browse files
authored
Merge pull request #1269 from pan-training/configurable_footer_logos
Configurable footer logos
2 parents b97ba40 + d2899f6 commit b398dba

13 files changed

Lines changed: 170 additions & 52 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ config/secrets.yml
1515
config/sunspot.yml
1616
config/tess.yml
1717
config/ingestion.yml
18+
config/initializers/local_hosts.rb
1819
tmp/
1920
solr/test/
2021
solr/pids/

app/assets/stylesheets/application.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,11 @@ input[type=checkbox].field-lock + label:before,
808808
margin: 15px;
809809
}
810810

811+
.masonry-brick .space-logo {
812+
padding: .5em;
813+
border-radius: 4px;
814+
}
815+
811816
.list-card {
812817
@include floating-card;
813818
border-radius: 8px;

app/assets/stylesheets/workflows.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@
160160
bottom: 5px;
161161
left: 5px;
162162
z-index: 20000;
163+
164+
.space-logo {
165+
padding: .5em;
166+
border-radius: 4px;
167+
}
163168
}
164169

165170
.nav-heading-darker {

app/views/about/us.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
<h3><%== t "us.keys.#{key}" %></h3>
1717
<%== t 'us.funding' %>
1818
<% if TeSS::Config.funders.present? %>
19+
<% expected_space = current_space.default? ? 'default' : current_space.host %>
1920
<p>
2021
<% TeSS::Config.funders.each do |funder| %>
21-
<% unless funder[:only] && funder[:only] != 'about' %>
22+
<% if (funder[:only].blank? || funder[:only] == 'about') && (funder[:space].blank? || funder[:space] == expected_space) %>
2223
<%= link_to(funder[:url], target: '_blank', rel: 'noopener') do -%>
2324
<%= image_tag(funder[:logo], class: 'funding-logo') -%>
2425
<% end %>

app/views/layouts/_footer.html.erb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
<% space_string_in_config = current_space.default? ? 'default' : current_space.host %>
2+
13
<footer class="footer">
24
<div class="container">
35
<div class="row">
46
<div class="col-sm-4 col-xs-6">
57
<div class="footer-logo footer-item">
6-
<%= image_tag(TeSS::Config.site['logo'], :alt => TeSS::Config.site['logo_alt']) %>
8+
<% if TeSS::Config.site.dig('footer', 'show_space_logo') && current_space.image? %>
9+
<%= image_tag(current_space.image.url, :alt => current_space.logo_alt) %>
10+
<% else %>
11+
<%= image_tag(TeSS::Config.site['logo'], :alt => TeSS::Config.site['logo_alt']) %>
12+
<% end %>
713
</div>
814

915
<div class="footer-item contact-link">
@@ -12,7 +18,7 @@
1218

1319
<% if TeSS::Config.site.dig('footer', 'additional_links') %>
1420
<% TeSS::Config.site.dig('footer', 'additional_links').each do |link| %>
15-
<% if link[:location] == 'left' %>
21+
<% if link[:location] == 'left' && (link[:space].blank? || link[:space] == space_string_in_config) %>
1622
<div class="footer-item">
1723
<%= link_to link[:title], link[:url] %>
1824
</div>
@@ -45,7 +51,7 @@
4551
<% end %>
4652
<% if TeSS::Config.site.dig('footer', 'additional_links') %>
4753
<% TeSS::Config.site.dig('footer', 'additional_links').each do |link| %>
48-
<% if link[:location] == 'center' || !link[:location] %>
54+
<% if (link[:location] == 'center' || !link[:location]) && (link[:space].blank? || link[:space] == space_string_in_config)%>
4955
<div class="footer-item">
5056
<%= link_to link[:title], link[:url] %>
5157
</div>
@@ -76,7 +82,7 @@
7682

7783
<% if TeSS::Config.site.dig('footer', 'additional_links') %>
7884
<% TeSS::Config.site.dig('footer', 'additional_links').each do |link| %>
79-
<% if link[:location] == 'right' %>
85+
<% if link[:location] == 'right' && (link[:space].blank? || link[:space] == space_string_in_config)%>
8086
<div class="footer-item">
8187
<%= link_to link[:title], link[:url] %>
8288
</div>

app/views/layouts/_supported_by.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<div class="col-xs-12">
22
<hr/>
33
<div class="supporters">
4+
<% expected_space = current_space.default? ? 'default' : current_space.host %>
45
<%- TeSS::Config&.funders&.reverse&.each do |funder| %>
5-
<% unless funder[:only] && funder[:only] != 'footer' %>
6+
<% if (funder[:only].blank? || funder[:only] == 'footer') && (funder[:space].blank? || funder[:space] == expected_space) %>
67
<%= link_to funder[:url], class: 'footer-logo', target: '_blank', rel: 'noopener' do %>
78
<%= image_tag(funder[:logo]) %>
89
<% end %>

app/views/spaces/_space.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<% cache(space, expires_in: 6.hours) do %>
33
<li class="masonry-brick media-item long">
44
<%= link_to space, class: 'link-overlay', style: (theme_colour ? "border-color: #{theme_colour}" : nil) do %>
5-
<%= image_tag get_image_url_for(space), class: "media-image listing_image pull-right" %>
5+
<%= image_tag get_image_url_for(space), class: "media-image listing_image pull-right space-logo", style: (theme_colour ? "background-color: #{theme_colour}" : nil) %>
66
<h4 class="mb-2 mt-3" style="<%= theme_colour ? "color: #{theme_colour}" : ''-%>">
77
<%= space.title %>
88
</h4>

app/views/workflows/embed.html.erb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,19 @@
1313
<%= render partial: 'workflows/workflow_diagram', locals: { workflow: @workflow } %>
1414

1515
<%= link_to @workflow, class: 'embed-floating-link', target: '_parent' do %>
16-
<%= image_tag TeSS::Config.site['logo'],
17-
alt: TeSS::Config.site['title'],
18-
title: "View this workflow on #{TeSS::Config.site['title_short']}",
19-
style: 'height: 50px;' %>
16+
<% if TeSS::Config.site.dig('footer', 'show_space_logo') && current_space&.image? %>
17+
<% logo_background = TeSS::Config.themes[current_space.theme]&.dig('primary') %>
18+
<%= image_tag current_space.image.url,
19+
alt: current_space.logo_alt,
20+
title: "View this workflow on #{current_space.title}",
21+
class: 'space-logo',
22+
style: "height: 50px;#{ " background-color: #{logo_background};" if logo_background }" %>
23+
<% else %>
24+
<% logo_background = TeSS::Config.themes[TeSS::Config.site['default_theme']]&.dig('primary') %>
25+
<%= image_tag TeSS::Config.site['logo'],
26+
alt: TeSS::Config.site['logo_alt'],
27+
title: "View this workflow on #{TeSS::Config.site['title_short']}",
28+
class: 'space-logo',
29+
style: "height: 50px;#{ " background-color: #{logo_background};" if logo_background }" %>
30+
<% end %>
2031
<% end %>

config/tess.example.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ default: &default
123123
# - url: https://example.com/
124124
# title: Example
125125
# location: center # Display link on 'left', 'center' or 'right', defaults to 'center'
126+
# space: # e.g. myspace.tesshub.mydomain.com - if present, show link only in specified space ("default" for default space)
127+
show_space_logo: false # Show space logo instead of site logo in footer
126128
# The order in which the tabs appear (if feature enabled)
127129
tab_order: ['about', 'events', 'materials', 'elearning_materials', 'workflows', 'collections', 'trainers', 'content_providers', 'nodes']
128130
# The tabs that should be collapsed under the "Directory" tab. Can be left blank to hide it.
@@ -236,6 +238,7 @@ default: &default
236238
# - url: https://example.org/your-funders-website
237239
# logo: foo.png
238240
# only: # "footer" or "about" - if pressent, show funder only in specified location
241+
# space: # e.g. myspace.tesshub.mydomain.com - if present, show funder only in specified space
239242
priority_licences:
240243
- MIT
241244
- Apache-2.0

docs/spaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This will ensure that if you visit e.g. plants.mytess.training, your browser wil
1818
(you may need to restart your browser after changing the hosts file).
1919

2020
To ensure your Rails application accepts requests to the hosts provided above, you will also need to create a
21-
file `config/initializers/hosts.rb` and add the necessary hosts to Rails' config:
21+
file `config/initializers/local_hosts.rb` and add the necessary hosts to Rails' config:
2222

2323
```ruby
2424
Rails.application.config.hosts << '.mytess.training' if Rails.env.development?

0 commit comments

Comments
 (0)