Skip to content

Commit

Permalink
add map authors in show page (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
cesswairimu authored and jywarren committed Sep 25, 2019
1 parent e227387 commit 72d3350
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/controllers/maps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def show
.where.not(id: @map.id)
.sample(4)
@unpaginated = true
@users = @map.authors
render layout: 'application'
end

Expand Down
8 changes: 8 additions & 0 deletions app/models/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,12 @@ def fetch_map_data
data = warpables
data.to_json
end

def authors
user_ids = []
warpables.each do |warp|
user_ids.push(warp.versions.map(&:whodunnit))
end
User.where(id: user_ids.flatten.uniq).where.not(id: user_id)
end
end
17 changes: 14 additions & 3 deletions app/views/maps/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,21 @@
<div class="container-fluid">
<div class="text-center lead-text">
<p class="text-muted">A Community Atlas of </p>
<h2><%= @map.name %> </h2>
<p><%= @map.location %> | by <%= @map.anonymous? ? @map.author : link_to("@#{@map.author}", "/profile/#{@map.author}") %></p>
<h2><%= @map.name %>,</h2>
<p><%= @map.location %> </p>
<p>by <%= @map.anonymous? ? @map.author : link_to("@#{@map.author}", "/profile/#{@map.author}") %>
<%= 'with' unless @users.empty? %>
<% @users.each_with_index do |author,i| %>
<a href="/profile/<%= author.login %>">
<%= "@#{author.login}"%></a>
<% if i < @users.length-2 %>
<%= ',' %>
<% elsif i < @users.length-1 %>
<%= '&' %>
<% end %>
<% end %>
<br><br>
</div>
<br>
</div>

<div class="container">
Expand Down

0 comments on commit 72d3350

Please sign in to comment.