Changeset 565
- Timestamp:
- 08/24/05 22:40:48 (3 years ago)
- Files:
-
- trunk (modified) (1 prop)
- trunk/app/apis/blogger_service.rb (modified) (3 diffs)
- trunk/app/apis/meta_weblog_service.rb (modified) (7 diffs)
- trunk/app/apis/movable_type_service.rb (modified) (3 diffs)
- trunk/app/apis/typo_web_service.rb (modified) (2 diffs)
- trunk/app/controllers/admin/comments_controller.rb (modified) (2 diffs)
- trunk/app/controllers/admin/content_controller.rb (modified) (4 diffs)
- trunk/app/controllers/admin/pages_controller.rb (modified) (3 diffs)
- trunk/app/controllers/admin/textfilters_controller.rb (added)
- trunk/app/controllers/admin/themes_controller.rb (modified) (1 diff)
- trunk/app/controllers/application.rb (modified) (2 diffs)
- trunk/app/controllers/articles_controller.rb (modified) (2 diffs)
- trunk/app/controllers/backend_controller.rb (modified) (1 diff)
- trunk/app/controllers/textfilter_controller.rb (added)
- trunk/app/helpers/admin/base_helper.rb (modified) (2 diffs)
- trunk/app/helpers/articles_helper.rb (modified) (1 diff)
- trunk/app/helpers/textfilter_helper.rb (added)
- trunk/app/models/aggregations/flickr.rb (modified) (2 diffs)
- trunk/app/models/article.rb (modified) (4 diffs)
- trunk/app/models/comment.rb (modified) (2 diffs)
- trunk/app/models/page.rb (modified) (1 diff)
- trunk/app/models/text_filter.rb (added)
- trunk/app/models/theme.rb (modified) (2 diffs)
- trunk/app/views/admin/content/preview.rhtml (modified) (1 diff)
- trunk/app/views/admin/general/index.rhtml (modified) (2 diffs)
- trunk/app/views/admin/pages/preview.rhtml (modified) (1 diff)
- trunk/app/views/admin/textfilters (added)
- trunk/app/views/admin/textfilters/destroy.rhtml (added)
- trunk/app/views/admin/textfilters/edit.rhtml (added)
- trunk/app/views/admin/textfilters/list.rhtml (added)
- trunk/app/views/admin/textfilters/macro_help.rhtml (added)
- trunk/app/views/admin/textfilters/new.rhtml (added)
- trunk/app/views/admin/textfilters/preview.rhtml (added)
- trunk/app/views/admin/textfilters/show.rhtml (added)
- trunk/app/views/admin/textfilters/show_help.rhtml (added)
- trunk/app/views/admin/textfilters/_form.rhtml (added)
- trunk/app/views/admin/textfilters/_macros.rhtml (added)
- trunk/app/views/admin/textfilters/_textfilters.rhtml (added)
- trunk/app/views/admin/themes/index.rhtml (modified) (1 diff)
- trunk/app/views/layouts/administration.rhtml (modified) (1 diff)
- trunk/app/views/textfilter (added)
- trunk/components/plugins/sidebars/flickr_controller.rb (modified) (1 diff)
- trunk/components/plugins/textfilters (added)
- trunk/components/plugins/textfilters/amazon_controller.rb (added)
- trunk/components/plugins/textfilters/code_controller.rb (added)
- trunk/components/plugins/textfilters/flickr_controller.rb (added)
- trunk/components/plugins/textfilters/htmlfilter_controller.rb (added)
- trunk/components/plugins/textfilters/macropost_controller.rb (added)
- trunk/components/plugins/textfilters/macropre_controller.rb (added)
- trunk/components/plugins/textfilters/markdown_controller.rb (added)
- trunk/components/plugins/textfilters/none_controller.rb (added)
- trunk/components/plugins/textfilters/smartypants_controller.rb (added)
- trunk/components/plugins/textfilters/sparkline_controller.rb (added)
- trunk/components/plugins/textfilters/textile_controller.rb (added)
- trunk/config/environment.rb (modified) (3 diffs)
- trunk/config/routes.rb (modified) (1 diff)
- trunk/db/migrate/13_add_textfilters.rb (added)
- trunk/db/migrate/14_move_text_filter_to_text_filter_id.rb (added)
- trunk/lib/html_engine.rb (deleted)
- trunk/test/fixtures/pages.yml (modified) (1 diff)
- trunk/test/fixtures/text_filters.yml (added)
- trunk/test/functional/admin/content_controller_test.rb (modified) (3 diffs)
- trunk/test/functional/articles_controller_test.rb (modified) (2 diffs)
- trunk/test/functional/backend_controller_test.rb (modified) (8 diffs)
- trunk/test/functional/textfilter_controller_test.rb (added)
- trunk/test/mocks/test/flickr_mock.rb (added)
- trunk/test/unit/article_test.rb (modified) (3 diffs)
- trunk/test/unit/comment_test.rb (modified) (2 diffs)
- trunk/test/unit/flickr_test.rb (modified) (1 diff)
- trunk/test/unit/page_test.rb (modified) (1 diff)
- trunk/test/unit/text_filter_test.rb (added)
- trunk/test/unit/theme_test.rb (modified) (1 diff)
- trunk/themes/azure/stylesheets/azure.css (modified) (1 diff)
- trunk/vendor/flickr (added)
- trunk/vendor/flickr/flickr.rb (added)
- trunk/vendor/flickr/index.html (added)
- trunk/vendor/flickr/Rakefile (added)
- trunk/vendor/flickr/test_flickr.rb (added)
- trunk/vendor/sparklines (added)
- trunk/vendor/sparklines/lib (added)
- trunk/vendor/sparklines/lib/sparklines.rb (added)
- trunk/vendor/sparklines/README.txt (added)
- trunk/vendor/sparklines/samples (added)
- trunk/vendor/sparklines/samples/sparklinestest.rb (added)
- trunk/vendor/sparklines/sparklines_generator.rb (added)
- trunk/vendor/sparklines/templates (added)
- trunk/vendor/sparklines/templates/sparklines_controller.rb (added)
- trunk/vendor/sparklines/templates/sparklines_helper.rb (added)
- trunk/vendor/sparklines/USAGE (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk
- Property svn:ignore changed from public/stylesheets/theme to cache
trunk/app/apis/blogger_service.rb
r444 r565 41 41 class BloggerService < TypoWebService 42 42 web_service_api BloggerApi 43 44 43 before_invocation :authenticate 45 attr_reader :controller46 47 def initialize(controller)48 @controller = controller49 end50 44 51 45 def deletePost(appkey, postid, username, password, publish) … … 84 78 article.created_at = Time.now 85 79 article.user = @user 80 article.text_filter ||= TextFilter.find_by_name(config[:text_filter]) 86 81 87 82 if categories … … 91 86 end 92 87 88 update_html(article) 89 93 90 article.save 94 91 article.id 95 92 end 96 93 97 94 end trunk/app/apis/meta_weblog_service.rb
r554 r565 66 66 class MetaWeblogService < TypoWebService 67 67 web_service_api MetaWeblogApi 68 69 68 before_invocation :authenticate 70 attr_reader :controller71 72 def initialize(controller)73 @controller = controller74 end75 69 76 70 def getCategories(blogid, username, password) … … 98 92 99 93 # Movable Type API support 100 article.allow_comments = struct['mt_allow_comments'] || config[ 'default_allow_comments']101 article.allow_pings = struct['mt_allow_pings'] || config[ 'default_allow_pings']94 article.allow_comments = struct['mt_allow_comments'] || config[:default_allow_comments] 95 article.allow_pings = struct['mt_allow_pings'] || config[:default_allow_pings] 102 96 article.extended = struct['mt_text_more'] || '' 103 97 article.excerpt = struct['mt_excerpt'] || '' 104 98 article.keywords = struct['mt_keywords'] || '' 105 article.text_filter = struct['mt_convert_breaks'] || ''99 article.text_filter = TextFilter.find_by_name(struct['mt_convert_breaks'] || config[:text_filter]) 106 100 107 101 if struct['categories'] … … 113 107 114 108 article.send_pings(article_url(article), struct['mt_tb_ping_urls']) 109 update_html(article) 115 110 116 111 article.save … … 138 133 article.excerpt = struct['mt_excerpt'] || '' 139 134 article.keywords = struct['mt_keywords'] || '' 140 article.text_filter = struct['mt_convert_breaks'] || ''135 article.text_filter = TextFilter.find_by_name(struct['mt_convert_breaks'] || config[:text_filter]) 141 136 142 137 if struct['categories'] … … 148 143 RAILS_DEFAULT_LOGGER.info(struct['mt_tb_ping_urls']) 149 144 article.send_pings(article_url(article), struct['mt_tb_ping_urls']) 150 145 update_html(article) 151 146 article.save 152 147 true … … 174 169 :mt_allow_comments => article.allow_comments.to_i, 175 170 :mt_allow_pings => article.allow_pings.to_i, 176 :mt_convert_breaks => article.text_filter.to_s,171 :mt_convert_breaks => (article.text_filter.name.to_s rescue ''), 177 172 :mt_tb_ping_urls => article.pings.collect { |p| p.url }, 178 173 :dateCreated => (article.created_at.to_formatted_s(:db) rescue "") … … 196 191 def pub_date(time) 197 192 time.strftime "%a, %e %b %Y %H:%M:%S %Z" 198 end 193 end 199 194 end trunk/app/apis/movable_type_service.rb
r548 r565 109 109 article.categories.push_with_attributes(category, :is_primary => c['isPrimary']) 110 110 end 111 111 update_html(article) 112 112 article.save 113 113 end … … 120 120 # translators being available. 121 121 def supportedTextFilters() 122 filters = [] 123 filters << MovableTypeStructs::TextFilter.new(:key => 'markdown', :label => 'Markdown') if defined?(BlueCloth) 124 filters << MovableTypeStructs::TextFilter.new(:key => 'smartypants', :label => 'SmartyPants') if defined?(RubyPants) 125 filters << MovableTypeStructs::TextFilter.new(:key => 'markdown smartypants', :label => 'Markdown with SmartyPants') if defined?(RubyPants) and defined?(BlueCloth) 126 filters << MovableTypeStructs::TextFilter.new(:key => 'textile', :label => 'Textile') if defined?(RedCloth) 127 filters 122 TextFilter.find(:all).collect do |filter| 123 MovableTypeStructs::TextFilter.new(:key => filter.name, :label => filter.description) 124 end 128 125 end 129 126 … … 150 147 time.strftime "%a, %e %b %Y %H:%M:%S %Z" 151 148 end 149 152 150 end trunk/app/apis/typo_web_service.rb
r431 r565 1 1 class TypoWebService < ActionWebService::Base 2 attr_accessor :controller 3 4 def initialize(controller) 5 @controller = controller 6 end 2 7 3 8 protected … … 15 20 end 16 21 end 22 23 private 24 def update_html(article) 25 article.body_html = controller.filter_text_by_name(article.body, (article.text_filter.name rescue nil)) 26 article.extended_html = controller.filter_text_by_name(article.extended, (article.text_filter.name rescue nil)) 27 end 17 28 end trunk/app/controllers/admin/comments_controller.rb
r310 r565 19 19 def new 20 20 @comment = @article.comments.build(params[:comment]) 21 @comment.body_html = filter_text_by_name(@comment.body, config[:comment_text_filter],true) 21 22 22 23 if request.post? and @comment.save … … 29 30 @comment = @article.comments.find(params[:id]) 30 31 @comment.attributes = params[:comment] 32 @comment.body_html = filter_text_by_name(@comment.body, config[:comment_text_filter],true) 31 33 if request.post? and @comment.save 32 34 flash[:notice] = 'Comment was successfully updated.' trunk/app/controllers/admin/content_controller.rb
r544 r565 25 25 @article.allow_comments ||= config[:default_allow_comments] 26 26 @article.allow_pings ||= config[:default_allow_pings] 27 @article.text_filter ||= config[:text_filter]27 @article.text_filter ||= TextFilter.find_by_name(config[:text_filter]) 28 28 @article.user = session[:user] 29 update_html(@article) 29 30 30 31 @categories = Category.find(:all, :order => 'UPPER(name)') … … 53 54 @article.categories.clear 54 55 @article.categories << Category.find(params[:categories]) if params[:categories] 56 update_html(@article) 55 57 56 58 params[:attachments].each do |k,v| … … 94 96 def preview 95 97 @headers["Content-Type"] = "text/html; charset=utf-8" 96 @article = params[:article] 98 @article = Article.new 99 @article.attributes = params[:article] 100 update_html(@article) 97 101 render :layout => false 98 102 end … … 134 138 end 135 139 end 140 141 private 142 def update_html(article) 143 article.body_html = filter_text_by_name(article.body, article.text_filter.name) rescue article.body 144 article.extended_html = filter_text_by_name(article.extended, article.text_filter.name) rescue article.extended 145 end 146 136 147 end trunk/app/controllers/admin/pages_controller.rb
r461 r565 21 21 @page.user_id = session[:user].id 22 22 @page.text_filter ||= config[:text_filter] 23 @page.body_html = filter_text_by_name(@page.body,@page.text_filter) 23 24 if request.post? and @page.save 24 25 flash[:notice] = 'Page was successfully created.' … … 30 31 @page = Page.find(params[:id]) 31 32 @page.attributes = params[:page] 33 @page.body_html = filter_text_by_name(@page.body,@page.text_filter) 32 34 if request.post? and @page.save 33 35 flash[:notice] = 'Page was successfully updated.' … … 46 48 def preview 47 49 @headers["Content-Type"] = "text/html; charset=utf-8" 48 @page = params[:page] 50 @page = Page.new 51 @page.attributes = params[:page] 52 @page.body_html = filter_text_by_name(@page.body,@page.text_filter) 49 53 render :layout => false 50 54 end trunk/app/controllers/admin/themes_controller.rb
r442 r565 3 3 def index 4 4 @themes = Theme.find_all 5 @themes.each do |theme| 6 theme.description_html = filter_text(theme.description,[:markdown,:smartypants]) 7 end 5 8 @active = Theme.current 6 9 end trunk/app/controllers/application.rb
r462 r565 1 2 1 # The filters added to this controller will be run for all controllers in the application. 3 2 # Likewise will all the methods added be available for all controllers. … … 37 36 Theme.current.layout 38 37 end 38 39 def filter_text(text, filters, filterparams={}, filter_html=false) 40 map=TextFilter.filters_map 41 42 if(filter_html) 43 filters = [:htmlfilter, filters].flatten 44 end 45 46 filters.each do |filter| 47 begin 48 filter_component = map[filter.to_s].controller_path 49 text = render_component_as_string(:controller => filter_component, 50 :action => 'filtertext', 51 :params => {:text => text, :filterparams => filterparams} ) 52 rescue => err 53 logger.error "Filter #{filter} failed: #{err}" 54 end 55 end 56 57 text 58 end 59 60 def filter_text_by_name(text, filtername, filter_html=false) 61 f = TextFilter.find_by_name(filtername) 62 if (f) 63 filters = [:macropre, f.markup, :macropost, f.filters].flatten 64 filter_text(text,filters,f.params,filter_html) 65 else 66 filter_text(text,[:macropre,:macropost],{},filter_html) 67 end 68 end 39 69 end 70 71 require_dependency 'controllers/textfilter_controller' trunk/app/controllers/articles_controller.rb
r557 r565 108 108 @comment.article = @article 109 109 @comment.ip = request.remote_ip 110 @comment.body_html = filter_text_by_name(@comment.body, config[:comment_text_filter],true) 110 111 111 112 if request.post? and @comment.save … … 119 120 render :partial => "comment", :object => @comment 120 121 else 122 STDERR.puts @comment.errors.inspect 121 123 render :text => @comment.errors.full_messages.join(", "), :status => 500 122 124 end trunk/app/controllers/backend_controller.rb
r196 r565 4 4 web_service_dispatching_mode :layered 5 5 web_service(:metaWeblog) { MetaWeblogService.new(self) } 6 web_service(:mt) { MovableTypeService.new }6 web_service(:mt) { MovableTypeService.new(self) } 7 7 web_service(:blogger) { BloggerService.new(self) } 8 8 trunk/app/helpers/admin/base_helper.rb
r558 r565 61 61 end 62 62 63 def text_filter_options 64 text_filter_options = Array.new 65 text_filter_options << [ 'None', 'none' ] 66 text_filter_options << [ 'Textile', 'textile' ] if defined?(RedCloth) 67 text_filter_options << [ 'Markdown', 'markdown' ] if defined?(BlueCloth) 68 text_filter_options << [ 'SmartyPants', 'smartypants' ] if defined?(RubyPants) 69 text_filter_options << [ 'Markdown with SmartyPants', 'markdown smartypants' ] if defined?(RubyPants) and defined?(BlueCloth) 70 text_filter_options 63 def text_filter_options 64 TextFilter.find(:all).collect do |filter| 65 [ filter.description, filter ] 66 end 71 67 end 72 68 73 69 def alternate_class 74 70 @class = @class != '' ? '' : 'class="shade"' 71 end 72 73 def reset_alternation 74 @class = nil 75 75 end 76 76 … … 103 103 end 104 104 105 def task_help(title, id) 106 task(title, 'show_help', id) 107 end 108 105 109 def task(title, action, id = nil) 106 110 content_tag :li, link_to(title, :action => action, :id => id) trunk/app/helpers/articles_helper.rb
r556 r565 91 91 92 92 image_tag("http://www.gravatar.com/avatar.php?" << 93 options.map { |key, value| "#{key}=#{value}" }.join("&"), :class => "gravatar")93 options.map { |key,value| "#{key}=#{value}" }.sort.join("&"), :class => "gravatar") 94 94 end 95 95 end trunk/app/models/aggregations/flickr.rb
r364 r565 10 10 # end 11 11 # 12 class Flickr 12 class FlickrAggregation 13 13 include REXML 14 14 … … 24 24 25 25 # This object holds given information of a picture 26 class Picture < Struct.new(:link, :title, :date, :description) 27 def to_s; title end 28 def date=(value); super(Time.parse(value)) end 26 class Picture 27 attr_accessor :link, :title, :date, :description 28 29 def to_s 30 title 31 end 32 33 def date=(value) 34 @date = Time.parse(value) 35 end 36 29 37 def image 30 38 description.scan( /http\:\/\/photo.*\.jpg/ ).to_s trunk/app/models/article.rb
r557 r565 12 12 has_and_belongs_to_many :tags 13 13 belongs_to :user 14 belongs_to :text_filter 14 15 15 16 after_destroy :fix_resources 17 18 # Compatibility hack, so Article.attributes(params[:article]) still works. 19 def text_filter=(filter) 20 if filter.nil? 21 self.text_filter_id = nil 22 elsif filter.kind_of? TextFilter 23 self.text_filter_id = filter.id 24 else 25 new_filter = TextFilter.find_by_name(filter.to_s) 26 self.text_filter_id = (new_filter.nil? ? nil : new_filter.id) 27 end 28 end 16 29 17 30 def stripped_title … … 108 121 protected 109 122 110 before_save :set_defaults , :transform_body123 before_save :set_defaults 111 124 112 125 def set_defaults … … 120 133 121 134 self.published ||= 1 122 self.text_filter = config['text_filter'] if self.text_filter.blank?135 self.text_filter = TextFilter.find_by_name(config['text_filter']) if self.text_filter_id.blank? 123 136 124 137 if schema_version >= 7 … … 136 149 137 150 def transform_body 138 self.body_html = HtmlEngine.transform(body, self.text_filter)139 self.extended_html = HtmlEngine.transform(extended, self.text_filter)151 # self.body_html = TextFilter.filter_by_name(body,text_filter) 152 # self.extended_html = TextFilter.filter_by_name(extended,text_filter) 140 153 end 141 154 trunk/app/models/comment.rb
r287 r565 10 10 protected 11 11 12 before_save :correct_url, :make_nofollow , :transform_body, :make_nofollow13 12 before_save :correct_url, :make_nofollow 13 14 14 def correct_url 15 15 unless url.to_s.empty? … … 22 22 def make_nofollow 23 23 self.author = nofollowify(author) 24 self.body = nofollowify(body)24 self.body_html = nofollowify(body_html.to_s) 25 25 end 26 27 def transform_body28 # Escape HTML in comments29 self.body_html = HtmlEngine.transform(body, config["comment_text_filter"], [:filter_html])30 end31 32 26 end trunk/app/models/page.rb
r464 r565 1 1 class Page < ActiveRecord::Base 2 2 belongs_to :user 3 be fore_save :transform_body3 belongs_to :text_filter 4 4 validates_presence_of :name, :title, :body 5 5 validates_uniqueness_of :name 6 7 protected8 6 9 def transform_body 10 self.body_html = HtmlEngine.transform(body, self.text_filter) 11 end 7 # Compatibility hack, so Page.attributes(params[:page]) still works. 8 def text_filter=(filter) 9 if filter.nil? 10 self.text_filter_id = nil 11 elsif filter.kind_of? TextFilter 12 self.text_filter_id = filter.id 13 else 14 new_filter = TextFilter.find_by_name(filter.to_s) 15 self.text_filter_id = (new_filter.nil? ? nil : new_filter.id) 16 end 17 end 12 18 end trunk/app/models/theme.rb
r463 r565 3 3 @@cache_theme_lookup = false 4 4 5 attr_accessor :name, :path 5 attr_accessor :name, :path, :description_html 6 6 7 7 def initialize(name, path) … … 14 14 15 15 def description 16 readme = File.read("#{path}/about.markdown") 17 HtmlEngine.transform(readme, "markdown smartypants") 16 File.read("#{path}/about.markdown") 18 17 end 19 18 trunk/app/views/admin/content/preview.rhtml
r461 r565 1 1 <h4><%= @article[:title] %></h4> 2 2 3 <% [:body, :extended].each do |text| -%> 4 <p><%= HtmlEngine.transform(@article[text], @article[:text_filter]) %></p> 5 <% end -%> 3 <%= @article.full_html %> trunk/app/views/admin/general/index.rhtml
r556 r565 76 76 <p> 77 77 <select name="setting[text_filter]" id="text_filter"> 78 <%= options_for_select text_filter_options, config_value(:text_filter) %>78 <%= options_for_select text_filter_options, TextFilter.find_by_name(config_value(:text_filter)) %> 79 79 </select> 80 80 <label for="text_filter">Article filter</label> … … 82 82 <p> 83 83 <select name="setting[comment_text_filter]" id="comment_text_filter"> 84 <%= options_for_select text_filter_options, config_value(:comment_text_filter) %>84 <%= options_for_select text_filter_options, TextFilter.find_by_name(config_value(:comment_text_filter)) %> 85 85 </select> 86 86 <label for="comment_text_filter">Comments filter</label> trunk/app/views/admin/pages/preview.rhtml
r464 r565 1 1 <h3><%= @page[:title] %></h3> 2 2 3 <p><%= HtmlEngine.transform(@page[:body], @page[:text_filter])%></p>3 <p><%= @page.body_html %></p> trunk/app/views/admin/themes/index.rhtml
r498 r565 2 2 <div class="set theme" style="margin-top:10px;"> 3 3 <div class="preview"><img src="<%= url_for :action => 'preview', :theme => theme.name %>" alt="<%= theme.name %>" /></div> 4 <%= theme.description %>4 <%= theme.description_html %> 5 5 <% if theme.path == @active.path -%> 6 6 <em>(Active theme)</em> trunk/app/views/layouts/administration.rhtml
r558 r565 37 37 <%= tab "Users", :controller=>"/admin/users", :action => 'index' %> 38 38 <%= tab "Resources", :controller=>"/admin/resources", :action => 'index' %> 39 <%= tab "Filters", :controller=>"/admin/textfilters", :action => 'index' %> 39 40 </ul> 40 41 </div> trunk/components/plugins/sidebars/flickr_controller.rb
r440 r565 13 13 14 14 def content 15 @flickr=check_cache(Flickr , @sb_config['feed']) rescue nil15 @flickr=check_cache(FlickrAggregration, @sb_config['feed']) rescue nil 16 16 end 17 17 trunk/config/environment.rb
r561 r565 24 24 vendor/redcloth/lib 25 25 vendor/bluecloth/lib 26 vendor/flickr 27 vendor/sparklines/lib 26 28 vendor/rails/railties 27 29 vendor/rails/railties/lib … … 40 42 require 'bluecloth' 41 43 require 'rubypants' 44 require 'flickr' 42 45 43 46 # Require Rails libraries. … … 95 98 96 99 ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:database_manager => CGI::Session::ActiveRecordStore) 100 ActionController::Base.fragment_cache_store = ActionController::Caching::Fragments::FileStore.new("#{RAILS_ROOT}/cache/fragment/") 97 101 98 102 ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!( trunk/config/routes.rb
r563 r565 64 64 :controller => 'theme', :action => 'images' 65 65 66 map.connect 'plugins/filters/:filter/:public_action', 67 :controller => 'textfilter', :action => 'public_action' 68 66 69 # Kill attempts to connect directly to the theme controller. 67 70 # Ideally we'd disable these by removing the default route (below), trunk/test/fixtures/pages.yml
r464 r565 10 10 title: Another Page Title 11 11 body: another body for yet another page 12 markdown_page: 13 id: 3 14 name: markdown-page 15 title: Markdown Page 16 text_filter_id: 1 17 body: this is *markdown*. 18 trunk/test/functional/admin/content_controller_test.rb
r534 r565 6 6 7 7 class Admin::ContentControllerTest < Test::Unit::TestCase 8 fixtures :articles, :users, :categories, :resources 8 fixtures :articles, :users, :categories, :resources, :text_filters, :settings 9 9 10 10 def setup … … 53 53 assert_equal @tobi, new_article.user 54 54 end 55 56 def test_create_filtered 57 body = "body via *textile*" 58 extended="*foo*" 59 post :new, 'article' => { :title => "another test", :body => body, :extended => extended} 60 assert_redirected_to :action => 'show' 61 62 new_article = Article.find(:first, :order => "id DESC") 63 assert_equal body, new_article.body 64 assert_equal extended, new_article.extended 65 assert_equal "textile", new_article.text_filter.name 66 assert_equal '<p>body via <strong>textile</strong></p>', new_article.body_html 67 assert_equal '<p><strong>foo</strong></p>', new_article.extended_html 68 end 55 69 56 70 def test_edit … … 62 76 63 77 def test_update 64 post :edit, 'id' => 1 78 body = "another *textile* test" 79 post :edit, 'id' => 1, 'article' => {:body => body, :text_filter => 'textile'} 65 80 assert_redirected_to :action => 'show', :id => 1 81 82 article = Article.find(1) 83 assert_equal "textile", article.text_filter.name 84 assert_equal body, article.body 85 assert_equal '<p>another <strong>textile</strong> test</p>', article.body_html 66 86 end 67 87 trunk/test/functional/articles_controller_test.rb
r560 r565 6 6 7 7 class ArticlesControllerTest < Test::Unit::TestCase 8 fixtures :articles, :categories, :settings, :users, :comments, :trackbacks, :pages, :articles_categories 8 fixtures :articles, :categories, :settings, :users, :comments, :trackbacks, :pages, :articles_categories, :text_filters 9 9 10 10 def setup … … 54 54 end 55 55 56 def test_comment_posting 57 post :comment, { :id => 1, :comment => {'body' => 'This is *textile*', 'author' => 'bob' }} 58 59 assert_response :success 60 assert_tag :tag => 'strong', :content => 'textile' 61 62 comment = Comment.find(:first, :order => 'created_at desc') 63 assert comment 64 65 assert_equal '<p>This is <strong>textile</strong></p>', comment.body_html 66 end 67 68 def test_comment_spam1 69 post :comment, { 70 :id => 1, 71 :comment => { 72 'body' => 'Link to <a href="http://spammer.example.com">spammy goodness</a>', 73 'author' => 'bob', 74 'url' => 'http://spam2.example.com', 75 'email' => 'foo'}} 76 77 assert_response :success 78 79 comment = Comment.find(:first, :order => 'created_at desc') 80 assert comment 81 82 assert_equal '<p>Link to <a href=”http://spammer.example.com”>spammy goodness</a></p>', 83 comment.body_html 84 end 85 86 def test_comment_spam2 87 post :comment, { 88 :id => 1, 89 :comment => { 90 'body' => 'Link to "spammy goodness":http://spammer.example.com', 91 'author' => 'bob', 92 'url' => 'http://spam2.example.com', 93 'email' => 'foo'}} 94 95 assert_response :success 96 97 comment = Comment.find(:first, :order => 'created_at desc') 98 assert comment 99 100 assert_equal '<p>Link to <a href="http://spammer.example.com" rel="nofollow">spammy goodness</a></p>', 101 comment.body_html 102 end 103 56 104 def test_comment_nuking 57 105 num_comments = Comment.count trunk/test/functional/backend_controller_test.rb
r553 r565 40 40 41 41 def test_blogger_new_post 42 args = [ 'foo', '1', 'tobi', 'whatever', '<title>new post title</title>new post body', 1]42 args = [ 'foo', '1', 'tobi', 'whatever', '<title>new post title</title>new post *body*', 1] 43 43 44 44 result = invoke_layered :blogger, :newPost, *args … … 46 46 new_post = Article.find(result) 47 47 assert_equal "new post title", new_post.title 48 assert_equal "new post body", new_post.body 49 assert_equal "textile", new_post.text_filter 48 assert_equal "new post *body*", new_post.body 49 assert_equal "<p>new post <strong>body</strong></p>", new_post.body_html 50 assert_equal "textile", new_post.text_filter.name 50 51 assert_equal @tobi, new_post.user 51 52 end … … 59 60 assert_equal "new post body for post without", new_post.title 60 61 assert_equal "new post body for post without title but with a lenghty body", new_post.body 62 assert_equal "<p>new post body for post without title but with a lenghty body</p>", new_post.body_html 61 63 end 62 64 … … 120 122 article = Article.find(1) 121 123 article.title = "Modified!" 124 article.body = "this is a *test*" 125 article.text_filter = TextFilter.find_by_name("textile") 122 126 article.created_at = Time.now.midnight 123 127 … … 126 130 result = invoke_layered :metaWeblog, :editPost, *args 127 131 assert result 128 assert_equal "Modified!", Article.find(1).title 129 assert_equal Time.now.midnight.to_s, Article.find(1).created_at.to_s 132 133 new_article = Article.find(1) 134 135 assert_equal article.title, new_article.title 136 assert_equal article.body, new_article.body 137 assert_equal "<p>this is a <strong>test</strong></p>", new_article.body_html 138 assert_equal Time.now.midnight.to_s, new_article.created_at.to_s 130 139 end 131 140 … … 134 143 article.title = "Posted via Test" 135 144 article.body = "body" 145 article.extended = "extend me" 146 article.text_filter = TextFilter.find_by_name("textile") 136 147 article.created_at = Time.now.midnight 137 148 … … 142 153 new_post = Article.find(result) 143 154 assert_equal "Posted via Test", new_post.title 144 assert_equal "textile", new_post.text_filter 155 assert_equal "textile", new_post.text_filter.name 156 as
