From 57c31896fdfda8415cb7a13672b534bf5fc1a7ae Mon Sep 17 00:00:00 2001 From: Alex Dergachev Date: Thu, 30 Oct 2014 21:36:20 +0000 Subject: [PATCH] Initial commit --- README.md | 5 ++- .../recent_wiki_pages_controller.rb | 12 ++++++ app/helpers/recent_wiki_pages_helper.rb | 2 + .../my/blocks/_recent_wiki_pages.html.erb | 40 +++++++++++++++++++ .../recent_wiki_pages/date_index.html.erb | 15 +++++++ config/routes.rb | 1 + init.rb | 12 ++++++ 7 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 app/controllers/recent_wiki_pages_controller.rb create mode 100644 app/helpers/recent_wiki_pages_helper.rb create mode 100644 app/views/my/blocks/_recent_wiki_pages.html.erb create mode 100644 app/views/recent_wiki_pages/date_index.html.erb create mode 100644 config/routes.rb create mode 100644 init.rb diff --git a/README.md b/README.md index 7f8a658..ac89d99 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/app/controllers/recent_wiki_pages_controller.rb b/app/controllers/recent_wiki_pages_controller.rb new file mode 100644 index 0000000..29976a9 --- /dev/null +++ b/app/controllers/recent_wiki_pages_controller.rb @@ -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 diff --git a/app/helpers/recent_wiki_pages_helper.rb b/app/helpers/recent_wiki_pages_helper.rb new file mode 100644 index 0000000..8f417f5 --- /dev/null +++ b/app/helpers/recent_wiki_pages_helper.rb @@ -0,0 +1,2 @@ +module RecentWikiPagesHelper +end diff --git a/app/views/my/blocks/_recent_wiki_pages.html.erb b/app/views/my/blocks/_recent_wiki_pages.html.erb new file mode 100644 index 0000000..33f6cb3 --- /dev/null +++ b/app/views/my/blocks/_recent_wiki_pages.html.erb @@ -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} +%> + +

Top 10 Most Recent Wiki Pages

+ <%=link_to("more", {:controller => 'recent_wiki_pages', :action => 'date_index' }) %> + + + + + + + + <% i=0 %> +<% pages[0,10].each do |page| %> + <% + if i % 2 == 0 + trclass = "even" + else + trclass = "odd" + end + %> + + + + + + + <% i += 1 %> +<% end %> +
PageProjectUpdated OnAuthor
+ <%=link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id=> page.title}) %> + + <%=link_to(h(page.project), {:controller => 'wiki', :action => 'date_index', :project_id => page.project }) %> + + <%= page.content.updated_on.strftime("%I:%M%p %Y-%m-%d") %> + + <%= page.content.author %> +
diff --git a/app/views/recent_wiki_pages/date_index.html.erb b/app/views/recent_wiki_pages/date_index.html.erb new file mode 100644 index 0000000..48dd3eb --- /dev/null +++ b/app/views/recent_wiki_pages/date_index.html.erb @@ -0,0 +1,15 @@ +

Recently modified pages

+ +<% if @pages.empty? %> +

<%= l(:label_no_data) %>

+<% end %> + +<% @pages_by_date.keys.sort.reverse.each do |date| %> +

<%= format_date(date) %>

+ +<% end %> diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..c7649f9 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1 @@ +match 'recent_wiki_pages/date_index', :controller => 'recent_wiki_pages', :action => 'date_index', :via => [:get] diff --git a/init.rb b/init.rb new file mode 100644 index 0000000..e92287e --- /dev/null +++ b/init.rb @@ -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