Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dergachev committed Oct 30, 2014
1 parent b5321fb commit 57c3189
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
redmine_recent_wiki_pages
=========================

Displays a list of recently updated wiki pages across all projects
Adds a "Recent Wiki Pages" block to be used for /my/page, which displays a list
of recently updated wiki pages across all projects.

Tested against Redmine 2.6
12 changes: 12 additions & 0 deletions app/controllers/recent_wiki_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class RecentWikiPagesController < ApplicationController
def date_index
@pages = WikiPage.find :all,
:select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on",
:joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id",
:order => "#{WikiContent.table_name}.updated_on DESC"
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
@pages_by_parent_id = @pages.group_by(&:parent_id)

@pages.first.wiki
end
end
2 changes: 2 additions & 0 deletions app/helpers/recent_wiki_pages_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module RecentWikiPagesHelper
end
40 changes: 40 additions & 0 deletions app/views/my/blocks/_recent_wiki_pages.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<%
#see WikiController::load_pages_for_index
pages = WikiPage.with_updated_on.find :all, :order => "updated_on DESC", :limit => 10,:include => {:wiki => :project}
%>

<span style="display:inline-block"> <h3>Top 10 Most Recent Wiki Pages</h3></span>
<span style="display:inline-block"> <%=link_to("more", {:controller => 'recent_wiki_pages', :action => 'date_index' }) %></span>

<table class="list issues">
<thead>
<tr>
<th>Page</th><th>Project</th><th>Updated On</th><th>Author</th>
</tr>
</thead>
<% i=0 %>
<% pages[0,10].each do |page| %>
<%
if i % 2 == 0
trclass = "even"
else
trclass = "odd"
end
%>
<tr class="<%=trclass%>">
<td>
<%=link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id=> page.title}) %>
</td>
<td>
<%=link_to(h(page.project), {:controller => 'wiki', :action => 'date_index', :project_id => page.project }) %>
</td>
<td>
<%= page.content.updated_on.strftime("%I:%M%p %Y-%m-%d") %>
</td>
<td>
<%= page.content.author %>
</td>
</tr>
<% i += 1 %>
<% end %>
</table>
15 changes: 15 additions & 0 deletions app/views/recent_wiki_pages/date_index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h2>Recently modified pages</h2>

<% if @pages.empty? %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>
<% @pages_by_date.keys.sort.reverse.each do |date| %>
<h3><%= format_date(date) %></h3>
<ul>
<% @pages_by_date[date].each do |page| %>
<li><%= link_to page.pretty_title, :action => 'show', :id => page.title, :project_id => page.project, :controller => 'wiki' %> (<%=link_to(h(page.project), {:controller => 'wiki', :action => 'date_index', :project_id => page.project }) %>) by <%= page.content.author %> on <%= page.content.updated_on.strftime("%I:%M%p %Y-%m-%d") %>
</li>
<% end %>
</ul>
<% end %>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
match 'recent_wiki_pages/date_index', :controller => 'recent_wiki_pages', :action => 'date_index', :via => [:get]
12 changes: 12 additions & 0 deletions init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'redmine'

# require_dependency "welcome_controller_patch"

Redmine::Plugin.register :redmine_recent_wiki_pages do
name 'Redmine Recent Wiki Pages'
author 'Alex Dergachev'
url 'https://github.com/evolvingweb/redmine_recent_wiki_pages'
author_url 'http://evolvingweb.ca'
description 'Displays a list of recently updated wiki pages across all projects'
version '0.0.1'
end

0 comments on commit 57c3189

Please sign in to comment.