Skip to content

Commit fff1673

Browse files
authored
Merge pull request #1590 from git/fix_1589
Fix #1589
2 parents 7987e25 + 20cf2b1 commit fff1673

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/tasks/book2.rake

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require "nokogiri"
44
require "octokit"
55
require "pathname"
6-
require "open-uri"
76

87
def expand(content, path, &get_content)
98
content.gsub(/include::(\S+)\[\]/) do |line|
@@ -31,8 +30,6 @@ task reset_book2: :environment do
3130
end
3231

3332
def genbook(code, &get_content)
34-
template_dir = Rails.root.join("templates")
35-
3633
nav = '<div id="nav"><a href="[[nav-prev]]">prev</a> | <a href="[[nav-next]]">next</a></div>'
3734

3835
progit = get_content.call("progit.asc")
@@ -73,7 +70,7 @@ def genbook(code, &get_content)
7370
end
7471

7572
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
7774
rescue
7875
l10n_file = ""
7976
end
@@ -83,12 +80,12 @@ def genbook(code, &get_content)
8380
# revert internal links decorations for ebooks
8481
content.gsub!(/<<.*?\#(.*?)>>/, "<<\\1>>")
8582

86-
asciidoc = Asciidoctor::Document.new(content, template_dir: template_dir, attributes: { "lang" => code})
83+
asciidoc = Asciidoctor::Document.new(content, attributes: { "lang" => code})
8784
html = asciidoc.render
8885
alldoc = Nokogiri::HTML(html)
8986
number = 1
9087

91-
Book.destroy_all(edition: 2, code: code)
88+
Book.where(edition: 2, code: code).destroy_all
9289
book = Book.create(edition: 2, code: code)
9390

9491
alldoc.xpath("//div[@class='sect1']").each_with_index do |entry, index|

0 commit comments

Comments
 (0)