Exemplo n.º 1
0
 def webmanifest(self):
     """ Returns a WebManifest describing the metadata associated with a web application.
     Using this metadata, user agents can provide developers with means to create user 
     experiences that are more comparable to that of a native application.
     """
     website = request.website
     manifest = {
         'name': website.events_app_name,
         'short_name': website.events_app_name,
         'description':
         _('%s Online Events Application') % website.company_id.name,
         'scope': url_for('/event'),
         'start_url': url_for('/event'),
         'display': 'standalone',
         'background_color': '#ffffff',
         'theme_color': '#009EFB',
     }
     icon_sizes = ['192x192', '512x512']
     manifest['icons'] = [{
         'src':
         website.image_url(website, 'app_icon', size=size),
         'sizes':
         size,
         'type':
         'image/png',
     } for size in icon_sizes]
     body = json.dumps(manifest, default=ustr)
     response = request.make_response(body, [
         ('Content-Type', 'application/manifest+json'),
     ])
     return response
Exemplo n.º 2
0
 def service_worker(self):
     """ Returns a ServiceWorker javascript file scoped for website_event
     """
     sw_file = get_module_resource('website_event_track',
                                   'static/src/js/service_worker.js')
     with open(sw_file, 'r') as fp:
         body = fp.read()
     js_cdn_url = 'undefined'
     if request.website.cdn_activated:
         cdn_url = request.website.cdn_url.replace('"', '%22').replace(
             '\x5c', '%5C')
         js_cdn_url = '"%s"' % cdn_url
     body = body.replace('__FLECTRA_CDN_URL__', js_cdn_url)
     response = request.make_response(body, [
         ('Content-Type', 'text/javascript'),
         ('Service-Worker-Allowed', url_for('/event')),
     ])
     return response
Exemplo n.º 3
0
 def get_suggested_controllers(self):
     suggested_controllers = super(Website,
                                   self).get_suggested_controllers()
     suggested_controllers.append(
         (_('Events'), url_for('/event'), 'website_event'))
     return suggested_controllers
Exemplo n.º 4
0
 def get_suggested_controllers(self):
     suggested_controllers = super(Website,
                                   self).get_suggested_controllers()
     suggested_controllers.append(
         (_('Members'), url_for('/members'), 'website_membership'))
     return suggested_controllers