jekyll-flant-plugins 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/jekyll-flant-plugins/snippetcut.rb +71 -0
- data/lib/jekyll-flant-plugins/version.rb +5 -0
- data/lib/jekyll-flant-plugins.rb +4 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a41738634aa1a1d30a05e38149f2686a7a2c1853f7b2cecedf72f188b1786291
|
4
|
+
data.tar.gz: 67f9c55637d6f872624746583c26c5f98ab744bc73e4710da07b2727e16d8671
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 32a20188058a77dd76882c24f78b5e3e19fe5d30afe867c4a7d2206828d098fc148fd21ccea1ad32331b84155f2a2064046fd2e0ba83a81e620989d2db389ce2
|
7
|
+
data.tar.gz: 3122447e979ec0137085d3594ba8b20bdcf200572cfaa89a55344e90450dc8d5fb6f578ca112c0d10d75cdd9a734be8f57dcea0ae87484a1f645290ba268f8e4
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "liquid"
|
2
|
+
|
3
|
+
module JekyllFlantPlugins
|
4
|
+
module SnippetCut
|
5
|
+
class SnippetCutTag < Liquid::Block
|
6
|
+
@@DEFAULTS = {
|
7
|
+
:name => 'changeme.yaml',
|
8
|
+
:url => '/changeme.yaml',
|
9
|
+
:limited => false
|
10
|
+
}
|
11
|
+
|
12
|
+
def self.DEFAULTS
|
13
|
+
return @@DEFAULTS
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(tag_name, raw_markup, tokens)
|
17
|
+
super
|
18
|
+
@raw_markup = raw_markup
|
19
|
+
@config = {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def render(context)
|
23
|
+
@markup = Liquid::Template
|
24
|
+
.parse(@raw_markup)
|
25
|
+
.render(context)
|
26
|
+
.gsub(%r!\\\{\\\{|\\\{\\%!, '\{\{' => "{{", '\{\%' => "{%")
|
27
|
+
.strip
|
28
|
+
|
29
|
+
site = context.registers[:site]
|
30
|
+
lang = context.registers[:page]['lang']
|
31
|
+
|
32
|
+
override_config(@@DEFAULTS)
|
33
|
+
|
34
|
+
params = @markup.scan /([a-z]+)\=\"(.+?)\"/
|
35
|
+
if params.size > 0
|
36
|
+
config = {}
|
37
|
+
params.each do |param|
|
38
|
+
config[param[0].to_sym] = param[1]
|
39
|
+
end
|
40
|
+
override_config(config)
|
41
|
+
end
|
42
|
+
|
43
|
+
content = super
|
44
|
+
rendered_content = Jekyll::Converters::Markdown::KramdownParser.new(Jekyll.configuration()).convert(content)
|
45
|
+
|
46
|
+
%Q(
|
47
|
+
<div class="snippetcut#{@config[:limited] ? ' snippetcut_limited' : ''}" data-snippetcut>
|
48
|
+
<div class="snippetcut__title">#{if (@config[:url]!='#') then "<a href=\""+@config[:url]+"\" target=\"_blank\" class=\"snippetcut__title-name\" data-snippetcut-name>" else "<span class=\"snippetcut__title-name-text\" data-snippetcut-name>" end}#{@config[:name]}#{if (@config[:url]!='#') then "</a>" else "</span>" end}
|
49
|
+
<a href="javascript:void(0)" class="snippetcut__title-btn" data-snippetcut-btn-name>#{ site.data.dig('i18n', 'copy_filename', lang) ? site.data['i18n']['copy_filename'][lang] : site.data['global']['i18n']['copy_filename'][lang].capitalize }</a>
|
50
|
+
<a href="javascript:void(0)" class="snippetcut__title-btn" data-snippetcut-btn-text>#{ site.data.dig('i18n', 'copy_content', lang) ? site.data['i18n']['copy_content'][lang] : site.data['global']['i18n']['copy_content'][lang].capitalize }</a>
|
51
|
+
</div>
|
52
|
+
<div class="highlight">
|
53
|
+
#{rendered_content}
|
54
|
+
</div>
|
55
|
+
<div class="snippetcut__raw" data-snippetcut-text>#{CGI::escapeHTML(remove_excessive_newlines(content.strip.gsub(%r!^```[a-zA-Z0-9]*!,'')))}</div>
|
56
|
+
</div>
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def override_config(config)
|
63
|
+
config.each{ |key,value| @config[key] = value }
|
64
|
+
end
|
65
|
+
|
66
|
+
def remove_excessive_newlines(text)
|
67
|
+
return text.sub(/^(\s*\R)*/, "").rstrip()
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-flant-plugins
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Artem Kladov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: liquid
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '4.0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '4.0'
|
47
|
+
description:
|
48
|
+
email:
|
49
|
+
- artem.kladov@flant.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- lib/jekyll-flant-plugins.rb
|
55
|
+
- lib/jekyll-flant-plugins/snippetcut.rb
|
56
|
+
- lib/jekyll-flant-plugins/version.rb
|
57
|
+
homepage: https://github.com/flant/website-core
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata:
|
61
|
+
homepage_uri: https://github.com/flant/website-core
|
62
|
+
source_code_uri: https://github.com/flant/website-core
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 2.7.0
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubygems_version: 3.1.4
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: The Jekyll Plugins for using on the Flant Europe (flant.com) sites
|
82
|
+
test_files: []
|