refinerycms-blog 2.1.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +9 -23
  3. data/Gemfile +15 -7
  4. data/Rakefile +0 -1
  5. data/app/assets/javascripts/refinery/blog/backend.js +18 -59
  6. data/app/assets/stylesheets/refinery/blog/backend.css.scss +4 -55
  7. data/app/assets/stylesheets/refinery/blog/frontend.css.scss +2 -2
  8. data/app/controllers/refinery/blog/admin/categories_controller.rb +6 -0
  9. data/app/controllers/refinery/blog/admin/posts_controller.rb +25 -3
  10. data/app/controllers/refinery/blog/blog_controller.rb +31 -5
  11. data/app/controllers/refinery/blog/categories_controller.rb +10 -3
  12. data/app/controllers/refinery/blog/posts_controller.rb +16 -6
  13. data/app/helpers/refinery/blog/controller_helper.rb +1 -22
  14. data/app/models/refinery/blog/categorization.rb +0 -1
  15. data/app/models/refinery/blog/category.rb +3 -6
  16. data/app/models/refinery/blog/comment.rb +15 -17
  17. data/app/models/refinery/blog/post.rb +44 -43
  18. data/app/views/refinery/blog/admin/_submenu.html.erb +1 -3
  19. data/app/views/refinery/blog/admin/categories/_category.html.erb +14 -5
  20. data/app/views/refinery/blog/admin/posts/_form.html.erb +13 -6
  21. data/app/views/refinery/blog/admin/posts/_form_part.html.erb +1 -1
  22. data/app/views/refinery/blog/admin/posts/_post.html.erb +12 -5
  23. data/app/views/refinery/blog/admin/posts/_teaser_part.html.erb +1 -1
  24. data/app/views/refinery/blog/posts/index.html.erb +2 -2
  25. data/app/views/refinery/blog/shared/_categories.html.erb +3 -3
  26. data/app/views/refinery/shared/admin/_autocomplete.html.erb +45 -0
  27. data/bin/rails +5 -0
  28. data/bin/refinerycms +62 -0
  29. data/changelog.md +4 -1
  30. data/config/locales/cs.yml +2 -2
  31. data/config/locales/en.yml +3 -0
  32. data/config/locales/fr.yml +6 -4
  33. data/config/locales/nb.yml +154 -14
  34. data/config/locales/nl.yml +21 -0
  35. data/config/locales/pl.yml +2 -2
  36. data/config/locales/ru.yml +25 -14
  37. data/config/locales/zh-CN.yml +32 -1
  38. data/config/locales/zh-TW.yml +160 -0
  39. data/config/routes.rb +6 -3
  40. data/db/migrate/20110803223522_create_blog_structure.rb +4 -4
  41. data/db/migrate/20120531113632_delete_cached_slugs.rb +2 -2
  42. data/db/migrate/20140622132537_add_missing_unique_indices.acts_as_taggable_on_engine.rb +20 -0
  43. data/db/migrate/20140622132538_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
  44. data/db/seeds.rb +4 -4
  45. data/lib/refinery/blog.rb +1 -1
  46. data/lib/refinery/blog/configuration.rb +1 -1
  47. data/lib/refinery/blog/engine.rb +8 -3
  48. data/readme.md +21 -6
  49. data/refinerycms-blog.gemspec +9 -7
  50. data/script/rails +1 -3
  51. data/spec/controllers/refinery/blog/admin/comments_controller_spec.rb +23 -19
  52. data/spec/controllers/refinery/blog/admin/posts_controller_spec.rb +35 -0
  53. data/spec/controllers/refinery/blog/posts_controller_spec.rb +3 -3
  54. data/spec/factories/blog_posts.rb +1 -1
  55. data/spec/factories/user.rb +27 -0
  56. data/spec/features/refinery/blog/admin/categories_spec.rb +106 -104
  57. data/spec/features/refinery/blog/admin/comments_spec.rb +18 -18
  58. data/spec/features/refinery/blog/admin/menu_spec.rb +14 -8
  59. data/spec/features/refinery/blog/admin/posts_spec.rb +99 -86
  60. data/spec/features/refinery/blog/categories_spec.rb +20 -18
  61. data/spec/features/refinery/blog/posts_spec.rb +128 -124
  62. data/spec/helpers/refinery/blog/posts_helper_spec.rb +13 -13
  63. data/spec/lib/refinery/blog/engine_spec.rb +1 -11
  64. data/spec/models/refinery/blog/category_spec.rb +10 -10
  65. data/spec/models/refinery/blog/comment_spec.rb +3 -3
  66. data/spec/models/refinery/blog/post_spec.rb +59 -33
  67. data/spec/spec_helper.rb +2 -3
  68. metadata +75 -50
  69. data/app/assets/images/refinery/blog/icons/add.png +0 -0
  70. data/app/assets/images/refinery/blog/icons/cog.png +0 -0
  71. data/app/assets/images/refinery/blog/icons/comment.png +0 -0
  72. data/app/assets/images/refinery/blog/icons/comment_cross.png +0 -0
  73. data/app/assets/images/refinery/blog/icons/comment_tick.png +0 -0
  74. data/app/assets/images/refinery/blog/icons/comments.png +0 -0
  75. data/app/assets/images/refinery/blog/icons/down.gif +0 -0
  76. data/app/assets/images/refinery/blog/icons/folder.png +0 -0
  77. data/app/assets/images/refinery/blog/icons/folder_add.png +0 -0
  78. data/app/assets/images/refinery/blog/icons/folder_edit.png +0 -0
  79. data/app/assets/images/refinery/blog/icons/page.png +0 -0
  80. data/app/assets/images/refinery/blog/icons/page_add.png +0 -0
  81. data/app/assets/images/refinery/blog/icons/page_copy.png +0 -0
  82. data/app/assets/images/refinery/blog/icons/up.gif +0 -0
  83. data/spec/helpers/refinery/blog/controller_helper_spec.rb +0 -27
  84. data/todo.md +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 474d4fdc2f9ad359bd9255e60b9ca70b80a5ec62
