"user interface" to allow or prohibit file uploads (not working, just the UI element)

This commit is contained in:
Alexey Verkhovsky 2005-01-24 00:20:31 +00:00
parent a99e492f05
commit 8d8deb8e76
5 changed files with 35 additions and 11 deletions

View file

@ -148,7 +148,8 @@ class WikiController < ApplicationController
@params['password'].empty? ? nil : @params['password'], @params['password'].empty? ? nil : @params['password'],
@params['published'] ? true : false, @params['published'] ? true : false,
@params['brackets_only'] ? true : false, @params['brackets_only'] ? true : false,
@params['count_pages'] ? true : false @params['count_pages'] ? true : false,
@params['allow_uploads'] ? true : false
) )
redirect_show('HomePage', @params['address']) redirect_show('HomePage', @params['address'])
else else

View file

@ -6,8 +6,8 @@ require "zip/zip"
class Web class Web
attr_accessor :name, :address, :password, :markup, :color, :safe_mode, :pages attr_accessor :name, :address, :password, :markup, :color, :safe_mode, :pages
attr_accessor :additional_style, :published, :brackets_only, :count_pages attr_accessor :additional_style, :published, :brackets_only, :count_pages, :allow_uploads
def initialize(parent_wiki, name, address, password = nil) def initialize(parent_wiki, name, address, password = nil)
@name, @address, @password, @safe_mode = name, address, password, false @name, @address, @password, @safe_mode = name, address, password, false
@pages = {} @pages = {}

View file

@ -75,21 +75,22 @@ module AbstractWikiService
end end
def update_web(old_address, new_address, name, markup, color, additional_style, safe_mode = false, def update_web(old_address, new_address, name, markup, color, additional_style, safe_mode = false,
password = nil, published = false, brackets_only = false, count_pages = false) password = nil, published = false, brackets_only = false, count_pages = false,
allow_uploads = true)
if old_address != new_address if old_address != new_address
@webs[new_address] = @webs[old_address] @webs[new_address] = @webs[old_address]
@webs.delete(old_address) @webs.delete(old_address)
@webs[new_address].address = new_address @webs[new_address].address = new_address
end end
web = @webs[new_address] web = @webs[new_address]
web.refresh_revisions if settings_changed?(web, markup, safe_mode, brackets_only) web.refresh_revisions if settings_changed?(web, markup, safe_mode, brackets_only)
web.name, web.markup, web.color, web.additional_style, web.safe_mode = web.name, web.markup, web.color, web.additional_style, web.safe_mode =
name, markup, color, additional_style, safe_mode name, markup, color, additional_style, safe_mode
web.password, web.published, web.brackets_only, web.count_pages = web.password, web.published, web.brackets_only, web.count_pages, web.allow_uploads =
password, published, brackets_only, count_pages password, published, brackets_only, count_pages, allow_uploads
end end
def write_page(web_address, page_name, content, written_on, author) def write_page(web_address, page_name, content, written_on, author)

View file

@ -21,6 +21,8 @@
Turning safe mode on will strip HTML tags and stylesheet options from the content of all pages. Turning safe mode on will strip HTML tags and stylesheet options from the content of all pages.
Turning on "brackets only" will require all wiki words to be as [[wiki word]] and WikiWord Turning on "brackets only" will require all wiki words to be as [[wiki word]] and WikiWord
won't work. won't work.
Turning "allow uploads" on will let wiki users to upload pictures and other files to the wiki
and include them on wiki pages.
Additions to the stylesheet take precedence over the existing styles. Additions to the stylesheet take precedence over the existing styles.
<i>Hint:</i> View source on a page you want to style to find ID names on individual tags. <i>Hint:</i> View source on a page you want to style to find ID names on individual tags.
<a href="#" onClick="document.getElementById('additionalStyle').style.display='block';return false;"> <a href="#" onClick="document.getElementById('additionalStyle').style.display='block';return false;">
@ -51,6 +53,8 @@
Brackets only Brackets only
&nbsp;&nbsp; &nbsp;&nbsp;
<input type="checkbox" name="count_pages"<%= " CHECKED" if @web.count_pages %> /> Count pages <input type="checkbox" name="count_pages"<%= " CHECKED" if @web.count_pages %> /> Count pages
&nbsp;&nbsp;
<input type="checkbox" name="allow_uploads"<%= " CHECKED" if @web.allow_uploads %> /> Allow uploads
</small> </small>
<textarea id="additionalStyle" <textarea id="additionalStyle"

View file

@ -636,8 +636,8 @@ class WikiControllerTest < Test::Unit::TestCase
process('update_web', 'system_password' => 'pswd', process('update_web', 'system_password' => 'pswd',
'web' => 'wiki1', 'address' => 'renamed_wiki1', 'name' => 'Renamed Wiki1', 'web' => 'wiki1', 'address' => 'renamed_wiki1', 'name' => 'Renamed Wiki1',
'markup' => 'markdown', 'color' => 'blue', 'additional_style' => 'whatever', 'markup' => 'markdown', 'color' => 'blue', 'additional_style' => 'whatever',
'safe_mode' => 'y', 'password' => 'new_password', 'published' => 'y', 'safe_mode' => 'on', 'password' => 'new_password', 'published' => 'on',
'brackets_only' => 'y', 'count_pages' => 'y') 'brackets_only' => 'on', 'count_pages' => 'on', 'allow_uploads' => 'on')
assert_redirected_to :web => 'renamed_wiki1', :action => 'show', :id => 'HomePage' assert_redirected_to :web => 'renamed_wiki1', :action => 'show', :id => 'HomePage'
assert_equal 'renamed_wiki1', @web.address assert_equal 'renamed_wiki1', @web.address
@ -649,8 +649,26 @@ class WikiControllerTest < Test::Unit::TestCase
assert @web.published assert @web.published
assert @web.brackets_only assert @web.brackets_only
assert @web.count_pages assert @web.count_pages
assert @web.allow_uploads
end end
def test_update_web_opposite_values
@wiki.system[:password] = 'pswd'
process('update_web', 'system_password' => 'pswd',
'web' => 'wiki1', 'address' => 'renamed_wiki1', 'name' => 'Renamed Wiki1',
'markup' => 'markdown', 'color' => 'blue', 'additional_style' => 'whatever',
'password' => 'new_password')
# safe_mode, published, brackets_only, count_pages, allow_uploads not set
# and should become false
assert_redirected_to :web => 'renamed_wiki1', :action => 'show', :id => 'HomePage'
assert !@web.safe_mode
assert !@web.published
assert !@web.brackets_only
assert !@web.count_pages
assert !@web.allow_uploads
end
def test_web_list def test_web_list
another_wiki = @wiki.create_web('Another Wiki', 'another_wiki') another_wiki = @wiki.create_web('Another Wiki', 'another_wiki')