Skip to content

Commit

Permalink
Improve navigation linking in manage views
Browse files Browse the repository at this point in the history
  • Loading branch information
amorde committed Oct 22, 2023
1 parent f9faab2 commit a44891b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
37 changes: 37 additions & 0 deletions app/controllers/manage_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,43 @@ def self.hash_password(password)
end

helpers ManageHelper
helpers do
# @return [String]
#
def pod_url(pod_id)
"/manage/pods/#{pod_id}"
end

# @return [String]
#
def pod_link(pod)
"<a href=\"#{pod_url(pod.id)}\">#{pod.name}</a>"
end

# @return [String]
#
def commit_url(commit_id)
"/manage/commits/#{commit_id}"
end

# @return [String]
#
def commit_link(commit)
"<a href=\"#{commit_url(commit.id)}\">#{commit.id}</a>"
end

# @return [String]
#
def owner_url(owner_id)
"/manage/owners/#{owner_id}"
end

# @return [String]
#
def owner_link(owner)
"<a href=\"#{owner_url(owner.id)}\">#{owner.id}</a>"
end
end

register Sinatra::Twitter::Bootstrap::Assets

Expand Down
4 changes: 2 additions & 2 deletions app/views/manage/commits/show.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<% @title = @commit.pod_version.pod.name %>

<div class="page-header">
<h1><%= @commit.pod_version.pod.name %> <small><%= @commit.pod_version.name %></small></h1>
<h1><%= pod_link(@commit.pod_version.pod) %> <small><%= @commit.pod_version.name %></small></h1>
</div>

<dl class="dl-horizontal">
<dt>ID</dt>
<dd><%= @commit.id %></dd>
<dt>SHA</dt>
<dd><%= @commit.sha %><dd>
<dd><a href="<%= @commit.pod_version.data_url %>"><%= @commit.sha %></a><dd>
<dt>Committer</dt>
<dd><%= @commit.committer.public_attributes %></dd>
</dl>
Expand Down
27 changes: 21 additions & 6 deletions app/views/manage/pods/detail.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,31 @@
<tr>
<th>Version</th>
<th>Commit</th>
<th>SHA</th>
<th>Published At</th>
</tr>
</thead>
<tbody>
<% @pod.versions.each do |version| %>
<tr>
<td><%= version.name %></td>
<td>
<% if version.published? %>
<%= version.name %>
</td>
<% if version.published? %>
<td>
<%= commit_link(version.last_published_by) %>
</td>
<td>
<a href="<%= version.data_url %>"><%= version.commit_sha %></a>
<% else %>
Unpublished
<% end %>
</td>
<td>
<%= version.last_published_by.created_at.to_formatted_s(:rfc822) %>
</td>
<% else %>
<td>Unpublished</td>
<td></td>
<td></td>
<% end %>
</td>
</tr>
<% end %>
Expand All @@ -41,7 +54,9 @@
<tbody>
<% @pod.owners.each do |owner| %>
<tr>
<td><%= owner.id %></td>
<td>
<%= owner_link(owner) %>
</td>
<td><%= owner.name %></td>
<td><a href="mailto:<%= owner.email %>"><%= owner.email %></a></td>
</tr>
Expand Down

0 comments on commit a44891b

Please sign in to comment.