Merge pull request #569 from git/fix-builds

Fix Builds
This commit is contained in:
Scott Chacon 2015-08-11 09:41:54 -07:00
Родитель 1dfab27251 1be6736047
Коммит 41cd34c2ad
4 изменённых файлов: 39 добавлений и 39 удалений

Просмотреть файл

@ -32,9 +32,7 @@ gem 'nokogiri'
gem 'compass-rails'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'less-rails-bootstrap'
gem 'sass-rails', '4.0.3'
gem 'therubyracer'
gem 'uglifier'
group :development do

Просмотреть файл

@ -60,7 +60,6 @@ GEM
execjs
coffee-script-source (1.7.1)
columnize (0.8.9)
commonjs (0.2.7)
compass (0.12.7)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
@ -106,14 +105,6 @@ GEM
kgio (2.9.2)
launchy (2.4.2)
addressable (~> 2.3)
less (2.5.1)
commonjs (~> 0.2.7)
less-rails (2.5.0)
actionpack (>= 3.1)
less (~> 2.5.0)
less-rails-bootstrap (3.2.0)
less-rails (~> 2.5.0)
libv8 (3.16.14.3)
loofah (2.0.1)
nokogiri (>= 1.5.9)
mail (2.6.3)
@ -170,7 +161,6 @@ GEM
rdoc (4.1.1)
json (~> 1.4)
redcarpet (3.2.3)
ref (1.0.5)
rest-client (1.6.8)
mime-types (~> 1.16)
rdoc (>= 2.4.2)
@ -222,9 +212,6 @@ GEM
rest-client (>= 1.4.0, < 1.7.0)
sequel (~> 3.20.0)
sinatra (~> 1.0.0)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
@ -274,7 +261,6 @@ DEPENDENCIES
jquery-rails
json
launchy
less-rails-bootstrap
memcachier
netrc
newrelic_rpm
@ -293,7 +279,6 @@ DEPENDENCIES
shoulda-matchers
sqlite3
taps
therubyracer
tilt
tire
uglifier

Просмотреть файл

@ -20,7 +20,7 @@ Rails.application.configure do
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
config.serve_static_assets = true
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier

Просмотреть файл

@ -17,31 +17,48 @@ task :genbook2 => :environment do
# Handle entries one by one
max_chapter = 0
# go through all the files and order them properly
chapters = {}
zip_file.glob("*.html").each do |entry|
if m = /(app|ch)(.*?).html/.match(entry.name)
puts entry.name
chapter_type = m[1]
chapter_number = m[2]
if chapter_type == 'app'
chapters["xapp#{chapter_number}"] = ['appendix', chapter_number.to_i, entry.name]
else
chapters["ch#{chapter_number}"] = ['chapter', chapter_number.to_i, entry.name]
end
appnumber = 0
chnumber = 0
ids = {}
toc = JSON.parse(zip_file.find_entry("build.json").get_input_stream.read)
navi = toc['navigations']['navigation']
navi.each_with_index do |chthing, index|
if chthing['type'] == 'appendix'
appnumber += 1
chapters["xapp#{index}"] = ['appendix', appnumber, chthing['href'], chthing['label']]
end
if chthing['type'] == 'chapter'
chnumber += 1
chapters["ch#{index}"] = ['chapter', chnumber, chthing['href'], chthing['label']]
end
chthing['children'].each do |child|
ids[child['id']] = child['label']
end
end
# sort and create the numbers in order
number = 0
chapters.sort.each_with_index do |data, index|
number = index + 1
chapter_type, chapter_number, file = data[1]
chapters.sort.each_with_index do |entry, index|
p entry
chapter_type, chapter_number, file, title = entry[1]
p file
content = zip_file.find_entry(file).get_input_stream.read
doc = Nokogiri::HTML(content)
chapter = doc.at("section[@data-type=#{chapter_type}]")
chapter_title = doc.at("section[@data-type=#{chapter_type}] > h1").text
chapter_title = title
next if !chapter_title
next if !chapter_number
puts chapter_title
puts chapter_number
number = chapter_number
if chapter_type == 'appendix'
number = 100 + chapter_number
end
id_xref = chapter.attribute('id').to_s
pretext = "<a id=\"#{id_xref}\"></a>"
@ -62,9 +79,8 @@ task :genbook2 => :environment do
section = 1
chapter.search("section[@data-type=sect1]").each do |sec|
section_title = sec.attribute('data-pdf-bookmark')
id_xref = sec.attribute('id').to_s
section_title = ids[id_xref]
pretext += "<a id=\"#{id_xref}\"></a>"
html = pretext + sec.inner_html.to_s + nav
@ -128,11 +144,11 @@ task :genbook2 => :environment do
section += 1
pretext = ""
end # loop through sections
extra = schapter.sections.where("number >= #{section}")
extra.delete_all
#extra = schapter.sections.where("number >= #{section}")
#extra.delete_all
end # if it's a chapter
extra = book.chapters.where("number > #{number}")
extra.delete_all
#extra = book.chapters.where("number > #{number}")
#extra.delete_all
end
book.processed = true
@ -149,6 +165,7 @@ end
def self.download(url)
puts "downloading #{url}"
#return "/Users/schacon/github/progit/gitscm2/ugh/progit-en.661.zip" # for testing
file = File.new("#{Rails.root}/tmp/download" + Time.now.to_i.to_s + Random.new.rand(100).to_s, 'wb')
begin
uri = URI.parse(url)