html-pipeline-gitlab 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7313484da93e94bb584aa3176ea1017937b3cc2
4
- data.tar.gz: b44f39f65e35854f45e32ab7fd2f3fca5b0196fd
3
+ metadata.gz: c84b06ddf12420f2ccdb9d2eb4e8704f6f4f5745
4
+ data.tar.gz: c5ad5e05767490da93d8a840698c3f1f29c9cb8a
5
5
  SHA512:
6
- metadata.gz: d2fc11352c8a791d6ef9be5f550f929f5787aaa95cc63b66bf9a0d44cdf578351d0f13abeb468606d13a92c58a0da5498e4c324ee2a01ae4f171ce4953f6d555
7
- data.tar.gz: 7083bb915724aafecb0bc77bb399a1312a555a3977a45bbb4fd8981c579c0cfe30930b0a2670c764cf9255748d54267687a02c2b97c4a02bf35aa74546e6d45b
6
+ metadata.gz: f86ed1f0880c9dc13d7fafc6e4a28afd803443d0676a19e7aeb0bc7178bcc5b3397f4476df95cdd63bbb79bf47b5b7c8f5c22d39f67175b77003e448d91eb63e
7
+ data.tar.gz: c3230cf3e24f63dc94688c6e365bed5647ce00e6a83a3094457ecf2c0e21c7548d20eb6240ad295758801a0761dee8b82abcc1febc10cb397aa38395c590e952
data/README.md CHANGED
@@ -21,15 +21,29 @@ Or install it yourself as:
21
21
 
22
22
  $ gem install html-pipeline-gitlab
23
23
 
24
+ ## Testing
25
+
26
+ Install required gems
27
+
28
+ ```bash
29
+ bundle
30
+ ```
31
+
32
+ and then run the test suite:
33
+
34
+ ```bash
35
+ bundle exec rake test
36
+ ```
37
+
24
38
  ## Filters
25
39
 
