Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tag page tab overhaul, removing sidebar, styling/spacing tweaks #8046

Merged
merged 11 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/notes/_card.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<%= node.comments.size %> &nbsp; | &nbsp; <%= distance_of_time_in_words(node.created_at, Time.current, { include_seconds: false, scope:'datetime.time_ago_in_words' }).gsub('about ','') %>
</span>
<% end %>
<a class="ellipsis bottom-right" data-toggle="dropdown">&nbsp;<i class="fa fa-ellipsis-h" style="color : #666; font-size:15px; float:right;"></i></a>
<a class="ellipsis bottom-right" data-toggle="dropdown"><i class="fa fa-ellipsis-h" style="color : #666; font-size:15px; float:right;"></i></a>

<ul class="dropdown-menu" style = "width: 150px; font-size:10px;">
<% if node.type == 'note' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tag/_contributors.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<% end %>

<% end %>

<br />
<% if @wildcard %>
<p><%= raw translation('tag.contributors.wild_card_search_detected', :tag => params[:id]) %></p>
<% elsif @note_count.nil? || @note_count == 0 %>
Expand Down
49 changes: 17 additions & 32 deletions app/views/tag/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script src="/assets/wikis.js" type="text/javascript"></script>

<div class="container tag-header" style="height:400px;">
<div class="container tag-header">
<%= render partial: 'tag/show/header' %>
<div class= "card tag-card">
<div class="card-body">
Expand Down Expand Up @@ -48,36 +48,17 @@
<div class="box">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-lg-9">

<%= render partial: 'tag/show/contributors' %>

<div class="row" style="padding-bottom:1rem;align-items:baseline;">
<div class="col-lg-6">
<p class="contributor-info"><%= @total_posts %> posts by
<a href="/contributors/<%= params[:id] %>"><%= Tag.contributor_count(params[:id]) %> contributors</a> |
<a href="/contributors/<%= params[:id] %>"><%= Tag.follower_count(params[:id]) %> followers</a>
<a aria-label="About contributors" href="https://publiclab.org/wiki/contributors"><i class="fa fa-question-circle-o" aria-hidden="true"></i></a>
</p>
</div>
<div class="col-lg-6 d-flex justify-content-lg-end">
<%= render partial: 'tag/show/nav_tabs' %>
</div>
</div>

<%= render partial: 'tag/show/tab_content' %>
<div>
<script type="text/javascript">
$('#questions .btn-group .btn').click(function(){
$(this).addClass('active').siblings().removeClass('active');
});
</script>
</div>
</div>
<div class="col-md-3">
<%= render partial: "tag/show/related_tags" %>
</div>
<%= render partial: 'tag/show/contributors' %>
<%= render partial: 'tag/show/sort' %>
<%= render partial: 'tag/show/nav_tabs' %>
<%= render partial: 'tag/show/tab_content' %>
<div>
<script type="text/javascript">
$('#questions .btn-group .btn').click(function(){
$(this).addClass('active').siblings().removeClass('active');
});
</script>
</div>
</div>
</div>
Expand All @@ -87,6 +68,9 @@
<%= stylesheet_link_tag "dashboard" %>

<style>
.node-types .nav-link {
color: #495057;
}
.tag-card {
position: absolute;
top: 100px;
Expand All @@ -107,8 +91,9 @@
top: 90px;
width: 90%;
}
.tag-header {
}
}
.tag-header {
height: 355px;
}
.wiki-sub{
overflow: hidden;
Expand Down
42 changes: 4 additions & 38 deletions app/views/tag/show/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,12 @@
class: "img-fluid d-sm-none",
id: "tag-wiki-header-image2") %>
</div>
<div class="bottom-right">
<a href="/contributors/<%= params[:id] %>">
<%= Tag.follower_count(params[:id]) %> following
</a>
</div>
</div>

<% else %>

<div class="im d-none d-md-block" id="wiki-empty1">
<div class="bottom-right">
<a href="/contributors/<%= params[:id] %>">
<%= Tag.follower_count(params[:id]) %> following
</a>
</div>
</div>
<div class="im d-sm-none" id="wiki-empty2">
<div class="bottom-right"><%= Tag.follower_count(params[:id]) %> following</div>
</div>

