Its opens tArgs[1] (the first augment) on the computers.
Scroll up and down with either the arrows or W and S.
Press Backspace, or End to Quit
Enter Brings up a list of URLs, but Firebox (read below) or some other program is necessary to download the page.
You can combine this with Firebox to open web pages from the internet. Just change the edit variable in firebox to this program. and then run "Firebox http://put.somesite.here"
pastebin get nm5sT4KD html
Spoiler
--[[
Intializing
]]--
local tArgs = { ... }
veiw = "page"
shell.run("clear")
file = io.open( tArgs[1] )
split = function(s, pattern, maxsplit)
local pattern = pattern or ' '
local maxsplit = maxsplit or -1
local s = s
local t = {}
local patsz = #pattern
while maxsplit ~= 0 do
local curpos = 1
local found = string.find(s, pattern)
if found ~= nil then
table.insert(t, string.sub(s, curpos, found - 1))
curpos = found + patsz
s = string.sub(s, curpos)
else
table.insert(t, string.sub(s, curpos))
break
end
maxsplit = maxsplit - 1
if maxsplit == 0 then
table.insert(t, string.sub(s, curpos - patsz - 1))
end
end
return t
end
--[[
Reading Html
]]--
-- where to find links
herf = {"herf='(.-)'", "Herf='(.-)'", "HERF='(.-)'",
"herf=\"(.-)\"", "Href=\"(.-)\"", "HREF=\"(.-)\"",
"herf=(.-) ", "Href=(.-) ", "HREF=(.-) ",
"herf=(.-)>", "Href=(.-)>", "HREF=(.-)>",
"href='(.-)'", "Href='(.-)'", "HREF='(.-)'",
"href=\"(.-)\"", "Herf=\"(.-)\"", "HERF=\"(.-)\"",
"href=(.-)>", "Herf=(.-)>", "HERF=(.-)>",
"href=(.-) ", "Herf=(.-) ", "HERF=(.-) ",
"src='(.-)'", "Src='(.-)'", "SRC='(.-)'",
"src=\"(.-)\"", "Src=\"(.-)\"", "SRC=\"(.-)\"",
"src=(.-)>", "Src=(.-)>", "SRC=(.-)>",
"src=(.-) ", "Src=(.-) ", "SRC=(.-) ",
}
-- Tags to remove
remove = {"<!DOCTYPE(.-)>", "<!doctype(.-)>",
"<!--(.-)-->", "<!--(.-)-->",
"<html(.-)>", "<HTML(.-)>", "</html>", "</HTML>",
"<head>(.-)</head>", "<HEAD>(.-)</HEAD>",
"<body>", "<body(.-)>", "</body>", "<BODY>", "<BODY(.-)>", "</BODY>",
"<HEAD>(.-)</HEAD>",
"<form(.-)>", "</form>", "<FORM(.-)>", "</FORM>",
"<input(.-)>", "</input>", "<INPUT(.-)>", "</INPUT>",
"<script>(.-)</script>","<SCRIPT>(.-)</SCRIPT>",
"<script(.-)>", "</script>", "<SCRIPT(.-)>", "</SCRIPT>",
"<span(.-)>", "</span>", "<SPAN(.-)>", "</SPAN>",
"<div(.-)</div>", "<div(.-)>", "</div>",
"<Iframe(.-)</Iframe>", "<iframe(.-)</iframe>",
"<a(.-)>", "</a>", "<A(.-)>", "</A>",
"<TH>", "<TH(.-)>", "</TH>", "<th>", "<th(.-)>", "</th>",
"<img(.-)>", "</img>", "<IMG(.-)>", "</IMG>",
"<TD>", "<TD(.-)>", "</TD>", "<td>", "<td(.-)>", "</td>",
"<ol>", "<ol(.-)>", "</ol>", "<OL>", "<OL(.-)>", "</OL>",
"<sub>", "</sub>", "<SUB>", "</SUB>",
"</ul>", "</UL>",
"</NAV>", "</Nav>", "</nav>",
"<FOOTER>", "<FOOTER(.-)>", "</FOOTER>",
"<Footer>", "<Footer(.-)>", "</Footer>",
"<footer>", "<footer(.-)>", "</footer>",
}
-- Bullets
Bullets = { "<li>", "<LI>", "<li(.-)>", "<LI(.-)>" }
-- Tags to add spaces too
newline = {"<br(.-)>", "<BR(.-)>", "<br />", "<BR />", "<br/>", "<BR/>", "</br>", "</BR>",
"<h1>", "<h1(.-)>", "</h1>", "<H1>", "<H1(.-)>", "</H1>",
"<h2>", "<h2(.-)>", "</h2>", "<H2>", "<H2(.-)>", "</H2>",
"<h3>", "<h3(.-)>", "</h3>", "<H3>", "<H3(.-)>", "</H3>",
"<h4>", "<h4(.-)>", "</h4>", "<H4>", "<H4(.-)>", "</H4>",
"<h5>", "<h5(.-)>", "</h5>", "<H5>", "<H5(.-)>", "</H5>",
"<HEADER>", "<HEADER(.-)>", "</HEADER>",
"<Header>", "<Header(.-)>", "</Header>",
"<header>", "<header(.-)>", "</header>",
"<ARTICLE>", "<ARTICLE(.-)>", "</ARTICLE>",
"<Article>", "<Article(.-)>", "</Article>",
"<article>", "<article(.-)>", "</article>",
"<p(.-)>", "</p>", "<P(.-)>", "</P>",
"<TR(.-)>", "</TR>", "<tr(.-)>", "</tr>",
"<TABLE(.-)>", "<Table(.-)>", "<table(.-)>", "</TABLE>", "</Table>", "</table>",
"<ul>", "<UL>", "</li>", "</LI>"
}
-- Predefing Variables
htmlpage = ""
links = {"None"}
viewpage = {}
center={}
hr={}
centerenabled = false
-- Reading filedata
while true do
filedata = file:read()
if filedata then
htmlpage = htmlpage .. filedata
else break end
end
file:close()
-- Get all outgoing links
i = 1
ia = 1
j = 1
while herf[j] do
while string.find(htmlpage, herf[j]) do
links[ia] = string.match(htmlpage, herf[j])
htmlpage = string.gsub(htmlpage, herf[j], "", 1)
ia = ia + 1
end
j = j + 1
end
-- Remove useless tags
i = 1
while remove[i] do
while string.find(htmlpage, remove[i]) do
htmlpage = string.gsub(htmlpage, remove[i], "")
end
i = i + 1
end
-- HTML Entities - Spaces
while string.find(htmlpage, "&#160;") do
htmlpage = string.gsub(htmlpage, "&#160;", " ")
end
while string.find(htmlpage, "&nbsp;") do
htmlpage = string.gsub(htmlpage, "&nbsp;", " ")
end
-- HTML Entities - inverted exclamation mark
while string.find(htmlpage, "&#161;") do
htmlpage = string.gsub(htmlpage, "&#161;", "¡")
end
while string.find(htmlpage, "&iexcl;") do
htmlpage = string.gsub(htmlpage, "&iexcl;", " ")
end
-- HTML Entities - right pointing guillemet
while string.find(htmlpage, "&raquo;") do
htmlpage = string.gsub(htmlpage, "&raquo;", ">>")
end
while string.find(htmlpage, "&#169;") do
htmlpage = string.gsub(htmlpage, "&#169;", "(c)")
end
while string.find(htmlpage, "&copy;") do
htmlpage = string.gsub(htmlpage, "&copy;", "(c)")
end
-- Reduce Spaces
while string.find(htmlpage, " ") do
htmlpage = string.gsub(htmlpage, " ", " ")
end
while string.find(htmlpage, " ") do
htmlpage = string.gsub(htmlpage, " ", " ")
end
-- Add Bullet points
i = 1
while Bullets[i] do
while string.find(htmlpage, Bullets[i]) do
htmlpage = string.gsub(htmlpage, Bullets[i], " * ")
end
i = i + 1
end
-- adding new line where needed
i = 1
while newline[i] do
htmlpage = string.gsub(htmlpage, newline[i], " ?!@ ")
i = i + 1
end
viewpage = split(htmlpage, "?!@")
i = 1
while viewpage[i] do
-- Style Tags
--center
donotdeisablecenter = true
if string.find(string.lower(viewpage[i]), "<center>") then
centerenabled = true
donotdeisablecenter = false
viewpage[i] = string.gsub(viewpage[i], "<center>", "")
viewpage[i] = string.gsub(viewpage[i], "<Center>", "")
viewpage[i] = string.gsub(viewpage[i], "<CENTER>", "")
end
if string.find(string.lower(viewpage[i]), "</center>") then
if donotdeisablecenter then centerenabled = false end
viewpage[i] = string.gsub(viewpage[i], "</center>", "")
viewpage[i] = string.gsub(viewpage[i], "</Center>", "")
viewpage[i] = string.gsub(viewpage[i], "</CENTER>", "")
end
if centerenabled then
center[i] = 1
else
center[i] = false
end
--Horzonle Line
if string.find(string.lower(viewpage[i]), "<hr>") then
viewpage[i] = string.gsub(viewpage[i], "<hr>", "")
viewpage[i] = string.gsub(viewpage[i], "<Hr>", "")
viewpage[i] = string.gsub(viewpage[i], "<HR>", "")
hr[i] = true
else
hr[i] = false
end
i = i + 1
end
--[[
Displaying Result
]]--
i = 0
while true do
-- Displaying Page
if veiw == "page" then
shell.run("clear")
y = 1
j = i + y
w,h = term.getSize()
while viewpage[j] and y <= h do
--set x to center
if center[j] == 1 then
x = math.ceil((w / 2) - (viewpage[j]:len() / 2))
if x < 1 then
x = 1
end
else
-- not center
x = 1
end
term.setCursorPos(x,y)
term.clearLine()
-- Draw Horizontle line
if hr[j] then
hrX = 1
while hrX <= w do
term.setCursorPos(hrX,y)
write("-")
hrX = hrX + 1
end
term.setCursorPos(x,y + 1)
term.clearLine()
end
-- Line wrap handaling
stringSize = string.len(viewpage[j])
while stringSize > w do
stringSize = stringSize - w
y = y + 1
end
--print text
write(viewpage[j])
y = y + 1
j = i + y
end
local evt, arg1, arg2 = os.pullEvent()
if arg1 == 17 or arg1 == 200 then
if viewpage[i + 21] then
i = i + 1
end
elseif arg1 == 31 or arg1 == 208 then
if viewpage[i - 1] then
i = i - 1
end
elseif arg1 == 14 or arg1 == 207 then
shell.run("clear")
break
elseif arg1 == 28 and links[1] ~= "None" then
veiw = "links"
end
-- Displaying Links
elseif veiw == "links" then
shell.run("clear")
print("Use the arrows and enter to chose.")
j=0
max=-1
while true do
j=j+1
max=max+1
if links[j]==njl then break end
end
pointer = 1
term.setCursorPos(1,10)
term.clearLine(none)
print("->"..pointer..":"..links[pointer])
while true do
list=1
while list < 10 do
term.setCursorPos(1,10-list)
term.clearLine(none)
if links[pointer - (list)] then
write(""..pointer - (list)..":"..links[pointer - (list)])
end
list=list+1
end
term.setCursorPos(1,10)
selectedItemString = "->"..pointer..":"..links[pointer] .. "<-"
if string.len(selectedItemString) > w then
diffrenct = string.len(selectedItemString) - w
selectedItemString = string.sub(selectedItemString, diffrenct)
end
term.clearLine(none)
print(selectedItemString)
list=1
while list< 10 do
term.setCursorPos(1,10+list)
term.clearLine(none)
if links[pointer + (list)] then
write(""..pointer + (list)..":".. links[pointer + (list)])
end
list=list+1
end
local evt,arg1,arg2 = os.pullEvent()
if arg1 == 14 or arg1 == 207 then veiw = "page" break end
if arg1 == 200 and pointer > 1 then
pointer = pointer - 1
elseif arg1 == 208 and pointer < max then
pointer = pointer + 1
end
if arg1 == 28 then veiw = "none" break end
end
else
shell.run("clear")
shell.run("Firebox", links[pointer])
break
end
end