Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2013-03-19 13:57:11 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-03-19 14:02:54 (GMT)
commite13438d4eeac2e3b9fbe4ddbf399fdd136962297 (patch)
tree6847c04f68013c6873e557482043235cccaf7f83
parent985a44390c9d0a870b2c17d23fa14ddb0c8e6fb6 (diff)
Add information about the journal owner
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--server.py30
-rw-r--r--web/index.html10
-rw-r--r--web/style.css9
3 files changed, 41 insertions, 8 deletions
diff --git a/server.py b/server.py
index 4c58265..f411353 100644
--- a/server.py
+++ b/server.py
@@ -24,6 +24,8 @@ import dbus
from gi.repository import Gio
from sugar3 import network
from sugar3.datastore import datastore
+from sugar3.graphics.xocolor import XoColor
+from sugar3 import profile
from warnings import filterwarnings, catch_warnings
with catch_warnings():
@@ -212,19 +214,22 @@ class JournalHTTPRequestHandler(network.ChunkedGlibHTTPRequestHandler):
if self.path.startswith('/datastore'):
# queries to the datastore
- jm = JournalManager()
if self.path == '/datastore/starred':
self.send_header_response("text/html")
- self.wfile.write(jm.get_starred())
+ self.wfile.write(server.jm.get_starred())
logging.error('Returned datastore/starred')
- if self.path.startswith('/datastore/id='):
+ elif self.path == '/datastore/owner_info':
+ self.send_header_response("text/html")
+ self.wfile.write(server.jm.get_journal_owner_info())
+ elif self.path.startswith('/datastore/id='):
object_id = self.path[self.path.find('=') + 1:]
- mime_type, title, content = jm.get_object_by_id(object_id)
+ mime_type, title, content = \
+ server.jm.get_object_by_id(object_id)
self.send_header_response(mime_type, title)
self.wfile.write(content)
- if self.path.startswith('/datastore/preview/id='):
+ elif self.path.startswith('/datastore/preview/id='):
object_id = self.path[self.path.find('=') + 1:]
- preview = jm.get_preview_by_id(object_id)
+ preview = server.jm.get_preview_by_id(object_id)
self.send_header_response('image/png')
self.wfile.write(preview)
@@ -245,14 +250,23 @@ class JournalHTTPServer(network.GlibTCPServer):
"""
self.activity_path = activity_path
self.activity_root = activity_root
+ self.jm = JournalManager()
network.GlibTCPServer.__init__(self, server_address,
JournalHTTPRequestHandler)
-
class JournalManager():
def __init__(self):
- pass
+ self.nick_name = profile.get_nick_name()
+ self.xo_color = profile.get_color()
+
+ def get_journal_owner_info(self):
+ info = {}
+ info['nick_name'] = self.nick_name
+ info['stroke_color'] = self.xo_color.get_stroke_color()
+ info['fill_color'] = self.xo_color.get_fill_color()
+ logging.error('INFO %s', info)
+ return json.dumps(info)
def get_object_by_id(self, object_id):
dsobj = datastore.get(object_id)
diff --git a/web/index.html b/web/index.html
index 413ca0c..246f7ce 100644
--- a/web/index.html
+++ b/web/index.html
@@ -5,6 +5,13 @@
<link href="style.css" rel="stylesheet" type="text/css"/>
<script src="jquery-1.9.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
+
+ $.getJSON("/datastore/owner_info", function(owner_info) {
+ $('#header').append("Journal of " + owner_info.nick_name);
+ $('#header').css('color', owner_info.stroke_color);
+ $('#header').css('background-color', owner_info.fill_color);
+ });
+
$.getJSON("/datastore/starred", function(starred) {
for (var i = 0; i < starred.length; i++)
{
@@ -24,6 +31,9 @@
</script>
</head>
<body>
+ <div id="header">
+ </div>
+
<table>
<tr><td>
<form action="/datastore/upload" method="post" enctype="multipart/form-data">
diff --git a/web/style.css b/web/style.css
index 698b1ca..65e3048 100644
--- a/web/style.css
+++ b/web/style.css
@@ -7,6 +7,15 @@ body {
width: 100%;
}
+#header {
+ font-family: sans-serif,cantarell,helvetica;
+ text-align: center;
+ font-size: 26px;
+ font-weight: bold;
+ width: 100%;
+ padding: 20px;
+}
+
.title {
font-family: sans-serif,cantarell,helvetica;
color: #fff;