Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
52a0b565a5
9 changed files with 96 additions and 75 deletions
|
@ -140,7 +140,7 @@ class ApplicationController < ActionController::Base
|
|||
<html xmlns="http://www.w3.org/1999/xhtml"><body>
|
||||
<h2>Internal Error</h2>
|
||||
<p>An application error occurred while processing your request.</p>
|
||||
<!-- \n#{exception.to_s.is_utf8? ? exception.to_s.gsub!(/-{2,}/, '- -') : ''}\n#{exception.backtrace.join("\n")}\n -->
|
||||
<!-- \n#{exception.to_s.purify.gsub!(/-{2,}/, '- -') }\n#{exception.backtrace.join("\n")}\n -->
|
||||
</body></html>
|
||||
EOL
|
||||
end
|
||||
|
|
|
@ -124,14 +124,10 @@ class FileController < ApplicationController
|
|||
zip = Zip::ZipInputStream.open(archive)
|
||||
while (entry = zip.get_next_entry) do
|
||||
ext_length = File.extname(entry.name).length
|
||||
page_name = entry.name[0..-(ext_length + 1)]
|
||||
page_content = entry.get_input_stream.read
|
||||
page_name = entry.name[0..-(ext_length + 1)].purify
|
||||
page_content = entry.get_input_stream.read.purify
|
||||
logger.info "Processing page '#{page_name}'"
|
||||
begin
|
||||
if !page_content.is_utf8?
|
||||
logger.info "Page '#{page_name}' contains non-utf8 character data. Skipping."
|
||||
next
|
||||
end
|
||||
existing_page = @wiki.read_page(@web.address, page_name)
|
||||
if existing_page
|
||||
if existing_page.content == page_content
|
||||
|
|
|
@ -162,8 +162,7 @@ class WikiController < ApplicationController
|
|||
end
|
||||
|
||||
def search
|
||||
@query = params['query']
|
||||
render(:text => "Your query string was not valid utf-8", :layout => 'error', :status => 400) and return unless @query.is_utf8?
|
||||
@query = params['query'].purify
|
||||
@title_results = @web.select { |page| page.name =~ /#{@query}/i }.sort
|
||||
@results = @web.select { |page| page.content =~ /#{@query}/i }.sort
|
||||
all_pages_found = (@results + @title_results).uniq
|
||||
|
@ -180,7 +179,7 @@ class WikiController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
if @page.nil? or not @page_name.is_utf8?
|
||||
if @page.nil?
|
||||
redirect_home
|
||||
elsif @page.locked?(Time.now) and not params['break_lock']
|
||||
redirect_to :web => @web_name, :action => 'locked', :id => @page_name
|
||||
|
@ -190,12 +189,10 @@ class WikiController < ApplicationController
|
|||
end
|
||||
|
||||
def locked
|
||||
render(:text => 'Page name is not valid utf-8.', :status => 400, :layout => 'error') unless @page_name.is_utf8?
|
||||
# to template
|
||||
end
|
||||
|
||||
def new
|
||||
render(:text => 'Page name is not valid utf-8.', :status => 400, :layout => 'error') unless @page_name.is_utf8?
|
||||
# to template
|
||||
end
|
||||
|
||||
|
@ -258,32 +255,22 @@ class WikiController < ApplicationController
|
|||
end
|
||||
|
||||
def save
|
||||
render(:status => 404, :text => 'Undefined page name', :layout => 'error') and return if @page_name.nil? or not @page_name.is_utf8?
|
||||
render(:status => 404, :text => 'Undefined page name', :layout => 'error') and return if @page_name.nil?
|
||||
unless (request.post? || ENV["RAILS_ENV"] == "test")
|
||||
headers['Allow'] = 'POST'
|
||||
render(:status => 405, :text => 'You must use an HTTP POST', :layout => 'error')
|
||||
return
|
||||
end
|
||||
author_name = params['author']
|
||||
author_name = params['author'].purify
|
||||
author_name = 'AnonymousCoward' if author_name =~ /^\s*$/
|
||||
|
||||
begin
|
||||
raise Instiki::ValidationError.new('Your name was not valid utf-8') unless author_name.is_utf8?
|
||||
raise Instiki::ValidationError.new('Your name cannot contain a "."') if author_name.include? '.'
|
||||
cookies['author'] = { :value => author_name, :expires => Time.utc(2030) }
|
||||
the_content = params['content']
|
||||
the_content = params['content'].purify
|
||||
filter_spam(the_content)
|
||||
unless the_content.is_utf8?
|
||||
if @page
|
||||
the_content = @page.content
|
||||
else
|
||||
the_content = ''
|
||||
end
|
||||
raise Instiki::ValidationError.new('Your content was not valid utf-8.')
|
||||
end
|
||||
if @page
|
||||
new_name = params['new_name'] || @page_name
|
||||
raise Instiki::ValidationError.new('Your new title was not valid utf-8.') unless new_name.is_utf8?
|
||||
new_name = params['new_name'] ? params['new_name'].purify : @page_name
|
||||
raise Instiki::ValidationError.new('Your new title cannot contain a "."') if new_name.include? '.'
|
||||
raise Instiki::ValidationError.new('A page named "' + new_name.escapeHTML + '" already exists.') if @page_name != new_name && @web.has_page?(new_name)
|
||||
wiki.revise_page(@web_name, @page_name, new_name, the_content, Time.now,
|
||||
|
@ -325,7 +312,7 @@ class WikiController < ApplicationController
|
|||
end
|
||||
end
|
||||
else
|
||||
if not @page_name.nil? and @page_name.is_utf8? and not @page_name.empty?
|
||||
if not @page_name.nil? and not @page_name.empty?
|
||||
real_page = WikiReference.page_that_redirects_for(@web, @page_name)
|
||||
if real_page
|
||||
flash[:info] = "Redirected from \"#{@page_name}\"."
|
||||
|
@ -354,7 +341,7 @@ class WikiController < ApplicationController
|
|||
end
|
||||
render :action => 'history'
|
||||
else
|
||||
if not @page_name.nil? and @page_name.is_utf8? and not @page_name.empty?
|
||||
if not @page_name.nil? and not @page_name.empty?
|
||||
redirect_to :web => @web_name, :action => 'new', :id => @page_name
|
||||
else
|
||||
render :text => 'Page name is not specified', :status => 404, :layout => 'error'
|
||||
|
@ -397,7 +384,7 @@ class WikiController < ApplicationController
|
|||
end
|
||||
|
||||
def load_page
|
||||
@page_name = params['id']
|
||||
@page_name = params['id'] ? params['id'].purify : nil
|
||||
@page = @wiki.read_page(@web_name, @page_name) if @page_name
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
'accept-charset' => 'utf-8' }) do %>
|
||||
<div>
|
||||
<textarea name="content" id="content" rows="24" cols="60"><%= h(flash[:content] ||
|
||||
((params['content'] && params['content'].is_utf8?) ? params['content'] : @page.content).purify) %></textarea>
|
||||
(params['content'] ? params['content'] : @page.content).purify) %></textarea>
|
||||
<% if @page_name != 'HomePage' -%>
|
||||
<p>
|
||||
<%= check_box_tag :alter_title, value = "1", checked=false,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{ 'id' => 'editForm', 'method' => 'post', 'onsubmit' => 'cleanAuthorName();', 'accept-charset' => 'utf-8' }) do %>
|
||||
|
||||
<textarea name="content" id="content" rows="24" cols="60"><%= h(flash[:content] ||
|
||||
( (params['content'] && params['content'].is_utf8?) ? params['content'] : '').purify ) %></textarea>
|
||||
params['content'] ? params['content'].purify : '' ) %></textarea>
|
||||
<div id="editFormButtons">
|
||||
<input type="submit" value="Submit" accesskey="s"/> as
|
||||
<%= text_field_tag :author, @author,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<%- @title = "Search results for \"#{h params["query"]}\"" -%>
|
||||
<%- @title = "Search results for \"#{h @query}\"" -%>
|
||||
|
||||
<%- unless @title_results.empty? -%>
|
||||
<h2><%= @title_results.length %> page(s) containing search string in the page name:</h2>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<%- end -%>
|
||||
|
||||
<%- if (@results + @title_results).empty? -%>
|
||||
<h2>No pages contain "<%= h params["query"] %>" </h2>
|
||||
<h2>No pages contain "<%= h @query %>" </h2>
|
||||
<p>
|
||||
Perhaps you should try expanding your query. Remember that Instiki searches for entire
|
||||
phrases, so if you search for "all that jazz" it will not match pages that contain these
|
||||
|
@ -36,6 +36,6 @@
|
|||
"[a-z]*Leet?RegExpSkill(s|z)"
|
||||
</p>
|
||||
<p>
|
||||
<b>Create a new page, named:</b> "<span class='newWikiWord'><%= link_to h(params[:query]), :web => @web.address, :action => 'new', :id => params[:query] %></span>"
|
||||
<b>Create a new page, named:</b> "<span class='newWikiWord'><%= link_to h(@query), :web => @web.address, :action => 'new', :id => @query %></span>"
|
||||
</p>
|
||||
<%- end -%>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue