Exemplo n.º 1
0
def getGoogleTemplate(gadgetData):
    metadata = gadgetData['metadata']
    googleContext = Context({
        'platform':
        'google',
        'gadgetUri':
        metadata['gadgetUri'],
        'gadgetTitle':
        metadata['name'],
        'gadgetVendor':
        notEmptyValueOrDefault(metadata, 'vendor', metadata['owner']),
        'gadgetMail':
        notEmptyValueOrDefault(metadata, 'email',
                               settings.DEFAULT_EZWEB_AUTHOR_EMAIL),
        'gadgetDescription':
        notEmptyValueOrDefault(metadata, 'description', metadata['name']),
        'gadgetHeight':
        notEmptyValueOrDefault(metadata, 'height',
                               settings.DEFAULT_EZWEB_GADGET_HEIGHT),
        'gadgetWidth':
        notEmptyValueOrDefault(metadata, 'width',
                               settings.DEFAULT_EZWEB_GADGET_WIDTH),
        'gadgetPersistent':
        metadata['persistent'],
        'gadgetScreens':
        gadgetData['screens']
    })
    return loader.render_to_string(
        path.join('resources', 'gadget', 'googleTemplate.xml'), googleContext)
Exemplo n.º 2
0
    def __completeGadgetData(self, request):
        if request.POST.has_key('gadget'):
            json = simplejson.loads(request.POST['gadget'], encoding = 'utf-8')
        else:
            raise Exception ('Gadget parameter expected in screenflow json')

        gadgetData = getGadgetData(request.POST['screenflow'])

        metadata = gadgetData['metadata']
        #Gadget Data
        metadata['label'] = valueOrDefault(json, 'label', {'en-gb': 'FAST Gadget'})
        metadata['name'] = metadata['label']['en-gb']
        metadata['shortname'] =  valueOrDefault(json, 'shortname', 'FAST Gadget')
        metadata['owner'] =  notEmptyValueOrDefault(json, 'owner', 'Morfeo')
        metadata['vendor'] =  valueOrEmpty(json, 'vendor')
        metadata['version'] = notEmptyValueOrDefault(json, 'version', '1.0')
        metadata['description'] = valueOrDefault(json, 'description', {'en-gb': ''})
        metadata['description'] = metadata['description']['en-gb']
        metadata['imageURI'] = valueOrDefault(json, 'imageURI', 'http://demo.fast.morfeo-project.org/fast/images/FASTLogo.png')
        metadata['gadgetHomepage'] = valueOrEmpty(json, 'gadgetHomepage')
        metadata['height'] = valueOrEmpty(json, 'height')
        metadata['width'] = valueOrEmpty(json, 'width')
        metadata['persistent'] = valueOrDefault(json, 'persistent', 'false')[0].upper()=='T'
        #Author Data
        metadata['authorName'] =  valueOrEmpty(json, 'authorName')
        metadata['email'] = valueOrEmpty(json, 'email')
        metadata['authorHomepage'] = valueOrEmpty(json, 'authorHomepage')
        #Platforms
        metadata['platforms'] = valueOrDefault(json, 'platforms', [])

        return gadgetData
Exemplo n.º 3
0
def getGoogleTemplate(gadgetData):
    metadata = gadgetData['metadata']
    googleContext = Context({'platform': 'google',
                              'gadgetUri': metadata['gadgetUri'],
                              'gadgetTitle': metadata['name'],
                              'gadgetVendor': notEmptyValueOrDefault(metadata, 'vendor', metadata['owner']),
                              'gadgetMail': notEmptyValueOrDefault(metadata, 'email', settings.DEFAULT_EZWEB_AUTHOR_EMAIL),
                              'gadgetDescription': notEmptyValueOrDefault(metadata, 'description', metadata['name']),
                              'gadgetHeight': notEmptyValueOrDefault(metadata, 'height', settings.DEFAULT_EZWEB_GADGET_HEIGHT),
                              'gadgetWidth': notEmptyValueOrDefault(metadata, 'width', settings.DEFAULT_EZWEB_GADGET_WIDTH),
                              'gadgetPersistent': metadata['persistent'],
                              'gadgetScreens': gadgetData['screens']})
    return loader.render_to_string(path.join('resources','gadget','googleTemplate.xml'), googleContext);
