Sync with Instiki Trunk

Sync with Revision 519 of Instiki trunk (2007/5/7).
This commit is contained in:
Jacques Distler 2007-05-11 11:47:38 -05:00
parent b0e063451f
commit 3b6cd309ff
21 changed files with 173 additions and 158 deletions

View file

@ -13,12 +13,12 @@ class AdminController < ApplicationController
"\n\n" +
"(WARNING: this will destroy content of your current wiki)."
redirect_home(@wiki.webs.keys.first)
elsif @params['web_name']
elsif params['web_name']
# form submitted -> create a wiki
@wiki.setup(@params['password'], @params['web_name'], @params['web_address'])
flash[:info] = "Your new wiki '#{@params['web_name']}' is created!\n" +
@wiki.setup(params['password'], params['web_name'], params['web_address'])
flash[:info] = "Your new wiki '#{params['web_name']}' is created!\n" +
"Please edit its home page and press Submit when finished."
redirect_to :web => @params['web_address'], :controller => 'wiki', :action => 'new',
redirect_to :web => params['web_address'], :controller => 'wiki', :action => 'new',
:id => 'HomePage'
else
# no form submitted -> go to template
@ -26,13 +26,13 @@ class AdminController < ApplicationController
end
def create_web
if @params['address']
if params['address']
# form submitted
if @wiki.authenticate(@params['system_password'])
if @wiki.authenticate(params['system_password'])
begin
@wiki.create_web(@params['name'], @params['address'])
flash[:info] = "New web '#{@params['name']}' successfully created."
redirect_to :web => @params['address'], :controller => 'wiki', :action => 'new',
@wiki.create_web(params['name'], params['address'])
flash[:info] = "New web '#{params['name']}' successfully created."
redirect_to :web => params['address'], :controller => 'wiki', :action => 'new',
:id => 'HomePage'
rescue Instiki::ValidationError => e
@error = e.message
@ -47,25 +47,25 @@ class AdminController < ApplicationController
end
def edit_web
system_password = @params['system_password']
system_password = params['system_password']
if system_password
# form submitted
if wiki.authenticate(system_password)
begin
wiki.edit_web(
@web.address, @params['address'], @params['name'],
@params['markup'].intern,
@params['color'], @params['additional_style'],
@params['safe_mode'] ? true : false,
@params['password'].empty? ? nil : @params['password'],
@params['published'] ? true : false,
@params['brackets_only'] ? true : false,
@params['count_pages'] ? true : false,
@params['allow_uploads'] ? true : false,
@params['max_upload_size']
@web.address, params['address'], params['name'],
params['markup'].intern,
params['color'], params['additional_style'],
params['safe_mode'] ? true : false,
params['password'].empty? ? nil : params['password'],
params['published'] ? true : false,
params['brackets_only'] ? true : false,
params['count_pages'] ? true : false,
params['allow_uploads'] ? true : false,
params['max_upload_size']
)
flash[:info] = "Web '#{@params['address']}' was successfully updated"
redirect_home(@params['address'])
flash[:info] = "Web '#{params['address']}' was successfully updated"
redirect_home(params['address'])
rescue Instiki::ValidationError => e
logger.warn e.message
@error = e.message
@ -81,12 +81,12 @@ class AdminController < ApplicationController
end
def remove_orphaned_pages
if wiki.authenticate(@params['system_password_orphaned'])
if wiki.authenticate(params['system_password_orphaned'])
wiki.remove_orphaned_pages(@web_name)
flash[:info] = 'Orphaned pages removed'
redirect_to :controller => 'wiki', :web => @web_name, :action => 'list'
else
flash[:error] = password_error(@params['system_password_orphaned'])
flash[:error] = password_error(params['system_password_orphaned'])
redirect_to :controller => 'admin', :web => @web_name, :action => 'edit_web'
end
end

View file

