def get_sort_capabilities(self): """ Returns the UPnP sort capabilities. :return: (str) UPnP sort capabilities :since: v0.2.00 """ didl_fields = Hook.call("dNG.pas.upnp.Resource.getSortableDidlFields", client_user_agent = self.client_user_agent) if (type(didl_fields) != list or len(didl_fields) < 1): didl_fields = None if (didl_fields is None): _return = "" else: _return = ",".join(InputFilter.filter_unique_list(didl_fields)) return _return
def render(self, content): """ Renders content ready for output from the given OSet template. :param content: Content data :return: (str) Rendered content :since: v1.0.0 """ # pylint: disable=no-member if (self._log_handler is not None): self._log_handler.debug("#echo(__FILEPATH__)# -{0!r}.render()- (#echo(__LINE__)#)", self, context = "pas_http_core") theme = self.theme theme_path = theme.replace(".", path.sep) theme_subtype = self.theme_subtype file_path_name = path.join(self.path, theme_path, "{0}.tsc".format(theme_subtype)) if (theme_subtype != "site" and (not os.access(file_path_name, os.R_OK))): file_path_name = path.join(self.path, theme_path, "site.tsc") # theme_data = (None if (self.cache_instance is None) else self.cache_instance.get_file(file_path_name)) if (theme_data is None): file_obj = File() if (not file_obj.open(file_path_name, True, "r")): raise IOException("Failed to open theme file for '{0}'".format(theme)) theme_data = file_obj.read() file_obj.close() if (theme_data is None): raise IOException("Failed to read theme file for '{0}'".format(theme)) if (self.cache_instance is not None): self.cache_instance.set_file(file_path_name, theme_data) # """ Read corresponding theme configuration """ file_path_name = file_path_name[:-3] + "json" Settings.read_file(file_path_name) self.content = { "canonical_url": self.canonical_url, "page_description": self.description, "page_title": self.title, "page_content": content } css_files = (self.css_files.copy() if (hasattr(self.css_files, "copy")) else copy(self.css_files)) js_files = (self.js_files.copy() if (hasattr(self.js_files, "copy")) else copy(self.js_files)) webc_files = (self.webc_files.copy() if (hasattr(self.webc_files, "copy")) else copy(self.webc_files)) theme_settings = self.settings if (theme_settings is not None): if ("css_files" in theme_settings): css_files += theme_settings['css_files'] if ("js_files" in theme_settings): js_files += theme_settings['js_files'] if ("webc_files" in theme_settings): webc_files += theme_settings['webc_files'] if ("l10n_inits" in theme_settings): for file_basename in theme_settings['l10n_inits']: L10n.init(file_basename) # app_entry_point = Hook.call("dNG.pas.http.App.getBrowserEntryPointUrl", renderer = self, theme_subtype_settings = theme_settings ) app_cache_manifest_url = Hook.call("dNG.pas.http.App.getBrowserCacheManifestUrl", renderer = self, theme_subtype_settings = theme_settings, entry_point = app_entry_point ) app_web_manifest_url = Hook.call("dNG.pas.http.App.getBrowserWebManifestUrl", renderer = self, theme_subtype_settings = theme_settings, entry_point = app_entry_point ) if (app_entry_point is not None): self.content['app_entry_point'] = app_entry_point if (app_cache_manifest_url is None): app_cache_manifest_url = Link().build_url(Link.TYPE_VIRTUAL_PATH, { "__virtual__": "/app/cache.manifest" } ) # if (app_web_manifest_url is None): app_web_manifest_url = Link().build_url(Link.TYPE_VIRTUAL_PATH, { "__virtual__": "/app/web.manifest" } ) # # if (app_cache_manifest_url is not None): self.content['app_cache_manifest'] = app_cache_manifest_url if (app_web_manifest_url is not None): self.content['app_web_manifest'] = app_web_manifest_url # css_files = InputFilter.filter_unique_list(css_files) if (len(css_files) > 0): self.content['css_files'] = css_files js_files = InputFilter.filter_unique_list(js_files) if (len(js_files) > 0): self.content['js_files'] = js_files webc_files = InputFilter.filter_unique_list(webc_files) if (len(webc_files) > 0): self.content['webc_files'] = webc_files return self._parse(theme_data)