publify_core 9.2.10 → 10.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +57 -18
- data/app/assets/javascripts/lang/ar_AR.js +17 -0
- data/app/controllers/admin/{content_controller.rb → articles_controller.rb} +24 -24
- data/app/controllers/admin/dashboard_controller.rb +3 -3
- data/app/controllers/admin/feedback_controller.rb +23 -23
- data/app/controllers/admin/pages_controller.rb +2 -2
- data/app/controllers/admin/post_types_controller.rb +10 -4
- data/app/controllers/admin/redirects_controller.rb +10 -6
- data/app/controllers/admin/resources_controller.rb +2 -2
- data/app/controllers/admin/sidebar_controller.rb +2 -2
- data/app/controllers/admin/tags_controller.rb +5 -3
- data/app/controllers/admin/themes_controller.rb +1 -2
- data/app/controllers/admin/users_controller.rb +5 -3
- data/app/controllers/articles_controller.rb +5 -5
- data/app/controllers/authors_controller.rb +2 -2
- data/app/controllers/base_controller.rb +0 -3
- data/app/controllers/feedback_controller.rb +3 -3
- data/app/controllers/tags_controller.rb +3 -3
- data/app/helpers/authors_helper.rb +1 -1
- data/app/helpers/base_helper.rb +6 -6
- data/app/models/ability.rb +1 -1
- data/app/models/archives_sidebar.rb +3 -3
- data/app/models/article.rb +13 -13
- data/app/models/blog.rb +3 -6
- data/app/models/content.rb +1 -3
- data/app/models/content_base.rb +2 -13
- data/app/models/feedback.rb +1 -2
- data/app/models/meta_sidebar.rb +1 -1
- data/app/models/note.rb +2 -2
- data/app/models/redirect.rb +0 -1
- data/app/models/sidebar.rb +1 -1
- data/app/models/static_sidebar.rb +1 -1
- data/app/models/tag.rb +7 -8
- data/app/models/tag_sidebar.rb +3 -3
- data/app/models/text_filter.rb +17 -43
- data/app/models/user.rb +2 -2
- data/app/services/title_builder.rb +4 -4
- data/app/views/admin/{content → articles}/_article_list.html.erb +3 -3
- data/app/views/admin/{content → articles}/_form.html.erb +11 -1
- data/app/views/admin/{content → articles}/index.html.erb +1 -1
- data/app/views/admin/dashboard/_drafts.html.erb +2 -2
- data/app/views/admin/dashboard/_overview.html.erb +1 -1
- data/app/views/admin/dashboard/_welcome.html.erb +4 -4
- data/app/views/admin/dashboard/index.html.erb +0 -7
- data/app/views/admin/feedback/article.html.erb +12 -6
- data/app/views/admin/feedback/edit.html.erb +14 -2
- data/app/views/admin/feedback/index.html.erb +6 -7
- data/app/views/admin/pages/_form.html.erb +13 -14
- data/app/views/admin/seo/show.html.erb +12 -1
- data/app/views/admin/shared/_menu.html.erb +5 -4
- data/app/views/admin/tags/_index_and_form.html.erb +2 -1
- data/app/views/articles/_comment_errors.html.erb +11 -1
- data/app/views/articles/read.html.erb +1 -1
- data/app/views/layouts/administration.html.erb +9 -17
- data/config/i18n-tasks.yml +8 -1
- data/config/initializers/devise.rb +1 -1
- data/config/locales/ar.yml +885 -0
- data/config/locales/da.yml +12 -12
- data/config/locales/de.yml +12 -12
- data/config/locales/en.yml +12 -12
- data/config/locales/es-MX.yml +12 -12
- data/config/locales/fr.yml +12 -12
- data/config/locales/he.yml +12 -12
- data/config/locales/it.yml +12 -12
- data/config/locales/ja.yml +13 -13
- data/config/locales/lt.yml +12 -12
- data/config/locales/{nb-NO.yml → nb.yml} +13 -13
- data/config/locales/nl.yml +13 -13
- data/config/locales/pl.yml +12 -12
- data/config/locales/pt-BR.yml +12 -12
- data/config/locales/ro.yml +12 -12
- data/config/locales/ru.yml +13 -13
- data/config/locales/sidebars.ar.yml +20 -0
- data/config/locales/{sidebars.nb-NO.yml → sidebars.nb.yml} +1 -1
- data/config/locales/zh-CN.yml +12 -12
- data/config/locales/zh-TW.yml +12 -12
- data/config/routes.rb +2 -2
- data/db/migrate/20150807134129_simplify_redirect_relations.rb +1 -0
- data/db/migrate/20150808052637_add_blog_ids.rb +3 -1
- data/db/migrate/20160605103918_replace_profile_id_with_string.rb +1 -0
- data/db/migrate/20160701062604_add_blog_id_to_resources.rb +2 -0
- data/db/migrate/20190208152646_move_text_filter_to_name.rb +17 -17
- data/db/migrate/20221007091049_remove_table_sitealizer.rb +19 -0
- data/db/migrate/20221010092846_remove_page_caches_table.rb +15 -0
- data/db/migrate/20221012163214_remove_itunes_fields_from_resources.rb +14 -0
- data/db/seeds.rb +0 -4
- data/lib/publify_core/content_text_helpers.rb +11 -0
- data/lib/publify_core/lang.rb +1 -1
- data/lib/publify_core/testing_support/factories/articles.rb +55 -0
- data/lib/publify_core/testing_support/factories/blogs.rb +24 -0
- data/lib/publify_core/testing_support/factories/comments.rb +40 -0
- data/lib/publify_core/testing_support/factories/contents.rb +7 -0
- data/lib/publify_core/testing_support/factories/notes.rb +17 -0
- data/lib/publify_core/testing_support/factories/pages.rb +13 -0
- data/lib/publify_core/testing_support/factories/post_types.rb +8 -0
- data/lib/publify_core/testing_support/factories/redirects.rb +9 -0
- data/lib/publify_core/testing_support/factories/resources.rb +16 -0
- data/lib/publify_core/testing_support/factories/sequences.rb +12 -0
- data/lib/publify_core/testing_support/factories/sidebars.rb +10 -0
- data/lib/publify_core/testing_support/factories/tags.rb +9 -0
- data/lib/publify_core/testing_support/factories/trackbacks.rb +13 -0
- data/lib/publify_core/testing_support/factories/users.rb +43 -0
- data/lib/publify_core/version.rb +1 -1
- data/lib/publify_core.rb +3 -3
- data/lib/publify_textfilter_markdown.rb +8 -9
- data/lib/publify_textfilter_markdown_smartquotes.rb +20 -0
- data/lib/publify_textfilter_twitterfilter.rb +36 -18
- data/lib/sidebar_field.rb +2 -2
- data/lib/sidebar_registry.rb +0 -12
- data/lib/text_filter_plugin.rb +23 -30
- metadata +213 -105
- data/lib/publify_core/testing_support/factories.rb +0 -240
- data/lib/publify_textfilter_textile.rb +0 -24
- data/lib/tasks/i18n.rake +0 -9
- /data/app/views/admin/{content → articles}/autosave.js.erb +0 -0
- /data/app/views/admin/{content → articles}/edit.html.erb +0 -0
- /data/app/views/admin/{content → articles}/index.js.erb +0 -0
- /data/app/views/admin/{content → articles}/new.html.erb +0 -0
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "text_filter_plugin"
|
4
|
+
require "html/pipeline"
|
5
|
+
require "html/pipeline/hashtag/hashtag_filter"
|
4
6
|
|
5
7
|
class PublifyApp
|
6
8
|
class Textfilter
|
@@ -8,31 +10,47 @@ class PublifyApp
|
|
8
10
|
plugin_display_name "HTML Filter"
|
9
11
|
plugin_description "Strip HTML tags"
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
class TwitterHashtagFilter < HTML::Pipeline::HashtagFilter
|
14
|
+
def initialize(text)
|
15
|
+
super(text,
|
16
|
+
tag_url: "https://twitter.com/search?q=%%23%<tag>s&src=tren&mode=realtime",
|
17
|
+
tag_link_attr: "")
|
16
18
|
end
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
text
|
20
|
-
|
21
|
-
|
22
|
-
search_item = URI.encode_www_form_component(item)
|
21
|
+
class TwitterMentionFilter < HTML::Pipeline::MentionFilter
|
22
|
+
def initialize(text)
|
23
|
+
super(text, base_url: "https://twitter.com")
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
# Override base mentions finder, treating @mention just like any other @foo.
|
27
|
+
def self.mentioned_logins_in(text, username_pattern = UsernamePattern)
|
28
|
+
text.gsub MentionPatterns[username_pattern] do |match|
|
29
|
+
login = Regexp.last_match(1)
|
30
|
+
yield match, login, false
|
31
|
+
end
|
26
32
|
end
|
27
33
|
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
34
|
+
# Override base link creator, removing the class
|
35
|
+
def link_to_mentioned_user(login)
|
36
|
+
result[:mentioned_usernames] |= [login]
|
37
|
+
|
38
|
+
url = base_url.dup
|
39
|
+
url << "/" unless %r{[/~]\z}.match?(url)
|
40
|
+
|
41
|
+
"<a href='#{url << login}'>" \
|
42
|
+
"@#{login}" \
|
43
|
+
"</a>"
|
33
44
|
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.filtertext(text)
|
48
|
+
# First, autolink
|
49
|
+
helper = PublifyCore::ContentTextHelpers.new
|
50
|
+
text = helper.auto_link(text)
|
34
51
|
|
35
|
-
text
|
52
|
+
text = TwitterHashtagFilter.new(text).call
|
53
|
+
TwitterMentionFilter.new(text).call.to_s
|
36
54
|
end
|
37
55
|
end
|
38
56
|
end
|
data/lib/sidebar_field.rb
CHANGED
@@ -51,8 +51,8 @@ class SidebarField
|
|
51
51
|
|
52
52
|
class TextAreaField < self
|
53
53
|
def input_html(sidebar)
|
54
|
-
html_options = { "rows" => "10", "class" => "form-control" }
|
55
|
-
update(options.stringify_keys)
|
54
|
+
html_options = { "rows" => "10", "class" => "form-control" }
|
55
|
+
.update(options.stringify_keys)
|
56
56
|
text_area_tag(input_name(sidebar), current_value(sidebar), html_options)
|
57
57
|
end
|
58
58
|
end
|
data/lib/sidebar_registry.rb
CHANGED
@@ -14,18 +14,6 @@ class SidebarRegistry
|
|
14
14
|
registered_sidebars.sort
|
15
15
|
end
|
16
16
|
|
17
|
-
def register_sidebar_directory(plugins_root, paths)
|
18
|
-
separator = plugins_root.include?("/") ? "/" : '\\'
|
19
|
-
|
20
|
-
Dir.glob(File.join(plugins_root, "*_sidebar")).select do |file|
|
21
|
-
plugin_name = file.split(separator).last
|
22
|
-
register_sidebar plugin_name.classify
|
23
|
-
# TODO: Move Sidebars to app/models, and views to app/views so this can
|
24
|
-
# be simplified.
|
25
|
-
paths << File.join(plugins_root, plugin_name, "lib")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
17
|
private
|
30
18
|
|
31
19
|
def registered_sidebars
|
data/lib/text_filter_plugin.rb
CHANGED
@@ -13,7 +13,7 @@ class TextFilterPlugin
|
|
13
13
|
def self.inherited(sub)
|
14
14
|
super
|
15
15
|
|
16
|
-
if sub.to_s.start_with?("Plugin", "PublifyApp::Textfilter")
|
16
|
+
if sub.to_s.start_with?("Plugin", "PublifyTextfilter", "PublifyApp::Textfilter")
|
17
17
|
name = sub.short_name
|
18
18
|
@@filter_map[name] = sub
|
19
19
|
end
|
@@ -43,7 +43,28 @@ class TextFilterPlugin
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.macro_filters
|
46
|
-
|
46
|
+
macro_pre_filters + macro_post_filters
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.macro_pre_filters
|
50
|
+
available_filter_types["macropre"]
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.macro_post_filters
|
54
|
+
available_filter_types["macropost"]
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.expand_filter_list(filter_list)
|
58
|
+
filter_list.flat_map do |key|
|
59
|
+
case key
|
60
|
+
when :macropost
|
61
|
+
macro_post_filters
|
62
|
+
when :macropre
|
63
|
+
macro_pre_filters
|
64
|
+
else
|
65
|
+
filter_map[key.to_s]
|
66
|
+
end
|
67
|
+
end.compact
|
47
68
|
end
|
48
69
|
|
49
70
|
plugin_display_name "Unknown Text Filter"
|
@@ -153,31 +174,3 @@ class TextFilterPlugin::Markup < TextFilterPlugin
|
|
153
174
|
"markup"
|
154
175
|
end
|
155
176
|
end
|
156
|
-
|
157
|
-
class PublifyApp
|
158
|
-
class Textfilter
|
159
|
-
class MacroPost < TextFilterPlugin
|
160
|
-
plugin_display_name "MacroPost"
|
161
|
-
plugin_description "Macro expansion meta-filter (post-markup)"
|
162
|
-
|
163
|
-
def self.filtertext(text)
|
164
|
-
macros = TextFilterPlugin.available_filter_types["macropost"]
|
165
|
-
macros.reduce(text) do |new_text, macro|
|
166
|
-
macro.filtertext(new_text)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
class MacroPre < TextFilterPlugin
|
172
|
-
plugin_display_name "MacroPre"
|
173
|
-
plugin_description "Macro expansion meta-filter (pre-markup)"
|
174
|
-
|
175
|
-
def self.filtertext(text)
|
176
|
-
macros = TextFilterPlugin.available_filter_types["macropre"]
|
177
|
-
macros.reduce(text) do |new_text, macro|
|
178
|
-
macro.filtertext(new_text)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|