diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml index 4daf50d4..749912c3 100644 --- a/tracks/app/views/layouts/standard.rhtml +++ b/tracks/app/views/layouts/standard.rhtml @@ -3,9 +3,9 @@
<% tracks_path = app_configurations["path"]["base"] %> - <%= "" %> +#{ code }#{ after }"
+ rip_offtags( "#{ before }#{ code }#{ after }" )
end
end
@@ -552,19 +577,14 @@ class RedCloth < String
end
def hard_break( text )
- text.gsub!( /(.)\n(?! *[#*\s|])/, "\\1#{ blk }"
else
@@ -603,16 +623,18 @@ class RedCloth < String
end
end
- end
+ end.join( "\n\n" ) )
end
def textile_bq( tag, atts, cite, content )
cite, cite_title = check_refs( cite )
cite = " cite=\"#{ cite }\"" if cite
+ atts = shelve( atts ) if atts
"\t\n\t\t" end def textile_p( tag, atts, cite, content ) + atts = shelve( atts ) if atts "\t<#{ tag }#{ atts }>#{ content }#{ tag }>" end @@ -626,6 +648,7 @@ class RedCloth < String def textile_fn_( tag, num, atts, cite, content ) atts << " id=\"fn#{ num }\"" content = "#{ num } #{ content }" + atts = shelve( atts ) if atts "\t#{ content }
\n\t
#{ content }
" end @@ -700,14 +723,21 @@ class RedCloth < String end def inline_textile_span( text ) - QTAGS.each do |ttr, ht| - text.gsub!(ttr) do |m| - - start,atts,cite,content,tend = $~[1..5] + QTAGS.each do |qtag_rc, ht, qtag_re, rtype| + text.gsub!( qtag_re ) do |m| + + case rtype + when :limit + sta,qtag,atts,cite,content = $~[1..5] + else + qtag,atts,cite,content = $~[1..4] + sta = '' + end atts = pba( atts ) atts << " cite=\"#{ cite }\"" if cite + atts = shelve( atts ) if atts - "#{ start }<#{ ht }#{ atts }>#{ content }#{ tend }#{ ht }>" + "#{ sta }<#{ ht }#{ atts }>#{ content }#{ ht }>" end end @@ -890,6 +920,13 @@ class RedCloth < String text.gsub!( /&(?![#a-z0-9]+;)/i, "x%x%" ) end + def no_textile( text ) + text.gsub!( /(^|\s)==([^=]+.*?)==(\s|$)?/, + '\1, etc.
if $1
- if @filter_html
- htmlesc( line, :NoQuotes )
- elsif line =~ OFFTAG_OPEN
+ if line =~ OFFTAG_OPEN
codepre += 1
elsif line =~ OFFTAG_CLOSE
codepre -= 1
@@ -956,7 +993,6 @@ class RedCloth < String
end
def rip_offtags( text )
- pre_list = []
if text =~ /<.*>/
## strip and encode content
codepre, used_offtags = 0, {}
@@ -967,17 +1003,17 @@ class RedCloth < String
used_offtags[offtag] = true
if codepre - used_offtags.length > 0
htmlesc( line, :NoQuotes ) unless used_offtags['notextile']
- pre_list.last << line
+ @pre_list.last << line
line = ""
else
htmlesc( aftertag, :NoQuotes ) if aftertag and not used_offtags['notextile']
- line = ""
- pre_list << "#{ $3 }#{ aftertag }"
+ line = ""
+ @pre_list << "#{ $3 }#{ aftertag }"
end
elsif $1 and codepre > 0
if codepre - used_offtags.length > 0
htmlesc( line, :NoQuotes ) unless used_offtags['notextile']
- pre_list.last << line
+ @pre_list.last << line
line = ""
end
codepre -= 1 unless codepre.zero?
@@ -986,13 +1022,13 @@ class RedCloth < String
line
end
end
- pre_list
+ text
end
- def smooth_offtags( text, pre_list )
- unless pre_list.empty?
+ def smooth_offtags( text )
+ unless @pre_list.empty?
## replace content
- text.gsub!( // ) { pre_list[$1.to_i] }
+ text.gsub!( // ) { @pre_list[$1.to_i] }
end
end
@@ -1014,5 +1050,64 @@ class RedCloth < String
' ' + name + '
'
end
+ # HTML cleansing stuff
+ BASIC_TAGS = {
+ 'a' => ['href', 'title'],
+ 'img' => ['src', 'alt', 'title'],
+ 'br' => [],
+ 'i' => nil,
+ 'u' => nil,
+ 'b' => nil,
+ 'pre' => nil,
+ 'kbd' => nil,
+ 'code' => ['lang'],
+ 'cite' => nil,
+ 'strong' => nil,
+ 'em' => nil,
+ 'ins' => nil,
+ 'sup' => nil,
+ 'sub' => nil,
+ 'del' => nil,
+ 'table' => nil,
+ 'tr' => nil,
+ 'td' => ['colspan', 'rowspan'],
+ 'th' => nil,
+ 'ol' => nil,
+ 'ul' => nil,
+ 'li' => nil,
+ 'p' => nil,
+ 'h1' => nil,
+ 'h2' => nil,
+ 'h3' => nil,
+ 'h4' => nil,
+ 'h5' => nil,
+ 'h6' => nil,
+ 'blockquote' => ['cite']
+ }
+
+ def clean_html( text, tags = BASIC_TAGS )
+ text.gsub!( /]*)>/ ) do
+ raw = $~
+ tag = raw[2].downcase
+ if tags.has_key? tag
+ pcs = [tag]
+ tags[tag].each do |prop|
+ ['"', "'", ''].each do |q|
+ q2 = ( q != '' ? q : '\s' )
+ if raw[3] =~ /#{prop}\s*=\s*#{q}([^#{q2}]+)#{q}/i
+ attrv = $1
+ next if prop == 'src' and attrv !~ /^http/
+ pcs << "#{prop}=\"#{$1.gsub('"', '\\"')}\""
+ break
+ end
+ end
+ end if tags[tag]
+ "<#{raw[1]}#{pcs.join " "}>"
+ else
+ " "
+ end
+ end
+ end
end
diff --git a/tracks/public/.htaccess b/tracks/public/.htaccess
index 5a6a18a5..e2cee75e 100644
--- a/tracks/public/.htaccess
+++ b/tracks/public/.htaccess
@@ -7,7 +7,7 @@ Options +FollowSymLinks +ExecCGI
RewriteEngine On
# Change extension from .cgi to .fcgi to switch to FCGI and to .rb to switch to mod_ruby
-RewriteBase /dispatch.cgi
+RewriteBase /dispatch.fcgi
# Enable this rewrite rule to point to the controller/action that should serve root.
RewriteRule ^$ /todo/list [R]
@@ -16,9 +16,9 @@ RewriteRule ^$ /todo/list [R]
RewriteRule ^([-_a-zA-Z0-9]+)$ /$1/ [R]
# Default rewriting rules.
-RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([0-9]+)$ ?controller=$1&action=$2&id=$3 [QSA,L]
-RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ ?controller=$1&action=$2 [QSA,L]
-RewriteRule ^([-_a-zA-Z0-9]+)/$ ?controller=$1&action=index [QSA,L]
+RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([0-9]+)$ ?controller=$1&action=$2&id=$3 [QSA,L]
+RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ ?controller=$1&action=$2 [QSA,L]
+RewriteRule ^([-_a-zA-Z0-9]+)/$ ?controller=$1&action=index [QSA,L]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([0-9]+)$ ?module=$1&controller=$2&action=$3&id=$4 [QSA,L]
RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ ?module=$1&controller=$2&action=$3 [QSA,L]