@ -29,8 +29,8 @@ class ApplicationController < ActionController::Base
end
def connect_to_model
@action_name = @params['action'] || 'index'
@web_name = @params['web']
@action_name = params['action'] || 'index'
@web_name = params['web']
@wiki = wiki
@author = cookies['author'] || 'AnonymousCoward'
if @web_name
@ -106,11 +106,11 @@ class ApplicationController < ActionController::Base
end
def remember_location
if @request.method == :get and
@response.headers['Status'] == '200 OK' and not
if request.method == :get and
response.headers['Status'] == '200 OK' and not
%w(locked save back file pic import).include?(action_name)
@session[:return_to] = @request.request_uri
logger.debug "Session ##{session.object_id}: remembered URL '#{@session[:return_to]}'"
session[:return_to] = request.request_uri
logger.debug "Session ##{session.object_id}: remembered URL '#{session[:return_to]}'"
end
end
@ -126,8 +126,8 @@ class ApplicationController < ActionController::Base
def return_to_last_remembered
# Forget the redirect location
redirect_target, @session[:return_to] = @session[:return_to], nil
tried_home, @session[:tried_home] = @session[:tried_home], false
redirect_target, session[:return_to] = session[:return_to], nil
tried_home, session[:tried_home] = session[:tried_home], false
# then try to redirect to it
if redirect_target.nil?
@ -146,15 +146,15 @@ class ApplicationController < ActionController::Base
def set_content_type_header
if %w(atom_with_content atom_with_headlines).include?(action_name)
@response.headers['Content-Type'] = 'application/atom+xml; charset=UTF-8'
response.headers['Content-Type'] = 'application/atom+xml; charset=UTF-8'
elsif %w(tex).include?(action_name)
@response.headers['Content-Type'] = 'text/plain; charset=UTF-8'
elsif @request.env['HTTP_USER_AGENT'] =~ /MathPlayer|Validator/ or @request.env.include?('HTTP_ACCEPT') &&
Mime::Type.parse(@request.env["HTTP_ACCEPT"]).include?(Mime::XHTML) &&
!(@request.env['HTTP_USER_AGENT'] =~ /Safari/ and %w(s5).include?(action_name))
@response.headers['Content-Type'] = 'application/xhtml+xml; charset=UTF-8'
response.headers['Content-Type'] = 'text/plain; charset=UTF-8'
elsif request.env['HTTP_USER_AGENT'] =~ /MathPlayer|Validator/ or request.env.include?('HTTP_ACCEPT') &&
Mime::Type.parse(request.env["HTTP_ACCEPT"]).include?(Mime::XHTML) &&
!(request.env['HTTP_USER_AGENT'] =~ /Safari/ and %w(s5).include?(action_name))
response.headers['Content-Type'] = 'application/xhtml+xml; charset=UTF-8'
else
@response.headers['Content-Type'] = 'text/html; charset=UTF-8'
response.headers['Content-Type'] = 'text/html; charset=UTF-8'
end
end
@ -192,7 +192,7 @@ class ApplicationController < ActionController::Base
@web.nil? or
@web.password.nil? or
cookies[CGI.escape(@web_name)] == @web.password or
password_check(@params['password']) or
password_check(params['password']) or
(@web.published? and action_name == 's5')
end

View file

@ -10,10 +10,10 @@ class FileController < ApplicationController
before_filter :check_allow_uploads
def file
@file_name = @params['id']
if @params['file']
@file_name = params['id']
if params['file']
# form supplied
new_file = @web.wiki_files.create(@params['file'])
new_file = @web.wiki_files.create(params['file'])
if new_file.valid?
flash[:info] = "File '#{@file_name}' successfully uploaded"
return_to_last_remembered
@ -39,10 +39,10 @@ class FileController < ApplicationController
end
def import
if @params['file']
if params['file']
@problems = []
import_file_name = "#{@web.address}-import-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.zip"
import_from_archive(@params['file'].path)
import_from_archive(params['file'].path)
if @problems.empty?
flash[:info] = 'Import successfully finished'
else
@ -58,7 +58,7 @@ class FileController < ApplicationController
protected
def check_allow_uploads
render(:status => 404, :text => "Web #{@params['web'].inspect} not found") and return false unless @web
render(:status => 404, :text => "Web #{params['web'].inspect} not found") and return false unless @web
if @web.allow_uploads?
return true
else

View file

