Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bArgs = {...}
- local ignoreScripts, isScript = false
- local handle, details, contents = nil
- local function loadPage(url)
- if not fs.exists(url) then
- if fs.isDir(url) then
- if fs.exists(url.."/index") then
- return fs.open(url.."/index", "r"), nil
- elseif fs.exists(url.."/index.php") then
- return fs.open(url.."/index.php", "r"), nil
- end
- else
- return nil, "404: File not found!"
- end
- elseif fs.exists(url..".php") then
- return fs.open(url..".php", "r"), nil
- elseif fs.exists(url..".script") then
- if ignoreScripts then
- return nil, "Scripts are unavailable; Try not using the -ns parameter"
- end
- isScript = true
- print("Running "..url..".script")
- shell.run(url..".script")
- else
- return fs.open(url, "r"), nil
- end
- end
- if #bArgs < 1 then
- print("browser < url > [ -ns/--no-scripts ]")
- else
- if bArgs[2] == "--no-scripts" or bArgs[2] == "-ns" then
- ignoreScripts = true
- end
- handle, details = loadPage(bArgs[1])
- if handle and details == nil then
- contents = handle.readAll()
- shell.run("clear")
- term.setCursorPos(1,1)
- print(contents)
- os.pullEventRaw("key")
- handle.close()
- elseif isScript then
- return
- elseif details ~= nil then
- printError([[
- Atom Browser has crashed!
- Details:
- ]]..details)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement