Manage Uploaded Files
A less abstruse interface for deleting files (this time, many at-a-shot). Available from the Edit Web page.
This commit is contained in:
parent
788d1eb075
commit
1d3f7007c6
7 changed files with 58 additions and 2 deletions
|
@ -121,6 +121,23 @@ class AdminController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_files
|
||||||
|
return unless is_post
|
||||||
|
some_deleted = false
|
||||||
|
if wiki.authenticate(params['system_password'])
|
||||||
|
params.each do |file, p|
|
||||||
|
if p == 'delete'
|
||||||
|
WikiFile.find_by_file_name(file).destroy
|
||||||
|
some_deleted = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
flash[:info] = "File(s) successfully deleted." if some_deleted
|
||||||
|
else
|
||||||
|
flash[:error] = password_error(params['system_password'])
|
||||||
|
end
|
||||||
|
redirect_to :controller => 'wiki', :web => @web_name, :action => 'file_list'
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def is_post
|
def is_post
|
||||||
|
|
|
@ -17,7 +17,7 @@ class FileController < ApplicationController
|
||||||
new_file = @web.wiki_files.create(params['file'])
|
new_file = @web.wiki_files.create(params['file'])
|
||||||
if new_file.valid?
|
if new_file.valid?
|
||||||
flash[:info] = "File '#{@file_name}' successfully uploaded"
|
flash[:info] = "File '#{@file_name}' successfully uploaded"
|
||||||
return_to_last_remembered
|
redirect_to_page(@page_name)
|
||||||
else
|
else
|
||||||
# pass the file with errors back into the form
|
# pass the file with errors back into the form
|
||||||
@file = new_file
|
@file = new_file
|
||||||
|
|
|
@ -53,6 +53,10 @@ class WikiController < ApplicationController
|
||||||
@authors = @page_names_by_author.keys.sort
|
@authors = @page_names_by_author.keys.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def file_list
|
||||||
|
@web.file_list
|
||||||
|
end
|
||||||
|
|
||||||
def export_html
|
def export_html
|
||||||
stylesheet = File.read(File.join(RAILS_ROOT, 'public', 'stylesheets', 'instiki.css'))
|
stylesheet = File.read(File.join(RAILS_ROOT, 'public', 'stylesheets', 'instiki.css'))
|
||||||
export_pages_as_zip('html') do |page|
|
export_pages_as_zip('html') do |page|
|
||||||
|
|
|
@ -47,6 +47,10 @@ class Web < ActiveRecord::Base
|
||||||
WikiFile.find_by_file_name(file_name) != nil
|
WikiFile.find_by_file_name(file_name) != nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def file_list
|
||||||
|
WikiFile.find(:all, :order => 'file_name')
|
||||||
|
end
|
||||||
|
|
||||||
def description(file_name)
|
def description(file_name)
|
||||||
file = WikiFile.find_by_file_name(file_name)
|
file = WikiFile.find_by_file_name(file_name)
|
||||||
file.description if file
|
file.description if file
|
||||||
|
|
|
@ -112,6 +112,11 @@
|
||||||
:onsubmit => "return checkSystemPassword(document.getElementById('system_password_orphaned').value)",
|
:onsubmit => "return checkSystemPassword(document.getElementById('system_password_orphaned').value)",
|
||||||
'accept-charset' => 'utf-8' }) do
|
'accept-charset' => 'utf-8' }) do
|
||||||
%>
|
%>
|
||||||
|
<div class="inputBox">
|
||||||
|
<%= link_to ' Manage uploaded files',
|
||||||
|
{:controller => 'wiki', :web => @web.address, :action => 'file_list'}, :style => 'font-weight:bold' %>
|
||||||
|
for this web (<%= @web.name %>)
|
||||||
|
</div>
|
||||||
<p style="text-align:right;font-size:.85em;">
|
<p style="text-align:right;font-size:.85em;">
|
||||||
Clean up this web (<%= @web.name %>) by entering the system password
|
Clean up this web (<%= @web.name %>) by entering the system password
|
||||||
<input type="password" id="system_password_orphaned" class="disableAutoComplete" name="system_password_orphaned" />
|
<input type="password" id="system_password_orphaned" class="disableAutoComplete" name="system_password_orphaned" />
|
||||||
|
|
25
app/views/wiki/file_list.html.erb
Normal file
25
app/views/wiki/file_list.html.erb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<%- @title = "Uploaded Files" -%>
|
||||||
|
|
||||||
|
<% form_tag({ :controller => 'admin', :action => 'delete_files', :web => @web.address },
|
||||||
|
{'method' => 'post', 'accept-charset' => 'utf-8' }) do
|
||||||
|
%>
|
||||||
|
<div id="allFiles">
|
||||||
|
<h2>
|
||||||
|
Uploaded Files in <%= @web.name %>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<p>Check the files you wish to delete.</p>
|
||||||
|
<ul style="list-style-type:none">
|
||||||
|
<%- for @file in @web.file_list -%>
|
||||||
|
<li>
|
||||||
|
<input type="checkbox" name="<%= @file.file_name %>" value="delete"/>
|
||||||
|
<a href="<%= url_for :web => @web.address, :action => 'file',
|
||||||
|
:id => @file.file_name %>"><%= @file.file_name%></a>
|
||||||
|
</li>
|
||||||
|
<%- end -%>
|
||||||
|
</ul>
|
||||||
|
<label for="system_password">Enter system password</label>
|
||||||
|
<%= password_field_tag "system_password", '', :class => "disableAutoComplete" %>
|
||||||
|
and <%= submit_tag("Delete Files") %>
|
||||||
|
</div>
|
||||||
|
<%- end %>
|
|
@ -12,6 +12,7 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
map.connect 'create_system', :controller => 'admin', :action => 'create_system'
|
map.connect 'create_system', :controller => 'admin', :action => 'create_system'
|
||||||
map.connect 'create_web', :controller => 'admin', :action => 'create_web'
|
map.connect 'create_web', :controller => 'admin', :action => 'create_web'
|
||||||
map.connect 'delete_web', :controller => 'admin', :action => 'delete_web'
|
map.connect 'delete_web', :controller => 'admin', :action => 'delete_web'
|
||||||
|
map.connect 'delete_files', :controller => 'admin', :action => 'delete_files'
|
||||||
map.connect 'web_list', :controller => 'wiki', :action => 'web_list'
|
map.connect 'web_list', :controller => 'wiki', :action => 'web_list'
|
||||||
|
|
||||||
connect_to_web map, ':web/edit_web', :controller => 'admin', :action => 'edit_web'
|
connect_to_web map, ':web/edit_web', :controller => 'admin', :action => 'edit_web'
|
||||||
|
|
Loading…
Add table
Reference in a new issue