@ -30,10 +30,10 @@ class WikiController < ApplicationController
# Outside a single web --------------------------------------------------------
def authenticate
if password_check(@params['password'])
if password_check(params['password'])
redirect_home
else
flash[:info] = password_error(@params['password'])
flash[:info] = password_error(params['password'])
redirect_to :action => 'login', :web => @web_name
end
end
@ -146,7 +146,7 @@ class WikiController < ApplicationController
end
def search
@query = @params['query']
@query = params['query']
@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
@ -165,7 +165,7 @@ class WikiController < ApplicationController
def edit
if @page.nil?
redirect_home
elsif @page.locked?(Time.now) and not @params['break_lock']
elsif @page.locked?(Time.now) and not params['break_lock']
redirect_to :web => @web_name, :action => 'locked', :id => @page_name
else
@page.lock(Time.now, @author)
@ -216,7 +216,7 @@ class WikiController < ApplicationController
def revision
get_page_and_revision
@show_diff = (@params[:mode] == 'diff')
@show_diff = (params[:mode] == 'diff')
@renderer = PageRenderer.new(@revision)
end
@ -227,13 +227,13 @@ class WikiController < ApplicationController
def save
render(:status => 404, :text => 'Undefined page name') and return if @page_name.nil?
author_name = @params['author'].delete("\x01-\x08\x0B\x0C\x0E-\x1F")
author_name = params['author'].delete("\x01-\x08\x0B\x0C\x0E-\x1F")
author_name = 'AnonymousCoward' if author_name =~ /^\s*$/
raise "Your name was not valid utf-8" if !author_name.is_utf8?
cookies['author'] = { :value => author_name, :expires => Time.utc(2030) }
begin
the_content = @params['content'].delete("\x01-\x08\x0B\x0C\x0E-\x1F")
the_content = params['content'].delete("\x01-\x08\x0B\x0C\x0E-\x1F")
raise "Your content was not valid utf-8" if !the_content.is_utf8?
filter_spam(the_content)
if @page
@ -262,7 +262,7 @@ class WikiController < ApplicationController
if @page
begin
@renderer = PageRenderer.new(@page.revisions.last)
@show_diff = (@params[:mode] == 'diff')
@show_diff = (params[:mode] == 'diff')
render_action 'page'
# TODO this rescue should differentiate between errors due to rendering and errors in
# the application itself (for application errors, it's better not to rescue the error at all)
@ -309,7 +309,7 @@ class WikiController < ApplicationController
protected
def load_page
@page_name = @params['id']
@page_name = params['id']
@page = @wiki.read_page(@web_name, @page_name) if @page_name
end
@ -371,8 +371,8 @@ class WikiController < ApplicationController
end
def get_page_and_revision
if @params['rev']
@revision_number = @params['rev'].to_i
if params['rev']
@revision_number = params['rev'].to_i
else
@revision_number = @page.revisions.length
end
@ -381,7 +381,7 @@ class WikiController < ApplicationController
def parse_category
@categories = WikiReference.list_categories(@web).sort
@category = @params['category']
@category = params['category']
if @category
@set_name = "category '#{@category}'"
pages = WikiReference.pages_in_category(@web, @category).sort.map { |page_name| @web.page(page_name) }
@ -394,7 +394,7 @@ class WikiController < ApplicationController
end
def remote_ip
ip = @request.remote_ip
ip = request.remote_ip
logger.info(ip)
ip
end

View file

@ -40,7 +40,7 @@ class Web < ActiveRecord::Base
end
def has_page?(name)
Page.count(['web_id = ? AND name = ?', id, name]) > 0
Page.count(:conditions => ['web_id = ? AND name = ?', id, name]) > 0
end
def has_file?(file_name)

View file

@ -6,9 +6,9 @@
you'll need to do a brief one-time setup.
</p>
<%= form_tag({ :controller => 'admin', :action => 'create_system' },
<% form_tag({ :controller => 'admin', :action => 'create_system' },
{ 'id' => 'setup', 'method' => 'post', 'onsubmit' => 'return validateSetup()',
'accept-charset' => 'utf-8' })
'accept-charset' => 'utf-8' }) do
%>
<ol class="setup">
<li>
@ -46,7 +46,7 @@
<p style="text-align:right">
<input type="submit" value="Setup" style="margin-left: 40px" />
</p>
<%= end_form_tag %>
<% end %>
<script type="text/javascript">
function proposeAddress() {

View file

@ -5,10 +5,10 @@
so different subjects or projects can write about different <i>MuppetShows</i>.
</p>
<%= form_tag({ :controller => 'admin', :action => 'create_web' },
<% form_tag({ :controller => 'admin', :action => 'create_web' },
{ 'id' => 'setup', 'method' => 'post',
'onsubmit' => 'cleanAddress(); return validateSetup()',
'accept-charset' => 'utf-8' })
'accept-charset' => 'utf-8' }) do
%>
<ol class="setup">
@ -36,7 +36,7 @@
<input type="submit" value="Create Web" />
</p>
<%= end_form_tag %>
<% end %>
<script type="text/javascript">
function proposeAddress() {

View file

@ -1,9 +1,9 @@
<% @title = "Edit Web" %>
<%= form_tag({ :controller => 'admin', :action => 'edit_web', :web => @web.address },
<% form_tag({ :controller => 'admin', :action => 'edit_web', :web => @web.address },
{ 'id' => 'setup', 'method' => 'post',
'onsubmit' => 'cleanAddress(); return validateSetup()',
'accept-charset' => 'utf-8' })
'accept-charset' => 'utf-8' }) do
%>
<h2 style="margin-bottom: 3px">Name and address</h2>
@ -107,15 +107,15 @@
...or forget changes and <%= link_to 'create a new web', :action => 'create_web' %>
</p>
<%= end_form_tag %>
<% end %>
<br/>
<h1>Other administrative tasks</h1>
<%= form_tag({:controller => 'admin', :web => @web.address, :action => 'remove_orphaned_pages'},
<% form_tag({:controller => 'admin', :web => @web.address, :action => 'remove_orphaned_pages'},
{ :id => 'remove_orphaned_pages',
:onsubmit => "return checkSystemPassword(document.getElementById('system_password_orphaned').value)",
'accept-charset' => 'utf-8' })
'accept-charset' => 'utf-8' }) do
%>
<p style="text-align:right;font-size:.85em;">
Clean up by entering system password
@ -123,6 +123,6 @@
and
<input type="submit" value="Delete Orphan Pages" />
</p>
<%= end_form_tag %>
<% end %>
<%= javascript_include_tag 'edit_web' %>

View file

@ -5,8 +5,8 @@
<%= error_messages_for 'file' %>
<%= form_tag({ :controller => 'file', :web => @web_name, :action => 'file' },
{ 'multipart' => true , 'accept-charset' => 'utf-8' }) %>
<% form_tag({ :controller => 'file', :web => @web_name, :action => 'file' },
{ 'multipart' => true , 'accept-charset' => 'utf-8' }) do %>
<div class="inputFieldWithPrompt">
<%= hidden_field 'file', 'file_name' %>
<label for="file_content"><b>Content of <%= h @file_name %> to upload</b> (required):</label>
@ -28,4 +28,4 @@
:onfocus => "this.value == 'AnonymousCoward' ? this.value = '' : true;",
:onblur => "this.value == '' ? this.value = 'AnonymousCoward' : true" %>
</div>
<%= end_form_tag %>
<% end %>

View file

@ -54,12 +54,12 @@
<%= render 'navigation' unless @web.nil? || @hide_navigation %>
<% if @flash[:info] %>
<div class="info"><%= escape_preserving_linefeeds @flash[:info] %></div>
<% if flash[:info] %>
<div class="info"><%= escape_preserving_linefeeds flash[:info] %></div>
<% end %>
<% if @error or @flash[:error] %>
<div class="errorExplanation"><%= escape_preserving_linefeeds(@error || @flash[:error]) %></div>
<% if @error or flash[:error] %>
<div class="errorExplanation"><%= escape_preserving_linefeeds(@error || flash[:error]) %></div>
<% end %>
<%= @content_for_layout %>

View file

@ -16,12 +16,12 @@ end
<%= list_item 'Authors', {:action => 'authors'}, 'Who wrote what' %> |
<%= list_item 'Feeds', {:action => 'feeds'}, 'Subscribe to changes by RSS' %> |
<%= list_item 'Export', {:action => 'export'}, 'Download a zip with all the pages in this wiki', 'X' %> |
<%= form_tag({ :controller => 'wiki', :action => 'search', :web => @web.address},
{'id' => 'navigationSearchForm', 'method' => 'get', 'accept-charset' => 'utf-8' }) %>
<% form_tag({ :controller => 'wiki', :action => 'search', :web => @web.address},
{'id' => 'navigationSearchForm', 'method' => 'get', 'accept-charset' => 'utf-8' }) do %>
<fieldset class="search"><input type="text" id="searchField" name="query" value="Search"
onfocus="this.value == 'Search' ? this.value = '' : true"
onblur="this.value == '' ? this.value = 'Search' : true" /></fieldset>
<%= end_form_tag %>
<% end_form_tag %>
<% else %>
<%= list_item 'Home Page', {:action => 'published', :id => 'HomePage'}, 'Home, Sweet Home', 'H' %>
<% end%>