4
- data.tar.gz: acb4c9dbd5960f3f873ade37e2257c551f999c37
3
+ metadata.gz: 103f97d3e1867df74bda38e15a917f4c2b294199
4
+ data.tar.gz: 4676a7e4be28f32f41b06a9cfc9ca5564e442497
5
5
  SHA512:
6
- metadata.gz: d5f19a55c12dd44d8eee1e97b5ebb96bc16dbd3d56f23d5499e794df091afea8cd1800249db1ea221fa80d8b472b17c58ff2f39cb26ef0043e48a6790e4b7df1
7
- data.tar.gz: aad373a5e0c9052fc338f379ef74a49ab31ebe9b32357f38e4bff98ef4dab01c905ddf95f55b851b6a14dbbfe31fe53a2adeb23fda386573bc3b34c9f9459242
6
+ metadata.gz: 360bbc5841fb2a5cd87b1aa7fcc1742f53ee66d9c51dfe2bbec3068458857deed71b9be6c53e8d8df785552b05735c2fbb436dac044367743c0f97575052e930
7
+ data.tar.gz: 25eb5dab9e584d61542e3bd076493056696ba5443104e3beb2fb72ab6fc357bbf58ae7e71d062bd236077f1067921e4cb23479bb7dd85943c02f0fe411db7629
@@ -1,30 +1,16 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  bundler_args: --without development
3
- before_script:
4
- - "sh -e /etc/init.d/xvfb start"
5
- - "bundle exec rake refinery:testing:dummy_app"
6
- script:
7
- - "DISPLAY=:99.0 bundle exec rspec spec"
8
- notifications:
9
- email: true
10
- irc:
11
- use_notice: true
12
- skip_join: true
13
- channels:
14
- - "irc.freenode.org#refinerycms"
15
- campfire:
16
- on_success: always
17
- on_failure: always
18
- rooms:
19
- - secure: "JaX+Ckvdd2wqL2bD6t8PHvMDBHxWBlCrkBKPcDKxV0t0DOwzzzwxMryVqcRi\nPsmM/zvmWFATDyRmivhNOpu4lRg9RytSroxZ9nkmbLDqjCyEAZ6tv4yZXME/\nPaxPwmfwgS9g8TKjj3lSWS7rEpqqg0D5S0XIfIHrj6KB6LUmFHc="
4
+ before_script: "bundle exec rake refinery:testing:dummy_app"
20
5
  env:
