diff options
Diffstat (limited to 'app/views/nodes/show.html.erb')
| -rw-r--r-- | app/views/nodes/show.html.erb | 307 |
1 files changed, 248 insertions, 59 deletions
diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb index de4d8a2..1469572 100644 --- a/app/views/nodes/show.html.erb +++ b/app/views/nodes/show.html.erb | |||
| @@ -1,62 +1,251 @@ | |||
| 1 | <% content_for :subnavigation do %> | 1 | <% locked_by_other = @node.locked? && @node.lock_owner != current_user %> |
| 2 | <%= link_to 'Edit', edit_node_path(@node), :class => "unselected" %> | 2 | <div id="page_editor" class="show_node"> |
| 3 | <%= link_to 'Preview', preview_page_path(@page) %> | 3 | <h1><%= title_for_node(@node) %> <small>(<%= I18n.default_locale.to_s.upcase %>)</small></h1> |
| 4 | <%= link_to 'Revisions', node_revisions_path(@node) %> | 4 | <div id="content"> |
| 5 | <%= unlock_link if @node.locked? %> | 5 | <div class="node_description">Status</div> |
| 6 | <% end %> | 6 | <div class="node_content node_info_group node_status"> |
| 7 | <div class="node_info_group_items"> | ||
| 8 | <div class="node_info_item"> | ||
| 9 | <span class="node_info_label">Head</span> | ||
| 10 | <%= @node.head ? "#{@node.head.title} (rev #{@node.head.revision}, #{@node.head.updated_at})" : "none — never published" %> | ||
| 11 | </div> | ||
| 12 | <div class="node_info_item"> | ||
| 13 | <span class="node_info_label">Draft</span> | ||
| 14 | <%= @node.draft ? "#{@node.draft.title} (rev #{@node.draft.revision}, saved #{@node.draft.updated_at})" : "none" %> | ||
| 15 | </div> | ||
| 16 | <div class="node_info_item"> | ||
| 17 | <span class="node_info_label">Autosave</span> | ||
| 18 | <%= @node.autosave ? "#{@node.autosave.title} (unsaved, #{@node.autosave.updated_at})" : "none" %> | ||
| 19 | </div> | ||
| 20 | </div> | ||
| 7 | 21 | ||
| 22 | <% edit_label = @node.autosave ? "Continue Editing" : (@node.draft ? "Edit Draft" : "Edit") %> | ||
| 23 | <div class="node_info_group_items"> | ||
| 24 | <div class="node_info_item"> | ||
| 25 | <% if locked_by_other %> | ||
| 26 | <span class="disabled_action"><%= edit_label %></span> | ||
| 27 | <% else %> | ||
| 28 | <%= link_to edit_node_path(@node), class: "action_button" do %> | ||
| 29 | <%= icon("edit", library: "tabler", "aria-hidden": true) %> | ||
| 30 | <%= @node.autosave ? "Continue Editing" : (@node.draft ? "Edit Draft" : "Lock + Edit") %> | ||
| 31 | <% end %> | ||
| 32 | <% if !@node.draft && !@node.autosave %> | ||
| 33 | <span class="field_hint">Nothing pending — this will start a fresh draft.</span> | ||
| 34 | <% end %> | ||
| 35 | <% end %> | ||
| 36 | </div> | ||
| 8 | 37 | ||
| 9 | <div id="page_editor" class="show_node"> | 38 | <% @node.available_layer_pairs.each do |pair| %> |
| 10 | <table id="content"> | 39 | <div class="node_info_item"> |
| 11 | <tr> | 40 | <%= button_to "Diff #{pair.first.to_s.capitalize} vs. #{pair.last.to_s.capitalize}", |
| 12 | <td class="description">Public Link</td> | 41 | diff_node_revisions_path(@node), |
| 13 | <td><%= link_to @page.public_link, content_url(@node.unique_path) %></td> | 42 | method: :get, |
| 14 | </tr> | 43 | params: { start_revision: pair.first, end_revision: pair.last }, |
| 15 | <tr> | 44 | form: { class: 'button_to computation' } %> |
| 16 | <td class="description">Author</td> | 45 | </div> |
| 17 | <td><%= @page.user.try(:login) %></td> | 46 | <% end %> |
| 18 | </tr> | 47 | |
| 19 | <tr> | 48 | <% unless locked_by_other %> |
| 20 | <td class="description">Editor</td> | 49 | <% if @node.draft && !@node.autosave %> |
| 21 | <td><%= @page.editor.try(:login) %></td> | 50 | <div class="node_info_item"> |
| 22 | </tr> | 51 | <%= button_to 'Publish', publish_node_path(@node), method: :put, |
| 23 | <% if @page.node.locked? %> | 52 | form: { data: { confirm: "Publish this draft?" }, class: 'button_to state_changing' } %> |
| 24 | <tr> | 53 | </div> |
| 25 | <td class="description">Locked by</td> | 54 | <% end %> |
| 26 | <td><span class="warning"><%= @page.node.lock_owner.login %></span></td> | 55 | <% if @node.autosave || (@node.draft && @node.head) %> |
| 27 | </tr> | 56 | <div class="node_info_item"> |
| 57 | <%= button_to revert_node_path(@node), method: :put, | ||
| 58 | params: { return_to: request.path }, | ||
| 59 | form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } do %> | ||
| 60 | <%= icon("trash", library: "tabler", "aria-hidden": true) %> | ||
| 61 | <%= @node.draft && !@node.autosave ? "Destroy Draft" : "Discard Autosave" %> | ||
| 62 | <% end %> | ||
| 63 | </div> | ||
| 64 | <% end %> | ||
| 65 | <% end %> | ||
| 66 | </div> | ||
| 67 | |||
| 68 | <% if locked_by_other %> | ||
| 69 | <span class="field_hint">Locked — see People below to unlock before editing, publishing, or discarding.</span> | ||
| 70 | <% end %> | ||
| 71 | </div> | ||
| 72 | |||
| 73 | <div class="node_description">Translations</div> | ||
| 74 | <div class="node_content node_info_group"> | ||
| 75 | <div class="node_info_group_items"> | ||
| 76 | <% @translations.each do |t| %> | ||
| 77 | <div class="node_info_item"> | ||
| 78 | <span class="node_info_label"><%= t[:locale].to_s.upcase %></span> | ||
| 79 | <div class="aligned_action_row"> | ||
| 80 | <% if t[:exists] %> | ||
| 81 | <%= link_to t[:title], node_translation_path(@node, t[:locale]) %> — updated <%= t[:updated_at] %> | ||
| 82 | <% if t[:outdated] %> | ||
| 83 | <span class="warning">may be outdated</span> | ||
| 84 | <% end %> | ||
| 85 | <% else %> | ||
| 86 | <span class="field_hint">Not yet translated.</span> | ||
| 87 | <% end %> | ||
| 88 | <% if locked_by_other %> | ||
| 89 | <span class="disabled_action"><%= t[:exists] ? "Lock + Edit" : "Create translation + Lock" %></span> | ||
| 90 | <% else %> | ||
| 91 | <%= link_to edit_node_translation_path(@node, t[:locale]), class: "action_button" do %> | ||
| 92 | <%= icon(t[:exists] ? "edit" : "language", library: "tabler", "aria-hidden": true) %> | ||
| 93 | <%= t[:exists] ? "Lock + Edit" : "Create translation + Lock" %> | ||
| 94 | <% end %> | ||
| 95 | <% if t[:exists] %> | ||
| 96 | <%= button_to node_translation_path(@node, t[:locale]), method: :delete, | ||
| 97 | form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } do %> | ||
| 98 | <%= icon("trash", library: "tabler", "aria-hidden": true) %> | ||
| 99 | Destroy Translation | ||
| 100 | <% end %> | ||
| 101 | <% end %> | ||
| 102 | <% end %> | ||
| 103 | </div> | ||
| 104 | </div> | ||
| 105 | <% end %> | ||
| 106 | </div> | ||
| 107 | </div> | ||
| 108 | |||
| 109 | <div class="node_description">People</div> | ||
| 110 | <div class="node_content node_info_group"> | ||
| 111 | <div class="node_info_group_items"> | ||
| 112 | <div class="node_info_item"> | ||
| 113 | <span class="node_info_label">Author</span> | ||
| 114 | <%= @page.user.try(:login) %> | ||
| 115 | </div> | ||
| 116 | <div class="node_info_item"> | ||
| 117 | <span class="node_info_label">Editor</span> | ||
| 118 | <%= @page.editor.try(:login) %> | ||
| 119 | </div> | ||
| 120 | <% if @node.locked? %> | ||
| 121 | <div class="node_info_item"> | ||
| 122 | <span class="node_info_label">Locked by</span> | ||
| 123 | <span class="warning"><%= @node.lock_owner.login %></span> | ||
| 124 | <%= unlock_link %> | ||
| 125 | </div> | ||
| 126 | <% end %> | ||
| 127 | </div> | ||
| 128 | </div> | ||
| 129 | |||
| 130 | <div class="node_description">Dates</div> | ||
| 131 | <div class="node_content node_info_group"> | ||
| 132 | <div class="node_info_group_items"> | ||
| 133 | <div class="node_info_item"> | ||
| 134 | <span class="node_info_label">Last updated</span> | ||
| 135 | <%= @page.updated_at %> | ||
| 136 | </div> | ||
| 137 | <% if @page.published_at.present? %> | ||
| 138 | <div class="node_info_item"> | ||
| 139 | <span class="node_info_label"><%= @page.public? ? 'Published at' : 'Will publish at' %></span> | ||
| 140 | <%= @page.published_at %> | ||
| 141 | </div> | ||
| 142 | <% end %> | ||
| 143 | </div> | ||
| 144 | </div> | ||
| 145 | |||
| 146 | <div class="node_description">Links</div> | ||
| 147 | <div class="node_content node_info_group"> | ||
| 148 | <div class="node_info_group_items"> | ||
| 149 | <div class="node_info_item"> | ||
| 150 | <span class="node_info_label">Public</span> | ||
| 151 | <%= link_to @page.public_link, content_url(@node.unique_path) %> | ||
| 152 | </div> | ||
| 153 | <% if @node.draft %> | ||
| 154 | <div class="node_info_item"> | ||
| 155 | <span class="node_info_label">Admin Preview</span> | ||
| 156 | <%= link_to preview_page_path(@node.draft), preview_page_path(@node.draft) %> | ||
| 157 | </div> | ||
| 158 | <div class="node_info_item"> | ||
| 159 | <span class="node_info_label">Public Preview</span> | ||
| 160 | <% if @node.draft.preview_token.present? %> | ||
| 161 | <div class="aligned_action_row"> | ||
| 162 | <%= link_to shared_preview_path(token: @node.draft.preview_token), shared_preview_url(token: @node.draft.preview_token), target: "_blank", rel: "noopener" %> | ||
| 163 | <%= button_to 'Revoke', revoke_shared_preview_node_path(@node), method: :put, form: { data: { confirm: "Revoke this preview link? Anyone currently using it will immediately lose access." }, class: 'button_to state_changing' } %> | ||
| 164 | </div> | ||
| 165 | <% else %> | ||
| 166 | <%= button_to 'Create public preview link', generate_shared_preview_node_path(@node), method: :put, form: { class: 'button_to state_changing' } %> | ||
| 167 | <% end %> | ||
| 168 | </div> | ||
| 169 | <% end %> | ||
| 170 | </div> | ||
| 171 | </div> | ||
| 172 | |||
| 173 | <div class="node_description">Revisions</div> | ||
| 174 | <div class="node_content node_info_group"> | ||
| 175 | <details> | ||
| 176 | <summary> | ||
| 177 | <%= pluralize(@node.pages.count, 'revision', 'revisions') %> | ||
| 178 | </summary> | ||
| 179 | <ul> | ||
| 180 | <% @node.pages.order(:revision).each do |page| %> | ||
| 181 | <li><%= link_to "##{page.revision} — #{page.title} (#{page.editor.try(:login)}, #{page.updated_at})", node_revision_path(@node, page) %></li> | ||
| 182 | <% end %> | ||
| 183 | </ul> | ||
| 184 | </details> | ||
| 185 | <p class="revisions_full_history_link"><%= link_to 'Full history (diff / restore)', node_revisions_path(@node) %></p> | ||
| 186 | </div> | ||
| 187 | |||
| 188 | <div class="node_description">Tags</div> | ||
| 189 | <div class="node_content node_info_group"><%= @page.tag_list %></div> | ||
| 190 | |||
| 191 | <% if @page.assets.images.any? %> | ||
| 192 | <div class="node_description">Images</div> | ||
| 193 | <div class="node_content node_info_group"> | ||
| 194 | <ul class="thumbnail_list"> | ||
| 195 | <% @page.assets.images.each do |asset| %> | ||
| 196 | <li><%= link_to image_tag(asset.upload.url(:thumb)), asset_path(asset) %></li> | ||
| 197 | <% end %> | ||
| 198 | </ul> | ||
| 199 | </div> | ||
| 200 | <% end %> | ||
| 201 | |||
| 202 | <div class="node_description">Events</div> | ||
| 203 | <div class="node_content node_info_group"> | ||
| 204 | <ul> | ||
| 205 | <% @node.events.order(:start_time).each do |event| %> | ||
| 206 | <li> | ||
| 207 | <%= event_schedule_text(event) %> | ||
| 208 | [<%= link_to 'show', event_path(event, return_to: request.path) %> | ||
| 209 | | <%= link_to 'edit', edit_event_path(event, return_to: request.path) %>] | ||
| 210 | </li> | ||
| 211 | <% end %> | ||
| 212 | </ul> | ||
| 213 | <% mapping = default_event_tag_mapping(@page) %> | ||
| 214 | <%= link_to 'add event', new_event_path(node_id: @node.id, tag_list: mapping&.last, auto_tag_source: mapping&.first, return_to: request.path) %> | ||
| 215 | </div> | ||
| 216 | |||
| 217 | <% matches = matching_node_kinds(@node) %> | ||
| 218 | <% if @node.children.any? || matches.any? %> | ||
| 219 | <div class="node_description">Children</div> | ||
| 220 | <div class="node_content node_info_group"> | ||
| 221 | <% if @node.children.any? %> | ||
| 222 | <details> | ||
| 223 | <summary><%= pluralize(@node.children.count, 'child', 'children') %></summary> | ||
| 224 | <ul> | ||
| 225 | <% @node.children.order(:slug).each do |child| %> | ||
| 226 | <li><%= link_to (child.head&.title || child.draft&.title || child.slug), node_path(child) %></li> | ||
| 227 | <% end %> | ||
| 228 | </ul> | ||
| 229 | </details> | ||
| 230 | <% end %> | ||
| 231 | <% if matches.any? %> | ||
| 232 | <p class="add_child_links"> | ||
| 233 | <% matches.each_with_index do |(kind, config), index| %> | ||
| 234 | <%= " · ".html_safe if index > 0 %> | ||
| 235 | <% link_params = { kind: kind } %> | ||
| 236 | <% link_params[:parent_id] = @node.id if kind == "generic" %> | ||
| 237 | <%= link_to "add '#{resolve_kind_text(config[:label])}' child", new_node_path(link_params) %> | ||
| 238 | <% end %> | ||
| 239 | </p> | ||
| 240 | <% end %> | ||
| 241 | </div> | ||
| 28 | <% end %> | 242 | <% end %> |
| 29 | <tr> | 243 | |
| 30 | <td class="description">Last updated</td> | 244 | <div class="node_description">Abstract (<%= I18n.default_locale.to_s.upcase %>)</div> |
| 31 | <td><%= @page.updated_at %></td> | 245 | <div class="node_content"><%= sanitize(@page.abstract) %></div> |
| 32 | </tr> | 246 | |
| 33 | <tr> | 247 | <div class="node_description">Body (<%= I18n.default_locale.to_s.upcase %>)</div> |
| 34 | <td class="description">Published at</td> | 248 | <div class="node_content"><%= sanitize(@page.body) %></div> |
| 35 | <td><%= @page.published_at %></td> | 249 | |
| 36 | </tr> | 250 | </div> |
| 37 | <tr> | 251 | </div> |
| 38 | <td class="description">Revision</td> | ||
| 39 | <td><%= @page.revision %></td> | ||
| 40 | </tr> | ||
| 41 | <tr> | ||
| 42 | <td class="description">Tagged with:</td> | ||
| 43 | <td><%= @page.tag_list %></td> | ||
| 44 | </tr> | ||
| 45 | <tr> | ||
| 46 | <td class="description"><strong>Title</strong></td> | ||
| 47 | <td><%= sanitize( @page.title ) %></td> | ||
| 48 | </tr> | ||
| 49 | <tr> | ||
| 50 | <td class="description"><strong>Abstract</strong></td> | ||
| 51 | <td><%= sanitize( @page.abstract ) %></td> | ||
| 52 | </tr> | ||
| 53 | <tr> | ||
| 54 | <td class="description"><strong>Body</strong></td> | ||
| 55 | <td><%= sanitize( @page.body ) %></td> | ||
| 56 | </tr> | ||
| 57 | <tr> | ||
| 58 | <td></td> | ||
| 59 | <td class="right"></td> | ||
| 60 | </tr> | ||
| 61 | </table> | ||
| 62 | </div> \ No newline at end of file | ||
