Skip to content

Commit

Permalink
[Outreachy] All Posts Design (publiclab#8848)
Browse files Browse the repository at this point in the history
* all posts route

* add to do item

* notes controller

* remove previous code and inline comments

* remove inline comments

* reuse published_notes for popular, recent, liked

* implements review feedback

* fix order and increase limit

* fixed tests

* all posts design

* revert pagination code

* revert pagy code in wiki

* remove target blank from research note link

* optimize query and add test for hidden response id

* update styling

* fix tests

* styling

* remove target blank

* add columns in the hidden_response select

* all posts route

* add to do item

* notes controller

* remove previous code and inline comments

* remove inline comments

* reuse published_notes for popular, recent, liked

* implements review feedback

* fix order and increase limit

* fixed tests

* revert pagy code in wiki

* optimize query and add test for hidden response id

* update styling

* fix tests

* add columns in the hidden_response select

* all_posts_route merge

* fix failing test

* revise node query

* all posts route

* add to do item

* notes controller

* remove previous code and inline comments

* remove inline comments

* reuse published_notes for popular, recent, liked

* implements review feedback

* fix order and increase limit

* fixed tests

* revert pagy code in wiki

* optimize query and add test for hidden response id

* update styling

* fix tests

* add columns in the hidden_response select

* fix failing test

* revise node query

* add a revision for the hidden note test node

* remove trailing whitespace

* remove sidebar test

* make nav bar links responsive

* make navbar responsive

* cleanup and styling

* nav pills responsive design galaxy fold
  • Loading branch information
RuthNjeri authored and reginaalyssa committed Oct 16, 2021
1 parent de24361 commit 64c257c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 20 deletions.
5 changes: 0 additions & 5 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class NotesController < ApplicationController
before_action :set_node, only: %i(show)

def index
@title = I18n.t('notes_controller.research_notes')
@pagy, @notes = pagy(published_notes.order('node.nid DESC'))
end

Expand Down Expand Up @@ -303,21 +302,18 @@ def author_topic

# notes with high # of likes
def liked
@title = I18n.t('notes_controller.highly_liked_research_notes')
@pagy, @notes = pagy(published_notes.limit(100).order(cached_likes: :desc, nid: :desc))
render template: 'notes/index'
end

def recent
@title = I18n.t('notes_controller.recent_research_notes')
@pagy, @notes = pagy(published_notes.where(created: Time.now.to_i - 1.weeks.to_i..Time.now.to_i)
.order('created DESC'))
render template: 'notes/index'
end

# notes with high # of views
def popular
@title = I18n.t('notes_controller.popular_research_notes')
@pagy, @notes = pagy(published_notes
.limit(100)
.order(views: :desc, nid: :desc))
Expand Down Expand Up @@ -447,7 +443,6 @@ def location

def published_notes
hidden_nids = Node.hidden_response_node_ids

Node.research_notes
.where('node.status = 1')
.where.not(nid: hidden_nids)
Expand Down
17 changes: 17 additions & 0 deletions app/views/notes/_sidebar.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="dropdown pull-right" style="margin-top: -26px;">
<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">
<a class="dropdown-item <% if params[:action] == 'recent' %> active<% end %>" href="/notes/recent/">
<i class="fa fa-clock-o"></i> <span class="d-lg-inline"><%= translation('notes.index.recent') %></span>
</a>
<a class="dropdown-item <% if params[:action] == 'popular' %> active<% end %>" href="/notes/popular/">
<i class="fa fa-bolt"></i> <span class="d-lg-inline"><%= translation('notes.index.popular') %></span>
</a>
<a class="dropdown-item <% if params[:action] == 'liked' %> active<% end %>" href="/notes/liked/">
<i class="fa fa-star"></i> <span class="d-lg-inline"><%= translation('notes.index.liked')%></span>
</a>
<a class="dropdown-item <% if params[:action] == 'index' %> active<% end %>" href="/notes/">
<i class="fa fa-file"></i> <span class="d-lg-inline"><%= translation('notes.index.all_notes')%></span>
</a>
</div>
</div>
52 changes: 38 additions & 14 deletions app/views/notes/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="col-lg-9">
<% if params[:controller] == "search" %>
<h3><%= raw translation('notes.index.search_results_for', :params => params[:id]) %> <small>(<a href="/search/advanced/<%= params[:id] %>"><%= translation('notes.index.advanced_search') %></a>)</h3>

<% elsif params[:controller] == "tag" %>
<h3><%= raw translation('notes.index.notes_tagged_with', :params => params[:id]) %></h3>
<% elsif params[:action] == "popular" %>
Expand All @@ -15,29 +15,53 @@
<% else %>
<h2><%= raw translation('notes.index.research_notes_ideas_and_documentation') %></h2>
<% end %>
<% if params[:controller] == "notes" && (params[:action] == "popular" || params[:action] == "index" || params[:action] == "liked" || params[:action] == "recent") %>
<%= render :partial => "notes/format_toggle" %>
<% if params[:action] == "liked" %><a style="margin-right:4px;" class="float-right btn btn-outline-secondary btn-sm" href="/feed/liked.rss"><i class="fa fa-rss"></i></a><% end %>
<br/>
<% if params[:action] == "liked" %><a style="margin-right:9px;" class="float-right btn btn-outline-secondary btn-sm" href="/feed/liked.rss"><i class="fa fa-rss"></i></a><% end %>

<ul class="nav nav-tabs" id="tab-bar">
<ul class="nav nav-pills notes-pills">
<li class="nav-item">
<a class="nav-link <% if params[:action] == "recent" %> active <% end %>" href="/notes/recent"> <i class="fa fa-clock-o"></i><span class="hidden-sm hidden-xs"> <%= translation('notes.index.recent') %></span></a>
</li>
<a class="nav-link <% if params[:controller] == "notes" %> active <% end %>" href="/notes/">
<i class="fa fa-file"></i>
<span class="d-lg-inline">
<span class="d-none d-md-inline"> <%= translation('notes.index.research_notes') %></span>
</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link <% if params[:action] == "popular" %> active <% end %> " href="/notes/popular/"> <i class="fa fa-bolt"></i><span class="hidden-sm hidden-xs"> <%= translation('notes.index.popular') %></span></a>
<a class="nav-link" href="/questions/">
<i class="fa fa-question-circle"></i>
<span class="d-lg-inline">
<span class="d-none d-md-inline"> <%= translation('notes.index.questions') %></span>
</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link <% if params[:action] == "liked" %> active <% end %> " href="/notes/liked/"> <i class="fa fa-star-o"></i><span class="hidden-sm hidden-xs"> <%= translation('notes.index.liked') %></span></a>
<a class="nav-link" href="/wiki/">
<i class="fa fa-book"></i>
<span class="d-lg-inline">
<span class="d-none d-md-inline"> <%= translation('notes.index.wiki_pages') %></span>
</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/comments/">
<i class="fa fa-comment"></i>
<span class="d-lg-inline">
<span class="d-none d-md-inline"> <%= translation('notes.index.comments') %></span>
</span>
</a>
</li>
</ul>

<% end %>

<%= render :partial => "notes/sidebar" %>
<br />

<%= render :partial => "notes/notes" %>

<hr />
</div>

<!-- Galaxy Fold Responsive Styling -->
<style>
@media (max-width: 280px) {
.notes-pills{ display: inline !important; }
}
</style>
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ en:
popular: "Popular"
liked: "Liked"
wiki_pages: "Wiki pages"
research_notes: "Research Notes"
questions: "Questions"
comments: "Comments"
all_notes: "All Notes"
_notes:
moderate_first_time_post: "Moderate first-time post:"
approve: "Approve"
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/revisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -425,4 +425,4 @@ hidden_response_note_revision: # for testing comments on notes
title: "Note tagged with hidden:response"
body: "This is a hidden note"
timestamp: <%= DateTime.new(2020,12,8).to_i %>
status: 1
status: 1

0 comments on commit 64c257c

Please sign in to comment.