publify_core 10.0.0 → 10.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -1
- data/app/assets/javascripts/markup_help_popup.js +25 -0
- data/app/assets/javascripts/optional_field_toggle.js +7 -0
- data/app/assets/javascripts/preview_comment.js +10 -0
- data/app/assets/javascripts/publify.js +3 -0
- data/app/assets/javascripts/publify_admin.js +1 -25
- data/app/assets/javascripts/spinnable.js +7 -2
- data/app/assets/stylesheets/administration_structure.css.scss +1 -1
- data/app/assets/stylesheets/publify.css.scss +43 -0
- data/app/assets/stylesheets/publify_admin.css.scss +0 -1
- data/app/controllers/admin/articles_controller.rb +4 -4
- data/app/controllers/admin/dashboard_controller.rb +0 -4
- data/app/controllers/admin/post_types_controller.rb +1 -1
- data/app/controllers/admin/themes_controller.rb +1 -9
- data/app/controllers/articles_controller.rb +5 -3
- data/app/controllers/comments_controller.rb +1 -1
- data/app/controllers/setup_controller.rb +20 -11
- data/app/helpers/admin/feedback_helper.rb +1 -1
- data/app/helpers/base_helper.rb +21 -13
- data/app/models/archives_sidebar.rb +1 -1
- data/app/models/article.rb +1 -2
- data/app/models/content.rb +8 -3
- data/app/models/note.rb +1 -1
- data/app/models/redirect.rb +2 -2
- data/app/models/tag_sidebar.rb +25 -3
- data/app/models/text_filter.rb +1 -1
- data/app/uploaders/resource_uploader.rb +4 -10
- data/app/views/admin/articles/_form.html.erb +2 -2
- data/app/views/admin/articles/index.html.erb +4 -5
- data/app/views/admin/dashboard/_comment.html.erb +1 -1
- data/app/views/admin/dashboard/_drafts.html.erb +1 -1
- data/app/views/admin/feedback/_ham.html.erb +1 -1
- data/app/views/admin/feedback/article.html.erb +1 -1
- data/app/views/admin/feedback/edit.html.erb +1 -1
- data/app/views/admin/feedback/index.html.erb +2 -2
- data/app/views/admin/migrations/show.html.erb +1 -1
- data/app/views/admin/notes/_form.html.erb +2 -3
- data/app/views/admin/notes/_note.html.erb +2 -2
- data/app/views/admin/notes/edit.html.erb +0 -1
- data/app/views/admin/pages/_pages.html.erb +1 -1
- data/app/views/admin/post_types/_index_and_form.html.erb +2 -2
- data/app/views/admin/redirects/_index_and_form.html.erb +2 -2
- data/app/views/admin/seo/show.html.erb +1 -1
- data/app/views/admin/settings/display.html.erb +1 -1
- data/app/views/admin/settings/feedback.html.erb +1 -1
- data/app/views/admin/settings/index.html.erb +1 -1
- data/app/views/admin/settings/write.html.erb +1 -1
- data/app/views/admin/tags/_index_and_form.html.erb +1 -1
- data/app/views/admin/users/_form.html.erb +1 -1
- data/app/views/articles/_comment_form.html.erb +9 -7
- data/app/views/articles/_comment_preview.html.erb +1 -1
- data/app/views/articles/_trackback.html.erb +3 -3
- data/app/views/articles/comment_failed.js.erb +1 -1
- data/app/views/articles/read.html.erb +4 -2
- data/app/views/comments/_comment.html.erb +1 -1
- data/app/views/comments/preview.js.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +3 -3
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/registrations/new.html.erb +2 -2
- data/app/views/devise/sessions/new.html.erb +2 -2
- data/app/views/devise/shared/_links.html.erb +3 -3
- data/app/views/layouts/accounts.html.erb +3 -3
- data/app/views/layouts/administration.html.erb +4 -6
- data/app/views/layouts/default.html.erb +1 -1
- data/app/views/layouts/editor.html.erb +3 -3
- data/app/views/notes/index.html.erb +1 -1
- data/app/views/notes/show_in_reply.html.erb +1 -1
- data/app/views/notification_mailer/comment.html.erb +1 -1
- data/app/views/search_sidebar/_content.html.erb +2 -3
- data/app/views/settings/install.html.erb +2 -2
- data/app/views/setup/index.html.erb +42 -11
- data/app/views/shared/_page_header.html.erb +5 -5
- data/app/views/tag_sidebar/_content.html.erb +2 -2
- data/config/locales/ar.yml +0 -1
- data/config/locales/da.yml +0 -1
- data/config/locales/de.yml +0 -1
- data/config/locales/en.yml +0 -1
- data/config/locales/es-MX.yml +0 -1
- data/config/locales/fr.yml +0 -1
- data/config/locales/he.yml +0 -1
- data/config/locales/it.yml +0 -1
- data/config/locales/ja.yml +0 -1
- data/config/locales/lt.yml +0 -1
- data/config/locales/nb.yml +0 -1
- data/config/locales/nl.yml +0 -1
- data/config/locales/pl.yml +0 -1
- data/config/locales/pt-BR.yml +0 -1
- data/config/locales/ro.yml +0 -1
- data/config/locales/ru.yml +0 -1
- data/config/locales/zh-CN.yml +0 -1
- data/config/locales/zh-TW.yml +0 -1
- data/db/seeds.rb +5 -5
- data/lib/publify_core/string_ext.rb +52 -0
- data/lib/publify_core/testing_support/feed_assertions.rb +1 -4
- data/lib/publify_core/text_filter/markdown.rb +53 -0
- data/lib/{publify_textfilter_markdown_smartquotes.rb → publify_core/text_filter/markdown_smartquotes.rb} +3 -3
- data/lib/publify_core/text_filter/none.rb +14 -0
- data/lib/publify_core/text_filter/smartypants.rb +14 -0
- data/lib/publify_core/text_filter/twitterfilter.rb +55 -0
- data/lib/publify_core/version.rb +1 -1
- data/lib/publify_core.rb +6 -6
- data/lib/text_filter_plugin.rb +23 -11
- data/lib/theme.rb +18 -7
- metadata +64 -29
- data/app/assets/javascripts/datetimepicker.js +0 -1470
- data/app/assets/stylesheets/datetimepicker.css +0 -306
- data/lib/publify_textfilter_markdown.rb +0 -56
- data/lib/publify_textfilter_none.rb +0 -16
- data/lib/publify_textfilter_smartypants.rb +0 -16
- data/lib/publify_textfilter_twitterfilter.rb +0 -57
- data/lib/transforms.rb +0 -47
@@ -1,17 +1,48 @@
|
|
1
|
+
<div class="row">
|
2
|
+
<div class="col-md-8 col-md-offset-2" id="error-message-page">
|
3
|
+
<% if this_blog.errors.any? %>
|
4
|
+
<div id="error_explanation">
|
5
|
+
<h2><%= t("errors.template.header", model: 'blog', count: this_blog.errors.count) %></h2>
|
6
|
+
<p><%= t("errors.template.body") %></p>
|
7
|
+
<ul>
|
8
|
+
<% this_blog.errors.full_messages.each do |message| %>
|
9
|
+
<li><%= message %></li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
<% if @user.errors.any? %>
|
15
|
+
<div id="error_explanation">
|
16
|
+
<h2><%= t("errors.template.header", model: 'blog', count: @user.errors.count) %></h2>
|
17
|
+
<p><%= t("errors.template.body") %></p>
|
18
|
+
<ul>
|
19
|
+
<% @user.errors.full_messages.each do |message| %>
|
20
|
+
<li><%= message %></li>
|
21
|
+
<% end %>
|
22
|
+
</ul>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
|
1
28
|
<%= form_tag action: 'index' do %>
|
2
29
|
<div class='alert alert-info'>
|
3
30
|
<small><%= t('.welcome_to_your_blog_setup', publify: link_to('Publify', 'https://publify.github.io/')) %></small>
|
4
31
|
</div>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
32
|
+
<%= fields model: this_blog do |form| %>
|
33
|
+
<div class='form-group'>
|
34
|
+
<%= form.text_field(:blog_name, class: 'form-control', placeholder: t('.blog_name')) %>
|
35
|
+
</div>
|
36
|
+
<% end %>
|
37
|
+
<%= fields model: @user do |form| %>
|
38
|
+
<div class='form-group'>
|
39
|
+
<%= form.text_field(:email, class: 'form-control', placeholder: t('.your_mail')) %>
|
40
|
+
</div>
|
41
|
+
<div class='form-group'>
|
42
|
+
<%= form.label :password, t('.password') %><br>
|
43
|
+
<%= form.password_field(:password, class: 'form-control') %>
|
44
|
+
</div>
|
45
|
+
<% end %>
|
15
46
|
|
16
|
-
<input type="submit" id="submit" class='btn btn-lg btn-success btn-block' value="<%= t('generic.save') %>"
|
47
|
+
<input type="submit" id="submit" class='btn btn-lg btn-success btn-block' value="<%= t('generic.save') %>">
|
17
48
|
<% end %>
|
@@ -1,21 +1,21 @@
|
|
1
|
-
<meta http-equiv="content-type" content="text/html; charset=utf-8"
|
1
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
2
2
|
<%= meta_tag 'ICBM', this_blog.geourl_location if this_blog.geourl_location.present? %>
|
3
3
|
<%= meta_tag 'description', @description if @description.present? %>
|
4
4
|
<%= meta_tag 'robots', 'noindex, follow' if stop_index_robots?(this_blog) %>
|
5
5
|
<%= meta_tag 'google-site-verification', this_blog.google_verification if this_blog.google_verification.present? %>
|
6
|
-
<meta name="generator" content="Publify <%= PublifyCore::VERSION %>"
|
6
|
+
<meta name="generator" content="Publify <%= PublifyCore::VERSION %>">
|
7
7
|
<%= show_meta_keyword %>
|
8
8
|
<% if feed_atom %>
|
9
|
-
<link rel="alternate" type="application/atom+xml" title="Atom" href="<%= feed_atom %>"
|
9
|
+
<link rel="alternate" type="application/atom+xml" title="Atom" href="<%= feed_atom %>">
|
10
10
|
<% end %>
|
11
11
|
<% if feed_rss %>
|
12
|
-
<link rel="alternate" type="application/rss+xml" title="RSS" href="<%= feed_rss %>"
|
12
|
+
<link rel="alternate" type="application/rss+xml" title="RSS" href="<%= feed_rss %>">
|
13
13
|
<% end %>
|
14
14
|
<%= javascript_include_tag :publify, async: Rails.env.production? %>
|
15
15
|
<%= csrf_meta_tags %>
|
16
16
|
<%= stylesheet_link_tag :publify %>
|
17
17
|
<%= page_header_includes %>
|
18
|
-
<link rel="canonical" href="<%= this_blog.url_for request.fullpath %>"
|
18
|
+
<link rel="canonical" href="<%= this_blog.url_for request.fullpath %>">
|
19
19
|
<%= raw this_blog.custom_tracking_field if this_blog.custom_tracking_field.present? %>
|
20
20
|
<%= render 'shared/google_analytics' if this_blog.google_analytics.present? %>
|
21
21
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<% unless sidebar.tags.blank? %>
|
2
2
|
<h3 class="sidebar-title"><%= t('.tags') %></h3>
|
3
3
|
<div class="sidebar-body">
|
4
|
-
<p
|
4
|
+
<p class="tag-sidebar-tag-cloud">
|
5
5
|
<% sidebar.tags.each do |tag| %>
|
6
|
-
<span
|
6
|
+
<span class="tag-sidebar-tag-<%= sidebar.sizes[tag] %>"><%= link_to tag.display_name, tag_url(tag.name) %></span>
|
7
7
|
<% end %>
|
8
8
|
</p>
|
9
9
|
</div>
|
data/config/locales/ar.yml
CHANGED
data/config/locales/da.yml
CHANGED
data/config/locales/de.yml
CHANGED
data/config/locales/en.yml
CHANGED
data/config/locales/es-MX.yml
CHANGED
@@ -246,7 +246,6 @@ es-MX:
|
|
246
246
|
compose_new_note: Componer una nueva nota
|
247
247
|
in_reply_to: In reply to
|
248
248
|
no_notes: No existen notas aún. Por qué no empieza creando una?
|
249
|
-
now: Now
|
250
249
|
or: or
|
251
250
|
permanent_link: Permanent link
|
252
251
|
posse_to_twitter: POSSE to twitter
|
data/config/locales/fr.yml
CHANGED
@@ -250,7 +250,6 @@ fr:
|
|
250
250
|
compose_new_note: Écrire un nouveau billet
|
251
251
|
in_reply_to: En réponse à
|
252
252
|
no_notes: 'Il n''y a pas encore de notes, pourquoi ne pas en créer une ? '
|
253
|
-
now: Maintenant
|
254
253
|
or: ou
|
255
254
|
permanent_link: Lien permanent
|
256
255
|
posse_to_twitter: POSSE to twitter
|
data/config/locales/he.yml
CHANGED
data/config/locales/it.yml
CHANGED
data/config/locales/ja.yml
CHANGED
data/config/locales/lt.yml
CHANGED
data/config/locales/nb.yml
CHANGED
data/config/locales/nl.yml
CHANGED
data/config/locales/pl.yml
CHANGED
data/config/locales/pt-BR.yml
CHANGED
@@ -246,7 +246,6 @@ pt-BR:
|
|
246
246
|
compose_new_note: Compor nova nota
|
247
247
|
in_reply_to: Em resposta a
|
248
248
|
no_notes: Não existem notas ainda. Por que você não inicia e cria uma?
|
249
|
-
now: Agora
|
250
249
|
or: ou
|
251
250
|
permanent_link: link permanente
|
252
251
|
posse_to_twitter: POSSE para twitter
|
data/config/locales/ro.yml
CHANGED
data/config/locales/ru.yml
CHANGED
data/config/locales/zh-CN.yml
CHANGED
data/config/locales/zh-TW.yml
CHANGED
data/db/seeds.rb
CHANGED
@@ -13,9 +13,9 @@
|
|
13
13
|
blog = Blog.first || Blog.create!
|
14
14
|
|
15
15
|
unless blog.sidebars.any?
|
16
|
-
PageSidebar.create!(active_position: 0, staged_position: 0,
|
17
|
-
TagSidebar.create!(active_position: 1,
|
18
|
-
ArchivesSidebar.create!(active_position: 2,
|
19
|
-
StaticSidebar.create!(active_position: 3,
|
20
|
-
MetaSidebar.create!(active_position: 4,
|
16
|
+
PageSidebar.create!(active_position: 0, staged_position: 0, blog: blog)
|
17
|
+
TagSidebar.create!(active_position: 1, blog: blog)
|
18
|
+
ArchivesSidebar.create!(active_position: 2, blog: blog)
|
19
|
+
StaticSidebar.create!(active_position: 3, blog: blog)
|
20
|
+
MetaSidebar.create!(active_position: 4, blog: blog)
|
21
21
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# FIXME: Replace with helpers and/or methods provided by Rails
|
4
|
+
module PublifyCore
|
5
|
+
module StringExt
|
6
|
+
ACCENTS = { %w(á à â ä ã Ã Ä Â À) => "a",
|
7
|
+
%w(é è ê ë Ë É È Ê) => "e",
|
8
|
+
%w(í ì î ï I Î Ì) => "i",
|
9
|
+
%w(ó ò ô ö õ Õ Ö Ô Ò) => "o",
|
10
|
+
["œ"] => "oe",
|
11
|
+
["ß"] => "ss",
|
12
|
+
%w(ú ù û ü U Û Ù) => "u",
|
13
|
+
%w(ç Ç) => "c" }.freeze
|
14
|
+
|
15
|
+
def to_permalink
|
16
|
+
string = self
|
17
|
+
ACCENTS.each do |key, value|
|
18
|
+
string = string.tr(key.join, value)
|
19
|
+
end
|
20
|
+
string = string.tr("'", "-")
|
21
|
+
string.gsub(/<[^>]*>/, "").to_url
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns a-string-with-dashes when passed 'a string with dashes'.
|
25
|
+
# All special chars are stripped in the process
|
26
|
+
def to_url
|
27
|
+
return if nil?
|
28
|
+
|
29
|
+
s = downcase.tr("\"'", "")
|
30
|
+
s = s.gsub(/\P{Word}/, " ")
|
31
|
+
s.strip.tr_s(" ", "-").tr(" ", "-").sub(/^$/, "-")
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_title(item, settings, params)
|
35
|
+
TitleBuilder.new(self).build(item, settings, params)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Strips any html markup from a string
|
39
|
+
TYPO_TAG_KEY = TYPO_ATTRIBUTE_KEY = /[\w:_-]+/.freeze
|
40
|
+
TYPO_ATTRIBUTE_VALUE = /(?:[A-Za-z0-9]+|(?:'[^']*?'|"[^"]*?"))/.freeze
|
41
|
+
TYPO_ATTRIBUTE = /(?:#{TYPO_ATTRIBUTE_KEY}(?:\s*=\s*#{TYPO_ATTRIBUTE_VALUE})?)/.freeze
|
42
|
+
TYPO_ATTRIBUTES = /(?:#{TYPO_ATTRIBUTE}(?:\s+#{TYPO_ATTRIBUTE})*)/.freeze
|
43
|
+
TAG =
|
44
|
+
%r{<[!/?\[]?(?:#{TYPO_TAG_KEY}|--)(?:\s+#{TYPO_ATTRIBUTES})?\s*(?:[!/?\]]+|--)?>}
|
45
|
+
.freeze
|
46
|
+
def strip_html
|
47
|
+
gsub(TAG, "").gsub(/\s+/, " ").strip
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
String.include PublifyCore::StringExt
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "feedjira"
|
4
|
-
require "rexml/document"
|
5
4
|
|
6
5
|
module PublifyCore
|
7
6
|
module TestingSupport
|
@@ -9,9 +8,7 @@ module PublifyCore
|
|
9
8
|
# TODO: Clean up use of these Test::Unit style expectations
|
10
9
|
def assert_xml(xml)
|
11
10
|
expect(xml).not_to be_empty
|
12
|
-
expect
|
13
|
-
assert REXML::Document.new(xml)
|
14
|
-
end.not_to raise_error
|
11
|
+
expect { Nokogiri::XML.parse(xml) }.not_to raise_error
|
15
12
|
end
|
16
13
|
|
17
14
|
def assert_atom10(feed, count)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "text_filter_plugin"
|
4
|
+
require "commonmarker"
|
5
|
+
|
6
|
+
module PublifyCore::TextFilter
|
7
|
+
class Markdown < TextFilterPlugin::Markup
|
8
|
+
plugin_display_name "Markdown"
|
9
|
+
plugin_description "Markdown markup language from" \
|
10
|
+
' <a href="http://daringfireball.com/">Daring Fireball</a>'
|
11
|
+
|
12
|
+
def self.help_text
|
13
|
+
<<~TXT
|
14
|
+
[Markdown](http://daringfireball.net/projects/markdown/) is a simple
|
15
|
+
text-to-HTML converter that turns common text idioms into HTML. The
|
16
|
+
[full syntax](http://daringfireball.net/projects/markdown/syntax) is
|
17
|
+
available from the author's site, but here's a short summary:
|
18
|
+
|
19
|
+
* **Paragraphs**: Start a new paragraph by skipping a line.
|
20
|
+
* **Italics**: Put text in *italics* by enclosing it in either * or
|
21
|
+
_: `*italics*` turns into *italics*.
|
22
|
+
* **Bold**: Put text in **bold** by enclosing it in two *s:
|
23
|
+
`**bold**` turns into **bold**.
|
24
|
+
* **Pre-formatted text**: Enclosing a short block of text in
|
25
|
+
backquotes (`) displays it in a monospaced font and converts HTML
|
26
|
+
metacharacters so they display correctly. Example:
|
27
|
+
``<img src="foo"/>`` displays as `<img src="foo"/>`. Also,
|
28
|
+
any paragraph indented 4 or more spaces is treated as pre-formatted
|
29
|
+
text.
|
30
|
+
* **Block quotes**: Any paragraph (or line) that starts with a `>` is
|
31
|
+
treated as a blockquote.
|
32
|
+
* **Hyperlinks**: You can create links like this:
|
33
|
+
`[amazon's web site](http://www.amazon.com)`. That produces
|
34
|
+
"[amazon's web site](http://www.amazon.com)".
|
35
|
+
* **Lists**: You can create numbered or bulleted lists by ending a
|
36
|
+
paragraph with a colon (:), skipping a line, and then using asterisks
|
37
|
+
(*, for bullets) or numbers (for numbered lists). See the
|
38
|
+
[Markdown syntax page](http://daringfireball.net/projects/markdown/syntax)
|
39
|
+
for examples.
|
40
|
+
* **Raw HTML**: Markdown will pass raw HTML through unchanged, so you
|
41
|
+
can use HTML's syntax whenever Markdown doesn't provide a reasonable
|
42
|
+
alternative.
|
43
|
+
TXT
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.filtertext(text)
|
47
|
+
# FIXME: Workaround for <publify:foo> not being interpreted as an HTML tag.
|
48
|
+
escaped_macros = text.gsub(%r{(</?publify):}, '\1X')
|
49
|
+
html = CommonMarker.render_html(escaped_macros, :UNSAFE)
|
50
|
+
html.gsub(%r{(</?publify)X}, '\1:').strip
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "text_filter_plugin"
|
4
|
-
require "
|
4
|
+
require "publify_core/text_filter/markdown"
|
5
5
|
|
6
|
-
module
|
7
|
-
class MarkdownSmartquotes <
|
6
|
+
module PublifyCore::TextFilter
|
7
|
+
class MarkdownSmartquotes < PublifyCore::TextFilter::Markdown
|
8
8
|
plugin_display_name "Markdown with smart quotes"
|
9
9
|
plugin_description "Markdown markup language from" \
|
10
10
|
' <a href="http://daringfireball.com/">Daring Fireball</a>' \
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "text_filter_plugin"
|
4
|
+
|
5
|
+
module PublifyCore::TextFilter
|
6
|
+
class None < TextFilterPlugin::Markup
|
7
|
+
plugin_display_name "None"
|
8
|
+
plugin_description "Raw HTML only"
|
9
|
+
|
10
|
+
def self.filtertext(text)
|
11
|
+
text
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubypants"
|
4
|
+
|
5
|
+
module PublifyCore::TextFilter
|
6
|
+
class Smartypants < TextFilterPlugin::PostProcess
|
7
|
+
plugin_display_name "Smartypants"
|
8
|
+
plugin_description "Converts HTML to use typographically correct quotes and dashes"
|
9
|
+
|
10
|
+
def self.filtertext(text)
|
11
|
+
RubyPants.new(text).to_html
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "text_filter_plugin"
|
4
|
+
require "html/pipeline"
|
5
|
+
require "html/pipeline/hashtag/hashtag_filter"
|
6
|
+
|
7
|
+
module PublifyCore::TextFilter
|
8
|
+
class Twitterfilter < TextFilterPlugin::PostProcess
|
9
|
+
plugin_display_name "Twitter Filter"
|
10
|
+
plugin_description "Convert hashtags and mentions to links"
|
11
|
+
|
12
|
+
class TwitterHashtagFilter < HTML::Pipeline::HashtagFilter
|
13
|
+
def initialize(text)
|
14
|
+
super(text,
|
15
|
+
tag_url: "https://twitter.com/search?q=%%23%<tag>s&src=tren&mode=realtime",
|
16
|
+
tag_link_attr: "")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class TwitterMentionFilter < HTML::Pipeline::MentionFilter
|
21
|
+
def initialize(text)
|
22
|
+
super(text, base_url: "https://twitter.com")
|
23
|
+
end
|
24
|
+
|
25
|
+
# Override base mentions finder, treating @mention just like any other @foo.
|
26
|
+
def self.mentioned_logins_in(text, username_pattern = UsernamePattern)
|
27
|
+
text.gsub MentionPatterns[username_pattern] do |match|
|
28
|
+
login = Regexp.last_match(1)
|
29
|
+
yield match, login, false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Override base link creator, removing the class
|
34
|
+
def link_to_mentioned_user(login)
|
35
|
+
result[:mentioned_usernames] |= [login]
|
36
|
+
|
37
|
+
url = base_url.dup
|
38
|
+
url << "/" unless %r{[/~]\z}.match?(url)
|
39
|
+
|
40
|
+
"<a href='#{url << login}'>" \
|
41
|
+
"@#{login}" \
|
42
|
+
"</a>"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.filtertext(text)
|
47
|
+
# First, autolink
|
48
|
+
helper = PublifyCore::ContentTextHelpers.new
|
49
|
+
text = helper.auto_link(text)
|
50
|
+
|
51
|
+
text = TwitterHashtagFilter.new(text).call
|
52
|
+
TwitterMentionFilter.new(text).call.to_s
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/publify_core/version.rb
CHANGED
data/lib/publify_core.rb
CHANGED
@@ -8,6 +8,12 @@ require "publify_core/version"
|
|
8
8
|
require "publify_core/engine"
|
9
9
|
require "publify_core/lang"
|
10
10
|
require "publify_core/content_text_helpers"
|
11
|
+
require "publify_core/text_filter/none"
|
12
|
+
require "publify_core/text_filter/markdown"
|
13
|
+
require "publify_core/text_filter/markdown_smartquotes"
|
14
|
+
require "publify_core/text_filter/smartypants"
|
15
|
+
require "publify_core/text_filter/twitterfilter"
|
16
|
+
require "publify_core/string_ext"
|
11
17
|
|
12
18
|
require "carrierwave"
|
13
19
|
require "jquery-rails"
|
@@ -20,17 +26,11 @@ require "sassc-rails"
|
|
20
26
|
|
21
27
|
require "email_notify"
|
22
28
|
require "publify_guid"
|
23
|
-
require "publify_textfilter_none"
|
24
|
-
require "publify_textfilter_markdown"
|
25
|
-
require "publify_textfilter_markdown_smartquotes"
|
26
|
-
require "publify_textfilter_smartypants"
|
27
|
-
require "publify_textfilter_twitterfilter"
|
28
29
|
require "publify_time"
|
29
30
|
require "sidebar_registry"
|
30
31
|
require "spam_protection"
|
31
32
|
require "text_filter_plugin"
|
32
33
|
require "theme"
|
33
|
-
require "transforms"
|
34
34
|
|
35
35
|
module PublifyCore
|
36
36
|
Theme.register_themes File.join(Engine.root, "themes")
|
data/lib/text_filter_plugin.rb
CHANGED
@@ -13,10 +13,8 @@ class TextFilterPlugin
|
|
13
13
|
def self.inherited(sub)
|
14
14
|
super
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
@@filter_map[name] = sub
|
19
|
-
end
|
16
|
+
name = sub.short_name
|
17
|
+
@@filter_map[name] = sub
|
20
18
|
end
|
21
19
|
|
22
20
|
def self.filter_map
|
@@ -116,34 +114,40 @@ class TextFilterPlugin
|
|
116
114
|
def self.logger
|
117
115
|
@logger ||= ::Rails.logger || Logger.new($stdout)
|
118
116
|
end
|
117
|
+
|
118
|
+
def self.abstract_filter!
|
119
|
+
@@filter_map.delete short_name
|
120
|
+
end
|
119
121
|
end
|
120
122
|
|
121
123
|
class TextFilterPlugin::PostProcess < TextFilterPlugin
|
124
|
+
abstract_filter!
|
125
|
+
|
122
126
|
def self.filter_type
|
123
127
|
"postprocess"
|
124
128
|
end
|
125
129
|
end
|
126
130
|
|
127
|
-
|
131
|
+
module TextFilterPlugin::MacroMethods
|
128
132
|
# Utility function -- hand it a XML string like <a href="foo" title="bar">
|
129
133
|
# and it'll give you back { "href" => "foo", "title" => "bar" }
|
130
|
-
def
|
134
|
+
def attributes_parse(string)
|
131
135
|
attributes = {}
|
132
136
|
|
133
137
|
string.gsub(/([^ =]+="[^"]*")/) do |match|
|
134
|
-
key, value = match.split(
|
138
|
+
key, value = match.split("=", 2)
|
135
139
|
attributes[key] = value.delete('"')
|
136
140
|
end
|
137
141
|
|
138
142
|
string.gsub(/([^ =]+='[^']*')/) do |match|
|
139
|
-
key, value = match.split(
|
143
|
+
key, value = match.split("=", 2)
|
140
144
|
attributes[key] = value.delete("'")
|
141
145
|
end
|
142
146
|
|
143
147
|
attributes
|
144
148
|
end
|
145
149
|
|
146
|
-
def
|
150
|
+
def filtertext(text)
|
147
151
|
regex1 = %r{<publify:#{short_name}(?:[ \t][^>]*)?/>}
|
148
152
|
regex2 = %r{<publify:#{short_name}([ \t][^>]*)?>(.*?)</publify:#{short_name}>}m
|
149
153
|
|
@@ -157,19 +161,27 @@ class TextFilterPlugin::Macro < TextFilterPlugin
|
|
157
161
|
end
|
158
162
|
end
|
159
163
|
|
160
|
-
class TextFilterPlugin::MacroPre < TextFilterPlugin
|
164
|
+
class TextFilterPlugin::MacroPre < TextFilterPlugin
|
165
|
+
abstract_filter!
|
166
|
+
extend TextFilterPlugin::MacroMethods
|
167
|
+
|
161
168
|
def self.filter_type
|
162
169
|
"macropre"
|
163
170
|
end
|
164
171
|
end
|
165
172
|
|
166
|
-
class TextFilterPlugin::MacroPost < TextFilterPlugin
|
173
|
+
class TextFilterPlugin::MacroPost < TextFilterPlugin
|
174
|
+
abstract_filter!
|
175
|
+
extend TextFilterPlugin::MacroMethods
|
176
|
+
|
167
177
|
def self.filter_type
|
168
178
|
"macropost"
|
169
179
|
end
|
170
180
|
end
|
171
181
|
|
172
182
|
class TextFilterPlugin::Markup < TextFilterPlugin
|
183
|
+
abstract_filter!
|
184
|
+
|
173
185
|
def self.filter_type
|
174
186
|
"markup"
|
175
187
|
end
|