jekyll-theme-pages 0.1.0

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.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +21 -0
  4. data/README.md +40 -0
  5. data/Rakefile +10 -0
  6. data/lib/jekyll-theme-pages.rb +70 -0
  7. metadata +112 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 218ee851d9d8ca52c858f58fcc1cfa86293df295
4
+ data.tar.gz: 2153af288865b4aec17354dfde5c68abaa4d3248
5
+ SHA512:
6
+ metadata.gz: fad74ec2af5f031b11d15c83bae1b09963b023451db6e14728040aa8b99384249c99be02d2f2082a0ce3d66601eadc96357658cba856880af531a6d94164e285
7
+ data.tar.gz: c1f9b228fa11a1a5371278cecbfd851c1c4f41c9dadd0c6fb259b1ce5e5c12305b84b37a65cf3679f54ba7afa22e5dff080ec5b07f943d52b8d8f476b3af5cda
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-theme-assets.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Pavel Tsurbeleu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # Jekyll::Theme::Assets
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'jekyll-theme-pages'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install jekyll-theme-pages
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-theme-assets. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,70 @@
1
+ module Jekyll
2
+ # Fetches and injects theme pages
3
+ class ThemePagesGenerator < Generator
4
+ # Safe
5
+ safe true
6
+ # Attributes
7
+ attr_reader :site
8
+
9
+ def generate(site)
10
+ # Activated only if theme is defined
11
+ return unless site.theme
12
+ # Init attributes
13
+ @site, base = site, site.theme.root
14
+
15
+ # TODO: Find out a way to share the code
16
+ dot_files = Dir.chdir(base) { filter_entries(Dir["*.*"], base) }
17
+ dot_pages = dot_files.select do |file|
18
+ Utils.has_yaml_header?(@site.in_theme_dir(base, file))
19
+ end
20
+ dot_static_files = dot_files - dot_pages
21
+
22
+ retrieve_pages(base, dot_pages)
23
+ retrieve_static_files(base, dot_static_files)
24
+ end
25
+
26
+ private
27
+ # Filter out any files/directories that are hidden or backup files (start
28
+ # with "." or "#" or end with "~"), or contain site content (start with "_"),
29
+ # or are excluded in the site configuration, unless they are web server
30
+ # files such as '.htaccess'.
31
+ #
32
+ # entries - The Array of String file/directory entries to filter.
33
+ # base_directory - The string representing the optional base directory.
34
+ #
35
+ # Returns the Array of filtered entries.
36
+ def filter_entries(entries, base_directory = nil)
37
+ EntryFilter.new(site, base_directory).filter(entries)
38
+ end
39
+
40
+ # Retrieve all the pages from the current directory,
41
+ # add them to the site and sort them.
42
+ #
43
+ # dir - The String representing the directory retrieve the pages from.
44
+ # dot_pages - The Array of pages in the dir.
45
+ #
46
+ # Returns nothing.
47
+ def retrieve_pages(dir, dot_pages)
48
+ theme_pages = []
49
+ dot_pages.each do |page|
50
+ theme_pages << Page.new(@site, dir, "/", page)
51
+ end
52
+ site.pages.concat(theme_pages)
53
+ end
54
+
55
+ # Retrieve all the static files from the current directory,
56
+ # add them to the site and sort them.
57
+ #
58
+ # dir - The directory retrieve the static files from.
59
+ # dot_static_files - The static files in the dir.
60
+ #
61
+ # Returns nothing.
62
+ def retrieve_static_files(dir, dot_static_files)
63
+ theme_static_files = []
64
+ dot_static_files.each do |file|
65
+ theme_static_files << StaticFile.new(@site, dir, "/", file)
66
+ end
67
+ site.static_files.concat(theme_static_files)
68
+ end
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-theme-pages
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pavel Tsurbeleu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-14 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: '3.0'
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.1'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.14'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.14'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: minitest
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '5.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '5.0'
75
+ description: A Jekyll plugin, that allows you to use pages defined in a gem-based
76
+ Jekyll theme.
77
+ email:
78
+ - pavel.tsurbeleu@me.com
79
+ executables: []
80
+ extensions: []
81
+ extra_rdoc_files: []
82
+ files:
83
+ - Gemfile
84
+ - LICENSE
85
+ - README.md
86
+ - Rakefile
87
+ - lib/jekyll-theme-pages.rb
88
+ homepage: https://github.com/ptsurbeleu/jekyll-theme-pages/
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.5.2
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Pages from a gem-based Jekyll theme
112
+ test_files: []