Exemplo n.º 4
0
    def __completeGadgetData(self, request):
        if request.POST.has_key('gadget'):
            json = simplejson.loads(request.POST['gadget'], encoding='utf-8')
        else:
            raise Exception('Gadget parameter expected in screenflow json')

        gadgetData = getGadgetData(request.POST['screenflow'])

        metadata = gadgetData['metadata']
        #Gadget Data
        metadata['label'] = valueOrDefault(json, 'label',
                                           {'en-gb': 'FAST Gadget'})
        metadata['name'] = metadata['label']['en-gb']
        metadata['shortname'] = valueOrDefault(json, 'shortname',
                                               'FAST Gadget')
        metadata['owner'] = notEmptyValueOrDefault(json, 'owner', 'Morfeo')
        metadata['vendor'] = valueOrEmpty(json, 'vendor')
        metadata['version'] = notEmptyValueOrDefault(json, 'version', '1.0')
        metadata['description'] = valueOrDefault(json, 'description',
                                                 {'en-gb': ''})
        metadata['description'] = metadata['description']['en-gb']
        metadata['imageURI'] = valueOrDefault(
            json, 'imageURI',
            'http://demo.fast.morfeo-project.org/fast/images/FASTLogo.png')
        metadata['gadgetHomepage'] = valueOrEmpty(json, 'gadgetHomepage')
        metadata['height'] = valueOrEmpty(json, 'height')
        metadata['width'] = valueOrEmpty(json, 'width')
        metadata['persistent'] = valueOrDefault(json, 'persistent',
                                                'false')[0].upper() == 'T'
        #Author Data
        metadata['authorName'] = valueOrEmpty(json, 'authorName')
        metadata['email'] = valueOrEmpty(json, 'email')
        metadata['authorHomepage'] = valueOrEmpty(json, 'authorHomepage')
        #Platforms
        metadata['platforms'] = valueOrDefault(json, 'platforms', [])

        return gadgetData
Exemplo n.º 5
0
def getEzWebTemplate(gadgetData):
    metadata = gadgetData['metadata']
    ezWebContext = Context({'gadgetUri': metadata['gadgetUri'],
                            'gadgetTitle': metadata['name'],
                            'gadgetVendor': metadata['vendor'],
                            'gadgetVersion': metadata['version'],
                            'gadgetAuthor': notEmptyValueOrDefault(metadata, 'authorName', settings.DEFAULT_EZWEB_AUTHOR_NAME),
                            'gadgetMail': notEmptyValueOrDefault(metadata, 'email', settings.DEFAULT_EZWEB_AUTHOR_EMAIL),
                            'gadgetDescription': notEmptyValueOrDefault(metadata, 'description', metadata['name']),
                            'gadgetImageURI': notEmptyValueOrDefault(metadata, 'imageURI', settings.DEFAULT_GADGET_IMAGE_URI),
                            'gadgetWikiURI': notEmptyValueOrDefault(metadata, 'gadgetHomepage', settings.DEFAULT_GADGET_HOMEPAGE_URI),
                            'gadgetHeight': notEmptyValueOrDefault(metadata, 'height', settings.DEFAULT_EZWEB_GADGET_HEIGHT),
                            'gadgetWidth': notEmptyValueOrDefault(metadata, 'width', settings.DEFAULT_EZWEB_GADGET_WIDTH),
                            'gadgetPersistent': metadata['persistent'],
                            'gadgetSlots': gadgetData['prec'],
                            'gadgetEvents': gadgetData['post']})
    return loader.render_to_string(path.join('resources','gadget','ezwebTemplate.xml'), ezWebContext);
Exemplo n.º 6
0
def getEzWebTemplate(gadgetData):
    metadata = gadgetData['metadata']
    ezWebContext = Context({
        'gadgetUri':
        metadata['gadgetUri'],
        'gadgetTitle':
        metadata['name'],
        'gadgetVendor':
        metadata['vendor'],
        'gadgetVersion':
        metadata['version'],
        'gadgetAuthor':
        notEmptyValueOrDefault(metadata, 'authorName',
                               settings.DEFAULT_EZWEB_AUTHOR_NAME),
        'gadgetMail':
        notEmptyValueOrDefault(metadata, 'email',
                               settings.DEFAULT_EZWEB_AUTHOR_EMAIL),
        'gadgetDescription':
        notEmptyValueOrDefault(metadata, 'description', metadata['name']),
        'gadgetImageURI':
        notEmptyValueOrDefault(metadata, 'imageURI',
                               settings.DEFAULT_GADGET_IMAGE_URI),
        'gadgetWikiURI':
        notEmptyValueOrDefault(metadata, 'gadgetHomepage',
                               settings.DEFAULT_GADGET_HOMEPAGE_URI),
        'gadgetHeight':
        notEmptyValueOrDefault(metadata, 'height',
                               settings.DEFAULT_EZWEB_GADGET_HEIGHT),
        'gadgetWidth':
        notEmptyValueOrDefault(metadata, 'width',
                               settings.DEFAULT_EZWEB_GADGET_WIDTH),
        'gadgetPersistent':
        metadata['persistent'],
        'gadgetSlots':
        gadgetData['prec'],
        'gadgetEvents':
        gadgetData['post']
    })
    return loader.render_to_string(
        path.join('resources', 'gadget', 'ezwebTemplate.xml'), ezWebContext)