21
6
  - DB=postgresql
22
7
  - DB=mysql
23
- matrix:
24
- allow_failures:
25
- - rvm: rbx-19mode
8
+ notifications:
9
+ webhooks:
10
+ - https://webhooks.gitter.im/e/b5d48907cdc89864b874
26
11
  rvm:
12
+ - 2.3.1
13
+ - 2.2
14
+ - 2.1
27
15
  - 2.0.0
28
- - 1.9.3
29
- - rbx-19mode
30
- - jruby-19mode
16
+ sudo: false
data/Gemfile CHANGED
@@ -1,12 +1,23 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ gem "refinerycms-authentication-devise", '~> 1.0.4'
4
+
3
5
  gemspec
4
6
 
5
- gem 'refinerycms', '~> 2.1.0'
6
- gem 'refinerycms-testing', :github => 'refinery/refinerycms', :branch => '2-1-stable', :group => :test
7
- gem 'refinerycms-settings', '~> 2.1.0'
8
- gem 'refinerycms-acts-as-indexed', :github => 'refinery/refinerycms-acts-as-indexed', :branch => '1-0-stable'
7
+ gem 'refinerycms', '~> 3.0.5'
8
+
9
+ group :development, :test do
10
+ gem 'refinerycms-testing', '~> 3.0.5'
11
+ end
12
+
13
+ # Add the default visual editor, for now.
14
+ gem 'refinerycms-wymeditor', ['~> 1.0', '>= 1.0.6']
9
15
 
16
+ group :test do
17
+ gem 'pry'
18
+ gem 'launchy'
19
+ gem 'poltergeist'
20
+ end
10
21
 
11
22
  # Database Configuration
12
23
  unless ENV['TRAVIS']
@@ -25,13 +36,10 @@ if !ENV['TRAVIS'] || ENV['DB'] == 'postgresql'
25
36
  gem 'pg', :platform => :ruby
26
37
  end
27
38
 
28
- gem 'jruby-openssl', :platform => :jruby
29
-
30
39
  # Refinery/rails should pull in the proper versions of these
31
40
  group :assets do
32
41
  gem 'sass-rails'
33
42
  gem 'coffee-rails'
34
- gem 'uglifier'
35
43
  end
36
44
 
37
45
  # Load local gems according to Refinery developer preference.
data/Rakefile CHANGED
@@ -13,7 +13,6 @@ if File.exists?(APP_RAKEFILE)
13
13
  end
14
14
 
15
15
  require "refinerycms-testing"
16
- Refinery::Testing::Railtie.load_tasks
17
16
  Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
18
17
 
19
18
  load File.expand_path('../tasks/rspec.rake', __FILE__)
