Skip to content

Commit 64d8e91

Browse files
committed
Different front page when in a space
1 parent 5fa2345 commit 64d8e91

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed

app/controllers/static_controller.rb

+7-6
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ def set_count_strings
7878
count_strings = {}
7979
return count_strings unless TeSS::Config.site.dig('home_page', 'counters')
8080

81-
count_strings['events'] = Event.where.not(end: nil).where('events.end > ?', Time.zone.now).count
82-
count_strings['last_month_events'] = Event.where('events.created_at > ?', 1.month.ago).count
83-
count_strings['materials'] = Material.all.count
84-
count_strings['workflows'] = Workflow.all.count
85-
count_strings['content_providers'] = ContentProvider.all.count
86-
count_strings['trainers'] = Trainer.all.count
81+
count_strings['events'] = Space.current_space.events.where.not(end: nil).where('events.end > ?', Time.zone.now).count
82+
count_strings['last_month_events'] = Space.current_space.events.where('events.created_at > ?', 1.month.ago).count
83+
count_strings['materials'] = Space.current_space.materials.count
84+
count_strings['workflows'] = Space.current_space.workflows.count
85+
count_strings['learning_paths'] = Space.current_space.learning_paths.count
86+
count_strings['content_providers'] = ContentProvider.count
87+
count_strings['trainers'] = Trainer.count
8788
count_strings
8889
end
8990
end

app/views/static/home.html.erb

+14-8
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,27 @@
2222
}
2323
</script>
2424

25-
<%= render partial: 'communities/banner' if TeSS::Config.site.dig('home_page', 'communities') %>
25+
<% if current_space.default? %>
26+
<%= render partial: 'communities/banner' if TeSS::Config.site.dig('home_page', 'communities') %>
2627

27-
<%= render partial: 'static/home/welcome' %>
28+
<%= render partial: 'static/home/welcome' %>
2829

29-
<%= render partial: 'static/home/counters' if TeSS::Config.site.dig('home_page', 'counters') %>
30+
<%= render partial: 'static/home/counters' if TeSS::Config.site.dig('home_page', 'counters') %>
3031

31-
<%= render partial: 'static/home/catalogue_blocks' if TeSS::Config.site.dig('home_page', 'catalogue_blocks') %>
32+
<%= render partial: 'static/home/catalogue_blocks' if TeSS::Config.site.dig('home_page', 'catalogue_blocks') %>
3233

33-
<%= render partial: 'static/home/provider_carousel' if TeSS::Config.site.dig('home_page', 'provider_carousel') %>
34+
<%= render partial: 'static/home/provider_carousel' if TeSS::Config.site.dig('home_page', 'provider_carousel') %>
3435

35-
<%= render partial: 'static/home/provider_grid' if TeSS::Config.site.dig('home_page', 'provider_grid') %>
36+
<%= render partial: 'static/home/provider_grid' if TeSS::Config.site.dig('home_page', 'provider_grid') %>
3637

37-
<%= render partial: 'static/home/faq' if TeSS::Config.site.dig('home_page', 'faq')&.any? %>
38+
<%= render partial: 'static/home/faq' if TeSS::Config.site.dig('home_page', 'faq')&.any? %>
3839

39-
<%= render partial: 'static/home/promo_blocks' if TeSS::Config.site.dig('home_page', 'promo_blocks') %>
40+
<%= render partial: 'static/home/promo_blocks' if TeSS::Config.site.dig('home_page', 'promo_blocks') %>
41+
<% else %>
42+
<%= render partial: 'static/home/space_welcome' %>
43+
44+
<%= render partial: 'static/home/counters' %>
45+
<% end %>
4046

4147
<%= render partial: 'static/home/upcoming_events' if @events.present? %>
4248

app/views/static/home/_counters.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<% features = ['events', 'materials', 'workflows', 'trainers'].select { |f| TeSS::Config.feature[f] } %>
1+
<% features = ['events', 'materials', 'workflows', 'learning_paths', 'trainers'].select { |f| TeSS::Config.feature[f] } %>
22

33
<section id="counters">
44
<ul class="counter">
55
<% features.each do |feature| %>
66
<li class="resource-counter">
77
<%= link_to polymorphic_path(feature), class: 'link-overlay' do %>
88
<div class="resource-counter-title">
9-
<%= image_tag(asset_path("modern/icons/#{feature}-icon.svg"), alt: feature.titleize) %>
9+
<%= image_tag(asset_path("modern/icons/#{feature.dasherize}-icon.svg"), alt: feature.titleize) %>
1010
</div>
1111

1212
<div id='resource_count' class='resource-counter-number'> <%= @count_strings[feature] %> </div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<section>
2+
<%# Welcome text %>
3+
<div class="welcome-text">
4+
<h1 class="module-heading"><%= current_space.title %></h1>
5+
<div class="description font-size-lg">
6+
<%= render_markdown current_space.description %>
7+
</div>
8+
</div>
9+
10+
<%# Big search box %>
11+
<div class="searchbox">
12+
<%= form_tag search_path, method: :get, role: 'search' do %>
13+
<div class="searchbox-wrapper">
14+
<input type="text" class="searchbox-field" name="q"
15+
placeholder= "<%= t('home.search_placeholder', site_name: current_space.title) %>" autofocus="autofocus">
16+
<button type="submit" class="searchbox-btn">
17+
<i class="icon icon-h3 search-icon"></i>
18+
</button>
19+
</div>
20+
<% end %>
21+
</div>
22+
</section>

0 commit comments

Comments
 (0)