summaryrefslogtreecommitdiff
path: root/app/views/nodes/show.html.erb
blob: 963bc37c95917bcc265ecbc623677725504ab615 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<% content_for :subnavigation do %>
  <%= link_to 'Edit', edit_node_path(@node), :class => "unselected" %>
  <%= link_to 'Preview', preview_page_path(@page) %>
<% end %>

<div id="page_editor" class="show_node">
  <div id="content">

    <div class="node_description">People</div>
    <div class="node_content node_info_group">
      <div class="node_info_group_items">
        <div class="node_info_item">
          <span class="node_info_label">Author</span>
          <%= @page.user.try(:login) %>
        </div>
        <div class="node_info_item">
          <span class="node_info_label">Editor</span>
          <%= @page.editor.try(:login) %>
        </div>
        <% if @node.locked? %>
          <div class="node_info_item">
            <span class="node_info_label">Locked by</span>
            <span class="warning"><%= @node.lock_owner.login %></span>
            <%= unlock_link %>
          </div>
        <% end %>
      </div>
    </div>

    <div class="node_description">Dates</div>
    <div class="node_content node_info_group">
      <div class="node_info_group_items">
        <div class="node_info_item">
          <span class="node_info_label">Last updated</span>
          <%= @page.updated_at %>
        </div>
        <% if @page.published_at.present? %>
          <div class="node_info_item">
            <span class="node_info_label"><%= @page.public? ? 'Published at' : 'Will publish at' %></span>
            <%= @page.published_at %>
          </div>
        <% end %>
      </div>
    </div>

    <div class="node_description">Links</div>
    <div class="node_content node_info_group">
      <div class="node_info_group_items">
        <div class="node_info_item">
          <span class="node_info_label">Public</span>
          <%= link_to @page.public_link, content_url(@node.unique_path) %>
        </div>
        <% if @node.draft %>
          <div class="node_info_item">
            <span class="node_info_label">Admin Preview</span>
            <%= link_to preview_page_path(@node.draft), preview_page_path(@node.draft) %>
          </div>
          <div class="node_info_item">
            <span class="node_info_label">Public Preview</span>
            <% if @node.draft.preview_token.present? %>
              <%= link_to shared_preview_path(token: @node.draft.preview_token), shared_preview_url(token: @node.draft.preview_token), target: "_blank", rel: "noopener" %>
              <%= 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." } } %>
            <% else %>
              <%= button_to 'Create public preview link', generate_shared_preview_node_path(@node), method: :put %>
            <% end %>
          </div>
        <% end %>
      </div>
    </div>

    <div class="node_description">Revisions</div>
    <div class="node_content node_info_group">
      <details>
        <summary>
          <%= pluralize(@node.pages.count, 'revision', 'revisions') %>
          &middot; <%= link_to 'full history (diff / restore)', node_revisions_path(@node) %>
        </summary>
        <ul>
          <% @node.pages.order(:revision).each do |page| %>
            <li><%= link_to "##{page.revision} — #{page.title} (#{page.user.try(:login)}, #{page.updated_at})", node_revision_path(@node, page) %></li>
          <% end %>
        </ul>
      </details>
    </div>

    <div class="node_description">Tags</div>
    <div class="node_content node_info_group"><%= @page.tag_list %></div>

    <div class="node_description">Events</div>
    <div class="node_content node_info_group">
      <ul>
      <% @node.events.order(:start_time).each do |event| %>
        <li>
          <%= event_schedule_text(event) %>
          [<%= link_to 'show', event_path(event, return_to: request.path) %>
          | <%= link_to 'edit', edit_event_path(event, return_to: request.path) %>]
        </li>
      <% end %>
      </ul>
      <% mapping = default_event_tag_mapping(@page) %>
      <%= link_to 'add event', new_event_path(node_id: @node.id, tag_list: mapping&.last, auto_tag_source: mapping&.first, return_to: request.path) %>
    </div>

    <% matches = matching_node_kinds(@node) %>
    <% if @node.children.any? || matches.any? %>
      <div class="node_description">Children</div>
      <div class="node_content node_info_group">
        <% if @node.children.any? %>
          <details>
            <summary><%= pluralize(@node.children.count, 'child', 'children') %></summary>
            <ul>
              <% @node.children.order(:slug).each do |child| %>
                <li><%= link_to (child.head&.title || child.draft&.title || child.slug), node_path(child) %></li>
              <% end %>
            </ul>
          </details>
        <% end %>
        <% if matches.any? %>
          <p class="add_child_links">
            <% matches.each_with_index do |(kind, config), index| %>
              <%= " &middot; ".html_safe if index > 0 %>
              <% link_params = { kind: kind } %>
              <% link_params[:parent_id] = @node.id if kind == "generic" %>
              <%= link_to "add '#{resolve_kind_text(config[:label])}' child", new_node_path(link_params) %>
            <% end %>
          </p>
        <% end %>
      </div>
    <% end %>

    <div class="node_description"><strong>Title</strong></div>
    <div class="node_content"><strong><%= sanitize(@page.title) %></strong></div>

    <div class="node_description">Abstract</div>
    <div class="node_content"><%= sanitize(@page.abstract) %></div>

    <div class="node_description">Body</div>
    <div class="node_content"><%= sanitize(@page.body) %></div>
    <%# Assets not yet addressed - no confirmed model/association seen for this page's attached assets %>

  </div>
</div>