220 |
220 |
"{{recent_pages}} -- displays pages updated within the last 7 days\n" +
|
221 |
221 |
"{{recent_pages(days=3)}} -- displays pages updated within the last 3 days\n" +
|
222 |
222 |
"{{recent_pages(limit=5)}} -- limits the maximum number of pages to display to 5\n" +
|
223 |
|
"{{recent_pages(time=true)}} -- displays pages updated within the last 7 days with updated time"
|
|
223 |
"{{recent_pages(time=true)}} -- displays pages updated within the last 7 days with updated time\n" +
|
|
224 |
"{{recent_pages(project=identifier)}} -- displays pages updated within the last 7 days from a specific project"
|
224 |
225 |
|
225 |
226 |
macro :recent_pages do |obj, args|
|
226 |
|
return '' if @project.nil?
|
227 |
|
return '' unless User.current.allowed_to?(:view_wiki_pages, @project)
|
228 |
|
|
229 |
|
args, options = extract_macro_options(args, :days, :limit, :time)
|
|
227 |
args, options = extract_macro_options(args, :days, :limit, :time, :project)
|
230 |
228 |
days_to_list = (options[:days].presence || 7).to_i
|
231 |
229 |
limit = options[:limit].to_i if options[:limit].present?
|
232 |
230 |
is_show_time = options[:time].to_s == 'true'
|
|
231 |
project = Project.find_by_identifier(options[:project].to_s) if options[:project].present?
|
|
232 |
project = @project if project.nil?
|
233 |
233 |
|
|
234 |
return '' if project.nil?
|
|
235 |
return '' unless User.current.allowed_to?(:view_wiki_pages, project)
|
|
236 |
|
234 |
237 |
pages = WikiPage.
|
235 |
238 |
joins(:content, :wiki).
|
236 |
|
where(["#{Wiki.table_name}.project_id = ? AND #{WikiContent.table_name}.updated_on >= ?", @project.id, days_to_list.days.ago]).
|
|
239 |
where(["#{Wiki.table_name}.project_id = ? AND #{WikiContent.table_name}.updated_on >= ?", project.id, days_to_list.days.ago]).
|
237 |
240 |
order("#{WikiContent.table_name}.updated_on desc, id").
|
238 |
241 |
limit(limit)
|
239 |
242 |
|
... | ... | |
241 |
244 |
pages.each do |page|
|
242 |
245 |
concat(
|
243 |
246 |
tag.li do
|
244 |
|
html = link_to(h(page.pretty_title), project_wiki_page_path(@project, page.title))
|
|
247 |
html = link_to(h(page.pretty_title), project_wiki_page_path(project, page.title))
|
245 |
248 |
html << " (#{time_ago_in_words(page.content.updated_on)})" if is_show_time
|
246 |
249 |
html
|
247 |
250 |
end
|