<% end %>

</div>

<% elsif @wildcard %>

<% else %>

<div class="im d-none d-md-block" id="wiki-empty1">
<div class="bottom-right">
<a href="/contributors/<%= params[:id] %>"><%= pluralize(Tag.follower_count(params[:id]), 'person') %> following</a>
</div>
</div>
<div class="im d-sm-none" id="wiki-empty2">
<div class="bottom-right">
<a href="/contributors/<%= params[:id] %>"><%= pluralize(Tag.follower_count(params[:id]), 'person') %> following</a>
</div>
</div>
<% end %>

<style>
Expand Down Expand Up @@ -132,22 +100,20 @@
margin-top: -20px;
}

.bottom-right {
.card .bottom-right {
position: absolute;
bottom: 10px;
right: 40px;
color: #fff;
overflow-x: hidden;
text-shadow: 0.5px 0.5px #333;
/* text-decoration: underline; */
}
.bottom-right a {
.card .bottom-right a {
color: #fff;
}

@media (min-width: 576px) {
.d-md-block {
display: block !important;
.card .d-md-block {
display: block !important;
}
}
</style>
91 changes: 56 additions & 35 deletions app/views/tag/show/_nav_tabs.html.erb
Original file line number Diff line number Diff line change
@@ -1,33 +1,63 @@
<div class="node-types" style="margin-bottom:8px;">
<ul class="nav nav-tabs" aria-labelledby="dropdownMenuButton">

<div class="dropdown" style="margin-top:10px; float:right; margin-right: 5px;">

<button class="btn btn-outline-secondary dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">by type</button>

<!-- when will it not be show...? -->
<div class="dropdown-menu dropdown-menu-right mt-1" aria-labelledby="dropdownMenuButton">
<% if params[:action] == "show" %>
<!-- #Enhancement #6306 - Add counts to `by type` dropdown on tag pages -->
<% unless params[:id].match("question:") %><a class="dropdown-item <% if @node_type == "note" %> active<% end %>" href="/tag/<%= params[:id] %>"><i class="fa fa-file"></i> <span class="d-lg-inline"><%= raw t('tag.show.research_notes') %> <span class="badge badge-primary"><%= params[:counts][:posts] %></span></span></a><% end %>
<!-- can we create a generic node type hash, and give it href and class and content classes? -->
<!-- this should be an if/else, because @node_type should only be one value -->
<a class="dropdown-item <% if @node_type == "questions" %> active<% end %>" href="/questions/tag/<%= params[:id] %>"><i class="fa fa-question-circle"></i> <span class="d-lg-inline"><%= t('tag.show.questions') %> <span class="badge badge-primary"><%= params[:counts][:questions] %></span></span></a>
<a class="dropdown-item <% if @node_type=="wiki" %> active <% end %>" href="/wiki/tag/<%= params[:id] %>"><i class="fa fa-book"></i> <span class="d-lg-inline"><%= raw t('tag.show.wiki_pages') %> <span class="badge badge-primary"><%= params[:counts][:wiki] %></span></span></a>
<!-- END #Enhancement #6306 - Add counts to `by type` dropdown on tag pages -->

<a class="dropdown-item <% if @node_type == "maps" %> active <% end %>" href="/maps/tag/<%= params[:id] %>"><i class="fa fa-map-marker"></i> <span class="d-lg-inline"><%= t('tag.show.maps') %></span></a>

<!-- show if we can see the list of contributors
again, can we have a generic list of contributors that is

calculated in the controller? -->
<% unless params[:id].match("question:") %>
<li class="nav-item">
<a class="nav-link <% if @node_type == "note" %> active<% end %>" href="/tag/<%= params[:id] %>">
<i class="fa fa-file"></i>
<span class="d-lg-inline">
<span class="d-none d-md-inline"><%= t('tag.show.research_notes') %></span>
<span class="badge badge-primary"><%= params[:counts][:posts] %></span>
</span>
</a>
</li>
<% end %>
<li class="nav-item">
<a class="nav-link <% if @node_type == "questions" %> active<% end %>" href="/questions/tag/<%= params[:id] %>">
<i class="fa fa-question-circle"></i>
<span class="d-lg-inline">
<span class="d-none d-md-inline"><%= t('tag.show.questions') %></span>
<span class="badge badge-primary"><%= params[:counts][:questions] %></span>
</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link <% if @node_type=="wiki" %> active <% end %>" href="/wiki/tag/<%= params[:id] %>">
<i class="fa fa-book"></i>
<span class="d-lg-inline">
<span class="d-none d-md-inline"><%= t('tag.show.wiki_pages') %></span>
<span class="badge badge-primary"><%= params[:counts][:wiki] %></span>
</span>
</a>
</li>
<!--
<li class="nav-item">
<a class="nav-link <% if @node_type == "maps" %> active <% end %>" href="/maps/tag/<%= params[:id] %>">
<i class="fa fa-map-marker"></i>
<span class="d-lg-inline"><%= t('tag.show.maps') %></span>
</a>
</li>
-->
<% if !@wildcard %>
<a class="dropdown-item <% if @node_type == "contributors" %> active <% end %>" href="/contributors/<%= params[:id] %>"><i class="fa fa-user"></i> <span class="d-lg-inline"><%= raw t('tag.show.people') %> </span><span class="badge badge-primary"><%=@length %></span></a>
<li class="nav-item">
<a class="nav-link <% if @node_type == "contributors" %> active <% end %>" href="/contributors/<%= params[:id] %>">
<i class="fa fa-user"></i>
<span class="d-lg-inline">
<span class="d-none d-lg-inline"><%= raw t('tag.show.people') %></span>
<span class="badge badge-primary"><%=@length %></span>
</span>
</a>
</li>
<% else %>
<a class="disabled" class="dropdown-item<% if @node_type == "contributors" %> active <% end %>" href="#" rel="tooltip" title="Contributors cannot be listed for wildcard tag searches" ><i class="fa fa-user"></i> <span class="d-lg-inline"><%= raw t('tag.show.contributors') %></span></a>
<a class="disabled" class="dropdown-item<% if @node_type == "contributors" %> active <% end %>" href="#" rel="tooltip" title="Contributors cannot be listed for wildcard tag searches" >
<i class="fa fa-user"></i>
<span class="d-lg-inline d-none d-md-inline"><%= raw t('tag.show.contributors') %></span>
</a>
<% end %>

<% else %>
<!-- calculate whatever this should be in the controller -->

<% unless params[:id].match("question:") %>
<a class="dropdown-item" <% if @node_type == "note" %> class="active"<% end %> href="/tag/<%= params[:id] %>/author/<%= params[:author] %>"><i class="fa fa-file"></i> <span class="d-lg-inline"><%= raw t('tag.show.research_notes') %></span>
</a>
Expand All @@ -39,23 +69,14 @@
<a class="dropdown-item" <% if @node_type == "wiki" %> class="active"<% end %> href="/wiki/tag/<%= params[:id] %>/author/<%= params[:author] %>" >
<i class="fa fa-book"></i> <span class="d-lg-inline"><%= raw t('tag.show.wiki_pages') %></span>
</a>
<!--
<a class="dropdown-item" <% if @node_type == "maps" %> class="active"<% end %> href="/maps/tag/<%= params[:id] %>/author/<%= params[:author] %>" >
<i class="fa fa-map-marker"></i> <span class="d-lg-inline"><%= t('tag.show.maps') %></span>
</a>
-->
<a class="dropdown-item"<% if @node_type == "contributors" %> class="active"<% end %> href="#" rel="tooltip" title="Contributors can't be listed for tag searches with Authors" >
<i class="fa fa-user"></i> <span class="d-lg-inline"><%= raw t('tag.show.contributors') %></span>
</a>
<% end %>
</div>
</div>

<div class="dropdown" style="margin-top:10px; float:right; margin-left:5px;">
<button class="btn btn-outline-secondary dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Sort by</button>
<div class="dropdown-menu dropdown-menu-right mt-1" aria-labelledby="dropdownMenuButton">
<% if params[:action] == "show" %>
<a class="dropdown-item <% if params[:order] == 'last_updated' %> active<% end %>" href="/tag/<%= params[:id] %>"><i class="fa fa-clock-o"></i> <span class="d-lg-inline">by last updated</span></a>
<a class="dropdown-item <% if params[:order] == 'views' %> active<% end %>" href="?order=views"><i class="fa fa-eye"></i> <span class="d-lg-inline">by views</span></a>
<a class="dropdown-item <% if params[:order] == 'likes' %> active<% end %>" href="?order=likes"><i class="fa fa-star"></i> <span class="d-lg-inline">by likes</span></a>
<% end %>
</div>
</ul>
</div>
10 changes: 10 additions & 0 deletions app/views/tag/show/_sort.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="dropdown pull-right">
<button class="btn btn-outline-secondary dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="margin-left:14px;">Sort by</button>
<div class="dropdown-menu dropdown-menu-right mt-1" aria-labelledby="dropdownMenuButton">
<% if params[:action] == "show" %>
<a class="dropdown-item <% if params[:order] == 'last_updated' %> active<% end %>" href="/tag/<%= params[:id] %>"><i class="fa fa-clock-o"></i> <span class="d-lg-inline">by last updated</span></a>
<a class="dropdown-item <% if params[:order] == 'views' %> active<% end %>" href="?order=views"><i class="fa fa-eye"></i> <span class="d-lg-inline">by views</span></a>
<a class="dropdown-item <% if params[:order] == 'likes' %> active<% end %>" href="?order=likes"><i class="fa fa-star"></i> <span class="d-lg-inline">by likes</span></a>
<% end %>
</div>
</div>
8 changes: 4 additions & 4 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ en:
recent: "Recent"
popular: "Popular"
liked: "Liked"
wiki_pages: "Wiki<span class=\"hidden-sm\"> pages</span>"
wiki_pages: "Wiki pages"
_notes:
moderate_first_time_post: "Moderate first-time post:"
approve: "Approve"
Expand Down Expand Up @@ -392,9 +392,9 @@ en:
or_subscribe_to_answer: "<a style='margin-bottom:6px;' class='btn btn-primary
requireLogin' target='_blank' href='%{url1}'>Subscribe to answer questions
on this topic</a>"
research_notes: "<span class=\"hidden-sm\">Research </span>Notes"
research_notes: "Research notes"
questions: "Questions"
wiki_pages: "Wiki<span class=\"hidden-sm\"> pages</span>"
wiki_pages: "Wiki pages"
maps: "Maps"
no_results_found: "No results found; try searching for '<b>%{tag}</b>'"
try_advanced_search: "Or try an <a href='%{url1}'>advanced search</a>"
Expand Down Expand Up @@ -471,7 +471,7 @@ en:
back_to_wiki: "Back to <a href='%{url1}'>%{title}"
overview: "Overview"
research: "Research"
wiki_pages: "Wiki<span class=\"hidden-sm\"> pages</span>"
wiki_pages: "Wiki pages"
more_research: "More research on \"%{tag}\""
more_tag_research: "More \"%{tag}\" research"
_wikis:
Expand Down
2 changes: 1 addition & 1 deletion test/integration/I18n_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ class I18nTest < ActionDispatch::IntegrationTest
follow_redirect!

get '/tag/some-tag'
assert_select 'a', I18n.t('tag.show.maps')
assert_select 'a span.d-none', I18n.t('tag.show.wiki_pages')
end
end

Expand Down
11 changes: 0 additions & 11 deletions test/system/tags_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ def setup
find(".login-modal-form #login-button").click()
end

test 'viewing the dropdown menu' do
visit '/tag/test'

take_screenshot

click_on "by type"

take_screenshot

end

test 'subscribing to a tag' do
visit '/tag/nature'

Expand Down