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

sidebar tags card #6124

Closed
wants to merge 11 commits into from
Closed
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
37 changes: 28 additions & 9 deletions app/views/tag/_tagging.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

<!-- This is the sidebar tagging display, also renders Subscribe button for multiple subscription -->
<div>
<h1 style="display: inline-block; margin-right: 20px;">Tags</h1>
<% if @node && [email protected]_tags.empty? %>
<%= render partial: 'tag/subscribe_button', locals:{tags: @node.node_tags} %>
<% end %>
<h6 style="display: inline-block; margin-right: 20px; color:#666;">This page is part of: </h6>
</div>
<em class="italics"><a href="/tags">Tags</a> organize our knowledge base. Click to learn more or subscribe to a topic.</em>


<% if @node %>
<%= render partial: 'tag/replication' %>

<span id="tags">
<%= render partial: 'tag/tags', locals: { power_tag: true, badge_name: 'badge-secondary', tags: @node.node_tags } %>
<%= render partial: 'tag/tags', locals: { power_tag: false, badge_name: 'badge-primary', tags: @node.node_tags } %>
<%= render partial: 'tag/tags', locals: { power_tag: true, badge_name: 'badge-secondary', tags: @node.node_tags } %>
<%= render partial: 'tag/tags', locals: { power_tag: false, badge_name: 'badge-primary', tags: @node.node_tags } %>
<% if @tags.count > 2 %>
<a href=""><p style="float:left; color:#666; margin-top:15px; margin-left:5px;"><u><%= @tags.count-2 %> more</u> &nbsp </p></a>
<% end %>
</span>
<% else %>
<span id="tags">
<%= render partial: 'tag/tags', locals: { power_tag: false, badge_name: 'badge-primary', tags: user.user_tags, user: user } %>
<%= render partial: 'tag/tags', locals: { power_tag: false, badge_name: 'badge-primary', tags: user.user_tags, user: user } %>
<% if @tags.count > 2 %>
<a href=""><p style="float:left; margin-top:-10px; color:#666;"><%= @tags.count-2 %> more &nbsp </p></a>
<% end %>
</span>
<% end %>

