Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
3fdfad29a3
|
@ -43,6 +43,9 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
FILE_TYPES = {
|
||||
'.aif' => 'audio/x-aiff',
|
||||
'.aiff'=> 'audio/x-aiff',
|
||||
'.avi' => 'video/x-msvideo',
|
||||
'.exe' => 'application/octet-stream',
|
||||
'.gif' => 'image/gif',
|
||||
'.jpg' => 'image/jpeg',
|
||||
|
@ -50,20 +53,30 @@ class ApplicationController < ActionController::Base
|
|||
'.png' => 'image/png',
|
||||
'.oga' => 'audio/ogg',
|
||||
'.ogg' => 'audio/ogg',
|
||||
'.ogv' => 'video/ogg',
|
||||
'.ogv' => 'video/ogg',
|
||||
'.mov' => 'video/quicktime',
|
||||
'.mp3' => 'audio/mpeg',
|
||||
'.mp4' => 'video/mp4',
|
||||
'.txt' => 'text/plain',
|
||||
'.tex' => 'text/plain',
|
||||
'.wav' => 'audio/x-wav',
|
||||
'.zip' => 'application/zip'
|
||||
} unless defined? FILE_TYPES
|
||||
|
||||
DISPOSITION = {
|
||||
'application/octet-stream' => 'attachment',
|
||||
'application/pdf' => 'inline',
|
||||
'image/gif' => 'inline',
|
||||
'image/jpeg' => 'inline',
|
||||
'application/pdf' => 'inline',
|
||||
'image/png' => 'inline',
|
||||
'audio/mpeg' => 'inline',
|
||||
'audio/x-wav' => 'inline',
|
||||
'audio/x-aiff' => 'inline',
|
||||
'audio/ogg' => 'inline',
|
||||
'video/ogg' => 'inline',
|
||||
'video/mp4' => 'inline',
|
||||
'video/quicktime' => 'inline',
|
||||
'video/x-msvideo' => 'inline',
|
||||
'text/plain' => 'inline',
|
||||
'application/zip' => 'attachment'
|
||||
} unless defined? DISPOSITION
|
||||
|
|
|
@ -105,7 +105,7 @@ module WikiChunk
|
|||
|
||||
unless defined? WIKI_LINK
|
||||
WIKI_LINK = /(":)?\[\[\s*([^\]\s][^\]]*?)\s*\]\]/
|
||||
LINK_TYPE_SEPARATION = Regexp.new('^(.+):((file)|(pic)|(video)|(delete))$', 0)
|
||||
LINK_TYPE_SEPARATION = Regexp.new('^(.+):((file)|(pic)|(video)|(audio)|(delete))$', 0)
|
||||
ALIAS_SEPARATION = Regexp.new('^(.+)\|(.+)$', 0)
|
||||
WEB_SEPARATION = Regexp.new('^(.+):(.+)$', 0)
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module Sanitizer
|
|||
require 'node'
|
||||
require 'stringsupport'
|
||||
|
||||
acceptable_elements = %w[a abbr acronym address area b big blockquote br
|
||||
acceptable_elements = %w[a abbr acronym address area audio b big blockquote br
|
||||
button caption center cite code col colgroup dd del dfn dir div dl dt
|
||||
em fieldset font form h1 h2 h3 h4 h5 h6 hr i img input ins kbd label
|
||||
legend li map menu ol optgroup option p pre q s samp select small span
|
||||
|
@ -31,8 +31,8 @@ module Sanitizer
|
|||
align alt axis border cellpadding cellspacing char charoff charset
|
||||
checked cite class clear cols colspan color compact controls coords datetime
|
||||
dir disabled enctype for frame headers height href hreflang hspace id
|
||||
ismap label lang longdesc maxlength media method multiple name nohref
|
||||
noshade nowrap prompt readonly rel rev rows rowspan rules scope
|
||||
ismap label lang longdesc loop maxlength media method multiple name nohref
|
||||
noshade nowrap poster prompt readonly rel rev rows rowspan rules scope
|
||||
selected shape size span src start style summary tabindex target title
|
||||
type usemap valign value vspace width xml:lang]
|
||||
|
||||
|
|
|
@ -35,8 +35,10 @@ class AbstractUrlGenerator
|
|||
file_link(mode, name, text, web.address, known_page, description)
|
||||
when :pic
|
||||
pic_link(mode, name, text, web.address, known_page)
|
||||
when :audio
|
||||
media_link(mode, name, text, web.address, known_page, 'audio')
|
||||
when :video
|
||||
video_link(mode, name, text, web.address, known_page)
|
||||
media_link(mode, name, text, web.address, known_page, 'video')
|
||||
when :delete
|
||||
delete_link(mode, name, web.address, known_page)
|
||||
else
|
||||
|
@ -143,25 +145,25 @@ class UrlGenerator < AbstractUrlGenerator
|
|||
end
|
||||
end
|
||||
|
||||
def video_link(mode, name, text, web_address, known_vid)
|
||||
def media_link(mode, name, text, web_address, known_media, media_type)
|
||||
href = @controller.url_for :controller => 'file', :web => web_address, :action => 'file',
|
||||
:id => name
|
||||
case mode
|
||||
when :export
|
||||
if known_vid
|
||||
%{<video src="#{CGI.escape(name)}" controls="controls">#{text}</video>}
|
||||
if known_media
|
||||
%{<#{media_type} src="#{CGI.escape(name)}" controls="controls">#{text}</#{media_type}>}
|
||||
else
|
||||
text
|
||||
end
|
||||
when :publish
|
||||
if known_vid
|
||||
%{<video src="#{href}" controls="controls">#{text}</video>}
|
||||
if known_media
|
||||
%{<#{media_type} src="#{href}" controls="controls">#{text}</#{media_type}>}
|
||||
else
|
||||
%{<span class="newWikiWord">#{text}</span>}
|
||||
end
|
||||
else
|
||||
if known_vid
|
||||
%{<video src="#{href}" controls="controls">#{text}</video>}
|
||||
if known_media
|
||||
%{<#{media_type} src="#{href}" controls="controls">#{text}</#{media_type}>}
|
||||
else
|
||||
%{<span class="newWikiWord">#{text}<a href="#{href}">?</a></span>}
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ module HTML5
|
|||
|
||||
module HTMLSanitizeModule
|
||||
|
||||
ACCEPTABLE_ELEMENTS = %w[a abbr acronym address area b big blockquote br
|
||||
ACCEPTABLE_ELEMENTS = %w[a abbr acronym address area audio b big blockquote br
|
||||
button caption center cite code col colgroup dd del dfn dir div dl dt
|
||||
em fieldset font form h1 h2 h3 h4 h5 h6 hr i img input ins kbd label
|
||||
legend li map menu ol optgroup option p pre q s samp select small span
|
||||
|
@ -41,8 +41,8 @@ module HTML5
|
|||
align alt axis border cellpadding cellspacing char charoff charset
|
||||
checked cite class clear cols colspan color compact controls coords datetime
|
||||
dir disabled enctype for frame headers height href hreflang hspace id
|
||||
ismap label lang longdesc maxlength media method multiple name nohref
|
||||
noshade nowrap prompt readonly rel rev rows rowspan rules scope
|
||||
ismap label lang longdesc loop maxlength media method multiple name nohref
|
||||
noshade nowrap poster prompt readonly rel rev rows rowspan rules scope
|
||||
selected shape size span src start style summary tabindex target title
|
||||
type usemap valign value vspace width xml:lang]
|
||||
|
||||
|
|
Loading…
Reference in a new issue