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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 474a7a7e024e8fdae812794d6970da82887655c2
4
- data.tar.gz: 4a8f30df701b2530cda2ce3339a95bb234983a25
3
+ metadata.gz: efc4684030b0b9565cbb4bbf8d14dbd632bf7fd2
4
+ data.tar.gz: bacc98469b5dc3315cbac9e7c2c12a8d4740f7b7
5
5
  SHA512:
6
- metadata.gz: b029db16f1aa3a05c7e4d60a0d60d849bdac2ca87541cdea1d71308c71d5c336b841642f750b52261e62e11438f75026d4cd242e54fbdb27ead31789fee6d635
7
- data.tar.gz: 5146e49851e0bd2e50bc124e446c4ee41faae2cf992f1854784cac6d848c0637746fe440b43b2e7680b3978bc8cf99aeab5577ce3b557abcaef8b2daf71319cd
6
+ metadata.gz: a87f90185e2ab6991395a5250b5699b9e6f23ae923bdc91c883d3dab423aeca59d3abe2bd8177a0042016d9a99b038d7d36db828f6ade326fe2d2aa7e05fab03
7
+ data.tar.gz: ddc18a8cc3f387876d838fea2e724d0994e85fb170386e74e216134d17cc4262d3e8c16c75a61c23b4d8caa308a2c58da90ca347d9be8343714a3a60e7a34eba
@@ -1,61 +1,22 @@
1
- module Jekyll
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
2
3
 
3
- # internal requires for plugin
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
- module LanguagePlugin
12
-
13
- # plugin requires
14
- autoload :PluginError, 'jekyll/language-plugin/plugin_error.rb'
15
- autoload :LanguageData, 'jekyll/language-plugin/language_data.rb'
16
- autoload :LiquidContext, 'jekyll/language-plugin/liquid_context.rb'
17
- autoload :DateLocalizer, 'jekyll/language-plugin/date_localizer.rb'
18
- autoload :VERSION, 'jekyll/language-plugin/version'
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 DateLocalizer
@@ -0,0 +1,10 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
4
+ module Jekyll
5
+ module LanguagePlugin
6
+ module Filters
7
+ require_relative 'filters/language_date'
8
+ end
9
+ end
10
+ 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
  module Filters
@@ -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
- inject_loaders(language) do |result, loader|
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
- inject_loaders(language) do |result, loader|
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 inject_loaders(language)
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 result, l_inst
34
+ result = yield l_inst
32
35
  break result unless result.nil?
33
36
  end
34
37
  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
  module LiquidContext
@@ -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
  module Jekyll
2
5
  module LanguagePlugin
3
6
  module Loaders
@@ -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)
@@ -1,3 +1,6 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
1
4
  module Jekyll
2
5
  module LanguagePlugin
3
6
  module Loaders
@@ -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 PluginError < RuntimeError
@@ -0,0 +1,12 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
4
+ module Jekyll
5
+ module LanguagePlugin
6
+ module Tags
7
+ require_relative 'tags/language'
8
+ require_relative 'tags/language_include'
9
+ require_relative 'tags/language_name'
10
+ end
11
+ end
12
+ 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
  module Tags
@@ -1,3 +1,6 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
1
4
  module Jekyll
2
5
  module LanguagePlugin
3
6
  module Tags
@@ -1,3 +1,6 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
1
4
  module Jekyll
2
5
  module LanguagePlugin
3
6
  module Tags
@@ -1,5 +1,8 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
1
4
  module Jekyll
2
5
  module LanguagePlugin
3
- VERSION = '1.2.3'
6
+ VERSION = '1.3.0'
4
7
  end
5
8
  end
@@ -1,3 +1,6 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
1
4
  module Jekyll
2
5
  class LanguageDocument < Document
3
6
  include LanguageProperties
@@ -1,3 +1,6 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
1
4
  module Jekyll
2
5
  class LanguagePage < Page
3
6
  include LanguageProperties
@@ -1,3 +1,6 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
1
4
  module Jekyll
2
5
  module LanguageProperties
3
6
  def language
@@ -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,5 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
4
+ require_relative 'patches/jekyll/site'
5
+ require_relative 'patches/jekyll/url'
@@ -0,0 +1,8 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
4
+ module Jekyll
5
+ class Site
6
+ attr_accessor :languageData
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
4
+ module Jekyll
5
+ class URL
6
+ # optimized version by Jordon Bedwell
7
+ def sanitize_url(str)
8
+ "/" + str.gsub(/\/{2,}/, "/").gsub(%r!\.+\/|\A/+!, "")
9
+ end
10
+ end
11
+ end
@@ -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
@@ -1,3 +1,6 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
1
4
  module Jekyll
2
5
  class LanguagePageReader < PageReader
3
6
  alias_method :read_orig, :read
@@ -1,3 +1,6 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
1
4
  module Jekyll
2
5
  class LanguagePostReader < PostReader
3
6
  alias_method :read_content_orig, :read_content
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.2.3
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-15 00:00:00.000000000 Z
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