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.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -18
  3. data/app/assets/javascripts/lang/ar_AR.js +17 -0
  4. data/app/controllers/admin/{content_controller.rb → articles_controller.rb} +24 -24
  5. data/app/controllers/admin/dashboard_controller.rb +3 -3
  6. data/app/controllers/admin/feedback_controller.rb +23 -23
  7. data/app/controllers/admin/pages_controller.rb +2 -2
  8. data/app/controllers/admin/post_types_controller.rb +10 -4
  9. data/app/controllers/admin/redirects_controller.rb +10 -6
  10. data/app/controllers/admin/resources_controller.rb +2 -2
  11. data/app/controllers/admin/sidebar_controller.rb +2 -2
  12. data/app/controllers/admin/tags_controller.rb +5 -3
  13. data/app/controllers/admin/themes_controller.rb +1 -2
  14. data/app/controllers/admin/users_controller.rb +5 -3
  15. data/app/controllers/articles_controller.rb +5 -5
  16. data/app/controllers/authors_controller.rb +2 -2
  17. data/app/controllers/base_controller.rb +0 -3
  18. data/app/controllers/feedback_controller.rb +3 -3
  19. data/app/controllers/tags_controller.rb +3 -3
  20. data/app/helpers/authors_helper.rb +1 -1
  21. data/app/helpers/base_helper.rb +6 -6
  22. data/app/models/ability.rb +1 -1
  23. data/app/models/archives_sidebar.rb +3 -3
  24. data/app/models/article.rb +13 -13
  25. data/app/models/blog.rb +3 -6
  26. data/app/models/content.rb +1 -3
  27. data/app/models/content_base.rb +2 -13
  28. data/app/models/feedback.rb +1 -2
  29. data/app/models/meta_sidebar.rb +1 -1
  30. data/app/models/note.rb +2 -2
  31. data/app/models/redirect.rb +0 -1
  32. data/app/models/sidebar.rb +1 -1
  33. data/app/models/static_sidebar.rb +1 -1
  34. data/app/models/tag.rb +7 -8
  35. data/app/models/tag_sidebar.rb +3 -3
  36. data/app/models/text_filter.rb +17 -43
  37. data/app/models/user.rb +2 -2
  38. data/app/services/title_builder.rb +4 -4
  39. data/app/views/admin/{content → articles}/_article_list.html.erb +3 -3
  40. data/app/views/admin/{content → articles}/_form.html.erb +11 -1
  41. data/app/views/admin/{content → articles}/index.html.erb +1 -1
  42. data/app/views/admin/dashboard/_drafts.html.erb +2 -2
  43. data/app/views/admin/dashboard/_overview.html.erb +1 -1
  44. data/app/views/admin/dashboard/_welcome.html.erb +4 -4
  45. data/app/views/admin/dashboard/index.html.erb +0 -7
  46. data/app/views/admin/feedback/article.html.erb +12 -6
  47. data/app/views/admin/feedback/edit.html.erb +14 -2
  48. data/app/views/admin/feedback/index.html.erb +6 -7
  49. data/app/views/admin/pages/_form.html.erb +13 -14
  50. data/app/views/admin/seo/show.html.erb +12 -1
  51. data/app/views/admin/shared/_menu.html.erb +5 -4
  52. data/app/views/admin/tags/_index_and_form.html.erb +2 -1
  53. data/app/views/articles/_comment_errors.html.erb +11 -1
  54. data/app/views/articles/read.html.erb +1 -1
  55. data/app/views/layouts/administration.html.erb +9 -17
  56. data/config/i18n-tasks.yml +8 -1
  57. data/config/initializers/devise.rb +1 -1
  58. data/config/locales/ar.yml +885 -0
  59. data/config/locales/da.yml +12 -12
  60. data/config/locales/de.yml +12 -12
  61. data/config/locales/en.yml +12 -12
  62. data/config/locales/es-MX.yml +12 -12
  63. data/config/locales/fr.yml +12 -12
  64. data/config/locales/he.yml +12 -12
  65. data/config/locales/it.yml +12 -12
  66. data/config/locales/ja.yml +13 -13
  67. data/config/locales/lt.yml +12 -12
  68. data/config/locales/{nb-NO.yml → nb.yml} +13 -13
  69. data/config/locales/nl.yml +13 -13
  70. data/config/locales/pl.yml +12 -12
  71. data/config/locales/pt-BR.yml +12 -12
  72. data/config/locales/ro.yml +12 -12
  73. data/config/locales/ru.yml +13 -13
  74. data/config/locales/sidebars.ar.yml +20 -0
  75. data/config/locales/{sidebars.nb-NO.yml → sidebars.nb.yml} +1 -1
  76. data/config/locales/zh-CN.yml +12 -12
  77. data/config/locales/zh-TW.yml +12 -12
  78. data/config/routes.rb +2 -2
  79. data/db/migrate/20150807134129_simplify_redirect_relations.rb +1 -0
  80. data/db/migrate/20150808052637_add_blog_ids.rb +3 -1
  81. data/db/migrate/20160605103918_replace_profile_id_with_string.rb +1 -0
  82. data/db/migrate/20160701062604_add_blog_id_to_resources.rb +2 -0
  83. data/db/migrate/20190208152646_move_text_filter_to_name.rb +17 -17
  84. data/db/migrate/20221007091049_remove_table_sitealizer.rb +19 -0
  85. data/db/migrate/20221010092846_remove_page_caches_table.rb +15 -0
  86. data/db/migrate/20221012163214_remove_itunes_fields_from_resources.rb +14 -0
  87. data/db/seeds.rb +0 -4
  88. data/lib/publify_core/content_text_helpers.rb +11 -0
  89. data/lib/publify_core/lang.rb +1 -1
  90. data/lib/publify_core/testing_support/factories/articles.rb +55 -0
  91. data/lib/publify_core/testing_support/factories/blogs.rb +24 -0
  92. data/lib/publify_core/testing_support/factories/comments.rb +40 -0
  93. data/lib/publify_core/testing_support/factories/contents.rb +7 -0
  94. data/lib/publify_core/testing_support/factories/notes.rb +17 -0
  95. data/lib/publify_core/testing_support/factories/pages.rb +13 -0
  96. data/lib/publify_core/testing_support/factories/post_types.rb +8 -0
  97. data/lib/publify_core/testing_support/factories/redirects.rb +9 -0
  98. data/lib/publify_core/testing_support/factories/resources.rb +16 -0
  99. data/lib/publify_core/testing_support/factories/sequences.rb +12 -0
  100. data/lib/publify_core/testing_support/factories/sidebars.rb +10 -0
  101. data/lib/publify_core/testing_support/factories/tags.rb +9 -0
  102. data/lib/publify_core/testing_support/factories/trackbacks.rb +13 -0
  103. data/lib/publify_core/testing_support/factories/users.rb +43 -0
  104. data/lib/publify_core/version.rb +1 -1
  105. data/lib/publify_core.rb +3 -3
  106. data/lib/publify_textfilter_markdown.rb +8 -9
  107. data/lib/publify_textfilter_markdown_smartquotes.rb +20 -0
  108. data/lib/publify_textfilter_twitterfilter.rb +36 -18
  109. data/lib/sidebar_field.rb +2 -2
  110. data/lib/sidebar_registry.rb +0 -12
  111. data/lib/text_filter_plugin.rb +23 -30
  112. metadata +213 -105
  113. data/lib/publify_core/testing_support/factories.rb +0 -240
  114. data/lib/publify_textfilter_textile.rb +0 -24
  115. data/lib/tasks/i18n.rake +0 -9
  116. /data/app/views/admin/{content → articles}/autosave.js.erb +0 -0
  117. /data/app/views/admin/{content → articles}/edit.html.erb +0 -0
  118. /data/app/views/admin/{content → articles}/index.js.erb +0 -0
  119. /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
- def self.filtertext(text)
12
- # First, autolink
13
- text = text.to_s
14
- URI.extract(text, %w(http https mailto gopher)) do |item|
15
- text = text.gsub(item, "<a href='#{item}'>#{item}</a>")
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
- # hashtags
19
- text.split.grep(/^#\w+/) do |item|
20
- # strip_html because Ruby considers "#prouddad</p>" as a word
21
- item = item.strip_html
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
- uri = "https://twitter.com/search?q=#{search_item}&src=tren&mode=realtime"
25
- text = text.gsub(item, "<a href='#{uri}'>#{item}</a>")
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
- # @mention
29
- text.to_s.split.grep(/@\w+/) do |item|
30
- item = item.strip_html
31
- uri = html_escape("https://twitter.com/#{item.delete("@")}")
32
- text = text.gsub(item, "<a href='#{uri}'>#{item}</a>")
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
@@ -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
@@ -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
- available_filters.select { |filter| TextFilterPlugin::Macro > filter }
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