3
3
require "nokogiri"
4
4
require "octokit"
5
5
require "pathname"
6
- require "open-uri"
7
6
8
7
def expand ( content , path , &get_content )
9
8
content . gsub ( /include::(\S +)\[ \] / ) do |line |
@@ -31,8 +30,6 @@ task reset_book2: :environment do
31
30
end
32
31
33
32
def genbook ( code , &get_content )
34
- template_dir = Rails . root . join ( "templates" )
35
-
36
33
nav = '<div id="nav"><a href="[[nav-prev]]">prev</a> | <a href="[[nav-next]]">next</a></div>'
37
34
38
35
progit = get_content . call ( "progit.asc" )
@@ -73,7 +70,7 @@ def genbook(code, &get_content)
73
70
end
74
71
75
72
begin
76
- l10n_file = open ( "https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/data/locale/attributes-#{ code } .adoc" ) . read
73
+ l10n_file = URI . open ( "https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/data/locale/attributes-#{ code } .adoc" ) . read
77
74
rescue
78
75
l10n_file = ""
79
76
end
@@ -83,12 +80,12 @@ def genbook(code, &get_content)
83
80
# revert internal links decorations for ebooks
84
81
content . gsub! ( /<<.*?\# (.*?)>>/ , "<<\\ 1>>" )
85
82
86
- asciidoc = Asciidoctor ::Document . new ( content , template_dir : template_dir , attributes : { "lang" => code } )
83
+ asciidoc = Asciidoctor ::Document . new ( content , attributes : { "lang" => code } )
87
84
html = asciidoc . render
88
85
alldoc = Nokogiri ::HTML ( html )
89
86
number = 1
90
87
91
- Book . destroy_all ( edition : 2 , code : code )
88
+ Book . where ( edition : 2 , code : code ) . destroy_all
92
89
book = Book . create ( edition : 2 , code : code )
93
90
94
91
alldoc . xpath ( "//div[@class='sect1']" ) . each_with_index do |entry , index |
0 commit comments