Permalink
Browse files

Move models and supporting libs to publify_core engine

- Moves all models to the Engine
- Moves a minimum set of supporting libraries, which includes the text
  filters.
- Moves 'plain' theme, but not the bootstrap-2 theme. As a result, the
  default theme for a new Blog is 'plain'.
- Unifies DNS mocks across specs
- Moves article after_save hook from observer into article
  • Loading branch information...
1 parent 495d34a commit b5bc06eaac60ab1b52bc03919e56b5bd7c76f1ae @mvz mvz committed Jun 18, 2016
Showing with 632 additions and 306 deletions.
  1. +0 −9 Gemfile
  2. +0 −7 app/models/web_notifier.rb
  3. +0 −175 config/routes.rb
  4. 0 { → publify_core}/app/models/ability.rb
  5. +1 −0 { → publify_core}/app/models/article.rb
  6. 0 { → publify_core}/app/models/article/factory.rb
  7. 0 { → publify_core}/app/models/article/states.rb
  8. +2 −2 { → publify_core}/app/models/blog.rb
  9. 0 { → publify_core}/app/models/blog_sweeper.rb
  10. 0 { → publify_core}/app/models/comment.rb
  11. 0 { → publify_core}/app/models/concerns/.keep
  12. 0 { → publify_core}/app/models/config_manager.rb
  13. +0 −8 { → publify_core}/app/models/content.rb
  14. 0 { → publify_core}/app/models/content_base.rb
  15. 0 { → publify_core}/app/models/email_notifier.rb
  16. +5 −0 { → publify_core}/app/models/feedback.rb
  17. 0 { → publify_core}/app/models/feedback/states.rb
  18. 0 { → publify_core}/app/models/note.rb
  19. 0 { → publify_core}/app/models/page.rb
  20. 0 { → publify_core}/app/models/page_cache.rb
  21. 0 { → publify_core}/app/models/ping.rb
  22. 0 { → publify_core}/app/models/post_type.rb
  23. 0 { → publify_core}/app/models/redirect.rb
  24. 0 { → publify_core}/app/models/redirection.rb
  25. +3 −0 { → publify_core}/app/models/resource.rb
  26. 0 { → publify_core}/app/models/sidebar.rb
  27. 0 { → publify_core}/app/models/tag.rb
  28. +3 −9 { → publify_core}/app/models/text_filter.rb
  29. 0 { → publify_core}/app/models/trackback.rb
  30. 0 { → publify_core}/app/models/trigger.rb
  31. 0 { → publify_core}/app/models/user.rb
  32. 0 { → publify_core}/app/services/migrator.rb
  33. +2 −0 { → publify_core}/app/uploaders/resource_uploader.rb
  34. 0 { → publify_core}/config/initializers/devise.rb
  35. +175 −0 publify_core/config/routes.rb
  36. 0 { → publify_core}/lib/format.rb
  37. +16 −0 publify_core/lib/publify_core.rb
  38. +1 −1 publify_core/lib/publify_core/version.rb
  39. +2 −0 { → publify_core}/lib/publify_guid.rb
  40. 0 { → publify_core}/lib/publify_plugins.rb
  41. +3 −0 { → publify_core}/lib/publify_textfilter_textile.rb
  42. +2 −0 { → publify_core}/lib/publify_textfilter_twitterfilter.rb
  43. 0 { → publify_core}/lib/publify_time.rb
  44. +2 −0 { → publify_core}/lib/spam_protection.rb
  45. 0 { → publify_core}/lib/stateful.rb
  46. +2 −0 { → publify_core}/lib/text_filter_plugin.rb
  47. 0 { → publify_core}/lib/theme.rb
  48. 0 { → publify_core}/lib/transforms.rb
  49. +10 −0 publify_core/publify_core.gemspec
  50. +313 −0 publify_core/spec/factories.rb
  51. 0 { → publify_core}/spec/fixtures/testfile.txt
  52. 0 { → publify_core}/spec/lib/publify_time_spec.rb
  53. +13 −0 publify_core/spec/lib/text_filter_plugin_spec.rb
  54. +6 −7 { → publify_core}/spec/lib/theme_spec.rb
  55. 0 { → publify_core}/spec/lib/transforms_spec.rb
  56. 0 { → publify_core}/spec/models/article/factory_spec.rb
  57. 0 { → publify_core}/spec/models/article_spec.rb
  58. 0 { → publify_core}/spec/models/blog_spec.rb
  59. 0 { → publify_core}/spec/models/cache_support_spec.rb
  60. +8 −10 { → publify_core}/spec/models/comment_spec.rb
  61. +2 −2 { → publify_core}/spec/models/configuration_spec.rb
  62. +4 −2 { → publify_core}/spec/models/content_spec.rb
  63. 0 { → publify_core}/spec/models/feedback/states_spec.rb
  64. 0 { → publify_core}/spec/models/feedback_spec.rb
  65. 0 { → publify_core}/spec/models/note_spec.rb
  66. +39 −0 publify_core/spec/models/page_cache_spec.rb
  67. 0 { → publify_core}/spec/models/page_spec.rb
  68. 0 { → publify_core}/spec/models/ping_pinger_spec.rb
  69. 0 { → publify_core}/spec/models/ping_spec.rb
  70. 0 { → publify_core}/spec/models/post_type_spec.rb
  71. 0 { → publify_core}/spec/models/redirect_spec.rb
  72. 0 { → publify_core}/spec/models/resource_spec.rb
  73. 0 { → publify_core}/spec/models/tag_spec.rb
  74. +1 −14 { → publify_core}/spec/models/trackback_spec.rb
  75. 0 { → publify_core}/spec/models/trigger_spec.rb
  76. 0 { → publify_core}/spec/models/user_spec.rb
  77. +12 −1 publify_core/spec/rails_helper.rb
  78. +1 −1 {spec/support/mocks → publify_core/spec/support}/dns_mock.rb
  79. 0 { → publify_core}/spec/uploaders/resource_uploader_spec.rb
  80. 0 { → publify_core}/themes/plain/about.markdown
  81. BIN { → publify_core}/themes/plain/preview.png
  82. 0 { → publify_core}/themes/plain/stylesheets/theme.css
  83. +4 −13 spec/lib/text_filter_plugin_spec.rb
  84. +0 −20 spec/models/page_cache_spec.rb
  85. +0 −25 spec/rails_helper.rb
