diff options
author | Agustin Zubiaga <aguz@sugarlabs.org> | 2013-02-24 02:17:22 (GMT) |
---|---|---|
committer | Agustin Zubiaga <aguz@sugarlabs.org> | 2013-02-24 02:17:22 (GMT) |
commit | 1ab47b54196ca6550afa4eca2d993722dc95780c (patch) | |
tree | 850fd4e8f608eadacf07255c16fa059ec755634b | |
parent | b818d6bf5d757955fbc344f7a72d8a8bac4525d6 (diff) |
Adding headers and some code for activity.py
Signed-off-by: Agustin Zubiaga <aguz@sugarlabs.org>
-rw-r--r-- | activity.py | 51 | ||||
-rw-r--r-- | page_builder.py | 28 | ||||
-rw-r--r-- | server.py | 18 | ||||
-rw-r--r-- | utils.py | 48 |
4 files changed, 116 insertions, 29 deletions
diff --git a/activity.py b/activity.py index e69de29..ac180ff 100644 --- a/activity.py +++ b/activity.py @@ -0,0 +1,51 @@ +# Copyright 2013 Agustin Zubiaga <aguz@sugarlabs.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +from gi.repository import Gtk + +from sugar3.activity import activity +from sugar3.activity.widgets import ActivityToolbarButton +from sugar3.activity.widgets import StopButton +from sugar3.graphics.toolbarbox import ToolbarBox + + +class JournalShare(activity.Activity): + + def __init__(self, handle): + activity.Activity.__init__(self, handle) + + self.max_participants = 1 + + toolbar_box = ToolbarBox() + + activity_button = ActivityToolbarButton(self) + toolbar_box.toolbar.insert(activity_button, 0) + activity_button.show() + + separator = Gtk.SeparatorToolItem() + separator.props.draw = False + separator.props.expand = True + toolbar_box.toolbar.insert(separator, -1) + separator.show() + + stopbutton = StopButton(self) + toolbar_box.toolbar.insert(stopbutton, -1) + stopbutton.show() + + self.set_toolbar_box(toolbar_box) + toolbar_box.show() + + diff --git a/page_builder.py b/page_builder.py deleted file mode 100644 index ded0214..0000000 --- a/page_builder.py +++ /dev/null @@ -1,28 +0,0 @@ -import os - -from sugar.datastore import datastore - -tfile = open('templates', 'r') -templates = tfile.read() -tfile.close() - -def fill_out_template(template, content): - template = templates.split('#!%s\n' % template)[1].split('\n!#')[0] - for x in content.keys(): - template = template.replace('{%s}' % x, content[x]) - return template - -def build_journal(): - objects_starred, no = datastore.find({'keep': '1'}) - print objects_starred, no - - objects = [{'file': 'a', 'name': 'No Te Va Gustar - A las nueve', 'icon': 'audio-x-generic.svg'}, - {'file': 'b', 'name': 'Perla jugando con el gato BOB', 'icon': 'image.svg'}] - - objects_html = '' - for o in objects: - objects_html += '%s' % fill_out_template('object', o) - - print fill_out_template('index', {'nick': 'Agus', 'objects': objects_html}) - -build_journal() @@ -1,3 +1,18 @@ +# Copyright 2013 Agustin Zubiaga <aguz@sugarlabs.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import SimpleHTTPServer import SocketServer @@ -5,13 +20,14 @@ import os os.chdir('web') + def setup_server(): PORT = 1097 Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(("", PORT), Handler) print "serving at port", PORT - + return httpd if __name__ == "__main__": diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..9d0e944 --- /dev/null +++ b/utils.py @@ -0,0 +1,48 @@ +# Copyright 2013 Agustin Zubiaga <aguz@sugarlabs.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +from sugar.datastore import datastore + +tfile = open('templates', 'r') +templates = tfile.read() +tfile.close() + + +def fill_out_template(template, content): + template = templates.split('#!%s\n' % template)[1].split('\n!#')[0] + for x in content.keys(): + template = template.replace('{%s}' % x, content[x]) + + return template + + +def build_journal(): + objects_starred, no = datastore.find({'keep': '1'}) + + objects = [{'file': 'a', 'name': 'No Te Va Gustar - A las nueve', + 'icon': 'audio-x-generic.svg'}, + {'file': 'b', 'name': 'Perla jugando con el gato BOB', + 'icon': 'image.svg'}] + + objects_html = '' + for o in objects: + objects_html += '%s' % fill_out_template('object', o) + + print fill_out_template('index', {'nick': 'Agus', 'objects': objects_html}) + + +if __name__ == "__main__": + build_journal() |