From b9d5c01abd098395d97319874310c1f43c124de0 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Fri, 29 Sep 2023 14:31:57 +0200 Subject: [PATCH 1/6] Fix file name for PublifyTextfilter::MarkdownSmartquotes and its specs --- lib/publify_core.rb | 2 +- .../markdown_smartquotes.rb} | 0 .../markdown_smartquotes_spec.rb} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename lib/{publify_textfilter_markdown_smartquotes.rb => publify_textfilter/markdown_smartquotes.rb} (100%) rename spec/lib/{publify_textfilter_markdown_smartquotes_spec.rb => publify_textfilter/markdown_smartquotes_spec.rb} (100%) diff --git a/lib/publify_core.rb b/lib/publify_core.rb index 4b77a4cc..132cffef 100644 --- a/lib/publify_core.rb +++ b/lib/publify_core.rb @@ -22,7 +22,7 @@ require "publify_guid" require "publify_textfilter_none" require "publify_textfilter_markdown" -require "publify_textfilter_markdown_smartquotes" +require "publify_textfilter/markdown_smartquotes" require "publify_textfilter_smartypants" require "publify_textfilter_twitterfilter" require "publify_time" diff --git a/lib/publify_textfilter_markdown_smartquotes.rb b/lib/publify_textfilter/markdown_smartquotes.rb similarity index 100% rename from lib/publify_textfilter_markdown_smartquotes.rb rename to lib/publify_textfilter/markdown_smartquotes.rb diff --git a/spec/lib/publify_textfilter_markdown_smartquotes_spec.rb b/spec/lib/publify_textfilter/markdown_smartquotes_spec.rb similarity index 100% rename from spec/lib/publify_textfilter_markdown_smartquotes_spec.rb rename to spec/lib/publify_textfilter/markdown_smartquotes_spec.rb From fa0e0a9bb334b9bb8e98bc8df5671de03fc1b893 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Fri, 29 Sep 2023 14:39:17 +0200 Subject: [PATCH 2/6] Move classes in PublifyApp::Textfilter namespace to PublifyTextfilter --- app/models/note.rb | 2 +- app/views/notes/show_in_reply.html.erb | 2 +- .../markdown_smartquotes.rb | 2 +- lib/publify_textfilter_markdown.rb | 87 +++++++++---------- lib/publify_textfilter_none.rb | 14 ++- lib/publify_textfilter_smartypants.rb | 14 ++- lib/publify_textfilter_twitterfilter.rb | 74 ++++++++-------- lib/text_filter_plugin.rb | 2 +- spec/lib/publify_textfilter_markdown_spec.rb | 2 +- .../publify_textfilter_smartypants_spec.rb | 2 +- .../publify_textfilter_twitterfilter_spec.rb | 2 +- spec/lib/text_filter_plugin_spec.rb | 12 +-- 12 files changed, 103 insertions(+), 112 deletions(-) diff --git a/app/models/note.rb b/app/models/note.rb index 8cd84193..baec940e 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -44,7 +44,7 @@ def tags end def html_postprocess(field, html) - super(field, PublifyApp::Textfilter::Twitterfilter.filtertext(html)) + super(field, PublifyTextfilter::Twitterfilter.filtertext(html)) end def truncate(message, length) diff --git a/app/views/notes/show_in_reply.html.erb b/app/views/notes/show_in_reply.html.erb index b2287f9b..395a2c86 100644 --- a/app/views/notes/show_in_reply.html.erb +++ b/app/views/notes/show_in_reply.html.erb @@ -5,7 +5,7 @@ <%= image_tag(@reply['user']['profile_image_url'], class: 'alignleft', alt: @reply['user']['name']) %> <% end %> <%= get_reply_context_url(@reply) %> -

<%= nofollowify_links(PublifyApp::Textfilter::Twitterfilter.filtertext(@reply['text'])) %>

+

<%= nofollowify_links(PublifyTextfilter::Twitterfilter.filtertext(@reply['text'])) %>

