app/controllers/wiki.rb in Pimki-1.5.092 vs app/controllers/wiki.rb in Pimki-1.6.092
- old
+ new
@@ -55,10 +55,25 @@
password_check(@params["password"]) ? redirect_show("HomePage") : redirect_action("login")
end
def static_style_sheet() render "static_style_sheet" end
+ def stop
+ redirect_show("HomePage") unless wiki.authenticate(@params["system_password"])
+
+ begin
+ secs = @params['seconds'].to_i
+ raise if secs.zero?
+ @logger.warn "Pimki server will stop in #{secs} seconds!"
+ WikiService.request_stop
+ render_text "Pimki server will stop in #{secs} seconds!"
+ Thread.new { sleep secs; Kernel.exit! }
+ rescue
+ redirect_show("HomePage")
+ end
+ end
+
# Within a single web ---------------------------------------------------------
def parse_category
@categories = web.categories
@category = @params["category"]
@@ -162,10 +177,11 @@
@pages_by_revision = @pages_in_category.by_revision
end
def rss_with_content
@pages_by_revision = web.select.by_revision.first(15)
+ @bliki_entries = web.bliki_entries_by_date
@uri = @req.request_uri
host = @req.meta_vars["HTTP_X_FORWARDED_HOST"] || "#{@uri.host}:#{@uri.port.to_s}"
@web_url = "#{@uri.scheme}://#{host}/#{@web.address}"
@res["Content-Type"] = "text/xml"
render "wiki/rss_feed"
@@ -186,18 +202,18 @@
if @req.query['Action']
redirect_action 'list/' if web.check_pass_on_edit and not authenticate
case @req.query['Action']
when 'Delete' # Handle page deletion
- wiki.delete_page(web_address, @req.query['sel_page_name'])
+ wiki.delete_page(web_address, @req.query['del_sel_page_name'])
redirect_action "list/"
when 'Create' # Handle page creation
redirect_show @req.query['newpage']
when 'Rename' # Handle page rename
- wiki.rename_page(web_address, @req.query['sel_page_name'], @req.query['newpage'])
+ wiki.rename_page(web_address, @req.query['ren_sel_page_name'], @req.query['newpage'])
redirect_action "list/"
end
end
end
@@ -236,11 +252,11 @@
end
def edit_web #{{{
parse_category
set_mm_options
- @snapshot_interval = MadeleineService.snapshot_interval_hours
+ @snapshot_interval = WikiService.snapshot_interval_hours
end #}}}
def update_web
redirect_show("HomePage") unless wiki.authenticate(@params["system_password"])
@@ -276,14 +292,14 @@
when 'Clear Render Cache'
clear_render_cache true
when 'Force Data Snapshot'
- MadeleineService.take_snapshot
+ WikiService.take_snapshot
when 'Clean Storage'
- MadeleineService.clean_old_snapshots
+ WikiService.clean_old_snapshots
end
@message = 'Operation succeeded'
redirect_action 'edit_web/'
else
@@ -370,11 +386,11 @@
def clear_render_cache dont_redirect=false
web.refresh_revisions
redirect_path "/#{web_address}/edit_web/" unless dont_redirect
end
- def set_menu_pages #{{{
+ def set_menu_pages published = false #{{{
parse_category
@all_pages = web.select { true }
@menu_pages = case web.menu_type
when 'all' then @all_pages.by_name
when 'recent' then @all_pages.by_last_visited
@@ -385,10 +401,11 @@
@menu_content = if Page === web.menu_content
web.menu_content.revisions.last.display_content
else
web.menu_content
end
+ @menu_content = @menu_content.gsub('/show/', '/published/').gsub( %r{<a href="../published/.*?">\?</a>}, '') if published
nil
when 'linkers'
web.select { |page|
page.wiki_words.size > 0
}.sort_by { |page| page.name }
@@ -463,11 +480,10 @@
else
[]
end
end #}}}
-
def edit_menu #{{{
@menu_type = web.menu_type
@menu_content = web.menu_content
@list_limit = web.menu_limit
@list_limit += 1 if @list_limit >= -1
@@ -536,9 +552,10 @@
end
end
end
def published
+ set_menu_pages true
if web.published then @page = wiki.read_page(web_address, page_name || "HomePage") else redirect_show("HomePage") end
end
def print
@page = wiki.read_page(web_address, page_name)
\ No newline at end of file