Expand Down Expand Up @@ -52,6 +53,8 @@ $(".label").on("click", function(e){
<% if current_user && (parent != :profile || (current_user.id == user.id || logged_in_as(['admin']))) %>
<% url = url || "/tag/create/" + @node.id.to_s %>

<a id="tags-open" style="cursor: pointer;"><i class="fa fa-plus-circle fa-2x " style="color:#808080; float:left; margin-top:13px; margin-left:5px;" aria-hidden="true"></i></a>

<form id="tagform" class="form" data-remote="true" action="<%= url %>">
<div class="control-group">
<input class="form-control" name="remote" type="hidden" value="true" />
Expand Down Expand Up @@ -82,4 +85,20 @@ $(".label").on("click", function(e){
</form>
<% end %>

<script>
$("#tags-open").click(function(){
$("#tagform").toggle();
});
</script>

<style>
#tagform {
display:none;
}
.list-inline {
overflow: hidden;
text-overflow: ellipsis;
}
</style>

<%= render partial: 'tag/location' %>
78 changes: 42 additions & 36 deletions app/views/tag/_tags.html.erb
Original file line number Diff line number Diff line change
@@ -1,47 +1,53 @@
<% user = user || @user # allow overriding w/ local variable %>
<ul class= "list-inline">
<% tags.each do |tag| %>
<% if tag.class == NodeTag %>
<% if power_tag ^ tag.name.include?(':') # XOR operator??? %>
<li style="width: 100%;"><span id="tag_<%= tag.tid %>" class="badge <%= badge_name %> pop" style="cursor:pointer" data-toggle="popover" data-trigger="focus" data-count=0 data-placement="top" data-content="<p style='text-align:center;'><a href='/tag/<%= tag.name %>'><%= Tag.tagged_node_count(tag.name) || 0 %> notes</a> - <a href='/contributors/<%= tag.name %>'><%= Tag.contributors(tag.name).count %> people <br></a></p> <p style='text-align:center;font-size:12px;'><%if tag.description %><%= tag.description %> |<% end %> created by <a href='/profile/<%= tag.try(:author).try(:username) %>'><%= tag.try(:author).try(:username) %></a> <%= time_ago_in_words(Time.at(tag.date)) %> ago </p><div style='text-align:center;' class='text-center'><a href='/subscribe/tag/<%= tag.name %>' class='btn btn-primary'>Follow</a></div>" data-html="true" title="<%= tag.name %>">
<%= tag.name %>
<% if logged_in_as(['admin', 'moderator']) || (current_user && ( current_user.uid == @node.uid || current_user.uid == tag.uid)) %>
<% if tag.name.include? ':' %>
<a data-confirm="This is a power tag (see https://publiclab.org/wiki/power-tags) -- and may drive a specific function on this page. Are you sure you want to delete it?" class="tag-delete" data-remote="true" href="/tag/delete/<%= @node.id %>/<%= tag.tid %>" data-tag-id="<%= tag.tid %>" data-method="delete" style="color:white;">x</a>
<% else %>
<a data-confirm="Are you sure you want to delete it?" class="tag-delete" data-remote="true" href="/tag/delete/<%= @node.id %>/<%= tag.tid %>" data-tag-id="<%= tag.tid %>" data-method="delete" style="color:white">x</a>
<% end %>
<% end %>
</span></li>
<% end %>

<% elsif tag.class == UserTag && (tag.name[0..4] != "oauth" || (logged_in_as(['admin', 'moderator']) || (current_user && current_user.uid == tag.uid))) %>
<% tags.limit(2).each do |tag| %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I think this may cause some trouble - it looks like we would need to switch by tag.class outside this iterator, so profile tags are unaffected. Then, we can split off the first 2, within the NodeTag block, and show those as cards. The rest we can show, still in that block, the previous way.

<% if tag.class == NodeTag %>

<li style="width: 100%;"><span id="tag_<%= tag.id %>" class="badge <%= badge_name %> pop" style="cursor:pointer" data-toggle="popover" data-trigger="manual" data-count=0 data-placement="top" data-content="<a href='/contributors/<%= tag.name %>'><%= Tag.tagged_node_count(tag.name) || 0 %> notes - <%= Tag.contributors(tag.name).count %> people <br></a>" data-html="true" title="<%= tag.name %>">
<% if tag.name[0..4] != "oauth" %>
<%= tag.name %>
<% else %>
<%= tag.name[0..5] + tag.name.split(':')[1] %>
<% end %>
<% if logged_in_as(['admin', 'moderator']) || (current_user && current_user.uid == tag.uid) %>
<a data-confirm="Are you sure you want to delete it?" class="tag-delete" data-remote="true" href="/profile/tags/delete/<%= user.id %>?name=<%= tag.name %>" data-method="delete">x</a>
<% end %>
</span></li>
<% if power_tag ^ tag.name.include?(':') # XOR operator??? %>
<div class="card">
<div class="card-body">

<% end %>
<a class="ellipsis pull-right" data-toggle="dropdown">&nbsp<i class="fa fa-ellipsis-h" style="color : #666; font-size:15px; margin-right:20px;"></i></a>
<ul class="dropdown-menu" style = "font-size:13px;">
<li><a href='/tag/<%= tag.name %>' style="color:black; text-decoration: underline;"><%= Tag.tagged_node_count(tag.name) || 0 %> notes</a></li>
<li>created by <a href='/profile/<%= tag.try(:author).try(:username) %>' style="color:black; text-decoration: underline;"><%= tag.try(:author).try(:username) %></a> </li>
<li>created <%= time_ago_in_words(Time.at(tag.date)) %> ago</li>
<% if logged_in_as(['admin', 'moderator']) || (current_user && ( current_user.uid == @node.uid || current_user.uid == tag.uid)) %>
<% if tag.name.include? ':' %>
<li><a data-confirm="This is a power tag (see https://publiclab.org/wiki/power-tags) -- and may drive a specific function on this page. Are you sure you want to delete it?" class="tag-delete" data-remote="true" href="/tag/delete/<%= @node.id %>/<%= tag.tid %>" data-tag-id="<%= tag.tid %>" data-method="delete" style="color:black; text-decoration: underline;">delete tag</a></li>
<% else %>
<li><a data-confirm="Are you sure you want to delete it?" class="tag-delete" data-remote="true" href="/tag/delete/<%= @node.id %>/<%= tag.tid %>" data-tag-id="<%= tag.tid %>" data-method="delete" style="color:black; text-decoration: underline;">delete tag</a></li>
<% end %>
<% end %>
</ul>

<% end %>
</ul>
<a href="/tag/<%= tag.name%>">
<h5 style="text-decoration:underline;color:black;"><%= tag.name %></h5>
</a>
<p style="font-size:15px;">
<a style="color:#808080;" href="/tag/<%= tag.name %>"><%= Tag.follower_count(tag.name) %> people</a>
</p>

<style>
<a class="pull-right btn btn-primary" href='/subscribe/tag/<%= tag.name %>'>Subscribe</a>
</div>
</div>
<br />
<% end %>

.list-inline {
overflow: hidden;
text-overflow: ellipsis;
}
<% elsif tag.class == UserTag && (tag.name[0..4] != "oauth" || (logged_in_as(['admin', 'moderator']) || (current_user && current_user.uid == tag.uid))) %>

</style>
<li style="width: 100%;"><span id="tag_<%= tag.id %>" class="badge <%= badge_name %> pop" style="cursor:pointer" data-toggle="popover" data-trigger="manual" data-count=0 data-placement="top" data-content="<a href='/contributors/<%= tag.name %>'><%= Tag.tagged_node_count(tag.name) || 0 %> notes - <%= Tag.contributors(tag.name).count %> people <br></a>" data-html="true" title="<%= tag.name %>">
<% if tag.name[0..4] != "oauth" %>
<%= tag.name %>
<% else %>
<%= tag.name[0..5] + tag.name.split(':')[1] %>
<% end %>
<% if logged_in_as(['admin', 'moderator']) || (current_user && current_user.uid == tag.uid) %>
<a data-confirm="Are you sure you want to delete it?" class="tag-delete" data-remote="true" href="/profile/tags/delete/<%= user.id %>?name=<%= tag.name %>" data-method="delete">x</a>
<% end %>
</span></li>

<% end %>
<% end %>
<script type="text/javascript">

$(".pop").popover({ trigger: "manual" , html: true, animation:false})
Expand Down