<%= get_reply_context_twitter_link(@reply) %> diff --git a/lib/publify_textfilter/markdown_smartquotes.rb b/lib/publify_textfilter/markdown_smartquotes.rb index a808bdbb..fcf8b72e 100644 --- a/lib/publify_textfilter/markdown_smartquotes.rb +++ b/lib/publify_textfilter/markdown_smartquotes.rb @@ -4,7 +4,7 @@ require "publify_textfilter_markdown" module PublifyTextfilter - class MarkdownSmartquotes < PublifyApp::Textfilter::Markdown + class MarkdownSmartquotes < PublifyTextfilter::Markdown plugin_display_name "Markdown with smart quotes" plugin_description "Markdown markup language from" \ ' Daring Fireball' \ diff --git a/lib/publify_textfilter_markdown.rb b/lib/publify_textfilter_markdown.rb index a44d493e..efadb4e5 100644 --- a/lib/publify_textfilter_markdown.rb +++ b/lib/publify_textfilter_markdown.rb @@ -3,54 +3,51 @@ require "text_filter_plugin" require "commonmarker" -# TODO: Move to a different namespace -class PublifyApp - class Textfilter - class Markdown < TextFilterPlugin::Markup - plugin_display_name "Markdown" - plugin_description "Markdown markup language from" \ - ' Daring Fireball' +module PublifyTextfilter + class Markdown < TextFilterPlugin::Markup + plugin_display_name "Markdown" + plugin_description "Markdown markup language from" \ + ' Daring Fireball' - def self.help_text - <<~TXT - [Markdown](http://daringfireball.net/projects/markdown/) is a simple - text-to-HTML converter that turns common text idioms into HTML. The - [full syntax](http://daringfireball.net/projects/markdown/syntax) is - available from the author's site, but here's a short summary: + def self.help_text + <<~TXT + [Markdown](http://daringfireball.net/projects/markdown/) is a simple + text-to-HTML converter that turns common text idioms into HTML. The + [full syntax](http://daringfireball.net/projects/markdown/syntax) is + available from the author's site, but here's a short summary: - * **Paragraphs**: Start a new paragraph by skipping a line. - * **Italics**: Put text in *italics* by enclosing it in either * or - _: `*italics*` turns into *italics*. - * **Bold**: Put text in **bold** by enclosing it in two *s: - `**bold**` turns into **bold**. - * **Pre-formatted text**: Enclosing a short block of text in - backquotes (`) displays it in a monospaced font and converts HTML - metacharacters so they display correctly. Example: - ```` displays as ``. Also, - any paragraph indented 4 or more spaces is treated as pre-formatted - text. - * **Block quotes**: Any paragraph (or line) that starts with a `>` is - treated as a blockquote. - * **Hyperlinks**: You can create links like this: - `[amazon's web site](http://www.amazon.com)`. That produces - "[amazon's web site](http://www.amazon.com)". - * **Lists**: You can create numbered or bulleted lists by ending a - paragraph with a colon (:), skipping a line, and then using asterisks - (*, for bullets) or numbers (for numbered lists). See the - [Markdown syntax page](http://daringfireball.net/projects/markdown/syntax) - for examples. - * **Raw HTML**: Markdown will pass raw HTML through unchanged, so you - can use HTML's syntax whenever Markdown doesn't provide a reasonable - alternative. - TXT - end + * **Paragraphs**: Start a new paragraph by skipping a line. + * **Italics**: Put text in *italics* by enclosing it in either * or + _: `*italics*` turns into *italics*. + * **Bold**: Put text in **bold** by enclosing it in two *s: + `**bold**` turns into **bold**. + * **Pre-formatted text**: Enclosing a short block of text in + backquotes (`) displays it in a monospaced font and converts HTML + metacharacters so they display correctly. Example: + ```` displays as ``. Also, + any paragraph indented 4 or more spaces is treated as pre-formatted + text. + * **Block quotes**: Any paragraph (or line) that starts with a `>` is + treated as a blockquote. + * **Hyperlinks**: You can create links like this: + `[amazon's web site](http://www.amazon.com)`. That produces + "[amazon's web site](http://www.amazon.com)". + * **Lists**: You can create numbered or bulleted lists by ending a + paragraph with a colon (:), skipping a line, and then using asterisks + (*, for bullets) or numbers (for numbered lists). See the + [Markdown syntax page](http://daringfireball.net/projects/markdown/syntax) + for examples. + * **Raw HTML**: Markdown will pass raw HTML through unchanged, so you + can use HTML's syntax whenever Markdown doesn't provide a reasonable + alternative. + TXT + end - def self.filtertext(text) - # FIXME: Workaround for not being interpreted as an HTML tag. - escaped_macros = text.gsub(%r{( not being interpreted as an HTML tag. + escaped_macros = text.gsub(%r{(s&src=tren&mode=realtime", - tag_link_attr: "") - end +module PublifyTextfilter + class Twitterfilter < TextFilterPlugin::PostProcess + plugin_display_name "HTML Filter" + plugin_description "Strip HTML tags" + + class TwitterHashtagFilter < HTML::Pipeline::HashtagFilter + def initialize(text) + super(text, + tag_url: "https://twitter.com/search?q=%%23%s&src=tren&mode=realtime", + tag_link_attr: "") end + end - class TwitterMentionFilter < HTML::Pipeline::MentionFilter - def initialize(text) - super(text, base_url: "https://twitter.com") - end + class TwitterMentionFilter < HTML::Pipeline::MentionFilter + def initialize(text) + super(text, base_url: "https://twitter.com") + end - # Override base mentions finder, treating @mention just like any other @foo. - def self.mentioned_logins_in(text, username_pattern = UsernamePattern) - text.gsub MentionPatterns[username_pattern] do |match| - login = Regexp.last_match(1) - yield match, login, false - end + # Override base mentions finder, treating @mention just like any other @foo. + def self.mentioned_logins_in(text, username_pattern = UsernamePattern) + text.gsub MentionPatterns[username_pattern] do |match| + login = Regexp.last_match(1) + yield match, login, false end + end - # Override base link creator, removing the class - def link_to_mentioned_user(login) - result[:mentioned_usernames] |= [login] + # Override base link creator, removing the class + def link_to_mentioned_user(login) + result[:mentioned_usernames] |= [login] - url = base_url.dup - url << "/" unless %r{[/~]\z}.match?(url) + url = base_url.dup + url << "/" unless %r{[/~]\z}.match?(url) - "" \ - "@#{login}" \ - "" - end + "" \ + "@#{login}" \ + "" end + end - def self.filtertext(text) - # First, autolink - helper = PublifyCore::ContentTextHelpers.new - text = helper.auto_link(text) + def self.filtertext(text) + # First, autolink + helper = PublifyCore::ContentTextHelpers.new + text = helper.auto_link(text) - text = TwitterHashtagFilter.new(text).call - TwitterMentionFilter.new(text).call.to_s - end + text = TwitterHashtagFilter.new(text).call + TwitterMentionFilter.new(text).call.to_s end end end diff --git a/lib/text_filter_plugin.rb b/lib/text_filter_plugin.rb index 9f1b7529..d18ed316 100644 --- a/lib/text_filter_plugin.rb +++ b/lib/text_filter_plugin.rb @@ -13,7 +13,7 @@ class << self def self.inherited(sub) super - if sub.to_s.start_with?("Plugin", "PublifyTextfilter", "PublifyApp::Textfilter") + if sub.to_s.start_with?("Plugin", "PublifyTextfilter") name = sub.short_name @@filter_map[name] = sub end diff --git a/spec/lib/publify_textfilter_markdown_spec.rb b/spec/lib/publify_textfilter_markdown_spec.rb index abaf23c1..a06af912 100644 --- a/spec/lib/publify_textfilter_markdown_spec.rb +++ b/spec/lib/publify_textfilter_markdown_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe PublifyApp::Textfilter::Markdown do +RSpec.describe PublifyTextfilter::Markdown do def filter_text(text) described_class.filtertext(text) end diff --git a/spec/lib/publify_textfilter_smartypants_spec.rb b/spec/lib/publify_textfilter_smartypants_spec.rb index b920f6e7..552bdba8 100644 --- a/spec/lib/publify_textfilter_smartypants_spec.rb +++ b/spec/lib/publify_textfilter_smartypants_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe PublifyApp::Textfilter::Smartypants do +RSpec.describe PublifyTextfilter::Smartypants do describe "#filtertext" do it "applies smartypants processing to the supplied text" do text = described_class.filtertext('"foo"') diff --git a/spec/lib/publify_textfilter_twitterfilter_spec.rb b/spec/lib/publify_textfilter_twitterfilter_spec.rb index 07384a93..45cd844a 100644 --- a/spec/lib/publify_textfilter_twitterfilter_spec.rb +++ b/spec/lib/publify_textfilter_twitterfilter_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe PublifyApp::Textfilter::Twitterfilter do +RSpec.describe PublifyTextfilter::Twitterfilter do describe ".filtertext" do it "replaces a hashtag with a proper URL to Twitter search" do text = described_class.filtertext("A test tweet with a #hashtag") diff --git a/spec/lib/text_filter_plugin_spec.rb b/spec/lib/text_filter_plugin_spec.rb index 765d4fff..4cb4550c 100644 --- a/spec/lib/text_filter_plugin_spec.rb +++ b/spec/lib/text_filter_plugin_spec.rb @@ -6,9 +6,9 @@ describe ".available_filters" do subject { described_class.available_filters } - it { is_expected.to include(PublifyApp::Textfilter::Markdown) } - it { is_expected.to include(PublifyApp::Textfilter::Smartypants) } - it { is_expected.to include(PublifyApp::Textfilter::Twitterfilter) } + it { is_expected.to include(PublifyTextfilter::Markdown) } + it { is_expected.to include(PublifyTextfilter::Smartypants) } + it { is_expected.to include(PublifyTextfilter::Twitterfilter) } it { is_expected.not_to include(TextFilterPlugin::Markup) } it { is_expected.not_to include(TextFilterPlugin::Macro) } it { is_expected.not_to include(TextFilterPlugin::MacroPre) } @@ -18,9 +18,9 @@ describe ".macro_filters" do subject { described_class.macro_filters } - it { is_expected.not_to include(PublifyApp::Textfilter::Markdown) } - it { is_expected.not_to include(PublifyApp::Textfilter::Smartypants) } - it { is_expected.not_to include(PublifyApp::Textfilter::Twitterfilter) } + it { is_expected.not_to include(PublifyTextfilter::Markdown) } + it { is_expected.not_to include(PublifyTextfilter::Smartypants) } + it { is_expected.not_to include(PublifyTextfilter::Twitterfilter) } it { is_expected.not_to include(TextFilterPlugin::Markup) } it { is_expected.not_to include(TextFilterPlugin::Macro) } it { is_expected.not_to include(TextFilterPlugin::MacroPre) } From 315b36b206624437102341bb678a898530abe64b Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Fri, 29 Sep 2023 14:42:52 +0200 Subject: [PATCH 3/6] Fix file names for PublifyTextfilter classes and their specs --- lib/publify_core.rb | 8 ++++---- .../markdown.rb} | 0 lib/publify_textfilter/markdown_smartquotes.rb | 2 +- .../none.rb} | 0 .../smartypants.rb} | 0 .../twitterfilter.rb} | 0 .../markdown_spec.rb} | 0 .../smartypants_spec.rb} | 0 .../twitterfilter_spec.rb} | 0 9 files changed, 5 insertions(+), 5 deletions(-) rename lib/{publify_textfilter_markdown.rb => publify_textfilter/markdown.rb} (100%) rename lib/{publify_textfilter_none.rb => publify_textfilter/none.rb} (100%) rename lib/{publify_textfilter_smartypants.rb => publify_textfilter/smartypants.rb} (100%) rename lib/{publify_textfilter_twitterfilter.rb => publify_textfilter/twitterfilter.rb} (100%) rename spec/lib/{publify_textfilter_markdown_spec.rb => publify_textfilter/markdown_spec.rb} (100%) rename spec/lib/{publify_textfilter_smartypants_spec.rb => publify_textfilter/smartypants_spec.rb} (100%) rename spec/lib/{publify_textfilter_twitterfilter_spec.rb => publify_textfilter/twitterfilter_spec.rb} (100%) diff --git a/lib/publify_core.rb b/lib/publify_core.rb index 132cffef..9e3045d9 100644 --- a/lib/publify_core.rb +++ b/lib/publify_core.rb @@ -20,11 +20,11 @@ require "email_notify" require "publify_guid" -require "publify_textfilter_none" -require "publify_textfilter_markdown" +require "publify_textfilter/none" +require "publify_textfilter/markdown" require "publify_textfilter/markdown_smartquotes" -require "publify_textfilter_smartypants" -require "publify_textfilter_twitterfilter" +require "publify_textfilter/smartypants" +require "publify_textfilter/twitterfilter" require "publify_time" require "sidebar_registry" require "spam_protection" diff --git a/lib/publify_textfilter_markdown.rb b/lib/publify_textfilter/markdown.rb similarity index 100% rename from lib/publify_textfilter_markdown.rb rename to lib/publify_textfilter/markdown.rb diff --git a/lib/publify_textfilter/markdown_smartquotes.rb b/lib/publify_textfilter/markdown_smartquotes.rb index fcf8b72e..6c24dade 100644 --- a/lib/publify_textfilter/markdown_smartquotes.rb +++ b/lib/publify_textfilter/markdown_smartquotes.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "text_filter_plugin" -require "publify_textfilter_markdown" +require "publify_textfilter/markdown" module PublifyTextfilter class MarkdownSmartquotes < PublifyTextfilter::Markdown diff --git a/lib/publify_textfilter_none.rb b/lib/publify_textfilter/none.rb similarity index 100% rename from lib/publify_textfilter_none.rb rename to lib/publify_textfilter/none.rb diff --git a/lib/publify_textfilter_smartypants.rb b/lib/publify_textfilter/smartypants.rb similarity index 100% rename from lib/publify_textfilter_smartypants.rb rename to lib/publify_textfilter/smartypants.rb diff --git a/lib/publify_textfilter_twitterfilter.rb b/lib/publify_textfilter/twitterfilter.rb similarity index 100% rename from lib/publify_textfilter_twitterfilter.rb rename to lib/publify_textfilter/twitterfilter.rb diff --git a/spec/lib/publify_textfilter_markdown_spec.rb b/spec/lib/publify_textfilter/markdown_spec.rb similarity index 100% rename from spec/lib/publify_textfilter_markdown_spec.rb rename to spec/lib/publify_textfilter/markdown_spec.rb diff --git a/spec/lib/publify_textfilter_smartypants_spec.rb b/spec/lib/publify_textfilter/smartypants_spec.rb similarity index 100% rename from spec/lib/publify_textfilter_smartypants_spec.rb rename to spec/lib/publify_textfilter/smartypants_spec.rb diff --git a/spec/lib/publify_textfilter_twitterfilter_spec.rb b/spec/lib/publify_textfilter/twitterfilter_spec.rb similarity index 100% rename from spec/lib/publify_textfilter_twitterfilter_spec.rb rename to spec/lib/publify_textfilter/twitterfilter_spec.rb From 9fb8b1650f59b80fb9f4612d385226e20e6cd384 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Fri, 29 Sep 2023 21:44:30 +0200 Subject: [PATCH 4/6] Rename PublifyTextfilter to PublifyCore::TextFilter --- app/models/note.rb | 2 +- app/views/notes/show_in_reply.html.erb | 2 +- lib/publify_core.rb | 10 +++++----- .../text_filter}/markdown.rb | 2 +- .../text_filter}/markdown_smartquotes.rb | 6 +++--- .../text_filter}/none.rb | 2 +- .../text_filter}/smartypants.rb | 2 +- .../text_filter}/twitterfilter.rb | 2 +- lib/text_filter_plugin.rb | 2 +- spec/lib/text_filter_plugin_spec.rb | 12 ++++++------ .../text_filter}/markdown_smartquotes_spec.rb | 2 +- .../text_filter}/markdown_spec.rb | 2 +- .../text_filter}/smartypants_spec.rb | 2 +- .../text_filter}/twitterfilter_spec.rb | 2 +- 14 files changed, 25 insertions(+), 25 deletions(-) rename lib/{publify_textfilter => publify_core/text_filter}/markdown.rb (98%) rename lib/{publify_textfilter => publify_core/text_filter}/markdown_smartquotes.rb (82%) rename lib/{publify_textfilter => publify_core/text_filter}/none.rb (88%) rename lib/{publify_textfilter => publify_core/text_filter}/smartypants.rb (90%) rename lib/{publify_textfilter => publify_core/text_filter}/twitterfilter.rb (98%) rename spec/{lib/publify_textfilter => publify_core/text_filter}/markdown_smartquotes_spec.rb (92%) rename spec/{lib/publify_textfilter => publify_core/text_filter}/markdown_spec.rb (93%) rename spec/{lib/publify_textfilter => publify_core/text_filter}/smartypants_spec.rb (82%) rename spec/{lib/publify_textfilter => publify_core/text_filter}/twitterfilter_spec.rb (96%) diff --git a/app/models/note.rb b/app/models/note.rb index baec940e..14c59abc 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -44,7 +44,7 @@ def tags end def html_postprocess(field, html) - super(field, PublifyTextfilter::Twitterfilter.filtertext(html)) + super(field, PublifyCore::TextFilter::Twitterfilter.filtertext(html)) end def truncate(message, length) diff --git a/app/views/notes/show_in_reply.html.erb b/app/views/notes/show_in_reply.html.erb index 395a2c86..84585258 100644 --- a/app/views/notes/show_in_reply.html.erb +++ b/app/views/notes/show_in_reply.html.erb @@ -5,7 +5,7 @@ <%= image_tag(@reply['user']['profile_image_url'], class: 'alignleft', alt: @reply['user']['name']) %> <% end %> <%= get_reply_context_url(@reply) %> -

