jekyll-language-plugin 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-language-plugin.rb +12 -51
- data/lib/jekyll/language-plugin.rb +24 -0
- data/lib/jekyll/language-plugin/date_localizer.rb +3 -0
- data/lib/jekyll/language-plugin/filters.rb +10 -0
- data/lib/jekyll/language-plugin/filters/language_date.rb +3 -0
- data/lib/jekyll/language-plugin/language_data.rb +7 -4
- data/lib/jekyll/language-plugin/liquid_context.rb +3 -0
- data/lib/jekyll/language-plugin/loaders.rb +12 -0
- data/lib/jekyll/language-plugin/loaders/base_loader.rb +3 -0
- data/lib/jekyll/language-plugin/loaders/builtin_data_loader.rb +3 -1
- data/lib/jekyll/language-plugin/loaders/jekyll_data_loader.rb +3 -0
- data/lib/jekyll/language-plugin/plugin_error.rb +3 -0
- data/lib/jekyll/language-plugin/tags.rb +12 -0
- data/lib/jekyll/language-plugin/tags/language.rb +3 -0
- data/lib/jekyll/language-plugin/tags/language_include.rb +3 -0
- data/lib/jekyll/language-plugin/tags/language_name.rb +3 -0
- data/lib/jekyll/language-plugin/version.rb +4 -1
- data/lib/jekyll/language_document.rb +3 -0
- data/lib/jekyll/language_page.rb +3 -0
- data/lib/jekyll/language_properties.rb +3 -0
- data/lib/jekyll/language_reader.rb +11 -0
- data/lib/jekyll/patches.rb +5 -0
- data/lib/jekyll/patches/jekyll/site.rb +8 -0
- data/lib/jekyll/patches/jekyll/url.rb +11 -0
- data/lib/jekyll/readers/language_collection_reader.rb +39 -0
- data/lib/jekyll/readers/language_page_reader.rb +3 -0
- data/lib/jekyll/readers/language_post_reader.rb +3 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efc4684030b0b9565cbb4bbf8d14dbd632bf7fd2
|
4
|
+
data.tar.gz: bacc98469b5dc3315cbac9e7c2c12a8d4740f7b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a87f90185e2ab6991395a5250b5699b9e6f23ae923bdc91c883d3dab423aeca59d3abe2bd8177a0042016d9a99b038d7d36db828f6ade326fe2d2aa7e05fab03
|
7
|
+
data.tar.gz: ddc18a8cc3f387876d838fea2e724d0994e85fb170386e74e216134d17cc4262d3e8c16c75a61c23b4d8caa308a2c58da90ca347d9be8343714a3a60e7a34eba
|
@@ -1,61 +1,22 @@
|
|
1
|
-
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Encoding: utf-8
|
2
3
|
|
3
|
-
|
4
|
-
autoload :LanguageReader, 'jekyll/language_reader.rb'
|
5
|
-
autoload :LanguageProperties, 'jekyll/language_properties.rb'
|
6
|
-
autoload :LanguagePage, 'jekyll/language_page.rb'
|
7
|
-
autoload :LanguageDocument, 'jekyll/language_document.rb'
|
8
|
-
autoload :LanguagePageReader, 'jekyll/readers/language_page_reader.rb'
|
9
|
-
autoload :LanguagePostReader, 'jekyll/readers/language_post_reader.rb'
|
4
|
+
require 'jekyll'
|
10
5
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
module Loaders
|
21
|
-
autoload :BaseLoader, 'jekyll/language-plugin/loaders/base_loader.rb'
|
22
|
-
end
|
23
|
-
|
24
|
-
class << self
|
25
|
-
def register_loader(loader)
|
26
|
-
LanguageData.register_loader(loader)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# require data built-in loaders
|
33
|
-
require 'jekyll/language-plugin/loaders/jekyll_data_loader.rb'
|
34
|
-
require 'jekyll/language-plugin/loaders/builtin_data_loader.rb'
|
35
|
-
|
36
|
-
# require liquid tags and filters
|
37
|
-
Dir[File.join(File.dirname(__FILE__), 'jekyll/language-plugin/tags/*.rb')].each{ |f| require f }
|
38
|
-
require 'jekyll/language-plugin/filters/language_date.rb'
|
6
|
+
require_relative 'jekyll/language_reader.rb'
|
7
|
+
require_relative 'jekyll/language_properties.rb'
|
8
|
+
require_relative 'jekyll/language_page.rb'
|
9
|
+
require_relative 'jekyll/language_document.rb'
|
10
|
+
require_relative 'jekyll/readers/language_collection_reader.rb'
|
11
|
+
require_relative 'jekyll/readers/language_page_reader.rb'
|
12
|
+
require_relative 'jekyll/readers/language_post_reader.rb'
|
13
|
+
require_relative 'jekyll/patches'
|
14
|
+
require_relative 'jekyll/language-plugin'
|
39
15
|
|
40
16
|
Jekyll::Hooks.register :site, :after_reset do |site|
|
41
17
|
# replace Jekyll::Reader with Jekyll::LanguageReader extension
|
42
18
|
site.reader = Jekyll::LanguageReader.new(site)
|
43
19
|
|
44
|
-
# add dynamic languageData property
|
45
|
-
unless site.respond_to?(:languageData) && site.respond_to?(:languageData=)
|
46
|
-
site.class.module_eval { attr_accessor :languageData }
|
47
|
-
end
|
48
|
-
|
49
20
|
# create new language data instance
|
50
21
|
site.languageData = Jekyll::LanguagePlugin::LanguageData.new(site)
|
51
22
|
end
|
52
|
-
|
53
|
-
# monkey patch URL.sanitize_url for handling of triple slashes
|
54
|
-
module Jekyll
|
55
|
-
class URL
|
56
|
-
# optimized version by Jordon Bedwell
|
57
|
-
def sanitize_url(str)
|
58
|
-
"/" + str.gsub(/\/{2,}/, "/").gsub(%r!\.+\/|\A/+!, "")
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Encoding: utf-8
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
module LanguagePlugin
|
6
|
+
|
7
|
+
# plugin requires
|
8
|
+
require_relative 'language-plugin/plugin_error'
|
9
|
+
require_relative 'language-plugin/language_data'
|
10
|
+
require_relative 'language-plugin/liquid_context'
|
11
|
+
require_relative 'language-plugin/date_localizer'
|
12
|
+
require_relative 'language-plugin/version'
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def register_loader(loader)
|
16
|
+
LanguageData.register_loader(loader)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
require_relative 'language-plugin/loaders'
|
21
|
+
require_relative 'language-plugin/tags'
|
22
|
+
require_relative 'language-plugin/filters'
|
23
|
+
end
|
24
|
+
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Encoding: utf-8
|
3
|
+
|
1
4
|
module Jekyll
|
2
5
|
module LanguagePlugin
|
3
6
|
class LanguageData
|
@@ -9,18 +12,18 @@ module Jekyll
|
|
9
12
|
end
|
10
13
|
|
11
14
|
def get(key, language)
|
12
|
-
|
15
|
+
inject_loader(language) do |loader|
|
13
16
|
loader.get(key, language)
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
20
|
def get_with_placeholders(key, tokens, language)
|
18
|
-
|
21
|
+
inject_loader(language) do |loader|
|
19
22
|
loader.get_with_placeholders(key, tokens, language)
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
23
|
-
def
|
26
|
+
def inject_loader(language)
|
24
27
|
self.class.loaders.inject(nil) do |result, loader|
|
25
28
|
unless l_inst = @l_inst_ary.detect { |l| l.is_a?(loader) }
|
26
29
|
l_inst = loader.new(@site)
|
@@ -28,7 +31,7 @@ module Jekyll
|
|
28
31
|
end
|
29
32
|
|
30
33
|
l_inst.load(language) unless l_inst.loaded?(language)
|
31
|
-
result = yield
|
34
|
+
result = yield l_inst
|
32
35
|
break result unless result.nil?
|
33
36
|
end
|
34
37
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Encoding: utf-8
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
module LanguagePlugin
|
6
|
+
module Loaders
|
7
|
+
require_relative 'loaders/base_loader.rb'
|
8
|
+
require_relative 'loaders/jekyll_data_loader.rb'
|
9
|
+
require_relative 'loaders/builtin_data_loader.rb'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Encoding: utf-8
|
3
|
+
|
1
4
|
require 'rubygems'
|
2
5
|
require 'yaml'
|
3
6
|
|
@@ -35,5 +38,4 @@ module Jekyll
|
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
38
|
-
$stdout.puts("Registering!")
|
39
41
|
Jekyll::LanguagePlugin.register_loader(Jekyll::LanguagePlugin::Loaders::BuiltinDataLoader)
|
data/lib/jekyll/language_page.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Encoding: utf-8
|
3
|
+
|
1
4
|
module Jekyll
|
2
5
|
class LanguageReader < Reader
|
6
|
+
def read
|
7
|
+
@site.layouts = LayoutReader.new(site).read
|
8
|
+
read_directories
|
9
|
+
sort_files!
|
10
|
+
@site.data = DataReader.new(site).read(site.config['data_dir'])
|
11
|
+
LanguageCollectionReader.new(site).read
|
12
|
+
end
|
13
|
+
|
3
14
|
def retrieve_posts(dir)
|
4
15
|
site.posts.docs.concat(LanguagePostReader.new(site).read_posts(dir))
|
5
16
|
site.posts.docs.concat(LanguagePostReader.new(site).read_drafts(dir)) if site.show_drafts
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Encoding: utf-8
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
class LanguageCollectionReader < CollectionReader
|
6
|
+
def read
|
7
|
+
site.collections.each do |_, collection|
|
8
|
+
collection.read unless SPECIAL_COLLECTIONS.include?(collection.label)
|
9
|
+
collection.docs = collection.docs.flat_map do |document|
|
10
|
+
ldocuments = []
|
11
|
+
ldocument = LanguageDocument.new(document.path, { site: @site, collection: collection })
|
12
|
+
ldocument.read
|
13
|
+
|
14
|
+
if ldocument.languages
|
15
|
+
for language in ldocument.languages do
|
16
|
+
if ldocument.language == language
|
17
|
+
ldocuments << ldocument
|
18
|
+
elsif ldocument.language.nil?
|
19
|
+
ldocument.data['language'] = language
|
20
|
+
ldocuments << ldocument
|
21
|
+
else
|
22
|
+
ldocument2 = LanguageDocument.new(document.path, { site: @site, collection: collection })
|
23
|
+
ldocument2.read
|
24
|
+
ldocument2.data['language'] = language
|
25
|
+
ldocuments << ldocument2
|
26
|
+
end
|
27
|
+
end
|
28
|
+
elsif ldocument.language
|
29
|
+
ldocuments << ldocument
|
30
|
+
else
|
31
|
+
# no languages -> do not add extended Page
|
32
|
+
ldocuments << document
|
33
|
+
end
|
34
|
+
ldocuments
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-language-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Wochnik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -76,20 +76,28 @@ files:
|
|
76
76
|
- lib/jekyll-language-plugin.rb
|
77
77
|
- lib/jekyll/language-plugin/date_localizer.rb
|
78
78
|
- lib/jekyll/language-plugin/filters/language_date.rb
|
79
|
+
- lib/jekyll/language-plugin/filters.rb
|
79
80
|
- lib/jekyll/language-plugin/language_data.rb
|
80
81
|
- lib/jekyll/language-plugin/liquid_context.rb
|
81
82
|
- lib/jekyll/language-plugin/loaders/base_loader.rb
|
82
83
|
- lib/jekyll/language-plugin/loaders/builtin_data_loader.rb
|
83
84
|
- lib/jekyll/language-plugin/loaders/jekyll_data_loader.rb
|
85
|
+
- lib/jekyll/language-plugin/loaders.rb
|
84
86
|
- lib/jekyll/language-plugin/plugin_error.rb
|
85
87
|
- lib/jekyll/language-plugin/tags/language.rb
|
86
88
|
- lib/jekyll/language-plugin/tags/language_include.rb
|
87
89
|
- lib/jekyll/language-plugin/tags/language_name.rb
|
90
|
+
- lib/jekyll/language-plugin/tags.rb
|
88
91
|
- lib/jekyll/language-plugin/version.rb
|
92
|
+
- lib/jekyll/language-plugin.rb
|
89
93
|
- lib/jekyll/language_document.rb
|
90
94
|
- lib/jekyll/language_page.rb
|
91
95
|
- lib/jekyll/language_properties.rb
|
92
96
|
- lib/jekyll/language_reader.rb
|
97
|
+
- lib/jekyll/patches/jekyll/site.rb
|
98
|
+
- lib/jekyll/patches/jekyll/url.rb
|
99
|
+
- lib/jekyll/patches.rb
|
100
|
+
- lib/jekyll/readers/language_collection_reader.rb
|
93
101
|
- lib/jekyll/readers/language_page_reader.rb
|
94
102
|
- lib/jekyll/readers/language_post_reader.rb
|
95
103
|
- data/lang/bg.yml
|