publify_core 9.0.1 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of publify_core might be problematic. Click here for more details.

Files changed (81) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +5 -0
  3. data/app/controllers/admin/base_controller.rb +0 -11
  4. data/app/controllers/admin/content_controller.rb +7 -18
  5. data/app/controllers/admin/dashboard_controller.rb +1 -2
  6. data/app/controllers/admin/feedback_controller.rb +1 -0
  7. data/app/controllers/admin/notes_controller.rb +1 -1
  8. data/app/controllers/admin/pages_controller.rb +6 -19
  9. data/app/controllers/admin/profiles_controller.rb +11 -3
  10. data/app/controllers/admin/seo_controller.rb +1 -3
  11. data/app/controllers/admin/sidebar_controller.rb +0 -2
  12. data/app/controllers/admin/users_controller.rb +2 -2
  13. data/app/controllers/comments_controller.rb +6 -10
  14. data/app/controllers/setup_controller.rb +1 -2
  15. data/app/helpers/admin/base_helper.rb +1 -2
  16. data/app/helpers/base_helper.rb +2 -19
  17. data/app/helpers/xml_helper.rb +1 -1
  18. data/app/models/article.rb +4 -12
  19. data/app/models/blog.rb +9 -17
  20. data/app/models/content.rb +6 -16
  21. data/app/models/feedback.rb +2 -1
  22. data/app/models/meta_sidebar.rb +0 -2
  23. data/app/models/note.rb +2 -3
  24. data/app/models/page.rb +1 -2
  25. data/app/models/ping.rb +1 -1
  26. data/app/models/post_type.rb +1 -3
  27. data/app/models/redirect.rb +3 -2
  28. data/app/models/redirection.rb +1 -1
  29. data/app/models/resource.rb +1 -1
  30. data/app/models/sidebar.rb +1 -1
  31. data/app/models/static_sidebar.rb +0 -2
  32. data/app/models/tag.rb +1 -1
  33. data/app/models/text_filter.rb +1 -1
  34. data/app/models/trigger.rb +2 -2
  35. data/app/models/user.rb +1 -1
  36. data/app/services/title_builder.rb +7 -11
  37. data/app/uploaders/resource_uploader.rb +1 -3
  38. data/app/views/admin/content/_form.html.erb +1 -1
  39. data/app/views/admin/content/autosave.js.erb +2 -2
  40. data/app/views/admin/pages/_form.html.erb +6 -6
  41. data/app/views/admin/seo/_general.html.erb +1 -1
  42. data/app/views/admin/seo/_permalinks.html.erb +2 -2
  43. data/app/views/admin/users/_form.html.erb +2 -2
  44. data/app/views/articles/view_page.html.erb +1 -1
  45. data/app/views/shared/_atom_header.atom.builder +1 -3
  46. data/app/views/shared/_atom_item_article.atom.builder +9 -13
  47. data/app/views/shared/_google_analytics.html.erb +8 -0
  48. data/app/views/shared/_page_header.html.erb +1 -1
  49. data/app/views/shared/_rss_item_article.rss.builder +2 -3
  50. data/config/initializers/mime_types.rb +1 -1
  51. data/config/locales/da.yml +1 -3
  52. data/config/locales/de.yml +1 -3
  53. data/config/locales/en.yml +1 -3
  54. data/config/locales/es-MX.yml +1 -3
  55. data/config/locales/fr.yml +1 -3
  56. data/config/locales/he.yml +1 -3
  57. data/config/locales/it.yml +1 -3
  58. data/config/locales/ja.yml +1 -3
  59. data/config/locales/lt.yml +1 -3
  60. data/config/locales/nb-NO.yml +1 -3
  61. data/config/locales/nl.yml +1 -3
  62. data/config/locales/pl.yml +193 -195
  63. data/config/locales/pt-BR.yml +1 -3
  64. data/config/locales/ro.yml +1 -3
  65. data/config/locales/ru.yml +1 -3
  66. data/config/locales/zh-CN.yml +1 -3
  67. data/config/locales/zh-TW.yml +1 -3
  68. data/config/routes.rb +1 -1
  69. data/db/migrate/113_initial_schema.rb +0 -2
  70. data/db/migrate/114_fixes_buggy_articles_and_notes.rb +1 -1
  71. data/db/migrate/115_drops_categories_for_tags.rb +3 -4
  72. data/db/migrate/20150807134129_simplify_redirect_relations.rb +1 -3
  73. data/db/migrate/20150808052637_add_blog_ids.rb +5 -1
  74. data/db/seeds.rb +1 -3
  75. data/lib/format.rb +1 -11
  76. data/lib/publify_core/version.rb +1 -1
  77. data/lib/spam_protection.rb +3 -4
  78. data/lib/text_filter_plugin.rb +3 -4
  79. data/lib/theme.rb +1 -3
  80. data/lib/transforms.rb +0 -2
  81. metadata +87 -80
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1a1cf89cac6e217d23be79402f8ea4fab3ef6d88
4
- data.tar.gz: 1c7a95fab11db0e9c95a10b21094f59d959b7d8b
2
+ SHA256:
3
+ metadata.gz: 2e15ef90fced3ea3b247dbf4606d8259c2b7afdc6c145d68850e7ff0afe0f5ad
4
+ data.tar.gz: ffeca171cf4dfc01482e7f58f6cd3df5946ad20c1dc9710f057a7a74e1f901b9
5
5
  SHA512:
