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

added recent notes page #2296

Merged
merged 4 commits into from
Mar 7, 2018
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
10 changes: 10 additions & 0 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,16 @@ def liked
render template: 'notes/index'
end

def recent
@title = I18n.t('notes_controller.recent_research_notes')
@wikis = Node.limit(10)
.where(type: 'page', status: 1)
.order('nid DESC')
@notes = Node.where(type: 'note', status: 1, created: Time.now.to_i - 1.weeks.to_i..Time.now.to_i)
@unpaginated = true
render template: 'notes/index'
end

# notes with high # of views
def popular
@title = I18n.t('notes_controller.popular_research_notes')
Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<h4 class="col-lg-12">
<% if current_user %>
<span class="hidden-xs hidden-sm"><%= t('dashboard._header.welcome') %><span class="hidden-md">, <b><%= current_user.username %></b></span>!</span>
<a href="/research"><%= @note_count %> <%= t('dashboard._header.notes') %></a> <%= t('dashboard._header.and') %> <a href="/wiki"><%= @wiki_count %> <%= t('dashboard._header.wiki_edits') %></a> <%= t('dashboard._header.posted_past_week') %>
<a href="/notes/recent"><%= @note_count %> <%= t('dashboard._header.notes') %></a> <%= t('dashboard._header.and') %> <a href="/wiki"><%= @wiki_count %> <%= t('dashboard._header.wiki_edits') %></a> <%= t('dashboard._header.posted_past_week') %>
<%= t('dashboard._header.you_shared') %> <a href="/profile/<%= current_user.username %>"><%= @user_note_count %> <% if @user_note_count <= 1 %><%= t('dashboard._header.research_note') %><% else %><%= t('dashboard._header.research_notes') %><% end %></a>.
<% else %>
<span class="hidden-xs hidden-sm"><%= t('dashboard._header.welcome') %>!</span>
Expand Down
6 changes: 4 additions & 2 deletions app/views/notes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@
<h3><%= raw t('notes.index.notes_tagged_with', :params => params[:id]) %></h3>
<% elsif params[:action] == "popular" %>
<h2><%= t('notes.index.popular_research_notes') %></h2>
<% elsif params[:action] == "recent" %>
<h2><%= t('notes.index.recent_research_notes') %></h2>
<% elsif params[:action] == "author_topic" %>
<h3><%= raw t('notes.index.research_on', :tags => @tagnames.join(', '), :url1 => "/people/"+@user.name, :user_name => @user.name) %> <br /><small><%= raw t('notes.index.research_notes_and_wiki_edits_with_time', :count => @user.node_count, :time => time_ago_in_words(@user.created_at)) %></small></h3>
<% elsif params[:action] == "author" %>
<h3><%= raw t('notes.index.research_by', :url1 => "/people/"+@user.name, :user_name => @user.name) %> <small><%= raw t('notes.index.research_notes_and_wiki_edits', :count => @user.node_count) %> <% if @user.notes.length > 0 %><%= raw t('notes.index.starting_time', :time => time_ago_in_words(@user.created_at)) %><% end %></small></h3>
<% else %>
<h2><%= raw t('notes.index.research_notes_ideas_and_documentation') %></h2>
<% end %>
<% if params[:controller] == "notes" && (params[:action] == "popular" || params[:action] == "index" || params[:action] == "liked") %>
<% 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="pull-right btn btn-default btn-sm" href="/feed/liked.rss"><i class="fa fa-rss"></i></a><% end %>

<ul class="nav nav-tabs">
<li<% if params[:action] == "index" %> class="active"<% end %>><a href="/notes/"><i class="fa fa-refresh"></i><span class="hidden-sm"> <%= t('notes.index.recent') %></span></a></li>
<li<% if params[:action] == "recent" %> class="active"<% end %>><a href="/notes/recent"><%= t('notes.index.recent') %></a></li>
<li<% if params[:action] == "popular" %> class="active"<% end %>><a href="/notes/popular/"><i class="fa fa-bolt"></i><span class="hidden-sm"> <%= t('notes.index.popular') %></span></a></li>
<li<% if params[:action] == "liked" %> class="active"<% end %>><a href="/notes/liked/"><i class="fa fa-star-o"></i><span class="hidden-sm"> <%= t('notes.index.liked') %></span></a></li>

Expand Down
1 change: 1 addition & 0 deletions config/locales/controllers/notes_controller/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ de:
content_deleted: "Inhalt gelöscht."
highly_liked_research_notes: "Sehr Research Notes gemocht"
popular_research_notes: "Beliebte Forschungsnotizen"
recent_research_notes: "Aktuelle Forschungsberichte"
1 change: 1 addition & 0 deletions config/locales/controllers/notes_controller/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ en:
content_deleted: "Content deleted."
highly_liked_research_notes: "Highly liked research notes"
popular_research_notes: "Popular research notes"
recent_research_notes: "Recent research notes"
more_than_one_contributor: "You cannot delete a wiki page once someone else has begun to contribute to it"
saved_as_draft: "Your contribution has been saved as draft and will be visible to you only"
1 change: 1 addition & 0 deletions config/locales/views/notes/index/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ de:
advanced_search: "Erweiterte Suche"
notes_tagged_with: "Hinweise getaggt mit <i style=\"color:#aaa;\">%{params}</i>"
popular_research_notes: "Beliebte Forschungsnotizen"
recent_research_notes: "Aktuelle Forschungsberichte"
research_on: "Forschung auf \"%{tags}\" von <a href='%{url1}'>%{user_name}</a>"
research_notes_and_wiki_edits_with_time: "%{count} Forschung Notizen und Wiki-Bearbeitungen beginnend vor %{time}"
research_by: "Forschung von <a href='%{url1}'>%{user_name}</a>"
Expand Down
1 change: 1 addition & 0 deletions config/locales/views/notes/index/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ en:
advanced_search: "advanced search"
notes_tagged_with: "Notes tagged with <i style=\"color:#aaa;\">%{params}</i>"
popular_research_notes: "Popular research notes"
recent_research_notes: "Recent research notes"
research_on: "Research on \"%{tags}\" by <a href='%{url1}'>%{user_name}</a>"
research_notes_and_wiki_edits_with_time: "%{count} research notes and wiki edits starting %{time} ago"
research_by: "Research by <a href='%{url1}'>%{user_name}</a>"
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
get 'place/:id' => 'legacy#place'
get 'tool/:id' => 'legacy#tool'
get 'people/:id' => 'legacy#people'
get 'notes/recent' => 'notes#recent'
get 'notes/:id' => 'legacy#notes'
get 'sites/default/files/:filename.:format' => 'legacy#file'
get 'sites/default/files/imagecache/:size/:filename.:format' => 'legacy#image'
Expand Down
9 changes: 9 additions & 0 deletions test/functional/notes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,15 @@ def teardown
assert !(notes & questions).present?
end

test 'should list only research notes with status 1 in recent' do
get :recent
notes = assigns(:notes)
expected = [nodes(:one)]
questions = [nodes(:question)]
assert (notes & expected).present?
assert (notes & questions).present?
end

test 'should list only research notes with status 1 in liked' do
UserSession.create(users(:admin))
get :liked
Expand Down