Permalink
Browse files

Fancy hex printing.. TODO this needs to be added in replacements more…

… smoothly..
  • Loading branch information...
o-jasper committed Oct 19, 2015
1 parent 989fd07 commit f1f8e85e7e3a86ab99260c03b99b3716ddb89e66
View
@@ -20,14 +20,16 @@ end
function Page:src_js()
return function(x)
return string.format([[<script src="/%s/js/%s.js"></script>]],
return string.format([[<script type="text/javascript" src="/%s/js/%s.js"></script>]],
self.name, string.sub(x, 2))
end
end
function Page:src_css()
return function(x)
return string.format([[<style src="/%s/css/%s.css"></style>]],
self.name, string.sub(x, 2))
return string.format([[<style>{%%css/%s.css}</style>]], string.sub(x, 2))
-- Persistent in not working
-- return string.format([[<link rel="stylesheet" href="/%s/css/%s.css">]],
-- self.name, string.sub(x, 2))
end
end
View
@@ -4,12 +4,21 @@ Page.__index = Page
Page.name = "contacts"
Page.info_ons = { require "tox_client.info_on.contact.basic" }
Page.info_ons = { require "tox_client.info_on.contact.default" }
local fancy_hex = require("page_html.util.text.hex").fancy_hex
function Page:repl(state)
local fa = string.match(state.rest_path or ">_<", "^([%x]+)/?$")
or self.edge_toxes[1]:addr()
return { fa = fa, js = self:src_js() }
local repl = {
fa = fa, js = self:src_js(), css=self:src_css(),
}
function repl.f_addr(addr_mem, front_cnt, aft_cnt)
local addr = repl[string.match(addr_mem, "[%w_]+")]
return fancy_hex(addr, front_cnt, aft_cnt)
end
return repl
end
local rpc_js = require "tox_client.rpc_js"
@@ -8,9 +8,12 @@
{%inject_js}
{%js common}
{%js contacts_update}
{%css default}
</head>
<body>
<p>Contacts from {%f_addr fa}</p>
<button onclick="contacts_update();">Update</button> <span id="cnt">no</span> results.
<table id="list">
</table>
@@ -0,0 +1,4 @@
.addr_mid{font-size:70%; color:#888}
.online {color:green}
.offline{color:red}
@@ -1,2 +1,2 @@
<td><a href="/chat/{%fa}/{%ta}">{%fa}</ta>:</td><td>{%contact_name}</td></tr>
<td><a class="addr" href="/chat/{%fa}/{%ta}">{%ta}</ta>:</td><td>{%contact_name}</td></tr>
<tr><td colspan=2>{%status_message}</td>
@@ -0,0 +1,2 @@
<td>{%f_online}<a class="addr" href="/chat/{%fa}/{%ta}">{%f_addr ta}</ta>:</td><td>{%contact_name}</td></tr>
<tr><td colspan=2>{%status_message}</td>
@@ -1,17 +1,17 @@
-- Basic (dumb) display.
local This = {}
for k,v in pairs(require "page_html.serve.Suggest") do This[k] = v end
This.__index = This
This.name = "contact/basic"
function This:init()
self.contact_name = self.name
self.contact_name = rawget(self, "name") or "(noname)"
self.name = nil -- Need this one cleared.
end
function This:priority()
return 0
end
function This:priority() return 0 end
function This:repl()
if not self._repl then
@@ -0,0 +1,27 @@
local This = {}
for k,v in pairs(require "tox_client.info_on.contact.basic") do This[k] = v end
This.__index = This
This.name = "contact/default"
local fancy_hex = require("page_html.util.text.hex").fancy_hex
function This:repl(state)
if not self._repl then
self._repl = {
fa = self.fa, ta = self.ta, contact_name = self.contact_name,
f_addr = function(addr_mem, front_cnt, aft_cnt)
local addr = self._repl[string.match(addr_mem, "[%w_]+")]
return fancy_hex(addr, front_cnt, aft_cnt)
end,
f_online = function() return self.claims.online and "{%online_indictator}"
or "{%offline_indicator}" end,
offline_indicator = [[<span class="offline">offline</span>]],
online_indicator = [[<span class="online">online</span>]],
}
self._repl = setmetatable(self._repl, {__index = self.claims})
end
return self._repl
end
return This

0 comments on commit f1f8e85

Please sign in to comment.