jekyll-readme-index 0.0.4 → 0.1.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-readme-index.rb +1 -0
- data/lib/jekyll-readme-index/generator.rb +28 -15
- data/lib/jekyll-readme-index/version.rb +1 -1
- data/lib/jekyll/static_file_ext.rb +10 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a6dbcea7f7b27ff87d656d95b87378598989165
|
4
|
+
data.tar.gz: 413e078182aab9e9a0116fbc8e6cf67c6758ff7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '07838efab593f1637a60272937fbed94b6234f6a2795681bee23217303034beae03ff65572ef16335bb02d4057332fc73bc6b1bcaf31b839a1019fbad85673a8'
|
7
|
+
data.tar.gz: 8e7b984a6bc9ca0e81ea42f2480917cb48f5378c6b88bcc234bb6f039c0c16ba290395ba6800ce3304e8840fbb1f44e0a9603769530966b9201af51bb13c8cac
|
data/lib/jekyll-readme-index.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module JekyllReadmeIndex
|
2
2
|
class Generator < Jekyll::Generator
|
3
|
-
|
4
|
-
INDEX_REGEX = %r!^/($|index\.(html?|xhtml|xml)$)!i
|
3
|
+
INDEX_REGEX = %r!$|index\.(html?|xhtml|xml)$!i
|
5
4
|
|
6
5
|
attr_accessor :site
|
7
6
|
|
@@ -15,27 +14,41 @@ module JekyllReadmeIndex
|
|
15
14
|
def generate(site)
|
16
15
|
@site = site
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
readmes.each do |readme|
|
18
|
+
next unless should_be_index?(readme)
|
19
|
+
site.pages << readme.to_page
|
20
|
+
end
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
# Returns an array of all READMEs as StaticFiles
|
26
|
+
def readmes
|
27
|
+
site.static_files.select { |file| file.relative_path =~ readme_regex }
|
26
28
|
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
# Should the given readme be the containing directory's index?
|
31
|
+
def should_be_index?(readme)
|
32
|
+
return false unless readme
|
33
|
+
!dir_has_index? File.dirname(readme.url)
|
30
34
|
end
|
31
35
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
# Does the given directory have an index?
|
37
|
+
#
|
38
|
+
# relative_path - the directory path relative to the site root
|
39
|
+
def dir_has_index?(relative_path)
|
40
|
+
relative_path << "/" unless relative_path.end_with? "/"
|
41
|
+
regex = %r!^#{Regexp.escape(relative_path)}#{INDEX_REGEX}!i
|
42
|
+
(site.pages + site.static_files).any? { |file| file.url =~ regex }
|
43
|
+
end
|
44
|
+
|
45
|
+
# Regexp to match a file path against to detect if the given file is a README
|
46
|
+
def readme_regex
|
47
|
+
@readmes_regex ||= %r!/readme(#{Regexp.union(markdown_converter.extname_list)})$!i
|
48
|
+
end
|
49
|
+
|
50
|
+
def markdown_converter
|
51
|
+
@markdown_converter ||= site.find_converter_instance(Jekyll::Converters::Markdown)
|
39
52
|
end
|
40
53
|
end
|
41
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-readme-index
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/jekyll-readme-index.rb
|
63
63
|
- lib/jekyll-readme-index/generator.rb
|
64
64
|
- lib/jekyll-readme-index/version.rb
|
65
|
+
- lib/jekyll/static_file_ext.rb
|
65
66
|
homepage: https://github.com/benbalter/jekyll-readme-index
|
66
67
|
licenses:
|
67
68
|
- MIT
|