Add logos for sent and received messages
Oh my God, there are images now!
This commit is contained in:
parent
44255d6bc2
commit
f25cc7aa03
74
sms.py
74
sms.py
|
@ -266,9 +266,37 @@ class Web_Service (BaseHTTPRequestHandler):
|
||||||
self.end_headers ()
|
self.end_headers ()
|
||||||
self.wfile.write ((
|
self.wfile.write ((
|
||||||
html_header (title = 'Termux WebSMS') +
|
html_header (title = 'Termux WebSMS') +
|
||||||
html_iframe ('/list', height = '100%', width = '30%', name = 'list') + html_iframe ('about:blank', height = '100%', width = '70%', name = 'messages') +
|
html_iframe ('/list', height = '100%', width = '30%', name = 'list') + html_iframe ('about:blank', height = '100%', width = '70%', name = 'thread') +
|
||||||
html_footer ()
|
html_footer ()
|
||||||
).encode ('utf-8'))
|
).encode ('utf-8'))
|
||||||
|
elif self.path == '/up.svg':
|
||||||
|
self.send_response (200)
|
||||||
|
self.send_header ('Content-type', 'image/svg+xml; charset=UTF-8')
|
||||||
|
self.end_headers ()
|
||||||
|
self.wfile.write ((
|
||||||
|
'<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128">\n' +
|
||||||
|
'\t<g>\n' +
|
||||||
|
'\t\t<path\n' +
|
||||||
|
'\t\t\tstyle="fill:#000000;stroke:#000000;stroke-width:0.264583"\n' +
|
||||||
|
'\t\t\td="M 42,128 86,128 86,64 128,64 64,0 0,64 42,64 Z"\n' +
|
||||||
|
'\t\t/>\n' +
|
||||||
|
'\t</g>\n' +
|
||||||
|
'</svg>'
|
||||||
|
).encode ('utf-8'))
|
||||||
|
elif self.path == '/down.svg':
|
||||||
|
self.send_response (200)
|
||||||
|
self.send_header ('Content-type', 'image/svg+xml; charset=UTF-8')
|
||||||
|
self.end_headers ()
|
||||||
|
self.wfile.write ((
|
||||||
|
'<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128">\n' +
|
||||||
|
'\t<g>\n' +
|
||||||
|
'\t\t<path\n' +
|
||||||
|
'\t\t\tstyle="fill:#000000;stroke:#000000;stroke-width:0.264583"\n' +
|
||||||
|
'\t\t\td="M 42,0 86,0 86,64 128,64 64,128 0,64 42,64 Z"\n' +
|
||||||
|
'\t\t/>\n' +
|
||||||
|
'\t</g>\n' +
|
||||||
|
'</svg>'
|
||||||
|
).encode ('utf-8'))
|
||||||
elif self.path == '/list':
|
elif self.path == '/list':
|
||||||
self.send_response (200)
|
self.send_response (200)
|
||||||
self.send_header ('Content-type', 'text/html; charset=UTF-8')
|
self.send_header ('Content-type', 'text/html; charset=UTF-8')
|
||||||
|
@ -279,11 +307,11 @@ class Web_Service (BaseHTTPRequestHandler):
|
||||||
s = ls [i] [0] + ' (' + str (ls [i] [3]) + ')'
|
s = ls [i] [0] + ' (' + str (ls [i] [3]) + ')'
|
||||||
if len (ls [i]) == 5:
|
if len (ls [i]) == 5:
|
||||||
s = ls [i] [4] + ' (' + str (ls [i] [3]) + ')'
|
s = ls [i] [4] + ' (' + str (ls [i] [3]) + ')'
|
||||||
lst.append (html_link ('/?thread=' + str (i), text = s, target = 'messages'))
|
lst.append (html_link ('/?thread=' + str (i), text = s, target = 'thread'))
|
||||||
self.wfile.write ((
|
self.wfile.write ((
|
||||||
html_header (title = 'Conversations list') +
|
html_header (title = 'Conversations list') +
|
||||||
html_title ('Conversation') +
|
html_title ('Conversation') +
|
||||||
html_paragraph (html_link ('/new', text = 'New conversation', target = 'messages')) +
|
html_paragraph (html_link ('/new', text = 'New conversation', target = 'thread')) +
|
||||||
html_paragraph (html_link ('/list', text = 'Refresh list')) +
|
html_paragraph (html_link ('/list', text = 'Refresh list')) +
|
||||||
html_paragraph ('List of conversations follows:') +
|
html_paragraph ('List of conversations follows:') +
|
||||||
html_list (lst) +
|
html_list (lst) +
|
||||||
|
@ -349,13 +377,6 @@ class Web_Service (BaseHTTPRequestHandler):
|
||||||
self.send_response (200)
|
self.send_response (200)
|
||||||
self.send_header ('Content-type', 'text/html; charset=UTF-8')
|
self.send_header ('Content-type', 'text/html; charset=UTF-8')
|
||||||
self.end_headers ()
|
self.end_headers ()
|
||||||
msgs = ''
|
|
||||||
for i in sorted (conv, key = lambda item: item [0], reverse = True) [0:2000]:
|
|
||||||
msgs += html_message (i [2], not i [1], i [0], '↓' if i [1] else '↑')
|
|
||||||
if name is None:
|
|
||||||
name = number
|
|
||||||
else:
|
|
||||||
name = name + ' (' + number + ')'
|
|
||||||
self.wfile.write ((
|
self.wfile.write ((
|
||||||
html_header (title = 'Conversation with ' + name) +
|
html_header (title = 'Conversation with ' + name) +
|
||||||
html_title (name) +
|
html_title (name) +
|
||||||
|
@ -365,6 +386,39 @@ class Web_Service (BaseHTTPRequestHandler):
|
||||||
html_form_submit ('Send'),
|
html_form_submit ('Send'),
|
||||||
'/send'
|
'/send'
|
||||||
) +
|
) +
|
||||||
|
html_iframe ('/messages?thread=' + str (id), , height = '100%', width = '100%', name = 'messages')
|
||||||
|
html_footer ()
|
||||||
|
).encode ('utf-8'))
|
||||||
|
elif self.path [0:17] == '/messages?thread=':
|
||||||
|
try:
|
||||||
|
id = self.path [17:]
|
||||||
|
number, name, conv = sms.get_thread (id)
|
||||||
|
if number is None:
|
||||||
|
raise (IndexError)
|
||||||
|
except (ValueError, IndexError):
|
||||||
|
self.send_response (404)
|
||||||
|
self.send_header ('Content-type', 'text/html')
|
||||||
|
self.end_headers ()
|
||||||
|
self.wfile.write ((
|
||||||
|
html_header (title = 'Page not found') +
|
||||||
|
html_title ('Not found') +
|
||||||
|
html_paragraph ('This page does not exist. You cas return to the ' + html_link ('/', text = 'home') + '.') +
|
||||||
|
html_footer ()
|
||||||
|
).encode ('utf-8'))
|
||||||
|
return ()
|
||||||
|
self.send_response (200)
|
||||||
|
self.send_header ('Content-type', 'text/html; charset=UTF-8')
|
||||||
|
self.send_header ('Refresh', '10')
|
||||||
|
self.end_headers ()
|
||||||
|
msgs = ''
|
||||||
|
for i in sorted (conv, key = lambda item: item [0], reverse = True) [0:2000]:
|
||||||
|
msgs += html_message (i [2], not i [1], i [0], '↓' if i [1] else '↑', avatar = 'down.svg' if i [1] else 'up.svg')
|
||||||
|
if name is None:
|
||||||
|
name = number
|
||||||
|
else:
|
||||||
|
name = name + ' (' + number + ')'
|
||||||
|
self.wfile.write ((
|
||||||
|
html_header (title = 'Conversation with ' + name) +
|
||||||
html_link (self.path, text = 'Refresh') +
|
html_link (self.path, text = 'Refresh') +
|
||||||
msgs +
|
msgs +
|
||||||
html_footer ()
|
html_footer ()
|
||||||
|
|
Loading…
Reference in New Issue