diff --git a/runserver.py b/runserver.py index 8e28f92..c5495d2 100644 --- a/runserver.py +++ b/runserver.py @@ -37,36 +37,12 @@ def check_older_than(chat_dic, secs_to_live = 180): if secs >= secs_to_live: return True - return False - def get_random_color(): - r = lambda: random.randint(0,128) return (r(),r(),r()) - -def process_chat(chat_dic): - - chats = [] - max_chat_len = 69 - if len(chat_dic["msg"]) > max_chat_len: - - for message in textwrap.wrap(chat_dic["msg"], width = max_chat_len): - partial_chat = {} - partial_chat["msg"] = message.strip() - partial_chat["timestamp"] = datetime.datetime.now() - partial_chat["username"] = session["_id"] - partial_chat["color"] = session["color"] - chats.append(partial_chat) - - else: - chats = [chat_dic] - - return chats - - # Remove headers that can be used to fingerprint this server @app.after_request def remove_headers(response): @@ -199,7 +175,7 @@ def chat_messages(url_addition): chat["timestamp"] = datetime.datetime.now() chat["username"] = session["_id"] chat["color"] = session["color"] - chats = process_chat(chat) + chats = [chat] chatlines = chatlines + chats chatlines = chatlines[-13:] more_chats = True @@ -243,7 +219,7 @@ def chat_messages_js(url_addition): chat["username"] = session["_id"] chat["color"] = session["color"] chat["num_people"] = len(chatters) - chats = process_chat(chat) + chats = [chat] chatlines = chatlines + chats chatlines = chatlines[-13:] more_chats = True diff --git a/templates/chats.html b/templates/chats.html index 67df5a5..7e8cb47 100644 --- a/templates/chats.html +++ b/templates/chats.html @@ -1,18 +1,15 @@ <html> + <head> + <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}"> + </head> <meta http-equiv="refresh" content="1" > - <style> - *{ - padding-top:3px; - font-family: Lucida Sans Typewriter,Lucida Console,monaco,Bitstream Vera Sans Mono,monospace; - font-size:22px; - } - </style> - <div style="float:right; font-size:10px;">People in chat: {{ num_people }}</div> + <div id="peopleinchat">People in chat: {{ num_people }}</div> <table> {% for message_dic in chatlines %} <tr> - <td name="msg" class="msg" style="color:rgb{{ message_dic["color"] }};"><b>{{ message_dic["username"] }}</b>: {{ message_dic["msg"] }}</td> + <th scope="row" name="msg" class="msg name" style='color: rgb({{ message_dic["color"] }});'><b>{{ message_dic["username"] }}:</b></th> + <td name="msg" class="msg text" style='color: rgb({{ message_dic["color"] }});'><b>{{ message_dic["msg"] }}</b></td> </tr> {% endfor %} </table> diff --git a/templates/chats_script.html b/templates/chats_script.html index 9a7defc..b2994ac 100644 --- a/templates/chats_script.html +++ b/templates/chats_script.html @@ -1,18 +1,15 @@ <html> + <head> + <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}"> + </head> <!--<meta http-equiv="refresh" content="1" >--> - <style> - *{ - padding-top:3px; - font-family: Lucida Sans Typewriter,Lucida Console,monaco,Bitstream Vera Sans Mono,monospace; - font-size:22px; - } - </style> - <div style="float:right; font-size:10px;">People in chat: {{ num_people }}</div> + <div id="peopleinchat">People in chat: {{ num_people }}</div> <table> {% for message_dic in chatlines %} <tr> - <td name="msg" class="msg" style="color:rgb{{ message_dic["color"] }};"><b>{{ message_dic["username"] }}</b>: {{ message_dic["msg"] }}</td> + <th scope="row" name="msg" class="msg name" style='color: rgb({{ message_dic["color"] }});'><b>{{ message_dic["username"] }}:</b></th> + <td name="msg" class="msg text" style='color: rgb({{ message_dic["color"] }});'><b>{{ message_dic["msg"] }}</b></td> </tr> {% endfor %} </table> diff --git a/templates/drop.html b/templates/drop.html index f90dc9b..cb1acd7 100644 --- a/templates/drop.html +++ b/templates/drop.html @@ -3,6 +3,7 @@ <head> <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"> <script src="{{ url_for('static', filename='jquery.js') }}"></script> +<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}"> </head> <noscript> @@ -10,15 +11,6 @@ <meta http-equiv="refresh" content="0.0;url=noscript"> </noscript> -<style> - *{ - padding-top:3px; - font-family: Lucida Sans Typewriter,Lucida Console,monaco,Bitstream Vera Sans Mono,monospace; - font-size:22px; - } - -</style> - <script> function doPoll() { $( document ).ready(function() { @@ -35,7 +27,7 @@ var color2 = JSON.stringify(obj.color[1]); var color3 = JSON.stringify(obj.color[2]); //alert(color1); - $("#chatf").append('<tr>' + '<td name="msg" class="msg" style="color:rgb(' + color1 + ',' + color2 + ',' + color3 + ');"><b>' + obj.username + ': ' + obj.msg + '</b></td>'); + $("#chatf").append('<tr><th scope="row" name="msg" class="msg name" style="color:rgb(' + color1 + ',' + color2 + ',' + color3 + ');"><b>' + obj.username + ': </b></th><td name="msg" class="msg text" style="color:rgb(' + color1 + ',' + color2 + ',' + color3 + ');"><b>' + obj.msg + '</b></td></tr>'); $("#numpeeps").html(obj.num_people); //alert(obj.num_people); } diff --git a/templates/drop.noscript.html b/templates/drop.noscript.html index 5afe0ff..4877893 100644 --- a/templates/drop.noscript.html +++ b/templates/drop.noscript.html @@ -1,15 +1,10 @@ <!doctype html> <title>Your Drop</title> -<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"> -<style> - *{ - padding-top:3px; - font-family: Lucida Sans Typewriter,Lucida Console,monaco,Bitstream Vera Sans Mono,monospace; - font-size:22px; - } +<head> + <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"> + <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}"> +</head> - -</style> <div id="welcome">Welcome to drop {{ hostname }}<br /> Share the <a href="/{{ path }}">drop URL</a> with your friends to chat with them. Do not share it publicly.<br /> diff --git a/templates/landing.html b/templates/landing.html index 486d0c0..cc00980 100644 --- a/templates/landing.html +++ b/templates/landing.html @@ -1,13 +1,9 @@ <!doctype html> <title>Your Drop</title> -<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"> -<style> - *{ - padding-top:3px; - font-family: Lucida Sans Typewriter,Lucida Console,monaco,Bitstream Vera Sans Mono,monospace; - font-size:22px; - } -</style> +<head> + <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"> + <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}"> +</head> <noscript> <style type="text/css">