6
- metadata.gz: f41c5ddd206410b9c6fbe1a9849a811e0fc074c9092924c1725e0a03f498807eb84e2c43b4f52d527497901d58bbda91b3293d5c492b6cd7077c2bc3aef18f82
7
- data.tar.gz: a56f839f4b1cff29318ffcd76fe6c1f4e680474534bd54d9ae184e28b4c1fe7e24400f2ce2ec46010cd382dfeae22080a5ddb0324dca648fcca5a8b9fcba654d
6
+ metadata.gz: de5fcf4b3a26d1272b120d1555b59f60101df6840ef8130f73c3d3b923e7df6be7fb91eb749e4d5806175bd6e7078468c732849fd61e309b7cc7ddcf1975be60
7
+ data.tar.gz: 35f8119af5a47cdad82825bca01a7f95519d4b2ef0791ae8b43ab3f8dfe46e2b583d74c8421d9bd13112e390f9dbcd5ba16846fc80e3c80a7ceeccbf18073fc0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 9.1.0 / 2018-04-19
4
+
5
+ * Upgrade to Rails 5.1 (mvz)
6
+ * Fix a bunch of issues (e-tobi)
7
+
3
8
  ## 9.0.1
4
9
 
5
10
  * Remove link_to_author setting: author email is no longer shown. Whoever
@@ -11,17 +11,6 @@ class Admin::BaseController < BaseController
11
11
 
12
12
  private
13
13
 
14
- def update_settings_with!(settings_param)
15
- Blog.transaction do
16
- settings_param.each { |k, v| this_blog.send("#{k}=", v) }
17
- if this_blog.save
18
- flash[:success] = I18n.t('admin.settings.update.success')
19
- else
20
- flash[:error] = I18n.t('admin.settings.update.error', messages: this_blog.errors.full_messages.join(', '))
21
- end
22
- end
23
- end
24
-
25
14
  def destroy_a(klass_to_destroy)
26
15
  @record = klass_to_destroy.find(params[:id])
27
16
  if @record.respond_to?(:access_by?) && !@record.access_by?(current_user)
@@ -3,8 +3,6 @@ require 'base64'
3
3
  module Admin; end
4
4
 
5
5
  class Admin::ContentController < Admin::BaseController
6
- layout :get_layout
7
-
8
6
  def index
9
7
  @search = params[:search] ? params[:search] : {}
10
8
  @articles = this_blog.articles.search_with(@search).page(params[:page]).per(this_blog.admin_display_elements)
@@ -21,6 +19,7 @@ class Admin::ContentController < Admin::BaseController
21
19
  def new
22
20
  @article = Article::Factory.new(this_blog, current_user).default
23
21
  load_resources
22
+ render layout: 'editor'
24
23
  end
