This commit is contained in:
Andrew Miner
2015-03-06 22:31:29 -08:00
parent 6a7f542414
commit a9dc4e3a26
13 changed files with 982 additions and 0 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env phantomjs --web-security=false
fs = require 'fs'
system = require 'system'
webPage = require 'webpage'
if system.args.length isnt 2
console.error 'USAGE: prerender <path>'
phantom.exit 1
########################################################################################################################
urlsFileName = system.args[1]
urls = fs.read(urlsFileName).split('\n')
outputDir = 'prerender'
currentPage = null
currentOutputPath = null
renderTime = 5000
urls = (url.trim() for url in urls when url.trim().length > 0)
if not fs.exists outputDir
fs.makeDirectory outputDir
startNextPage = ->
url = urls.pop()
if !url then phantom.exit()
path = "#{url}".replace(/http:\/\/[^/]*/, '').replace(/^\//, '')
url = "http://localhost:8000/#{path}"
currentOutputPath = "#{outputDir}/#{path}"
currentOutputPath = "#{outputDir}/index.html" if currentOutputPath is ''
if not fs.exists currentOutputPath
currentPage = webPage.create()
console.log "Opening #{url}..."
currentPage.open url, completePage()
else
setTimeout startNextPage, 0
completePage = (status)->
if status is 'fail'
console.error "Could not load #{url}"
startNextPage()
setTimeout (->
fs.write currentOutputPath, currentPage.content, 'w'
startNextPage()
), renderTime
startNextPage()
+1
View File
@@ -22,6 +22,7 @@ serveIndex = (request, response)->
response.set 'Content-Type', 'text/html' response.set 'Content-Type', 'text/html'
response.sendFile 'index.html', root:ROOT response.sendFile 'index.html', root:ROOT
app.get '/', serveIndex
app.get '/browse(/*)?', serveIndex app.get '/browse(/*)?', serveIndex
app.get '/configure(/*)?', serveIndex app.get '/configure(/*)?', serveIndex
app.get '/craft(/*)?', serveIndex app.get '/craft(/*)?', serveIndex
+10
View File
@@ -0,0 +1,10 @@
http://crafting-guide.com/browse/thermal_expansion/tin_ore
http://crafting-guide.com/browse/thermal_expansion/tinker_s_alloy_blend
http://crafting-guide.com/browse/thermal_expansion/tinker_s_alloy_block
http://crafting-guide.com/browse/thermal_expansion/tinker_s_alloy_gear
http://crafting-guide.com/browse/thermal_expansion/tinker_s_alloy_ingot
http://crafting-guide.com/browse/thermal_expansion/tinker_s_alloy_nugget
http://crafting-guide.com/browse/thermal_expansion/translocation_plate
http://crafting-guide.com/browse/thermal_expansion/tuberous_flux_capacitor
http://crafting-guide.com/browse/thermal_expansion/white_rockwool
http://crafting-guide.com/browse/thermal_expansion/yellow_rockwool