diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2013-12-31 21:02:48 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2013-12-31 21:31:06 (GMT) |
commit | 499eb6e121dfe7cef521553eba3f85e9122a6cea (patch) | |
tree | 16ddaf5e024c62cb9dad542976cb4453c9521441 | |
parent | fc98d378a6726923daa994e0d96efa8ede13073a (diff) |
Use stubs for missed context images; rename context types
29 files changed, 528 insertions, 139 deletions
diff --git a/misc/stub-images b/misc/stub-images new file mode 100755 index 0000000..93f0fac --- /dev/null +++ b/misc/stub-images @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# sugar-lint: disable + +# Copyright (C) 2013 Aleksey Lim +# +# 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, see <http://www.gnu.org/licenses/>. + +from optparse import OptionParser + +from sugar_network import db, model, static +from sugar_network.model.context import Context +from sugar_network.node import data_root +from sugar_network.toolkit import Option + + +Option.seek('node', [data_root]) +Option.parse_args(OptionParser(), config_files=['~/.config/sugar-network/config']) + +db.index_write_queue.value = 1024 * 10 +db.index_flush_threshold.value = 0 +db.index_flush_timeout.value = 0 + +volume = db.Volume(data_root.value, model.RESOURCES) +volume.populate() +directory = volume['context'] +try: + items, __ = directory.find() + for context in items: + if context['artifact_icon'] or not (set(context['type']) & set(['activity', 'book', 'group'])): + continue + for name in ('activity', 'book', 'group'): + if name in context['type']: + with file(static.path('images', name + '.svg')) as f: + Context.populate_images(context, f.read()) + directory.update(context.guid, context) + break +finally: + volume.close() diff --git a/sugar_network/db/routes.py b/sugar_network/db/routes.py index bff9fc5..9f59d68 100644 --- a/sugar_network/db/routes.py +++ b/sugar_network/db/routes.py @@ -135,14 +135,6 @@ class Routes(object): directory.update(request.guid, {'author': authors}) def on_create(self, request, props, event): - if 'guid' in props: - # TODO Temporal security hole, see TODO - guid = props['guid'] - enforce(not self.volume[request.resource].exists(guid), - '%s already exists', guid) - enforce(_GUID_RE.match(guid) is not None, - 'Malformed %s GUID', guid) - ts = int(time.time()) props['ctime'] = ts props['mtime'] = ts @@ -204,6 +196,14 @@ class Routes(object): content.get(name) is None and \ (prop.default is not None or prop.on_set is not None): doc[name] = prop.default + if doc['guid']: + # TODO Temporal security hole, see TODO + enforce(not self.volume[request.resource].exists(doc['guid']), + '%s already exists', doc['guid']) + enforce(_GUID_RE.match(doc['guid']) is not None, + 'Malformed %s GUID', doc['guid']) + else: + doc['guid'] = toolkit.uuid() try: for name, value in doc.props.items(): diff --git a/sugar_network/model/__init__.py b/sugar_network/model/__init__.py index bb70a8a..c846bc7 100644 --- a/sugar_network/model/__init__.py +++ b/sugar_network/model/__init__.py @@ -16,7 +16,7 @@ from sugar_network.model.routes import VolumeRoutes, FrontRoutes -CONTEXT_TYPES = ['activity', 'project', 'package', 'content'] +CONTEXT_TYPES = ['activity', 'group', 'package', 'book'] NOTIFICATION_TYPES = ['create', 'update', 'delete', 'vote'] FEEDBACK_TYPES = ['question', 'idea', 'problem'] ARTIFACT_TYPES = ['instance', 'preview'] diff --git a/sugar_network/model/artifact.py b/sugar_network/model/artifact.py index e461c4d..0a0239d 100644 --- a/sugar_network/model/artifact.py +++ b/sugar_network/model/artifact.py @@ -13,8 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from os.path import join - from sugar_network import db, model, static from sugar_network.toolkit.router import Blob, ACL @@ -62,8 +60,8 @@ class Artifact(db.Resource): if value: return value return Blob({ - 'url': '/static/images/missing.png', - 'blob': join(static.PATH, 'images', 'missing.png'), + 'url': '/static/images/missing-preview.png', + 'blob': static.path('images', 'missing-preview.png'), 'mime_type': 'image/png', }) diff --git a/sugar_network/model/context.py b/sugar_network/model/context.py index 869ad6c..461960b 100644 --- a/sugar_network/model/context.py +++ b/sugar_network/model/context.py @@ -13,9 +13,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from os.path import join +import hashlib +from cStringIO import StringIO -from sugar_network import db, model, static +from sugar_network import db, model, static, toolkit from sugar_network.toolkit.router import Blob, ACL @@ -30,6 +31,13 @@ class Context(db.Resource): def type(self, value): if value and 'package' in value and 'common' not in self['layer']: self['layer'] = tuple(self['layer']) + ('common',) + if 'artifact_icon' not in self: + for name in ('activity', 'book', 'group'): + if name not in self.type: + continue + with file(static.path('images', name + '.svg')) as f: + Context.populate_images(self, f.read()) + break return value @db.indexed_property(slot=1, prefix='S', full_text=True, localized=True) @@ -59,13 +67,13 @@ class Context(db.Resource): if 'package' in self['type']: return Blob({ 'url': '/static/images/package.png', - 'blob': join(static.PATH, 'images', 'package.png'), + 'blob': static.path('images', 'package.png'), 'mime_type': 'image/png', }) else: return Blob({ 'url': '/static/images/missing.png', - 'blob': join(static.PATH, 'images', 'missing.png'), + 'blob': static.path('images', 'missing.png'), 'mime_type': 'image/png', }) @@ -73,21 +81,35 @@ class Context(db.Resource): def artifact_icon(self, value): if value: return value - return Blob({ - 'url': '/static/images/missing.svg', - 'blob': join(static.PATH, 'images', 'missing.svg'), - 'mime_type': 'image/svg+xml', - }) + if 'package' in self['type']: + return Blob({ + 'url': '/static/images/package.svg', + 'blob': static.path('images', 'package.svg'), + 'mime_type': 'image/png', + }) + else: + return Blob({ + 'url': '/static/images/missing.svg', + 'blob': static.path('images', 'missing.svg'), + 'mime_type': 'image/svg+xml', + }) @db.blob_property(mime_type='image/png') def preview(self, value): if value: return value - return Blob({ - 'url': '/static/images/missing.png', - 'blob': join(static.PATH, 'images', 'missing.png'), - 'mime_type': 'image/png', - }) + if 'package' in self['type']: + return Blob({ + 'url': '/static/images/package-preview.png', + 'blob': static.path('images', 'package-preview.png'), + 'mime_type': 'image/png', + }) + else: + return Blob({ + 'url': '/static/images/missing-preview.png', + 'blob': static.path('images', 'missing-preview.png'), + 'mime_type': 'image/png', + }) @db.indexed_property(slot=3, default=0, acl=ACL.READ | ACL.CALC) def downloads(self, value): @@ -130,3 +152,24 @@ class Context(db.Resource): @db.stored_property(typecast=dict, default={}, acl=ACL.PUBLIC | ACL.LOCAL) def packages(self, value): return value + + @staticmethod + def populate_images(props, svg): + if 'guid' in props: + from sugar_network.toolkit.sugar import color_svg + svg = color_svg(svg, props['guid']) + + def convert(w, h): + png = toolkit.svg_to_png(svg, w, h) + return {'blob': png, + 'mime_type': 'image/png', + 'digest': hashlib.sha1(png.getvalue()).hexdigest(), + } + + props['artifact_icon'] = { + 'blob': StringIO(svg), + 'mime_type': 'image/svg+xml', + 'digest': hashlib.sha1(svg).hexdigest(), + } + props['icon'] = convert(55, 55) + props['preview'] = convert(140, 140) diff --git a/sugar_network/model/routes.py b/sugar_network/model/routes.py index 447ff30..c5c4929 100644 --- a/sugar_network/model/routes.py +++ b/sugar_network/model/routes.py @@ -15,7 +15,7 @@ import logging import mimetypes -from os.path import join, split +from os.path import split from sugar_network import static, db from sugar_network.toolkit.router import route, fallbackroute, Blob, ACL @@ -99,7 +99,7 @@ class FrontRoutes(object): @fallbackroute('GET', ['static']) def get_static(self, request): - path = join(static.PATH, *request.path[1:]) + path = static.path(*request.path[1:]) if not mimetypes.inited: mimetypes.init() mime_type = mimetypes.types_map.get('.' + path.rsplit('.', 1)[-1]) @@ -116,7 +116,7 @@ class FrontRoutes(object): @route('GET', ['favicon.ico']) def favicon(self, request, response): return Blob({ - 'blob': join(static.PATH, 'favicon.ico'), + 'blob': static.path('favicon.ico'), 'mime_type': 'image/x-icon', }) diff --git a/sugar_network/node/routes.py b/sugar_network/node/routes.py index 17e7bbf..80f8893 100644 --- a/sugar_network/node/routes.py +++ b/sugar_network/node/routes.py @@ -19,13 +19,13 @@ import shutil import gettext import logging import hashlib -from cStringIO import StringIO from contextlib import contextmanager from ConfigParser import ConfigParser from os.path import join, isdir, exists from sugar_network import node, toolkit, model from sugar_network.node import stats_node, stats_user +from sugar_network.model.context import Context # pylint: disable-msg=W0611 from sugar_network.toolkit.router import route, preroute, postroute, ACL from sugar_network.toolkit.router import Unauthorized, Request, fallbackroute @@ -504,7 +504,7 @@ def load_bundle(volume, request, bundle_path): bundle = Bundle(bundle_path, mime_type='application/zip') except Exception: _logger.debug('Load unrecognized bundle from %r', bundle_path) - context_type = 'content' + context_type = 'book' else: _logger.debug('Load Sugar Activity bundle from %r', bundle_path) context_type = 'activity' @@ -540,7 +540,6 @@ def load_bundle(volume, request, bundle_path): data['mime_type'] = 'application/vnd.olpc-sugar' if initial and not contexts.exists(context): - context_meta['guid'] = context context_meta['type'] = 'activity' request.call(method='POST', path=['context'], content=context_meta) context_meta = None @@ -583,32 +582,16 @@ def load_bundle(volume, request, bundle_path): def _load_context_metadata(bundle, spec): - - def convert(data, w, h): - result = toolkit.svg_to_png(data.getvalue(), w, h, spec['context']) - return {'blob': result, - 'mime_type': 'image/png', - 'digest': hashlib.sha1(result.getvalue()).hexdigest(), - } - result = {} for prop in ('homepage', 'mime_types'): if spec[prop]: result[prop] = spec[prop] + result['guid'] = spec['context'] try: icon_file = bundle.extractfile(join(bundle.rootdir, spec['icon'])) - icon = StringIO(icon_file.read()) + Context.populate_images(result, icon_file.read()) icon_file.close() - result.update({ - 'artifact_icon': { - 'blob': icon, - 'mime_type': 'image/svg+xml', - 'digest': hashlib.sha1(icon.getvalue()).hexdigest(), - }, - 'preview': convert(icon, 140, 140), - 'icon': convert(icon, 55, 55), - }) except Exception: exception(_logger, 'Failed to load icon') diff --git a/sugar_network/static/__init__.py b/sugar_network/static/__init__.py index 5fec95b..4295e38 100644 --- a/sugar_network/static/__init__.py +++ b/sugar_network/static/__init__.py @@ -15,5 +15,8 @@ from os.path import dirname, join - PATH = join(dirname(__file__), 'httpdocs') + + +def path(*args): + return join(PATH, *args) diff --git a/sugar_network/static/httpdocs/images/activity.svg b/sugar_network/static/httpdocs/images/activity.svg new file mode 100644 index 0000000..c5302fd --- /dev/null +++ b/sugar_network/static/httpdocs/images/activity.svg @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [ + <!ENTITY stroke_color "#ffffff"> + <!ENTITY fill_color "#000000"> +]> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 55.125 55" + height="55px" + id="Layer_1" + version="1.1" + viewBox="0 0 55.125 55" + width="55.125px" + x="0px" + xml:space="preserve" + y="0px" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="activities.svg"><metadata + id="metadata3043"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs3041" /><sodipodi:namedview + pagecolor="#ffff5f" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:window-width="1364" + inkscape:window-height="725" + id="namedview3039" + showgrid="true" + inkscape:zoom="8.165204" + inkscape:cx="39.036816" + inkscape:cy="27.452329" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="g3049"><inkscape:grid + type="xygrid" + id="grid3045" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /></sodipodi:namedview><g + style="display:inline" + inkscape:label="orig" + id="g3049" + inkscape:groupmode="layer"><rect + style="fill:&stroke_color;" + id="rect3006" + width="51" + height="51" + x="2" + y="2" + ry="6.1807232" /><path + style="fill:&fill_color;" + inkscape:connector-curvature="0" + d="m 40.198922,16.862795 q 0,-0.85783 -0.600131,-1.458322 -0.600147,-0.600492 -1.457476,-0.600492 -0.85733,0 -1.457463,0.600492 -0.600136,0.600492 -0.600136,1.458322 0,0.85784 0.600136,1.458331 0.600133,0.600487 1.457463,0.600487 0.857329,0 1.457476,-0.600487 0.600131,-0.600491 0.600131,-1.458331 z M 45,10.686356 q 0,5.340075 -1.618229,9.232518 -1.61823,3.89245 -5.433358,7.731302 -1.736116,1.715676 -4.179526,3.774485 l -0.428689,8.128035 q -0.04283,0.343147 -0.342934,0.557592 l -8.23044,4.803918 Q 24.616786,45 24.423888,45 24.166686,45 23.930913,44.806981 l -1.37172,-1.37253 q -0.278657,-0.300246 -0.171452,-0.686288 l 1.82182,-5.919094 -6.022764,-6.026326 -5.915608,1.822902 q -0.06426,0.02143 -0.192906,0.02143 -0.300069,0 -0.492975,-0.193021 l -1.37172,-1.37253 Q 9.8492312,30.674052 10.106426,30.245118 l 4.801082,-8.235297 q 0.214326,-0.300247 0.557261,-0.34314 l 8.12324,-0.428936 Q 25.645611,18.79289 27.36027,17.055752 31.389762,13.045347 35.033409,11.522656 38.677045,9.999965 44.271206,10 q 0.30007,0 0.514389,0.203757 0.214328,0.203751 0.214328,0.482529 z" + id="path2995-9" /></g></svg> diff --git a/sugar_network/static/httpdocs/images/book.svg b/sugar_network/static/httpdocs/images/book.svg new file mode 100644 index 0000000..92fb811 --- /dev/null +++ b/sugar_network/static/httpdocs/images/book.svg @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [ + <!ENTITY stroke_color "#ffffff"> + <!ENTITY fill_color "#000000"> +]> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 55.125 55" + height="55px" + id="Layer_1" + version="1.1" + viewBox="0 0 55.125 55" + width="55.125px" + x="0px" + xml:space="preserve" + y="0px" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="books.svg"><metadata + id="metadata3043"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs3041" /><sodipodi:namedview + pagecolor="#ffff5f" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:window-width="1364" + inkscape:window-height="725" + id="namedview3039" + showgrid="true" + inkscape:zoom="9.9636364" + inkscape:cx="18.33272" + inkscape:cy="27.485017" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="layer1"><inkscape:grid + type="xygrid" + id="grid3045" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /></sodipodi:namedview><g + inkscape:groupmode="layer" + id="layer1" + inkscape:label="Orig" + style="display:inline"><rect + style="fill:&stroke_color;" + id="rect3006" + width="51" + height="51" + x="2" + y="2" + ry="6.1807232" /><path + inkscape:connector-curvature="0" + d="m 44.457628,17.975387 q 0.840668,1.298804 0.378314,2.939427 l -5.77965,20.644433 q -0.399316,1.45831 -1.607781,2.449552 Q 36.240046,45.000041 34.873943,45 H 15.475341 q -1.618299,0 -3.121003,-1.219054 -1.502701,-1.219053 -2.091174,-2.99641 -0.5043946,-1.526698 -0.04204,-2.893852 0,-0.09115 0.06304,-0.615248 0.06304,-0.524093 0.08408,-0.843102 0.021,-0.182273 -0.06304,-0.48992 -0.08404,-0.307642 -0.06304,-0.444339 0.04204,-0.25066 0.16812,-0.478512 0.12608,-0.227853 0.346794,-0.535497 0.220714,-0.307646 0.346795,-0.535498 0.483393,-0.865869 0.945749,-2.084963 0.462355,-1.219091 0.630512,-2.084963 0.06305,-0.227852 0.01052,-0.683596 -0.05252,-0.455746 -0.01052,-0.638018 0.06305,-0.250663 0.357276,-0.638018 0.294235,-0.387356 0.357276,-0.524093 0.441356,-0.820292 0.882709,-2.096329 0.441354,-1.276034 0.525434,-2.050789 0.021,-0.205083 -0.05257,-0.729175 -0.07357,-0.524093 0.01052,-0.638018 0.08409,-0.29624 0.462357,-0.695001 0.378277,-0.398762 0.462356,-0.512689 0.399315,-0.592438 0.893227,-1.925457 0.493913,-1.33302 0.577955,-2.198891 0.021,-0.182273 -0.06305,-0.581035 -0.08405,-0.398759 -0.04205,-0.603842 0.04205,-0.182276 0.189157,-0.410167 0.147118,-0.227893 0.378315,-0.524092 0.231196,-0.296199 0.357276,-0.478513 0.168119,-0.273432 0.346795,-0.695002 0.178675,-0.42157 0.315237,-0.797522 0.136562,-0.375952 0.336275,-0.820294 0.199712,-0.444339 0.409834,-0.729173 0.210122,-0.284836 0.556953,-0.535497 0.346831,-0.250661 0.756592,-0.262026 0.409761,-0.01136 0.998307,0.125331 l -0.021,0.06834 Q 22.473973,10 22.747208,10 h 15.993845 q 1.55526,0 2.39593,1.276037 0.84067,1.276035 0.378315,2.962238 l -5.758612,20.644432 q -0.756592,2.711578 -1.502702,3.497697 -0.746109,0.786117 -2.700684,0.786117 H 13.289642 q -0.567472,0 -0.798631,0.341778 -0.231195,0.364588 -0.021,0.979796 0.504396,1.595046 3.026444,1.595046 h 19.398601 q 0.609473,0 1.176945,-0.353182 0.567472,-0.353185 0.735591,-0.945624 l 6.305082,-22.490139 q 0.147118,-0.501282 0.105079,-1.298807 0.798632,0.341779 1.239986,0.979798 z m -22.361969,0.04557 q -0.08408,0.29624 0.04205,0.512688 0.126117,0.216446 0.420354,0.216486 H 35.33634 q 0.273237,0 0.535915,-0.216486 0.262679,-0.216487 0.346795,-0.512688 l 0.441354,-1.45831 q 0.08409,-0.29624 -0.04205,-0.512687 -0.126114,-0.216449 -0.420351,-0.216489 H 23.419725 q -0.273237,0 -0.535916,0.216489 -0.262679,0.216487 -0.346794,0.512687 z m -1.74438,5.83328 q -0.08408,0.29624 0.04205,0.512689 0.126116,0.216446 0.420352,0.216486 h 12.778283 q 0.273235,0 0.535914,-0.216486 0.26268,-0.216489 0.346795,-0.512689 l 0.441354,-1.45831 q 0.08408,-0.29624 -0.04205,-0.512688 -0.126118,-0.216447 -0.420354,-0.216487 h -12.77828 q -0.273234,0 -0.535915,0.216487 -0.262679,0.216489 -0.346794,0.512688 z" + id="path2990" + style="fill:&fill_color;" /></g></svg> diff --git a/sugar_network/static/httpdocs/images/group.svg b/sugar_network/static/httpdocs/images/group.svg new file mode 100644 index 0000000..c9a6b64 --- /dev/null +++ b/sugar_network/static/httpdocs/images/group.svg @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [ + <!ENTITY stroke_color "#ffffff"> + <!ENTITY fill_color "#000000"> +]> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 55.125 55" + height="55px" + id="Layer_1" + version="1.1" + viewBox="0 0 55.125 55" + width="55.125px" + x="0px" + xml:space="preserve" + y="0px" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="groups.svg"><metadata + id="metadata3043"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs3041" /><sodipodi:namedview + pagecolor="#ffff5f" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:window-width="1364" + inkscape:window-height="725" + id="namedview3039" + showgrid="true" + inkscape:zoom="9.9636364" + inkscape:cx="15.364787" + inkscape:cy="26.136611" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="layer1"><inkscape:grid + type="xygrid" + id="grid3045" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /></sodipodi:namedview><g + inkscape:groupmode="layer" + id="layer1" + inkscape:label="Orig" + style="display:inline"><rect + style="fill:&stroke_color;" + id="rect3006" + width="51" + height="51" + x="2" + y="2" + ry="6.1807232" /><path + inkscape:connector-curvature="0" + d="m 20.80989,27.5 q -2.953112,0.09765 -4.830743,2.500005 h -2.442693 q -1.494787,0 -2.515621,-0.791021 Q 10,28.417965 10,26.894541 q 0,-6.894521 2.260412,-6.894521 0.109389,0 0.792964,0.410156 0.683576,0.410156 1.777334,0.830087 1.09376,0.419932 2.16927,0.419932 1.221365,0 2.424479,-0.449224 -0.09114,0.722662 -0.09114,1.289054 0,2.714858 1.476571,5.000009 z m 19.523435,12.441406 q 0,2.343736 -1.33072,3.701182 Q 37.671885,45.000034 35.466152,45 H 19.533848 q -2.205733,0 -3.536453,-1.357412 -1.330719,-1.357412 -1.330719,-3.701182 0,-1.035165 0.0638,-2.021489 0.0638,-0.986323 0.255209,-2.128916 0.191406,-1.142592 0.483077,-2.119141 0.291671,-0.976547 0.78384,-1.904287 0.492169,-0.927739 1.130221,-1.582041 0.638054,-0.654302 1.55859,-1.044907 0.920536,-0.390605 2.032543,-0.39064 0.182283,0 0.783839,0.419932 0.601559,0.419931 1.330721,0.937515 0.729162,0.517583 1.950525,0.937514 1.221363,0.419933 2.460942,0.419933 1.239578,0 2.460941,-0.419933 1.221363,-0.419931 1.950525,-0.937514 0.729163,-0.517584 1.33072,-0.937515 0.601558,-0.419932 0.783841,-0.419932 1.111974,0 2.032543,0.39064 0.920567,0.39064 1.558588,1.044907 0.638021,0.654268 1.130221,1.582041 0.492203,0.927773 0.783842,1.904287 0.291638,0.976514 0.483077,2.119141 0.191438,1.142628 0.255208,2.128916 0.06377,0.98629 0.0638,2.021489 z M 21.666657,15.00001 q 0,2.070297 -1.367184,3.535171 -1.367183,1.464873 -3.299493,1.464839 -1.932308,-3.5e-5 -3.299491,-1.464839 -1.367183,-1.464805 -1.367183,-3.535171 0,-2.070366 1.367183,-3.535171 Q 15.067672,10.000034 16.99998,10 q 1.93231,-3.4e-5 3.299493,1.464839 1.367184,1.464873 1.367184,3.535171 z m 12.833339,7.499981 q 0,3.105463 -2.05079,5.302738 -2.05079,2.197276 -4.949221,2.197276 -2.898434,0 -4.949224,-2.197276 -2.05079,-2.197275 -2.05079,-5.302738 0,-3.105464 2.05079,-5.30274 2.05079,-2.197276 4.949224,-2.197276 2.898431,0 4.949221,2.197276 2.05079,2.197276 2.05079,5.30274 z M 45,26.894541 q 0,1.523424 -1.020833,2.314443 -1.020834,0.791021 -2.515621,0.791021 H 39.020853 Q 37.143253,27.597652 34.19011,27.5 q 1.476571,-2.285152 1.476571,-5.000009 0,-0.566393 -0.09114,-1.289053 1.203114,0.449223 2.424479,0.449223 1.07551,0 2.16927,-0.419932 1.093758,-0.419931 1.777334,-0.830087 0.683575,-0.410157 0.792964,-0.410157 Q 45,19.999985 45,26.894507 z M 42.666663,15.00001 q 0,2.070297 -1.367183,3.535171 -1.367183,1.464873 -3.299493,1.464839 -1.93231,-3.5e-5 -3.299492,-1.464839 -1.367183,-1.464805 -1.367183,-3.535171 0,-2.070366 1.367183,-3.535171 Q 36.067677,10.000034 37.999987,10 q 1.93231,-3.4e-5 3.299493,1.464839 1.367183,1.464873 1.367183,3.535171 z" + id="path2988" + style="fill:&fill_color;" /></g></svg> diff --git a/sugar_network/static/httpdocs/images/missing-preview.png b/sugar_network/static/httpdocs/images/missing-preview.png Binary files differnew file mode 100644 index 0000000..64f5077 --- /dev/null +++ b/sugar_network/static/httpdocs/images/missing-preview.png diff --git a/sugar_network/static/httpdocs/images/missing.png b/sugar_network/static/httpdocs/images/missing.png Binary files differindex 8d6c26d..c3907f7 100644 --- a/sugar_network/static/httpdocs/images/missing.png +++ b/sugar_network/static/httpdocs/images/missing.png diff --git a/sugar_network/static/httpdocs/images/missing.svg b/sugar_network/static/httpdocs/images/missing.svg index cba7e35..d11c283 100644 --- a/sugar_network/static/httpdocs/images/missing.svg +++ b/sugar_network/static/httpdocs/images/missing.svg @@ -1,69 +1,70 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" + xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.0" - width="75" - height="75" - viewBox="-13.5 -13.5 75 75" - id="svg1872" - sodipodi:version="0.32" - inkscape:version="0.44" - sodipodi:docname="stock-missing.svg" - sodipodi:docbase="/home/marco/sugar-jhbuild/source/artwork/art/icon-theme/scalable/stock"> - <metadata - id="metadata42"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <sodipodi:namedview - inkscape:window-height="624" - inkscape:window-width="860" - inkscape:pageshadow="2" - inkscape:pageopacity="0.0" - guidetolerance="10.0" - gridtolerance="10.0" - objecttolerance="10.0" - borderopacity="1.0" - bordercolor="#666666" + enable-background="new 0 0 55.125 55" + height="55px" + id="Layer_1" + version="1.1" + viewBox="0 0 55.125 55" + width="55.125px" + x="0px" + xml:space="preserve" + y="0px" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="missing.svg"><metadata + id="metadata3043"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs3041" /><sodipodi:namedview pagecolor="#ffffff" - id="base" - inkscape:zoom="8.4791667" - inkscape:cx="24" - inkscape:cy="24.058968" - inkscape:window-x="55" - inkscape:window-y="49" - inkscape:current-layer="svg1872" /> - <defs - id="defs1874" /> - <g - id="layer1"> - <path - d="M 46.857141 26.285715 A 25.142857 16.714285 0 1 1 -3.4285717,26.285715 A 25.142857 16.714285 0 1 1 46.857141 26.285715 z" - transform="matrix(0.889463,0,0,1.337995,4.685959,-11.17014)" - style="opacity:0.66976743;fill:#8a8c90;fill-opacity:1;stroke:black;stroke-width:3;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - id="path4550" /> - <text - x="4.7315407" - y="46.846149" - transform="scale(1.186648,0.84271)" - style="font-size:50.32819366px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - id="text4552" - xml:space="preserve"><tspan - x="4.7315407" - y="46.846149" - id="tspan4554" /></text> - </g> -</svg> + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:window-width="1364" + inkscape:window-height="725" + id="namedview3039" + showgrid="true" + inkscape:zoom="8" + inkscape:cx="3.412668" + inkscape:cy="28.88286" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="layer1" + showguides="true" + inkscape:guide-bbox="true" + showborder="true"><inkscape:grid + type="xygrid" + id="grid3045" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /><sodipodi:guide + orientation="0,1" + position="21.375,63.75" + id="guide3095" /></sodipodi:namedview><g + inkscape:groupmode="layer" + id="layer1" + inkscape:label="Orig" + style="display:inline"><g + id="g3018" + transform="matrix(1.0024382,0,0,1.0033449,-0.06721282,-0.09913801)" + style="fill:#e5e5e5;fill-opacity:1"><path + inkscape:connector-curvature="0" + id="path3014" + d="M 7.312668,52.88195 C 6.7099324,52.779031 5.4955186,52.338195 5.0176599,52.048855 4.2658562,51.593644 3.2489622,50.517012 2.8351314,49.738115 2.0161815,48.196716 2.062668,49.534599 2.062668,27.506609 2.062668,5.6552305 2.0232307,6.8739053 2.7786566,5.3814313 3.498485,3.9592864 4.8883161,2.803557 6.4312977,2.3440372 7.264056,2.096031 7.5895024,2.09214 27.500168,2.09214 c 19.910665,0 20.236112,0.00389 21.06887,0.2518972 1.542982,0.4595198 2.932812,1.6152492 3.652641,3.0373941 0.755426,1.492474 0.715989,0.2737992 0.715989,22.1251777 0,22.017872 0.04589,20.691205 -0.768746,22.224531 -0.427042,0.803788 -1.433087,1.870171 -2.178743,2.309416 -0.280494,0.16523 -0.842994,0.427244 -1.25,0.582251 l -0.740011,0.281833 -20.1875,0.01534 c -11.103125,0.0084 -20.328125,-0.0087 -20.5,-0.03802 z m 23.674911,-8.174335 c 3.489854,-0.7094 6.352566,-2.252699 8.895104,-4.795381 3.21359,-3.213773 4.905765,-7.022684 5.140214,-11.570094 0.158646,-3.07712 -0.476745,-6.069858 -1.866614,-8.791884 -2.469169,-4.83581 -6.81136,-8.138539 -12.218615,-9.293643 -0.81477,-0.174052 -1.61625,-0.226973 -3.4375,-0.226973 -1.82125,0 -2.62273,0.05292 -3.4375,0.226973 -5.407255,1.155104 -9.749446,4.457833 -12.218615,9.293643 -2.4511324,4.800485 -2.5312113,10.635604 -0.212619,15.492894 2.605326,5.457974 7.892106,9.232251 13.898061,9.921944 1.408629,0.161758 3.99615,0.0397 5.458084,-0.257479 l 0,0 z" + style="fill:#e5e5e5;fill-opacity:1;stroke:none" /><path + inkscape:connector-curvature="0" + id="path3016" + d="M 24.978969,41.781971 C 16.145314,40.179195 10.799373,30.889246 13.900132,22.52964 c 1.747089,-4.710129 5.756064,-8.166365 10.744487,-9.263088 1.348135,-0.296392 4.362963,-0.296392 5.711098,0 4.894498,1.076073 8.905941,4.469126 10.634216,8.994886 0.585261,1.532597 0.788962,2.39317 0.936335,3.955702 0.698281,7.403629 -4.583521,14.270159 -11.973724,15.566266 -1.266075,0.222047 -3.745807,0.221332 -4.973575,-0.0014 l 0,2e-6 z m -3.452783,-5.086423 c 0.104108,-0.0864 0.415792,-0.633848 0.692631,-1.216546 1.070481,-2.253171 2.963376,-3.511862 5.281351,-3.511862 2.327261,0 4.210227,1.257339 5.291596,3.53343 0.502986,1.058694 0.831835,1.421421 1.333404,1.470764 0.622337,0.06123 0.961284,-0.02897 1.322817,-0.351999 0.785237,-0.701609 0.548547,-2.027396 -0.696221,-3.899794 -1.01576,-1.527921 -2.584326,-2.716596 -4.38378,-3.32207 -3.754919,-1.263443 -7.99672,0.129084 -10.119412,3.32207 -1.189591,1.7894 -1.465414,3.149908 -0.777967,3.837354 0.517901,0.517901 1.517382,0.585317 2.055581,0.138653 l 0,0 z M 23.027949,24.27353 c 1.062891,-0.529661 1.557446,-1.360203 1.562781,-2.624492 0.0074,-1.761863 -1.368456,-3.036782 -3.139072,-2.908708 -2.473463,0.178915 -3.621562,3.064289 -1.968455,4.947074 0.828346,0.943434 2.329588,1.191665 3.544746,0.586126 l 0,0 z m 11.598291,0.08549 c 2.072782,-0.941644 2.229132,-3.980824 0.267195,-5.193796 -1.98621,-1.22798 -4.49363,0.161006 -4.483828,2.483817 0.0036,0.856027 0.137445,1.275425 0.60089,1.883033 0.730373,0.95757 2.458305,1.352759 3.615743,0.826946 l 0,0 z" + style="fill:#e5e5e5;fill-opacity:1;stroke:none" /></g></g></svg>
\ No newline at end of file diff --git a/sugar_network/static/httpdocs/images/package-preview.png b/sugar_network/static/httpdocs/images/package-preview.png Binary files differnew file mode 100644 index 0000000..c6cf086 --- /dev/null +++ b/sugar_network/static/httpdocs/images/package-preview.png diff --git a/sugar_network/static/httpdocs/images/package.png b/sugar_network/static/httpdocs/images/package.png Binary files differindex b8134cf..24bd5ac 100644 --- a/sugar_network/static/httpdocs/images/package.png +++ b/sugar_network/static/httpdocs/images/package.png diff --git a/sugar_network/static/httpdocs/images/package.svg b/sugar_network/static/httpdocs/images/package.svg new file mode 100644 index 0000000..a5fd32d --- /dev/null +++ b/sugar_network/static/httpdocs/images/package.svg @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 55.125 55" + height="55px" + id="Layer_1" + version="1.1" + viewBox="0 0 55.125 55" + width="55.125px" + x="0px" + xml:space="preserve" + y="0px" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="package.svg"><metadata + id="metadata3043"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs3041" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:window-width="1364" + inkscape:window-height="725" + id="namedview3039" + showgrid="true" + inkscape:zoom="8" + inkscape:cx="25.537668" + inkscape:cy="28.88286" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="layer1" + showguides="true" + inkscape:guide-bbox="true" + showborder="true"><inkscape:grid + type="xygrid" + id="grid3045" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /><sodipodi:guide + orientation="0,1" + position="21.375,63.75" + id="guide3095" /></sodipodi:namedview><g + inkscape:groupmode="layer" + id="layer1" + inkscape:label="Orig" + style="display:inline"><rect + style="fill:#fdd99b;fill-opacity:1" + id="rect3006" + width="51" + height="51" + x="-53" + y="2" + ry="6.1807232" + transform="scale(-1,1)" /><path + inkscape:connector-curvature="0" + d="m 21.272799,37.045483 q 0,-1.107944 -0.809649,-1.917636 -0.80965,-0.809686 -1.917636,-0.809649 -1.107979,3.6e-5 -1.917628,0.809649 -0.80965,0.809613 -0.80965,1.917636 0,1.108022 0.80965,1.917635 0.809649,0.809614 1.917628,0.809649 1.107986,3.6e-5 1.917636,-0.809649 0.809649,-0.809686 0.809649,-1.917635 z M 13.090987,26.136378 h 8.181855 v -5.454569 h -3.366501 q -0.277004,0 -0.468734,0.191772 l -4.154854,4.154854 q -0.191766,0.191765 -0.191766,0.468734 v 0.639209 z m 27.272772,10.909105 q 0,-1.107944 -0.80965,-1.917636 -0.80965,-0.809686 -1.917635,-0.809649 -1.107986,3.6e-5 -1.917636,0.809649 -0.809649,0.809613 -0.809649,1.917636 0,1.108022 0.809649,1.917635 0.80965,0.809614 1.917636,0.809649 1.107985,3.6e-5 1.917635,-0.809649 0.80965,-0.809686 0.80965,-1.917635 z m 5.45457,-23.181866 v 21.818244 q 0,0.319583 -0.08524,0.564634 -0.08524,0.245052 -0.287631,0.394159 -0.202393,0.149114 -0.35158,0.245016 -0.149185,0.09591 -0.500729,0.12786 -0.351543,0.03198 -0.479396,0.04259 -0.12786,0.01069 -0.543315,0 -0.415448,-0.01069 -0.479397,-0.01069 0,2.258515 -1.598009,3.856561 -1.59801,1.598045 -3.85656,1.598009 -2.258552,-3.6e-5 -3.856562,-1.598009 -1.598009,-1.597973 -1.598009,-3.856561 h -8.181854 q 0,2.258515 -1.59801,3.856561 -1.598008,1.598045 -3.856562,1.598009 -2.258541,-3.2e-5 -3.856557,-1.598004 -1.59801,-1.597974 -1.59801,-3.856562 h -1.363621 q -0.06388,0 -0.479395,0.01069 -0.415493,0.01069 -0.543318,0 -0.127816,-0.01069 -0.479394,-0.04259 Q 9.8736003,36.981554 9.72445,36.885674 9.5753064,36.789764 9.372871,36.640654 9.1704416,36.491547 9.08524,36.246495 9.000042,36.001444 9,35.681861 q 0,-0.553979 0.4048281,-0.9588 0.404821,-0.404827 0.9587929,-0.404827 v -6.818191 q 0,-0.170441 -0.01069,-0.745745 -0.01069,-0.575298 0,-0.809649 0.01069,-0.234346 0.05328,-0.735075 0.04259,-0.500729 0.13848,-0.78836 0.09586,-0.28763 0.298299,-0.649872 0.20243,-0.362248 0.479397,-0.639217 l 4.218767,-4.218766 q 0.40483,-0.404821 1.075991,-0.681825 0.671169,-0.277011 1.246473,-0.277011 h 3.40911 v -4.090906 q 0,-0.553972 0.404829,-0.958799 0.404821,-0.404822 0.9588,-0.404822 h 21.818236 q 0.553979,0 0.958801,0.404822 0.404827,0.404827 0.404827,0.958799 z" + id="path4" + style="fill:#816647" /></g></svg>
\ No newline at end of file diff --git a/sugar_network/toolkit/__init__.py b/sugar_network/toolkit/__init__.py index 95d89dc..5988e5d 100644 --- a/sugar_network/toolkit/__init__.py +++ b/sugar_network/toolkit/__init__.py @@ -499,14 +499,10 @@ class mkdtemp(str): shutil.rmtree(self) -def svg_to_png(data, w, h, replace_color=None): +def svg_to_png(data, w, h): import rsvg import cairo - if replace_color: - from sugar_network.toolkit.sugar import color_svg - data = color_svg(data, replace_color) - svg = rsvg.Handle(data=data) surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h) context = cairo.Context(surface) diff --git a/sugar_network/toolkit/router.py b/sugar_network/toolkit/router.py index 6309301..7f2c268 100644 --- a/sugar_network/toolkit/router.py +++ b/sugar_network/toolkit/router.py @@ -214,6 +214,10 @@ class Request(dict): if value is not None: return int(value) + @content_length.setter + def content_length(self, value): + self.environ['CONTENT_LENGTH'] = str(value) + @property def content_stream(self): if self._content_stream is _NOT_SET: @@ -224,6 +228,10 @@ class Request(dict): self._content_stream = _ContentStream(s, self.content_length) return self._content_stream + @content_stream.setter + def content_stream(self, value): + self._content_stream = value + @property def resource(self): if self.path: diff --git a/tests/integration/master_personal.py b/tests/integration/master_personal.py index 6c1dfed..82c66b2 100755 --- a/tests/integration/master_personal.py +++ b/tests/integration/master_personal.py @@ -77,6 +77,7 @@ class MasterPersonalTest(tests.Test): 'title': 'title_1', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview1', 'layer': 'pilot', }) @@ -85,6 +86,7 @@ class MasterPersonalTest(tests.Test): 'title': 'title_2', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview2', 'layer': 'pilot', }) @@ -95,6 +97,7 @@ class MasterPersonalTest(tests.Test): 'title': 'title_3', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview3', 'layer': 'pilot', }) @@ -103,6 +106,7 @@ class MasterPersonalTest(tests.Test): 'title': 'title_4', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview4', 'layer': 'pilot', }) @@ -129,6 +133,7 @@ class MasterPersonalTest(tests.Test): 'title': 'title_5', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview5', 'layer': 'pilot', }) @@ -141,6 +146,7 @@ class MasterPersonalTest(tests.Test): 'title': 'title_6', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview6', 'layer': 'pilot', }) diff --git a/tests/integration/master_slave.py b/tests/integration/master_slave.py index f521a2b..9a870e3 100755 --- a/tests/integration/master_slave.py +++ b/tests/integration/master_slave.py @@ -65,6 +65,7 @@ class MasterSlaveTest(tests.Test): 'title': 'title1', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview1', 'layer': 'pilot', }) @@ -75,6 +76,7 @@ class MasterSlaveTest(tests.Test): 'title': 'title2', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview2', 'layer': 'pilot', }) @@ -115,6 +117,7 @@ class MasterSlaveTest(tests.Test): 'title': 'title3', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview3', 'layer': 'pilot', }) @@ -128,6 +131,7 @@ class MasterSlaveTest(tests.Test): 'title': 'title4', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview4', 'layer': 'pilot', }) @@ -187,6 +191,7 @@ class MasterSlaveTest(tests.Test): 'title': 'title_1', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview1', 'layer': 'pilot', }) @@ -195,6 +200,7 @@ class MasterSlaveTest(tests.Test): 'title': 'title_2', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview2', 'layer': 'pilot', }) @@ -205,6 +211,7 @@ class MasterSlaveTest(tests.Test): 'title': 'title_3', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview3', 'layer': 'pilot', }) @@ -213,6 +220,7 @@ class MasterSlaveTest(tests.Test): 'title': 'title_4', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview4', 'layer': 'pilot', }) @@ -237,6 +245,7 @@ class MasterSlaveTest(tests.Test): 'title': 'title_5', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview5', 'layer': 'pilot', }) @@ -249,6 +258,7 @@ class MasterSlaveTest(tests.Test): 'title': 'title_6', 'summary': 'summary', 'description': 'description', + 'artifact_icon': 'artifact_icon', 'preview': 'preview6', 'layer': 'pilot', }) diff --git a/tests/integration/node_client.py b/tests/integration/node_client.py index a44ce77..c4de2fb 100755 --- a/tests/integration/node_client.py +++ b/tests/integration/node_client.py @@ -75,7 +75,7 @@ class NodeClientTest(tests.Test): def test_ReleaseContext(self): context = self.cli(['POST', '/context'], stdin={ - 'type': 'content', + 'type': 'book', 'title': 'title', 'summary': 'summary', 'description': 'description', diff --git a/tests/units/client/implementations.py b/tests/units/client/implementations.py index 06902a0..b77c558 100755 --- a/tests/units/client/implementations.py +++ b/tests/units/client/implementations.py @@ -359,7 +359,7 @@ class Implementations(tests.Test): conn.post(['context'], { 'guid': 'document', - 'type': 'content', + 'type': 'book', 'title': 'title', 'summary': 'summary', 'description': 'description', @@ -432,7 +432,7 @@ class Implementations(tests.Test): conn.post(['context'], { 'guid': 'document', - 'type': 'content', + 'type': 'book', 'title': 'title', 'summary': 'summary', 'description': 'description', diff --git a/tests/units/client/offline_routes.py b/tests/units/client/offline_routes.py index 2300b7a..a163769 100755 --- a/tests/units/client/offline_routes.py +++ b/tests/units/client/offline_routes.py @@ -141,7 +141,7 @@ class OfflineRoutes(tests.Test): ipc = self.start_offline_client() guid = ipc.post(['context'], { - 'type': 'activity', + 'type': 'package', 'title': 'title', 'summary': 'summary', 'description': 'description', @@ -159,13 +159,13 @@ class OfflineRoutes(tests.Test): ipc.get(['context'], reply=['preview'])['result']) self.assertEqual( - file(src_root + '/sugar_network/static/httpdocs/images/missing.png').read(), + file(src_root + '/sugar_network/static/httpdocs/images/package.png').read(), ipc.request('GET', ['context', guid, 'icon']).content) self.assertEqual( - {'icon': 'http://127.0.0.1:5555/static/images/missing.png'}, + {'icon': 'http://127.0.0.1:5555/static/images/package.png'}, ipc.get(['context', guid], reply=['icon'])) self.assertEqual( - [{'icon': 'http://127.0.0.1:5555/static/images/missing.png'}], + [{'icon': 'http://127.0.0.1:5555/static/images/package.png'}], ipc.get(['context'], reply=['icon'])['result']) def test_favorite(self): diff --git a/tests/units/client/online_routes.py b/tests/units/client/online_routes.py index 6314948..ddf8a4c 100755 --- a/tests/units/client/online_routes.py +++ b/tests/units/client/online_routes.py @@ -228,7 +228,7 @@ class OnlineRoutes(tests.Test): ipc = IPCConnection() guid = ipc.post(['context'], { - 'type': 'activity', + 'type': 'package', 'title': 'title', 'summary': 'summary', 'description': 'description', @@ -246,13 +246,13 @@ class OnlineRoutes(tests.Test): ipc.get(['context'], reply=['preview'])['result']) self.assertEqual( - file(src_root + '/sugar_network/static/httpdocs/images/missing.png').read(), + file(src_root + '/sugar_network/static/httpdocs/images/package.png').read(), ipc.request('GET', ['context', guid, 'icon']).content) self.assertEqual( - {'icon': 'http://127.0.0.1:8888/static/images/missing.png'}, + {'icon': 'http://127.0.0.1:8888/static/images/package.png'}, ipc.get(['context', guid], reply=['icon'])) self.assertEqual( - [{'icon': 'http://127.0.0.1:8888/static/images/missing.png'}], + [{'icon': 'http://127.0.0.1:8888/static/images/package.png'}], ipc.get(['context'], reply=['icon'])['result']) def test_favorite(self): @@ -486,7 +486,7 @@ Can't find all required implementations: coroutine.dispatch() context = ipc.post(['context'], { - 'type': 'content', + 'type': 'book', 'title': 'title', 'summary': 'summary', 'description': 'description', @@ -545,7 +545,7 @@ Can't find all required implementations: [(i.guid, i['layer']) for i in local['context'].find(reply='layer')[0]]) self.assertEqual({ 'layer': ['clone'], - 'type': ['content'], + 'type': ['book'], 'author': {tests.UID: {'role': 3, 'name': 'test', 'order': 0}}, 'title': {'en-us': 'title'}, }, @@ -590,7 +590,7 @@ Can't find all required implementations: self.assertEqual([], ipc.get(['context', context, 'layer'])) self.assertEqual({ 'layer': [], - 'type': ['content'], + 'type': ['book'], 'author': {tests.UID: {'role': 3, 'name': 'test', 'order': 0}}, 'title': {'en-us': 'title'}, }, @@ -1181,7 +1181,7 @@ Can't find all required implementations: ipc = IPCConnection() guid = ipc.post(['context'], { - 'type': 'content', + 'type': 'book', 'title': 'remote', 'summary': 'summary', 'description': 'description', diff --git a/tests/units/client/server_routes.py b/tests/units/client/server_routes.py index c477ff2..47282ce 100755 --- a/tests/units/client/server_routes.py +++ b/tests/units/client/server_routes.py @@ -124,7 +124,7 @@ class ServerRoutesTest(tests.Test): ipc = IPCConnection() guid = ipc.post(['context'], { - 'type': 'activity', + 'type': 'package', 'title': 'title', 'summary': 'summary', 'description': 'description', @@ -142,13 +142,13 @@ class ServerRoutesTest(tests.Test): ipc.get(['context'], reply=['preview'])['result']) self.assertEqual( - file(src_root + '/sugar_network/static/httpdocs/images/missing.png').read(), + file(src_root + '/sugar_network/static/httpdocs/images/package.png').read(), ipc.request('GET', ['context', guid, 'icon']).content) self.assertEqual( - {'icon': 'http://127.0.0.1:5555/static/images/missing.png'}, + {'icon': 'http://127.0.0.1:5555/static/images/package.png'}, ipc.get(['context', guid], reply=['icon'])) self.assertEqual( - [{'icon': 'http://127.0.0.1:5555/static/images/missing.png'}], + [{'icon': 'http://127.0.0.1:5555/static/images/package.png'}], ipc.get(['context'], reply=['icon'])['result']) def test_PopulateNode(self): diff --git a/tests/units/model/context.py b/tests/units/model/context.py index 25b21b4..b48db6f 100755 --- a/tests/units/model/context.py +++ b/tests/units/model/context.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # sugar-lint: disable +from os.path import exists + from __init__ import tests from sugar_network.node import obs @@ -40,6 +42,21 @@ class ContextTest(tests.Test): }) self.assertEqual(['common', 'bar'], ipc.get(['context', guid, 'layer'])) + def test_DefaultImages(self): + self.start_online_client() + ipc = IPCConnection() + + guid = ipc.post(['context'], { + 'guid': 'guid', + 'type': 'activity', + 'title': 'title', + 'summary': 'summary', + 'description': 'description', + }) + assert exists('master/context/gu/guid/artifact_icon.blob') + assert exists('master/context/gu/guid/icon.blob') + assert exists('master/context/gu/guid/preview.blob') + if __name__ == '__main__': tests.main() diff --git a/tests/units/model/implementation.py b/tests/units/model/implementation.py index 6b4bbc3..070df70 100755 --- a/tests/units/model/implementation.py +++ b/tests/units/model/implementation.py @@ -70,7 +70,7 @@ class ImplementationTest(tests.Test): self.node_volume['context'].create({ 'guid': 'context', - 'type': 'content', + 'type': 'book', 'title': 'title', 'summary': 'summary', 'description': 'description', diff --git a/tests/units/node/node.py b/tests/units/node/node.py index cf0bf73..5c7cb58 100755 --- a/tests/units/node/node.py +++ b/tests/units/node/node.py @@ -817,8 +817,8 @@ class NodeTest(tests.Test): svg = '\n'.join([ '<?xml version="1.0" encoding="UTF-8"?>', '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [', - ' <!ENTITY fill_color "#FFFFFF">', - ' <!ENTITY stroke_color "#010101">', + ' <!ENTITY fill_color "#123456">', + ' <!ENTITY stroke_color "#123456">', ']>', '<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">', ' <rect x="3" y="7" width="44" height="36" style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3"/>', |