wip
This commit is contained in:
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
Executable
+51
@@ -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()
|
||||
@@ -22,6 +22,7 @@ serveIndex = (request, response)->
|
||||
response.set 'Content-Type', 'text/html'
|
||||
response.sendFile 'index.html', root:ROOT
|
||||
|
||||
app.get '/', serveIndex
|
||||
app.get '/browse(/*)?', serveIndex
|
||||
app.get '/configure(/*)?', serveIndex
|
||||
app.get '/craft(/*)?', serveIndex
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user