summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/helpers/content_helper.rb3
-rw-r--r--app/helpers/link_helper.rb5
-rw-r--r--app/models/page.rb5
-rw-r--r--app/views/custom/partials/_chapter.html.erb38
4 files changed, 29 insertions, 22 deletions
diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb
index 9d52c110..b2603481 100644
--- a/app/helpers/content_helper.rb
+++ b/app/helpers/content_helper.rb
@@ -98,6 +98,9 @@ module ContentHelper
98 # order_by="published_at" 98 # order_by="published_at"
99 # order_direction="DESC" 99 # order_direction="DESC"
100 # ] 100 # ]
101 #
102 # order_by currently takes id, published_at, created_at, updated_at, title
103 # and slug
101 104
102 105
103 def aggregate? content 106 def aggregate? content
diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb
index 2121133e..21e4da59 100644
--- a/app/helpers/link_helper.rb
+++ b/app/helpers/link_helper.rb
@@ -21,8 +21,9 @@ module LinkHelper
21 active = (page_path == path.sub(/^\//, "")) 21 active = (page_path == path.sub(/^\//, ""))
22 end 22 end
23 23
24 active_class = active ? {:class => 'active'} : {:class => 'inactive'} 24 html_options = html_options.merge(
25 html_options = html_options.merge(active_class) 25 :class => [html_options[:class], active ? "active" : "inactive"].compact.join(" ")
26 )
26 locale = (params[:locale] || I18n.locale).to_sym == I18n.default_locale ? nil : (params[:locale] || I18n.locale) 27 locale = (params[:locale] || I18n.locale).to_sym == I18n.default_locale ? nil : (params[:locale] || I18n.locale)
27 28
28 link_to( 29 link_to(
diff --git a/app/models/page.rb b/app/models/page.rb
index a66527da..8313b1d4 100644
--- a/app/models/page.rb
+++ b/app/models/page.rb
@@ -92,6 +92,11 @@ class Page < ApplicationRecord
92 .paginate(:page => page, :per_page => options[:limit]) 92 .paginate(:page => page, :per_page => options[:limit])
93 end 93 end
94 94
95 if options[:order_by] == "slug"
96 return scope.order(Arel.sql("MIN(LOWER(nodes.slug)) #{direction}"))
97 .paginate(:page => page, :per_page => options[:limit])
98 end
99
95 column = options[:order_by].to_s.sub(/\Apages\./, "") 100 column = options[:order_by].to_s.sub(/\Apages\./, "")
96 column = "id" unless %w[id published_at created_at updated_at].include?(column) 101 column = "id" unless %w[id published_at created_at updated_at].include?(column)
97 102
diff --git a/app/views/custom/partials/_chapter.html.erb b/app/views/custom/partials/_chapter.html.erb
index 5d47679e..8a92b46f 100644
--- a/app/views/custom/partials/_chapter.html.erb
+++ b/app/views/custom/partials/_chapter.html.erb
@@ -1,26 +1,24 @@
1<div class="article_partial chapter_partial" lang="<%= page.effective_lang %>"> 1<div class="article_partial chapter_partial" lang="<%= page.effective_lang %>">
2 <div class="chapter_partial_layout"> 2 <div class="chapter_partial_layout">
3 <% if page.headline_asset %> 3 <% if page.headline_asset %>
4 <%= link_to_path image_tag(page.headline_asset.upload.url(:thumb), :alt => ""), page.node.unique_name, class: "chapter_thumbnail" %> 4 <%= link_to_path image_tag(page.headline_asset.upload.url(:medium), :alt => ""), page.node.unique_name, class: "chapter_thumbnail" %>
5 <% end %> 5 <% end %>
6 <div class="chapter_partial_content"> 6 <h2 class="headline"><%= link_to_path page.title, page.node.unique_name %></h2>
7 <h2 class="headline"><%= link_to_path page.title, page.node.unique_name %></h2> 7 <% if page.abstract.present? %>
8 <% if page.abstract.present? %> 8 <div class="chapter_location"><%= page.abstract %></div>
9 <div class="chapter_location"><%= page.abstract %></div> 9 <% end %>
10 <% end %> 10 <% if page.node.external_url.present? %>
11 <% if page.node.external_url.present? %> 11 <div class="chapter_url"><%= link_to page.node.external_url, page.node.external_url, target: '_blank', rel: 'noopener' %></div>
12 <div class="chapter_url"><%= link_to page.node.external_url, page.node.external_url, target: '_blank', rel: 'noopener' %></div> 12 <% end %>
13 <% end %> 13 <% open_days = page.node.events.tagged_with('open-day').order(:start_time) %>
14 <% open_days = page.node.events.tagged_with('open-day').order(:start_time) %> 14 <% if open_days.any? %>
15 <% if open_days.any? %> 15 <div class="chapter_open_days">
16 <div class="chapter_open_days"> 16 <span class="open_days_label"><%= t(:open_days_label) %>: </span>
17 <span class="open_days_label"><%= t(:open_days_label) %>: </span> 17 <% open_days.each do |event| %>
18 <% open_days.each do |event| %> 18 <span class="event_schedule"><%= event_schedule_text(event) %></span>
19 <span class="event_schedule"><%= event_schedule_text(event) %></span> 19 <% end %>
20 <% end %> 20 </div>
21 </div> 21 <% end %>
22 <% end %> 22 <p class="excerpt"><%= sanitize page.body %></p>
23 <p class="excerpt"><%= sanitize page.body %></p>
24 </div>
25 </div> 23 </div>
26</div> 24</div>