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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/app/controllers/admin/base_controller.rb +0 -11
- data/app/controllers/admin/content_controller.rb +7 -18
- data/app/controllers/admin/dashboard_controller.rb +1 -2
- data/app/controllers/admin/feedback_controller.rb +1 -0
- data/app/controllers/admin/notes_controller.rb +1 -1
- data/app/controllers/admin/pages_controller.rb +6 -19
- data/app/controllers/admin/profiles_controller.rb +11 -3
- data/app/controllers/admin/seo_controller.rb +1 -3
- data/app/controllers/admin/sidebar_controller.rb +0 -2
- data/app/controllers/admin/users_controller.rb +2 -2
- data/app/controllers/comments_controller.rb +6 -10
- data/app/controllers/setup_controller.rb +1 -2
- data/app/helpers/admin/base_helper.rb +1 -2
- data/app/helpers/base_helper.rb +2 -19
- data/app/helpers/xml_helper.rb +1 -1
- data/app/models/article.rb +4 -12
- data/app/models/blog.rb +9 -17
- data/app/models/content.rb +6 -16
- data/app/models/feedback.rb +2 -1
- data/app/models/meta_sidebar.rb +0 -2
- data/app/models/note.rb +2 -3
- data/app/models/page.rb +1 -2
- data/app/models/ping.rb +1 -1
- data/app/models/post_type.rb +1 -3
- data/app/models/redirect.rb +3 -2
- data/app/models/redirection.rb +1 -1
- data/app/models/resource.rb +1 -1
- data/app/models/sidebar.rb +1 -1
- data/app/models/static_sidebar.rb +0 -2
- data/app/models/tag.rb +1 -1
- data/app/models/text_filter.rb +1 -1
- data/app/models/trigger.rb +2 -2
- data/app/models/user.rb +1 -1
- data/app/services/title_builder.rb +7 -11
- data/app/uploaders/resource_uploader.rb +1 -3
- data/app/views/admin/content/_form.html.erb +1 -1
- data/app/views/admin/content/autosave.js.erb +2 -2
- data/app/views/admin/pages/_form.html.erb +6 -6
- data/app/views/admin/seo/_general.html.erb +1 -1
- data/app/views/admin/seo/_permalinks.html.erb +2 -2
- data/app/views/admin/users/_form.html.erb +2 -2
- data/app/views/articles/view_page.html.erb +1 -1
- data/app/views/shared/_atom_header.atom.builder +1 -3
- data/app/views/shared/_atom_item_article.atom.builder +9 -13
- data/app/views/shared/_google_analytics.html.erb +8 -0
- data/app/views/shared/_page_header.html.erb +1 -1
- data/app/views/shared/_rss_item_article.rss.builder +2 -3
- data/config/initializers/mime_types.rb +1 -1
- data/config/locales/da.yml +1 -3
- data/config/locales/de.yml +1 -3
- data/config/locales/en.yml +1 -3
- data/config/locales/es-MX.yml +1 -3
- data/config/locales/fr.yml +1 -3
- data/config/locales/he.yml +1 -3
- data/config/locales/it.yml +1 -3
- data/config/locales/ja.yml +1 -3
- data/config/locales/lt.yml +1 -3
- data/config/locales/nb-NO.yml +1 -3
- data/config/locales/nl.yml +1 -3
- data/config/locales/pl.yml +193 -195
- data/config/locales/pt-BR.yml +1 -3
- data/config/locales/ro.yml +1 -3
- data/config/locales/ru.yml +1 -3
- data/config/locales/zh-CN.yml +1 -3
- data/config/locales/zh-TW.yml +1 -3
- data/config/routes.rb +1 -1
- data/db/migrate/113_initial_schema.rb +0 -2
- data/db/migrate/114_fixes_buggy_articles_and_notes.rb +1 -1
- data/db/migrate/115_drops_categories_for_tags.rb +3 -4
- data/db/migrate/20150807134129_simplify_redirect_relations.rb +1 -3
- data/db/migrate/20150808052637_add_blog_ids.rb +5 -1
- data/db/seeds.rb +1 -3
- data/lib/format.rb +1 -11
- data/lib/publify_core/version.rb +1 -1
- data/lib/spam_protection.rb +3 -4
- data/lib/text_filter_plugin.rb +3 -4
- data/lib/theme.rb +1 -3
- data/lib/transforms.rb +0 -2
- metadata +87 -80
data/app/models/blog.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Once upon a time, there were plans to make publify handle multiple blogs,
|
6
6
|
# but it never happened and publify is now firmly single-blog.
|
7
7
|
#
|
8
|
-
class Blog <
|
8
|
+
class Blog < ApplicationRecord
|
9
9
|
include ConfigManager
|
10
10
|
include Rails.application.routes.url_helpers
|
11
11
|
|
@@ -73,16 +73,16 @@ class Blog < ActiveRecord::Base
|
|
73
73
|
setting :meta_keywords, :string, ''
|
74
74
|
setting :google_analytics, :string, ''
|
75
75
|
setting :rss_description, :boolean, false
|
76
|
-
setting :rss_description_text, :string,
|
76
|
+
setting :rss_description_text, :string, <<-HTML.strip_heredoc
|
77
77
|
<hr />
|
78
78
|
<p><small>Original article written by %author% and published on <a href='%blog_url%'>%blog_name%</a>
|
79
79
|
| <a href='%permalink_url%'>direct link to this article</a>
|
80
80
|
| If you are reading this article anywhere other than on <a href='%blog_url%'>%blog_name%</a>,
|
81
81
|
it has been illegally reproduced and without proper authorization.</small></p>
|
82
|
-
|
82
|
+
HTML
|
83
83
|
setting :permalink_format, :string, '/%year%/%month%/%day%/%title%'
|
84
84
|
setting :robots, :string, 'User-agent: *\nAllow: /\nDisallow: /admin\n'
|
85
|
-
setting :humans, :string,
|
85
|
+
setting :humans, :string, <<-TEXT.strip_heredoc
|
86
86
|
/* TEAM */
|
87
87
|
Your title: Your name.
|
88
88
|
Site: email, link to a contact form, etc.
|
@@ -90,7 +90,7 @@ EOS
|
|
90
90
|
|
91
91
|
/* SITE */
|
92
92
|
Software: Publify [http://publify.co] #{PublifyCore::VERSION}
|
93
|
-
|
93
|
+
TEXT
|
94
94
|
setting :index_categories, :boolean, true # deprecated but still needed for backward compatibility
|
95
95
|
setting :unindex_categories, :boolean, false
|
96
96
|
setting :index_tags, :boolean, true # deprecated but still needed for backward compatibility
|
@@ -179,9 +179,7 @@ EOS
|
|
179
179
|
host: host_with_port,
|
180
180
|
script_name: root_path)
|
181
181
|
cache_key = merged_opts.values.prepend('blog-urlfor-withbaseurl').join('-')
|
182
|
-
unless Rails.cache.exist?(cache_key)
|
183
|
-
Rails.cache.write(cache_key, super(merged_opts))
|
184
|
-
end
|
182
|
+
Rails.cache.write(cache_key, super(merged_opts)) unless Rails.cache.exist?(cache_key)
|
185
183
|
Rails.cache.read(cache_key)
|
186
184
|
else
|
187
185
|
raise "Invalid URL in url_for: #{options.inspect}"
|
@@ -219,13 +217,9 @@ EOS
|
|
219
217
|
end
|
220
218
|
|
221
219
|
def permalink_has_identifier
|
222
|
-
unless permalink_format =~ /(%title%)/
|
223
|
-
errors.add(:base, I18n.t('errors.permalink_need_a_title'))
|
224
|
-
end
|
220
|
+
errors.add(:base, I18n.t('errors.permalink_need_a_title')) unless permalink_format =~ /(%title%)/
|
225
221
|
|
226
|
-
if permalink_format =~ /\.(atom|rss)$/
|
227
|
-
errors.add(:permalink_format, I18n.t('errors.cant_end_with_rss_or_atom'))
|
228
|
-
end
|
222
|
+
errors.add(:permalink_format, I18n.t('errors.cant_end_with_rss_or_atom')) if permalink_format =~ /\.(atom|rss)$/
|
229
223
|
end
|
230
224
|
|
231
225
|
def root_path
|
@@ -258,9 +252,7 @@ EOS
|
|
258
252
|
|
259
253
|
def split_base_url
|
260
254
|
unless @split_base_url
|
261
|
-
unless base_url =~
|
262
|
-
raise "Invalid base_url: #{base_url}"
|
263
|
-
end
|
255
|
+
raise "Invalid base_url: #{base_url}" unless base_url =~ %r{(https?)://([^/]*)(.*)}
|
264
256
|
@split_base_url = { protocol: Regexp.last_match[1], host_with_port: Regexp.last_match[2], root_path: Regexp.last_match[3].gsub(%r{/$}, '') }
|
265
257
|
end
|
266
258
|
@split_base_url
|
data/app/models/content.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'set'
|
2
2
|
require 'uri'
|
3
3
|
|
4
|
-
class Content <
|
4
|
+
class Content < ApplicationRecord
|
5
5
|
include ContentBase
|
6
6
|
|
7
7
|
belongs_to :text_filter, optional: true
|
@@ -18,11 +18,7 @@ class Content < ActiveRecord::Base
|
|
18
18
|
|
19
19
|
scope :user_id, ->(user_id) { where('user_id = ?', user_id) }
|
20
20
|
scope :published, -> { where(state: 'published'). order(default_order) }
|
21
|
-
scope :published_at, ->(time_params) {
|
22
|
-
published.
|
23
|
-
where(published_at: PublifyTime.delta(*time_params)).
|
24
|
-
order('published_at DESC')
|
25
|
-
}
|
21
|
+
scope :published_at, ->(time_params) { published.where(published_at: PublifyTime.delta(*time_params)) }
|
26
22
|
scope :not_published, -> { where.not(state: 'published') }
|
27
23
|
scope :drafts, -> { where(state: 'draft').order('created_at DESC') }
|
28
24
|
scope :no_draft, -> { where.not(state: 'draft').order('published_at DESC') }
|
@@ -93,17 +89,11 @@ class Content < ActiveRecord::Base
|
|
93
89
|
def self.search_with(params)
|
94
90
|
params ||= {}
|
95
91
|
scoped = unscoped
|
96
|
-
if params[:searchstring].present?
|
97
|
-
scoped = scoped.searchstring(params[:searchstring])
|
98
|
-
end
|
92
|
+
scoped = scoped.searchstring(params[:searchstring]) if params[:searchstring].present?
|
99
93
|
|
100
|
-
if params[:published_at].present? && /(\d\d\d\d)-(\d\d)/ =~ params[:published_at]
|
101
|
-
scoped = scoped.published_at_like(params[:published_at])
|
102
|
-
end
|
94
|
+
scoped = scoped.published_at_like(params[:published_at]) if params[:published_at].present? && /(\d\d\d\d)-(\d\d)/ =~ params[:published_at]
|
103
95
|
|
104
|
-
if params[:user_id].present? && params[:user_id].to_i > 0
|
105
|
-
scoped = scoped.user_id(params[:user_id])
|
106
|
-
end
|
96
|
+
scoped = scoped.user_id(params[:user_id]) if params[:user_id].present? && params[:user_id].to_i > 0
|
107
97
|
|
108
98
|
if params[:published].present?
|
109
99
|
scoped = scoped.published if params[:published].to_s == '1'
|
@@ -117,7 +107,7 @@ class Content < ActiveRecord::Base
|
|
117
107
|
self[:whiteboard] ||= {}
|
118
108
|
end
|
119
109
|
|
120
|
-
def
|
110
|
+
def rss_description
|
121
111
|
return '' unless blog.rss_description
|
122
112
|
|
123
113
|
rss_desc = blog.rss_description_text
|
data/app/models/feedback.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'aasm'
|
4
4
|
require 'akismet'
|
5
5
|
|
6
|
-
class Feedback <
|
6
|
+
class Feedback < ApplicationRecord
|
7
7
|
self.table_name = 'feedback'
|
8
8
|
|
9
9
|
belongs_to :text_filter, optional: true
|
@@ -68,6 +68,7 @@ class Feedback < ActiveRecord::Base
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
# FIXME: Inline this method
|
71
72
|
def self.paginated(page, per_page)
|
72
73
|
page(page).per(per_page)
|
73
74
|
end
|
data/app/models/meta_sidebar.rb
CHANGED
data/app/models/note.rb
CHANGED
@@ -113,8 +113,7 @@ class Note < Content
|
|
113
113
|
action: 'show',
|
114
114
|
permalink: permalink,
|
115
115
|
anchor: anchor,
|
116
|
-
only_path: only_path
|
117
|
-
)
|
116
|
+
only_path: only_path)
|
118
117
|
end
|
119
118
|
|
120
119
|
def short_link
|
@@ -123,7 +122,7 @@ class Note < Content
|
|
123
122
|
end
|
124
123
|
|
125
124
|
def prefix
|
126
|
-
blog.shortener_url.sub(
|
125
|
+
blog.shortener_url.sub(%r{^https?://}, '')
|
127
126
|
end
|
128
127
|
|
129
128
|
def published?
|
data/app/models/page.rb
CHANGED
data/app/models/ping.rb
CHANGED
data/app/models/post_type.rb
CHANGED
data/app/models/redirect.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class Redirect <
|
1
|
+
class Redirect < ApplicationRecord
|
2
2
|
belongs_to :contents, optional: true, touch: true
|
3
3
|
belongs_to :blog
|
4
4
|
|
@@ -8,7 +8,8 @@ class Redirect < ActiveRecord::Base
|
|
8
8
|
|
9
9
|
def full_to_path
|
10
10
|
path = to_path
|
11
|
-
|
11
|
+
# FIXME: Unify HTTP URI matchers
|
12
|
+
return path if path =~ %r{^(https?)://([^/]*)(.*)}
|
12
13
|
url_root = blog.root_path
|
13
14
|
path = File.join(url_root, path) unless url_root.nil? || path[0, url_root.length] == url_root
|
14
15
|
path
|
data/app/models/redirection.rb
CHANGED
data/app/models/resource.rb
CHANGED
data/app/models/sidebar.rb
CHANGED
data/app/models/tag.rb
CHANGED
data/app/models/text_filter.rb
CHANGED
data/app/models/trigger.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class Trigger <
|
1
|
+
class Trigger < ApplicationRecord
|
2
2
|
belongs_to :pending_item, polymorphic: true
|
3
3
|
|
4
4
|
class << self
|
@@ -9,7 +9,7 @@ class Trigger < ActiveRecord::Base
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def fire
|
12
|
-
where('due_at <= ?', Time.now).destroy_all
|
12
|
+
where('due_at <= ?', Time.zone.now).destroy_all
|
13
13
|
true
|
14
14
|
end
|
15
15
|
|
data/app/models/user.rb
CHANGED
@@ -18,10 +18,10 @@ class TitleBuilder
|
|
18
18
|
|
19
19
|
def substitute_time(s, settings)
|
20
20
|
# Other
|
21
|
-
s = s.gsub('%currentdate%', Time.now.strftime(settings.date_format))
|
22
|
-
s = s.gsub('%currenttime%', Time.now.strftime(settings.time_format))
|
23
|
-
s = s.gsub('%currentmonth%', Time.now.strftime('%B'))
|
24
|
-
s = s.gsub('%currentyear%', Time.now.year.to_s)
|
21
|
+
s = s.gsub('%currentdate%', Time.zone.now.strftime(settings.date_format))
|
22
|
+
s = s.gsub('%currenttime%', Time.zone.now.strftime(settings.time_format))
|
23
|
+
s = s.gsub('%currentmonth%', Time.zone.now.strftime('%B'))
|
24
|
+
s = s.gsub('%currentyear%', Time.zone.now.year.to_s)
|
25
25
|
s
|
26
26
|
end
|
27
27
|
|
@@ -34,13 +34,9 @@ class TitleBuilder
|
|
34
34
|
s = s.gsub('%author%', item.name) if s =~ /%author%/ && item.respond_to?(:name)
|
35
35
|
s = s.gsub('%body%', item.body) if s =~ /%body%/ && item.respond_to?(:body)
|
36
36
|
|
37
|
-
if s =~ /%categories%/ && item.respond_to?(:categories)
|
38
|
-
s = s.gsub('%categories%', item.categories.map(&:name).join(', '))
|
39
|
-
end
|
37
|
+
s = s.gsub('%categories%', item.categories.map(&:name).join(', ')) if s =~ /%categories%/ && item.respond_to?(:categories)
|
40
38
|
|
41
|
-
if s =~ /%tags%/ && item.respond_to?(:tags)
|
42
|
-
s = s.gsub('%tags%', item.tags.map(&:display_name).join(', '))
|
43
|
-
end
|
39
|
+
s = s.gsub('%tags%', item.tags.map(&:display_name).join(', ')) if s =~ /%tags%/ && item.respond_to?(:tags)
|
44
40
|
|
45
41
|
s
|
46
42
|
end
|
@@ -70,7 +66,7 @@ class TitleBuilder
|
|
70
66
|
format << '%B ' if params[:month]
|
71
67
|
format << '%Y' if params[:year]
|
72
68
|
|
73
|
-
string.gsub('%date%', Time.
|
69
|
+
string.gsub('%date%', Time.zone.local(*params.values_at(:year, :month, :day)).strftime(format))
|
74
70
|
end
|
75
71
|
|
76
72
|
def parse_page(_string, params)
|
@@ -34,9 +34,7 @@ class ResourceUploader < CarrierWave::Uploader::Base
|
|
34
34
|
def check_image_content_type!(new_file)
|
35
35
|
if image?(new_file)
|
36
36
|
magic_type = mime_magic_content_type(new_file)
|
37
|
-
if magic_type != new_file.content_type
|
38
|
-
raise CarrierWave::IntegrityError, 'has MIME type mismatch'
|
39
|
-
end
|
37
|
+
raise CarrierWave::IntegrityError, 'has MIME type mismatch' if magic_type != new_file.content_type
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<div class="row">
|
26
26
|
<div class="col-md-2" id="quicktags-block">
|
27
27
|
<div id="quicktags" class="pull-right">
|
28
|
-
<script type="text/javascript">edToolbar('article_body_and_extended', '<%= @article.text_filter %>');</script>
|
28
|
+
<script type="text/javascript">edToolbar('article_body_and_extended', '<%= @article.text_filter.name %>');</script>
|
29
29
|
</div>
|
30
30
|
</div>
|
31
31
|
<div class="col-md-8">
|
@@ -1,5 +1,5 @@
|
|
1
1
|
$('#autosave').html('<%= hidden_field_tag('article[id]', @article.id) %>');
|
2
2
|
$('#preview_link').replaceWith('<%= link_to('Preview', {:controller => '/articles', :action => 'preview', :id => @article.id}, {:target => 'new', :class => 'btn btn-default'}); %>');
|
3
3
|
<% if @article.state.to_s.downcase == "draft" %>
|
4
|
-
$("#article_published_at").val(<% Time.now() %>);
|
5
|
-
<% end %>
|
4
|
+
$("#article_published_at").val(<% Time.zone.now() %>);
|
5
|
+
<% end %>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<span class='pull-right'>
|
19
19
|
<%= link_to(t('.cancel'), {action: 'index'}, {class: 'btn btn-default'}) %>
|
20
20
|
<!-- Button trigger modal -->
|
21
|
-
<button class="btn btn-success" data-toggle="modal" data-target="#publish">
|
21
|
+
<button class="btn btn-success" data-toggle="modal" type="button" data-target="#publish">
|
22
22
|
<%= controller.action_name == "new" ? t(".publish") : t(".save") %>
|
23
23
|
</button>
|
24
24
|
</span>
|
@@ -34,7 +34,7 @@
|
|
34
34
|
<div class='row'>
|
35
35
|
<div class='col-md-2' id='quicktags-block'>
|
36
36
|
<div id='quicktags' class='pull-right'>
|
37
|
-
<script type="text/javascript">edToolbar('page_body', '<%= @page.text_filter %>');</script>
|
37
|
+
<script type="text/javascript">edToolbar('page_body', '<%= @page.text_filter.name %>');</script>
|
38
38
|
</div>
|
39
39
|
</div>
|
40
40
|
|
@@ -69,11 +69,11 @@
|
|
69
69
|
<fieldset>
|
70
70
|
<legend><%= t(".publish_settings") %></legend>
|
71
71
|
<div class='control-group'>
|
72
|
-
<%= t(".status") %>: <strong><%=
|
72
|
+
<%= t(".status") %>: <strong><%= @page.state %></strong>
|
73
73
|
<%= toggle_element('status') %>
|
74
74
|
<div id='status' class='collapse'>
|
75
75
|
<label for="page_published" class='checkbox'>
|
76
|
-
<%= check_box 'page', 'published
|
76
|
+
<%= check_box 'page', 'state', {}, 'published', '' %>
|
77
77
|
<%= t(".online")%>
|
78
78
|
</label>
|
79
79
|
<p><span class='btn btn-default btn-mini'><%= toggle_element 'status', "OK" %></span></p>
|
@@ -82,8 +82,8 @@
|
|
82
82
|
<div class='control-group'>
|
83
83
|
<%= t(".article_filter") %>: <strong><%= @page.text_filter.description %></strong> <%= toggle_element 'text_filter' %>
|
84
84
|
<div id='text_filter' class='collapse'>
|
85
|
-
<select name="page[
|
86
|
-
<%= options_for_select
|
85
|
+
<select name="page[text_filter_id]" id="text_filter" class='form-control'>
|
86
|
+
<%= options_for_select text_filter_options_with_id, @page.text_filter.id %>
|
87
87
|
</select>
|
88
88
|
<p><span class='btn btn-mini btn-default'><%= toggle_element 'text_filter', "OK" %></span></p>
|
89
89
|
</div>
|
@@ -12,12 +12,12 @@
|
|
12
12
|
<%= radio_button(:setting, :permalink_format, '/%year%/%month%/%day%/%title%') %>
|
13
13
|
<%= t(".date_and_title") %>
|
14
14
|
</label>
|
15
|
-
<small class='help-block'><%= "#{this_blog.base_url}/#{Time.now.strftime('%Y/%m/%d')}/sample-article" %></small>
|
15
|
+
<small class='help-block'><%= "#{this_blog.base_url}/#{Time.zone.now.strftime('%Y/%m/%d')}/sample-article" %></small>
|
16
16
|
<label for="setting_permalink_format_yearmonthtitle">
|
17
17
|
<%= radio_button(:setting, :permalink_format, '/%year%/%month%/%title%') %>
|
18
18
|
<%= t(".month_and_title") %>
|
19
19
|
</label>
|
20
|
-
<small class='help-block'><%= "#{this_blog.base_url}/#{Time.now.strftime('%Y/%m')}/sample-article" %></small>
|
20
|
+
<small class='help-block'><%= "#{this_blog.base_url}/#{Time.zone.now.strftime('%Y/%m')}/sample-article" %></small>
|
21
21
|
<label for="setting_permalink_format_title">
|
22
22
|
<%= radio_button(:setting, :permalink_format, '/%title%') %> <%= t(".title_only") %>
|
23
23
|
</label>
|
@@ -87,9 +87,9 @@
|
|
87
87
|
</div>
|
88
88
|
<% end %>
|
89
89
|
<div class='form-group'>
|
90
|
-
<label class='control-label col-sm-2' for="
|
90
|
+
<label class='control-label col-sm-2' for="text_filter_id"><%= t('.article_filter') %></label>
|
91
91
|
<div class='col-sm-5'>
|
92
|
-
<select name="user[text_filter_id]" id="
|
92
|
+
<select name="user[text_filter_id]" id="text_filter_id" class='form-control'>
|
93
93
|
<%= options_for_select text_filter_options_with_id, user.text_filter.id %>
|
94
94
|
</select>
|
95
95
|
</div>
|