@@ -1,4 +1,8 @@
1
+ //= require jquery-ui/autocomplete
2
+
1
3
  $(document).ready(function(){
4
+ $('#more_options').hide()
5
+
2
6
  $('nav#actions.multilist > ul:not(.search_list) li a[href$="' + window.location.pathname + '"]')
3
7
  .parent().addClass('selected');
4
8
  if($('nav#actions.multilist > ul:not(.search_list) li.selected').length == 0) {
@@ -48,68 +52,23 @@ $(document).ready(function(){
48
52
  e.preventDefault();
49
53
  });
50
54
 
51
-
52
- $(function() {
53
- $('#page-tabs').tabs();
54
- $('#copy_body_link').click(function(event) {
55
- // Find the WYMEditor that maps to the custom_teaser field
56
- var teaserTextArea = $('#post_custom_teaser')[0];
57
- var teaserEditor = null;
58
- $.each(WYMeditor.INSTANCES, function(index, editor) {
59
- if (editor._element[0] == teaserTextArea) {
60
- teaserEditor = editor;
61
- }
62
- });
63
-
64
- if (teaserEditor) {
65
- teaserEditor.html($('#post_body').attr('value'));
55
+ $('#page-tabs').tabs();
56
+ $('#copy_body_link').click(function(event) {
57
+ // Find the WYMEditor that maps to the custom_teaser field
58
+ var teaserTextArea = $('#post_custom_teaser')[0];
59
+ var teaserEditor = null;
60
+ $.each(WYMeditor.INSTANCES, function(index, editor) {
61
+ if (editor._element[0] == teaserTextArea) {
62
+ teaserEditor = editor;
66
63
  }
67
-
68
- event.preventDefault();
69
64
  });
70
- });
71
-
72
65
 
73
- function split( val ) {
74
- return val.split( /,\s*/ );
75
- }
76
- function extractLast( term ) {
77
- return split( term ).pop();
78
- }
66
+ if (teaserEditor) {
67
+ teaserEditor.html($('#post_body').val());
68
+ }
79
69
 
80
- page_options.init(false, '', '')
70
+ event.preventDefault();
71
+ });
81
72
 
82
- $('<%= dom_id %>').bind( "keydown", function( event ) {
83
- if ( event.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) {
84
- event.preventDefault()
85
- }
86
- }).autocomplete({
87
- source: function( request, response ) {
88
- $.getJSON( "<%= url %>", {
89
- term: extractLast( request.term )
90
- }, response );
91
- },
92
- search: function() {
93
- // custom minLength
94
- var term = extractLast( this.value );
95
- if ( term.length < 2 ) {
96
- return false;
97
- }
98
- },
99
- focus: function() {
100
- // prevent value inserted on focus
101
- return false;
102
- },
103
- select: function( event, ui ) {
104
- var terms = split( this.value );
105
- // remove the current input
106
- terms.pop();
107
- // add the selected item
108
- terms.push( ui.item.value );
109
- // add placeholder to get the comma-and-space at the end
110
- terms.push( "" );
111
- this.value = terms.join( ", " );
112
- return false;
113
- }
114
- })
73
+ page_options.init(false, '', '');
115
74
  });
@@ -1,58 +1,3 @@
1
- .comments_icon {
2
- background-image: image_url('refinery/blog/icons/comments.png');
3
- }
4
- .comment_icon {
5
- background-image: image_url('refinery/blog/icons/comment.png');
6
- }
7
- .comment_cross_icon {
8
- background-image: image_url('refinery/blog/icons/comment_cross.png');
9
- }
10
- .comment_tick_icon {
11
- background-image: image_url('refinery/blog/icons/comment_tick.png');
12
- }
13
- .folder_icon {
14
- background-image: image_url('refinery/blog/icons/folder.png');
15
- }
16
- .folder_add_icon {
17
- background-image: image_url('refinery/blog/icons/folder_add.png');
18
- }
19
- .folder_edit_icon {
20
- background-image: image_url('refinery/blog/icons/folder_edit.png');
21
- }
22
- .settings_icon {
23
- background-image: image_url('refinery/blog/icons/cog.png');
24
- }
25
- .page_icon {
26
- background-image: image_url('refinery/blog/icons/page.png');
27
- }
28
- .page_copy_icon {
29
- background-image: image_url('refinery/blog/icons/page_copy.png');
30
- }
31
- .page_add_icon {
32
- background-image: image_url('refinery/blog/icons/page_add.png');
33
- }
34
- ul.collapsible_menu li {
35
- position: relative;
36
- span.arrow {
37
- background-repeat: no-repeat;
38
- position: absolute;
39
- right: 10px;
40
- top: 13px;
41
- width: 11px;
42
- height: 7px;
43
- cursor: pointer;
44
- background-image: image_url('refinery/blog/icons/up.gif');
45
- }
46
- &.closed {
47
- span.arrow {
48
- background-image: image_url('refinery/blog/icons/down.gif');
49
- }
50
- }
51
- > div {
52
- width: 93%;
53
- margin: 0px auto;
54
- }
55
- }
56
1
  ul.blog_categories {
57
2
  height:200px;
58
3
  overflow:auto;
@@ -71,3 +16,7 @@ a#copy_body_link {
71
16
  margin-top: 0;
72
17
  padding-left: 20px;
73
18
  }
19
+ .form-actions a.confirm-delete, #content .form-actions a.confirm-delete {
20
+ position: relative;
21
+ right: auto;
22
+ }
@@ -65,7 +65,7 @@
65
65
  &.flash_notice, &.flash_message {
66
66
  border: 1px solid #00A017;
67
67
  color: #00A017;
68
- background: 7px 7px no-repeat image_url('refinery/blog/icons/accept.png') #E0F5E0;
68
+ background: 7px 7px no-repeat image_url('refinery/icons/accept.png') #E0F5E0;
69
69
  }
70
70
  &.flash_notice #flash_close, &.flash_error #flash_close {
71
71
  text-transform: lowercase;
@@ -88,7 +88,7 @@
88
88
  &.flash_error {
89
89
  border: 1px solid #A00027;
90
90
  color: #A00027;
91
- background: 7px 7px no-repeat image_url('refinery/blog/icons/cancel.png') #FFB1B1;
91
+ background: 7px 7px no-repeat image_url('refinery/icons/cancel.png') #FFB1B1;
92
92
  a {
93
93
  &, &:hover {
94
94
  display: none;
@@ -4,8 +4,14 @@ module Refinery
4
4
  class CategoriesController < ::Refinery::AdminController
5
5
 
6
6
  crudify :'refinery/blog/category',
7
+ :include => [:translations],
7
8
  :order => 'title ASC'
8
9
 
10
+ private
11
+
12
+ def category_params
13
+ params.require(:category).permit(:title)
14
+ end
9
15
  end
10
16
  end
11
17
  end
@@ -38,12 +38,12 @@ module Refinery
38
38
  def create
39
39
  # if the position field exists, set this object as last object, given the conditions of this class.
40
40
  if Refinery::Blog::Post.column_names.include?("position")
41
- params[:post].merge!({
41
+ post_params.merge!({
42
42
  :position => ((Refinery::Blog::Post.maximum(:position, :conditions => "")||-1) + 1)
43
43
  })
44
44
  end
45
45
 
46
- if (@post = Refinery::Blog::Post.create(params[:post])).valid?
46
+ if (@post = Refinery::Blog::Post.create(post_params)).valid?
47
47
  (request.xhr? ? flash.now : flash).notice = t(
48
48
  'refinery.crudify.created',
49
49
  :what => "'#{@post.title}'"
@@ -75,9 +75,31 @@ module Refinery
75
75
  end
76
76
  end
77
77
 
78
+ def delete_translation
79
+ find_post
80
+ @post.translations.find_by_locale(params[:locale_to_delete]).destroy
81
+ flash[:notice] = ::I18n.t('delete_translation_success', :scope => 'refinery.blog.admin.posts.post')
82
+ redirect_to refinery.blog_admin_posts_path
83
+ end
84
+
85
+ private
86
+
87
+ def post_params
88
+ params.require(:post).permit(permitted_post_params)
89
+ end
90
+
91
+ def permitted_post_params
92
+ [
93
+ :title, :body, :custom_teaser, :tag_list,
94
+ :draft, :published_at, :custom_url, :user_id, :browser_title,
95
+ :meta_description, :source_url, :source_url_title, :category_ids => []
96
+ ]
97
+ end
98
+
78
99
  protected
100
+
79
101
  def find_post
80
- @post = Refinery::Blog::Post.find_by_slug_or_id(params[:id])
102
+ @post = Refinery::Blog::Post.friendly.find(params[:id])
81
103
  end
82
104
 
83
105
  def find_all_categories
@@ -2,16 +2,42 @@ module Refinery
2
2
  module Blog
3
3
  class BlogController < ::ApplicationController
4
4
 
5
- include ControllerHelper
6
-
7
5
  helper :'refinery/blog/posts'
8
- before_filter :find_page, :find_all_blog_categories
6
+ before_action :find_page, :find_all_blog_categories
9
7
 
10
8
  protected
11
9
 
12
- def find_page
13
- @page = Refinery::Page.find_by_link_url(Refinery::Blog.page_url)
10
+ def find_all_blog_categories
11
+ @categories = Refinery::Blog::Category.translated
12
+ end
13
+
14
+ def find_blog_post
15
+ unless (@post = post_finder_scope.with_globalize.friendly.find(params[:id])).try(:live?)
16
+ if current_refinery_user && current_refinery_user.has_plugin?("refinerycms_blog")
17
+ @post = post_finder_scope.friendly.find(params[:id])
18
+ else
19
+ error_404
20
+ end
14
21
  end
22
+ end
23
+
24
+ def find_all_blog_posts
25
+ @posts = post_finder_scope.live.includes(
26
+ :comments, :categories, :translations
27
+ ).with_globalize.newest_first.page(params[:page])
28
+ end
29
+
30
+ def find_page
31
+ @page = Refinery::Page.find_by(:link_url => Refinery::Blog.page_url)
32
+ end
33
+
34
+ def find_tags
35
+ @tags = post_finder_scope.live.tag_counts_on(:tags)
36
+ end
37
+
38
+ def post_finder_scope
39
+ Refinery::Blog::Post
40
+ end
15
41
  end
16
42
  end
17
43
  end
@@ -2,9 +2,16 @@ module Refinery
2
2
  module Blog
3
3
  class CategoriesController < BlogController
4
4
 
5
- def show
6
- @category = Refinery::Blog::Category.find(params[:id])
7
- @posts = @category.posts.live.includes(:comments, :categories).with_globalize.page(params[:page])
5
+ before_action :find_category, :find_all_blog_posts, only: :show
6
+
7
+ private
8
+
9
+ def find_category
10
+ @category = Refinery::Blog::Category.friendly.find(params[:id])
11
+ end
12
+
13
+ def post_finder_scope
14
+ @category.posts
8
15
  end
9
16
 
10
17
  end
@@ -10,9 +10,12 @@ module Refinery
10
10
 
11
11
  def index
12
12
  if request.format.rss?
13
- @posts = Post.live.includes(:comments, :categories)
14
- # limit rss feed for services (like feedburner) who have max size
15
- @posts = Post.recent(params["max_results"]) if params["max_results"].present?
13
+ @posts = if params["max_results"].present?
14
+ # limit rss feed for services (like feedburner) who have max size
15
+ Post.recent(params["max_results"])
16
+ else
17
+ Post.newest_first.live.includes(:comments, :categories)
18
+ end
16
19
  end
17
20
  respond_with (@posts) do |format|
18
21
  format.html
@@ -34,10 +37,11 @@ module Refinery
34
37
  end
35
38
 
36
39
  def comment
37
- if (@comment = @post.comments.create(params[:comment])).valid?
40
+ @comment = @post.comments.create(comment_params)
41
+ if @comment.valid?
38
42
  if Comment::Moderation.enabled? or @comment.ham?
39
43
  begin
40
- CommentMailer.notification(@comment, request).deliver
44
+ CommentMailer.notification(@comment, request).deliver_now
41
45
  rescue
42
46
  logger.warn "There was an error delivering a blog comment notification.\n#{$!}\n"
43
47
  end
@@ -74,7 +78,13 @@ module Refinery
74
78
  def tagged
75
79
  @tag = ActsAsTaggableOn::Tag.find(params[:tag_id])
76
80
  @tag_name = @tag.name
77
- @posts = Post.live.tagged_with(@tag_name).page(params[:page])
81
+ @posts = Post.live.newest_first.uniq.tagged_with(@tag_name).page(params[:page])
82
+ end
83
+
84
+ private
85
+
86
+ def comment_params
87
+ params.require(:comment).permit(:name, :email, :message)
78
88
  end
79
89
 
80
90
  protected