app/controllers/wiki.rb in Pimki-1.0.092 vs app/controllers/wiki.rb in Pimki-1.1.092
- old
+ new
@@ -1,10 +1,10 @@
require "cgi"
require "redcloth_for_tex"
class WikiController < ActionControllerServlet
- EXPORT_DIRECTORY = File.dirname(__FILE__) + "/../../storage/" unless const_defined?("EXPORT_DIRECTORY")
+ EXPORT_DIRECTORY = WikiService.storage_path unless const_defined?("EXPORT_DIRECTORY")
def index
if web_address
redirect_show "HomePage"
elsif !wiki.setup?
@@ -182,28 +182,39 @@
def todo #{{{
parse_category
set_menu_pages
@pages_by_name = @pages_in_category.by_name
@todo_items = Hash.new { Array.new }
+ @bliki_todo_items = Hash.new { Array.new }
@pages_by_name.each do |page|
if page.content =~ Todo.pattern
# Page has todo items. Get the rendered version (marked-up and with links):
content = page.revisions.last.display_content
@todo_items[page] = content.scan /<span class="todo"><strong>TODO:<\/strong> (.*?)<\/span>/
end
end
@todo_items = @todo_items.sort_by { |page, items| page.name }
+ web.bliki.each do |pname, entry|
+ if entry.content =~ Todo.pattern
+ # Entry has todo items. Get the rendered version (marked-up and with links):
+ content = entry.revisions.last.display_content
+ @bliki_todo_items[entry] = content.scan /<span class="todo"><strong>TODO:<\/strong> (.*?)<\/span>/
+ end
+ end
+ @bliki_todo_items = @bliki_todo_items.sort_by { |entry, items| entry.name }
end #}}}
def set_menu_pages #{{{
parse_category
+ @all_pages = web.select { true }
@menu_pages = case web.menu_type
- when 'all' then @pages_in_category.by_name
- when 'recent' then @pages_in_category.by_last_visited
- when 'viewed' then @pages_in_category.by_most_viewed
- when 'revised' then @pages_in_category.by_revision
- when 'user' then @menu_content = web.rendered_menu; nil
+ when 'all' then @all_pages.by_name
+ when 'recent' then @all_pages.by_last_visited
+ when 'viewed' then @all_pages.by_most_viewed
+ when 'revised' then @all_pages.by_revision
+ when 'user' then @menu_content = web.rendered_menu; nil
+ when 'category' then web.select { |page| page.in_category?(web.menu_category) }
when 'linkers'
web.select { |page|
page.wiki_words.size > 0
}.sort_by { |page| page.name }
end
@@ -252,19 +263,20 @@
@list_limit += 1 if @list_limit >= -1
end #}}}
def save_menu #{{{
unless @req.query['action'] == 'Cancel Update'
- type = @req.query['type']
- content = @req.query['content']
+ type = @req.query['type']
+ content = @req.query['content']
+ category = @req.query['category']
limit = @req.query['limit'].to_i rescue nil
limit = 20 unless limit
limit -= 1 if limit >= 0
# need to go through the WikiService to persist the command:
- wiki.save_menu_pref web, type, limit, content
+ wiki.save_menu_pref web, type, limit, content, category
end
if web_address
redirect_show "HomePage"
elsif wiki.webs.length == 1
@@ -415,11 +427,11 @@
@revision = @page.revisions[@params["rev"].to_i] || @page.revisions.last
end
def rollback_bliki
@page = wiki.read_bliki_entry(web_address, page_name)
- wiki.rollback_bliki_entry(web_address, page_name, @params["rev"].to_i-1, Time.now)
+ wiki.rollback_bliki_entry(web_address, page_name, @params["rev"].to_i, Time.now)
redirect_bliki
end
# ----------------------------------------------------------------------------
@@ -453,10 +465,13 @@
def redirect_action(action, web = web_address)
redirect_path "/#{web}/#{action}"
end
-
+ def link_to_bliki(entry, web = web_address) #{{{
+ "<a class='existingWikiWord' href='/#{web}/bliki_revision/#{entry.name}?rev=#{entry.revisions.size-1}'>#{entry.name}</a>"
+ end #}}}
+
private
def wiki
WikiService.instance
end
\ No newline at end of file