25
24
 
26
25
  def edit
@@ -29,6 +28,7 @@ class Admin::ContentController < Admin::BaseController
29
28
  @article.text_filter ||= current_user.default_text_filter
30
29
  @article.keywords = Tag.collection_to_string @article.tags
31
30
  load_resources
31
+ render layout: 'editor'
32
32
  end
33
33
 
34
34
  def create
@@ -49,7 +49,7 @@ class Admin::ContentController < Admin::BaseController
49
49
  else
50
50
  @article.keywords = Tag.collection_to_string @article.tags
51
51
  load_resources
52
- render 'new'
52
+ render 'new', layout: 'editor'
53
53
  end
54
54
  end
55
55
 
@@ -59,7 +59,7 @@ class Admin::ContentController < Admin::BaseController
59
59
  @article = Article.find(id)
60
60
 
61
61
  if params[:article][:draft]
62
- get_fresh_or_existing_draft_for_article
62
+ fetch_fresh_or_existing_draft_for_article
63
63
  else
64
64
  @article = Article.find(@article.parent_id) unless @article.parent_id.nil?
65
65
  end
@@ -100,7 +100,7 @@ class Admin::ContentController < Admin::BaseController
100
100
  article_factory = Article::Factory.new(this_blog, current_user)
101
101
  @article = article_factory.get_or_build_from(id)
102
102
 
103
- get_fresh_or_existing_draft_for_article
103
+ fetch_fresh_or_existing_draft_for_article
104
104
 
105
105
  @article.attributes = params[:article].permit!
106
106
 
@@ -116,7 +116,7 @@ class Admin::ContentController < Admin::BaseController
116
116
 
117
117
  if @article.save
118
118
  flash[:success] = I18n.t('admin.content.autosave.success')
119
- @must_update_calendar = (params[:article][:published_at] and params[:article][:published_at].to_time.to_i < Time.now.to_time.to_i and @article.parent_id.nil?)
119
+ @must_update_calendar = (params[:article][:published_at] and params[:article][:published_at].to_time.to_i < Time.zone.now.to_time.to_i and @article.parent_id.nil?)
120
120
  respond_to do |format|
121
121
  format.js
122
122
  end
@@ -125,7 +125,7 @@ class Admin::ContentController < Admin::BaseController
125
125
 
126
126
  protected
127
127
 
128
- def get_fresh_or_existing_draft_for_article
128
+ def fetch_fresh_or_existing_draft_for_article
129
129
  return unless @article.published? && @article.id
130
130
 
131
131
  parent_id = @article.id
@@ -177,15 +177,4 @@ class Admin::ContentController < Admin::BaseController
177
177
  :title,
178
178
  :keywords)
179
179
  end
180
-
181
- def get_layout
182
- case action_name
183
- when 'new', 'edit', 'create'
184
- 'editor'
185
- when 'show', 'autosave'
186
- nil
187
- else
188
- 'administration'
189
- end
190
- end
191
180
  end
@@ -6,8 +6,7 @@ class Admin::DashboardController < Admin::BaseController
6
6
  require 'rexml/document'
7
7
 
8
8
  def index
9
- t = Time.new
10
- today = t.strftime('%Y-%m-%d 00:00')
9
+ today = Time.zone.now.strftime('%Y-%m-%d 00:00')
11
10
 
12
11
  # Since last visit
13
12
  last_sign_in = current_user.last_sign_in_at
@@ -83,6 +83,7 @@ class Admin::FeedbackController < Admin::BaseController
83
83
  template = @feedback.change_state!
84
84
 
85
85
  respond_to do |format|
86
+ # TODO: Make this special case not necessary
86
87
  if params[:context] != 'listing'
87
88
  @comments = Comment.last_published
88
89
  page.replace_html('commentList', partial: 'admin/dashboard/comment')
@@ -23,7 +23,7 @@ class Admin::NotesController < Admin::BaseController
23
23
  note.state = 'published'
24
24
  note.attributes = params[:note].permit!
25
25
  note.text_filter ||= current_user.default_text_filter
