jekyll-mentions 1.1.3 → 1.2.0
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/lib/jekyll-mentions.rb +23 -9
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b515aa7b27b314a2816ada8cd789f8184f4c7e95
|
4
|
+
data.tar.gz: b131642ac041798fda9cff29d25d4b716b77658b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efbfd53ad4d2992e2c0424f75cc803c2fe1b1aca7a81275ce27ecb20ca0c9ec21221306e53694c5d3f4845cdac6c428c11b1a7c18b2960f1883825252cc3ad45
|
7
|
+
data.tar.gz: 616f14c534cb4e7b38a28332dcb026aa7f0c3c7a310aa2a93bea0c4d44334a3d3db189cf309c61143a65bfd0815f7860bcf190cff041a3044ad8265b26f2d916
|
data/lib/jekyll-mentions.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "jekyll"
|
2
|
+
require "html/pipeline"
|
3
3
|
|
4
4
|
module Jekyll
|
5
5
|
class Mentions
|
6
6
|
GITHUB_DOT_COM = "https://github.com".freeze
|
7
7
|
BODY_START_TAG = "<body".freeze
|
8
8
|
|
9
|
-
|
10
9
|
InvalidJekyllMentionConfig = Class.new(Jekyll::Errors::FatalException)
|
11
10
|
|
12
11
|
class << self
|
12
|
+
# rubocop:disable Metrics/AbcSize
|
13
13
|
def mentionify(doc)
|
14
14
|
return unless doc.output.include?("@")
|
15
15
|
src = mention_base(doc.site.config)
|
16
16
|
if doc.output.include? BODY_START_TAG
|
17
17
|
parsed_doc = Nokogiri::HTML::Document.parse(doc.output)
|
18
|
-
body = parsed_doc.at_css(
|
18
|
+
body = parsed_doc.at_css("body")
|
19
19
|
body.children = filter_with_mention(src).call(body.inner_html)[:output].to_s
|
20
20
|
doc.output = parsed_doc.to_html
|
21
21
|
else
|
@@ -31,11 +31,14 @@ module Jekyll
|
|
31
31
|
def filter_with_mention(src)
|
32
32
|
filters[src] ||= HTML::Pipeline.new([
|
33
33
|
HTML::Pipeline::MentionFilter
|
34
|
-
], { :base_url => src
|
34
|
+
], { :base_url => src, :username_pattern => mention_username_pattern })
|
35
35
|
end
|
36
36
|
|
37
37
|
def mention_username_pattern
|
38
|
-
Regexp.new(
|
38
|
+
Regexp.new(
|
39
|
+
HTML::Pipeline::MentionFilter::UsernamePattern.source,
|
40
|
+
Regexp::IGNORECASE
|
41
|
+
)
|
39
42
|
end
|
40
43
|
|
41
44
|
# Public: Filters hash where the key is the mention base URL.
|
@@ -55,14 +58,14 @@ module Jekyll
|
|
55
58
|
# Returns a URL to use as the base URL for mentions.
|
56
59
|
# Defaults to the https://github.com.
|
57
60
|
def mention_base(config = {})
|
58
|
-
mention_config = config[
|
61
|
+
mention_config = config["jekyll-mentions"]
|
59
62
|
case mention_config
|
60
63
|
when nil, NilClass
|
61
|
-
|
64
|
+
default_mention_base
|
62
65
|
when String
|
63
66
|
mention_config.to_s
|
64
67
|
when Hash
|
65
|
-
mention_config.fetch(
|
68
|
+
mention_config.fetch("base_url", default_mention_base)
|
66
69
|
else
|
67
70
|
raise InvalidJekyllMentionConfig,
|
68
71
|
"Your jekyll-mentions config has to either be a" \
|
@@ -79,6 +82,17 @@ module Jekyll
|
|
79
82
|
(doc.is_a?(Jekyll::Page) || doc.write?) &&
|
80
83
|
doc.output_ext == ".html" || (doc.permalink && doc.permalink.end_with?("/"))
|
81
84
|
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def default_mention_base
|
89
|
+
if !ENV["SSL"].to_s.empty? && !ENV["GITHUB_HOSTNAME"].to_s.empty?
|
90
|
+
scheme = ENV["SSL"] == "true" ? "https://" : "http://"
|
91
|
+
"#{scheme}#{ENV["GITHUB_HOSTNAME"].chomp("/")}"
|
92
|
+
else
|
93
|
+
GITHUB_DOT_COM
|
94
|
+
end
|
95
|
+
end
|
82
96
|
end
|
83
97
|
end
|
84
98
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-mentions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
121
|
version: '0'
|
108
122
|
requirements: []
|
109
123
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.6.6
|
111
125
|
signing_key:
|
112
126
|
specification_version: 4
|
113
127
|
summary: "@mention support for your Jekyll site"
|