26
- * `GitLabEmojiFilter` - replaces emoji references with images from
40
+ * `GitlabEmojiFilter` - replaces emoji references with images from
27
41
  [PhantomOpenEmoji](https://github.com/Genshin/PhantomOpenEmoji)
28
42
 
29
43
  ## Contributing
30
44
 
31
- 1. Fork it ( https://github.com/razer6/html-pipeline-gitlab/fork )
32
- 2. Create your feature branch (`git checkout -b my-new-feature`)
33
- 3. Commit your changes (`git commit -am 'Add some feature'`)
34
- 4. Push to the branch (`git push origin my-new-feature`)
35
- 5. Create a new Pull Request
45
+ 1. Fork it
46
+ 1. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 1. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 1. Push to the branch (`git push origin my-new-feature`)
49
+ 1. Create a new Merge Request
@@ -6,11 +6,11 @@ require 'html/pipeline/gitlab/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'html-pipeline-gitlab'
8
8
  spec.version = Html::Pipeline::Gitlab::VERSION
9
- spec.authors = ['Robert Schilling']
9
+ spec.authors = ['Robert Schilling', 'Marin Jankovski']
10
10
  spec.email = ['schilling.ro@gmail.com']
11
11
  spec.summary = %q{Extension filters for html-pipeline used by GitLab}
12
12
  spec.description = %q{Extension filters for html-pipeline used by GitLab}
13
- spec.homepage = 'https://github.com/Razer6/html-pipeline-gitlab'
13
+ spec.homepage = 'https://gitlab.com/gitlab-org/html-pipeline-gitlab'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -22,6 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency 'rake', '~> 10.0'
23
23
 
24
24
  spec.add_runtime_dependency 'html-pipeline', '~> 1.11.0'
25
- spec.add_runtime_dependency 'gitlab_emoji', '~> 0.0.1.1'
25
+ spec.add_runtime_dependency 'gitlab_emoji', '~> 0.0.1'
26
26
  spec.add_runtime_dependency 'sanitize', '~> 2.1'
27
27
  end
@@ -3,17 +3,17 @@ require 'html/pipeline/gitlab/version'
3
3
 
4
4
  module HTML
5
5
  class Pipeline
6
- class GitLab
6
+ class Gitlab
7
7
  # GitLab related filters for html-pipeline. Implements new filters used
8
8
  # by GitLab.
9
9
 
10
10
  # Custom filter implementations
11
- autoload :GitLabEmojiFilter, 'html/pipeline/gitlab/gitlab_emoji_filter'
11
+ autoload :GitlabEmojiFilter, 'html/pipeline/gitlab/gitlab_emoji_filter'
12
12
 
13
13
  # Most used markdown pipeline in GitLab. Performs emoji replacement.
14
14
  MarkdownPipeline = HTML::Pipeline.new [
15
15
  SanitizationFilter,
16
- GitLabEmojiFilter
16
+ GitlabEmojiFilter
17
17
  ]
18
18
  end
19
19
  end
@@ -2,10 +2,9 @@ require 'cgi'
2
2
  require 'gitlab_emoji'
3
3
  require 'html/pipeline/filter'
4
4
 
5
-
6
5
  module HTML
7
6
  class Pipeline
8
- class GitLab
7
+ class Gitlab
9
8
  # HTML filter that replaces :emoji: with images.
10
9
  #
11
10
  # Context:
@@ -13,7 +12,7 @@ module HTML
13
12
  # :asset_path (optional) - url path to link to emoji sprite.
14
13
  # :file_name can be used as a placeholder for the sprite file name.
15
14
  # If no asset_path is set "emoji/:file_name" is used.
16
- class GitLabEmojiFilter < Filter
15
+ class GitlabEmojiFilter < Filter
17
16
  def call
18
17
  search_text_nodes(doc).each do |node|
19
18
  content = node.to_html
@@ -57,7 +56,7 @@ module HTML
57
56
  private
58
57
 
59
58
  def emoji_url(name)
60
- File.join(asset_root, 'emoji', emoji_filename(name))
59
+ ActionController::Base.helpers.url_to_image("emoji/#{emoji_filename(name)}")
61
60
  end
62
61
 
63
62
  # Build a regexp that matches all valid :emoji: names.
@@ -74,7 +73,12 @@ module HTML
74
73
  end
75
74
 
76
75
  def emoji_filename(name)
77
- "#{::CGI.escape(name)}.png"
76
+ # CGI.escape makes + into %20, skip that in this case
77
+ if name == "+1"
78
+ "+1.png"
79
+ else
80
+ "#{::CGI.escape(name)}.png"
81
+ end
78
82
  end
79
83
  end
80
84
  end
@@ -1,7 +1,7 @@
1
1
  module Html
2
2
  module Pipeline
3
3
  module Gitlab
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
6
6
  end
7
7
  end
@@ -1,31 +1,31 @@
1
1
  require 'test_helper'
2
2
  require 'html/pipeline/gitlab'
3
3
 
4
- class HTML::Pipeline::GitLabEmojiFilterTest < Minitest::Test
5
- GitLabEmojiFilter = HTML::Pipeline::GitLab::GitLabEmojiFilter
4
+ class HTML::Pipeline::GitlabEmojiFilterTest < Minitest::Test
5
+ GitlabEmojiFilter = HTML::Pipeline::Gitlab::GitlabEmojiFilter
6
6
 
7
7
  def test_emojify
8
- filter = GitLabEmojiFilter.new('<p>:heart:</p>', {asset_root: 'https://foo.com'})
8
+ filter = GitlabEmojiFilter.new('<p>:heart:</p>', { asset_root: 'https://foo.com' })
9
9
  doc = filter.call
10
10
  assert_match 'https://foo.com/emoji/heart.png', doc.search('img').attr('src').value
11
11
  end
12
12
 
13
13
  def test_unsupported_emoji
14
14
  block = '<p>:sheep:</p>'
15
- filter = GitLabEmojiFilter.new(block, {asset_root: 'https://foo.com'})
15
+ filter = GitlabEmojiFilter.new(block, { asset_root: 'https://foo.com' })
16
16
  doc = filter.call
17
17
  assert_match block, doc.to_html
18
18
  end
19
19
 
20
20
  def test_uri_encoding
21
- filter = GitLabEmojiFilter.new('<p>:+1:</p>', {asset_root: 'https://foo.com'})
21
+ filter = GitlabEmojiFilter.new('<p>:+1:</p>', { asset_root: 'https://foo.com' })
22
22
  doc = filter.call
23
23
  assert_match 'https://foo.com/emoji/%2B1.png', doc.search('img').attr('src').value
24
24
  end
25
25
 
26
26
  def test_required_context_validation
27
27
  exception = assert_raises(ArgumentError) {
28
- GitLabEmojiFilter.call("", {})
28
+ GitlabEmojiFilter.call("", {})
29
29
  }
30
30
  assert_match /:asset_root/, exception.message
31
31
  end
metadata CHANGED
@@ -1,83 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline-gitlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Schilling
8
+ - Marin Jankovski
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-09-26 00:00:00.000000000 Z
12
+ date: 2014-10-08 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - ~>
18
+ - - "~>"
18
19
  - !ruby/object:Gem::Version
19
20
  version: '1.6'
20
21
  type: :development
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - ~>
25
+ - - "~>"
25
26
  - !ruby/object:Gem::Version
26
27
  version: '1.6'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: rake
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - ~>
32
+ - - "~>"
32
33
  - !ruby/object:Gem::Version
33
34
  version: '10.0'
34
35
  type: :development
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - ~>
39
+ - - "~>"
39
40
  - !ruby/object:Gem::Version
40
41
  version: '10.0'
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: html-pipeline
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
- - - ~>
46
+ - - "~>"
46
47
  - !ruby/object:Gem::Version
47
48
  version: 1.11.0
48
49
  type: :runtime
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
- - - ~>
53
+ - - "~>"
53
54
  - !ruby/object:Gem::Version
54
55
  version: 1.11.0
55
56
  - !ruby/object:Gem::Dependency
56
57
  name: gitlab_emoji
57
58
  requirement: !ruby/object:Gem::Requirement
58
59
  requirements:
59
- - - ~>
60
+ - - "~>"
60
61
  - !ruby/object:Gem::Version
61
- version: 0.0.1.1
62
+ version: 0.0.1
62
63
  type: :runtime
63
64
  prerelease: false
64
65
  version_requirements: !ruby/object:Gem::Requirement
65
66
  requirements:
66
- - - ~>
67
+ - - "~>"
67
68
  - !ruby/object:Gem::Version
68
- version: 0.0.1.1
69
+ version: 0.0.1
69
70
  - !ruby/object:Gem::Dependency
70
71
  name: sanitize
71
72
  requirement: !ruby/object:Gem::Requirement
72
73
  requirements:
73
- - - ~>
74
+ - - "~>"
74
75
  - !ruby/object:Gem::Version
75
76
  version: '2.1'
76
77
  type: :runtime
77
78
  prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - ~>
81
+ - - "~>"
81
82
  - !ruby/object:Gem::Version
82
83
  version: '2.1'
83
84
  description: Extension filters for html-pipeline used by GitLab
@@ -87,8 +88,7 @@ executables: []
87
88
  extensions: []
88
89
  extra_rdoc_files: []
89
90
  files:
90
- - .gitignore
91
- - .travis.yml
91
+ - ".gitignore"
92
92
  - CHANGELOG
93
93
  - Gemfile
94
94
  - LICENSE
@@ -100,7 +100,7 @@ files:
100
100
  - lib/html/pipeline/gitlab/version.rb
101
101
  - test/html/pipeline/gitlab_gemoji_filter_test.rb
102
102
  - test/test_helper.rb
103
- homepage: https://github.com/Razer6/html-pipeline-gitlab
103
+ homepage: https://gitlab.com/gitlab-org/html-pipeline-gitlab
104
104
  licenses:
105
105
  - MIT
106
106
  metadata: {}
@@ -110,17 +110,17 @@ require_paths:
110
110
  - lib
111
111
  required_ruby_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - '>='
113
+ - - ">="
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - '>='
118
+ - - ">="
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.0.14
123
+ rubygems_version: 2.2.2
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Extension filters for html-pipeline used by GitLab
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.0
4
- - 2.0.0
5
- - 1.9.3
6
- before_install:
7
- - sudo apt-get install -y libicu-dev
8
- install:
9
- - travis_retry bundle config build.nokogiri --use-system-libraries
10
- - travis_retry bundle install
11
- script: rake test
12
- notifications:
13
- email: false