aweplug 1.0.0.a3 → 1.0.0.a4
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.
@@ -11,7 +11,7 @@ module Aweplug
|
|
11
11
|
|
12
12
|
def initialize repository, layout, output_dir
|
13
13
|
@repo = repository
|
14
|
-
@output_dir = output_dir
|
14
|
+
@output_dir = Pathname.new output_dir
|
15
15
|
@layout = layout
|
16
16
|
end
|
17
17
|
|
@@ -22,22 +22,33 @@ module Aweplug
|
|
22
22
|
metadata = extract_metadata(file)
|
23
23
|
metadata[:commits] = commit_info @repo, Pathname.new(file)
|
24
24
|
|
25
|
-
page.send 'metadata=',
|
25
|
+
page.send 'metadata=', metadata
|
26
26
|
# TODO: Upload to DCP
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def extract_metadata(file)
|
31
|
-
(Kramdown::Document.new File.readlines(file).join, :input => 'QuickStartParser')
|
31
|
+
document = (::Kramdown::Document.new File.readlines(file).join, :input => 'QuickStartParser')
|
32
|
+
toc = ::Kramdown::Converter::Toc.convert(document.root)
|
33
|
+
toc_items = toc[0].children.select { |el| el.value.options[:level] == 2 }.map do |t|
|
34
|
+
{:id => t.attr[:id], :text => t.value.children.first.value}
|
35
|
+
end
|
36
|
+
|
37
|
+
metadata = document.root.options[:metadata]
|
38
|
+
metadata[:toc] = toc_items
|
39
|
+
metadata
|
32
40
|
end
|
33
41
|
|
34
42
|
def add_to_site(site, file)
|
43
|
+
page_path = Pathname.new file
|
35
44
|
page = site.engine.load_site_page file
|
36
45
|
page.layout = @layout
|
37
|
-
page.output_path = File.join @
|
46
|
+
page.output_path = File.join @output_dir, page_path.relative_path_from(Pathname.new @repo).dirname, 'index.html'
|
47
|
+
site.pages << page
|
38
48
|
page
|
39
49
|
end
|
40
50
|
end
|
41
51
|
end
|
42
52
|
end
|
43
53
|
end
|
54
|
+
|
@@ -12,47 +12,75 @@ module Kramdown
|
|
12
12
|
@block_parsers.unshift :target_product_metadata
|
13
13
|
@block_parsers.unshift :source_metadata
|
14
14
|
@block_parsers.unshift :summary_metadata
|
15
|
+
@block_parsers.unshift :product_metadata
|
16
|
+
@block_parsers.unshift :title_hack_metadata
|
15
17
|
|
16
18
|
@root.options[:metadata] = {:author => '', :level => '',
|
17
19
|
:technologies => '', :target_product => '',
|
18
20
|
:source => '', :summary => ''}
|
19
21
|
end
|
20
22
|
|
23
|
+
HEADER_ID=/(?:[ \t]+\{#([A-Za-z][\w:-]*)\})?/
|
24
|
+
SETEXT_HEADER_START = /^(#{OPT_SPACE}[^ \t].*?)#{HEADER_ID}[ \t]*?\n(=)+\s*?\n/
|
25
|
+
|
26
|
+
def parse_title_hack_metadata
|
27
|
+
return false if !after_block_boundary?
|
28
|
+
|
29
|
+
#start_line_number = @src.current_line_number
|
30
|
+
@src.pos += @src.matched_size
|
31
|
+
text, id, _ = @src[1], @src[2], @src[3]
|
32
|
+
text.strip!
|
33
|
+
el = new_block_el(:header, nil, nil, :level => 1, :raw_text => text, :location => 1)
|
34
|
+
add_text(text, el)
|
35
|
+
el.attr['id'] = id if id
|
36
|
+
|
37
|
+
@root.options[:metadata][:title] = text
|
38
|
+
#@tree.children << el
|
39
|
+
true
|
40
|
+
end
|
41
|
+
define_parser(:title_hack_metadata, SETEXT_HEADER_START)
|
42
|
+
|
21
43
|
def parse_author_metadata
|
22
44
|
@src.pos += @src.matched_size
|
23
|
-
@root.options[:metadata][:author] = @src[
|
45
|
+
@root.options[:metadata][:author] = @src[2].rstrip
|
24
46
|
end
|
25
|
-
define_parser(:author_metadata, /^(Author:)(\s
|
47
|
+
define_parser(:author_metadata, /^(Author:)#{OPT_SPACE}(.*?)\s*?\n/)
|
26
48
|
|
27
49
|
def parse_level_metadata
|
28
50
|
@src.pos += @src.matched_size
|
29
|
-
@root.options[:metadata][:level] = @src[
|
51
|
+
@root.options[:metadata][:level] = @src[2].rstrip
|
30
52
|
end
|
31
|
-
define_parser(:level_metadata, /^(Level:)(\s
|
53
|
+
define_parser(:level_metadata, /^(Level:)#{OPT_SPACE}(.*?)\s*?\n/)
|
32
54
|
|
33
55
|
def parse_technologies_metadata
|
34
56
|
@src.pos += @src.matched_size
|
35
|
-
@root.options[:metadata][:technologies] = @src[
|
57
|
+
@root.options[:metadata][:technologies] = @src[2].rstrip
|
36
58
|
end
|
37
|
-
define_parser(:technologies_metadata, /^(Technologies:)(\s
|
59
|
+
define_parser(:technologies_metadata, /^(Technologies:)#{OPT_SPACE}(.*?)\s*?\n/)
|
38
60
|
|
39
61
|
def parse_target_product_metadata
|
40
62
|
@src.pos += @src.matched_size
|
41
|
-
@root.options[:metadata][:target_product] = @src[
|
63
|
+
@root.options[:metadata][:target_product] = @src[2].rstrip
|
42
64
|
end
|
43
|
-
define_parser(:target_product_metadata, /^(Target Product:)(\s
|
65
|
+
define_parser(:target_product_metadata, /^(Target Product:)#{OPT_SPACE}(.*?)\s*?\n/)
|
44
66
|
|
45
67
|
def parse_source_metadata
|
46
68
|
@src.pos += @src.matched_size
|
47
|
-
@root.options[:metadata][:source] = @src[
|
69
|
+
@root.options[:metadata][:source] = @src[2][1..-2].rstrip
|
48
70
|
end
|
49
|
-
define_parser(:source_metadata, /^(Source:)(\s
|
71
|
+
define_parser(:source_metadata, /^(Source:)#{OPT_SPACE}(.*?)\s*?\n/)
|
50
72
|
|
51
73
|
def parse_summary_metadata
|
52
74
|
@src.pos += @src.matched_size
|
53
|
-
@root.options[:metadata][:summary] = @src[
|
75
|
+
@root.options[:metadata][:summary] = @src[2].rstrip
|
76
|
+
end
|
77
|
+
define_parser(:summary_metadata, /^(Summary:)#{OPT_SPACE}(.*?)\s*?\n/)
|
78
|
+
|
79
|
+
def parse_product_metadata
|
80
|
+
@src.pos += @src.matched_size
|
81
|
+
@root.options[:metadata][:product] = @src[2].rstrip
|
54
82
|
end
|
55
|
-
define_parser(:
|
83
|
+
define_parser(:product_metadata, /^(Product Versions:)#{OPT_SPACE}(.*?)\s*?\n/)
|
56
84
|
end
|
57
85
|
end
|
58
86
|
end
|
data/lib/aweplug/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aweplug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.a4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: octokit
|