Class: ClWiki::PageController
Instance Method Summary
collapse
#authorized, #current_owner, #current_user, #expire_old_session, #initialize_index, #logged_in?
Instance Method Details
#assign_page_name ⇒ Object
92
93
94
|
# File 'app/controllers/cl_wiki/page_controller.rb', line 92
def assign_page_name
@page_name = params[:page_name]
end
|
#edit ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/cl_wiki/page_controller.rb', line 20
def edit
@render_encryption_ui = $wiki_conf.use_authentication
@page = instantiate_page
@encrypt_default = determine_encryption_default
@page.read_raw_content
@page
end
|
#find ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/controllers/cl_wiki/page_controller.rb', line 42
def find
@formatter = ClWiki::PageFormatter.new
@search_text = params[:search_text]
@results = []
if @search_text
hits = search(@search_text)
hits.each do |full_name|
@formatter.full_name = full_name
@results << @formatter.convert_to_link(full_name).to_s
end
end
end
|
#front_page_name ⇒ Object
77
78
79
|
# File 'app/controllers/cl_wiki/page_controller.rb', line 77
def front_page_name
'FrontPage'
end
|
111
112
113
|
# File 'app/controllers/cl_wiki/page_controller.rb', line 111
def initialize_formatter
@formatter = ClWiki::PageFormatter.new
end
|
#recent ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'app/controllers/cl_wiki/page_controller.rb', line 61
def recent
page_names = ClWiki::MemoryIndexer.instance.recent(10, text: $wiki_conf.publishTag)
without_header_and_footer = false
@pages = page_names.map do |page_name|
ClWiki::Page.new(page_name, owner: current_owner).tap do |page|
page.read_content(without_header_and_footer)
end
end
respond_to do |format|
format.html
format. { render layout: false }
end
end
|
#redirect_legacy_cgi_urls ⇒ Object
81
82
83
84
85
86
87
88
89
90
|
# File 'app/controllers/cl_wiki/page_controller.rb', line 81
def redirect_legacy_cgi_urls
if request.fullpath.start_with?(legacy_path)
page_name = (params[:page] || front_page_name).split('/')[-1]
if request.query_parameters.include?('edit')
redirect_to page_edit_url(page_name: page_name), status: '301'
else
redirect_to page_show_url(page_name: page_name), status: '301'
end
end
end
|
#redirect_to_front_page_if_bad_name ⇒ Object
96
97
98
99
100
101
102
|
# File 'app/controllers/cl_wiki/page_controller.rb', line 96
def redirect_to_front_page_if_bad_name
if (@page_name.blank? || !@formatter.is_wiki_name?(@page_name)) ||
(!$wiki_conf.editable && !ClWiki::Page.page_exists?(@page_name))
redirect_to page_show_url(page_name: front_page_name)
nil
end
end
|
#redirect_to_show_if_read_only ⇒ Object
104
105
106
107
108
109
|
# File 'app/controllers/cl_wiki/page_controller.rb', line 104
def redirect_to_show_if_read_only
unless $wiki_conf.editable
redirect_to page_show_url(page_name: @page_name)
nil
end
end
|
#show ⇒ Object
14
15
16
17
18
|
# File 'app/controllers/cl_wiki/page_controller.rb', line 14
def show
@page = instantiate_page
@page.read_content
@page
end
|
#update ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/cl_wiki/page_controller.rb', line 30
def update
@page = instantiate_page
mtime = Time.at(params[:client_mod_time].to_s.to_i)
encrypt = params[:encrypt].present?
@page.update_content(params[:page_content], mtime, encrypt)
redirect_to params[:save_and_edit] ?
page_edit_url(page_name: @page.page_name) :
page_show_url(page_name: @page.page_name)
end
|