26
- note.published_at ||= Time.now
26
+ note.published_at ||= Time.zone.now
27
27
  if note.save
28
28
  if params[:push_to_twitter] && note.twitter_id.blank?
29
29
  unless note.send_to_twitter
@@ -1,12 +1,8 @@
1
- # coding: utf-8
2
-
3
1
  require 'base64'
4
2
 
5
3
  class Admin::PagesController < Admin::BaseController
6
4
  before_action :set_macro, only: [:new, :edit]
7
- before_action :set_page, only: [:show, :edit, :update, :destroy]
8
-
9
- layout :get_layout
5
+ before_action :set_page, only: [:edit, :update, :destroy]
10
6
 
11
7
  def index
12
8
  @search = params[:search] ? params[:search] : {}
@@ -18,22 +14,24 @@ class Admin::PagesController < Admin::BaseController
18
14
  @page.text_filter ||= default_textfilter
19
15
  @page.user_id = current_user.id
20
16
  @page.state = 'published'
17
+ render layout: 'editor'
21
18
  end
22
19
 
23
20
  def edit
24
21
  @page.text_filter ||= default_textfilter
22
+ render layout: 'editor'
25
23
  end
26
24
 
27
25
  def create
28
26
  @page = Page.new(page_params)
29
- @page.published_at = Time.now
27
+ @page.published_at = Time.zone.now
30
28
  @page.blog = this_blog
31
29
  @page.user_id = current_user.id
32
30
 
33
31
  if @page.save
34
32
  redirect_to admin_pages_url, notice: I18n.t('admin.pages.new.success')
35
33
  else
36
- render :new
34
+ render :new, layout: 'editor'
37
35
  end
38
36
  end
39
37
 
@@ -60,17 +58,6 @@ class Admin::PagesController < Admin::BaseController
60
58
  @macros = TextFilterPlugin.macro_filters
61
59
  end
62
60
 
63
- def get_layout
64
- case action_name
65
- when 'new', 'edit', 'create'
66
- 'editor'
67
- when 'show'
68
- nil
69
- else
70
- 'administration'
71
- end
72
- end
73
-
74
61
  # Use callbacks to share common setup or constraints between actions.
75
62
  def set_page
76
63
  @page = Page.find(params[:id])
@@ -78,6 +65,6 @@ class Admin::PagesController < Admin::BaseController
78
65
 
79
66
  # Never trust parameters from the scary internet, only allow the white list through.
80
67
  def page_params
81
- params.require(:page).permit(:title, :body, :name, :state, :text_filter)
68
+ params.require(:page).permit(:title, :body, :name, :state, :text_filter_id)
82
69
  end
83
70
  end
@@ -7,7 +7,7 @@ class Admin::ProfilesController < Admin::BaseController
7
7
  def update
8
8
  @user.resource = upload_avatar if params[:user][:filename]
9
9
 
10
- if @user.update(user_params)
10
+ if @user.update(update_params)
11
11
  redirect_to admin_profiles_url, notice: I18n.t('admin.profiles.index.success')
12
12
  else
13
13
  render :index
@@ -25,7 +25,7 @@ class Admin::ProfilesController < Admin::BaseController
25
25
  'text/plain'
26
26
  end
27
27
 
28
- Resource.create(upload: file, mime: mime, created_at: Time.now)
28
+ Resource.create(upload: file, mime: mime, created_at: Time.zone.now)
29
29
  end
30
30
 
31
31
  # Use callbacks to share common setup or constraints between actions.
@@ -37,11 +37,19 @@ class Admin::ProfilesController < Admin::BaseController
37
37
  def user_params
38
38
  params.require(:user).permit(:login, :password, :password_confirmation,
39
39
  :email, :firstname, :lastname, :nickname,
40
- :display_name, :notify_via_email,
40
+ :name, :notify_via_email,
41
41
  :notify_on_new_articles, :notify_on_comments,
42
42
  :text_filter_id, :state,
43
43
  :twitter_account, :twitter_oauth_token,
44
44
  :twitter_oauth_token_secret, :description,
45
45
  :url, :msn, :yahoo, :jabber, :aim, :twitter)
46
46
  end
47
+
48
+ def update_params
49
+ if user_params[:password].blank? && user_params[:password_confirmation].blank?
50
+ user_params.except(:password_confirmation, :password)
51
+ else
52
+ user_params
53
+ end
54
+ end
47
55
  end
@@ -12,9 +12,7 @@ class Admin::SeoController < Admin::BaseController
12
12
  end
13
13
 
14
14
  def update
15
- if settings_params[:permalink_format] == 'custom'
16
- settings_params[:permalink_format] = settings_params[:custom_permalink]
17
- end
15
+ settings_params[:permalink_format] = settings_params[:custom_permalink] if settings_params[:permalink_format] == 'custom'
18
16
  if @setting.update_attributes(settings_params)
19
17
  flash[:success] = I18n.t('admin.settings.update.success')
20
18
  redirect_to admin_seo_path(section: @section)
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  class Admin::SidebarController < Admin::BaseController
4
2
  def index
5
3
  @available = SidebarRegistry.available_sidebars
@@ -46,9 +46,9 @@ class Admin::UsersController < Admin::BaseController
46
46
  def user_params
47
47
  params.require(:user).permit(:login, :password, :password_confirmation,
48
48
  :email, :firstname, :lastname, :nickname,
49
- :display_name, :notify_via_email,
49
+ :name, :notify_via_email,
50
50
  :notify_on_new_articles, :notify_on_comments,
51
- :profile, :text_filter, :state,
51
+ :profile, :text_filter_id, :state,
52
52
  :twitter_account, :twitter_oauth_token,
53
53
  :twitter_oauth_token_secret, :description,
54
54
  :url, :msn, :yahoo, :jabber, :aim, :twitter)
@@ -1,5 +1,5 @@
1
1
  class CommentsController < BaseController
2
- before_action :get_article, only: [:create, :preview]
2
+ before_action :set_article, only: [:create, :preview]
3
3
 
4
4
  def create
5
5
  options = new_comment_defaults.merge comment_params.to_h
@@ -10,12 +10,10 @@ class CommentsController < BaseController
10
10
  @comment.user_id = current_user.id if current_user.id == session[:user_id]
11
11
  end
12
12
 
13
- set_cookies_for @comment
13
+ remember_author_info_for @comment
14
14
 
15
15
  partial = '/articles/comment_failed'
16
- if recaptcha_ok_for?(@comment) && @comment.save
17
- partial = '/articles/comment'
18
- end
16
+ partial = '/articles/comment' if recaptcha_ok_for?(@comment) && @comment.save
19
17
  respond_to do |format|
20
18
  format.js { render partial }
21
19
  format.html { redirect_to URI.parse(@article.permalink_url).path }
@@ -49,15 +47,13 @@ class CommentsController < BaseController
49
47
  permalink: @article.permalink_url }.stringify_keys
50
48
  end
51
49
 
52
- def set_cookies_for(comment)
50
+ def remember_author_info_for(comment)
53
51
  add_to_cookies(:author, comment.author)
54
52
  add_to_cookies(:url, comment.url)
55
- if comment.email.present?
56
- add_to_cookies(:gravatar_id, Digest::MD5.hexdigest(comment.email.strip))
57
- end
53
+ add_to_cookies(:gravatar_id, Digest::MD5.hexdigest(comment.email.strip)) if comment.email.present?
58
54
  end
59
55
 
60
- def get_article
56
+ def set_article
61
57
  @article = Article.find(params[:article_id])
62
58
  end
63
59
 
@@ -2,8 +2,7 @@ class SetupController < BaseController
2
2
  before_action :check_config
3
3
  layout 'accounts'
4
4
 
5
- def index
6
- end
5
+ def index; end
7
6
 
8
7
  def create
9
8
  this_blog.blog_name = params[:setting][:blog_name]
@@ -64,8 +64,7 @@ module Admin::BaseHelper
64
64
  content_tag(:span, '', class: 'glyphicon glyphicon-trash'),
65
65
  { action: 'destroy', id: item.id },