View
@@ -49,32 +49,23 @@ gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails', '~> 4.1.0'
gem 'jquery-ui-rails', '~> 5.0.2'
-gem 'RedCloth', '~> 4.3.1'
-gem 'actionpack-page_caching', '~> 1.0.2' # removed from Rails-core as Rails 4.0
gem 'addressable', '~> 2.1', require: 'addressable/uri'
gem 'akismet', '~> 2.0'
gem 'bluecloth', '~> 2.1'
gem 'cancancan', '~> 1.14'
-gem 'carrierwave', '~> 0.11.2'
gem 'coderay', '~> 1.1.0'
-gem 'devise', '~> 4.2.0'
gem 'devise-i18n', '~> 1.1.0'
gem 'dynamic_form', '~> 1.1.4'
gem 'flickraw-cached', '20120701'
gem 'flickraw', '~> 0.9.8'
gem 'fog-aws', '~> 0.9.2'
gem 'htmlentities', '~> 4.3'
-gem 'kaminari', '~> 0.17.0'
-gem 'mini_magick', '~> 4.2', require: 'mini_magick'
gem 'non-stupid-digest-assets', '~> 1.0'
gem 'rails-observers', '~> 0.1.2'
gem 'rails-timeago', '~> 2.0'
-gem 'rails_autolink', '~> 1.1.0'
gem 'rake', '~> 11.1'
gem 'recaptcha', '~> 3.2', require: 'recaptcha/rails'
gem 'rubypants', '~> 0.2.0'
-gem 'twitter', '~> 5.16.0'
-gem 'uuidtools', '~> 2.1.1'
gem 'feedjira', '~> 2.0.0'
gem 'bootstrap-sass', '~> 3.3.6'
@@ -1,7 +0,0 @@
-class WebNotifier < ActiveRecord::Observer
- observe Article
-
- def after_save(article)
- article.send_pings
- end
-end
View
@@ -1,177 +1,2 @@
Rails.application.routes.draw do
- devise_for :users
- # TODO: use only in archive sidebar. See how made other system
- get ':year/:month', to: 'articles#index', year: /\d{4}/, month: /\d{1,2}/, as: 'articles_by_month', format: false
- get ':year/:month/page/:page', to: 'articles#index', year: /\d{4}/, month: /\d{1,2}/, as: 'articles_by_month_page', format: false
- get ':year', to: 'articles#index', year: /\d{4}/, as: 'articles_by_year', format: false
- get ':year/page/:page', to: 'articles#index', year: /\d{4}/, as: 'articles_by_year_page', format: false
-
- get 'articles.:format', to: 'articles#index', constraints: {format: 'rss'}, as: 'rss'
- get 'articles.:format', to: 'articles#index', constraints: {format: 'atom'}, as: 'atom'
-
- scope controller: 'xml', path: 'xml' do
- get 'articlerss/:id/feed.xml', action: 'articlerss', format: false
- get 'commentrss/feed.xml', action: 'commentrss', format: false
- get 'trackbackrss/feed.xml', action: 'trackbackrss', format: false
- end
-
- get 'xml/:format', to: 'xml#feed', type: 'feed', constraints: {format: 'rss'}, as: 'xml'
- get 'sitemap.xml', to: 'xml#feed', format: 'googlesitemap', type: 'sitemap', as: 'sitemap_xml'
-
- scope controller: 'xml', path: 'xml', as: 'xml' do
- scope action: 'feed' do
- get ':format/feed.xml', type: 'feed'
- get ':format/:type/:id/feed.xml'
- get ':format/:type/feed.xml'
- end
- end
-
- get 'xml/rsd', to: 'xml#rsd', format: false
- get 'xml/feed', to: 'xml#feed'
-
- # CommentsController
- resources :comments, as: 'admin_comments', only: [:index, :create] do
- collection do
- post :preview
- end
- end
-
- resources :trackbacks
-
- # I thinks it's useless. More investigating
- post "trackbacks/:id/:day/:month/:year", to: 'trackbacks#create', format: false
-
- # ArticlesController
- get '/live_search/', to: 'articles#live_search', as: :live_search_articles, format: false
- get '/search/:q(.:format)/page/:page', to: 'articles#search', as: 'search', defaults: {page: 1}
- get '/search(/:q(.:format))', to: 'articles#search'
- get '/search/', to: 'articles#search', as: 'search_base', format: false
- get '/archives/', to: 'articles#archives', format: false
- get '/page/:page', to: 'articles#index', page: /\d+/, format: false
- get '/pages/*name', to: 'articles#view_page', format: false
- get 'previews(/:id)', to: 'articles#preview', format: false
- get 'previews_pages(/:id)', to: 'articles#preview_page', format: false
- get 'check_password', to: 'articles#check_password', format: false
- get 'articles/markup_help/:id', to: 'articles#markup_help', format: false
- get 'articles/tag', to: 'articles#tag', format: false
-
- # SetupController
- match '/setup', to: 'setup#index', via: [:get, :post], format: false
-
- # TagsController (imitate inflected_resource)
- resources :tags, only: [:index, :create, :new]
- resources :tags, path: 'tag', only: [:show, :edit, :update, :destroy]
- get '/tag/:id/page/:page', to: 'tags#show', format: false
- get '/tags/page/:page', to: 'tags#index', format: false
-
- resources :authors, path: 'author', only: :show
-
- # ThemeController
- scope controller: 'theme', filename: /.*/ do
- get 'stylesheets/theme/:filename', action: 'stylesheets', format: false
- get 'javascripts/theme/:filename', action: 'javascript', format: false
- get 'images/theme/:filename', action: 'images', format: false
- get 'fonts/theme/:filename', action: 'fonts', format: false
- end
-
- # For the tests
- get 'theme/static_view_test', format: false
-
- # For the statuses
- get '/notes', to: 'notes#index', format: false
- get '/notes/page/:page', to: 'notes#index', format: false
- get '/note/:permalink', to: 'notes#show', format: false
-
- get '/humans', to: 'text#humans', format: 'txt'
- get '/robots', to: 'text#robots', format: 'txt'
-
- # TODO: Remove if possible
- resources :accounts, only: [], format: false do
- collection do
- get 'confirm'
- end
- end
-
- namespace :admin do
- root 'dashboard#index', as: 'dashboard'
-
- get 'cache', to: 'cache#show', format: false
- delete 'cache', to: 'cache#destroy', format: false
-
- resources :content, only: [:index, :new, :edit, :create, :update, :destroy], format: false do
- collection do
- get 'auto_complete_for_article_keywords'
- post 'autosave'
- put 'autosave'
- end
- end
-
- resources :feedback, only: [:index, :edit, :create, :update, :destroy], format: false do
- collection do
- post 'bulkops'
- end
- member do
- get 'article'
- post 'change_state'
- end
- end
-
- resources :notes, only: [:index, :show, :edit, :create, :update, :destroy], format: false
-
- resources :pages, only: [:index, :new, :edit, :create, :update, :destroy], format: false
-
- resources :post_types, only: [:index, :edit, :create, :update, :destroy], format: false
-
- resources :profiles, only: [:index, :update], format: false
-
- resources :redirects, only: [:index, :edit, :create, :update, :destroy], format: false
-
- resources :resources, only: [:index, :destroy], format: false do
- collection do
- post 'upload'
- end
- end
-
- resource :seo, controller: 'seo', only: [:show, :update], format: false
- resource :migrations, only: [:show, :update]
-
- # TODO: This should be a singular resource
- resource :settings, only: [], format: false do
- collection do
- get 'index'
- get 'display'
- get 'feedback'
- get 'write'
- post 'migrate'
- post 'update'
- end
- end
-
- # TODO: This should have a plural resource name
- resources :sidebar, only: [:index, :update, :destroy] do
- collection do
- put :publish
- post :sortable
- end
- end
-
- resources :tags, only: [:index, :edit, :create, :update, :destroy], format: false
-
- # TODO: Work out if post is actually used or not.
- get 'textfilters/macro_help(/:id)', to: 'textfilters#macro_help', id: nil, format: false
- post 'textfilters/macro_help(/:id)', to: 'textfilters#macro_help', id: nil, format: false
-
- resources :themes, only: [:index], format: false do
- collection do
- get 'preview'
- get 'switchto'
- end
- end
-
- resources :users, only: [:index, :new, :edit, :create, :update, :destroy], format: false
- end
-
- root 'articles#index'
-
- get '*from', to: 'articles#redirect', format: false
end
File renamed without changes.
@@ -25,6 +25,7 @@ class Article < Content
before_create :create_guid
before_save :set_published_at, :set_permalink
after_save :post_trigger, :keywords_to_tags, :shorten_url
+ after_save :send_pings
scope :drafts, -> { where(state: 'draft').order('created_at DESC') }
scope :child_of, ->(article_id) { where(parent_id: article_id) }
@@ -59,7 +59,7 @@ class Blog < ActiveRecord::Base
setting :link_to_author, :boolean, false
setting :show_extended_on_rss, :boolean, true # deprecated but still needed for backward compatibility
setting :hide_extended_on_rss, :boolean, false
- setting :theme, :string, 'bootstrap-2'
+ setting :theme, :string, 'plain'
setting :plugin_avatar, :string, ''
setting :global_pings_disable, :boolean, false
setting :ping_urls, :string, "http://blogsearch.google.com/ping/RPC2\nhttp://rpc.technorati.com/rpc/ping\nhttp://ping.blo.gs/\nhttp://rpc.weblogs.com/RPC2"
@@ -94,7 +94,7 @@ class Blog < ActiveRecord::Base
Twitter: your Twitter username.
/* SITE */
-Software: Publify [http://publify.co] #{PUBLIFY_VERSION}
+Software: Publify [http://publify.co] #{PublifyCore::VERSION}
EOS
setting :index_categories, :boolean, true # deprecated but still needed for backward compatibility
setting :unindex_categories, :boolean, false
File renamed without changes.
@@ -141,11 +141,3 @@ def short_url
redirect.from_url
end
end
-
-class ContentTextHelpers
- include ActionView::Helpers::UrlHelper
- include ActionView::Helpers::TagHelper
- include ActionView::Helpers::SanitizeHelper
- include ActionView::Helpers::TextHelper
- extend ActionView::Helpers::SanitizeHelper::ClassMethods
-end
@@ -10,6 +10,11 @@ class Feedback < ActiveRecord::Base
include ContentBase
include States
+ class ContentTextHelpers
+ include ActionView::Helpers::TextHelper
+ include ActionView::Helpers::SanitizeHelper
+ end
+
validate :feedback_not_closed, on: :create
validates :article, presence: true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,3 +1,6 @@
+require 'carrierwave'
+require 'carrierwave/orm/activerecord'
+
class Resource < ActiveRecord::Base
belongs_to :blog
belongs_to :article
File renamed without changes.
File renamed without changes.
@@ -4,8 +4,6 @@ class TextFilter < ActiveRecord::Base
serialize :filters, Array
serialize :params, Hash
- @text_helper = ContentTextHelpers.new
-
def sanitize(*args, &blk)
self.class.sanitize(*args, &blk)
end
@@ -19,13 +17,9 @@ def self.filter_text(text, filters)
filters.each do |filter|
next if filter.nil?
- begin
- filter_class = map[filter.to_s]
- next unless filter_class
- text = filter_class.filtertext(text)
- rescue => err
- logger.error "Filter #{filter} failed: #{err}"
- end
+ filter_class = map[filter.to_s]
+ next unless filter_class
+ text = filter_class.filtertext(text)
end
text
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,3 +1,5 @@
+require 'carrierwave'
+
class ResourceUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
Oops, something went wrong.

0 comments on commit b5bc06e

Please sign in to comment.