View file

@ -9,9 +9,9 @@
<%= render 'wiki_words_help' %>
</div>
<%= form_tag({ :action => 'save', :web => @web.address, :id => @page.name },
<% form_tag({ :action => 'save', :web => @web.address, :id => @page.name },
{ 'id' => 'editForm', 'method' => 'post', 'onsubmit' => 'cleanAuthorName()',
'accept-charset' => 'utf-8' }) %>
'accept-charset' => 'utf-8' }) do %>
<div>
<textarea name="content" id="content" rows="24" cols="60"><%= h(@flash[:content] || @page.content.delete("\x01-\x08\x0B\x0C\x0E-\x1F")) %></textarea>
<div id="editFormButtons">
@ -27,7 +27,7 @@
</span>
</div>
</div>
<%= end_form_tag %>
<% end %>
<script type="text/javascript">
function cleanAuthorName() {

View file

@ -1,7 +1,7 @@
<% @title = "#{@web_name} Login" %><% @hide_navigation = true %>
<%= form_tag({ :controller => 'wiki', :action => 'authenticate', :web => @web.address},
{ 'id' => 'loginForm', 'method' => 'post', 'accept-charset' => 'utf-8' }) %>
<% form_tag({ :controller => 'wiki', :action => 'authenticate', :web => @web.address},
{ 'id' => 'loginForm', 'method' => 'post', 'accept-charset' => 'utf-8' }) do %>
<p>
This web is password-protected. Please enter the password.
<% if @web.published? %>
@ -13,7 +13,7 @@
<input type="password" name="password" id="password" />
<input type="submit" value="Login" />
</p>
<%= end_form_tag %>
<% end %>
<script type="text/javascript">
document.forms["loginForm"].elements["password"].focus();

View file

@ -10,8 +10,8 @@
</div>
<div id="editForm">
<%= form_tag({ :action => 'save', :web => @web.address, :id => @page_name },
{ 'id' => 'editForm', 'method' => 'post', 'onsubmit' => 'cleanAuthorName();', 'accept-charset' => 'utf-8' }) %>
<% form_tag({ :action => 'save', :web => @web.address, :id => @page_name },
{ 'id' => 'editForm', 'method' => 'post', 'onsubmit' => 'cleanAuthorName();', 'accept-charset' => 'utf-8' }) do %>
<textarea name="content" id="content" rows="24" cols="60"><%= h(@flash[:content] || '') %></textarea>
<div id="editFormButtons">
@ -20,7 +20,7 @@
:onfocus => "this.value == 'AnonymousCoward' ? this.value = '' : true;",
:onblur => "this.value == '' ? this.value = 'AnonymousCoward' : true" %>
</div>
<%= end_form_tag %>
<% end %>
</div>
<script type="text/javascript">

View file

@ -4,16 +4,16 @@
@hide_navigation = true
%>
<%= "<p style='color:red'>Please correct the error that caused this error in rendering:<br/><small>#{@params["msg"]}</small></p>" if @params["msg"] %>
<%= "<p style='color:red'>Please correct the error that caused this error in rendering:<br/><small>#{params["msg"]}</small></p>" if params["msg"] %>
<div id="MarkupHelp">
<%= render("#{@web.markup}_help") %>
<%= render 'wiki_words_help' %>
</div>
<%= form_tag({:web => @web.address, :action => 'save', :id => @page.name},
<% form_tag({:web => @web.address, :action => 'save', :id => @page.name},
{ :id => 'editForm', :method => 'post', :onsubmit => 'cleanAuthorName();',
'accept-charset' => 'utf-8' }) %>
'accept-charset' => 'utf-8' }) do %>
<div>
<textarea name="content" id="content" rows="24" cols="60"><%= h(@revision.content.delete("\x01-\x08\x0B\x0C\x0E-\x1F")) %></textarea>
<div id="editFormButtons">
@ -28,7 +28,7 @@
</span>
</div>
</div>
<%= end_form_tag %>
<% end %>
<script type="text/javascript">
function cleanAuthorName() {

View file

@ -1,4 +1,4 @@
<% @title = "Search results for \"#{h @params["query"]}\"" %>
<% @title = "Search results for \"#{h params["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 params["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