summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/page_translations_controller.rb5
-rw-r--r--app/controllers/revisions_controller.rb16
-rw-r--r--app/views/page_translations/edit.html.erb2
-rw-r--r--app/views/page_translations/index.html.erb19
-rw-r--r--app/views/page_translations/show.html.erb2
-rw-r--r--app/views/revisions/index.html.erb19
-rw-r--r--app/views/revisions/show.html.erb11
7 files changed, 40 insertions, 34 deletions
diff --git a/app/controllers/page_translations_controller.rb b/app/controllers/page_translations_controller.rb
index 9446cd2..38a7c4f 100644
--- a/app/controllers/page_translations_controller.rb
+++ b/app/controllers/page_translations_controller.rb
@@ -5,11 +5,6 @@ class PageTranslationsController < ApplicationController
5 before_action :find_node 5 before_action :find_node
6 before_action :find_locale, :only => [:show, :edit, :update, :autosave, :destroy] 6 before_action :find_locale, :only => [:show, :edit, :update, :autosave, :destroy]
7 7
8 def index
9 page = @node.draft || @node.head
10 @translations = page ? page.translation_summary : []
11 end
12
13 def show 8 def show
14 @page = @node.draft || @node.head 9 @page = @node.draft || @node.head
15 @translation = @page.translations.find_by(:locale => @locale) 10 @translation = @page.translations.find_by(:locale => @locale)
diff --git a/app/controllers/revisions_controller.rb b/app/controllers/revisions_controller.rb
index 0aed243..c5932a4 100644
--- a/app/controllers/revisions_controller.rb
+++ b/app/controllers/revisions_controller.rb
@@ -5,10 +5,11 @@ class RevisionsController < ApplicationController
5 before_action :login_required 5 before_action :login_required
6 6
7 layout 'admin' 7 layout 'admin'
8 8
9 def index 9 def index
10 @node = Node.find(params[:node_id]) 10 @node = Node.find(params[:node_id])
11 @pages = @node.pages.all 11 @pages = @node.pages.all
12 @locale = resolve_locale(params[:locale])
12 end 13 end
13 14
14 def diff 15 def diff
@@ -43,6 +44,7 @@ class RevisionsController < ApplicationController
43 def show 44 def show
44 @node = Node.find(params[:node_id]) 45 @node = Node.find(params[:node_id])
45 @page = @node.pages.find(params[:id]) 46 @page = @node.pages.find(params[:id])
47 @locale = resolve_locale(params[:locale])
46 end 48 end
47 49
48 def restore 50 def restore
@@ -51,4 +53,12 @@ class RevisionsController < ApplicationController
51 flash[:notice] = "Revision #{page.revision} restored" 53 flash[:notice] = "Revision #{page.revision} restored"
52 redirect_to node_path(page.node) 54 redirect_to node_path(page.node)
53 end 55 end
56
57 private
58
59 def resolve_locale(requested)
60 candidate = requested.presence&.to_sym
61 allowed = [I18n.default_locale] + Page.non_default_locales
62 allowed.include?(candidate) ? candidate : I18n.default_locale
63 end
54end 64end
diff --git a/app/views/page_translations/edit.html.erb b/app/views/page_translations/edit.html.erb
index 89b594e..981fb74 100644
--- a/app/views/page_translations/edit.html.erb
+++ b/app/views/page_translations/edit.html.erb
@@ -2,6 +2,8 @@
2 Editing the <strong><%= @locale.to_s.upcase %></strong> translation of <strong><%= title_for_node(@node) %></strong>. 2 Editing the <strong><%= @locale.to_s.upcase %></strong> translation of <strong><%= title_for_node(@node) %></strong>.
3</div> 3</div>
4 4
5<p class="node_action_bar standalone_action_bar"><%= link_to 'View revision history', node_revisions_path(@node, :locale => @locale) %></p>
6
5<p class="field_hint"> 7<p class="field_hint">
6 Metadata such as images, tags, template, and author belong to the page 8 Metadata such as images, tags, template, and author belong to the page
7 as a whole, not to a single translation — change those from the 9 as a whole, not to a single translation — change those from the
diff --git a/app/views/page_translations/index.html.erb b/app/views/page_translations/index.html.erb
deleted file mode 100644
index a8c4f5d..0000000
--- a/app/views/page_translations/index.html.erb
+++ /dev/null
@@ -1,19 +0,0 @@
1<h1>Translations — <%= title_for_node(@node) %></h1>
2
3<div class="node_content node_info_group">
4 <div class="node_info_group_items">
5 <% @translations.each do |t| %>
6 <div class="node_info_item">
7 <span class="node_info_label"><%= t[:locale].to_s.upcase %></span>
8 <% if t[:exists] %>
9 <%= t[:title] %> — updated <%= t[:updated_at] %>
10 <% if t[:outdated] %><span class="warning">may be outdated</span><% end %>
11 <%= link_to 'Edit', edit_node_translation_path(@node, t[:locale]) %>
12 <% else %>
13 <span class="field_hint">Not yet translated.</span>
14 <%= link_to 'Add', edit_node_translation_path(@node, t[:locale]) %>
15 <% end %>
16 </div>
17 <% end %>
18 </div>
19</div>
diff --git a/app/views/page_translations/show.html.erb b/app/views/page_translations/show.html.erb
index c5bd151..60eb7cf 100644
--- a/app/views/page_translations/show.html.erb
+++ b/app/views/page_translations/show.html.erb
@@ -1,5 +1,7 @@
1<h1>Compare — <%= title_for_node(@node) %></h1> 1<h1>Compare — <%= title_for_node(@node) %></h1>
2 2
3<p class="node_action_bar standalone_action_bar"><%= link_to 'View revision history', node_revisions_path(@node, :locale => @locale) %></p>
4
3<div class="translation_compare"> 5<div class="translation_compare">
4 <div class="translation_compare_column"> 6 <div class="translation_compare_column">
5 <h2><%= @locale.to_s.upcase %></h2> 7 <h2><%= @locale.to_s.upcase %></h2>
diff --git a/app/views/revisions/index.html.erb b/app/views/revisions/index.html.erb
index 4680ae2..7ea74a6 100644
--- a/app/views/revisions/index.html.erb
+++ b/app/views/revisions/index.html.erb
@@ -4,6 +4,20 @@
4 <%= link_to 'Back to node', node_path(@node) %> 4 <%= link_to 'Back to node', node_path(@node) %>
5</p> 5</p>
6 6
7<% if Page.non_default_locales.any? %>
8 <p class="diff_locale_toggle">
9 Locale:
10 <% ([I18n.default_locale] + Page.non_default_locales).each_with_index do |locale, i| %>
11 <%= " &middot; ".html_safe if i > 0 %>
12 <% if locale == @locale %>
13 <strong><%= locale.to_s.upcase %></strong>
14 <% else %>
15 <%= link_to locale.to_s.upcase, node_revisions_path(@node, :locale => locale) %>
16 <% end %>
17 <% end %>
18 </p>
19<% end %>
20
7<table id="revisions" class="revisions_table"> 21<table id="revisions" class="revisions_table">
8 <thead> 22 <thead>
9 <tr class="header"> 23 <tr class="header">
@@ -20,6 +34,7 @@
20 <td colspan="8"> 34 <td colspan="8">
21 <%= button_to 'Diff revisions', diff_node_revisions_path(@node), 35 <%= button_to 'Diff revisions', diff_node_revisions_path(@node),
22 method: :post, 36 method: :post,
37 params: { locale: @locale },
23 form: { id: 'diff_form', class: 'button_to computation' }, 38 form: { id: 'diff_form', class: 'button_to computation' },
24 disabled: true %> 39 disabled: true %>
25 <span id="diff_selection_label"></span> 40 <span id="diff_selection_label"></span>
@@ -35,10 +50,10 @@
35 <td><%= radio_button_tag :start_revision, page.revision, index == 1 %></td> 50 <td><%= radio_button_tag :start_revision, page.revision, index == 1 %></td>
36 <td><%= radio_button_tag :end_revision, page.revision, index == 0 %></td> 51 <td><%= radio_button_tag :end_revision, page.revision, index == 0 %></td>
37 <td class="revision"><%= page.revision %></td> 52 <td class="revision"><%= page.revision %></td>
38 <td class="title"><%= page.title %></td> 53 <td class="title"><%= page.translations.find_by(:locale => @locale)&.title || "—" %></td>
39 <td class="user"><%= page.editor.try(:login) %></td> 54 <td class="user"><%= page.editor.try(:login) %></td>
40 <td class="date"><%= page.updated_at %></td> 55 <td class="date"><%= page.updated_at %></td>
41 <td><%= link_to 'show', node_revision_path(@node, page) %></td> 56 <td><%= link_to 'show', node_revision_path(@node, page, :locale => @locale) %></td>
42 <td> 57 <td>
43 <%= button_to 'restore', restore_node_revision_path(@node, page), 58 <%= button_to 'restore', restore_node_revision_path(@node, page),
44 method: :put, 59 method: :put,
diff --git a/app/views/revisions/show.html.erb b/app/views/revisions/show.html.erb
index 92d959b..74fb51f 100644
--- a/app/views/revisions/show.html.erb
+++ b/app/views/revisions/show.html.erb
@@ -1,12 +1,13 @@
1<% translation = @page.translations.find_by(:locale => @locale) %>
1<div id="page_editor" class="show_node"> 2<div id="page_editor" class="show_node">
2 <h1>Revision <%= @page.revision %>: <%= @page.title %></h1> 3 <h1>Revision <%= @page.revision %>: <%= translation&.title %> <small>(<%= @locale.to_s.upcase %>)</small></h1>
3 4
4 <div id="content"> 5 <div id="content">
5 <div class="node_description">Actions</div> 6 <div class="node_description">Actions</div>
6 <div class="node_content node_info_group"> 7 <div class="node_content node_info_group">
7 <div class="node_info_group_items"> 8 <div class="node_info_group_items">
8 <div class="node_info_item"> 9 <div class="node_info_item">
9 <%= link_to 'Show all revisions', node_revisions_path(@node) %> 10 <%= link_to 'Show all revisions', node_revisions_path(@node, :locale => @locale) %>
10 </div> 11 </div>
11 </div> 12 </div>
12 </div> 13 </div>
@@ -27,12 +28,12 @@
27 <div class="node_content"><%= @page.published_at %></div> 28 <div class="node_content"><%= @page.published_at %></div>
28 29
29 <div class="node_description">Title</div> 30 <div class="node_description">Title</div>
30 <div class="node_content"><%= @page.title %></div> 31 <div class="node_content"><%= translation&.title %></div>
31 32
32 <div class="node_description">Abstract</div> 33 <div class="node_description">Abstract</div>
33 <div class="node_content"><%= @page.abstract %></div> 34 <div class="node_content"><%= translation&.abstract %></div>
34 35
35 <div class="node_description">Body</div> 36 <div class="node_description">Body</div>
36 <div class="node_content"><%= raw @page.body %></div> 37 <div class="node_content"><%= raw translation&.body %></div>
37 </div> 38 </div>
38</div> 39</div>