<%= nofollowify_links(PublifyTextfilter::Twitterfilter.filtertext(@reply['text'])) %>

+

<%= nofollowify_links(PublifyCore::TextFilter::Twitterfilter.filtertext(@reply['text'])) %>

<%= get_reply_context_twitter_link(@reply) %> diff --git a/lib/publify_core.rb b/lib/publify_core.rb index 9e3045d9..0aad440c 100644 --- a/lib/publify_core.rb +++ b/lib/publify_core.rb @@ -8,6 +8,11 @@ require "publify_core/engine" require "publify_core/lang" require "publify_core/content_text_helpers" +require "publify_core/text_filter/none" +require "publify_core/text_filter/markdown" +require "publify_core/text_filter/markdown_smartquotes" +require "publify_core/text_filter/smartypants" +require "publify_core/text_filter/twitterfilter" require "carrierwave" require "jquery-rails" @@ -20,11 +25,6 @@ require "email_notify" require "publify_guid" -require "publify_textfilter/none" -require "publify_textfilter/markdown" -require "publify_textfilter/markdown_smartquotes" -require "publify_textfilter/smartypants" -require "publify_textfilter/twitterfilter" require "publify_time" require "sidebar_registry" require "spam_protection" diff --git a/lib/publify_textfilter/markdown.rb b/lib/publify_core/text_filter/markdown.rb similarity index 98% rename from lib/publify_textfilter/markdown.rb rename to lib/publify_core/text_filter/markdown.rb index efadb4e5..45503d65 100644 --- a/lib/publify_textfilter/markdown.rb +++ b/lib/publify_core/text_filter/markdown.rb @@ -3,7 +3,7 @@ require "text_filter_plugin" require "commonmarker" -module PublifyTextfilter +module PublifyCore::TextFilter class Markdown < TextFilterPlugin::Markup plugin_display_name "Markdown" plugin_description "Markdown markup language from" \ diff --git a/lib/publify_textfilter/markdown_smartquotes.rb b/lib/publify_core/text_filter/markdown_smartquotes.rb similarity index 82% rename from lib/publify_textfilter/markdown_smartquotes.rb rename to lib/publify_core/text_filter/markdown_smartquotes.rb index 6c24dade..6c87df68 100644 --- a/lib/publify_textfilter/markdown_smartquotes.rb +++ b/lib/publify_core/text_filter/markdown_smartquotes.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true require "text_filter_plugin" -require "publify_textfilter/markdown" +require "publify_core/text_filter/markdown" -module PublifyTextfilter - class MarkdownSmartquotes < PublifyTextfilter::Markdown +module PublifyCore::TextFilter + class MarkdownSmartquotes < PublifyCore::TextFilter::Markdown plugin_display_name "Markdown with smart quotes" plugin_description "Markdown markup language from" \ ' Daring Fireball' \ diff --git a/lib/publify_textfilter/none.rb b/lib/publify_core/text_filter/none.rb similarity index 88% rename from lib/publify_textfilter/none.rb rename to lib/publify_core/text_filter/none.rb index e69f4891..803655bf 100644 --- a/lib/publify_textfilter/none.rb +++ b/lib/publify_core/text_filter/none.rb @@ -2,7 +2,7 @@ require "text_filter_plugin" -module PublifyTextfilter +module PublifyCore::TextFilter class None < TextFilterPlugin::Markup plugin_display_name "None" plugin_description "Raw HTML only" diff --git a/lib/publify_textfilter/smartypants.rb b/lib/publify_core/text_filter/smartypants.rb similarity index 90% rename from lib/publify_textfilter/smartypants.rb rename to lib/publify_core/text_filter/smartypants.rb index 0c611c50..f5409b4d 100644 --- a/lib/publify_textfilter/smartypants.rb +++ b/lib/publify_core/text_filter/smartypants.rb @@ -2,7 +2,7 @@ require "rubypants" -module PublifyTextfilter +module PublifyCore::TextFilter class Smartypants < TextFilterPlugin::PostProcess plugin_display_name "Smartypants" plugin_description "Converts HTML to use typographically correct quotes and dashes" diff --git a/lib/publify_textfilter/twitterfilter.rb b/lib/publify_core/text_filter/twitterfilter.rb similarity index 98% rename from lib/publify_textfilter/twitterfilter.rb rename to lib/publify_core/text_filter/twitterfilter.rb index a4c497f8..87493b0a 100644 --- a/lib/publify_textfilter/twitterfilter.rb +++ b/lib/publify_core/text_filter/twitterfilter.rb @@ -4,7 +4,7 @@ require "html/pipeline" require "html/pipeline/hashtag/hashtag_filter" -module PublifyTextfilter +module PublifyCore::TextFilter class Twitterfilter < TextFilterPlugin::PostProcess plugin_display_name "HTML Filter" plugin_description "Strip HTML tags" diff --git a/lib/text_filter_plugin.rb b/lib/text_filter_plugin.rb index d18ed316..6e43a216 100644 --- a/lib/text_filter_plugin.rb +++ b/lib/text_filter_plugin.rb @@ -13,7 +13,7 @@ class << self def self.inherited(sub) super - if sub.to_s.start_with?("Plugin", "PublifyTextfilter") + if sub.to_s.start_with?("Plugin", "PublifyCore::TextFilter") name = sub.short_name @@filter_map[name] = sub end diff --git a/spec/lib/text_filter_plugin_spec.rb b/spec/lib/text_filter_plugin_spec.rb index 4cb4550c..2bd08944 100644 --- a/spec/lib/text_filter_plugin_spec.rb +++ b/spec/lib/text_filter_plugin_spec.rb @@ -6,9 +6,9 @@ describe ".available_filters" do subject { described_class.available_filters } - it { is_expected.to include(PublifyTextfilter::Markdown) } - it { is_expected.to include(PublifyTextfilter::Smartypants) } - it { is_expected.to include(PublifyTextfilter::Twitterfilter) } + it { is_expected.to include(PublifyCore::TextFilter::Markdown) } + it { is_expected.to include(PublifyCore::TextFilter::Smartypants) } + it { is_expected.to include(PublifyCore::TextFilter::Twitterfilter) } it { is_expected.not_to include(TextFilterPlugin::Markup) } it { is_expected.not_to include(TextFilterPlugin::Macro) } it { is_expected.not_to include(TextFilterPlugin::MacroPre) } @@ -18,9 +18,9 @@ describe ".macro_filters" do subject { described_class.macro_filters } - it { is_expected.not_to include(PublifyTextfilter::Markdown) } - it { is_expected.not_to include(PublifyTextfilter::Smartypants) } - it { is_expected.not_to include(PublifyTextfilter::Twitterfilter) } + it { is_expected.not_to include(PublifyCore::TextFilter::Markdown) } + it { is_expected.not_to include(PublifyCore::TextFilter::Smartypants) } + it { is_expected.not_to include(PublifyCore::TextFilter::Twitterfilter) } it { is_expected.not_to include(TextFilterPlugin::Markup) } it { is_expected.not_to include(TextFilterPlugin::Macro) } it { is_expected.not_to include(TextFilterPlugin::MacroPre) } diff --git a/spec/lib/publify_textfilter/markdown_smartquotes_spec.rb b/spec/publify_core/text_filter/markdown_smartquotes_spec.rb similarity index 92% rename from spec/lib/publify_textfilter/markdown_smartquotes_spec.rb rename to spec/publify_core/text_filter/markdown_smartquotes_spec.rb index 2fa305d0..90296cc6 100644 --- a/spec/lib/publify_textfilter/markdown_smartquotes_spec.rb +++ b/spec/publify_core/text_filter/markdown_smartquotes_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe PublifyTextfilter::MarkdownSmartquotes do +RSpec.describe PublifyCore::TextFilter::MarkdownSmartquotes do it "applies markdown processing to the supplied text" do aggregate_failures do expect(described_class.filtertext("*foo*")) diff --git a/spec/lib/publify_textfilter/markdown_spec.rb b/spec/publify_core/text_filter/markdown_spec.rb similarity index 93% rename from spec/lib/publify_textfilter/markdown_spec.rb rename to spec/publify_core/text_filter/markdown_spec.rb index a06af912..f3933591 100644 --- a/spec/lib/publify_textfilter/markdown_spec.rb +++ b/spec/publify_core/text_filter/markdown_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe PublifyTextfilter::Markdown do +RSpec.describe PublifyCore::TextFilter::Markdown do def filter_text(text) described_class.filtertext(text) end diff --git a/spec/lib/publify_textfilter/smartypants_spec.rb b/spec/publify_core/text_filter/smartypants_spec.rb similarity index 82% rename from spec/lib/publify_textfilter/smartypants_spec.rb rename to spec/publify_core/text_filter/smartypants_spec.rb index 552bdba8..a57c3072 100644 --- a/spec/lib/publify_textfilter/smartypants_spec.rb +++ b/spec/publify_core/text_filter/smartypants_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe PublifyTextfilter::Smartypants do +RSpec.describe PublifyCore::TextFilter::Smartypants do describe "#filtertext" do it "applies smartypants processing to the supplied text" do text = described_class.filtertext('"foo"') diff --git a/spec/lib/publify_textfilter/twitterfilter_spec.rb b/spec/publify_core/text_filter/twitterfilter_spec.rb similarity index 96% rename from spec/lib/publify_textfilter/twitterfilter_spec.rb rename to spec/publify_core/text_filter/twitterfilter_spec.rb index 45cd844a..6ff64d5e 100644 --- a/spec/lib/publify_textfilter/twitterfilter_spec.rb +++ b/spec/publify_core/text_filter/twitterfilter_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" -RSpec.describe PublifyTextfilter::Twitterfilter do +RSpec.describe PublifyCore::TextFilter::Twitterfilter do describe ".filtertext" do it "replaces a hashtag with a proper URL to Twitter search" do text = described_class.filtertext("A test tweet with a #hashtag") From 3ee681639c7e2cfc6154940806387c11e7575399 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Fri, 29 Sep 2023 15:53:16 +0200 Subject: [PATCH 5/6] Update manifest file --- Manifest.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Manifest.txt b/Manifest.txt index ad490e9a..47dac738 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -445,14 +445,14 @@ lib/publify_core/testing_support/fixtures/testfile.jpg lib/publify_core/testing_support/fixtures/testfile.png lib/publify_core/testing_support/fixtures/testfile.txt lib/publify_core/testing_support/upload_fixtures.rb +lib/publify_core/text_filter/markdown.rb +lib/publify_core/text_filter/markdown_smartquotes.rb +lib/publify_core/text_filter/none.rb +lib/publify_core/text_filter/smartypants.rb +lib/publify_core/text_filter/twitterfilter.rb lib/publify_core/version.rb lib/publify_guid.rb lib/publify_plugins.rb -lib/publify_textfilter_markdown.rb -lib/publify_textfilter_markdown_smartquotes.rb -lib/publify_textfilter_none.rb -lib/publify_textfilter_smartypants.rb -lib/publify_textfilter_twitterfilter.rb lib/publify_time.rb lib/sidebar_field.rb lib/sidebar_registry.rb From a8cccb6d3390fafa44a44e7975b93ee8a01426ca Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Fri, 29 Sep 2023 15:59:54 +0200 Subject: [PATCH 6/6] Regenerate RuboCop to-do file --- .rubocop_todo.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 26b178ff..936a6391 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-offense-counts --no-auto-gen-timestamp` -# using RuboCop version 1.50.1. +# using RuboCop version 1.56.4. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -23,7 +23,7 @@ Metrics/AbcSize: # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 221 + Max: 220 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: @@ -64,7 +64,6 @@ Naming/PredicateName: Naming/VariableNumber: Exclude: - 'spec/controllers/authors_controller_spec.rb' - - 'spec/models/comment_spec.rb' # Configuration parameters: MinSize. Performance/CollectionLiteralInLoop: @@ -77,7 +76,7 @@ RSpec/AnyInstance: - 'spec/models/article_spec.rb' - 'spec/models/note_spec.rb' -# Configuration parameters: Prefixes. +# Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Exclude: @@ -116,10 +115,6 @@ RSpec/ExpectInHook: RSpec/FilePath: Exclude: - 'spec/helpers/author_helper_spec.rb' - - 'spec/lib/publify_textfilter_markdown_smartquotes_spec.rb' - - 'spec/lib/publify_textfilter_markdown_spec.rb' - - 'spec/lib/publify_textfilter_smartypants_spec.rb' - - 'spec/lib/publify_textfilter_twitterfilter_spec.rb' - 'spec/lib/transforms_spec.rb' - 'spec/models/article/factory_spec.rb' @@ -153,7 +148,8 @@ RSpec/MultipleExpectations: RSpec/MultipleMemoizedHelpers: Max: 9 -# Configuration parameters: IgnoreSharedExamples. +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only RSpec/NamedSubject: Exclude: - 'spec/helpers/base_helper_spec.rb' @@ -161,6 +157,7 @@ RSpec/NamedSubject: - 'spec/models/content_spec.rb' - 'spec/models/page_spec.rb' +# Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 5 @@ -172,6 +169,7 @@ RSpec/RepeatedExample: Exclude: - 'spec/models/configuration_spec.rb' +# This cop supports safe autocorrection (--autocorrect). RSpec/ScatteredSetup: Exclude: - 'spec/controllers/admin/articles_controller_spec.rb' @@ -191,7 +189,7 @@ RSpec/VerifiedDoubles: - 'spec/models/note_spec.rb' # Configuration parameters: Include. -# Include: db/migrate/*.rb +# Include: db/**/*.rb Rails/CreateTableWithTimestamps: Exclude: - 'db/migrate/113_initial_schema.rb'