66
66
  { class: 'btn btn-danger btn-xs btn-action', method: :delete,
67
- data: { confirm: confirm_text } }
68
- )
67
+ data: { confirm: confirm_text } })
69
68
  end
70
69
 
71
70
  def button_to_short_url(item)
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  # Methods added to this helper will be available to all templates in the application.
4
2
  require 'digest/sha1'
5
3
 
@@ -9,8 +7,8 @@ module BaseHelper
9
7
  # Need to rewrite this one, quick hack to test my changes.
10
8
  attr_reader :page_title
11
9
 
12
- def render_sidebars(*sidebars)
13
- rendered_sidebars = (sidebars.blank? ? Sidebar.order(:active_position) : sidebars).map do |sb|
10
+ def render_sidebars
11
+ rendered_sidebars = Sidebar.order(:active_position).map do |sb|
14
12
  @sidebar = sb
15
13
  sb.parse_request(content_array, params)
16
14
  render_sidebar(sb)
@@ -123,21 +121,6 @@ module BaseHelper
123
121
  image_tag(status.user.twitter_profile_image, class: 'alignleft', alt: status.user.nickname)
124
122
  end
125
123
 
126
- def google_analytics
127
- unless this_blog.google_analytics.empty?
128
- <<-HTML
129
- <script type="text/javascript">
130
- var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
131
- document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
132
- </script>
133
- <script type="text/javascript">
134
- var pageTracker = _gat._getTracker("#{this_blog.google_analytics}");
135
- pageTracker._trackPageview();
136
- </script>
137
- HTML
138
- end
139
- end
140
-
141
124
  def page_header_includes
142
125
  content_array.map(&:whiteboard).map do |w|
143
126
  w.select { |k, _v| k =~ /^page_header_/ }.map do |_, v|
@@ -8,7 +8,7 @@ module XmlHelper
8
8
  times.push article_published.updated_at if article_published
9
9
 
10
10
  if times.empty?
11
- Time.at(0).xmlschema
11
+ Time.zone.at(0).xmlschema
12
12
  else
13
13
  times.max.xmlschema
14
14
  end
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  require 'aasm'
4
2
  require 'uri'
5
3
  require 'net/http'
@@ -26,9 +24,7 @@ class Article < Content
26
24
  after_save :keywords_to_tags, :shorten_url
27
25
 
28
26
  scope :child_of, ->(article_id) { where(parent_id: article_id) }
29
- scope :published_since, ->(time) {
30
- published.where('published_at > ?', time).order(default_order)
31
- }
27
+ scope :published_since, ->(time) { published.where('published_at > ?', time) }
32
28
  scope :withdrawn, -> { where(state: 'withdrawn').order(default_order) }
33
29
  scope :pending, -> { where(state: 'publication_pending'). order(default_order) }
34
30
 
@@ -103,9 +99,7 @@ class Article < Content
103
99
  def self.search_with(params)
104
100
  params ||= {}
105
101
  scoped = super(params)
106
- if %w(no_draft drafts published withdrawn pending).include?(params[:state])
107
- scoped = scoped.send(params[:state])
108
- end
102
+ scoped = scoped.send(params[:state]) if %w(no_draft drafts published withdrawn pending).include?(params[:state])
109
103
 
110
104
  scoped.order('created_at DESC')
111
105
  end
@@ -119,7 +113,7 @@ class Article < Content
119
113
 
120
114
  def save_attachments!(files)
121
115
  files ||= {}
122
- files.values.each { |f| save_attachment!(f) }
116
+ files.each_value { |f| save_attachment!(f) }
123
117
  end
124
118
 
125
119
  def save_attachment!(file)
@@ -206,9 +200,7 @@ class Article < Content
206
200
  def html_urls
207
201
  urls = []
208
202
  html.gsub(/<a\s+[^>]*>/) do |tag|
209
- if tag =~ /\bhref=(["']?)([^ >"]+)\1/
210
- urls.push(Regexp.last_match[2].strip)
211
- end
203
+ urls.push(Regexp.last_match[2].strip) if tag =~ /\bhref=(["']?)([^ >"]+)\1/
212
204
  end
213
205
  urls.uniq
214
206
  end