jekyll-uj-powertools 1.0.1 → 1.0.3
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/README.md +4 -4
- data/lib/jekyll-uj-powertools/version.rb +1 -1
- data/lib/jekyll-uj-powertools.rb +3 -2
- data/spec/jekyll-uj-powertools_spec.rb +15 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b6d677c7527d35be38d783a4d7e0ae0b75008c509a57536002e32f628e7914e
|
4
|
+
data.tar.gz: 6b406248ced940be822db945101183c6e7b558962cec1b5d31bb69e6cb28fc8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b548b726718786b5eeaa7d26097a76a3317974d142e91d4f1e8cb9c4c38141ce0f0d3e06d855d500daba03382fe17e269a26f768eb68c7493dbb64ea1ce5cf8c
|
7
|
+
data.tar.gz: e0e02c8c8f08bf2504b3c280bb9095178c2f68befbcf4a245ee348575ead8ce5d6c787dd1699f918533589a75960a11d1cb6ee44f77bb4bee9f44811fed2a155
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
## Features
|
28
28
|
* Powerful utility for Jekyll sites
|
29
|
-
* `
|
29
|
+
* `strip_ads` filter to remove ads from a string
|
30
30
|
* `json_escape` filter to escape JSON characters
|
31
31
|
|
32
32
|
# Jekyll::uj-powertools
|
@@ -46,13 +46,13 @@ gem install jekyll-uj-powertools
|
|
46
46
|
```
|
47
47
|
|
48
48
|
## Usage
|
49
|
-
Now you can use the `
|
49
|
+
Now you can use the `strip_ads` and `json_escape` filters in your Jekyll site:
|
50
50
|
|
51
|
-
### `
|
51
|
+
### `strip_ads` Filter
|
52
52
|
Remove ads from a string, such as a blog post or article.
|
53
53
|
|
54
54
|
```liquid
|
55
|
-
{{ post.content |
|
55
|
+
{{ post.content | strip_ads }}
|
56
56
|
```
|
57
57
|
|
58
58
|
### `json_escape` Filter
|
data/lib/jekyll-uj-powertools.rb
CHANGED
@@ -2,8 +2,9 @@ require "jekyll"
|
|
2
2
|
|
3
3
|
module Jekyll
|
4
4
|
module UJPowertools
|
5
|
-
def
|
6
|
-
input.gsub(
|
5
|
+
def strip_ads(input)
|
6
|
+
# input.gsub(/\{% include \/master\/modules\/adunits[^%]*%\}/, '')
|
7
|
+
input.gsub(/<!--\s*ADUNIT_START\s*-->.*?<!--\s*ADUNIT_END\s*-->/m, '')
|
7
8
|
end
|
8
9
|
|
9
10
|
def json_escape(value)
|
@@ -8,15 +8,22 @@ RSpec.describe Jekyll::UJPowertools do
|
|
8
8
|
|
9
9
|
let(:dummy) { DummyClass.new }
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
describe '.strip_ads' do
|
12
|
+
# it 'removes ads from the string' do
|
13
|
+
# expect(dummy.strip_ads('{% include /master/modules/adunits/adsense-in-article.html index="0" %} This is content')).to eq(' This is content')
|
14
|
+
# end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
# it 'returns the original string if no ads are present' do
|
17
|
+
# expect(dummy.strip_ads('No ads here')).to eq('No ads here')
|
18
|
+
# end
|
19
|
+
it 'removes ads from the string' do
|
20
|
+
expect(dummy.remove_ads('This is <!-- ADUNIT_START -->and ad<!-- ADUNIT_END -->')).to eq('This is ')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns the original string if no ads are present' do
|
24
|
+
expect(dummy.remove_ads('No ads here')).to eq('No ads here')
|
25
|
+
end
|
26
|
+
end
|
20
27
|
|
21
28
|
describe '.json_escape' do
|
22
29
|
it 'escapes double quotes in JSON string' do
|