Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config/secrets.yml
config/sunspot.yml
config/tess.yml
config/ingestion.yml
config/initializers/local_hosts.rb
tmp/
solr/test/
solr/pids/
Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,11 @@ input[type=checkbox].field-lock + label:before,
margin: 15px;
}

.masonry-brick .space-logo {
padding: .5em;
border-radius: 4px;
}

.list-card {
@include floating-card;
border-radius: 8px;
Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/workflows.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@
bottom: 5px;
left: 5px;
z-index: 20000;

.space-logo {
padding: .5em;
border-radius: 4px;
}
}

.nav-heading-darker {
Expand Down
3 changes: 2 additions & 1 deletion app/views/about/us.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
<h3><%== t "us.keys.#{key}" %></h3>
<%== t 'us.funding' %>
<% if TeSS::Config.funders.present? %>
<% expected_space = current_space.default? ? 'default' : current_space.host %>
<p>
<% TeSS::Config.funders.each do |funder| %>
<% unless funder[:only] && funder[:only] != 'about' %>
<% if (funder[:only].blank? || funder[:only] == 'about') && (funder[:space].blank? || funder[:space] == expected_space) %>
<%= link_to(funder[:url], target: '_blank', rel: 'noopener') do -%>
<%= image_tag(funder[:logo], class: 'funding-logo') -%>
<% end %>
Expand Down
14 changes: 10 additions & 4 deletions app/views/layouts/_footer.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<% space_string_in_config = current_space.default? ? 'default' : current_space.host %>

<footer class="footer">
<div class="container">
<div class="row">
<div class="col-sm-4 col-xs-6">
<div class="footer-logo footer-item">
<%= image_tag(TeSS::Config.site['logo'], :alt => TeSS::Config.site['logo_alt']) %>
<% if TeSS::Config.site.dig('footer', 'show_space_logo') && current_space.image? %>
<%= image_tag(current_space.image.url, :alt => current_space.logo_alt) %>
<% else %>
<%= image_tag(TeSS::Config.site['logo'], :alt => TeSS::Config.site['logo_alt']) %>
<% end %>
</div>

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

<% if TeSS::Config.site.dig('footer', 'additional_links') %>
<% TeSS::Config.site.dig('footer', 'additional_links').each do |link| %>
<% if link[:location] == 'left' %>
<% if link[:location] == 'left' && (link[:space].blank? || link[:space] == space_string_in_config) %>
<div class="footer-item">
<%= link_to link[:title], link[:url] %>
</div>
Expand Down Expand Up @@ -45,7 +51,7 @@
<% end %>
<% if TeSS::Config.site.dig('footer', 'additional_links') %>
<% TeSS::Config.site.dig('footer', 'additional_links').each do |link| %>
<% if link[:location] == 'center' || !link[:location] %>
<% if (link[:location] == 'center' || !link[:location]) && (link[:space].blank? || link[:space] == space_string_in_config)%>
<div class="footer-item">
<%= link_to link[:title], link[:url] %>
</div>
Expand Down Expand Up @@ -76,7 +82,7 @@

<% if TeSS::Config.site.dig('footer', 'additional_links') %>
<% TeSS::Config.site.dig('footer', 'additional_links').each do |link| %>
<% if link[:location] == 'right' %>
<% if link[:location] == 'right' && (link[:space].blank? || link[:space] == space_string_in_config)%>
<div class="footer-item">
<%= link_to link[:title], link[:url] %>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/views/layouts/_supported_by.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<div class="col-xs-12">
<hr/>
<div class="supporters">
<% expected_space = current_space.default? ? 'default' : current_space.host %>
<%- TeSS::Config&.funders&.reverse&.each do |funder| %>
<% unless funder[:only] && funder[:only] != 'footer' %>
<% if (funder[:only].blank? || funder[:only] == 'footer') && (funder[:space].blank? || funder[:space] == expected_space) %>
<%= link_to funder[:url], class: 'footer-logo', target: '_blank', rel: 'noopener' do %>
<%= image_tag(funder[:logo]) %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spaces/_space.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<% cache(space, expires_in: 6.hours) do %>
<li class="masonry-brick media-item long">
<%= link_to space, class: 'link-overlay', style: (theme_colour ? "border-color: #{theme_colour}" : nil) do %>
<%= image_tag get_image_url_for(space), class: "media-image listing_image pull-right" %>
<%= image_tag get_image_url_for(space), class: "media-image listing_image pull-right space-logo", style: (theme_colour ? "background-color: #{theme_colour}" : nil) %>
<h4 class="mb-2 mt-3" style="<%= theme_colour ? "color: #{theme_colour}" : ''-%>">
<%= space.title %>
</h4>
Expand Down
19 changes: 15 additions & 4 deletions app/views/workflows/embed.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@
<%= render partial: 'workflows/workflow_diagram', locals: { workflow: @workflow } %>

<%= link_to @workflow, class: 'embed-floating-link', target: '_parent' do %>
<%= image_tag TeSS::Config.site['logo'],
alt: TeSS::Config.site['title'],
title: "View this workflow on #{TeSS::Config.site['title_short']}",
style: 'height: 50px;' %>
<% if TeSS::Config.site.dig('footer', 'show_space_logo') && current_space&.image? %>
<% logo_background = TeSS::Config.themes[current_space.theme]&.dig('primary') %>
<%= image_tag current_space.image.url,
alt: current_space.logo_alt,
title: "View this workflow on #{current_space.title}",
class: 'space-logo',
style: "height: 50px;#{ " background-color: #{logo_background};" if logo_background }" %>
<% else %>
<% logo_background = TeSS::Config.themes[TeSS::Config.site['default_theme']]&.dig('primary') %>
<%= image_tag TeSS::Config.site['logo'],
alt: TeSS::Config.site['logo_alt'],
title: "View this workflow on #{TeSS::Config.site['title_short']}",
class: 'space-logo',
style: "height: 50px;#{ " background-color: #{logo_background};" if logo_background }" %>
<% end %>
<% end %>
3 changes: 3 additions & 0 deletions config/tess.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ default: &default
# - url: https://example.com/
# title: Example
# location: center # Display link on 'left', 'center' or 'right', defaults to 'center'
# space: # e.g. myspace.tesshub.mydomain.com - if present, show link only in specified space ("default" for default space)
show_space_logo: false # Show space logo instead of site logo in footer
# The order in which the tabs appear (if feature enabled)
tab_order: ['about', 'events', 'materials', 'elearning_materials', 'workflows', 'collections', 'trainers', 'content_providers', 'nodes']
# The tabs that should be collapsed under the "Directory" tab. Can be left blank to hide it.
Expand Down Expand Up @@ -236,6 +238,7 @@ default: &default
# - url: https://example.org/your-funders-website
# logo: foo.png
# only: # "footer" or "about" - if pressent, show funder only in specified location
# space: # e.g. myspace.tesshub.mydomain.com - if present, show funder only in specified space
priority_licences:
- MIT
- Apache-2.0
Expand Down
2 changes: 1 addition & 1 deletion docs/spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This will ensure that if you visit e.g. plants.mytess.training, your browser wil
(you may need to restart your browser after changing the hosts file).

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

```ruby
Rails.application.config.hosts << '.mytess.training' if Rails.env.development?
Expand Down
42 changes: 41 additions & 1 deletion test/controllers/about_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AboutControllerTest < ActionController::TestCase
end

test 'should show correct funder logos in about us and footer' do
plant_space = spaces(:plants)
funder_setting = [
{
url: 'https://example.org/your-funders-website',
Expand All @@ -29,9 +30,19 @@ class AboutControllerTest < ActionController::TestCase
url: 'https://example.org/funder-about',
logo: 'https://example.org/funder-about/logo.png',
only: 'about'
},
{
url: 'https://example.org/funder-default-space',
logo: 'https://example.org/funder-default-space/logo.png',
space: 'default'
},
{
url: 'https://example.org/funder-plants-space',
logo: 'https://example.org/funder-plants-space/logo.png',
space: plant_space.host
}
]

with_settings(funders: funder_setting) do
get :us
assert_select '#funding' do
Expand All @@ -41,8 +52,13 @@ class AboutControllerTest < ActionController::TestCase
assert_select 'a[href=?]', 'https://example.org/funder-about' do
assert_select 'img[src=?]', 'https://example.org/funder-about/logo.png'
end
assert_select 'a[href=?]', 'https://example.org/funder-default-space' do
assert_select 'img[src=?]', 'https://example.org/funder-default-space/logo.png'
end
assert_select 'a[href=?]', 'https://example.org/funder-footer', count: 0
assert_select 'a[href=?]', 'https://example.org/funder-plants-space', count: 0
assert_select 'img[src=?]', 'https://example.org/funder-footer/logo.png', count: 0
assert_select 'img[src=?]', 'https://example.org/funder-plants-space/logo.png', count: 0
end

assert_select 'footer' do
Expand All @@ -52,8 +68,32 @@ class AboutControllerTest < ActionController::TestCase
assert_select 'a[href=?]', 'https://example.org/funder-footer' do
assert_select 'img[src=?]', 'https://example.org/funder-footer/logo.png'
end
assert_select 'a[href=?]', 'https://example.org/funder-default-space' do
assert_select 'img[src=?]', 'https://example.org/funder-default-space/logo.png'
end
assert_select 'a[href=?]', 'https://example.org/funder-about', count: 0
assert_select 'a[href=?]', 'https://example.org/funder-plants-space', count: 0
assert_select 'img[src=?]', 'https://example.org/funder-about/logo.png', count: 0
assert_select 'img[src=?]', 'https://example.org/funder-plants-space/logo.png', count: 0
end

with_host(plant_space.host) do
get :us
assert_select '#funding' do
assert_select 'a[href=?]', 'https://example.org/your-funders-website'
assert_select 'a[href=?]', 'https://example.org/funder-plants-space' do
assert_select 'img[src=?]', 'https://example.org/funder-plants-space/logo.png'
end
assert_select 'a[href=?]', 'https://example.org/funder-default-space', count: 0
end

assert_select 'footer' do
assert_select 'a[href=?]', 'https://example.org/your-funders-website'
assert_select 'a[href=?]', 'https://example.org/funder-plants-space' do
assert_select 'img[src=?]', 'https://example.org/funder-plants-space/logo.png'
end
assert_select 'a[href=?]', 'https://example.org/funder-default-space', count: 0
end
end
end
end
Expand Down
18 changes: 12 additions & 6 deletions test/controllers/spaces_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'test_helper'

class SpacesControllerTest < ActionController::TestCase

include Devise::Test::ControllerHelpers
include ActiveJob::TestHelper
include ActionMailer::TestHelper
Expand Down Expand Up @@ -95,7 +94,7 @@ class SpacesControllerTest < ActionController::TestCase
get :edit, params: { id: @space }
assert_response :success
end

test 'owner should not get edit for other space' do
sign_in @space.user
get :edit, params: { id: spaces(:other) }
Expand Down Expand Up @@ -250,17 +249,24 @@ class SpacesControllerTest < ActionController::TestCase
'collections': false,
'content_providers': false,
'trainers': false,
'nodes': false
}
'nodes': false }

with_settings(feature: features) do
get :edit, params: { id: @space }
assert_response :success
assert_select '[name="space[enabled_features][]"]', count: 4 # +1 because of the blank input that allows you to
# clear the list
# +1 because of the blank input that allows you to clear the list
assert_select '[name="space[enabled_features][]"]', count: 3 + 1
assert_select '#space_enabled_features_events', count: 1
assert_select '#space_enabled_features_workflows', count: 1
assert_select '#space_enabled_features_materials', count: 0
end
end

test 'space listing adds background-color style for themed space logo' do
@space.update!(theme: 'space')

get :index
assert_response :success
assert_select 'img.space-logo[style*="background-color"]'
end
end
Loading
Loading