Skip to content

Commit 57c3189

Browse files
committed
Initial commit
1 parent b5321fb commit 57c3189

File tree

7 files changed

+86
-1
lines changed

7 files changed

+86
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
redmine_recent_wiki_pages
22
=========================
33

4-
Displays a list of recently updated wiki pages across all projects
4+
Adds a "Recent Wiki Pages" block to be used for /my/page, which displays a list
5+
of recently updated wiki pages across all projects.
6+
7+
Tested against Redmine 2.6
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class RecentWikiPagesController < ApplicationController
2+
def date_index
3+
@pages = WikiPage.find :all,
4+
:select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on",
5+
:joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id",
6+
:order => "#{WikiContent.table_name}.updated_on DESC"
7+
@pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
8+
@pages_by_parent_id = @pages.group_by(&:parent_id)
9+
10+
@pages.first.wiki
11+
end
12+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module RecentWikiPagesHelper
2+
end
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<%
2+
#see WikiController::load_pages_for_index
3+
pages = WikiPage.with_updated_on.find :all, :order => "updated_on DESC", :limit => 10,:include => {:wiki => :project}
4+
%>
5+
6+
<span style="display:inline-block"> <h3>Top 10 Most Recent Wiki Pages</h3></span>
7+
<span style="display:inline-block"> <%=link_to("more", {:controller => 'recent_wiki_pages', :action => 'date_index' }) %></span>
8+
9+
<table class="list issues">
10+
<thead>
11+
<tr>
12+
<th>Page</th><th>Project</th><th>Updated On</th><th>Author</th>
13+
</tr>
14+
</thead>
15+
<% i=0 %>
16+
<% pages[0,10].each do |page| %>
17+
<%
18+
if i % 2 == 0
19+
trclass = "even"
20+
else
21+
trclass = "odd"
22+
end
23+
%>
24+
<tr class="<%=trclass%>">
25+
<td>
26+
<%=link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id=> page.title}) %>
27+
</td>
28+
<td>
29+
<%=link_to(h(page.project), {:controller => 'wiki', :action => 'date_index', :project_id => page.project }) %>
30+
</td>
31+
<td>
32+
<%= page.content.updated_on.strftime("%I:%M%p %Y-%m-%d") %>
33+
</td>
34+
<td>
35+
<%= page.content.author %>
36+
</td>
37+
</tr>
38+
<% i += 1 %>
39+
<% end %>
40+
</table>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h2>Recently modified pages</h2>
2+
3+
<% if @pages.empty? %>
4+
<p class="nodata"><%= l(:label_no_data) %></p>
5+
<% end %>
6+
7+
<% @pages_by_date.keys.sort.reverse.each do |date| %>
8+
<h3><%= format_date(date) %></h3>
9+
<ul>
10+
<% @pages_by_date[date].each do |page| %>
11+
<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") %>
12+
</li>
13+
<% end %>
14+
</ul>
15+
<% end %>

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
match 'recent_wiki_pages/date_index', :controller => 'recent_wiki_pages', :action => 'date_index', :via => [:get]

init.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'redmine'
2+
3+
# require_dependency "welcome_controller_patch"
4+
5+
Redmine::Plugin.register :redmine_recent_wiki_pages do
6+
name 'Redmine Recent Wiki Pages'
7+
author 'Alex Dergachev'
8+
url 'https://github.com/evolvingweb/redmine_recent_wiki_pages'
9+
author_url 'http://evolvingweb.ca'
10+
description 'Displays a list of recently updated wiki pages across all projects'
11+
version '0.0.1'
12+
end

0 commit comments

Comments
 (0)