Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
1f8a4fe282
|
@ -18,8 +18,8 @@ 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"
|
||||||
WikiReference.pages_that_want_file(@web, @file_name).each do |page|
|
WikiReference.pages_that_link_to_file(@web, @file_name).each do |page|
|
||||||
RevisionSweeper.expire_page(page)
|
RevisionSweeper.expire_page(@web, page)
|
||||||
end
|
end
|
||||||
redirect_to(params['referring_page'])
|
redirect_to(params['referring_page'])
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,8 +25,8 @@ class RevisionSweeper < ActionController::Caching::Sweeper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.expire_page(page)
|
def self.expire_page(web, page_name)
|
||||||
new.expire_caches(page)
|
new.expire_cached_page(web, page_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -46,16 +46,7 @@ class WikiReference < ActiveRecord::Base
|
||||||
query = 'SELECT name FROM pages JOIN wiki_references ' +
|
query = 'SELECT name FROM pages JOIN wiki_references ' +
|
||||||
'ON pages.id = wiki_references.page_id ' +
|
'ON pages.id = wiki_references.page_id ' +
|
||||||
'WHERE wiki_references.referenced_name = ? ' +
|
'WHERE wiki_references.referenced_name = ? ' +
|
||||||
"AND wiki_references.link_type in ('#{FILE}') " +
|
"AND wiki_references.link_type in ('#{FILE}','#{WANTED_FILE}') " +
|
||||||
"AND pages.web_id = '#{web.id}'"
|
|
||||||
names = connection.select_all(sanitize_sql([query, file_name])).map { |row| row['name'] }
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.pages_that_want_file(web, file_name)
|
|
||||||
query = 'SELECT name FROM pages JOIN wiki_references ' +
|
|
||||||
'ON pages.id = wiki_references.page_id ' +
|
|
||||||
'WHERE wiki_references.referenced_name = ? ' +
|
|
||||||
"AND wiki_references.link_type in ('#{WANTED_FILE}') " +
|
|
||||||
"AND pages.web_id = '#{web.id}'"
|
"AND pages.web_id = '#{web.id}'"
|
||||||
names = connection.select_all(sanitize_sql([query, file_name])).map { |row| row['name'] }
|
names = connection.select_all(sanitize_sql([query, file_name])).map { |row| row['name'] }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue