diff -Nur mephisto-0.7.3/CHANGELOG technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/CHANGELOG --- mephisto-0.7.3/CHANGELOG 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/CHANGELOG 2008-03-31 02:18:56.000000000 -0400 @@ -1,5 +1,149 @@ +* SVN * + +* Experimental comment preview. [court3nay] + +* Add multi-site admin interface. [Vincent, j2m] + +* Update Wordpress converter to support Wordpress 2.3+. [Aubrey] + +* refactor so that admin/comments is more restful, allow inline comment editing in the admin. [court3nay] + +* convert to cookie sessions. + +* Fix some failing test issues and git => svn sync errors. [Aubrey, octopod] + +* Fix issue where duplicate permalinks are allowed. + +* Fix admin/users issue where site admins could disable mephisto admins. + +* Fix nil.accept_comments? bug in CommentForm block. + +* allow the various link_to filters to accept multiple args to specify more html attributes. [rob-twf] + + # use this order: :text, :title, :id, :class, :rel + link_to_article article, "click here", "this article", "article-1", "articles", "whatever-rel-means" + +* encode search/tag urls properly. [rob-twf] + +* update article forms to explain new tag syntax (comma and space delimited tags) [xavier, rick] + +* start converting tests to rspec. + +* tweak mephisto_init to support the new ActionController::Dispatcher class. [Rob Anderton] + +* Don't generate an article event for unversioned changes. [Marcus Brito] + +* Switch to will_paginate plugin. [Mislav] + +* unit test fixes for those not using mysql or psql. [Mislav] + +* add comment moderation links to the overview. [court3nay] + +* convert tests to use test/spec instead of simply bdd. [Chris McGrath] + +* move xmlrpc stuff to plugin. rails doesn't include AWS anymore. May need some simple autodetection so the plugin just prints a warning if AWS isn't found. + +* turn off session for mephisto controller. sorry, caused way too many problems. + +* fix url_for calls with symbolized controllers/actions. + +* Fix controllers so include_into works with them. + +* Change plugin class/module to Mephisto::Plugin and Mephisto::Plugins. Sorry for the breakage (still technically experimental!). + +* Fix admin overview date timezone. [Ben Wyrosdick] + +* Extract template rendering code to separate handler class, add support for alternate template handlers. [Pascal Belloncle] + +* Add {{ article.next }} and {{ article | next: section }} for paginating articles [Pascal Belloncle] + +* [converters] initial movable type support [sd] + +* [converters] use no filter for wordpress articles + +* Small bug fixes + - show correct asset thumbnail url + - assert with correct named asset resource route + - add missing fixtures for About Section Feed Test + - update asset labeling tests to reflect current behavior + +* RESTRICT hyphens as a possible separator for permalink styles. [Chris Wanstrath] + +* Initial article/asset assignment support. Perfect for podcasting. + +* Raise MissingThemesError if Site#theme is nil + +* RIP: Site#search_layout + +* Add link_to_search_result filter that uses either a paged or blog permalink, depending on the search section. + +* Allow search page to take ?s parameter to specify section path. + + * nil (default) - all sections + * '' (empty string) - home section + * 'foo/bar' - given section + +* Initial Plugin Whammy Jammy [Nick Faiz, Rick Olson] + +* link_to_section adds class='selected' for the current section [Tammo Freese] + +* Process article permalinks with Iconv. + +* Support rel-tag microformat by default in liquid filters + +* Make ImageScience the default image processor for assets. + If you wish to configure this, set ASSET_IMAGE_PROCESSOR to one of 3 values in environment.rb + + ASSET_IMAGE_PROCESSOR = :image_science || :rmagick || :none + +* paged section feeds will show the paged url for articles instead of the long permalink. + +* Replace a couple @article.full_permalink instances with @site.permalink_for(@article) [defunkt] + +# Allow Resource#non_image_extnames to be overridden by plugins [myles_b] + +* filter password fields in logs [chrissturm] + +* add *.ico to list of approved extensions for theme resources [myles_b] + +* Link comments to the currently logged in user, requires latest edge/1.2 rails [Josh Susser] + +* Convert typo filters and permalinks to mephisto [Josh Susser] + +* replace acts_as_attachment with attachment_fu plugin + +* add tags to atom feed [evilchelu] + +* flexible theme names in routes [evilchelu] + +* update liquid plugin + +* use default test.host domain where possible [courtenay] + +* fix test ensuring that comments, not articles are sanitized for script tags [courtenay] + +* fix articles form for latest rails 1.2 changes to date helpers [courtenay] + +* fix test that breaks in multi-site mode [courtenay] + +* Allow Modules to use #include_into to dynamically mixin to loaded classes (plugin stuff) + +* Allow custom routes. + + Mephisto::Routing.connect_with map do + map.foo ... + end + +* fix that only published articles are available as section pages. + +Add sorting for liquid for statements. + + {% for page in section.pages limit: 3 sort_by: title %} + * 0.7.3 * +* Fix duplicate tag bug. + * add Mephisto.root javascript variable in case a mephisto site sets the relative_url_root * don't sanitize custom anchor text for liquid filters [Jonathan Leighton] @@ -52,7 +196,9 @@ * Remove any notion of a template hierarchy, and the page template itself. Paged sections now default to the 'single' template. * Added {{ mode }} so you can check what 'view' you're in. - + + {% unless mode == 'single' %} Read more {% endunless %} + * Ensure templates are sorted by name [Brian Chapados] * Fix bug that was caching redirected routes. @@ -290,4 +436,4 @@ {% endif %} {% endfor %} -* Fix issue where Articles don't allow comments with comment_age = 0 [Rick] \ No newline at end of file +* Fix issue where Articles don't allow comments with comment_age = 0 [Rick] diff -Nur mephisto-0.7.3/LICENSE technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/LICENSE --- mephisto-0.7.3/LICENSE 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/LICENSE 2008-03-31 02:18:56.000000000 -0400 @@ -1,4 +1,4 @@ -Copyright (c) 2005 Rick Olson +Copyright (c) 2005-2008 Rick Olson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -17,4 +17,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff -Nur mephisto-0.7.3/README technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/README --- mephisto-0.7.3/README 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/README 2008-03-31 02:18:56.000000000 -0400 @@ -5,7 +5,7 @@ = Timezones You MUST export the environment variable TZ=UTC, or else the article dates -and times will be fubar. +and times will be invalid. This would not be needed if rails used UTC for everything, but unfortunately it doesn't... eg: action_view/helpers/date_helper.rb uses @@ -19,4 +19,4 @@ = License Mephisto is distributed under the same license as Ruby on Rails. See -http://www.opensource.org/licenses/mit-license.php \ No newline at end of file +http://www.opensource.org/licenses/mit-license.php diff -Nur mephisto-0.7.3/app/apis/meta_weblog_api.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/meta_weblog_api.rb --- mephisto-0.7.3/app/apis/meta_weblog_api.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/meta_weblog_api.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,31 +0,0 @@ -class MetaWeblogApi < ActionWebService::API::Base - inflect_names false - - api_method :getCategories, - :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string} ], - :returns => [[:string]] - - api_method :getPost, - :expects => [ {:postid => :string}, {:username => :string}, {:password => :string} ], - :returns => [MetaWeblogStructs::Article] - - api_method :getRecentPosts, - :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string}, {:numberOfPosts => :int} ], - :returns => [[MetaWeblogStructs::Article]] - - api_method :deletePost, - :expects => [ {:appkey => :string}, {:postid => :string}, {:username => :string}, {:password => :string}, {:publish => :int} ], - :returns => [:bool] - - api_method :editPost, - :expects => [ {:postid => :string}, {:username => :string}, {:password => :string}, {:struct => MetaWeblogStructs::Article}, {:publish => :int} ], - :returns => [:bool] - - api_method :newPost, - :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string}, {:struct => MetaWeblogStructs::Article}, {:publish => :int} ], - :returns => [:string] - - api_method :newMediaObject, - :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string}, {:data => MetaWeblogStructs::MediaObject} ], - :returns => [MetaWeblogStructs::Url] -end \ No newline at end of file diff -Nur mephisto-0.7.3/app/apis/meta_weblog_service.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/meta_weblog_service.rb --- mephisto-0.7.3/app/apis/meta_weblog_service.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/meta_weblog_service.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,91 +0,0 @@ -class MetaWeblogService < XmlRpcService - web_service_api MetaWeblogApi - before_invocation :authenticate - - def getCategories(blogid, username, password) - site.sections.find(:all, :order => 'id ASC').collect &:name - end - - def getPost(postid, username, password) - article = @user.articles.find(postid) - article_dto_from(article) - end - - def getRecentPosts(blogid, username, password, numberOfPosts) - @user.articles.find(:all, :order => "created_at DESC", :limit => numberOfPosts).collect{ |c| article_dto_from(c) } - end - - def newPost(blogid, username, password, struct, publish) - article = @user.articles.build :site => site - post_it(article, username, password, struct, publish) - end - - def editPost(postid, username, password, struct, publish) - article = @user.articles.find(postid) - post_it(article, username, password, struct, publish) - true - end - - def deletePost(appkey, postid, username, password, publish) - article = @user.articles.find(postid) - article.destroy - true - end - - def newMediaObject(blogid, username, password, data) - asset = site.assets.create!( - :filename => data['name'], - :content_type => (data['type'] || guess_content_type_from(data['name'])), - :attachment_data => data['bits'] - ) - MetaWeblogStructs::Url.new("url" => asset.public_filename) - end - - def article_dto_from(article) - MetaWeblogStructs::Article.new( - :description => article.body, - :title => article.title, - :postid => article.id.to_s, - :url => article_url(article).to_s, - :link => article_url(article).to_s, - :permaLink => article.permalink.to_s, - :categories => article.sections.collect { |c| c.name }, - :mt_text_more => article.body.to_s, - :mt_excerpt => article.excerpt.to_s, - :mt_keywords => article.tag, - # :mt_allow_comments => article.allow_comments? ? 1 : 0, - # :mt_allow_pings => article.allow_pings? ? 1 : 0, - # :mt_convert_breaks => (article.text_filter.name.to_s rescue ''), - # :mt_tb_ping_urls => article.pings.collect { |p| p.url }, - :dateCreated => (article.published_at rescue "") - ) - end - - protected - def article_url(article) - article.published? && article.full_permalink - end - - def post_it(article, user, password, struct, publish) - # make sure publish is true if it's 1 if not leave it the way it is. - publish = publish == 1 || publish - # if no categories are supplied do not attempt to set any. - article.section_ids = Section.find(:all, :conditions => ['name IN (?)', struct['categories']]).collect(&:id) if struct['categories'] - article.attributes = {:updater => @user, :body => struct['description'].to_s, :title => struct['title'].to_s, :excerpt => struct['mt_excerpt'].to_s} - # Keywords/Tags support - Tagging.set_on article, struct['mt_keywords'] if struct['mt_keywords'] # set/modify keywords _only_ if they are supplied. mt_keywords _overwrite_ not alter the ``tags'' - - utc_date = Time.utc(struct['dateCreated'].year, struct['dateCreated'].month, struct['dateCreated'].day, struct['dateCreated'].hour, struct['dateCreated'].sec, struct['dateCreated'].min) rescue article.published_at || Time.now.utc - article.published_at = publish == true ? utc_date : nil - article.save! - article.id - end - - def guess_content_type_from(name) - if name =~ /(png|gif|jpe?g)/i - "image/#{$1 == 'jpg' ? 'jpeg' : $1}" - else - 'application/octet-stream' - end - end -end diff -Nur mephisto-0.7.3/app/apis/meta_weblog_structs/article.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/meta_weblog_structs/article.rb --- mephisto-0.7.3/app/apis/meta_weblog_structs/article.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/meta_weblog_structs/article.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,19 +0,0 @@ -module MetaWeblogStructs - class Article < ActionWebService::Struct - member :description, :string - member :title, :string - member :postid, :string - member :url, :string - member :link, :string - member :permaLink, :string - member :categories, [:string] - member :mt_text_more, :string - member :mt_excerpt, :string - member :mt_keywords, :string - member :mt_allow_comments, :int - member :mt_allow_pings, :int - member :mt_convert_breaks, :string - member :mt_tb_ping_urls, [:string] - member :dateCreated, :time - end -end \ No newline at end of file diff -Nur mephisto-0.7.3/app/apis/meta_weblog_structs/media_object.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/meta_weblog_structs/media_object.rb --- mephisto-0.7.3/app/apis/meta_weblog_structs/media_object.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/meta_weblog_structs/media_object.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,7 +0,0 @@ -module MetaWeblogStructs - class MediaObject < ActionWebService::Struct - member :bits, :string - member :name, :string - member :type, :string - end -end \ No newline at end of file diff -Nur mephisto-0.7.3/app/apis/meta_weblog_structs/url.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/meta_weblog_structs/url.rb --- mephisto-0.7.3/app/apis/meta_weblog_structs/url.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/meta_weblog_structs/url.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,5 +0,0 @@ -module MetaWeblogStructs - class Url < ActionWebService::Struct - member :url, :string - end -end \ No newline at end of file diff -Nur mephisto-0.7.3/app/apis/movable_type_api.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_api.rb --- mephisto-0.7.3/app/apis/movable_type_api.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_api.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,88 +0,0 @@ -class MovableTypeApi < ActionWebService::API::Base - inflect_names false - - # Movable Type Programatic interface - # see: - # supportedTextFilters has already been there! - # - Moritz Angermann - # - # mt.getRecentPostTitles - # Description: Returns a bandwidth-friendly list of the most recent posts in the system. - # Parameters: String blogid, String username, String password, int numberOfPosts - # Return value: on success, array of structs containing ISO.8601 dateCreated, String userid, String postid, String title; on failure, fault - # Notes: dateCreated is in the timezone of the weblog blogid - # Reference: - - #api_method :getRecentPostTitles, - # :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string}, {:numberOfPosts => :int} ], - # :returns => [[MovableTypeStructs::Post]] - - # mt.getCategoryList - # Description: Returns a list of all categories defined in the weblog. - # Parameters: String blogid, String username, String password - # Return value: on success, an array of structs containing String categoryId and String categoryName; on failure, fault. - # Reference: - api_method :getCategoryList, - :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string} ], - :returns => [[MovableTypeStructs::Category]] - - # mt.getPostCategories - # Description: Returns a list of all categories to which the post is assigned. - # Parameters: String postid, String username, String password - # Return value: on success, an array of structs containing String categoryName, String categoryId, and boolean isPrimary; on failure, fault. - # Notes: isPrimary denotes whether a category is the post's primary category. - # Reference: - api_method :getPostCategories, - :expects => [ {:postid => :string}, {:username => :string}, {:password => :string} ], - :returns => [[MovableTypeStructs::Category]] - - # mt.setPostCategories - # Description: Sets the categories for a post. - # Parameters: String postid, String username, String password, array categories - # Return value: on success, boolean true value; on failure, fault - # Notes: the array categories is an array of structs containing String categoryId and boolean isPrimary. Using isPrimary to set the primary category is optional--in the absence of this flag, the first struct in the array will be assigned the primary category for the post. - # Reference: - api_method :setPostCategories, - :expects => [ {:postid => :string}, {:username => :string}, {:password => :string}, {:categories => [MovableTypeStructs::PostCategory]} ], - :returns => [:bool] - - # mt.supportedMethods - # Description: Retrieve information about the XML-RPC methods supported by the server. - # Parameters: none - # Return value: an array of method names supported by the server. - # Reference: - - api_method :supportedMethods, - :expects => [], - :returns => [[:string]] - - # mt.supportedTextFilters - # Description: Retrieve information about the text formatting plugins supported by the server. - # Parameters: none - # Return value: an array of structs containing String key and String label. key is the unique string identifying a text formatting plugin, and label is the readable description to be displayed to a user. key is the value that should be passed in the mt_convert_breaks parameter to newPost and editPost. - # Reference: - - api_method :supportedTextFilters, - :expects => [], - :returns => [[MovableTypeStructs::TextFilter]] - - # mt.getTrackbackPings - # Description: Retrieve the list of TrackBack pings posted to a particular entry. This could be used to programmatically retrieve the list of pings for a particular entry, then iterate through each of those pings doing the same, until one has built up a graph of the web of entries referencing one another on a particular topic. - # Parameters: String postid - # Return value: an array of structs containing String pingTitle (the title of the entry sent in the ping), String pingURL (the URL of the entry), and String pingIP (the IP address of the host that sent the ping). - # Reference: - - # api_method :getTrackbackPings, - # :expects => [ {:postid => :string} ], - # :returns => [[MovableTypeStructs::Trackback]] - - # mt.publishPost - # Description: Publish (rebuild) all of the static files related to an entry from your weblog. Equivalent to saving an entry in the system (but without the ping). - # Parameters: String postid, String username, String password - # Returns value: on success, boolean true value; on failure, fault - # Reference: - - #api_method :publishPost, - # :expects => [ {:postid => :string}, {:username => :string}, {:password => :string} ], - # :returns => [:bool] -end diff -Nur mephisto-0.7.3/app/apis/movable_type_service.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_service.rb --- mephisto-0.7.3/app/apis/movable_type_service.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_service.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,44 +0,0 @@ -class MovableTypeService < XmlRpcService - web_service_api MovableTypeApi - before_invocation :authenticate, :except => [:supportedMethods, :supportedTextFilters] - - #def getRecentPostTitles(blogid, username, password, numberOfPosts) - # # FIXME not implemented - #end - - def getCategoryList(blogid, username, password) - site.sections.find(:all, :order => 'id ASC').collect { |c| MovableTypeStructs::Category.new(:categoryId => c.id, :categoryName => c.name) } - end - - def getPostCategories(postid, username, password) - article = @user.articles.find(postid) - article.sections.collect { |c| MovableTypeStructs::Category.new(:categoryId => c.id, :categoryName => c.name) } - end - - def setPostCategories(postid, username, password, categories) - article = @user.articles.find(postid) - article.section_ids= categories.collect { |c| c.categoryId } - article.save! - true - end - - def supportedMethods - MetaWeblogService.public_instance_methods(false).collect { |m| "metaWeblog.{#m}" } \ - + MovableTypeService.public_instance_methods(false).collect { |m| "mt.{#m}" } - end - - def supportedTextFilters - FilteredColumn.filters.collect { |(key, filter)| MovableTypeStructs::TextFilter.new(:key => key, :label => filter.filter_name) } - end - - # def getTrackbackPings, - # ... - # end - - #def publishPost(postid, username, password) - # article = @user.articles.find(postid) - # #article. hmmm now what? - # true - #end - -end diff -Nur mephisto-0.7.3/app/apis/movable_type_structs/category.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_structs/category.rb --- mephisto-0.7.3/app/apis/movable_type_structs/category.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_structs/category.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,12 +0,0 @@ -module MovableTypeStructs - class Category < ActionWebService::Struct - member :categoryId, :string - member :categoryName, :string - end -end -module MovableTypeStructs - class Category < ActionWebService::Struct - member :categoryId, :string - member :categoryName, :string - end -end diff -Nur mephisto-0.7.3/app/apis/movable_type_structs/post.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_structs/post.rb --- mephisto-0.7.3/app/apis/movable_type_structs/post.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_structs/post.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,16 +0,0 @@ -module MovableTypeStructs - class Post < ActionWebService::Struct - member :dateCreated, :time #ISO.8601 - member :userid, :string - member :postid, :string - member :title, :string - end -end -module MovableTypeStructs - class Post < ActionWebService::Struct - member :dateCreated, :time #ISO.8601 - member :userid, :string - member :postid, :string - member :title, :string - end -end diff -Nur mephisto-0.7.3/app/apis/movable_type_structs/post_category.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_structs/post_category.rb --- mephisto-0.7.3/app/apis/movable_type_structs/post_category.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_structs/post_category.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,14 +0,0 @@ -module MovableTypeStructs - class PostCategory < ActionWebService::Struct - member :categoryId, :string - member :categoryName, :string - member :isPrimary, :bool - end -end -module MovableTypeStructs - class PostCategory < ActionWebService::Struct - member :categoryId, :string - member :categoryName, :string - member :isPrimary, :bool - end -end diff -Nur mephisto-0.7.3/app/apis/movable_type_structs/text_filter.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_structs/text_filter.rb --- mephisto-0.7.3/app/apis/movable_type_structs/text_filter.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_structs/text_filter.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,6 +0,0 @@ -module MovableTypeStructs - class TextFilter < ActionWebService::Struct - member :key, :string - member :label, :string - end -end \ No newline at end of file diff -Nur mephisto-0.7.3/app/apis/movable_type_structs/trackback.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_structs/trackback.rb --- mephisto-0.7.3/app/apis/movable_type_structs/trackback.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/movable_type_structs/trackback.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,7 +0,0 @@ -module MovableTypeStructs - class Trackback < ActionWebService::Struct - member :pingTitle, :string - member :pingURL, :string - member :pingIP, :string - end -end \ No newline at end of file diff -Nur mephisto-0.7.3/app/apis/xml_rpc_service.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/xml_rpc_service.rb --- mephisto-0.7.3/app/apis/xml_rpc_service.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/apis/xml_rpc_service.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,30 +0,0 @@ -class XmlRpcService < ActionWebService::Base - attr_accessor :controller - delegate :site, :to => :controller - - def initialize(controller) - @controller = controller - end - - protected - def server_url - controller.url_for(:only_path => false, :controller => "/") - end - - def pub_date(time) - time.strftime "%a, %e %b %Y %H:%M:%S %Z" - end - - def authenticate(name, args) - method = self.class.web_service_api.api_methods[name] - - # Coping with backwards incompatibility change in AWS releases post 0.6.2 - begin - h = method.expects_to_hash(args) - raise "Invalid login" unless @user = User.authenticate_for(controller.site, h[:username], h[:password]) - rescue NoMethodError - username, password = method[:expects].index(:username=>String), method[:expects].index(:password=>String) - raise "Invalid login" unless @user = User.authenticate_for(controller.site, args[username], args[password]) - end - end -end \ No newline at end of file diff -Nur mephisto-0.7.3/app/cachers/article_observer.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/cachers/article_observer.rb --- mephisto-0.7.3/app/cachers/article_observer.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/cachers/article_observer.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,10 +1,12 @@ class ArticleObserver < ActiveRecord::Observer def before_save(record) - @event = Event.new - @event.mode = case - when record.is_a?(Comment) then 'comment' - when record.new_record? then 'publish' - else 'edit' + if (record.is_a?(Article) && record.save_version?) || record.is_a?(Comment) + @event = Event.new + @event.mode = case + when record.is_a?(Comment) then 'comment' + when record.new_record? then 'publish' + else 'edit' + end end end @@ -15,4 +17,4 @@ end alias after_destroy after_save -end \ No newline at end of file +end diff -Nur mephisto-0.7.3/app/cachers/comment_observer.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/cachers/comment_observer.rb --- mephisto-0.7.3/app/cachers/comment_observer.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/cachers/comment_observer.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,8 +1,15 @@ class CommentObserver < ArticleObserver - cattr_accessor :disabled + def self.disabled? + Thread.current[:comment_observer_disabled] + end + + def disabled=(value) + Thread.current[:comment_observer_disabled] = value + end + def after_save(record) @event.update_attributes :title => record.article.title, :body => record.body, :site => record.article.site, - :article => record.article, :author => record.author, :comment => record if record.approved? && !disabled + :article => record.article, :author => record.author, :comment => record if record.approved? && !self.class.disabled? end def after_destroy(record) diff -Nur mephisto-0.7.3/app/controllers/admin/articles_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/articles_controller.rb --- mephisto-0.7.3/app/controllers/admin/articles_controller.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/articles_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -3,21 +3,18 @@ with_options :only => [:create, :update, :destroy, :upload] do |c| c.before_filter :set_default_section_ids c.cache_sweeper :article_sweeper, :assigned_section_sweeper - cache_sweeper :comment_sweeper, :only => [:approve, :unapprove, :destroy_comment] end before_filter :convert_times_to_utc, :only => [:create, :update, :upload] before_filter :check_for_new_draft, :only => [:create, :update, :upload] - before_filter :find_site_article, :only => [:edit, :update, :comments, :approve, :unapprove, :destroy] + before_filter :find_site_article, :only => [:edit, :update, :comments, :approve, :unapprove, :destroy, :attach, :detach] before_filter :login_required, :except => :upload before_filter :load_sections, :only => [:new, :edit] def index - @article_pages = Paginator.new self, site.articles.count(:all, article_options), 30, params[:page] - @articles = site.articles.find(:all, article_options(:order => 'contents.published_at DESC', :select => 'contents.*', - :limit => @article_pages.items_per_page, - :offset => @article_pages.current.offset)) + @articles = site.articles.paginate(article_options(:order => 'contents.published_at DESC', :select => 'contents.*', + :page => params[:page], :per_page => params[:per_page])) @comments = @site.unapproved_comments.count :all, :group => :article, :order => '1 desc' @sections = site.sections.find(:all) @@ -29,7 +26,7 @@ Mephisto::Liquid::CommentForm.article = @article @article = @article.to_liquid(:mode => :single) - render :text => site.render_liquid_for(site.sections.home, :single, 'articles' => [@article], 'article' => @article, 'comments' => @comments, 'site' => site.to_liquid) + render :text => site.call_render(site.sections.home, :single, 'articles' => [@article], 'article' => @article, 'comments' => @comments, 'site' => site.to_liquid) end def new @@ -65,38 +62,14 @@ def destroy @article.destroy + flash[:notice] = "The article: #{@article.title.inspect} was deleted." render :update do |page| page.redirect_to :action => 'index' end end def comments - @comments = - case params[:filter] - when 'approved' then :comments - when 'unapproved' then :unapproved_comments - else :all_comments - end - @comments = @article.send @comments - @articles = @site.unapproved_comments.count :all, :group => :article, :order => '1 desc' - end - - # xhr baby - # needs some restful lovin' - def approve - @comment = @article.unapproved_comments.approve(params[:comment]) - @comment.mark_as_ham(site, request) - end - - def unapprove - @comment = @article.comments.unapprove(params[:comment]) - @comment.mark_as_spam(site, request) - render :action => 'approve' - end - - def destroy_comment - @comments = site.all_comments.find :all, :conditions => ['id in (?)', [params[:comment]].flatten] rescue [] - Comment.transaction { @comments.each(&:destroy) } if @comments.any? + redirect_to article_comments_path(@article) end def upload @@ -117,9 +90,28 @@ end end + def attach + @asset = site.assets.find(params[:version]) + @article.assets.add @asset + end + + def detach + @asset = site.assets.find(params[:version]) + @article.assets.remove @asset + end + + def label + AssignedAsset.update_all ['label = ?', params[:label]], ['article_id = ? and asset_id = ?', params[:id], params[:version]] + end + protected def load_sections - @assets = site.assets.find(:all, :order => 'created_at desc', :limit => 6) + @assets = site.assets.find(:all, :limit => 15) + @bucket_assets = [] + session[:bucket].each do |id, values| + (@bucket_assets ||= []) << site.assets.find(id) + end unless session[:bucket].blank? + @sections = site.sections.find(:all) home = @sections.find &:home? @sections.delete home diff -Nur mephisto-0.7.3/app/controllers/admin/assets_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/assets_controller.rb --- mephisto-0.7.3/app/controllers/admin/assets_controller.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/assets_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -29,8 +29,14 @@ end Asset.transaction { @assets.each &:save! } flash[:notice] = @assets.size == 1 ? "'#{CGI.escapeHTML @assets.first.title}' was uploaded." : "#{@assets.size} assets were uploaded." - @assets.size.zero? ? render(:action => 'new') : redirect_to(assets_path) - rescue ActiveRecord::RecordInvalid + if @assets.size.zero? + @asset = Asset.new + render :action => 'new' + else + redirect_to assets_path + end + rescue ActiveRecord::RecordInvalid => e + @asset = e.record render :action => 'new' end @@ -45,7 +51,7 @@ def latest @assets = site.assets.find(:all, :order => 'created_at desc', :limit => 6) render :update do |page| - page['latest-assets'].replace_html :partial => 'widget', :collection => @assets + page['latest-assets'].replace_html :partial => 'widget', :collection => @assets, :locals => { :prefix => 'latest' } end end @@ -53,7 +59,7 @@ search_assets 6 render :update do |page| page['spinner'].hide - return page['search-assets'].replace_html(:partial => 'widget', :collection => @assets) if @assets.any? + return page['search-assets'].replace_html(:partial => 'widget', :collection => @assets, :locals => { :prefix => 'search' }) if @assets.any? page['search-assets'].replace_html %(Couldn't find any matching assets.) end end @@ -67,11 +73,11 @@ # rjs def add_bucket - if (session[:bucket] ||= {}).key?(@asset.public_filename) + if (session[:bucket] ||= {}).key?(@asset.id) render :nothing => true and return end args = asset_image_args_for(@asset, :tiny, :title => "#{@asset.title} \n #{@asset.tags.join(', ')}") - session[:bucket][@asset.public_filename] = args + session[:bucket][@asset.id] = args end def clear_bucket @@ -85,14 +91,15 @@ def search_assets(limit) @types = params[:filter].blank? ? [] : params[:filter].keys - @asset_pages = Paginator.new self, count_by_conditions, limit, params[:page] + options = search_options.merge(:per_page => limit, :page => params[:page], :total_entries => count_by_conditions) + @assets = @types.any? ? - site.assets.find_all_by_content_types(@types, :all, search_options) : - site.assets.find(:all, search_options) + site.assets.paginate_by_content_types(@types, :all, options) : + site.assets.paginate(options) end def search_options - search_conditions.merge(:order => 'created_at desc', :limit => @asset_pages.items_per_page, :offset => @asset_pages.current.offset) + search_conditions.merge(:order => 'created_at desc') end def search_conditions diff -Nur mephisto-0.7.3/app/controllers/admin/cached_pages_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/cached_pages_controller.rb --- mephisto-0.7.3/app/controllers/admin/cached_pages_controller.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/cached_pages_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -3,10 +3,9 @@ def index CachedPage.with_current_scope do - @cached_page_pages = Paginator.new self, site.cached_pages.count, 30, params[:page] - offset = (((params[:page] || 1).to_i - 1) * @cached_page_pages.items_per_page) - @cached_pages = site.cached_pages.find(:all, :order => 'updated_at', :limit => @cached_page_pages.items_per_page, :offset => offset, - :conditions => (params[:query] && ['url LIKE ?', ["#{params[:query]}%"]])) + @cached_pages = site.cached_pages.paginate(:order => 'updated_at', + :conditions => (params[:query] && ['url LIKE ?', ["#{params[:query]}%"]]), + :page => params[:page]) end end alias_method :query, :index @@ -25,4 +24,4 @@ protected alias authorized? admin? -end \ No newline at end of file +end diff -Nur mephisto-0.7.3/app/controllers/admin/comments_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/comments_controller.rb --- mephisto-0.7.3/app/controllers/admin/comments_controller.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/comments_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,6 +1,75 @@ class Admin::CommentsController < Admin::BaseController + + member_actions.push(*%w(index unapproved create edit update approve unapprove destroy close )) + +private + + before_filter :find_site_article, :except => [ :close, :index, :destroy ] + before_filter :find_optional_site_article, :only => [:index, :destroy] + def find_site_article + @article = site.articles.find params[:article_id] + end + + def find_optional_site_article + @article = site.articles.find params[:article_id] unless params[:article_id].blank? + end + + cache_sweeper :comment_sweeper, :only => [:approve, :unapprove, :destroy, :create] + +public + def index - @comments = site.unapproved_comments.find(:all, :include => :article) + @comment = Comment.new + @articles = site.unapproved_comments.count :all, :group => :article, :order => '1 desc' + params[:filter] = 'unapproved' if @article.nil? + @comments = + (@article || @site).send case params[:filter] + when 'approved' then :comments + when 'unapproved' then :unapproved_comments + else :all_comments + end + end + + def unapproved + site.unapproved_comments.find(:all, :include => :article) + end + + def create + @comment = @article.comments.build(params[:comment].merge( + :user_id => session[:user], + :author_ip => request.remote_ip, + :user_agent => request.env['HTTP_USER_AGENT'], + :referrer => request.env['HTTP_REFERER']) + ) + @comment.approved = true + @comment.save + end + + def edit + @comment = @article.all_comments.find params[:id] + end + + def update + @comment = @article.all_comments.find params[:id] + @comment.update_attributes(params[:comment]) + end + + # xhr baby + # needs some restful lovin' + def approve + @comment = @article.unapproved_comments.approve(params[:comment] || params[:id]) + @comment.mark_as_ham(site, request) + end + + def unapprove + @comment = @article.comments.unapprove(params[:comment] || params[:id]) + @comment.mark_as_spam(site, request) + render :action => 'approve' + end + + def destroy + @comments = site.all_comments.find :all, :conditions => ['id in (?)', [ (params[:comment] || params[:id])].flatten] # rescue [] + Comment.transaction { @comments.each(&:destroy) } if @comments.any? end # ajax action, called from _page_nav diff -Nur mephisto-0.7.3/app/controllers/admin/overview_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/overview_controller.rb --- mephisto-0.7.3/app/controllers/admin/overview_controller.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/overview_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -9,10 +9,10 @@ def index @users = site.users(:order => 'updated_at desc') @events, @todays_events, @yesterdays_events = [], [], [] - today, yesterday = Time.now.utc.to_date, 1.day.ago.utc.to_date + today, yesterday = utc_to_local(Time.now.utc).to_date, utc_to_local(1.day.ago.utc).to_date @articles = @site.unapproved_comments.count :all, :group => :article, :order => '1 desc' @site.events.find(:all, :order => 'events.created_at DESC', :include => [:article, :user], :limit => 50).each do |event| - event_date = event.created_at.to_date + event_date = utc_to_local(event.created_at).to_date if event_date >= today @todays_events elsif event_date == yesterday diff -Nur mephisto-0.7.3/app/controllers/admin/plugins_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/plugins_controller.rb --- mephisto-0.7.3/app/controllers/admin/plugins_controller.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/plugins_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,24 @@ +class Admin::PluginsController < Admin::BaseController + before_filter :find_plugin, :except => :index + + def index + @plugins = Mephisto.plugins + end + + def update + @plugin.options = params[:options] + @plugin.save! + + redirect_to :action => "show", :id => params[:id] + end + + def destroy + @plugin.destroy + redirect_to :action => "show", :id => params[:id] + end + + protected + def find_plugin + @plugin = Mephisto.plugins[params[:id]] + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/app/controllers/admin/settings_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/settings_controller.rb --- mephisto-0.7.3/app/controllers/admin/settings_controller.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/settings_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,6 +1,6 @@ class Admin::SettingsController < Admin::BaseController before_filter :find_and_sort_templates - clear_empty_templates_for :site, :search_layout, :tag_layout, :only => :update + clear_empty_templates_for :site, :tag_layout, :only => :update def update if site.update_attributes params[:site] diff -Nur mephisto-0.7.3/app/controllers/admin/sites_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/sites_controller.rb --- mephisto-0.7.3/app/controllers/admin/sites_controller.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/sites_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,62 @@ +class Admin::SitesController < Admin::BaseController + + before_filter :admin_required + member_actions.push *%W(index show new destroy create) + + def index + @sites = Site.search_by_host_or_title params[:search_string] do + Site.paginate(:page => params[:page], :per_page => params[:per_page], :order => 'id') + end + end + + def show + @site = Site.find(params[:id]) + end + + def new + @site = Site.new + end + + def create + @site = Site.new(params[:site]) + if @site.save + flash[:notice] = "Site #{@site.host} was successfully created." + redirect_to :action => 'index' + else + flash[:error] = "Failed to create site." + render :action => "new" + end + end + + def update + @site = Site.find(params[:id]) + if @site.update_attributes(params[:site]) + flash[:notice] = "Site #{@site.host} was successfully updated." + redirect_to :action => 'show', :id => @site + else + render :action => 'show' + end + end + + def destroy + @site = Site.find(params[:id]) + if @site.destroy + flash[:notice] = "Site removed." + redirect_to :action => 'index' + else + flash[:error] = "Failed to remove site #{@site.host}. Check file permissions." + render :action => 'show' + end + end + + private + def admin_required + current_user.admin? ? true : not_allowed + end + + def not_allowed + flash[:error] = "Only global administrators can manage sites." + redirect_to :controller => "/account", :action => :login + end + +end diff -Nur mephisto-0.7.3/app/controllers/admin/templates_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/templates_controller.rb --- mephisto-0.7.3/app/controllers/admin/templates_controller.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/templates_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -28,7 +28,7 @@ if !@tmpl.file? page.flash.errors "File does not exist" page.visual_effect :fade, params[:context], :duration => 0.3 - elsif @theme.templates.custom.include?(@tmpl.basename.to_s) + elsif @theme.templates.custom(@theme.extension).include?(@tmpl.basename.to_s) @tmpl.unlink page.visual_effect :fade, params[:context], :duration => 0.3 else diff -Nur mephisto-0.7.3/app/controllers/admin/users_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/users_controller.rb --- mephisto-0.7.3/app/controllers/admin/users_controller.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/admin/users_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -34,19 +34,20 @@ end def destroy - @user.deleted_at = Time.now.utc - @user.save! + if @user == current_user then return @error = "Cannot delete yourself." end + if @user.admin? then return @error = "Cannot delete a Mephisto administrator." end + @allowed = @user.update_attribute :deleted_at, Time.now.utc end def enable - @user.deleted_at = nil - @user.save! + @allowed = @user.update_attribute :deleted_at, nil end def admin + if @user == current_user then return @error = "Cannot toggle admin permissions for yourself." end + if @user.admin? then return @error = "Cannot toggle admin permissions for a Mephisto administrator." end @membership = Membership.find_or_initialize_by_site_id_and_user_id(site.id, @user.id) - @membership.admin = !@membership.admin? - @membership.save! + @allowed = @membership.update_attribute :admin, !@membership.admin? end protected diff -Nur mephisto-0.7.3/app/controllers/application/errors.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/application/errors.rb --- mephisto-0.7.3/app/controllers/application/errors.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/application/errors.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,37 @@ +# Custom handlers for exceptions are defined here. +class ApplicationController + + protected + + # Handle public-facing errors by rendering the "error" liquid template + def show_404 + show_error 'Page Not Found', :not_found + end + + def show_error(message = 'An error occurred.', status = :internal_server_error) + render_liquid_template_for(:error, 'message' => message, :status => status) + end + + # Handle admin-application errors + # TODO: after rails 2.0.2, convert these to rescue_from [array] rather than 3 lines. + rescue_from ActiveRecord::RecordNotFound, :with => :render_admin_not_found + rescue_from ActionController::UnknownController, :with => :render_admin_not_found + rescue_from ActionController::UnknownAction, :with => :render_admin_not_found + + def render_admin_not_found + # TODO: render this from the site's custom admin 404 file, if it's a multi-site install. + render :file => File.join(RAILS_ROOT, 'public/404.html'), :status => :not_found + end + + def render_admin_error + # TODO: render this from the site's custom 500 file, if it's a multi-site install + render :file => File.join(RAILS_ROOT, 'public/500.html'), :status => :internal_server_error + end + + def rescue_action_in_public(exception) + logger.debug "#{exception.class.name}: #{exception.to_s}" + exception.backtrace.each { |t| logger.debug " > #{t}" } + render_admin_error + end + +end \ No newline at end of file diff -Nur mephisto-0.7.3/app/controllers/application.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/application.rb --- mephisto-0.7.3/app/controllers/application.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/application.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,20 +1,36 @@ class ApplicationController < ActionController::Base + require_dependency 'application/errors' + include Mephisto::CachingMethods - cattr_accessor :site_count before_filter :set_cache_root helper_method :site attr_reader :site + + auto_include! + + def self.inherited(klass) + super + klass.auto_include! + end + + filter_parameter_logging "password" protected helper_method :admin? + helper_method :global_admin? def admin? logged_in? && (current_user.admin? || current_user.site_admin?) end + def global_admin? + logged_in? && current_user.admin? + end + # so not the best place for this... def asset_image_args_for(asset, thumbnail = :tiny, options = {}) - options = options.reverse_merge(:title => "#{asset.title} \n #{asset.tags.join(', ')}") + thumb_size = Array.new(2).fill(Asset.attachment_options[:thumbnails][thumbnail].to_i).join('x') + options = options.reverse_merge(:title => "#{asset.title} \n #{asset.tags.join(', ')}", :size => thumb_size) if asset.movie? ['/images/mephisto/icons/video.png', options] elsif asset.audio? @@ -24,7 +40,7 @@ elsif asset.other? ['/images/mephisto/icons/doc.png', options] elsif asset.thumbnails_count.zero? - [asset.public_filename, options.update(:size => Array.new(2).fill(Asset.attachment_options[:thumbnails][thumbnail].to_i).join('x'))] + [asset.public_filename, options] else [asset.public_filename(thumbnail), options] end @@ -44,22 +60,14 @@ # use collect so it doesn't modify @articles assigns['articles'] = assigns['articles'].collect &:to_liquid end - status = (assigns.delete(:status) || '200 OK') + status = (assigns.delete(:status) || :ok) @liquid_assigns = assigns - render :text => site.render_liquid_for(@section, template_type, assigns, self), :status => status - end - - def show_error(message = 'An error occurred.', status = '500 Error') - render_liquid_template_for(:error, 'message' => message, :status => status) - end - - def show_404 - show_error 'Page Not Found', '404 NotFound' + render :text => site.call_render(@section, template_type, assigns, self), :status => status end def set_cache_root host = request.domain(request.subdomains.size + (request.subdomains.first == 'www' ? 0 : 1)) - @site ||= Site.find_by_host(host) || Site.find(:first, :order => 'id') + @site ||= Site.find_by_host(host) || Site.find(:first, :order => 'id') || raise(ActiveRecord::RecordNotFound, "You need to create your first site!") self.class.page_cache_directory = site.page_cache_directory.to_s end @@ -69,15 +77,5 @@ yield ENV['TZ'] = old_tz end - - def rescue_action_in_public(exception) - logger.debug "#{exception.class.name}: #{exception.to_s}" - exception.backtrace.each { |t| logger.debug " > #{t}" } - case exception - when ActiveRecord::RecordNotFound, ::ActionController::UnknownController, ::ActionController::UnknownAction - render :file => File.join(RAILS_ROOT, 'public/404.html'), :status => '404 Not Found' - else - render :file => File.join(RAILS_ROOT, 'public/500.html'), :status => '500 Error' - end - end + end diff -Nur mephisto-0.7.3/app/controllers/backend_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/backend_controller.rb --- mephisto-0.7.3/app/controllers/backend_controller.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/backend_controller.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,13 +0,0 @@ -require 'meta_weblog_api' -require 'movable_type_api' -class BackendController < ApplicationController - session :off - - web_service_dispatching_mode :layered - web_service(:metaWeblog) { MetaWeblogService.new(self) } - web_service(:mt) { MovableTypeService.new(self) } - - alias xmlrpc api - - cache_sweeper :article_sweeper, :assigned_section_sweeper, :comment_sweeper -end diff -Nur mephisto-0.7.3/app/controllers/feed_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/feed_controller.rb --- mephisto-0.7.3/app/controllers/feed_controller.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/feed_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -36,7 +36,6 @@ def comment_feed_for_site @comments = site.comments.find(:all, :limit => 15, :include => :article) - cached_references << @section self.cached_references += @comments self.cached_references += @comments.collect(&:article_referenced_cache_key) end diff -Nur mephisto-0.7.3/app/controllers/mephisto_controller.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/mephisto_controller.rb --- mephisto-0.7.3/app/controllers/mephisto_controller.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/controllers/mephisto_controller.rb 2008-03-31 02:18:56.000000000 -0400 @@ -18,7 +18,7 @@ # @dispatch_path.first has the headers if @dispatch_path.first.is_a?(Hash) response.headers['Status'] = interpret_status @section - redirect_to @dispatch_path.first[:location] + redirect_to @dispatch_path.first[:location], :status=>301 else head @section end @@ -31,21 +31,23 @@ end def dispatch_page - @article = @dispatch_path.empty? ? @section.articles.find_by_position : @section.articles.find_by_permalink(@dispatch_path.first) + Article.with_published do + @article = @dispatch_path.empty? ? @section.articles.find_by_position : @section.articles.find_by_permalink(@dispatch_path.first) + end show_404 and return unless @article Mephisto::Liquid::CommentForm.article = @article render_liquid_template_for(:page, 'section' => @section.to_liquid(true), - 'article' => @article.to_liquid(:mode => :single)) + 'article' => @article.to_liquid(:mode => :single, :page => @dispatch_path.empty?)) end def dispatch_comments + @skip_caching = true show_404 and return unless find_article if !request.post? || params[:comment].blank? - @skip_caching = true redirect_to site.permalink_for(@article) and return end - @comment = @article.comments.build(params[:comment].merge(:author_ip => request.remote_ip, :user_agent => request.user_agent, :referrer => request.referer)) + @comment = @article.comments.build(params[:comment].merge(:user_id => session[:user], :author_ip => request.remote_ip, :user_agent => request.user_agent, :referrer => request.referer)) @comment.check_approval site, request if @comment.valid? @comment.save! redirect_to dispatch_path(:path => (site.permalink_for(@article)[1..-1].split('/') << 'comments' << @comment.id.to_s), :anchor => @comment.dom_id) @@ -53,9 +55,12 @@ show_article_with 'errors' => @comment.errors.full_messages, 'submitted' => params[:comment] rescue Article::CommentNotAllowed show_article_with 'errors' => ["Commenting has been disabled on this article"] + rescue Comment::Previewing + show_article_with 'errors' => ["Previewing your comment"], 'submitted' => params[:comment] end def dispatch_comment + @skip_caching = true show_article_with 'message' => 'Thanks for the comment!' end @@ -73,20 +78,25 @@ end def dispatch_search + @section = params[:s].nil? ? nil : site.sections.detect { |s| s.path == params[:s] } + joins = nil conditions = ['(published_at IS NOT NULL AND published_at <= :now) AND (title LIKE :q OR excerpt LIKE :q OR body LIKE :q)', { :now => Time.now.utc, :q => "%#{params[:q]}%" }] - search_count = site.articles.count(:all, :conditions => conditions) - @article_pages = Paginator.new self, search_count, site.articles_per_page, params[:page] - @articles = site.articles.find(:all, :conditions => conditions, :order => 'published_at DESC', - :include => [:user, :sections], - :limit => @article_pages.items_per_page, - :offset => @article_pages.current.offset) + if @section + conditions.first << ' AND (assigned_sections.section_id = :section)' + conditions.last[:section] = @section.id + end + + @articles = site.articles.paginate(:conditions => conditions, :order => 'published_at DESC', + :include => [:user, :sections], + :per_page => site.articles_per_page, :page => params[:page]) render_liquid_template_for(:search, 'articles' => @articles, - 'previous_page' => paged_search_url_for(@article_pages.current.previous), - 'next_page' => paged_search_url_for(@article_pages.current.next), - 'search_string' => params[:q], - 'search_count' => search_count) + 'previous_page' => paged_search_url_for(@articles.previous_page), + 'next_page' => paged_search_url_for(@articles.next_page), + 'search_string' => CGI::escapeHTML(params[:q]), + 'search_count' => @articles.total_entries, + 'section' => @section) @skip_caching = true end @@ -124,7 +134,7 @@ show_404 and return unless @article || find_article Mephisto::Liquid::CommentForm.article = @article @article = @article.to_liquid(:mode => :single) - render_liquid_template_for(:single, assigns.merge('articles' => [@article], 'article' => @article)) + render_liquid_template_for(:single, assigns.update('articles' => [@article], 'article' => @article)) end alias dispatch_single show_article_with end diff -Nur mephisto-0.7.3/app/drops/article_drop.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/drops/article_drop.rb --- mephisto-0.7.3/app/drops/article_drop.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/drops/article_drop.rb 2008-03-31 02:18:56.000000000 -0400 @@ -6,12 +6,12 @@ def initialize(source, options = {}) super source - @options = options + @options = options @liquid.update \ - 'body' => @source.body_html, - 'excerpt' => (@source.excerpt_html.nil? || @source.excerpt_html.empty? ? nil : @source.excerpt_html), - 'accept_comments' => @source.accept_comments?, - 'is_page_home' => (options[:page] == true) + 'body' => @source.body_html, + 'excerpt' => (@source.excerpt_html.blank? ? nil : @source.excerpt_html), + 'accept_comments' => @source.accept_comments?, + 'is_page_home' => (options[:page] == true) end def author @@ -19,12 +19,11 @@ end def comments - @comments ||= liquify(*@source.comments.reject(&:new_record?)) + @comments ||= liquify(*@source.comments) # .reject(&:new_record?) <-- show new comments as they're built as a preview end def sections - @sections ||= @source.sections.inject([]) { |all, s| s.home? ? all : all << s.to_liquid } # your days are numbered, home section! - @sections ||= liquify(*@source.sections) { |s| s.home? ? nil : s.to_liquid } + @sections ||= liquify(*@source.sections.reject(&:home?)) end def tags @@ -44,7 +43,7 @@ end def url - @url ||= absolute_url(@site.permalink_for(@source)) + @url ||= absolute_url(@site.permalink_for(@source)[1..-1]) end def comments_feed_url @@ -54,6 +53,10 @@ def changes_feed_url @changes_feed_url ||= url + '/changes.xml' end + + def assets + @assets ||= liquify(*@source.assets) + end protected def body_for_mode(mode) diff -Nur mephisto-0.7.3/app/drops/comment_drop.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/drops/comment_drop.rb --- mephisto-0.7.3/app/drops/comment_drop.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/drops/comment_drop.rb 2008-03-31 02:18:56.000000000 -0400 @@ -19,7 +19,22 @@ @url ||= absolute_url(@source.site.permalink_for(@source)) end + def new_record + @source.new_record? + end + def author_link - @source.author_url.blank? ? "#{CGI::escapeHTML(@source.author)}" : %Q{#{CGI::escapeHTML @source.author}} + @source.author_url.blank? ? "#{@source.author}" : %Q{#{@source.author}} + end + + def presentation_class + @presentation_class ||= case @source.user_id + when @source.article.user_id + "by-author" + when nil + "by-guest" + else + "by-user" + end end end \ No newline at end of file diff -Nur mephisto-0.7.3/app/filters/core_filters.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/filters/core_filters.rb --- mephisto-0.7.3/app/filters/core_filters.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/filters/core_filters.rb 2008-03-31 02:18:56.000000000 -0400 @@ -56,6 +56,10 @@ def assign_to_global(value, name) @context.scopes.last[name] = value ; nil end + + def contains(source, text) + !source[text].nil? + end protected def liquify(*records, &block) diff -Nur mephisto-0.7.3/app/filters/drop_filters.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/filters/drop_filters.rb --- mephisto-0.7.3/app/filters/drop_filters.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/filters/drop_filters.rb 2008-03-31 02:18:56.000000000 -0400 @@ -13,8 +13,12 @@ @context['site'].find_descendant_sections(path) end - def linked_section_list(article, seperator = ', ') - article.sections.collect {|s| link_to_section s }.join(seperator) + def linked_section_list(article, separator = ', ') + article.sections.collect {|s| link_to_section s }.join(separator) + end + + def linked_tag_list(article, separator = ', ') + article.tags.collect {|t| link_to_tag t }.join(separator) end def latest_articles(site_or_section, limit = nil) @@ -28,6 +32,22 @@ def latest_comments(site, limit = nil) site.latest_comments(limit || site['articles_per_page']) end + + def find_asset(article, label) + article.assets.detect { |a| a.source.label == label } + end + + def next_article(article, section=nil) + if nxt = article.source.next(section ? section.source : nil) + nxt.to_liquid.tap { |n| n.context = @context if n } + end + end + + def previous_article(article, section=nil) + if prev = article.source.previous(section ? section.source : nil) + prev.to_liquid.tap { |p| p.context = @context if p } + end + end def monthly_articles(section, date = nil) date = parse_date(date) @@ -38,11 +58,17 @@ liquify(*@context['site'].source.articles.find(:all, :include => :tags, :conditions => ['tags.name in (?)', Tag.parse(tags)], :order => 'contents.created_at desc')) end - def assets_by_type(type) - liquify(*@context['site'].source.assets.find_all_by_content_types([type.to_sym], :all, :order => 'created_at desc')) + def tagged_articles_in_section(tags, section) + liquify(*section.source.articles.find(:all, :include => :tags, :conditions => ['tags.name in (?)', Tag.parse(tags)], :order => 'contents.published_at desc')) + end + + def assets_by_type(type, drop = nil) + drop ||= @context['site'] + liquify(*drop.source.assets.find_all_by_content_types([type.to_sym], :all, :order => 'created_at desc')) end - def tagged_assets(tags) - liquify(*@context['site'].source.assets.find(:all, :include => :tags, :conditions => ['tags.name in (?)', Tag.parse(tags)], :order => 'assets.created_at desc')) + def tagged_assets(tags, drop = nil) + drop ||= @context['site'] + liquify(*drop.source.assets.find(:all, :include => :tags, :conditions => ['tags.name in (?)', Tag.parse(tags)], :order => 'assets.created_at desc')) end end \ No newline at end of file diff -Nur mephisto-0.7.3/app/filters/url_filters.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/filters/url_filters.rb --- mephisto-0.7.3/app/filters/url_filters.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/filters/url_filters.rb 2008-03-31 02:18:56.000000000 -0400 @@ -4,26 +4,43 @@ include ActionView::Helpers::TagHelper include ActionView::Helpers::AssetTagHelper - def link_to_article(article, text = nil) - content_tag :a, text || h(article['title']), :href => article['url'] + def link_to_article(article, *args) + options = link_args_to_options(args) + text = options.delete(:text) || h(article['title']) + content_tag :a, text, { :href => article['url'], :title => text }.merge(options) end - def link_to_page(page, section = nil, text = nil) - content_tag :a, text || h(page['title']), page_anchor_options(page, section) + def link_to_page(page, section = nil, *args) + options = link_args_to_options(args) + text = options.delete(:text) || h(page['title']) + content_tag :a, text, page_anchor_options(page, section, { :title => text }.merge(options)) end - def link_to_comments(article, text = nil) - content_tag :a, text || pluralize(article['comments_count'], 'comment'), :href => article['url'] + def link_to_comments(article, *args) + options = link_args_to_options(args) + text = options.delete(:text) || pluralize(article['comments_count'], 'comment') + content_tag :a, text, { :href => article['url'] + '#comments', :title => text }.merge(options) end - def link_to_section(section, text = nil) - content_tag :a, text || h(section['name']), :href => section['url'], :title => section['title'] + def link_to_section(section, *args) + options = link_args_to_options(args) + text = options.delete(:text) || h(section['name']) + content_tag :a, text, section_anchor_options(section, { :title => text }.merge(options)) end def img_tag(img, options = {}) tag 'img', {:src => asset_url(img), :alt => img.split('.').first }.merge(options) end + # Special link that checks for current section. If it exists and it's a paged section, use link_to_page instead. + def link_to_search_result(article, *args) + if current_page_section && current_page_section[:is_paged] + link_to_page(article, current_page_section, *args) + else + link_to_article(article, *args) + end + end + def stylesheet_url(css) absolute_url :stylesheets, css end @@ -54,12 +71,16 @@ image_tag url, :class => 'gravatar', :size => "#{size}x#{size}", :alt => comment['author'] end - def link_to_tag(tag) - content_tag :a, h(tag), :href => tag_url(tag) + def link_to_tag(tag, *args) + options = link_args_to_options(args) + text = options.delete(:text) || h(tag) + content_tag :a, text, { :href => tag_url(tag), :rel => 'tag', :title => text }.merge(options) end - def link_to_month(section, date = nil, format = 'my') - content_tag :a, format_date(date, format), :href => monthly_url(section, date) + def link_to_month(section, date = nil, format = 'my', *args) + options = link_args_to_options(args) + text = options.delete(:text) || h(format_date(date, format)) + content_tag :a, text, { :href => monthly_url(section, date), :title => text }.merge(options) end def monthly_url(section, date = nil) @@ -109,11 +130,33 @@ atom_feed '/feed/' + section.source.to_feed_url.join('/'), (title.blank? ? "Articles for #{section['name']}" : title) end + def next(article, section = nil) + article.next(section) + end + + def previous(article, section = nil) + article.previous(section) + end + private # marks a page as class=selected - def page_anchor_options(page, section = nil) - options = {:href => page_url(page, section)} - current_page_article == page ? options.update(:class => 'selected') : options + def page_anchor_options(page, section = nil, options = {}) + options.update(:href => page_url(page, section)) + options[:class].nil? ? options.update(:class => 'selected') : options[:class] += ' selected' if current_page_article == page + options + end + + # marks a section as class=selected + def section_anchor_options(section, options = {}) + options.update(:href => section['url']) + options[:class].nil? ? options.update(:class => 'selected') : options[:class] += ' selected' if current_page_section && (current_page_section.url == section.url) + options + end + + def link_args_to_options(args) + options = {} + [:text, :title, :id, :class, :rel].zip(args) {|key, value| options[key] = h(value) unless value.blank?} + options end def current_page_section @@ -123,4 +166,4 @@ def current_page_article @current_page_article ||= @context['article'] end -end \ No newline at end of file +end diff -Nur mephisto-0.7.3/app/helpers/admin/cached_pages_helper.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/helpers/admin/cached_pages_helper.rb --- mephisto-0.7.3/app/helpers/admin/cached_pages_helper.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/helpers/admin/cached_pages_helper.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,14 +1,4 @@ module Admin::CachedPagesHelper - def pagination_remote_links(paginator, options={}, html_options={}) - name = options[:name] || ActionController::Pagination::DEFAULT_OPTIONS[:name] - params = (options[:params] || ActionController::Pagination::DEFAULT_OPTIONS[:params]).clone - - pagination_links_each(paginator, options) do |n| - params[name] = n - link_to n.to_s, :page => n - end - end - def display_cached_page_date(page) if Date.today == page.updated_at.to_date if page.updated_at > Time.now - 4.hours @@ -20,4 +10,4 @@ page.updated_at.strftime("%b %d, %Y") end end -end \ No newline at end of file +end diff -Nur mephisto-0.7.3/app/helpers/admin/plugins_helper.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/helpers/admin/plugins_helper.rb --- mephisto-0.7.3/app/helpers/admin/plugins_helper.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/helpers/admin/plugins_helper.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,4 @@ +module Admin + module PluginsHelper + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/app/helpers/application_helper.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/helpers/application_helper.rb --- mephisto-0.7.3/app/helpers/application_helper.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/helpers/application_helper.rb 2008-03-31 02:18:56.000000000 -0400 @@ -2,7 +2,7 @@ module ApplicationHelper def author_link_for(comment) - return comment.author if comment.author_url.blank? + return h(comment.author) if comment.author_url.blank? link_to h(comment.author), "#{'http://' unless comment.author_url =~ /^https?:\/\//}#{comment.author_url}" end @@ -52,16 +52,6 @@ end end - def pagination_remote_links(paginator, options={}, html_options={}) - name = options[:name] || ActionController::Pagination::DEFAULT_OPTIONS[:name] - params = (options[:params] || ActionController::Pagination::DEFAULT_OPTIONS[:params]).clone - - pagination_links_each(paginator, options) do |n| - params[name] = n - link_to_function n.to_s, "window.spotlight.search('#{n}')" - end - end - def comment_expiration_options [['Are not allowed', -1], ['Never expire', 0], diff -Nur mephisto-0.7.3/app/helpers/feed_helper.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/helpers/feed_helper.rb --- mephisto-0.7.3/app/helpers/feed_helper.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/helpers/feed_helper.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,2 +1,12 @@ -module FeedHelper +module FeedHelper + # show paged url for an article if the section is a paged section + def section_url_for(article) + if @section && @section.show_paged_articles? + @section_articles ||= {} + @section_articles[@section.id] ||= (@section.articles.find(:first) || :false) + ([nil] << (@section_articles[@section.id].permalink == article.permalink ? @section.to_url : @section.to_page_url(article))).join("/") + else + site.permalink_for(article) + end + end end diff -Nur mephisto-0.7.3/app/models/article.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/article.rb --- mephisto-0.7.3/app/models/article.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/article.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,12 +1,13 @@ class Article < Content class CommentNotAllowed < StandardError; end - + validates_presence_of :title, :user_id, :site_id before_validation { |record| record.set_default_filter! } after_validation :convert_to_utc - before_create :create_permalink + has_permalink :title after_save :save_assigned_sections + after_update :reset_comment_attributes acts_as_versioned :if_changed => [:title, :body, :excerpt], :limit => 5 do def self.included(base) @@ -33,7 +34,7 @@ has_many :events, :order => 'created_at desc', :dependent => :delete_all with_options :order => 'created_at', :class_name => 'Comment' do |comment| - comment.has_many :comments, :conditions => ['contents.approved = ?', true], :dependent => :delete_all do + comment.has_many :comments, :conditions => ['contents.approved = ?', true] do def unapprove(id) returning find(id) do |comment| comment.approved = false @@ -49,14 +50,33 @@ end end end - comment.has_many :all_comments + comment.has_many :all_comments, :dependent => :delete_all + end + + has_many :assigned_assets, :order => 'position', :dependent => :destroy + has_many :assets, :through => :assigned_assets, :conditions => ['assigned_assets.active = ?', true], :select => 'assets.*, assigned_assets.label' do + def add(asset, label = nil) + returning AssignedAsset.find_or_create_by_article_id_and_asset_id(proxy_owner.id, asset.id) do |aa| + aa.label = label + aa.active = true + aa.save! + end + end + + def remove(asset) + AssignedAsset.update_all ['active = ?', false], ['article_id = ? AND asset_id = ?', proxy_owner.id, asset.id] + end end class << self + def with_published(&block) + with_scope({:find => { :conditions => ['contents.published_at <= ? AND contents.published_at IS NOT NULL', Time.now.utc] } }, &block) + end + def find_by_date(options = {}) - find(:all, { :order => 'contents.published_at desc', - :conditions => ['contents.published_at <= ? AND contents.published_at IS NOT NULL', Time.now.utc] } \ - .merge(options)) + with_published do + find :all, {:order => 'contents.published_at desc'}.update(options) + end end def find_all_in_month(year, month, options = {}) @@ -70,7 +90,7 @@ end def permalink_for(str) - str.gsub(/\W+/, ' ').strip.downcase.gsub(/\ +/, '-') + PermalinkFu.escape(str) end end @@ -134,11 +154,52 @@ set_default_filter_from user end - protected - def create_permalink - self.permalink = self.class.permalink_for(title.to_s) if permalink.blank? + def add_xml(builder) + add_podcast_xml(builder) + end + + def next(section=nil) + return nil if section && !sections.include?(section) + section = sections[0] if (section.nil?) + self.class.with_published do + if section + if section.paged? + index = section.articles.index(self) + (index <= section.articles.length-1) ? section.articles[index+1] : nil + # article = section.articles.detect {|article| article.id == id } + else + site.articles.find :first, :conditions => ['published_at > ? and assigned_sections.section_id = ?', published_at, section.id], + :joins => 'inner join assigned_sections on contents.id = assigned_sections.article_id', + :order => 'published_at' + end + else + site.articles.find :first, :conditions => ['published_at > ?', published_at], :order => 'published_at' + end end + end + + def previous(section=nil) + return nil if section && !sections.include?(section) + section = sections[0] if (section.nil?) + self.class.with_published do + if section + if section.paged? + index = section.articles.index(self) + (index > 0) ? section.articles[index-1] : nil + # article = section.articles.detect {|article| article.id == id } + else + site.articles.find :first, :conditions => ['published_at < ? and assigned_sections.section_id = ?', published_at, section.id], + :joins => 'inner join assigned_sections on contents.id = assigned_sections.article_id', + :order => 'published_at desc' + end + else + site.articles.find :first, :conditions => ['published_at < ?', published_at], :order => 'published_at desc' + end + end + end + + protected def convert_to_utc self.published_at = published_at.utc if published_at end @@ -156,4 +217,14 @@ @new_sections = nil end + + def reset_comment_attributes + Content.update_all ['title = ?, published_at = ?, permalink = ?', title, published_at, permalink], ['article_id = ?', id] + end + + def add_podcast_xml(builder) + if asset = assets.find(:first, :conditions => ['label = ?', 'podcast'], :select => 'assets.*') + builder.link :rel => :enclosure, :type => asset.content_type, :length => asset.size, :href => asset.public_filename + end + end end \ No newline at end of file diff -Nur mephisto-0.7.3/app/models/asset.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/asset.rb --- mephisto-0.7.3/app/models/asset.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/asset.rb 2008-03-31 02:18:56.000000000 -0400 @@ -6,10 +6,10 @@ # use #send due to a ruby 1.8.2 issue @@movie_condition = send(:sanitize_sql, ['content_type LIKE ? OR content_type IN (?)', 'video%', extra_content_types[:movie]]).freeze @@audio_condition = send(:sanitize_sql, ['content_type LIKE ? OR content_type IN (?)', 'audio%', extra_content_types[:audio]]).freeze - @@image_condition = send(:sanitize_sql, ['content_type IN (?)', Technoweenie::ActsAsAttachment.content_types]).freeze + @@image_condition = send(:sanitize_sql, ['content_type IN (?)', Technoweenie::AttachmentFu.content_types]).freeze @@other_condition = send(:sanitize_sql, [ 'content_type NOT LIKE ? AND content_type NOT LIKE ? AND content_type NOT IN (?)', - 'audio%', 'video%', (extra_content_types[:movie] + extra_content_types[:audio] + Technoweenie::ActsAsAttachment.content_types)]).freeze + 'audio%', 'video%', (extra_content_types[:movie] + extra_content_types[:audio] + Technoweenie::AttachmentFu.content_types)]).freeze cattr_reader *%w(movie audio image other).collect! { |t| "#{t}_condition".to_sym } class << self @@ -45,7 +45,9 @@ include Mephisto::TaggableMethods belongs_to :site - acts_as_attachment :storage => :file_system, :thumbnails => { :thumb => '120>', :tiny => '50>' }, :max_size => 30.megabytes + has_many :assigned_assets, :order => 'position', :dependent => :destroy + has_attachment :storage => :file_system, :thumbnails => { :thumb => '120>', :tiny => '50>' }, :max_size => 30.megabytes, + :processor => (Object.const_defined?(:ASSET_IMAGE_PROCESSOR) ? ASSET_IMAGE_PROCESSOR : nil) before_validation_on_create :set_site_from_parent validates_presence_of :site_id validates_as_attachment @@ -69,6 +71,7 @@ end after_attachment_saved do |record| + File.chmod 0644, record.full_filename Asset.update_all ['thumbnails_count = ?', record.thumbnails.count], ['id = ?', record.id] unless record.parent_id end @@ -82,7 +85,7 @@ protected def rename_unique_filename - if (@old_filename || new_record?) && errors.empty? && site_id && filename + if ((@old_filename && !@old_filename.eql?(full_filename)) || new_record?) && errors.empty? && site_id && filename i = 1 pieces = filename.split('.') ext = pieces.size == 1 ? nil : pieces.pop diff -Nur mephisto-0.7.3/app/models/assigned_asset.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/assigned_asset.rb --- mephisto-0.7.3/app/models/assigned_asset.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/assigned_asset.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,14 @@ +class AssignedAsset < ActiveRecord::Base + belongs_to :article, :counter_cache => 'assets_count' + belongs_to :asset + acts_as_list :scope => :article_id + validates_presence_of :article_id, :asset_id + validate_on_create :check_for_dupe_article_and_asset + + protected + def check_for_dupe_article_and_asset + unless self.class.count(:all, :conditions => ['article_id = ? and asset_id = ?', article_id, asset_id]).zero? + errors.add_to_base("Cannot have a duplicate assignment for this article and asset") + end + end +end diff -Nur mephisto-0.7.3/app/models/assigned_section.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/assigned_section.rb --- mephisto-0.7.3/app/models/assigned_section.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/assigned_section.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,14 +1,14 @@ class AssignedSection < ActiveRecord::Base belongs_to :article belongs_to :section, :counter_cache => 'articles_count' - acts_as_list :scope => 'section_id = #{section_id}' + acts_as_list :scope => :section_id validates_presence_of :article_id, :section_id validate_on_create :check_for_dupe_article_and_section protected def check_for_dupe_article_and_section unless self.class.count(:all, :conditions => ['article_id = ? and section_id = ?', article_id, section_id]).zero? - errors.add_to_base("Cannot have a duplicate categorization for this article and section") + errors.add_to_base("Cannot have a duplicate assignment for this article and section") end end end diff -Nur mephisto-0.7.3/app/models/comment.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/comment.rb --- mephisto-0.7.3/app/models/comment.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/comment.rb 2008-03-31 02:18:56.000000000 -0400 @@ -7,12 +7,23 @@ before_validation :clean_up_author_url after_validation_on_create :snag_article_attributes before_create :check_comment_expiration + before_create :sanitize_attributes before_save :update_counter_cache before_destroy :decrement_counter_cache belongs_to :article has_one :event, :dependent => :destroy - attr_protected :approved + before_create :check_if_previewing + attr_accessible :article, :article_id, :user_id, :user, :excerpt, :body, :author, :author_url, :author_email, :author_ip, :updater_id, :updater, :comment_age, :user_agent, :referrer, :preview + attr_accessor :preview + class Previewing < StandardError; end + + # If the view sends the "preview" accessor, we raise this + # error so the controller can simply rescue + def check_if_previewing + raise Comment::Previewing if preview + end + def self.find_all_by_section(section, options = {}) find :all, options.update(:conditions => ['contents.approved = ? and assigned_sections.section_id = ?', true, section.id], :select => 'contents.*', :joins => 'INNER JOIN assigned_sections ON assigned_sections.article_id = contents.article_id', @@ -67,12 +78,19 @@ end protected + def sanitize_attributes + [:author, :author_url, :author_email, :author_ip, :user_agent, :referrer].each do |a| + self.send("#{a}=", CGI::escapeHTML(self.send(a).to_s)) + end + end + def snag_article_attributes - self.attributes = { :site => article.site, :filter => article.site.filter, :title => article.title, :published_at => article.published_at, :permalink => article.permalink } + self.filter ||= article.site.filter + [:site, :title, :published_at, :permalink].each { |a| self.send("#{a}=", article.send(a)) } end def check_comment_expiration - raise Article::CommentNotAllowed unless article.accept_comments? + raise Article::CommentNotAllowed, "#{article.status} does not allow comments" unless article.accept_comments? end def update_counter_cache diff -Nur mephisto-0.7.3/app/models/resources.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/resources.rb --- mephisto-0.7.3/app/models/resources.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/resources.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,7 +1,8 @@ class Resources < Attachments - NON_IMAGE_EXTNAMES = %w(.js .css) + @@non_image_extnames = %w(.js .css) + cattr_reader :non_image_extnames def image?(path) - !NON_IMAGE_EXTNAMES.include?(path.extname) + !non_image_extnames.include?(path.extname) end def content_type(path) @@ -12,6 +13,7 @@ when '.jpg', '.jpeg' then 'image/jpeg' when '.gif' then 'image/gif' when '.swf' then 'application/x-shockwave-flash' + when '.ico' then 'image/x-icon' end end diff -Nur mephisto-0.7.3/app/models/site.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/site.rb --- mephisto-0.7.3/app/models/site.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/site.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,10 +1,32 @@ +require 'uri' + class Site < ActiveRecord::Base - @@theme_path = Pathname.new(RAILS_ROOT) + 'themes' - cattr_reader :theme_path + @@default_assigns = {} + @@theme_path = Pathname.new(RAILS_ROOT) + 'themes' + cattr_reader :theme_path, :default_assigns cattr_accessor :multi_sites_enabled, :cache_sweeper_tracing + + # @@template_handlers = HashWithIndifferentAccess.new if @@template_handlers.nil? + @@template_handlers = {} + + # Register a class that knows how to handle template files with the given + # extension. This can be used to implement new template types. + # The constructor for the class must take a Site instance + # as a parameter, and the class must implement a #render method that + # has the following signature + # def render(section, layout, template, assigns ={}, controller = nil) + # and return the rendered template as a string. + def self.register_template_handler(extension, klass) + @@template_handlers[extension] = klass + end + register_template_handler(".liquid", Mephisto::Liquid::LiquidTemplate) + + def self.extensions + @@template_handlers.keys + end - has_many :sections, :order => "position" do + has_many :sections, :order => "position", :dependent => :destroy do def home find_by_path '' end @@ -19,7 +41,7 @@ end end - has_many :articles do + has_many :articles, :dependent => :destroy do def find_by_permalink(options) conditions = returning ["(contents.published_at IS NOT NULL AND contents.published_at <= ?)", Time.now.utc] do |cond| @@ -41,13 +63,13 @@ end end - has_many :comments, :order => 'comments.created_at desc' + has_many :comments, :order => 'comments.created_at desc', :dependent => :delete_all - has_many :events + has_many :events, :dependent => :destroy - has_many :cached_pages + has_many :cached_pages, :dependent => :destroy - has_many :assets, :order => 'created_at desc', :conditions => 'parent_id is null' + has_many :assets, :order => 'created_at desc', :conditions => 'parent_id is null', :dependent => :destroy has_many :memberships, :dependent => :destroy has_many :members, :through => :memberships, :source => :user @@ -60,13 +82,23 @@ validates_format_of :host, :with => Format::DOMAIN validates_uniqueness_of :host validate :check_permalink_style - after_create { |s| s.sections.create(:name => 'Home') } + + after_create :setup_site_theme_directories + after_create { |site| site.sections.create(:name => 'Home') } + before_destroy :flush_cache_and_remove_site_directories with_options :order => 'contents.created_at DESC', :class_name => 'Comment' do |comment| comment.has_many :comments, :conditions => ['contents.approved = ?', true] comment.has_many :unapproved_comments, :conditions => ['contents.approved = ? or contents.approved is null', false] comment.has_many :all_comments end + + def self.search_by_host_or_title(search_string) + conditions = search_string.blank? ? nil : ["host LIKE ? OR title LIKE ?"] + ["%#{search_string}%"] * 2 + with_scope( :find => { :conditions => conditions } ) do + yield + end + end def users(options = {}) User.find_all_by_site self, options @@ -123,7 +155,7 @@ end def theme - @theme ||= themes[current_theme_path] || themes.first + @theme ||= themes[current_theme_path] || themes.first || raise(MissingThemesError.new(self)) end def change_theme_to(new_theme_path) @@ -150,23 +182,26 @@ end def search_url(query, page = nil) - "/#{search_path}?q=#{CGI::escapeHTML(query)}#{%(&page=#{CGI::escapeHTML(page.to_s)}) unless page.blank?}" + "/#{search_path}?q=#{CGI::escapeHTML(query)}#{%(&page=#{CGI::escapeHTML(page.to_s)}) unless page.blank?}" end def tag_url(*tags) - ['', tag_path, *tags] * '/' + ['', tag_path, *tags.collect { |t| URI::escape(t.to_s) }] * '/' end def accept_comments? comment_age.to_i > -1 end - def render_liquid_for(section, template_type, assigns = {}, controller = nil) + def call_render(section, template_type, assigns = {}, controller = nil) assigns.update('site' => to_liquid(section), 'mode' => template_type) - parse_inner_template(set_content_template(section, template_type), assigns, controller) - parse_template(set_layout_template(section, template_type), assigns, controller) + assigns.update(default_assigns) unless default_assigns.empty? + template = set_content_template(section, template_type) + layout = set_layout_template(section, template_type) + handler = @@template_handlers[theme.extension] || @@template_handlers[".liquid"] + handler.new(self).render(section, layout, template, assigns, controller) end - + def to_liquid(current_section = nil) SiteDrop.new self, current_section end @@ -194,6 +229,13 @@ end end +#need non protected method for ErbTemplate - psq + def find_preferred_template(template_type, custom_template) + preferred = templates.find_preferred(template_type, custom_template) + return preferred if preferred && preferred.file? + raise MissingTemplateError.new(template_type, templates.collect_templates(template_type, custom_template).collect(&:basename)) + end + protected def cached_log_message_for(log_message, pages) pages.inject([log_message, "Expiring #{pages.size} page(s)"]) { |msg, p| msg << " - #{p.url}" }.join("\n") @@ -259,33 +301,38 @@ else case template_type when :tag then tag_layout - when :search then search_layout + when :search then sections.detect(&:home?).layout end end find_preferred_template(:layout, layout_template) end - def find_preferred_template(template_type, custom_template) - preferred = templates.find_preferred(template_type, custom_template) - return preferred if preferred && preferred.file? - raise MissingTemplateError.new(template_type, templates.collect_templates(template_type, custom_template).collect(&:basename)) - end + private - def parse_template(template, assigns, controller) - # give the include tag access to files in the site's fragments directory - Liquid::Template.file_system = Liquid::LocalFileSystem.new(File.join(theme.path, 'templates')) - tmpl = Liquid::Template.parse(template.read.to_s) - returning tmpl.render(assigns, :registers => {:controller => controller}) do |result| - yield tmpl, result if block_given? + def setup_site_theme_directories + begin + theme_path = "#{RAILS_ROOT}/themes/site-#{self.id}/simpla" + FileUtils.mkdir_p("#{RAILS_ROOT}/themes/site-#{self.id}") + FileUtils.cp_r("#{RAILS_ROOT}/themes/default", theme_path) + Dir[File.join(theme_path, '**/.svn')].each do |dir| + FileUtils.rm_rf dir + end + rescue + logger.error "ERROR: removing directories for site #{self.host}, check file permissions." + errors.add_to_base "Unable to create theme directories." + false end end - - def parse_inner_template(template, assigns, controller) - parse_template(template, assigns, controller) do |tmpl, result| - # Liquid::Template takes a copy of the assigns. - # merge any new values in to the assigns and pass them to the layout - tmpl.assigns.each { |k, v| assigns[k] = v } if tmpl.respond_to?(:assigns) - assigns['content_for_layout'] = result + + def flush_cache_and_remove_site_directories + begin + CachedPage.expire_pages self, self.cached_pages + FileUtils.rm_rf("#{RAILS_ROOT}/themes/site-#{self.id}") + FileUtils.rm_rf("#{RAILS_ROOT}/public/cache/#{self.host}") + rescue + logger.error "ERROR: removing directories for site #{self.host}, check file permissions." + false end end + end diff -Nur mephisto-0.7.3/app/models/tag.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/tag.rb --- mephisto-0.7.3/app/models/tag.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/tag.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,5 +1,4 @@ class Tag < ActiveRecord::Base - @@tag_parse_regex = /((?: |)['"]{0,1})['"]?\s*(.*?)\s*(?:[,'"]|$)(?:\1(?: |$))/ has_many :taggings class << self @@ -7,23 +6,19 @@ find_by_name(tag.to_s) end - # parses a comma separated list of tags into tag names - # handles all kinds of different tags. (comma seperated, space seperated (in quotation marks)) - # should handle most the common keyword formats. - # - # e.g.: b'log, emacs fun, rails, ruby => "b'log", "emacs fun", "rails", "ruby" - # "b'log" "emacs fun" "rails" "ruby" => "b'log", "emacs fun", "rails", "ruby" - # 'b\'log' 'emacs fun' 'rails' 'ruby' => "b'log", "emacs fun", "rails", "ruby" + # parses a list of tags into tag names # # Tag.parse('a, b, c') # # => ['a', 'b', 'c'] + # + # Tag.parse("a b c") + # # => ['a', 'b', 'c'] + # + # Tag.parse(%(a "b c")) + # # => ['a', 'b c'] def parse(list) return list if list.is_a?(Array) - returning list.scan(@@tag_parse_regex) do |tags| - tags.collect! { |t| t.last.strip!; t.last } - tags.uniq! - tags.delete_if &:blank? - end + list.include?(',') ? parse_with_commas(list) : parse_with_spaces(list) end # Parses comma separated tag list and returns tags for them. @@ -44,6 +39,38 @@ found_tags + (tag_names - found_tags.collect(&:name)).collect { |s| create!(:name => s) } end end + + private + def parse_with_commas(list) + cleanup_tags(list.split(',')) + end + + def parse_with_spaces(list) + tags = [] + + # first, pull out the quoted tags + list.gsub!(/\"(.*?)\"\s*/ ) { tags << $1; "" } + + # then, get whatever's left + tags.concat list.split(/\s/) + + cleanup_tags(tags) + end + + def cleanup_tags(tags) + tags.tap do |t| + t.collect! do |tag| + unless tag.blank? + tag.downcase! + tag.gsub!(/:/, '') + tag.strip! + tag + end + end + t.compact! + t.uniq! + end + end end def ==(comparison_object) diff -Nur mephisto-0.7.3/app/models/templates.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/templates.rb --- mephisto-0.7.3/app/models/templates.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/templates.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,15 +1,18 @@ class Templates < Attachments - @@template_types = [:section, :single, :archive, :search, :error, :tag, :layout].collect! { |f| "#{f}.liquid" } + @@template_types = ["section", "single", "archive", "search", "error", "tag", "layout"] @@template_types.sort! - cattr_reader :template_types + def template_types(extension = ".liquid") + @@template_types.collect { |f| "#{f}"+extension } + end + def [](template_name) - template_name = File.basename(template_name.to_s).sub /\.liquid$/, '' - theme.path + "#{template_name =~ /layout$/ ? 'layouts' : 'templates'}/#{template_name}.liquid" + template_name = File.basename(template_name.to_s).sub /#{theme.extension}$/, '' + theme.path + "#{template_name =~ /layout$/ ? 'layouts' : 'templates'}/#{template_name}#{theme.extension}" end def collect_templates(template_type, *custom_templates) - custom_templates.push(template_type).collect! { |t| self[t] } + custom_templates.push(template_type.to_s+theme.extension).collect! { |t| self[t] } end # adds the custom_template to the top of the hierarchy if given @@ -17,7 +20,7 @@ collect_templates(template_type, custom_template).detect(&:file?) end - def custom - @custom ||= collect { |p| p.basename.to_s } - template_types + def custom(extension = ".liquid") + @custom ||= (collect { |p| p.basename.to_s } - template_types(extension)).sort end end \ No newline at end of file diff -Nur mephisto-0.7.3/app/models/theme.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/theme.rb --- mephisto-0.7.3/app/models/theme.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/theme.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,9 +1,9 @@ class Theme @@root_theme_files = %w(about.yml preview.png) @@theme_directories = %w(templates layouts javascripts stylesheets images) - @@allowed_extensions = %w(.js .css .liquid .png .gif .jpg .swf) + @@allowed_extensions = %w(.js .css .png .gif .jpg .swf .ico) | Site.extensions cattr_reader :root_theme_files, :theme_directories, :allowed_extensions - attr_reader :path, :base_path + attr_reader :path, :base_path, :extension def self.import(zip_file, options = {}) dest = options[:to].is_a?(Pathname) ? options[:to] : Pathname.new(options[:to] || '.') @@ -47,6 +47,8 @@ @base_path = base @path = Pathname.new(@base_path) end + layout = (@path + "layouts").children(false).select {|v| v.to_s =~ /^layout/}[0] if (@path + "layouts").directory? + @extension = layout.extname if layout end def current? @@ -98,7 +100,7 @@ Pathname.glob(File.join(base_path, '*/*')).each do |path| next unless path.file? @attachments << path - (path.extname == '.liquid' ? @templates : @resources) << path + ((path.extname == @extension) ? @templates : @resources) << path end @attachments end diff -Nur mephisto-0.7.3/app/models/user.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/user.rb --- mephisto-0.7.3/app/models/user.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/user.rb 2008-03-31 02:18:56.000000000 -0400 @@ -6,7 +6,10 @@ # Virtual attribute for the unencrypted password attr_accessor :password - + + #Only these can be modified through bulk-setters like update_attributes, new, create + attr_accessible :login, :email, :password, :password_confirmation, :filter + validates_presence_of :login, :email validates_format_of :email, :with => Format::EMAIL validates_presence_of :password, :if => :password_required? diff -Nur mephisto-0.7.3/app/models/user_mailer.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/user_mailer.rb --- mephisto-0.7.3/app/models/user_mailer.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/models/user_mailer.rb 2008-03-31 02:18:56.000000000 -0400 @@ -6,7 +6,7 @@ def forgot_password(user) setup_email(user) @subject += 'Request to change your password' - @body[:url] = url_for :controller => :account, :action => :activate, :id => user.token + @body[:url] = url_for :controller => 'account', :action => 'activate', :id => user.token end protected diff -Nur mephisto-0.7.3/app/views/account/login.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/account/login.rhtml --- mephisto-0.7.3/app/views/account/login.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/account/login.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -1,5 +1,5 @@
-<% form_tag({:controller=>:account, :action=>:login}, { :id => 'login_form' }) do -%> +<% form_tag({:controller=>'account', :action=>'login'}, { :id => 'login_form' }) do -%>
<%= label_tag 'login', 'Login' %>
<%= text_field_tag 'login', params[:login], :class => 'big' %>
diff -Nur mephisto-0.7.3/app/views/admin/articles/_article.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/_article.rhtml --- mephisto-0.7.3/app/views/admin/articles/_article.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/_article.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -5,9 +5,9 @@ <% if article.comments.size == 0 %> none <% else %> - <%= link_to article.comments.size.to_s.rjust(2, '0'), { :action => 'comments', :id => article } %> + <%= link_to article.comments.size.to_s.rjust(2, '0'), article_comments_path(article) %> <% end %> <%= published_at_for article %> - <%= article.published? ? link_to(image_tag('/images/mephisto/icons/24-zoom-in.png', :style => 'vertical-align: middle'), article.full_permalink) : ' ' %> + <%= article.published? ? link_to(image_tag('/images/mephisto/icons/24-zoom-in.png', :style => 'vertical-align: middle'), @site.permalink_for(article)) : ' ' %> diff -Nur mephisto-0.7.3/app/views/admin/articles/_form.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/_form.rhtml --- mephisto-0.7.3/app/views/admin/articles/_form.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/_form.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -5,11 +5,11 @@
<%= form.text_field :title, :class => 'big' %>
-
<%= form.label_for :excerpt %> (<%= link_to_function 'Cancel', %(['x-lbl', 'x-body'].each(Element.toggle)) %>)
+
<%= form.label_for :excerpt %> (<%= link_to_function 'Hide', %(['x-lbl', 'x-body'].each(Element.toggle)) %>)
<%= form.text_area :excerpt, :rows => '8', :class => 'fat' %>
(<%= link_to_function 'Add an excerpt', %(['x-lbl', 'x-body'].each(Element.toggle)) %>)
<%= form.text_area :body, :class => 'fat', :rows => 25 %>
-
Enter one or more tags separated by a comma.
+
Enter one or more tags separated by a comma or a space (for example, "Web Dev" Tutorials or Web Dev, Tutorials).
<%= form.text_field :tag %>
@@ -22,7 +22,7 @@ diff -Nur mephisto-0.7.3/app/views/admin/articles/_page_nav.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/_page_nav.rhtml --- mephisto-0.7.3/app/views/admin/articles/_page_nav.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/_page_nav.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -2,13 +2,15 @@ <% content_for :action_nav do %> -<% end unless @article.new_record? && @article.comments.empty? -%> \ No newline at end of file +<% end unless @article && @article.new_record? && @article.comments.size == 0 -%> \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/articles/_shared_options.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/_shared_options.rhtml --- mephisto-0.7.3/app/views/admin/articles/_shared_options.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/_shared_options.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -14,6 +14,7 @@
  • Latest
  • +
  • Attached
  • Upload
  • Bucket
  • @@ -21,8 +22,13 @@
    -
      - <%= render :partial => "admin/assets/widget", :collection => @assets %> +
        + <%= render :partial => "admin/assets/widget", :collection => @assets, :locals => { :prefix => 'latest' } %> +
      +
    +
    diff -Nur mephisto-0.7.3/app/views/admin/articles/approve.rjs technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/approve.rjs --- mephisto-0.7.3/app/views/admin/articles/approve.rjs 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/approve.rjs 1969-12-31 19:00:00.000000000 -0500 @@ -1 +0,0 @@ -page["comment-#{@comment.id}"].add_class_name 'disabled' \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/articles/attach.rjs technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/attach.rjs --- mephisto-0.7.3/app/views/admin/articles/attach.rjs 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/attach.rjs 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1 @@ +page.insert_html :bottom, 'attached-assets', :partial => 'admin/assets/widget', :object => @asset, :locals => { :prefix => 'attached' } \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/articles/comments.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/comments.rhtml --- mephisto-0.7.3/app/views/admin/articles/comments.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/comments.rhtml 1969-12-31 19:00:00.000000000 -0500 @@ -1,57 +0,0 @@ -<%= render :partial => "page_nav" %> - - -

    Comments on <%= link_to @article.title, { :action => 'edit', :id => @article }, :style => 'border:none' %> <%= @article.published? ? link_to(image_tag('/images/mephisto/icons/24-zoom-in.png', :style => 'vertical-align: middle'), @article.full_permalink, :style => 'border:none;') : ' ' %>

    - -
      - <% if @comments.any? %> - <% @comments.reverse.each_with_index do |comment, i| -%> -
    • 0) %>" id="comment-<%= comment.id %>"> - <% if false %> - - <% end %> - - <% unless comment.body.blank? -%> -

      "<%= strip_tags(comment.body) %>"

      - <% end -%> - - — <%= author_link_for comment %><%= %( (#{comment.author_email})) unless comment.author_email.blank? %> said <%= time_ago_in_words comment.created_at %> ago - - <% if comment.approved? -%> - <%= link_to_remote 'Unapprove', :url => { :action => 'unapprove', :id => @article, :comment => comment } %> | - <% else -%> - <%= link_to_remote 'Approve', :url => { :action => 'approve', :id => @article, :comment => comment } %> | - <% end -%> - <%= link_to_remote 'Delete', :url => { :action => 'destroy_comment', :id => @article, :comment => comment } %> - -
    • - <% end -%> - <% else %> -
    • This article has no <%= params[:filter].to_s.humanize.downcase %> comments.
    • - <% end %> -
    - - -<% content_for :sidebar do %> - <% if @articles.size > 1 -%> -
    -

    Comments awaiting your approval

    -
      - <% @articles.each do |article, count| -%> - <% if article.title != @article.title -%> -
    • <%= link_to "(#{count}) #{h(article.title)}", :controller => 'articles', :action => 'comments', :id => article.id, :filter => :unapproved %>
    • - <% end -%> - <% end -%> -
    -
    - <% end -%> -<% end %> - - - \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/articles/destroy_comment.rjs technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/destroy_comment.rjs --- mephisto-0.7.3/app/views/admin/articles/destroy_comment.rjs 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/destroy_comment.rjs 1969-12-31 19:00:00.000000000 -0500 @@ -1,3 +0,0 @@ -@comments.each do |comment| - page["comment-#{comment.id}"].add_class_name 'disabled' -end \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/articles/edit.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/edit.rhtml --- mephisto-0.7.3/app/views/admin/articles/edit.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/edit.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -1,23 +1,24 @@ <%= render :partial => "page_nav" %> <% fields_for :article, @version do |f| -%> -<% content_for :sidebar do %> - <%= render :partial => 'shared_options', :locals => { :form => f } %> -<% end %> + <% content_for :sidebar do %> + <%= render :partial => 'shared_options', :locals => { :form => f } %> + <% end %> <% end %> <%= error_messages_for :article %> <% content_for :form do -%> - <%= form_tag({:action => 'update', :id => @article}, {:id => 'article-form', :multipart => true}) %> + <%= form_tag({:action => 'update', :id => @article}, {:id => 'article-form', :multipart => true, :method => :put}) %> <% end -%> <% fields_for :article, @version do |f| -%> -<%= render :partial => 'form', :object => f %> -

    - <%= submit_tag 'Apply Changes' %> - <%= submit_tag 'Save without Revision' %> - <%= link_to "cancel", :controller => "articles" %>

    + <%= render :partial => 'form', :object => f %> +

    + <%= submit_tag 'Apply Changes' %> + <%= submit_tag 'Save without Revision' %> + <%= link_to "cancel", :controller => "articles" %> +

    <% end -%> diff -Nur mephisto-0.7.3/app/views/admin/articles/index.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/index.rhtml --- mephisto-0.7.3/app/views/admin/articles/index.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/index.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -36,7 +36,12 @@
<% end %> -<% if @articles.any? %> +<% if @articles.size > 0 -%> + +<% content_tag :p, :class => 'total' do %> + Total: <%= content_tag :strong, @articles.total_entries %> articles. +<% end %> + @@ -54,13 +59,10 @@
- - <% else %> @@ -79,7 +81,7 @@

Comments awaiting your approval

    <% @comments.each do |article, count| -%> -
  • <%= link_to "(#{count}) #{h(article.title)}", :controller => 'articles', :action => 'comments', :id => article.id, :filter => :unapproved %>
  • +
  • <%= link_to "(#{count}) #{h(article.title)}", article_comments_path(article), :filter => :unapproved %>
  • <% end -%>
diff -Nur mephisto-0.7.3/app/views/admin/articles/label.rjs technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/label.rjs --- mephisto-0.7.3/app/views/admin/articles/label.rjs 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/articles/label.rjs 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1 @@ +page["label-attached-widget-#{params[:version]}"].replace_html "Save" \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/assets/_assets.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/assets/_assets.rhtml --- mephisto-0.7.3/app/views/admin/assets/_assets.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/assets/_assets.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -27,8 +27,6 @@
You have no files of this type or have yet to upload any files. <%= link_to 'Upload one now »', :action => 'new' %>
<% end %> -<% if @asset_pages.page_count > 1 %> - -<% end %> \ No newline at end of file +<% if @assets.page_count > 1 %> + <%= will_paginate @assets, :id => 'pagination' %> +<% end %> diff -Nur mephisto-0.7.3/app/views/admin/assets/_widget.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/assets/_widget.rhtml --- mephisto-0.7.3/app/views/admin/assets/_widget.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/assets/_widget.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -1,3 +1,18 @@ -
  • +
  • " class="widget<%= ' selected-widget' if @article && @article.assets.include?(widget) %>"> +<% if prefix == 'attached' -%> +
    + <%= link_to asset_image_for(widget), widget.public_filename %> + + <%= text_field_tag :version, (widget.respond_to?(:label) ? widget.label : nil), :id => widget.dom_id("#{prefix}-widget-version"), :class => 'txt' %> + ">Save + +
    +<% else -%> <%= link_to asset_image_for(widget), widget.public_filename %> -
  • \ No newline at end of file +<% end -%> + <%= image_tag('mephisto/icons/8-em-cross.png', :size => '16x16', :id => widget.dom_id("detach-#{prefix}-widget"), + :style => 'display:none', :class => 'detach-widget') %> + <%= image_tag('mephisto/icons/8-em-plus.png', :size => '16x16', :id => widget.dom_id("attach-#{prefix}-widget"), + :style => 'display:none', :class => 'attach-widget') %> + +<% if widget_counter.remainder(4).zero? && widget_counter > 0 %>
    <% end %> diff -Nur mephisto-0.7.3/app/views/admin/assets/edit.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/assets/edit.rhtml --- mephisto-0.7.3/app/views/admin/assets/edit.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/assets/edit.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -6,7 +6,7 @@ <%= error_messages_for :asset %>
    -
    Enter one or more tags separated by a comma.
    +
    Enter one or more tags separated by a comma or a space (for example, "Web Dev" Tutorials or Web Dev, Tutorials).
    <%= f.text_field :tag %>
    <%= f.file_field :uploaded_data %>
    diff -Nur mephisto-0.7.3/app/views/admin/assets/index.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/assets/index.rhtml --- mephisto-0.7.3/app/views/admin/assets/index.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/assets/index.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -43,7 +43,7 @@
      <% session[:bucket].each do |filename, values| -%>
    • - <%= link_to(image_tag(*values), filename, :target => '_blank') %> + <%= image_tag(*values) %>
    • <% end unless session[:bucket].blank? %>
    @@ -55,4 +55,4 @@ <%= number_to_human_size site.assets.sum(:size) %>.

    -<% end %> \ No newline at end of file +<% end %> diff -Nur mephisto-0.7.3/app/views/admin/cached_pages/pages.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/cached_pages/pages.rhtml --- mephisto-0.7.3/app/views/admin/cached_pages/pages.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/cached_pages/pages.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -1,34 +1,23 @@ -<% if @cached_pages.size > 0 -%> - -
    -<% if @cached_page_pages.page_count > 1 %> -Pages: <%= pagination_remote_links @cached_page_pages, :params => { :action => :index } %> -<% end %> -
    -

    Cached Pages


    - - - - - - - - - +<% unless @cached_pages.empty? -%> + <%= will_paginate @cached_pages, :class => 'pages' if @cached_pages.page_count > 1 %> + +

    Cached Pages


    +
     URLDateActions
    + + + + + + + + - - <%= render :partial => 'page', :collection => @cached_pages %> - -
     URLDateActions
    - + + <%= render :partial => 'page', :collection => @cached_pages %> + + + + <%= will_paginate @cached_pages, :id => 'pagination' if @cached_pages.page_count > 1 %> <% else -%>
    There currently aren't any pages being cached by Mephisto.
    -<% end -%> - - - - \ No newline at end of file +<% end -%> \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/comments/_comment.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/_comment.rhtml --- mephisto-0.7.3/app/views/admin/comments/_comment.rhtml 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/_comment.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,16 @@ + +
  • " id="comment-<%= comment.id %>"> +

    <%= link_to comment.article.title, :controller => 'articles', :action => 'edit', :id => comment.article %>

    +

    "<%= truncate strip_tags(comment.body), 255 %>"

    + + — <%= author_link_for comment %><%= %( (#{comment.author_email})) unless comment.author_email.blank? %> + + <%= link_to_remote 'Edit', :url => edit_article_comment_path(@article, comment), :method => :get %> | + <% if comment.approved? -%> + <%= link_to_remote 'Unapprove', :url => unapprove_article_comment_path(comment.article, comment) %> | + <% else -%> + <%= link_to_remote 'Approve', :url => approve_article_comment_path(comment.article, comment) %> | + <% end -%> + <%= link_to_remote 'Delete', :url => article_comment_path(comment.article, comment), :method => :delete %> + +
  • diff -Nur mephisto-0.7.3/app/views/admin/comments/_edit_comment.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/_edit_comment.rhtml --- mephisto-0.7.3/app/views/admin/comments/_edit_comment.rhtml 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/_edit_comment.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,9 @@ +
  • + <%= error_messages_for :comment %> + <% remote_form_for :comment, :url => article_comment_path(@article, comment), :html => { :method => :put, :onsubmit => "$('comment-#{comment.id}-spinner').show()" } do |form| %> + <%= render :partial => 'form', :object => form %> + <%= submit_tag "Update" %> + + <%= link_to_function "Cancel", "$('comment-#{comment.id}').show(); $('edit-comment-#{comment.id}').remove()" %> + <% end # form %> +
  • \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/comments/_form.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/_form.rhtml --- mephisto-0.7.3/app/views/admin/comments/_form.rhtml 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/_form.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,16 @@ +

    + + <%= form.text_field :author %> +

    +

    + + <%= form.text_field :author_email %> +

    +

    + + <%= form.text_field :author_url %> +

    +

    + <%= form.text_area :body, { :rows => '10' } %> +

    + diff -Nur mephisto-0.7.3/app/views/admin/comments/_new_comment.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/_new_comment.rhtml --- mephisto-0.7.3/app/views/admin/comments/_new_comment.rhtml 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/_new_comment.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,5 @@ + <%= error_messages_for :comment %> + <% remote_form_for :comment, :url => article_comments_path(@article) do |form| %> + <%= render :partial => 'form', :object => form %> + <%= submit_tag "Create" %> or <%= link_to_function "hide", "$('new-comment-form').toggle()" %> + <% end # form %> diff -Nur mephisto-0.7.3/app/views/admin/comments/approve.rjs technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/approve.rjs --- mephisto-0.7.3/app/views/admin/comments/approve.rjs 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/approve.rjs 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1 @@ +page["comment-#{@comment.id}"].add_class_name 'disabled' \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/comments/create.rjs technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/create.rjs --- mephisto-0.7.3/app/views/admin/comments/create.rjs 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/create.rjs 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,6 @@ + if @comment.new_record? + page.replace_html 'new-comment-form', :partial => 'new_comment' + else + page['new-comment-form'].reset + page.insert_html :top, 'comment-list', :partial => 'comment', :object => @comment + end diff -Nur mephisto-0.7.3/app/views/admin/comments/destroy.rjs technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/destroy.rjs --- mephisto-0.7.3/app/views/admin/comments/destroy.rjs 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/destroy.rjs 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,3 @@ +@comments.each do |comment| + page["comment-#{comment.id}"].add_class_name 'disabled' +end \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/comments/edit.rjs technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/edit.rjs --- mephisto-0.7.3/app/views/admin/comments/edit.rjs 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/edit.rjs 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,2 @@ + page.insert_html :after, "comment-#{@comment.id}", :partial => 'edit_comment', :locals => { :comment => @comment } + page.hide "comment-#{@comment.id}" diff -Nur mephisto-0.7.3/app/views/admin/comments/index.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/index.rhtml --- mephisto-0.7.3/app/views/admin/comments/index.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/index.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -1,33 +1,65 @@ -<% content_for :action_nav do %> - - - -<% end %> +<%= render :partial => "admin/articles/page_nav" %> + +

    +<% if @article -%> +Comments on <%= link_to @article.title, edit_article_path(@article), :style => 'border:none' %> <%= @article.published? ? link_to(image_tag('/images/mephisto/icons/24-zoom-in.png', :style => 'vertical-align: middle'), @site.permalink_for(@article), :style => 'border:none;') : ' ' %> +<% else -%> +Comments for all articles +<% end -%> +

    -

    <%= pluralize(@comments.size, 'Unapproved Comment') %>

    +<% if @article -%> + <%= link_to_function "New comment", "$('new-comment-form').toggle()" %> + +<% end -%> -
      - <% @comments.reverse.each_with_index do |comment, i| -%> -
    • 0) %>" id="comment-<%= comment.id %>"> -

      <%= link_to comment.article.title, :controller => 'articles', :action => :edit, :id => comment.article %>

      -

      "<%= truncate strip_tags(comment.body), 255 %>"

      +
        + <% if @comments.any? %> + <% @comments.reverse.each do |comment| -%> +
      • " id="comment-<%= comment.id %>"> + + <% unless comment.body.blank? -%> +

        "<%= strip_tags(comment.body) %>"

        + <% end -%> - — <%= author_link_for comment %><%= %( (#{comment.author_email})) unless comment.author_email.blank? %> - + — <%= author_link_for comment %><%= %( (#{comment.author_email})) unless comment.author_email.blank? %> said <%= time_ago_in_words comment.created_at %> ago + + <%= link_to_remote 'Edit', :url => edit_article_comment_path(comment.article, comment), :method => :get %> | <% if comment.approved? -%> - <%= link_to_remote 'Unapprove', :url => { :action => 'unapprove', :controller => 'articles', :id => comment.article, :comment => comment } %> | + <%= link_to_remote 'Unapprove', :url => unapprove_article_comment_path(comment.article, comment) %> | <% else -%> - <%= link_to_remote 'Approve', :url => { :action => 'approve', :controller => 'articles', :id => comment.article, :comment => comment } %> | + <%= link_to_remote 'Approve', :url => approve_article_comment_path(comment.article, comment) %> | <% end -%> - <%= link_to_remote 'Delete', :url => { :action => 'destroy_comment', :controller => 'articles', :id => comment.article, :comment => comment } %> + <%= link_to_remote 'Delete', :url => article_comment_path(comment.article, comment), :method => :delete %>
      • <% end -%> + <% else %> +
      • This article has no <%= params[:filter].to_s.humanize.downcase %> comments.
      • + <% end %>
      + + +<% content_for :sidebar do %> + <% if @articles.size > 1 -%> +
      +

      Comments awaiting your approval

      +
        + <% @articles.each do |article, count| -%> + <% if @article.nil? || article.title != @article.title -%> +
      • <%= link_to "(#{count}) #{h(article.title)}", :controller => 'comments', :action => 'index', :article_id => article.id, :filter => :unapproved %>
      • + <% end -%> + <% end -%> +
      +
      + <% end -%> +<% end %> + + + diff -Nur mephisto-0.7.3/app/views/admin/comments/unapproved.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/unapproved.rhtml --- mephisto-0.7.3/app/views/admin/comments/unapproved.rhtml 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/unapproved.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,20 @@ +<% content_for :action_nav do %> + + + +<% end %> + +

      <%= pluralize(@comments.size, 'Unapproved Comment') %>

      + +
        + <% @comments.reverse.each_with_index do |comment, i| -%> + <%= render :partial => 'comment', :object => comment %> + <% end -%> +
      diff -Nur mephisto-0.7.3/app/views/admin/comments/update.rjs technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/update.rjs --- mephisto-0.7.3/app/views/admin/comments/update.rjs 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/comments/update.rjs 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,3 @@ + + page.replace "comment-#{@comment.id}", :partial => 'comment', :object => @comment + page.remove "edit-comment-#{@comment.id}" \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/design/_sidebar.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/design/_sidebar.rhtml --- mephisto-0.7.3/app/views/admin/design/_sidebar.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/design/_sidebar.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -3,10 +3,10 @@

      Modify a template by selecting it from the list below. Add a new layout by creating a Liquid template with an *_layout suffix (e.g custom_layout).

        - <% @theme.templates.template_types.each do |template| -%> + <% @theme.templates.template_types(@theme.extension).each do |template| -%>
      • <%= link_to template, url_for_theme(:controller => 'templates', :action => 'edit', :filename => template) %>
      • <% end -%> - <% @theme.templates.custom.each_with_index do |template, i| -%> + <% @theme.templates.custom(@theme.extension).each_with_index do |template, i| -%>
      • <%= delete_link :templates, template, "templates-#{i}" %> <%= link_to template, url_for_theme(:controller => 'templates', :action => 'edit', :filename => template) %> diff -Nur mephisto-0.7.3/app/views/admin/overview/_comment_event.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/overview/_comment_event.rhtml --- mephisto-0.7.3/app/views/admin/overview/_comment_event.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/overview/_comment_event.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -1,14 +1,22 @@ <% with_options :controller => 'articles', :id => event.article_id do |article| -%>
      • "> - <%= link_to event.article.title, :controller => 'articles', :action => 'comments', :id => event.article_id, :anchor => "comment-#{event.comment_id}" %> received a comment. +
        + <%= link_to event.article.title, :controller => 'articles', :action => 'comments', :id => event.article_id, :anchor => "comment-#{event.comment_id}" %> received a comment. - <%= event_time_for event, later %> - <% unless event.body.blank? -%> -

        "<%= truncate strip_tags(event.body), 100 %>"

        - <% end -%> - - — <%=h event.author %> - - + <%= event_time_for event, later %> + <% unless event.body.blank? -%> +

        "<%= truncate strip_tags(event.body), 100 %>"

        + <% end -%> + — <%=h event.author %> + + <% if event.comment -%> + <% if event.comment.approved? -%> + <%= link_to_remote 'Unapprove', :url => unapprove_article_comment_path(event.article_id, event.comment_id) %> | + <% else -%> + <%= link_to_remote 'Approve', :url => approve_article_comment_path(event.article_id, event.comment_id) %> | + <% end -%> + <%= link_to_remote 'Delete', :url => article_comment_path(event.article_id, event.comment_id), :method => :delete %> + <% end -%> +
      • <% end -%> diff -Nur mephisto-0.7.3/app/views/admin/overview/index.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/overview/index.rhtml --- mephisto-0.7.3/app/views/admin/overview/index.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/overview/index.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -9,7 +9,7 @@
      • <%= link_to "Upload asset", new_asset_path %>
      • <% if @articles.any? -%> -
      • <%= link_to "Moderate Comments", :controller => 'comments' %>
      • +
      • <%= link_to "Moderate Comments", moderate_path %>
      • <% end -%>
      diff -Nur mephisto-0.7.3/app/views/admin/plugins/_plugin.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/plugins/_plugin.rhtml --- mephisto-0.7.3/app/views/admin/plugins/_plugin.rhtml 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/plugins/_plugin.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,10 @@ + + + <% if plugin.configurable? -%> + <%= link_to plugin.mephisto_name, :action => 'show', :id => plugin.name %> + <% else -%> + <%=h plugin.mephisto_name %> + <% end -%> + + <%= plugin.configurable? ? link_to(image_tag('/images/mephisto/icons/8-em-check.png', :style => 'vertical-align: middle'), :action => "show", :id => plugin.name) : ' ' %> + diff -Nur mephisto-0.7.3/app/views/admin/plugins/index.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/plugins/index.rhtml --- mephisto-0.7.3/app/views/admin/plugins/index.rhtml 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/plugins/index.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,31 @@ +<% if @plugins.size > 0 -%> + + + + + + + + + + + <%= render :partial => 'plugin', :collection => @plugins -%> + +
      PluginConfigurable? 
      + +<% end %> + +<% content_for :action_nav do %> + + + +<% end -%> + +<% content_for :sidebar do %> +
      +Configurable plugins may include modifiable properties, notes, homepage, author, and version information. +
      +<% end %> \ No newline at end of file diff -Nur mephisto-0.7.3/app/views/admin/plugins/show.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/plugins/show.rhtml --- mephisto-0.7.3/app/views/admin/plugins/show.rhtml 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/plugins/show.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,54 @@ + +<% content_for :sidebar do %> +
      +

      Errata

      + <% unless @plugin.notes.blank? -%> +

      Notes:

      +

      <%= simple_format @plugin.notes %>

      +
      + <% end %> + <% unless @plugin.author.blank? -%> +

      Author: <%=h @plugin.author %>

      + <% end -%> + <% unless @plugin.homepage.blank? -%> +

      Homepage: <%= @plugin.homepage %>

      + <% end -%> + <% unless @plugin.version.blank? -%> +

      Ver.: <%= @plugin.version %>

      + <% end -%> +
      +<% end %> + +<% content_for :action_nav do %> + +<% end %> + +<% content_for :form do -%> + <%= form_tag({:action => 'update', :id => @plugin.name}, {:id => 'plugin-config-form'}) %> +<% end -%> + +<% if @plugin.default_options.any? -%> +
      +
      +
      + <% @plugin.default_options.keys.each do |key| %> +
      <%= send "#{@plugin.default_options[key]}_tag", "options[#{key}]", @plugin.send(key) %>
      + <% end %> +
      + +

      + <%= submit_tag %> +

      +
      +<% else -%> +No configuration listed (perhaps not needed). +<% end -%> diff -Nur mephisto-0.7.3/app/views/admin/settings/index.rhtml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/settings/index.rhtml --- mephisto-0.7.3/app/views/admin/settings/index.rhtml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/admin/settings/index.rhtml 2008-03-31 02:18:56.000000000 -0400 @@ -3,6 +3,7 @@ - \ No newline at end of file + diff -Nur mephisto-0.7.3/app/views/mephisto/_article.rxml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/mephisto/_article.rxml --- mephisto-0.7.3/app/views/mephisto/_article.rxml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/app/views/mephisto/_article.rxml 2008-03-31 02:18:56.000000000 -0400 @@ -5,6 +5,12 @@ xm.id "tag:#{request.host_with_port},#{article.updated_at.to_date.to_s :db}:#{article.id}:#{article.version}" xm.published article.published_at.xmlschema if article.published_at xm.updated article.updated_at.xmlschema + article.sections.each do |section| + xm.category "term" => section.name unless section.home? + end if article.respond_to?(:sections) + article.tags.each do |tag| + xm.category "term" => tag.name + end xm.link "rel" => "alternate", "type" => "text/html", "href" => "http://#{request.host_with_port}#{site.permalink_for(article)}" xm.title strip_tags(article.title) unless article.excerpt_html.blank? diff -Nur mephisto-0.7.3/config/environment.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/environment.rb --- mephisto-0.7.3/config/environment.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/environment.rb 2008-03-31 02:18:56.000000000 -0400 @@ -10,16 +10,22 @@ # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') +require File.join(File.dirname(__FILE__), '../vendor/plugins/engines/boot') +require File.join(File.dirname(__FILE__), '../lib/mephisto/plugin') # requires vendor-loaded redcloth require 'RedCloth-3.0.4/lib/redcloth' unless Object.const_defined?(:RedCloth) + Rails::Initializer.run do |config| # Settings in config/environments/* take precedence those specified here # Skip frameworks you're not going to use - # config.frameworks -= [ :action_web_service ] + config.frameworks -= [ :active_resource ] config.load_paths += %W( #{RAILS_ROOT}/app/cachers #{RAILS_ROOT}/app/drops #{RAILS_ROOT}/app/filters ) + + # NFI why this is here. find and eradicate the bug. + config.load_paths += %W( #{RAILS_ROOT}/vendor/rails/actionwebservice/lib ) # Force all environments to use the same logger level # (by default production uses :info, the others :debug) @@ -27,7 +33,8 @@ # Use the database for sessions instead of the file system # (create the session table with 'rake create_sessions_table') - config.action_controller.session_store = :active_record_store + # config.action_controller.session_store = :active_record_store + config.action_controller.session = { :session_key => "_mephisto_session", :secret => "bd088a0f5b476fe5a2c02653a93ed14a95a8396829ce4e726ee77553ab6438a98d0f3e6d80fc6b120370ba047f28e09f71543ae5f842365e5070e7db51fb2cb9" } # Make Active Record use UTC-base instead of local time config.active_record.default_timezone = :utc @@ -37,43 +44,5 @@ config.active_record.schema_format = :ruby end -# Include your application configuration below -require 'mephisto_init' - -# Set this if you're running under a sub directory -# ActionController::AbstractRequest.relative_url_root = '/blog' - -# turn this on to get detailed cache sweeper logging in production mode -# Site.cache_sweeper_tracing = true - -# Enable if you want to host multiple sites on this app -# Site.multi_sites_enabled = true - -# shouldn't need to set the host, it's set automatically -UserMailer.default_url_options[:host] = 'localhost:3000' -UserMailer.mail_from = 'webmaster@localhost' - -# OPTIONAL - Redirections -# Deny a route by immediately returning a 404 -# -# Mephisto::Routing.deny 'articles/trackback/*' # return 404 -# -# Specify multiple denied routes: -# -# Mephisto::Routing.deny 'articles/trackback/*', 'monkey/foo/*' -# -# Redirect elsewhere. You can fill in variables marked by ? or * with variable names beginning with : -# -# Redirect /old/foo to /new/foo and /old/foo/bar to /new/foo/bar -# -# Mephisto::Routing.redirect 'old/*' => 'new/$1' -# -# Redirect with a more specific set of variables -# -# Mephisto::Routing.redirect 'article/?/?/?' => 'new/$2/$1/$3' - -# Multiple redirections at a time -# -# Mephisto::Routing.redirect \ -# 'old/*' => 'new/$1', -# 'article/?/?/?' => 'new/$2/$1/$3' \ No newline at end of file +# Don't update this file, make custom tweaks in config/initializers/custom.rb, +# or create your own file in config/initializers \ No newline at end of file diff -Nur mephisto-0.7.3/config/environments/development.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/environments/development.rb --- mephisto-0.7.3/config/environments/development.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/environments/development.rb 2008-03-31 02:18:56.000000000 -0400 @@ -8,9 +8,6 @@ # Log error messages when you accidentally call methods on nil. config.whiny_nils = true -# Enable the breakpoint server that script/breakpointer connects to -config.breakpoint_server = true - # Show full error reports and disable caching config.action_controller.consider_all_requests_local = true config.action_controller.perform_caching = false diff -Nur mephisto-0.7.3/config/initializers/custom.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/custom.rb --- mephisto-0.7.3/config/initializers/custom.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/custom.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,40 @@ +# Set this if you're running under a sub directory +# ActionController::AbstractRequest.relative_url_root = '/blog' + +# turn this on to get detailed cache sweeper logging in production mode +# Site.cache_sweeper_tracing = true + +# Enable if you want to host multiple sites on this app +# Site.multi_sites_enabled = true + +# shouldn't need to set the host, it's set automatically +UserMailer.default_url_options[:host] = 'localhost:3000' +UserMailer.mail_from = 'webmaster@localhost' + +# defaults to ImageScience, then RMagick, then nothing +# ASSET_IMAGE_PROCESSOR = :image_science || :rmagick || :none + +# OPTIONAL - Redirections +# Deny a route by immediately returning a 404 +# +# Mephisto::Routing.deny 'articles/trackback/*' # return 404 +# +# Specify multiple denied routes: +# +# Mephisto::Routing.deny 'articles/trackback/*', 'monkey/foo/*' +# +# Redirect elsewhere. You can fill in variables marked by ? or * with variable names beginning with : +# +# Redirect /old/foo to /new/foo and /old/foo/bar to /new/foo/bar +# +# Mephisto::Routing.redirect 'old/*' => 'new/$1' +# +# Redirect with a more specific set of variables +# +# Mephisto::Routing.redirect 'article/?/?/?' => 'new/$2/$1/$3' + +# Multiple redirections at a time +# +# Mephisto::Routing.redirect \ +# 'old/*' => 'new/$1', +# 'article/?/?/?' => 'new/$2/$1/$3' \ No newline at end of file diff -Nur mephisto-0.7.3/config/initializers/mephisto_init.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/mephisto_init.rb --- mephisto-0.7.3/config/initializers/mephisto_init.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/mephisto_init.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,44 @@ +# this is for standard library loading and configuration. All the hardcore monkey patching is in the mephisto plugin. +require 'tzinfo' +require 'zip/zipfilesystem' +require 'action_controller/dispatcher' +require 'coderay' +require 'ruby_pants' +require 'xmlrpc_patch' + +ActiveRecord::Base.observers = [:article_observer, :comment_observer] + +# temporarily moved to vendor/plugins/aaa/init.rb to make sure +# it's loaded before all other plugins +# Object::RAILS_PATH = Pathname.new(File.expand_path(RAILS_ROOT)) + +require 'mephisto' + +class ActionController::Dispatcher + def self.register_liquid_tags + Mephisto.liquid_filters.each { |mod| Liquid::Template.register_filter mod } + Mephisto.liquid_tags.each { |name, klass| Liquid::Template.register_tag name, klass } + end + + def cleanup_application_with_plugins(force = false) + returning cleanup_application_without_plugins(force) do + self.class.register_liquid_tags + end + end + + alias_method_chain :cleanup_application, :plugins +end + +ActionController::Dispatcher.register_liquid_tags + +Inflector.inflections do |inflect| + #inflect.plural /^(ox)$/i, '\1en' + #inflect.singular /^(ox)en/i, '\1' + #inflect.irregular 'person', 'people' + inflect.uncountable %w( audio ) +end + +Engines::Plugin::Config.set_table_name 'mephisto_plugins' + +Dependencies.autoloaded_constants.delete "Mephisto" +Dependencies.autoloaded_constants.delete "Mephisto::Plugin" diff -Nur mephisto-0.7.3/config/initializers/metaprogramming.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/metaprogramming.rb --- mephisto-0.7.3/config/initializers/metaprogramming.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/metaprogramming.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,42 @@ +# need to make pathname safe for windows! +Pathname.class_eval do + def read(*args) + returning [] do |s| + File.open(@path, 'rb') { |f| s << f.read } + end.to_s + end +end + +Symbol.class_eval do + def to_liquid + to_s + end +end + +# http://rails.techno-weenie.net/tip/2005/12/23/make_fixtures +ActiveRecord::Base.class_eval do + # person.dom_id #-> "person-5" + # new_person.dom_id #-> "person-new" + # new_person.dom_id(:bare) #-> "new" + # person.dom_id(:person_name) #-> "person-name-5" + def dom_id(prefix=nil) + display_id = new_record? ? "new" : id + prefix ||= self.class.name.underscore + prefix != :bare ? "#{prefix.to_s.dasherize}-#{display_id}" : display_id + end + + # Write a fixture file for testing + def self.to_fixture(fixture_path = nil) + File.open(File.expand_path(fixture_path || "test/fixtures/#{table_name}.yml", RAILS_ROOT), 'w') do |out| + YAML.dump find(:all).inject({}) { |hsh, record| hsh.merge(record.id => record.attributes) }, out + end + end + + expiring_attr_reader :referenced_cache_key, '"[#{[id, self.class.name] * ":"}]"' +end + +class Object + def tap + yield self; self; + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/config/initializers/templating.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/templating.rb --- mephisto-0.7.3/config/initializers/templating.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/templating.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,32 @@ +module Liquid + AllowedVariableCharacters = /[a-zA-Z_.-]/ unless Liquid.const_defined?(:AllowedVariableCharacters) +end + +Liquid::For.send :include, Mephisto::Liquid::ForWithSorting + +WhiteListHelper.tags.merge %w(table tr td) + +class MissingTemplateError < StandardError + attr_reader :template_type, :templates + def initialize(template_type, templates) + @template_type = template_type + @templates = templates + super "No template found for #{template_type}, checked #{templates.to_sentence}." + end +end + +class MissingThemesError < StandardError + attr_reader :site + def initialize(site) + @site = site + super "No themes found in '#{site.theme_path.to_s}/#{site.current_theme_path}'. This must be set correctly in the site settings." + end +end + +class ThemeError < StandardError + attr_reader :theme + def initialize(theme, message) + @theme = theme + super message + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/config/initializers/time_hacks.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/time_hacks.rb --- mephisto-0.7.3/config/initializers/time_hacks.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/time_hacks.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,54 @@ +# Time.now.to_ordinalized_s :long +# => "February 28th, 2006 21:10" +module ActiveSupport::CoreExtensions::Time::Conversions + def to_ordinalized_s(format = :default) + format = ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS[format] + return to_default_s if format.nil? + strftime(format.gsub(/%d/, '_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize } + end +end + +ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update \ + :standard => '%B %d, %Y @ %I:%M %p', + :stub => '%B %d', + :time_only => '%I:%M %p', + :plain => '%B %d %I:%M %p', + :mdy => '%B %d, %Y', + :my => '%B %Y' + +class Time + class << self + # Used for getting multifield attributes like those generated by a + # select_datetime into a new Time object. For example if you have + # following params={:meetup=>{:"time(1i)=>..."}} just do + # following: + # + # Time.parse_from_attributes(params[:meetup], :time) + def parse_from_attributes(attrs, field, method=:gm) + attrs = attrs.keys.sort.grep(/^#{field.to_s}\(.+\)$/).map { |k| attrs[k] } + attrs.any? ? Time.send(method, *attrs) : nil + end + + def delta(year, month = nil, day = nil) + from = Time.local(year, month || 1, day || 1) + + to = + if !day.blank? + from.advance :days => 1 + elsif !month.blank? + from.advance :months => 1 + else + from.advance :years => 1 + end + return [from.midnight, to.midnight-1] + end + end + + def to_delta(delta_type = :day) + case delta_type + when :year then self.class.delta(year) + when :month then self.class.delta(year, month) + else self.class.delta(year, month, day) + end + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/config/initializers/xml_simple_doctype_fix.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/xml_simple_doctype_fix.rb --- mephisto-0.7.3/config/initializers/xml_simple_doctype_fix.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/config/initializers/xml_simple_doctype_fix.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,2 @@ +# http://tinyurl.com/377j6s +REXML::Document.class_eval { def doctype() nil end } \ No newline at end of file diff -Nur mephisto-0.7.3/db/migrate/033_user_hostile_template_migration.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/033_user_hostile_template_migration.rb --- mephisto-0.7.3/db/migrate/033_user_hostile_template_migration.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/033_user_hostile_template_migration.rb 2008-03-31 02:18:56.000000000 -0400 @@ -5,7 +5,7 @@ class DbFile < ActiveRecord::Base; end class Attachment < ActiveRecord::Base belongs_to :site - acts_as_attachment + has_attachment end class Avatar < Attachment; end class Asset < Attachment; end diff -Nur mephisto-0.7.3/db/migrate/068_moment_of_silence.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/068_moment_of_silence.rb --- mephisto-0.7.3/db/migrate/068_moment_of_silence.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/068_moment_of_silence.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,8 @@ +class MomentOfSilence < ActiveRecord::Migration + def self.up + # makes up for migration #68 in the stable branch, which is the same as #072 on trunk + end + + def self.down + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/db/migrate/069_add_mephisto_plugins.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/069_add_mephisto_plugins.rb --- mephisto-0.7.3/db/migrate/069_add_mephisto_plugins.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/069_add_mephisto_plugins.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,13 @@ +class AddMephistoPlugins < ActiveRecord::Migration + def self.up + create_table :mephisto_plugins do |t| + t.column :name, :string + t.column :options, :text + t.column :type, :string + end + end + + def self.down + drop_table :mephisto_plugins + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/db/migrate/070_remove_site_search_layout.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/070_remove_site_search_layout.rb --- mephisto-0.7.3/db/migrate/070_remove_site_search_layout.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/070_remove_site_search_layout.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,9 @@ +class RemoveSiteSearchLayout < ActiveRecord::Migration + def self.up + remove_column "sites", "search_layout" + end + + def self.down + add_column "sites", "search_layout", :string + end +end diff -Nur mephisto-0.7.3/db/migrate/071_create_assigned_assets.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/071_create_assigned_assets.rb --- mephisto-0.7.3/db/migrate/071_create_assigned_assets.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/071_create_assigned_assets.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,20 @@ +class CreateAssignedAssets < ActiveRecord::Migration + def self.up + create_table :assigned_assets do |t| + t.column :article_id, :integer + t.column :asset_id, :integer + t.column :position, :integer + t.column :label, :string + t.column :created_at, :datetime + t.column :active, :boolean + end + add_column "contents", "assets_count", :integer, :default => 0 + add_column "content_versions", "assets_count", :integer, :default => 0 + end + + def self.down + drop_table :assigned_assets + remove_column "contents", "assets_count" + remove_column "content_versions", "assets_count" + end +end diff -Nur mephisto-0.7.3/db/migrate/072_filter_current_comments.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/072_filter_current_comments.rb --- mephisto-0.7.3/db/migrate/072_filter_current_comments.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/072_filter_current_comments.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,14 @@ +class FilterCurrentComments < ActiveRecord::Migration + def self.up + transaction do + Comment.find(:all).each do |c| + Comment.update_all ['author = ?, author_url = ?, author_email = ?, author_ip = ?, user_agent = ?, referrer = ?', + CGI::escapeHTML(c.author), CGI::escapeHTML(c.author_url), CGI::escapeHTML(c.author_email), CGI::escapeHTML(c.author_ip), + CGI::escapeHTML(c.user_agent), CGI::escapeHTML(c.referrer)], ['id = ?', c.id] + end + end + end + + def self.down + end +end diff -Nur mephisto-0.7.3/db/migrate/073_add_some_indexing_idiot.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/073_add_some_indexing_idiot.rb --- mephisto-0.7.3/db/migrate/073_add_some_indexing_idiot.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/073_add_some_indexing_idiot.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,14 @@ +class AddSomeIndexingIdiot < ActiveRecord::Migration + def self.up + return if indexes(:assigned_sections).any? { |idx| idx.name == 'idx_a_sections_article_section' } + add_index :assigned_sections, [:article_id, :section_id], :name => :idx_a_sections_article_section + add_index :contents, :published_at, :name => :idx_articles_published + add_index :contents, [:article_id, :approved, :type], :name => :idx_comments + end + + def self.down + remove_index :assigned_sections, :name => :idx_a_sections_article_section + remove_index :contents, :name => :idx_articles_published + remove_index :contents, :name => :idx_comments + end +end diff -Nur mephisto-0.7.3/db/migrate/074_remove_orphan_comments.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/074_remove_orphan_comments.rb --- mephisto-0.7.3/db/migrate/074_remove_orphan_comments.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/074_remove_orphan_comments.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,9 @@ +class RemoveOrphanComments < ActiveRecord::Migration + def self.up + article_ids = select_values("SELECT id FROM contents WHERE type = 'Article'") + Comment.delete_all(['article_id NOT IN (?)', article_ids]) + end + + def self.down + end +end diff -Nur mephisto-0.7.3/db/migrate/075_drop_session_table.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/075_drop_session_table.rb --- mephisto-0.7.3/db/migrate/075_drop_session_table.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/migrate/075_drop_session_table.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,16 @@ +class DropSessionTable < ActiveRecord::Migration + def self.up + remove_index :sessions, :name => :sessions_session_id_index + drop_table :sessions + end + + def self.down + create_table "sessions", :force => true do |t| + t.string "session_id" + t.text "data" + t.datetime "updated_at" + end + + add_index "sessions", ["session_id"], :name => "sessions_session_id_index" + end +end diff -Nur mephisto-0.7.3/db/schema.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/schema.rb --- mephisto-0.7.3/db/schema.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/db/schema.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,183 +1,212 @@ -# This file is autogenerated. Instead of editing this file, please use the -# migrations feature of ActiveRecord to incrementally modify your database, and +# This file is auto-generated from the current state of the database. Instead of editing this file, +# please use the migrations feature of ActiveRecord to incrementally modify your database, and # then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your database schema. If you need +# to create the application database on another system, you should be using db:schema:load, not running +# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 67) do +ActiveRecord::Schema.define(:version => 75) do create_table "assets", :force => true do |t| - t.column "content_type", :string - t.column "filename", :string - t.column "size", :integer - t.column "parent_id", :integer - t.column "thumbnail", :string - t.column "width", :integer - t.column "height", :integer - t.column "site_id", :integer - t.column "created_at", :datetime - t.column "title", :string - t.column "thumbnails_count", :integer, :default => 0 - t.column "user_id", :integer + t.string "content_type" + t.string "filename" + t.integer "size" + t.integer "parent_id" + t.string "thumbnail" + t.integer "width" + t.integer "height" + t.integer "site_id" + t.datetime "created_at" + t.string "title" + t.integer "thumbnails_count", :default => 0 + t.integer "user_id" + end + + create_table "assigned_assets", :force => true do |t| + t.integer "article_id" + t.integer "asset_id" + t.integer "position" + t.string "label" + t.datetime "created_at" + t.boolean "active" end create_table "assigned_sections", :force => true do |t| - t.column "article_id", :integer - t.column "section_id", :integer - t.column "position", :integer, :default => 1 + t.integer "article_id" + t.integer "section_id" + t.integer "position", :default => 1 end + add_index "assigned_sections", ["article_id", "section_id"], :name => "idx_a_sections_article_section" + create_table "cached_pages", :force => true do |t| - t.column "url", :string - t.column "references", :text - t.column "updated_at", :datetime - t.column "site_id", :integer - t.column "cleared_at", :datetime + t.string "url" + t.text "references" + t.datetime "updated_at" + t.integer "site_id" + t.datetime "cleared_at" end create_table "content_versions", :force => true do |t| - t.column "content_id", :integer - t.column "version", :integer - t.column "article_id", :integer - t.column "user_id", :integer - t.column "title", :string - t.column "permalink", :string - t.column "excerpt", :text - t.column "body", :text - t.column "excerpt_html", :text - t.column "body_html", :text - t.column "created_at", :datetime - t.column "updated_at", :datetime - t.column "published_at", :datetime - t.column "author", :string, :limit => 100 - t.column "author_url", :string - t.column "author_email", :string - t.column "author_ip", :string, :limit => 100 - t.column "comments_count", :integer, :default => 0 - t.column "updater_id", :integer - t.column "versioned_type", :string, :limit => 20 - t.column "site_id", :integer - t.column "approved", :boolean, :default => false - t.column "comment_age", :integer, :default => 0 - t.column "filter", :string - t.column "user_agent", :string - t.column "referrer", :string + t.integer "content_id" + t.integer "version" + t.integer "article_id" + t.integer "user_id" + t.string "title" + t.string "permalink" + t.text "excerpt" + t.text "body" + t.text "excerpt_html" + t.text "body_html" + t.datetime "created_at" + t.datetime "updated_at" + t.datetime "published_at" + t.string "author", :limit => 100 + t.string "author_url" + t.string "author_email" + t.string "author_ip", :limit => 100 + t.integer "comments_count", :default => 0 + t.integer "updater_id" + t.string "versioned_type", :limit => 20 + t.integer "site_id" + t.boolean "approved", :default => false + t.integer "comment_age", :default => 0 + t.string "filter" + t.string "user_agent" + t.string "referrer" + t.integer "assets_count", :default => 0 end create_table "contents", :force => true do |t| - t.column "article_id", :integer - t.column "user_id", :integer - t.column "title", :string - t.column "permalink", :string - t.column "excerpt", :text - t.column "body", :text - t.column "excerpt_html", :text - t.column "body_html", :text - t.column "created_at", :datetime - t.column "updated_at", :datetime - t.column "published_at", :datetime - t.column "type", :string, :limit => 20 - t.column "author", :string, :limit => 100 - t.column "author_url", :string - t.column "author_email", :string - t.column "author_ip", :string, :limit => 100 - t.column "comments_count", :integer, :default => 0 - t.column "updater_id", :integer - t.column "version", :integer - t.column "site_id", :integer - t.column "approved", :boolean, :default => false - t.column "comment_age", :integer, :default => 0 - t.column "filter", :string - t.column "user_agent", :string - t.column "referrer", :string + t.integer "article_id" + t.integer "user_id" + t.string "title" + t.string "permalink" + t.text "excerpt" + t.text "body" + t.text "excerpt_html" + t.text "body_html" + t.datetime "created_at" + t.datetime "updated_at" + t.datetime "published_at" + t.string "type", :limit => 20 + t.string "author", :limit => 100 + t.string "author_url" + t.string "author_email" + t.string "author_ip", :limit => 100 + t.integer "comments_count", :default => 0 + t.integer "updater_id" + t.integer "version" + t.integer "site_id" + t.boolean "approved", :default => false + t.integer "comment_age", :default => 0 + t.string "filter" + t.string "user_agent" + t.string "referrer" + t.integer "assets_count", :default => 0 end + add_index "contents", ["published_at"], :name => "idx_articles_published" + add_index "contents", ["article_id", "approved", "type"], :name => "idx_comments" + create_table "events", :force => true do |t| - t.column "mode", :string - t.column "user_id", :integer - t.column "article_id", :integer - t.column "title", :text - t.column "body", :text - t.column "created_at", :datetime - t.column "author", :string, :limit => 100 - t.column "comment_id", :integer - t.column "site_id", :integer + t.string "mode" + t.integer "user_id" + t.integer "article_id" + t.text "title" + t.text "body" + t.datetime "created_at" + t.string "author", :limit => 100 + t.integer "comment_id" + t.integer "site_id" + end + + create_table "feedbacks", :force => true do |t| + t.integer "site_id" + t.string "name" + t.string "email" + t.text "body" + t.string "key" + t.datetime "created_at" end create_table "memberships", :force => true do |t| - t.column "site_id", :integer - t.column "user_id", :integer - t.column "created_at", :datetime - t.column "admin", :boolean, :default => false + t.integer "site_id" + t.integer "user_id" + t.datetime "created_at" + t.boolean "admin", :default => false end - create_table "sections", :force => true do |t| - t.column "name", :string - t.column "show_paged_articles", :boolean, :default => false - t.column "articles_per_page", :integer, :default => 15 - t.column "layout", :string - t.column "template", :string - t.column "site_id", :integer - t.column "path", :string - t.column "articles_count", :integer, :default => 0 - t.column "archive_path", :string - t.column "archive_template", :string - t.column "position", :integer, :default => 1 - end - - create_table "sessions", :force => true do |t| - t.column "session_id", :string - t.column "data", :text - t.column "updated_at", :datetime + create_table "mephisto_plugins", :force => true do |t| + t.string "name" + t.text "options" + t.string "type" end - add_index "sessions", ["session_id"], :name => "sessions_session_id_index" + create_table "sections", :force => true do |t| + t.string "name" + t.boolean "show_paged_articles", :default => false + t.integer "articles_per_page", :default => 15 + t.string "layout" + t.string "template" + t.integer "site_id" + t.string "path" + t.integer "articles_count", :default => 0 + t.string "archive_path" + t.string "archive_template" + t.integer "position", :default => 1 + end create_table "sites", :force => true do |t| - t.column "title", :string - t.column "subtitle", :string - t.column "email", :string - t.column "ping_urls", :text - t.column "articles_per_page", :integer, :default => 15 - t.column "host", :string - t.column "akismet_key", :string, :limit => 100 - t.column "akismet_url", :string - t.column "approve_comments", :boolean - t.column "comment_age", :integer - t.column "timezone", :string - t.column "filter", :string - t.column "permalink_style", :string - t.column "search_path", :string - t.column "tag_path", :string - t.column "search_layout", :string - t.column "tag_layout", :string - t.column "current_theme_path", :string + t.string "title" + t.string "subtitle" + t.string "email" + t.text "ping_urls" + t.integer "articles_per_page", :default => 15 + t.string "host" + t.boolean "approve_comments" + t.integer "comment_age" + t.string "timezone" + t.string "filter" + t.string "permalink_style" + t.string "search_path" + t.string "tag_path" + t.string "tag_layout" + t.string "current_theme_path" + t.string "akismet_key", :limit => 100 + t.string "akismet_url" end add_index "sites", ["host"], :name => "index_sites_on_host" create_table "taggings", :force => true do |t| - t.column "tag_id", :integer - t.column "taggable_id", :integer - t.column "taggable_type", :string + t.integer "tag_id" + t.integer "taggable_id" + t.string "taggable_type" end create_table "tags", :force => true do |t| - t.column "name", :string + t.string "name" end create_table "users", :force => true do |t| - t.column "login", :string, :limit => 40 - t.column "email", :string, :limit => 100 - t.column "crypted_password", :string, :limit => 40 - t.column "salt", :string, :limit => 40 - t.column "activation_code", :string, :limit => 40 - t.column "activated_at", :datetime - t.column "created_at", :datetime - t.column "updated_at", :datetime - t.column "deleted_at", :datetime - t.column "token", :string - t.column "token_expires_at", :datetime - t.column "filter", :string - t.column "admin", :boolean, :default => false + t.string "login", :limit => 40 + t.string "email", :limit => 100 + t.string "crypted_password", :limit => 40 + t.string "salt", :limit => 40 + t.string "activation_code", :limit => 40 + t.datetime "activated_at" + t.datetime "created_at" + t.datetime "updated_at" + t.datetime "deleted_at" + t.string "token" + t.datetime "token_expires_at" + t.string "filter" + t.boolean "admin", :default => false end end diff -Nur mephisto-0.7.3/lib/authenticated_system.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/authenticated_system.rb --- mephisto-0.7.3/lib/authenticated_system.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/authenticated_system.rb 2008-03-31 02:18:56.000000000 -0400 @@ -51,7 +51,7 @@ # move to the last store_location call or to the passed default one def redirect_back_or_default(default) - location_stored? ? redirect_to_url(session[:return_to]) : redirect_to(default) + redirect_to(location_stored? ? session[:return_to] : default) session[:return_to] = nil end diff -Nur mephisto-0.7.3/lib/format.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/format.rb --- mephisto-0.7.3/lib/format.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/format.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,5 +1,6 @@ module Format - DOMAIN = /^([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)+((a[cdefgilmnoqrstuwxz]|aero|arpa)|(b[abdefghijmnorstvwyz]|biz)|(c[acdfghiklmnorsuvxyz]|cat|com|coop)|d[ejkmoz]|(e[ceghrstu]|edu)|f[ijkmor]|(g[abdefghilmnpqrstuwy]|gov)|h[kmnrtu]|(i[delmnoqrst]|info|int)|(j[emop]|jobs)|k[eghimnprwyz]|l[abcikrstuvy]|(m[acdghklmnopqrstuvwxyz]|mil|mobi|museum)|(n[acefgilopruz]|name|net)|(om|org)|(p[aefghklmnrstwy]|pro)|qa|r[eouw]|s[abcdeghijklmnortvyz]|(t[cdfghjklmnoprtvwz]|travel)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])$/ unless const_defined?(:DOMAIN) + # yes this is valid ruby, even if textmate's highlighter can't grok it + DOMAIN = /^([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)+((a[cdefgilmnoqrstuwxz]|aero|arpa)|(b[abdefghijmnorstvwyz]|biz)|(c[acdfghiklmnorsuvxyz]|cat|com|coop)|d[ejkmoz]|(e[ceghrstu]|edu)|f[ijkmor]|(g[abdefghilmnpqrstuwy]|gov)|(h[kmnrtu]#{RAILS_ENV=='test'?'|host':''})|(i[delmnoqrst]|info|int)|(j[emop]|jobs)|k[eghimnprwyz]|l[abcikrstuvy]|(m[acdghklmnopqrstuvwxyz]|mil|mobi|museum)|(n[acefgilopruz]|name|net)|(om|org)|(p[aefghklmnrstwy]|pro)|qa|r[eouw]|s[abcdeghijklmnortvyz]|(t[cdfghjklmnoprtvwz]|travel)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])$/ unless const_defined?(:DOMAIN) STRING = /^[a-z0-9-]+$/ EMAIL = /(\A(\s*)\Z)|(\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z)/i end \ No newline at end of file diff -Nur mephisto-0.7.3/lib/mephisto/directory_plugin.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/directory_plugin.rb --- mephisto-0.7.3/lib/mephisto/directory_plugin.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/directory_plugin.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,26 @@ +# Object model of a plugin in plugins/vendor. May or may not have an internal Mephisto::Plugins::Plugin (an AR). +module Mephisto + class DirectoryPlugin + @@filter = /^mephisto_(\w+)$/ + attr_accessor :plugin, :path + + def self.scan + Dir.new("#{RAILS_ROOT}/vendor/plugins/").collect do |entry| + # don't list "invisible" plugins nor directories/files hidden on the filesystem + entry =~ @@filter ? new($1) : nil + end.compact + end + + def initialize(path) + @path = path + end + + def klass + @klass ||= Mephisto::Plugin[@path] rescue :false + end + + def configurable? + klass != :false + end + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/lib/mephisto/dispatcher.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/dispatcher.rb --- mephisto-0.7.3/lib/mephisto/dispatcher.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/dispatcher.rb 2008-03-31 02:18:56.000000000 -0400 @@ -112,8 +112,8 @@ old_published = article.published_at article.published_at ||= Time.now.utc article.article_id ||= article.id - permalink_style.split('/').inject [''] do |s, piece| - s << ((name = variable_format?(piece)) && PERMALINK_OPTIONS.keys.include?(name.to_sym) ? variable_value_for(article, name) : piece) + '/' + permalink_style.split('/').collect! do |piece| + (name = variable_format?(piece)) && PERMALINK_OPTIONS.keys.include?(name.to_sym) ? variable_value_for(article, name) : piece end.join('/') ensure article.published_at = old_published diff -Nur mephisto-0.7.3/lib/mephisto/liquid/comment_form.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/liquid/comment_form.rb --- mephisto-0.7.3/lib/mephisto/liquid/comment_form.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/liquid/comment_form.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,10 +1,18 @@ module Mephisto module Liquid class CommentForm < ::Liquid::Block - cattr_accessor :article + def self.article + Thread.current[:comment_form_article] + end + + def self.article=(value) + Thread.current[:comment_form_article] = value + end + # Provides the required input, error, and form fields + # TODO: make this more accessible to users (let them mess it up, rather than forcing a structure on them) def render(context) - return '' unless article.accept_comments? + return '' unless self.class.article.accept_comments? result = [] context.stack do if context['message'].blank? diff -Nur mephisto-0.7.3/lib/mephisto/liquid/for_with_sorting.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/liquid/for_with_sorting.rb --- mephisto-0.7.3/lib/mephisto/liquid/for_with_sorting.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/liquid/for_with_sorting.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,26 @@ +module Mephisto + module Liquid + module ForWithSorting + def self.included(base) + base.alias_method_chain :render, :sorting + end + + def render_with_sorting(context) + context.registers[:for] ||= Hash.new(0) + + collection = context[@collection_name] + collection = collection.to_a if collection.is_a?(Range) + + return '' if collection.nil? or collection.empty? + + if @attributes['sort_by'] + sorted_name = "sorted_#{@collection_name.tr '.', '_'}" + context[sorted_name] = collection.sort_by { |i| i[@attributes['sort_by']] } + @collection_name = sorted_name + end + + render_without_sorting(context) + end + end + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/lib/mephisto/liquid/liquid_template.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/liquid/liquid_template.rb --- mephisto-0.7.3/lib/mephisto/liquid/liquid_template.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/liquid/liquid_template.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,33 @@ +module Mephisto + module Liquid + class LiquidTemplate + + def initialize(site) + @site = site + end + + def render(section, layout, template, assigns ={}, controller = nil) + parse_inner_template(template, assigns, controller) + parse_template(layout, assigns, controller) + end + + def parse_template(template, assigns, controller) + # give the include tag access to files in the site's fragments directory + ::Liquid::Template.file_system = ::Liquid::LocalFileSystem.new(File.join(@site.theme.path, 'templates')) + tmpl = ::Liquid::Template.parse(template.read.to_s) + returning tmpl.render(assigns, :registers => {:controller => controller}) do |result| + yield tmpl, result if block_given? + end + end + + def parse_inner_template(template, assigns, controller) + parse_template(template, assigns, controller) do |tmpl, result| + # Liquid::Template takes a copy of the assigns. + # merge any new values in to the assigns and pass them to the layout + tmpl.assigns.each { |k, v| assigns[k] = v } if tmpl.respond_to?(:assigns) + assigns['content_for_layout'] = result + end + end + end + end +end diff -Nur mephisto-0.7.3/lib/mephisto/liquid/url_methods.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/liquid/url_methods.rb --- mephisto-0.7.3/lib/mephisto/liquid/url_methods.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/liquid/url_methods.rb 2008-03-31 02:18:56.000000000 -0400 @@ -12,8 +12,10 @@ def absolute_url(*path) return "#{relative_url_root}/" if path.empty? + is_absolute = path.first.to_s[/(^\/)/] path.collect! { |p| p.to_s.gsub /(^\/)|(\/$)/, '' } - path.empty? ? "#{relative_url_root}/" : path.unshift(relative_url_root).join('/') + path.unshift(is_absolute ? '' : relative_url_root) + path * '/' end end end diff -Nur mephisto-0.7.3/lib/mephisto/plugin.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/plugin.rb --- mephisto-0.7.3/lib/mephisto/plugin.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/plugin.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,58 @@ +require File.join(File.dirname(__FILE__), 'plugin_about_patch') + +# needs to be loaded before or at beginning of plugin init stage because it +# allows to use add_tab and add_admin_tab from plugin init.rb + +module Mephisto + def self.plugins + @@plugins ||= Engines::Plugin::List.new Engines.plugins.select{ |plugin| plugin.mephisto_plugin? } + end + + module Plugin + @@tabs = [] + @@admin_tabs = [] + mattr_reader :tabs, :admin_tabs + + # delegate read access to about info + %w(author homepage version notes).each do |property| + module_eval "def #{property}; about['#{property}'] end", __FILE__, __LINE__ + end + + # Keeps track of custom adminstration tabs. Each item is an array of arguments to be passed to link_to. + def add_tab(*args) + args.push(:controller => args.first.to_s.downcase) if (args.size == 1) + Mephisto::Plugin.tabs << args + end + + # Keeps track of custom adminstration tabs for ADMIN users only. Each item is an array of arguments to be passed to link_to. + def add_admin_tab(*args) + args.push(:controller => args.first.to_s.downcase) if (args.size == 1) + Mephisto::Plugin.admin_tabs << args + end + + def mephisto_plugin? + name =~ /^mephisto_(\w+)$/ + end + + def configurable? + not default_options.empty? + end + + def mephisto_name + name.sub /^mephisto_/, '' + end + alias :conf_name :mephisto_name + end +end + +Engines::Plugin.send :include, Mephisto::Plugin + +module Engines + class Plugin < Rails::Plugin + protected + # override engine default list for Mephisto plugins + def default_code_paths + %w(app/controllers app/helpers app/models app/drops components lib) + end + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/lib/mephisto/plugin_about_patch.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/plugin_about_patch.rb --- mephisto-0.7.3/lib/mephisto/plugin_about_patch.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/plugin_about_patch.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,26 @@ +# separately patching Rails::Plugin assuming that this patch will be accepted: +# http://dev.rubyonrails.org/ticket/10979 + +unless Rails::Plugin.respond_to?(:directory) + Rails::Plugin.class_eval do + attr_reader :directory, :name, :about + + alias :initialize_without_about_info :initialize + def initialize(directory) + initialize_without_about_info(directory) + load_about_information + end + + private + + def load_about_information + begin + about_yml_path = File.join(@directory, "about.yml") + parsed_yml = File.exist?(about_yml_path) ? YAML.load(File.read(about_yml_path)) : {} + @about = parsed_yml || {} + rescue Exception + @about = {} + end + end + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/lib/mephisto/plugins.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/plugins.rb --- mephisto-0.7.3/lib/mephisto/plugins.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/plugins.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,5 @@ +# Empty module to hold plugin models +module Mephisto + module Plugins + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/lib/mephisto/routing.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/routing.rb --- mephisto-0.7.3/lib/mephisto/routing.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/routing.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,5 +1,10 @@ module Mephisto class Routing + # Adds Mephisto routes. Yield a given block to allow custom routes. + # + # Mephisto::Routing.connect_with map do + # map.foo ... + # end def self.connect_with(map) map.feed 'feed/*sections', :controller => 'feed', :action => 'feed' @@ -9,22 +14,38 @@ m.js 'javascripts/:path.:ext', :dir => 'javascripts' m.images 'images/:path.:ext', :dir => 'images' end - + + map.moderate 'admin/articles/comments', :controller => 'admin/comments', :action => 'index' + map.purge 'admin/articles/comments/purge', :controller => 'admin/comments', :action => 'destroy' + + map.resources :articles, :path_prefix => 'admin', :controller => 'admin/articles' do |r| + r.resources :comments, :controller => 'admin/comments', :member => { :unapprove => :post, :approve => :post, :edit => :get, :preview => :post } + end + map.overview 'admin/overview.xml', :controller => 'admin/overview', :action => 'feed' map.admin 'admin', :controller => 'admin/overview', :action => 'index' map.resources :assets, :path_prefix => '/admin', :controller => 'admin/assets', :member => { :add_bucket => :post }, :collection => { :latest => :post, :search => :post, :upload => :post, :clear_bucket => :post } - map.connect 'xmlrpc', :controller => 'backend', :action => 'xmlrpc' + # Where oh where is my xmlrpc code? + # map.connect 'xmlrpc', :controller => 'backend', :action => 'xmlrpc' - map.connect ':controller/:action/:id/:version', :version => nil, :controller => /routing_navigator|account|(admin\/\w+)/ + map_from_plugins(map) + + map.connect ':controller/:action/:id/:version', :version => nil, :controller => /routing_navigator|account|(admin\/\w+)/, :id => /[^\/]*/ + + yield if block_given? map.dispatch '*path', :controller => 'mephisto', :action => 'dispatch' map.home '', :controller => 'mephisto', :action => 'dispatch' end - def self.redirections - @redirections ||= {} + class << self + expiring_attr_reader :redirections, '{}' + end + + def self.map_from_plugins(map) + Engines.plugins.each { |plugin| map.from_plugin(plugin.name) } end def self.deny(*paths) @@ -53,8 +74,9 @@ end protected + @@sanitize_path_regex = /^(\/)|(https?:\/\/)/ def self.sanitize_path(path) - path =~ /^(\/)|(https?:\/\/)/ ? path : "/#{path.split("://").last}" + path =~ @@sanitize_path_regex ? path : "/#{path.split("://").last}" end def self.convert_redirection_to_regex(path) diff -Nur mephisto-0.7.3/lib/mephisto/version.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/version.rb --- mephisto-0.7.3/lib/mephisto/version.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto/version.rb 2008-03-31 02:18:56.000000000 -0400 @@ -1,9 +1,9 @@ module Mephisto module Version MAJOR = 0 - MINOR = 7 - TINY = 3 + MINOR = 8 + TINY = 0 STRING = [MAJOR, MINOR, TINY].join('.').freeze - TITLE = "Noh-Varr".freeze + TITLE = "Drax".freeze end end \ No newline at end of file diff -Nur mephisto-0.7.3/lib/mephisto.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto.rb --- mephisto-0.7.3/lib/mephisto.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,5 @@ +module Mephisto + @@liquid_filters = [CoreFilters, DropFilters, UrlFilters] + @@liquid_tags = {:textile => Mephisto::Liquid::Textile, :commentform => Mephisto::Liquid::CommentForm, :head => Mephisto::Liquid::Head} + mattr_reader :liquid_tags, :liquid_filters +end \ No newline at end of file diff -Nur mephisto-0.7.3/lib/mephisto_init.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto_init.rb --- mephisto-0.7.3/lib/mephisto_init.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/mephisto_init.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,148 +0,0 @@ -require 'tzinfo' -require 'zip/zipfilesystem' -require 'dispatcher' -require 'coderay' -require 'ruby_pants' -require 'xmlrpc_patch' - -RAILS_PATH = Pathname.new(File.expand_path(RAILS_ROOT)) - -ActiveRecord::Base.observers = [:article_observer, :comment_observer] - -Inflector.inflections do |inflect| - #inflect.plural /^(ox)$/i, '\1en' - #inflect.singular /^(ox)en/i, '\1' - #inflect.irregular 'person', 'people' - inflect.uncountable %w( audio ) -end - -class << Dispatcher - def register_liquid_tags - [CoreFilters, DropFilters, UrlFilters].each { |f| Liquid::Template.register_filter f } - Liquid::Template.register_tag(:textile, Mephisto::Liquid::Textile) - Liquid::Template.register_tag(:commentform, Mephisto::Liquid::CommentForm) - Liquid::Template.register_tag(:head, Mephisto::Liquid::Head) - end - - def reset_application_with_plugins! - returning reset_application_without_plugins! do - register_liquid_tags - end - end - - alias_method_chain :reset_application!, :plugins -end - -Dispatcher.register_liquid_tags -# http://rails.techno-weenie.net/tip/2005/12/23/make_fixtures -ActiveRecord::Base.class_eval do - # person.dom_id #-> "person-5" - # new_person.dom_id #-> "person-new" - # new_person.dom_id(:bare) #-> "new" - # person.dom_id(:person_name) #-> "person-name-5" - def dom_id(prefix=nil) - display_id = new_record? ? "new" : id - prefix ||= self.class.name.underscore - prefix != :bare ? "#{prefix.to_s.dasherize}-#{display_id}" : display_id - end - - # Write a fixture file for testing - def self.to_fixture(fixture_path = nil) - File.open(File.expand_path(fixture_path || "test/fixtures/#{table_name}.yml", RAILS_ROOT), 'w') do |out| - YAML.dump find(:all).inject({}) { |hsh, record| hsh.merge(record.id => record.attributes) }, out - end - end - - def referenced_cache_key - "[#{[id, self.class.name] * ':'}]" - end -end - -ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update \ - :standard => '%B %d, %Y @ %I:%M %p', - :stub => '%B %d', # XXX what is the meaning of stub in this context? (Basically it means short) - :time_only => '%I:%M %p', - :plain => '%B %d %I:%M %p', - :mdy => '%B %d, %Y', - :my => '%B %Y' - -# Time.now.to_ordinalized_s :long -# => "February 28th, 2006 21:10" -module ActiveSupport::CoreExtensions::Time::Conversions - def to_ordinalized_s(format = :default) - format = ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS[format] - return to_default_s if format.nil? - strftime(format.gsub(/%d/, '_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize } - end -end - -class Time - class << self - # Used for getting multifield attributes like those generated by a - # select_datetime into a new Time object. For example if you have - # following params={:meetup=>{:"time(1i)=>..."}} just do - # following: - # - # Time.parse_from_attributes(params[:meetup], :time) - def parse_from_attributes(attrs, field, method=:gm) - attrs = attrs.keys.sort.grep(/^#{field.to_s}\(.+\)$/).map { |k| attrs[k] } - attrs.any? ? Time.send(method, *attrs) : nil - end - end - - def to_delta(delta_type = :day) - case delta_type - when :year then self.class.delta(year) - when :month then self.class.delta(year, month) - else self.class.delta(year, month, day) - end - end - - def self.delta(year, month = nil, day = nil) - from = Time.local(year, month || 1, day || 1) - - to = - if !day.blank? - from.advance :days => 1 - elsif !month.blank? - from.advance :months => 1 - else - from.advance :years => 1 - end - return [from.midnight, to.midnight-1] - end -end - -# need to make pathname safe for windows! -Pathname.class_eval do - def read(*args) - returning '' do |s| - File.open @path, 'rb' do |f| - s << f.read - end - end - end -end - -class MissingTemplateError < StandardError - attr_reader :template_type, :templates - def initialize(template_type, templates) - @template_type = template_type - @templates = templates - super "No template found for #{template_type}, checked #{templates.to_sentence}." - end -end - -class ThemeError < StandardError - attr_reader :theme - def initialize(theme, message) - @theme = theme - super message - end -end - -Symbol.class_eval do - def to_liquid - to_s - end -end \ No newline at end of file diff -Nur mephisto-0.7.3/lib/tasks/bootstrap.rake technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/tasks/bootstrap.rake --- mephisto-0.7.3/lib/tasks/bootstrap.rake 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/tasks/bootstrap.rake 2008-03-31 02:18:56.000000000 -0400 @@ -1,7 +1,7 @@ SITE_DIR = File.join(RAILS_ROOT, 'themes/site-' + (ENV['SITE_ID'] || '1')) namespace :db do desc "Loads a schema.rb file into the database and then loads the initial database fixtures." - task :bootstrap do + task :bootstrap do |task_args| mkdir_p File.join(RAILS_ROOT, 'log') require 'rubygems' unless Object.const_defined?(:Gem) @@ -25,11 +25,11 @@ raise end - %w(environment db:schema:load db:bootstrap:load tmp:create).each { |t| Rake::Task[t].execute } + %w(environment db:schema:load db:bootstrap:load tmp:create).each { |t| Rake::Task[t].execute task_args} if File.exists?(SITE_DIR) puts "skipping default theme creation..." else - Rake::Task["db:bootstrap:copy_default_theme"].execute + Rake::Task["db:bootstrap:copy_default_theme"].execute task_args puts "copied default theme to #{SITE_DIR}..." end diff -Nur mephisto-0.7.3/lib/tasks/common.rake technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/tasks/common.rake --- mephisto-0.7.3/lib/tasks/common.rake 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/tasks/common.rake 2008-03-31 02:18:56.000000000 -0400 @@ -2,6 +2,7 @@ task :deploy_edge do ENV['SHARED_PATH'] = '../../shared' unless ENV['SHARED_PATH'] ENV['RAILS_PATH'] ||= File.join(ENV['SHARED_PATH'], 'rails') + ENV['REPO_BRANCH'] ||= 'trunk' checkout_path = File.join(ENV['RAILS_PATH'], 'trunk') export_path = "#{ENV['RAILS_PATH']}/rev_#{ENV['REVISION']}" @@ -11,7 +12,7 @@ unless File.exists?(checkout_path) puts 'setting up rails trunk' get_framework_for checkout_path do |framework| - system "svn co http://dev.rubyonrails.org/svn/rails/trunk/#{framework}/lib #{checkout_path}/#{framework}/lib --quiet" + system "svn co http://dev.rubyonrails.org/svn/rails/#{ENV['REPO_BRANCH']}/#{framework}/lib #{checkout_path}/#{framework}/lib --quiet" end end diff -Nur mephisto-0.7.3/lib/tasks/switchtower.rake technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/tasks/switchtower.rake --- mephisto-0.7.3/lib/tasks/switchtower.rake 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/lib/tasks/switchtower.rake 1969-12-31 19:00:00.000000000 -0500 @@ -1,33 +0,0 @@ -# ============================================================================= -# A set of rake tasks for invoking the SwitchTower automation utility. -# ============================================================================= - -desc "Push the latest revision into production using the release manager" -task :deploy do - system "switchtower -vvvv -r config/deploy -a deploy" -end - -desc "Rollback to the release before the current release in production" -task :rollback do - system "switchtower -vvvv -r config/deploy -a rollback" -end - -desc "Describe the differences between HEAD and the last production release" -task :diff_from_last_deploy do - system "switchtower -vvvv -r config/deploy -a diff_from_last_deploy" -end - -desc "Enumerate all available deployment tasks" -task :show_deploy_tasks do - system "switchtower -r config/deploy -a show_tasks" -end - -desc "Execute a specific action using the release manager" -task :remote_exec do - unless ENV['ACTION'] - raise "Please specify an action (or comma separated list of actions) via the ACTION environment variable" - end - - actions = ENV['ACTION'].split(",").map { |a| "-a #{a}" }.join(" ") - system "switchtower -vvvv -r config/deploy #{actions}" -end diff -Nur mephisto-0.7.3/public/.htaccess technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/public/.htaccess --- mephisto-0.7.3/public/.htaccess 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/public/.htaccess 1969-12-31 19:00:00.000000000 -0500 @@ -1,40 +0,0 @@ -# General Apache options -AddHandler fastcgi-script .fcgi -AddHandler cgi-script .cgi -Options +FollowSymLinks +ExecCGI - -# If you don't want Rails to look in certain directories, -# use the following rewrite rules so that Apache won't rewrite certain requests -# -# Example: -# RewriteCond %{REQUEST_URI} ^/notrails.* -# RewriteRule .* - [L] - -# Redirect all requests not available on the filesystem to Rails -# By default the cgi dispatcher is used which is very slow -# -# For better performance replace the dispatcher with the fastcgi one -# -# Example: -# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] -RewriteEngine On - -# If your Rails application is accessed via an Alias directive, -# then you MUST also set the RewriteBase in this htaccess file. -# -# Example: -# Alias /myrailsapp /path/to/myrailsapp/public -# RewriteBase /myrailsapp - -RewriteRule ^$ index.html [QSA] -RewriteRule ^([^.]+)$ $1.html [QSA] -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.*)$ dispatch.cgi [QSA,L] - -# In case Rails experiences terminal errors -# Instead of displaying this message you can supply a file here which will be rendered instead -# -# Example: -# ErrorDocument 500 /500.html - -ErrorDocument 500 "

      Application error

      Rails application failed to start properly" diff -Nur mephisto-0.7.3/public/install.html technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/public/install.html --- mephisto-0.7.3/public/install.html 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/public/install.html 2008-03-31 02:18:56.000000000 -0400 @@ -1,87 +1,87 @@ + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - - - Installing Mephisto - - - - - - + \ No newline at end of file diff -Nur mephisto-0.7.3/public/javascripts/mephisto/application.js technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/public/javascripts/mephisto/application.js --- mephisto-0.7.3/public/javascripts/mephisto/application.js 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/public/javascripts/mephisto/application.js 2008-03-31 02:18:56.000000000 -0400 @@ -206,9 +206,9 @@ Asset = { upload: function(form) { form = $(form); - article_id = location.href.match(/\/edit\/([0-9]+)/); + article_id = location.href.match(/\/(edit|upload)\/([0-9]+)/); form.action = Mephisto.root + "/admin/articles/upload" - if(article_id) form.action += "/" + article_id[1] + if(article_id) form.action += "/" + article_id[2] form.submit(); }, @@ -295,11 +295,36 @@ getAvailableComments: function() { return $$('ul.commentlist li').reject(function(div) { return !(div.visible() && !div.hasClassName('disabled') && div.id.match(/^comment-/)); }).collect(function(div) { return div.id.match(/comment-(\d+)/)[1] }); }, - + + attachAsset: function(assetId) { + var articleId = location.href.match(/\/([0-9]+)\/(edit|upload)/)[1]; + var attached = $('attached-widget-' + assetId); + if(attached) return; + new Ajax.Request('/admin/articles/attach/' + articleId + '/' + assetId); + $$('.widget').each(function(asset) { if(assetId == asset.getAttribute('id').match(/-(\d+)$/)[1]) asset.addClassName('selected-widget'); }); + }, + + labelAsset: function(assetId) { + var articleId = location.href.match(/\/([0-9]+)\/(edit|upload)/)[1]; + var attached = $('attached-widget-' + assetId); + var label = $('attached-widget-version-' + assetId); + new Ajax.Request('/admin/articles/label/' + articleId + '/' + assetId + '?label=' + escape(label.value)); + if(attached) return; + }, + + detachAsset: function(assetId) { + var articleId = location.href.match(/\/([0-9]+)\/(edit|upload)/)[1]; + var attached = $('attached-widget-' + assetId); + if(!attached) return; + new Ajax.Request('/admin/articles/detach/' + articleId + '/' + assetId); + new Effect.DropOut(attached, {afterFinish: function() { attached.remove(); }}); + $$('.widget').each(function(asset) { if(assetId == asset.getAttribute('id').match(/-(\d+)$/)[1]) asset.removeClassName('selected-widget'); }); + }, + getRevision: function() { var rev = $F(this) - var url = Mephisto.root + '/admin/articles/edit/' + location.href.match(/\/edit\/([0-9]+)/)[1]; - if(rev != '0') url += "/" + rev; + var url = Mephisto.root + '/admin/articles/' + location.href.match(/\/([0-9]+)\/edit/)[1] + "/edit"; + if(rev != '0') url += "?version=" + rev; location.href = url; } } @@ -548,7 +573,37 @@ $('published').value = '0'; $('article-search').submit(); }, + + 'li.widget:mouseover': function() { + var attach = $('attach-' + this.getAttribute('id')); + var detach = $('detach-' + this.getAttribute('id')); + if(attach) attach.show(); + if(detach) detach.show(); + }, + + 'li.widget:mouseout': function() { + var attach = $('attach-' + this.getAttribute('id')); + var detach = $('detach-' + this.getAttribute('id')); + if(attach) attach.hide(); + if(detach) detach.hide(); + }, + '.attach-widget:click': function() { + ArticleForm.attachAsset(this.getAttribute('id').match(/-(\d+)$/)[1]); + return false; + }, + + '.label-widget:click': function() { + ArticleForm.labelAsset(this.getAttribute('id').match(/-(\d+)$/)[1]); + this.innerHTML = 'Saving...' + return false; + }, + + '.detach-widget:click': function() { + ArticleForm.detachAsset(this.getAttribute('id').match(/-(\d+)$/)[1]); + return false; + }, + 'a.theme_dialog:click': function() { var img = this.down('img'); var pieces = img.src.split('/'); diff -Nur mephisto-0.7.3/public/stylesheets/mephisto/mephisto.css technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/public/stylesheets/mephisto/mephisto.css --- mephisto-0.7.3/public/stylesheets/mephisto/mephisto.css 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/public/stylesheets/mephisto/mephisto.css 2008-03-31 02:18:56.000000000 -0400 @@ -1199,6 +1199,14 @@ text-align: center; border-top: 1px solid #ccc; padding: 10px 0; + font-weight:bold; +} + +#main p.total { + margin:-0.3em 0 1.2em 0; + padding: 0.3em 3em; + background: #eee; + text-align:center; } @@ -1305,29 +1313,75 @@ *=ASSET MANAGEMENT */ -#assets, #files, #latest-assets, #bucket-assets, #search-assets { +#assets, #files, ul.asset-list { list-style: none; margin-top: 5px; } -#assets li, #files li, #latest-assets li, #bucket-assets li, #search-assets li { +#assets li, #files li, ul.asset-list li { display: inline; + white-space: no-wrap; margin-left: 5px; margin-bottom: 5px; } -#assets li a img, +#attached-assets li { + display:block; +} + +#attached-assets li div { + position:relative; +} + +#attached-assets li div a { + display:inline; +} + +#attached-assets div input.txt { + width:125px; +} + +#attached-assets div span { + position:absolute; + top:20px; right:8px; +} + +ul.asset-list .widget { + position:relative; +} + +.widget .attach-widget { + z-index:500; + position:absolute; + top:-13px; left:-23px; +} + +.widget .detach-widget { + z-index:500; + position:absolute; + top:-36px; left:-23px; +} + +#attached-assets .widget .attach-widget { + position:absolute; + top:11px; left:-23px; +} + +#attached-assets .widget .detach-widget { + position:absolute; + top:34px; left:-23px; +} + +#assets li a img, #latest-assets li a img, #bucket-assets li a img, -#search-assets li a img { +#search-assets li a img, +ul.asset-list li a img { padding: 4px; background: #fff; } -#assets img, -#latest-assets img, -#bucket-assets img, -#search-assets img { +ul.asset-list img { max-height: 50px; max-width: 50px; padding: 3px; @@ -1335,6 +1389,10 @@ border: 1px solid #8BCACD; } +ul.asset-list .selected-widget img { + border-color:#000; +} + #assets span, #latest-assets span, #bucket-assets span, diff -Nur mephisto-0.7.3/script/spec technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/script/spec --- mephisto-0.7.3/script/spec 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/script/spec 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib")) +require 'spec' +exit ::Spec::Runner::CommandLine.run(::Spec::Runner::OptionParser.parse(ARGV, STDERR, STDOUT)) diff -Nur mephisto-0.7.3/script/spec_server technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/script/spec_server --- mephisto-0.7.3/script/spec_server 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/script/spec_server 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,99 @@ +#!/usr/bin/env ruby +$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn +$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin +require 'rubygems' +require 'drb/drb' +require 'rbconfig' +require 'spec' +require 'optparse' + +# This is based on Florian Weber's TDDMate +module Spec + module Runner + class RailsSpecServer + def run(argv, stderr, stdout) + $stdout = stdout + $stderr = stderr + + base = ActiveRecord::Base + def base.clear_reloadable_connections! + active_connections.each do |name, conn| + if conn.requires_reloading? + conn.disconnect! + active_connections.delete(name) + end + end + end + + if ::Dispatcher.respond_to?(:cleanup_application) + ::Dispatcher.cleanup_application + elsif ::Dispatcher.respond_to?(:reset_application!) + ::Dispatcher.reset_application! + end + ::Dependencies.mechanism = :load + require_dependency('application.rb') unless Object.const_defined?(:ApplicationController) + load File.dirname(__FILE__) + '/../spec/spec_helper.rb' + + ::Spec::Runner::CommandLine.run( + ::Spec::Runner::OptionParser.parse( + argv, + $stderr, + $stdout + ) + ) + end + end + end +end +puts "Loading Rails environment" + +ENV["RAILS_ENV"] = "test" +require File.expand_path(File.dirname(__FILE__) + "/../config/environment") +require 'dispatcher' + +def restart_test_server + puts "restarting" + config = ::Config::CONFIG + ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT'] + command_line = [ruby, $0, ARGV].flatten.join(' ') + exec(command_line) +end + +def daemonize(pid_file = nil) + return yield if $DEBUG + pid = Process.fork{ + Process.setsid + Dir.chdir(RAILS_ROOT) + trap("SIGINT"){ exit! 0 } + trap("SIGTERM"){ exit! 0 } + trap("SIGHUP"){ restart_test_server } + File.open("/dev/null"){|f| + STDERR.reopen f + STDIN.reopen f + STDOUT.reopen f + } + yield + } + puts "spec_server launched. (PID: %d)" % pid + File.open(pid_file,"w"){|f| f.puts pid } if pid_file + exit! 0 +end + +options = Hash.new +opts = OptionParser.new +opts.on("-d", "--daemon"){|v| options[:daemon] = true } +opts.on("-p", "--pid PIDFILE"){|v| options[:pid] = v } +opts.parse!(ARGV) + +puts "Ready" +exec_server = lambda { + trap("USR2") { restart_test_server } if Signal.list.has_key?("USR2") + DRb.start_service("druby://localhost:8989", Spec::Runner::RailsSpecServer.new) + DRb.thread.join +} + +if options[:daemon] + daemonize(options[:pid], &exec_server) +else + exec_server.call +end diff -Nur mephisto-0.7.3/spec/controllers/plugin_routing_spec.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/controllers/plugin_routing_spec.rb --- mephisto-0.7.3/spec/controllers/plugin_routing_spec.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/controllers/plugin_routing_spec.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,18 @@ +# cant get this working with autotest for some reason +# invoking the spec manually will work though + +# require File.join(File.dirname(__FILE__), '/../../config/boot') +# +# Rails::Configuration.send(:define_method, :plugin_paths) do +# ["#{RAILS_ROOT}/vendor/plugins", "#{RAILS_ROOT}/vendor/plugins/engines_config/test/plugins"] +# end +# +# require File.dirname(__FILE__) + '/../spec_helper' +# +# describe "Mephisto::Plugin routing" do +# controller_name 'mephisto' +# +# it "should work" do +# route_for(:controller => "somethings", :action => "index").should == "/something" +# end +# end \ No newline at end of file diff -Nur mephisto-0.7.3/spec/filters/absolute_url_spec.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/filters/absolute_url_spec.rb --- mephisto-0.7.3/spec/filters/absolute_url_spec.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/filters/absolute_url_spec.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,57 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Mephisto::Liquid::UrlMethods, "#absolute_url" do + it "has root absolute url" do + absolute_url.should == '/' + end + + it "joins url pieces" do + absolute_url(:foo).should == '/foo' + absolute_url(:foo, :bar).should == '/foo/bar' + absolute_url(:foo, :bar, 'baz.html').should == '/foo/bar/baz.html' + end + + it "joins relative path" do + absolute_url('foo/bar/baz.html').should == '/foo/bar/baz.html' + end + + it "joins absolute path" do + absolute_url('/foo/bar/baz.html').should == '/foo/bar/baz.html' + end + + it "joins path ending with a slash" do + absolute_url('foo/bar/baz/').should == '/foo/bar/baz' + end +end + +describe Mephisto::Liquid::UrlMethods, "#absolute_url (with custom url root)" do + class << self + attr_accessor :relative_url_root + end + + before do + stub!(:relative_url_root).and_return("/blog") + end + + it "has root absolute url" do + absolute_url.should == '/blog/' + end + + it "joins url pieces" do + absolute_url(:foo).should == '/blog/foo' + absolute_url(:foo, :bar).should == '/blog/foo/bar' + absolute_url(:foo, :bar, 'baz.html').should == '/blog/foo/bar/baz.html' + end + + it "joins relative path" do + absolute_url('foo/bar/baz.html').should == '/blog/foo/bar/baz.html' + end + + it "joins absolute path" do + absolute_url('/foo/bar/baz.html').should == '/foo/bar/baz.html' + end + + it "joins path ending with a slash" do + absolute_url('foo/bar/baz/').should == '/blog/foo/bar/baz' + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/spec/model_stubs.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/model_stubs.rb --- mephisto-0.7.3/spec/model_stubs.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/model_stubs.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,21 @@ +ModelStubbing.define_models do + # only put minimal, core models in here if specs require interaction + # with lots of models + + time 2007, 6, 15 + + model Site do + stub :title => "Mephisto", :host => 'test.host', :filter => 'textile_filter', :approve_comments => false, + :comment_age => 30, :timezone => "America/New_York", :articles_per_page => 15, :permalink_style => ":year/:month/:day/:permalink", + :tag_path => 'tags', :search_path => 'search', :current_theme_path => 'current' + end + + model User do + stub :login => 'quentin', :email => 'quentin@example.com', :filter => 'textile_filter', :token => 'quentintoken', :admin => true, + :salt => '7e3041ebc2fc05a40c60028e2c4901a81035d3cd', :crypted_password => '00742970dc9e6319f8019fd54864d3ea740f04b1' + end + + # model Article do + # stub :title => 'foobar' + # end +end \ No newline at end of file diff -Nur mephisto-0.7.3/spec/models/comment_spec.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/models/comment_spec.rb --- mephisto-0.7.3/spec/models/comment_spec.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/models/comment_spec.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,53 @@ +require File.dirname(__FILE__) + '/../spec_helper' + + +describe Comment, "previewing" do + define_models do + time 2007, 6, 15 + + model Site do + stub :cupcake, :title => "Cupcake", :host => 'cupcake.com' + end + model Article do + stub :welcome, :title => "Welcome!", :body => "Hi there", :filter => "textile_filter", :site => all_stubs(:site), :created_at => current_time - 3.days, :published_at => current_time - 2.days, :comment_age => 0 + end + end + + before do + @comment = Comment.new :author => "1", :author_ip => "127.0.0.1", :body => "No answer" + @comment.article = contents(:welcome) + end + + it "should be valid" do + @comment.should be_valid + end + + it "raises Previewing error when preview accessor is set" do + @comment.preview = true + lambda{ + @comment.save! + }.should raise_error(Comment::Previewing) + end + +end + +describe Comment, "textilizing" do + define_models do + model Site do + stub :cupcake, :title => "Cupcake", :host => 'cupcake.com' + end + model Article do + stub :welcome, :title => "Welcome!", :body => "Hi there", :filter => "textile_filter", :site => all_stubs(:site), :created_at => current_time - 3.days, :published_at => current_time - 2.days, :comment_age => 0 + end + end + + # Copied from tests, in the hope that more people will PDI and convert the test::unit + # tests to RSpec. + it "processes comments with textile, if the article is textile-formatted" do + @comment = Comment.new :author => "1", :author_ip => "127.0.0.1", :body => "*test* comment" + @comment.article = contents(:welcome) + @comment.save + @comment.body_html.should == "

      test comment

      " + end + +end \ No newline at end of file diff -Nur mephisto-0.7.3/spec/models/membership_spec.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/models/membership_spec.rb --- mephisto-0.7.3/spec/models/membership_spec.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/models/membership_spec.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,39 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Membership do + define_models do + model Site do + stub :cupcake, :title => "Cupcake", :host => 'cupcake.com' + end + + model User do + stub :non_admin, :login => 'arthur', :admin => false + stub :deleted, :login => "aaron", :admin => false, :deleted_at => current_time - 5.minutes + end + + model Membership do + stub :admin_on_default, :site => all_stubs(:site), :user => all_stubs(:user), :admin => true + stub :admin_on_cupcake, :site => all_stubs(:cupcake_site), :user => all_stubs(:user), :admin => true + stub :user_on_default, :site => all_stubs(:site), :user => all_stubs(:non_admin_user), :admin => false + stub :deleted_on_default, :site => all_stubs(:site), :user => all_stubs(:deleted_user), :admin => false + end + end + + it "finds user sites" do + users(:default).sites.sort_by { |s| s.title }.should == [sites(:cupcake), sites(:default)] + end + + it "finds site members" do + sites(:default).members.sort_by { |u| u.login }.should == [users(:non_admin), users(:default)] + User.find_all_by_site(sites(:default)).sort_by { |u| u.login }.should == [users(:non_admin), users(:default)] + end + + it "finds site admins" do + sites(:default).admins.should == [users(:default)] + end + + it "finds all users with deleted" do + sites(:default).users_with_deleted.sort_by { |u| u.login }.should == [users(:deleted), users(:non_admin), users(:default)] + User.find_all_by_site_with_deleted(sites(:default)).sort_by { |u| u.login }.should == [users(:deleted), users(:non_admin), users(:default)] + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/spec/models/plugin_spec.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/models/plugin_spec.rb --- mephisto-0.7.3/spec/models/plugin_spec.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/models/plugin_spec.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,41 @@ +# cant get this working with autotest for some reason +# invoking the spec manually will work though + +require File.join(File.dirname(__FILE__), '/../../config/boot') + +Rails::Configuration.send(:define_method, :plugin_paths) do + ["#{RAILS_ROOT}/vendor/plugins", "#{RAILS_ROOT}/vendor/plugins/engines_config/test/plugins"] +end + +require File.dirname(__FILE__) + '/../spec_helper' + +describe Mephisto::Plugin do + def plugin_alpha + Engines.plugins['plugin_alpha'] + end + + it "should filter plugin list and return mephisto plugins" do + Engines.plugins.size.should > Mephisto.plugins.size + end + + it "should be a mephisto plugin when its name starts with 'mephisto_'" do + Mephisto.plugins.each {|p| p.name.should =~ /^mephisto_/ } + end + + it "should be configurable when at least one option is defined" do + plugin_alpha.configurable?.should be_true + Engines.plugins['engines'].configurable?.should be_false + end + + it "should allow to add tabs" do + Mephisto::Plugin.tabs.clear + plugin_alpha.add_tab :something + Mephisto::Plugin.tabs.first.first.should == :something + end + + it "should allow to add admin tabs" do + Mephisto::Plugin.admin_tabs.clear + plugin_alpha.add_admin_tab :something + Mephisto::Plugin.admin_tabs.first.first.should == :something + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/spec/models/site_spec.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/models/site_spec.rb --- mephisto-0.7.3/spec/models/site_spec.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/models/site_spec.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,69 @@ +require File.dirname(__FILE__) + '/../spec_helper' +describe Site do + define_models do + + model Site do + stub :destroy, :host => 'destroy.com' + end + + model User do + stub :destroy, :login => 'destroy' + end + + model Membership do + stub :destroy, :site => all_stubs(:destroy_site), :user => all_stubs(:destroy_user) + end + end + + it "should delete memberships on destruction" do + sites(:destroy).memberships.should == [memberships(:destroy)] + lambda { sites(:destroy).destroy }.should change(Membership, :count).by(-1) + end + +end +require File.dirname(__FILE__) + '/../spec_helper' +describe Site do + define_models do + + model Site do + stub :destroy, :host => 'destroy.com' + end + + model User do + stub :destroy, :login => 'destroy' + end + + model Membership do + stub :destroy, :site => all_stubs(:destroy_site), :user => all_stubs(:destroy_user) + end + end + + it "should delete memberships on destruction" do + sites(:destroy).memberships.should == [memberships(:destroy)] + lambda { sites(:destroy).destroy }.should change(Membership, :count).by(-1) + end + +end +require File.dirname(__FILE__) + '/../spec_helper' +describe Site do + define_models do + + model Site do + stub :destroy, :host => 'destroy.com' + end + + model User do + stub :destroy, :login => 'destroy' + end + + model Membership do + stub :destroy, :site => all_stubs(:destroy_site), :user => all_stubs(:destroy_user) + end + end + + it "should delete memberships on destruction" do + sites(:destroy).memberships.should == [memberships(:destroy)] + lambda { sites(:destroy).destroy }.should change(Membership, :count).by(-1) + end + +end diff -Nur mephisto-0.7.3/spec/models/tag_spec.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/models/tag_spec.rb --- mephisto-0.7.3/spec/models/tag_spec.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/models/tag_spec.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,69 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +ModelStubbing.define_models :tags, :copy => false do + model Tag do + [:ruby, :rails, :mongrel, :plugin].each do |t| + stub t, :name => t.to_s + end + end +end + +describe Tag, "#parse" do + define_models :tags + + it "parses comma separated tags" do + Tag.parse('a,b,c').should == %w(a b c) + Tag.parse('a, b c').should == %w(a b\ c) + end + + it "parses simple tags" do + Tag.parse('"a" "b" "c"').should == %w(a b c) + end + + it "parses space delimited tags" do + Tag.parse('a b c').should == %w(a b c) + end + + it "parses tags with double quotes" do + Tag.parse('tagging, it"s, weirdness').should == %w(tagging it"s weirdness) + end + + it "parses tags with single quotes" do + Tag.parse('"tagging" "it\'s" "weirdness"').should == %w(tagging it's weirdness) + end + + it "parses tags with quotes and spaces" do + Tag.parse('"tagging" "it\'s weirdness"').should == %w(tagging it's\ weirdness) + end + + it "returns tag array" do + Tag.parse(%w(a b c)).should == %w(a b c) + end + + it "returns unique tags" do + ["a, b, b", %("a" "b" " b ")].each do |input| + Tag.parse(input).should == %w(a b) + end + end +end + +describe Tag do + define_models :tags + + it "finds or creates tags" do + lambda { Tag.find_or_create %w(ruby rails foo) }.should change { Tag.count }.by(1) + end + + it "creates tags from comma separated list" do + lambda { Tag.parse_to_tags 'ruby, a, b, rails, c' }.should change { Tag.count }.by(3) + end + + it "equals tags of the same name" do + tags(:ruby).should == 'ruby' + tags(:ruby).should == Tag.new(:name => "ruby") + end + + it "selects tags by name" do + Tag[:ruby].should == tags(:ruby) + end +end diff -Nur mephisto-0.7.3/spec/rcov.opts technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/rcov.opts --- mephisto-0.7.3/spec/rcov.opts 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/rcov.opts 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,2 @@ +--exclude "spec/*,gems/*" +--rails \ No newline at end of file diff -Nur mephisto-0.7.3/spec/spec.opts technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/spec.opts --- mephisto-0.7.3/spec/spec.opts 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/spec.opts 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,7 @@ +--colour +--format +progress +--loadby +mtime +--reverse +--backtrace \ No newline at end of file diff -Nur mephisto-0.7.3/spec/spec_helper.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/spec_helper.rb --- mephisto-0.7.3/spec/spec_helper.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/spec/spec_helper.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,15 @@ +ENV["RAILS_ENV"] = "test" + +require File.expand_path(File.dirname(__FILE__) + "/../config/environment") +require 'spec' +require 'spec/rails' +require 'ruby-debug' +require 'model_stubbing/spec' +require File.join(File.dirname(__FILE__), 'model_stubs') + +Spec::Runner.configure do |config| + config.use_transactional_fixtures = true + config.use_instantiated_fixtures = false +end + +Debugger.start \ No newline at end of file diff -Nur mephisto-0.7.3/stories/all.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/stories/all.rb --- mephisto-0.7.3/stories/all.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/stories/all.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,4 @@ +dir = File.dirname(__FILE__) +Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file| + require file +end \ No newline at end of file diff -Nur mephisto-0.7.3/stories/helper.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/stories/helper.rb --- mephisto-0.7.3/stories/helper.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/stories/helper.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,3 @@ +ENV["RAILS_ENV"] = "test" +require File.expand_path(File.dirname(__FILE__) + "/../config/environment") +require 'spec/rails/story_adapter' \ No newline at end of file diff -Nur mephisto-0.7.3/test/actor.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/actor.rb --- mephisto-0.7.3/test/actor.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/actor.rb 2008-03-31 02:18:56.000000000 -0400 @@ -51,23 +51,23 @@ end def revise(article, contents) - post "/admin/articles/update/#{article.id}", to_article_params(article, contents.is_a?(Hash) ? contents : {:body => contents}) - assert_redirected_to "/admin/articles/edit/#{assigns(:article).id}" + put "/admin/articles/#{article.id}", to_article_params(article, contents.is_a?(Hash) ? contents : {:body => contents}) + assert_redirected_to "/admin/articles/#{assigns(:article).id}/edit" end def remove_article(article) - post "/admin/articles/destroy/#{article.id}" + delete "/admin/articles/#{article.id}" assert_equal 200, status, "Removing article #{article.id}" end def create(params) - post '/admin/articles/create', to_article_params(params) - assert_redirected_to "/admin/articles/edit/#{assigns(:article).id}" + post '/admin/articles', to_article_params(params) + assert_redirected_to "/admin/articles/#{assigns(:article).id}/edit" end private def manage_comment(action, comment) - post "/admin/articles/#{action}/#{comment.article_id}", :comment => comment.id + post "/admin/articles/#{comment.article_id}/comments/#{comment.id}/#{action}", :comment => comment.id end def to_article_params(*args) diff -Nur mephisto-0.7.3/test/fixtures/assigned_assets.yml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/assigned_assets.yml --- mephisto-0.7.3/test/fixtures/assigned_assets.yml 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/assigned_assets.yml 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,25 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +welcome_gif: + id: 1 + article_id: 1 + asset_id: 1 + position: 1 + label: welcome image + created_at: <%= 2.minutes.ago.to_s :db %> + active: true +welcome_mp3: + id: 2 + article_id: 1 + asset_id: 3 + position: 2 + label: podcast + created_at: <%= 1.minute.ago.to_s :db %> + active: true +welcome_png: + id: 3 + article_id: 1 + asset_id: 2 + position: 3 + label: png + created_at: <%= 90.seconds.ago.to_s :db %> + active: false diff -Nur mephisto-0.7.3/test/fixtures/assigned_sections.yml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/assigned_sections.yml --- mephisto-0.7.3/test/fixtures/assigned_sections.yml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/assigned_sections.yml 2008-03-31 02:18:56.000000000 -0400 @@ -45,4 +45,24 @@ id: 9 article_id: 11 section_id: 1 - position: 5 \ No newline at end of file + position: 5 +draft_about: + id: 10 + article_id: 11 + section_id: 2 + position: 4 +future_about: + id: 11 + article_id: 5 + section_id: 2 + position: 5 +paged_section_article_1: + id: 12 + article_id: 16 + section_id: 10 + position: 1 +paged_section_article_2: + id: 13 + article_id: 17 + section_id: 10 + position: 2 diff -Nur mephisto-0.7.3/test/fixtures/contents.yml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/contents.yml --- mephisto-0.7.3/test/fixtures/contents.yml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/contents.yml 2008-03-31 02:18:56.000000000 -0400 @@ -43,8 +43,8 @@ article_id: 1 title: Welcome to Mephisto permalink: welcome-to-mephisto - body: "rico's evil and linkage" - body_html: "

      rico’s evil and linkage

      " + body: "rico's evil script and linkage alert!" + body_html: "

      rico’s evil script and linkage

      <\nscrip\nt>alert!" created_at: <%= (3.days + 55.minutes).ago.utc.to_s(:db) %> updated_at: <%= (3.days + 55.minutes).ago.utc.to_s(:db) %> published_at: <%= 3.days.ago.utc.to_s(:db) %> @@ -199,6 +199,32 @@ permalink: at-beginning-of-next-month body: Lalala body_html: Lalala + created_at: <%= date = Time.now.utc.beginning_of_month.advance(:months => -1, :minutes => 2).to_s(:db) %> + updated_at: <%= date %> + published_at: <%= date %> + comment_age: 30 + user_id: 1 + type: Article +article_1_only_in_page_section: + id: 16 + site_id: 1 + title: Article 1 + permalink: article-1 + body: Lalala + body_html: Lalala + created_at: <%= date = Time.now.utc.beginning_of_month.advance(:months => -1, :minutes => 1).to_s(:db) %> + updated_at: <%= date %> + published_at: <%= date %> + comment_age: 30 + user_id: 1 + type: Article +article_2_only_in_page_section: + id: 17 + site_id: 1 + title: Article 2 + permalink: article-2 + body: Lalala + body_html: Lalala created_at: <%= date = Time.now.utc.beginning_of_month.advance(:months => -1).to_s(:db) %> updated_at: <%= date %> published_at: <%= date %> diff -Nur mephisto-0.7.3/test/fixtures/mephisto_plugins.yml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/mephisto_plugins.yml --- mephisto-0.7.3/test/fixtures/mephisto_plugins.yml 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/mephisto_plugins.yml 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,4 @@ +whammy_jammy: + id: 1 + name: plugin_whammy_jammy + type: PluginWhammyJammy \ No newline at end of file diff -Nur mephisto-0.7.3/test/fixtures/plugins/lib/test_plugin.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/plugins/lib/test_plugin.rb --- mephisto-0.7.3/test/fixtures/plugins/lib/test_plugin.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/plugins/lib/test_plugin.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,12 @@ +module Mephisto + module Plugins + class TestPlugin < Mephisto::Plugin + homepage 'http://foo.com' + author 'Captain Problematic' + version 'deathstar' + + option :config, 'one' => 'test' + option :notes, 'notes' + end + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/test/fixtures/sections.yml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/sections.yml --- mephisto-0.7.3/test/fixtures/sections.yml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/sections.yml 2008-03-31 02:18:56.000000000 -0400 @@ -7,6 +7,7 @@ articles_count: 3 template: home.liquid archive_path: archives + position: 1 about: id: 2 site_id: 1 @@ -16,6 +17,7 @@ articles_count: 3 template: page.liquid archive_path: archives + position: 2 cupcake_home: id: 3 site_id: 2 @@ -25,6 +27,7 @@ template: home.liquid articles_count: 1 archive_path: archives + position: 1 cupcake_about: id: 4 site_id: 2 @@ -34,6 +37,7 @@ template: page.liquid articles_count: 1 archive_path: archives + position: 2 earth: id: 5 site_id: 1 @@ -42,6 +46,7 @@ show_paged_articles: false articles_count: 0 archive_path: archives + position: 3 europe: id: 6 site_id: 1 @@ -50,6 +55,7 @@ show_paged_articles: false articles_count: 0 archive_path: archives + position: 4 africa: id: 7 site_id: 1 @@ -58,6 +64,7 @@ show_paged_articles: false articles_count: 0 archive_path: archives + position: 5 bucharest: id: 8 site_id: 1 @@ -66,6 +73,7 @@ show_paged_articles: false articles_count: 0 archive_path: archives + position: 6 links: id: 9 site_id: 1 @@ -75,3 +83,14 @@ template: page.liquid articles_count: 0 archive_path: archives + position: 7 +paged_section: + id: 10 + site_id: 1 + name: Paged Section + path: paged-section + show_paged_articles: true + template: page.liquid + articles_count: 2 + archive_path: archives + position: 8 \ No newline at end of file diff -Nur mephisto-0.7.3/test/fixtures/sites.yml technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/sites.yml --- mephisto-0.7.3/test/fixtures/sites.yml 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/fixtures/sites.yml 2008-03-31 02:18:56.000000000 -0400 @@ -7,7 +7,7 @@ first: id: 1 title: Mephisto - host: test.com + host: test.host filter: textile_filter approve_comments: false comment_age: 30 diff -Nur mephisto-0.7.3/test/functional/admin/admin_nav_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/admin_nav_test.rb --- mephisto-0.7.3/test/functional/admin/admin_nav_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/admin_nav_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -11,7 +11,7 @@ @controller = Admin::AssetsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - login_as :quentin + login_as :arthur get :new end @@ -63,3 +63,39 @@ end end end + +class Admin::GlobalAdminNavTest < Test::Unit::TestCase + fixtures :sites, :users, :memberships + + def setup + @old = Site.multi_sites_enabled + @controller = Admin::AssetsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + Site.multi_sites_enabled = true + login_as :quentin + get :new + end + + def teardown + Site.multi_sites_enabled = @old + end + + def test_should_show_primary_nav + assert_select "#header #nav a" do |anchors| + assert_equal %w(Overview Articles Assets), anchors[0..2].collect { |a| a.children.first.content } + end + end + + def test_should_show_secondary_nav + assert_select "#header #nav #nav-r a" do |anchors| + assert_equal %w(Sections Design Users), anchors.collect { |a| a.children.first.content } + end + end + + def test_should_show_user_nav + assert_select "#header #sec-nav a" do |anchors| + assert_equal %w(Website Settings Sites Account Logout), anchors.collect { |a| a.children.first.content } + end + end +end diff -Nur mephisto-0.7.3/test/functional/admin/articles_controller_assets_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/articles_controller_assets_test.rb --- mephisto-0.7.3/test/functional/admin/articles_controller_assets_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/articles_controller_assets_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -4,10 +4,10 @@ # Re-raise errors caught by the controller. class Admin::ArticlesController; def rescue_action(e) raise e end; end -class Admin::ArticlesControllerAssetsTest < Test::Unit::TestCase - fixtures :contents, :content_versions, :sections, :assigned_sections, :users, :sites, :tags, :taggings, :memberships +context "Admin Articles Controller Assets" do + fixtures :contents, :content_versions, :sections, :assigned_sections, :users, :sites, :tags, :taggings, :memberships, :assigned_assets, :assets - def setup + setup do @controller = Admin::ArticlesController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @@ -15,8 +15,8 @@ FileUtils.mkdir_p ASSET_PATH end - def test_should_upload_asset - asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails + specify "should upload asset" do + asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails assert_difference Asset, :count, asset_count do post :upload, :asset => { :uploaded_data => fixture_file_upload('assets/logo.png', 'image/png') } @@ -25,8 +25,8 @@ end end - def test_should_upload_asset_and_redirect_to_article - asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails + specify "should upload asset and redirect to article" do + asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails assert_difference Asset, :count, asset_count do post :upload, :id => contents(:welcome).id, @@ -37,8 +37,8 @@ end end - def test_should_upload_asset_as_member - asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails + specify "should upload asset as member" do + asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails login_as :ben assert_difference Asset, :count, asset_count do @@ -48,8 +48,8 @@ end end - def test_should_upload_asset_and_redirect_to_article_as_member - asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails + specify "should upload asset and redirect to article as member" do + asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails login_as :ben assert_difference Asset, :count, asset_count do @@ -61,7 +61,7 @@ end end - def test_should_not_error_on_new_article_asset_upload + specify "should not error on new article asset upload" do assert_no_difference Asset, :count do post :upload assert_response :success @@ -69,7 +69,7 @@ end end - def test_should_not_error_on_article_asset_upload + specify "should not error on article asset upload" do assert_no_difference Asset, :count do post :upload, :id => contents(:welcome).id assert_response :success @@ -78,7 +78,7 @@ end end - def test_should_not_create_article_when_uploading_asset + specify "should not create article when uploading asset" do Time.mock! Time.local(2005, 1, 1, 12, 0, 0) do assert_no_difference Article, :count do post :upload, :asset => { :uploaded_data => fixture_file_upload('assets/logo.png', 'image/png') }, @@ -94,7 +94,34 @@ end end - def teardown + # TODO: Fails due to asset test deleting asset fixtures + specify "should add asset to article" do + return if Asset.count == 1 + assert_difference AssignedAsset, :count do + post :attach, :id => contents(:welcome).id, :version => assets(:mov).id + end + assert_models_equal [assets(:gif), assets(:mp3), assets(:mov)], contents(:welcome).assets(true) + end + + # TODO: Fails due to asset test deleting asset fixtures + specify "should add inactive asset to article" do + return if Asset.count == 1 + assert_no_difference AssignedAsset, :count do + post :attach, :id => contents(:welcome).id, :version => assets(:png).id + end + assert_models_equal [assets(:gif), assets(:mp3), assets(:png)], contents(:welcome).assets(true) + end + + # TODO: Fails due to asset test deleting asset fixtures + specify "should find deactivate article assets" do + return if Asset.count == 1 + assert_no_difference AssignedAsset, :count do + post :detach, :id => contents(:welcome).id, :version => assets(:mp3).id + end + assert_models_equal [assets(:gif)], contents(:welcome).assets + end + + teardown do FileUtils.rm_rf ASSET_PATH end end diff -Nur mephisto-0.7.3/test/functional/admin/articles_controller_permissions_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/articles_controller_permissions_test.rb --- mephisto-0.7.3/test/functional/admin/articles_controller_permissions_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/articles_controller_permissions_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -16,7 +16,7 @@ def test_should_show_articles get :index - assert_equal 10, assigns(:articles).length + assert_equal 12, assigns(:articles).length end def test_should_show_new_article_form diff -Nur mephisto-0.7.3/test/functional/admin/articles_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/articles_controller_test.rb --- mephisto-0.7.3/test/functional/admin/articles_controller_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/articles_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -28,12 +28,12 @@ def test_should_show_articles get :index - assert_equal 10, assigns(:articles).length + assert_equal 12, assigns(:articles).length end def test_should_show_articles_with_empty_seartest_should_show_checked_sectionsch get :index, :q => '', :filter => 'title', :section => '0' - assert_equal 10, assigns(:articles).length + assert_equal 12, assigns(:articles).length end def test_should_search_article_titles @@ -57,7 +57,7 @@ def test_should_search_article_by_section get :index, :filter => 'section', :section => '2' assert_response :success - assert_models_equal [contents(:welcome), contents(:about), contents(:site_map)], assigns(:articles) + assert_models_equal [contents(:future), contents(:welcome), contents(:about), contents(:site_map), contents(:draft)], assigns(:articles) end def test_should_search_article_by_section_and_title @@ -125,7 +125,7 @@ def test_should_show_default_checked_sections get :new assert_response :success - assert_tag 'form', :attributes => { :action => '/admin/articles/create' } + assert_tag 'form', :attributes => { :action => '/admin/articles', :method => 'post' } assert_tag 'input', :attributes => { :id => "article_section_ids_#{sections(:home).id.to_s}" } assert_no_tag 'input', :attributes => { :id => "article_section_ids_#{sections(:about).id.to_s}", :checked => 'checked' } end @@ -162,7 +162,7 @@ def test_should_show_available_years_for_old_article contents(:welcome).update_attribute(:published_at, Time.utc(2003,1,1)) get :edit, :id => contents(:welcome).id - (2003..Time.now.utc.year).to_a.each do |year| + (2003..2007).to_a.each do |year| assert_select "select[name='article[published_at(1i)]'] option[value='#{year}']" end end @@ -182,7 +182,9 @@ def test_edit_form_should_have_correct_post_action get :edit, :id => contents(:welcome).id assert_response :success - assert_tag :tag => 'form', :attributes => { :action => "/admin/articles/update/#{contents(:welcome).id}" } + assert_tag :tag => 'form', :attributes => { :action => "/admin/articles/#{contents(:welcome).id}" } do + assert_tag :tag => 'input', :attributes => { :name => "_method", :value => "put" } + end end def test_should_update_article_with_correct_time diff -Nur mephisto-0.7.3/test/functional/admin/assets_controller_permissions_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/assets_controller_permissions_test.rb --- mephisto-0.7.3/test/functional/admin/assets_controller_permissions_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/assets_controller_permissions_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -21,7 +21,7 @@ end def test_should_upload_and_create_asset_records - asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails + asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails assert_difference sites(:first).assets, :count do assert_difference Asset, :count, asset_count do @@ -29,7 +29,7 @@ assert_equal users(:ben).id, assigns(:assets).first.user_id assert_equal 'logo.png', assigns(:assets).first.title assert_match /logo\.png/, flash[:notice] - assert_redirected_to asset_path + assert_redirected_to assets_path end end end @@ -74,7 +74,7 @@ assert_response :success assert_match /Flash\.notice/, @response.body assert_equal 1, session[:bucket].size - assert_kind_of Array, session[:bucket][assets(:gif).public_filename] + assert_kind_of Array, session[:bucket][assets(:gif).id] end def test_should_clear_bucket diff -Nur mephisto-0.7.3/test/functional/admin/assets_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/assets_controller_test.rb --- mephisto-0.7.3/test/functional/admin/assets_controller_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/assets_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -21,14 +21,14 @@ end def test_should_upload_and_create_asset_records - asset_count = Object.const_defined?(:Magick) ? 3 : 1 # asset + 2 thumbnails + asset_count = has_image_processor? ? 3 : 1 # asset + 2 thumbnails assert_difference sites(:first).assets, :count do assert_difference Asset, :count, asset_count do process_upload ['logo.png'] assert_equal 'logo.png', assigns(:assets).first.title assert_match /logo\.png/, flash[:notice] - assert_redirected_to asset_path + assert_redirected_to assets_path end end end @@ -53,12 +53,12 @@ end def test_should_upload_multiple_assets_and_ignore_titles - asset_count = Object.const_defined?(:Magick) ? 6 : 2 # asset + 2 thumbnails + asset_count = has_image_processor? ? 6 : 2 # asset + 2 thumbnails assert_difference sites(:first).assets, :count, 2 do assert_difference Asset, :count, asset_count do process_upload %w(logo.png logo.png) assert_match /2 assets/, flash[:notice] - assert_redirected_to asset_path + assert_redirected_to assets_path end end end @@ -138,16 +138,16 @@ assert_response :success assert_match /Flash\.notice/, @response.body assert_equal 1, session[:bucket].size - assert_kind_of Array, session[:bucket][assets(:gif).public_filename] + assert_kind_of Array, session[:bucket][assets(:gif).id] end def test_should_not_add_duplicate_asset_to_bucket - @request.session[:bucket] = {assets(:gif).public_filename => []} + @request.session[:bucket] = {assets(:gif).id => []} xhr :post, :add_bucket, :id => assets(:gif).id assert_response :success assert_equal ' ', @response.body assert_equal 1, session[:bucket].size - assert_kind_of Array, session[:bucket][assets(:gif).public_filename] + assert_kind_of Array, session[:bucket][assets(:gif).id] end def test_should_clear_bucket diff -Nur mephisto-0.7.3/test/functional/admin/assets_controller_upload_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/assets_controller_upload_test.rb --- mephisto-0.7.3/test/functional/admin/assets_controller_upload_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/assets_controller_upload_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -16,7 +16,7 @@ Fixtures.delete_existing_fixtures_for(Asset.connection, :assets) end -if Object.const_defined?(:Magick) +if has_image_processor? def test_should_sort_assets assert_difference sites(:first).assets, :count, 21 do assert_difference Asset, :count, 63 do diff -Nur mephisto-0.7.3/test/functional/admin/comments_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/comments_controller_test.rb --- mephisto-0.7.3/test/functional/admin/comments_controller_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/comments_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -10,7 +10,7 @@ @controller = Admin::CommentsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - login_as :ben + login_as :quentin end def test_should_disable_comments_on_article @@ -18,4 +18,60 @@ assert_equal -1, contents(:welcome).reload.comment_age assert_response :success end + + def test_should_destroy_comment + comment = contents(:welcome_comment) + + xhr :delete, :destroy, :id => '3', :article_id => '1' + assert_response :success + assert_equal [comment], assigns(:comments) + assert_raise(ActiveRecord::RecordNotFound) { comment.reload } + end + + def test_should_destroy_comments + comment = contents(:welcome_comment) + + xhr :delete, :destroy, :comment => ['3'], :article_id => '1' + assert_response :success + assert_equal [comment], assigns(:comments) + assert_raise(ActiveRecord::RecordNotFound) { comment.reload } + end + + def test_should_list_comments_on_article + get :index, :article_id => '1' + assert_response :success + end + + def test_should_list_approved_comments_on_article + get :index, :article_id => '1', :filter => 'approved' + assert_response :success + end + + def test_should_list_unapproved_comments_on_article + get :index, :article_id => '1', :filter => 'unapproved' + assert_response :success + end + + def test_should_create_comment + post :create, :article_id => '1', :comment => {} + assert_response :success + end + + def test_should_edit_comment + get :edit, :article_id => '1', :id => '3' + assert_response :success + end + + def test_should_approve_comment + contents(:welcome_comment).update_attribute(:approved, false) + xhr :get, :approve, :article_id => '1', :id => '3' + assert_response :success + end + + def test_should_unapprove_comment + xhr :get, :unapprove, :article_id => '1', :id => '3' + assert_response :success + assert_template 'approve' + end + end diff -Nur mephisto-0.7.3/test/functional/admin/plugins_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/plugins_controller_test.rb --- mephisto-0.7.3/test/functional/admin/plugins_controller_test.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/plugins_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,66 @@ +require File.dirname(__FILE__) + '/../../test_helper' +require 'admin/plugins_controller' + +class Admin::PluginsControllerTest < Test::Unit::TestCase + fixtures :contents, :content_versions, :sections, :assigned_sections, :users, :sites, :tags, :taggings, :memberships + @@test_plugin_dir = RAILS_PATH + 'test/fixtures/plugins/lib' + @@plugin_dir = RAILS_PATH + 'vendor/plugins/mephisto_test_plugin' + @@plugin_lib_dir = @@plugin_dir + 'lib' + + def setup + @controller = Admin::PluginsController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + login_as :quentin + + #here we create a temporary and simple plugin + FileUtils.mkdir_p(@@plugin_dir) + FileUtils.cp_r @@test_plugin_dir, @@plugin_dir + $LOAD_PATH << @@plugin_lib_dir.to_s + load @@plugin_lib_dir + 'test_plugin.rb' + end + + def teardown + $LOAD_PATH.delete @@plugin_lib_dir.to_s + FileUtils.rm_rf(@@plugin_dir) + end + + def test_should_list_plugins + get :index + assert_response :success + + test_dir_plugin = assigns(:plugins).detect { |p| p.path == 'test_plugin' } + + assert test_dir_plugin.configurable?, "Test Plugin is not configurable!" + end + + def test_should_show_plugin + assert_not_nil Mephisto::Plugins::TestPlugin.new + get :show, :id => 'test_plugin' + assert_response :success + end + + def test_should_update_plugin_options + get :update, :id => 'test_plugin', :options => { :notes => 'foo bar' } + assert_redirected_to :action => "show" + + assert_equal "foo bar", assigns(:plugin).notes + end + + def test_should_delete_plugin + test_should_update_plugin_options + get :destroy, :id => 'test_plugin' + assert_redirected_to :action => "show" + + + # weird, in the below the assigns hash holds the plugin object from delete + # not the second plugin reloaded from show. So I suppose assigns is built by + # the get. + # I'd like to work out a way to access the plugin object reloaded in the 302 show. + # + # TODO: Convert to integration test for this + # + # plugin = assigns["plugin"] + # assert_equal "test", plugin.config["one"] + end +end \ No newline at end of file diff -Nur mephisto-0.7.3/test/functional/admin/sections_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/sections_controller_test.rb --- mephisto-0.7.3/test/functional/admin/sections_controller_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/sections_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -18,9 +18,9 @@ get :index assert_equal sites(:first), assigns(:site) assert_equal sections(:home), assigns(:home) - assert_equal 7, assigns(:sections).length, "Sections: #{assigns(:sections).collect(&:id).to_sentence}" + assert_equal 8, assigns(:sections).length, "Sections: #{assigns(:sections).collect(&:id).to_sentence}" assert_equal 4, assigns(:article_count)['1'] - assert_equal 3, assigns(:article_count)['2'] + assert_equal 5, assigns(:article_count)['2'] end def test_should_create_blog_section @@ -67,8 +67,8 @@ def test_should_reorder_articles assert_reorder_articles sections(:about), - [contents(:welcome), contents(:about), contents(:site_map)], - [contents(:about), contents(:site_map), contents(:welcome)] + [contents(:welcome), contents(:about), contents(:site_map), contents(:draft), contents(:future)], + [contents(:future), contents(:about), contents(:site_map), contents(:welcome), contents(:draft)] end def test_should_destroy_section @@ -77,8 +77,8 @@ end def test_should_reorder_sections - assert_reorder_sections [sections(:home), sections(:about), sections(:earth), sections(:europe), sections(:africa), sections(:bucharest), sections(:links)], - [sections(:home), sections(:earth), sections(:europe), sections(:africa), sections(:bucharest), sections(:links), sections(:about)] + assert_reorder_sections [sections(:home), sections(:about), sections(:earth), sections(:europe), sections(:africa), sections(:bucharest), sections(:links), sections(:paged_section)], + [sections(:home), sections(:earth), sections(:europe), sections(:africa), sections(:bucharest), sections(:links), sections(:about), sections(:paged_section)] end protected diff -Nur mephisto-0.7.3/test/functional/admin/settings_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/settings_controller_test.rb --- mephisto-0.7.3/test/functional/admin/settings_controller_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/settings_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -27,8 +27,7 @@ def test_should_clear_layouts login_as :quentin - post :update, :site => { :title => 'foo', :search_layout => '-', :tag_layout => '-' } - assert_nil sites(:first).reload.search_layout + post :update, :site => { :title => 'foo', :tag_layout => '-' } assert_nil sites(:first).tag_layout end diff -Nur mephisto-0.7.3/test/functional/admin/sites_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/sites_controller_test.rb --- mephisto-0.7.3/test/functional/admin/sites_controller_test.rb 1969-12-31 19:00:00.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/sites_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -0,0 +1,58 @@ +require File.dirname(__FILE__) + '/../../test_helper' +require 'admin/sites_controller' + +# Re-raise errors caught by the controller. +class Admin::SitesController; def rescue_action(e) raise e end; end + +class Admin::SitesControllerTest < Test::Unit::TestCase + fixtures :users, :sites + def setup + @controller = Admin::SitesController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + def test_should_allow_admin_of_sites + login_as :quentin + get :index + assert_response :success + end + + def test_should_restrict_admin_of_sites + login_as :arthur + get :index + assert_redirected_to :controller => 'account', :action => 'login' + end + + def test_should_allow_admin_to_view_site + login_as :quentin + get :show, :id => sites(:hostess).id.to_s + assert_response :success + end + + def test_should_create_site + login_as :quentin + assert_difference Site, :count do + post :create, :site => { :host => 'example.com', :email => 'foo@example.com', :title => 'example', :subtitle => 'example site' } + assert_redirected_to :action => 'index' + assert flash[:notice] + end + end + + def test_should_show_error_while_creating_site + login_as :quentin + assert_no_difference Site, :count do + post :create, :site => { :host => 'not a valid host' } + assert_response :success + end + end + + def test_should_destroy_site + login_as :quentin + assert_difference Site, :count, -1 do + post :destroy, :id => sites(:hostess).id.to_s + assert_redirected_to :action => 'index' + end + end + +end diff -Nur mephisto-0.7.3/test/functional/admin/themes_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/themes_controller_test.rb --- mephisto-0.7.3/test/functional/admin/themes_controller_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/themes_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -4,9 +4,10 @@ # Re-raise errors caught by the controller. class Admin::ThemesController; def rescue_action(e) raise e end; end -class Admin::ThemesControllerTest < Test::Unit::TestCase +context "Admin Themes Controller" do fixtures :users, :sections, :sites, :memberships - def setup + + setup do @controller = Admin::ThemesController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new diff -Nur mephisto-0.7.3/test/functional/admin/users_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/users_controller_test.rb --- mephisto-0.7.3/test/functional/admin/users_controller_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/admin/users_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -5,7 +5,7 @@ class Admin::UsersController; def rescue_action(e) raise e end; end class Admin::UsersControllerTest < Test::Unit::TestCase - fixtures :users, :sites, :memberships + fixtures :users, :sites, :memberships, :contents def setup @controller = Admin::UsersController.new @request = ActionController::TestRequest.new @@ -40,7 +40,7 @@ login_as :quentin assert_difference User, :count do assert_difference Membership, :count do - post :create, :user => { :login => 'bob', :email => 'foo@example.com', :password => 'testy', :password_confirmation => 'testy', :admin => true } + post :create, :user => { :login => 'bob', :email => 'foo@example.com', :password => 'testy', :password_confirmation => 'testy' } assert_models_equal [sites(:first)], assigns(:user).sites assert_equal assigns(:user), User.authenticate_for(sites(:first), 'bob', 'testy') assert_redirected_to :action => 'index' @@ -114,6 +114,36 @@ assert_equal 'markdown_filter', users(:quentin).filter end + def test_should_not_permit_promoting_self_to_admin_in_update + login_as :arthur, :hostess + assert !users(:arthur).admin, "we mean to test with a non-admin user" + post :update, :id => users(:arthur).id, :user => { :admin => 'true' } + users(:arthur).reload + assert !users(:arthur).admin, "user.admin shouldn't change" + assert_response :success + end + + def test_should_not_permit_changing_own_created_at_in_update + login_as :arthur, :hostess + prev_time = users(:arthur).created_at + post :update, :id => users(:arthur).id, :user => { :created_at => prev_time - 1.year } + users(:arthur).reload + assert_equal prev_time, users(:arthur).created_at, "user.created_at shouldn't change" + assert_response :success + end + + def test_should_not_permit_changing_owned_articles_in_update + login_as :quentin + user = users(:quentin) + prev_article_ids = user.article_ids + assert prev_article_ids.size > 2, "Test needs more than 2 articles. Pick another user?" + #but now we're going to try to own only the first 2 of them... + post :update, :id => user.id, :user => { :article_ids => prev_article_ids[0..1] } + user.reload + assert_equal prev_article_ids, user.article_ids, "user.article_ids[] shouldn't change" + assert_response :success + end + def test_should_show_deleted_users login_as :quentin get :index @@ -137,11 +167,36 @@ end end - def test_should_disable_site_admin + def test_should_toggle_site_admin_as_admin login_as :quentin xhr :post, :admin, :id => users(:arthur).id assert_response :success assert !sites(:first).user(users(:arthur).id).site_admin? + assert_match /Flash\.notice/, @response.body + end + + def test_should_toggle_site_admin_as_site_admin + login_as :arthur + assert !sites(:first).user(users(:ben).id).site_admin? + xhr :post, :admin, :id => users(:ben).id + assert_response :success + assert sites(:first).user(users(:ben).id).site_admin? + assert_match /Flash\.notice/, @response.body + end + + def test_should_not_toggle_site_admin_for_admin + login_as :arthur + xhr :post, :admin, :id => users(:quentin).id + assert_response :success + assert_match /Flash\.errors/, @response.body + end + + def test_should_not_toggle_site_admin_for_self + login_as :arthur + xhr :post, :admin, :id => users(:arthur).id + assert_response :success + assert sites(:first).user(users(:arthur).id).site_admin? + assert_match /Flash\.errors/, @response.body end def test_should_enable_site_admin @@ -156,12 +211,35 @@ login_as :quentin assert_no_difference User, :count_with_deleted do assert_difference User, :count, -1 do - xhr :post, :destroy, :id => users(:quentin).id + xhr :post, :destroy, :id => users(:arthur).id assert_response :success + assert_match /Flash\.notice/, @response.body end end - assert_equal users(:quentin), User.find_with_deleted(users(:quentin).id) + assert_equal users(:arthur), User.find_with_deleted(users(:arthur).id) + end + + def test_should_not_disable_admin + login_as :arthur + assert_no_difference User, :count_with_deleted do + assert_no_difference User, :count do + xhr :post, :destroy, :id => users(:quentin).id + assert_response :success + assert_match /Flash\.errors/, @response.body + end + end + end + + def test_should_not_disable_self + login_as :arthur + assert_no_difference User, :count_with_deleted do + assert_no_difference User, :count do + xhr :post, :destroy, :id => users(:arthur).id + assert_response :success + assert_match /Flash\.errors/, @response.body + end + end end def test_should_enable_user diff -Nur mephisto-0.7.3/test/functional/application_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/application_controller_test.rb --- mephisto-0.7.3/test/functional/application_controller_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/application_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -12,33 +12,40 @@ class ApplicationControllerTest < Test::Unit::TestCase fixtures :sites def setup - @sub = Site.create!(:title => 'sub', :host => 'sub.test.com') + @sub = Site.create!(:title => 'sub', :host => 'sub.test.host') @uk = Site.create!(:title => 'sub', :host => 'sub.test.co.uk') @controller = AccountController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end + + def test_should_raise_404_if_no_site + Site.delete_all + host! 'test.hosts' + get :test_host + assert_response :missing + end def test_should_find_site_by_host - host! 'test.com' + host! 'test.host' get :test_host assert_equal sites(:first), @controller.site end def test_should_find_site_with_www_prefix - host! 'www.test.com' + host! 'www.test.host' get :test_host assert_equal sites(:first), @controller.site end def test_should_find_site_by_subdomain_and_host - host! 'sub.test.com' + host! 'sub.test.host' get :test_host assert_equal @sub, @controller.site end def test_should_find_site_by_subdomain_and_host_with_www_prefix - host! 'www.sub.test.com' + host! 'www.sub.test.host' get :test_host assert_equal @sub, @controller.site end diff -Nur mephisto-0.7.3/test/functional/application_helper_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/application_helper_test.rb --- mephisto-0.7.3/test/functional/application_helper_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/application_helper_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -55,14 +55,6 @@ assert_match assets(:png).public_filename, asset_image_for(assets(:png)) end - def test_should_not_sanitize_tables - assert_equal "<table>", sanitize_feed_content('') - end - - def test_should_sanitize_tables - assert_equal "&lt;table>", sanitize_feed_content('
      ', true) - end - protected def asset_image_args_for(*args) controller.send(:asset_image_args_for, *args) diff -Nur mephisto-0.7.3/test/functional/backend_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/backend_controller_test.rb --- mephisto-0.7.3/test/functional/backend_controller_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/backend_controller_test.rb 1969-12-31 19:00:00.000000000 -0500 @@ -1,303 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'meta_weblog_api' -require 'movable_type_api' -require 'backend_controller' - -# Re-raise errors caught by the controller. -class BackendController; def rescue_action(e) raise e end; end - -class BackendControllerTest < Test::Unit::TestCase - fixtures :users, :sections, :assigned_sections, :contents, :sites - - def setup - @controller = BackendController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @protocol = :xmlrpc - FileUtils.mkdir_p ASSET_PATH - end - - def teardown - FileUtils.rm_rf ASSET_PATH - end - - # Movable Type Backend Api Tests - def test_movable_type_get_category_list - # test test_movable_type_get_category_list - args = [ 1, 'quentin', 'test' ] - - result = invoke_layered :mt, :getCategoryList, *args - assert_equal 'Home', result.first['categoryName'] - end - - def test_movable_type_get_post_categories - # test test_movable_type_get_post_categories - args = [ 1, 'quentin', 'test' ] - - result = invoke_layered :mt, :getPostCategories, *args - assert_equal %w(About Home), result.collect { |c| c['categoryName'] } - end - - def test_movable_type_set_post_categories - # test test_movable_type_set_post_categories - # this needs some work!! FIXME FIXME FIXME - - c1 = MovableTypeStructs::PostCategory.new(:categoryId => 1, :categoryName => 'Home', :isPrimary => false) - c2 = MovableTypeStructs::PostCategory.new(:categoryId => 2, :categoryName => 'About', :isPrimary => false) - c3 = MovableTypeStructs::PostCategory.new(:categoryId => 9, :categoryName => 'Links', :isPrimary => false) - - args = [ 1, 'quentin', 'test', [ c1, c2, c3 ]] - - result = invoke_layered :mt, :setPostCategories, *args - assert_equal true, result - - # see if the categories have been set - args = [ 1, 'quentin', 'test' ] - - result = invoke_layered :mt, :getPostCategories, *args - assert_equal ["1","2","9"], result.collect { |c| c['categoryId'] }.sort - - # set the categories back to the default - args = [ 1, 'quentin', 'test', [c1,c2] ] - - result = invoke_layered :mt, :setPostCategories, *args - assert_equal true, result - end - - def test_movable_type_supported_methods - # test test_movable_type_supported_methods - result = invoke_layered :mt, :supportedMethods - - assert_instance_of Array, result - end - - def test_movable_type_supported_text_filters - # test test_movable_type_supported_text_filters - result = invoke_layered :mt, :supportedTextFilters - - assert_instance_of Array, result - end - - - - def test_meta_weblog_get_categories - args = [ 1, 'quentin', 'test' ] - - result = invoke_layered :metaWeblog, :getCategories, *args - assert_equal 'Home', result.first - end - - def test_meta_weblog_get_post - args = [ 1, 'quentin', 'test' ] - - result = invoke_layered :metaWeblog, :getPost, *args - assert_equal 'Welcome to Mephisto', result['title'], result.inspect - assert_equal %w(About Home), result['categories'] - end - - def test_meta_weblog_get_recent_posts - args = [ 1, 'quentin', 'test', 2 ] - - articles = invoke_layered :metaWeblog, :getRecentPosts, *args - assert_equal %w(test-draft article-in-the-future), articles.collect { |a| a['permaLink'] }, articles.inspect - end - - def test_meta_weblog_delete_post - args = [ 1, 1, 'quentin', 'test', 1 ] - - assert_difference Article, :count, -1 do - result = invoke_layered :metaWeblog, :deletePost, *args - end - end - - def test_meta_weblog_edit_post - post_time = Time.now.midnight.utc - article = contents(:welcome) - article.title = "Modified!" - article.body = "this is a *test*" - article.excerpt = "* one\n* two\n" - article.published_at = post_time - - struct = MetaWeblogService.new(@controller).article_dto_from(article) - invoke_layered :metaWeblog, :editPost, contents(:welcome).id, 'quentin', 'test', struct, true - - assert_equal post_time, struct['dateCreated'] - - assert_equal 'Modified!', article.reload.title - assert_equal "

      this is a test

      ", article.body_html, article.inspect - assert_equal "
        \n\t
      • one
      • \n\t\t
      • two
      • \n\t
      ", article.excerpt_html, article.inspect - assert_equal post_time, article.published_at - assert_equal users(:quentin), article.updater - end - - def test_meta_weblog_new_post - assert_difference Article, :count do - article = Article.new - article.title = "Posted via Test" - article.body = "body" - article.excerpt = "extend me" - article.published_at = Time.now.midnight.utc - - args = [ 1, 'quentin', 'test', MetaWeblogService.new(@controller).article_dto_from(article), 1 ] - - result = invoke_layered :metaWeblog, :newPost, *args - assert result - new_post = Article.find(result) - - assert_equal "Posted via Test", new_post.title - assert_equal article.body, new_post.body - assert_equal "

      body

      ", new_post.body_html - assert_equal "

      extend me

      ", new_post.excerpt_html - end - end - - def test_meta_weblog_new_post_tags - # test weather we can create a new post, set tags and get away with it... - tags = 'blog, emacs, fun, rails, ruby' - article = MetaWeblogStructs::Article.new(:title => 'This is a title', :description => 'This is a post', :mt_keywords => tags) - - args = [ 1, 'quentin', 'test', article, 1 ] - - result = invoke_layered :metaWeblog, :newPost, *args - # assert result - new_post = Article.find(result) - assert_equal Tag.parse_to_tags(tags).collect(&:name).sort, new_post.tags.collect(&:name).sort - end - - def test_meta_weblog_edit_post_tags - # changing tags - tags = 'blog, emacs, fun, rails, ruby' - article = MetaWeblogStructs::Article.new(:title => 'This is a title', :description => 'This is a post', :mt_keywords => tags) - args = [ 1, 'quentin', 'test', article, 1 ] - post_id = invoke_layered :metaWeblog, :newPost, *args - - new_post = Article.find(post_id) - assert_equal Tag.parse_to_tags(tags).collect(&:name).sort, new_post.tags.collect(&:name).sort - - tags = 'bar, baz, foo' - article = MetaWeblogStructs::Article.new(:title => 'This is a title', :description => 'This is a post', :mt_keywords => tags) - args = [ post_id, 'quentin', 'test', article, 1] - edit_result = invoke_layered :metaWeblog, :editPost, *args - assert_equal true, edit_result - - new_post = Article.find(post_id) - assert_equal Tag.parse_to_tags(tags).collect(&:name).sort, new_post.tags.collect(&:name).sort - end - - def test_meta_weblog_get_post_with_tags - # set tags and see if we recive them! - tags = 'blog, emacs, fun, rails, ruby' - article = MetaWeblogStructs::Article.new(:title => 'This is a title', :description => 'This is a post', :mt_keywords => tags) - - args = [ 1, 'quentin', 'test', article, 1 ] - post_id = invoke_layered :metaWeblog, :newPost, *args - - args = [ post_id, 'quentin', 'test' ] - result = invoke_layered :metaWeblog, :getPost, *args - - assert_equal tags, result['mt_keywords'] - end - - - def test_meta_weblog_new_post_min - # This is going to test weather a post is correctly submited or not without the published_at field! - # See http://www.xmlrpc.com/metaWeblogApi#theStruct or - # See http://www.sixapart.com/developers/xmlrpc/metaweblog_api/metaweblognewpost.html for more information - assert_difference Article, :count do - article = Article.new - article.title = 'This is a title' - article.body = 'This is a post' - - args = [ 1, 'quentin', 'test', MetaWeblogService.new(@controller).article_dto_from(article), 1 ] - - result = invoke_layered :metaWeblog, :newPost, *args - assert result - new_post = Article.find(result) - - assert_equal 'This is a post', new_post.body - assert_equal '

      This is a post

      ', new_post.body_html - assert_equal 'This is a title', new_post.title - assert_equal :published, new_post.status - end - end - - def test_meta_weblog_new_post_publish - # Test weather publish is set correctly on 1 and true to :published otherwise :pending - [{ :set => 1, :expect => :published }, - { :set => 0, :expect => :pending }, - { :set => true, :expect => :published}, - { :set => false, :expect => :pending }].each do |c| - assert_difference Article, :count do - article = Article.new - article.title = 'This is a title' - article.body = 'This is a post' - - args = [ 1, 'quentin', 'test', MetaWeblogService.new(@controller).article_dto_from(article), c[:set] ] - - result = invoke_layered :metaWeblog, :newPost, *args - assert result - new_post = Article.find(result) - - assert_equal 'This is a post', new_post.body - assert_equal '

      This is a post

      ', new_post.body_html - assert_equal 'This is a title', new_post.title - assert_equal c[:expect], new_post.status - end - end - end - - def test_should_upload_file_via_meta_weblog_new_media_object - now = Time.now.utc - media_object = new_media_object - - args = [ 1, 'quentin', 'test', media_object ] - result = invoke_layered :metaWeblog, :newMediaObject, *args - assert result['url'] =~ /#{media_object['name']}$/ - - assert_file_exists File.join(ASSET_PATH, now.year.to_s, now.month.to_s, now.day.to_s, media_object['name']) - end - - def test_should_guess_content_type_for_gif - media_object = new_media_object 'type' => nil, :name => 'filename.gif' - assert_nil media_object['type'] - - args = [ 1, 'quentin', 'test', media_object ] - result = invoke_layered :metaWeblog, :newMediaObject, *args - - new_asset = Asset.find :first, :order => 'created_at DESC' - assert_equal 'image/gif', new_asset.content_type - end - - def test_should_guess_content_type_for_jpg - media_object = new_media_object 'type' => nil - assert_nil media_object['type'] - - args = [ 1, 'quentin', 'test', media_object ] - result = invoke_layered :metaWeblog, :newMediaObject, *args - - new_asset = Asset.find :first, :order => 'created_at DESC' - assert_equal 'image/jpeg', new_asset.content_type - end - - def test_should_show_filters - result = invoke_layered :mt, :supportedTextFilters - filters = %w(textile_filter markdown_filter smartypants_filter) - result.each { |f| filters.include? f[:key] } - end - - def test_meta_weblog_fail_authentication - args = [ 1, 'quentin', 'using a wrong password', 2 ] - # This will be a little more useful with the upstream changes in [1093] - assert_raise(XMLRPC::FaultException) { invoke_layered :metaWeblog, :getRecentPosts, *args } - end - - protected - - def new_media_object(options = {}) - MetaWeblogStructs::MediaObject.new(options.reverse_merge!( - 'name' => Digest::SHA1.hexdigest("upload-test--#{Time.now}--") + ".jpg", - 'type' => 'image/jpeg', - 'bits' => Base64.encode64(File.open(File.expand_path(RAILS_ROOT) + '/public/images/mephisto/shadow.png', 'rb') { |f| f.read }) - )) - end -end diff -Nur mephisto-0.7.3/test/functional/feed_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/feed_controller_test.rb --- mephisto-0.7.3/test/functional/feed_controller_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/feed_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -12,14 +12,6 @@ @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end - - def test_feed_assigns - get :feed, :sections => ['about'] - assert_equal sections(:about), assigns(:section) - assert_equal [contents(:welcome), contents(:about), contents(:site_map)], assigns(:articles) - assert_select 'feed>title', 'Mephisto - About' - assert_atom_entries_size 3 - end def test_feed_comes_from_site host! 'cupcake.com' @@ -35,13 +27,12 @@ assert_models_equal [sections(:cupcake_home)], [assigns(:section)] assert_models_equal [contents(:cupcake_welcome)], assigns(:articles) assert_atom_entries_size 1 - assert_tag 'link', :attributes => {:href => 'http://cupcake.com/'} + assert_select 'link[href=?]', 'http://cupcake.com/' end def test_should_return_record_not_found_for_bad_feed_urls - assert_raise ActiveRecord::RecordNotFound do - get :feed, :sections => %w(beastie boys) - end + get :feed, :sections => %w(beastie boys) + assert_equal '404', @response.code end def test_should_find_comments_by_site @@ -61,8 +52,44 @@ end end +context "About Section Feed" do + fixtures :contents, :sections, :assigned_sections, :sites, :users, :assets, :assigned_assets + def setup + @controller = FeedController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + get :feed, :sections => ['about'] + end + + specify "should select correct records" do + assert_equal sections(:about), assigns(:section) + assert_equal [contents(:welcome), contents(:about), contents(:site_map)], assigns(:articles) + end + + specify "should show correct titles" do + assert_select 'feed>title', 'Mephisto - About' + assert_select 'feed>entry>title', 3 do |titles| + assert_equal 'Welcome to Mephisto', titles[0].children.first.content + assert_equal 'About this page', titles[1].children.first.content + assert_equal 'The Site Map', titles[2].children.first.content + end + end + + # TODO: Fails due to asset test deleting asset fixtures + specify "should show correct links" do + return if Asset.count == 1 + assert_select 'feed>link[href=?][type=?]', 'http://test.host/about', 'text/html' + assert_select 'feed>entry>link[href]', 4 do |hrefs| + assert_equal "http://test.host/about", hrefs[0]['href'] + assert_match /asset\.mp3$/, hrefs[1]['href'] + assert_equal "http://test.host/about/about-this-page", hrefs[2]['href'] + assert_equal "http://test.host/about/the-site-map", hrefs[3]['href'] + end + end +end + context "Home Section Feed" do - fixtures :contents, :sections, :assigned_sections, :sites + fixtures :contents, :sections, :assigned_sections, :sites, :assets, :assigned_assets def setup @controller = FeedController.new @request = ActionController::TestRequest.new @@ -72,16 +99,30 @@ end specify "should show titles" do - assert_xpath '/feed/entry[title="Welcome to Mephisto"]' - assert_xpath '/feed/entry[title="Another Welcome to Mephisto"]' + assert_select 'feed>title', 'Mephisto - Home' + assert_select 'feed>entry>title', 2 do |elements| + assert_equal 'Welcome to Mephisto', elements[0].children.first.content + assert_equal 'Another Welcome to Mephisto', elements[1].children.first.content + end end - specify "show absolute urls" do - assert_select 'feed entry link' do - assert_select '[href=?]', /^http\:\/\/test\.host\/\d{4}\/.*$/ + # TODO: Fails due to asset test deleting asset fixtures + specify "should show correct links" do + return if Asset.count == 1 + assert_select 'feed>link[href=?][type=?]', 'http://test.host/', 'text/html' + assert_select 'feed>entry>link[href]', 3 do |hrefs| + assert_match /\/welcome-to-mephisto$/, hrefs[0]['href'] + assert_match /asset\.mp3$/, hrefs[1]['href'] + assert_match /\/another-welcome-to-mephisto$/, hrefs[2]['href'] end end + # TODO: Fails due to asset test deleting asset fixtures + specify "should show podcast" do + return if Asset.count == 1 + assert_select 'feed>entry>link[rel=?][length=?][type=?]', 'enclosure', '252366', 'audio/mpeg' + end + specify "show absolute urls with custom relative url root" do begin old_root = ActionController::AbstractRequest.relative_url_root @@ -103,7 +144,7 @@ specify "should sanitize content" do text = @contents.first.get_text.to_s.strip evil = "linkage

      " - good = "<script>hi</script>linkage

      " + good = %(linkage

      ) assert !text.ends_with(CGI::escapeHTML(evil)), "'#{text.inspect}' was not sanitized" assert text.ends_with(CGI::escapeHTML(good)), "'#{text.inspect}' was not sanitized" end diff -Nur mephisto-0.7.3/test/functional/mephisto_controller_redirections_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/mephisto_controller_redirections_test.rb --- mephisto-0.7.3/test/functional/mephisto_controller_redirections_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/mephisto_controller_redirections_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -11,7 +11,6 @@ @controller = MephistoController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - host! 'test.com' end specify "should handle denied requests" do diff -Nur mephisto-0.7.3/test/functional/mephisto_controller_test.rb technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/mephisto_controller_test.rb --- mephisto-0.7.3/test/functional/mephisto_controller_test.rb 2006-11-23 13:57:06.000000000 -0500 +++ technoweenie-mephisto-9072b487bf45c5e41e33c66b32d94aea84732d1b/test/functional/mephisto_controller_test.rb 2008-03-31 02:18:56.000000000 -0400 @@ -12,7 +12,6 @@ @controller = MephistoController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - host! 'test.com' end def test_should_list_on_home @@ -108,6 +107,18 @@ assert_dispatch_action :page end + def test_should_not_show_future_page + dispatch 'about/future' + assert_dispatch_action :page + assert_response :missing + end + + def test_should_not_show_draft_page + dispatch 'about/draft' + assert_dispatch_action :page + assert_response :missing + end + def test_should_render_liquid_templates_on_home dispatch assert_tag 'h1', :content => 'This is the layout' @@ -184,27 +195,45 @@ assert_tag :tag => 'h1', :content => "#{contents(:welcome).title} in #{sections(:about).name}" end - def test_should_render_with_alternate_search_layout - sites(:first).update_attribute :search_layout, 'alt_layout.liquid' - dispatch 'search' - assert_dispatch_action :search - assert_preferred_template :search - assert_layout_template :alt_layout - assert_template_type :search - end - def test_should_search_entries dispatch 'search', :q => 'another' assert_dispatch_action :search assert_equal [contents(:another)], assigns(:articles) assert_equal sites(:first).articles_per_page, liquid(:site).before_method(:articles_per_page) assert_equal 'another', liquid(:search_string) + assert_nil liquid(:section) assert_equal 1, liquid(:search_count) assert_preferred_template :search assert_layout_template :layout assert_template_type :search end + def test_should_search_entries_in_section + Section.update_all ['layout = ?', 'alt_layout'], ['id = ?', sections(:about).id] + dispatch 'search', :q => 'welcome', :s => 'about' + assert_dispatch_action :search + assert_equal [contents(:welcome)], assigns(:articles) + assert_equal 'welcome', liquid(:search_string) + assert_equal 1, liquid(:search_count) + assert_equal sections(:about).to_liquid, liquid(:section) + assert_preferred_template :search + assert_layout_template :alt_layout + assert_template_type :search + end + + def test_should_search_entries_in_home_section + Section.update_all ['layout = ?', 'alt_layout'], ['id = ?', sections(:home).id] + dispatch 'search', :q => 'about', :s => '' + assert_dispatch_action :search + assert_equal [], assigns(:articles) + assert_equal 'about', liquid(:search_string) + assert_equal sections(:home).to_liquid, liquid(:section) + assert_equal 0, liquid(:search_count) + assert_preferred_template :search + assert_layout_template :alt_layout + assert_template_type :search + end + def test_should_search_and_not_find_draft dispatch 'search', :q => 'draft' assert_dispatch_action :search @@ -265,7 +294,7 @@ def test_should_show_navigation_on_paged_sections dispatch 'about' assert_tag 'ul', :attributes => { :id => 'nav' }, - :children => { :count => 3, :only => { :tag => 'li' } } + :children => { :count => 5, :only => { :tag => 'li' } } assert_tag 'ul', :attributes => { :id => 'nav' }, :descendant => { :tag => 'a', :attributes => { :class => 'selected' } } assert_tag 'a', :attributes => { :class => 'selected' }, :content => 'Welcome to Mephisto' @@ -273,7 +302,7 @@ def test_should_set_home_page_on_paged_sections dispatch 'about' - assert_equal 3, liquid(:section).pages.size + assert_equal 5, liquid(:section).pages.size [true, false, false].each_with_index do |expected, i| assert_equal expected, liquid(:section).pages[i][:is_page_home] end @@ -301,13 +330,11 @@ end end - def test_should_sanitize_comment + def test_should_sanitize_comment_not_article date = contents(:welcome).published_at dispatch "#{date.year}/#{date.month}/#{date.day}/welcome-to-mephisto" - evil = %(

      rico’s evil and linkage

      ) - good = %(

      rico’s evil <script>hi</script> and linkage

      ) - assert !@response.body.include?(evil), "includes unsanitized code" - assert @response.body.include?(good), "does not include sanitized code" + assert_select "body script", true, "Article can have some