def _make_collection_root_link(): global _collection_root_link if _collection_root_link is None: _collection_root_link = node_url(get_collections_node().id) return _collection_root_link
def __init__(self, file, link_params, language, fullstyle_name, separator=None): node = file sys_filetypes = [unicode(x) for x in node.get_sys_filetypes()] attachment = node.files.filter_by(filetype=u"attachment").first() if attachment is None: attachment = node.files.filter( ~File.filetype.in_(sys_filetypes)).first() self.attachment = attachment self.datatype = node self.image = Markup(node.show_node_image()) self.text = Markup( node.show_node_text(separator=separator, language=language)) self.thumbnail = self.image if fullstyle_name: link_params["style"] = fullstyle_name self.link = node_url(**link_params) self.shopping_bag_link = u'shoppingBag(\'{}\')'.format(node.id) self.node = node
def _make_collection_root_link(): global _collection_root_link if _collection_root_link is None: _collection_root_link = node_url(get_collections_node().id) return _collection_root_link
def render_startpage_error(node, language): # note: append "?after=0" to node_link to display content of page as list ctx = { "node_link": node_url(node.id) + "?after=0", "language" : language } html = webconfig.theme.render_template("content_startpage_error.j2.jade", ctx) return html
def render_startpage_error(node, language): # note: append "?after=0" to node_link to display content of page as list ctx = { "node_link": node_url(node.id) + "?after=0", "language" : language } html = webconfig.theme.render_template("content_startpage_error.j2.jade", ctx) return html
def show_node_big(self, req, style_name=""): # style_name is ignored content = u"" link = node_url(self.id, files=1) sidebar = u"" pages = self.getStartpageDict() if self.get("system.sidebar") != "": for sb in self.get("system.sidebar").split(";"): if sb: l, fn = sb.split(":") if l == lang(req): for f in self.getFiles(): if fn.endswith(f.getName()): sidebar = includetemplate( self, f.retrieveFile(), {}) if sidebar: sidebar = req.getTAL("contenttypes/container.html", {"content": sidebar}, macro="addcolumn") else: sidebar = u"" if "item" in req.params: fname = req.params.get("item") fname_allowed = False # accept only filenames which starts with a number and the number is a node_id and the current_user has # read access to this node, to avoid delivering of systemfiles like /etc/passwd # with e.g. 604993?item=../../../../../../../../../../etc/passwd node_id_list = self.item_file_pattern.findall(fname) if node_id_list: node_id = node_id_list[0] node = db.query(Node).get(node_id) fname_allowed = node and node.has_read_access( user=current_user) fpath = "{}html/{}".format(config.get("paths.datadir"), fname) if fname_allowed and os.path.isfile(fpath): with codecs.open(fpath, "r", encoding='utf8') as c: content = c.read() if sidebar: return u'<div id="portal-column-one">{}</div>{}'.format( content, sidebar) return content spn = self.getStartpageFileNode(lang(req)) if spn: long_path = spn.retrieveFile() if os.path.isfile(long_path) and fileIsNotEmpty(long_path): content = includetemplate(self, long_path, {'${next}': link}) if content: if sidebar: return u'<div id="portal-column-one">{}</div>{}'.format( content, sidebar) return content return u'{}{}'.format(content, sidebar)
def show_node_big(self, req, style_name=""): # style_name is ignored content = u"" link = node_url(self.id, files=1) sidebar = u"" pages = self.getStartpageDict() if self.get("system.sidebar") != "": for sb in self.get("system.sidebar").split(";"): if sb: l, fn = sb.split(":") if l == lang(req): for f in self.getFiles(): if fn.endswith(f.getName()): sidebar = includetemplate(self, f.retrieveFile(), {}) if sidebar: sidebar = req.getTAL("contenttypes/container.html", {"content": sidebar}, macro="addcolumn") else: sidebar = u"" if "item" in req.params: fname = req.params.get("item") fname_allowed = False # accept only filenames which starts with a number and the number is a node_id and the current_user has # read access to this node, to avoid delivering of systemfiles like /etc/passwd # with e.g. 604993?item=../../../../../../../../../../etc/passwd node_id_list = self.item_file_pattern.findall(fname) if node_id_list: node_id = node_id_list[0] node = db.query(Node).get(node_id) fname_allowed = node and node.has_read_access(user=current_user) fpath = "{}html/{}".format(config.get("paths.datadir"), fname) if fname_allowed and os.path.isfile(fpath): with codecs.open(fpath, "r", encoding='utf8') as c: content = c.read() if sidebar: return u'<div id="portal-column-one">{}</div>{}'.format(content, sidebar) return content spn = self.getStartpageFileNode(lang(req)) if spn: long_path = spn.retrieveFile() if os.path.isfile(long_path) and fileIsNotEmpty(long_path): content = includetemplate(self, long_path, {'${next}': link}) if content: if sidebar: return u'<div id="portal-column-one">{}</div>{}'.format(content, sidebar) return content return u'{}{}'.format(content, sidebar)
def child_node_url(child_id, **kwargs): """XXX: this shouldn't be here, child display should not be a responsibility of content types!""" from core.webconfig import node_url from core.transition import request params = {k: v for k, v in request.args.items()} if "show_id" in params: params["show_id"] = child_id else: params["id"] = child_id params.update(kwargs) return node_url(**params)
def child_node_url(child_id, **kwargs): """XXX: this shouldn't be here, child display should not be a responsibility of content types!""" from core.webconfig import node_url from core.transition import request params = {k: v for k, v in request.args.items()} if "show_id" in params: params["show_id"] = child_id else: params["id"] = child_id params.update(kwargs) return node_url(**params)
def search_link(self, mode="simple"): params = { k: v for k, v in iteritems(self.url_params) if k not in ("query", "searchmode", "id") } if mode != "simple": params["searchmode"] = mode return node_url(self.container.id, ** params) if not self.edit else edit_node_url( self.container.id, **params)
def addPaths(self, pathlist): if len(pathlist) > 0: self.addData(Paragraph(t(self.language, "print_preview_occurences") + ":", self.bp)) p = ' ' for path in pathlist: for item in path: p += u'<link href="http://{}{}">{}</link>'.format(self.host, node_url(item.id), item.getName()) if path.index(item) < len(path) - 1: p += ' > ' self.addData(Paragraph(p.replace('&', '&'), self.bv, bulletText=u'\267'.encode("utf-8"))) p = ' '
def html(self, req): language = lang(req) context = { "language": language, "query": self.query, "container": self.container.getLabel(language), "container_url": node_url(self.container.id) } theme = webconfig.theme if self.error: html = theme.render_template("search_error.j2.jade", context) else: html = theme.render_template("search_noresult.j2.jade", context) return html
def show_node_big(self, req, style_name=""): # style_name is ignored content = u"" link = node_url(self.id, files=1) sidebar = u"" pages = self.getStartpageDict() if self.get("system.sidebar") != "": for sb in self.get("system.sidebar").split(";"): if sb: l, fn = sb.split(":") if l == lang(req): for f in self.getFiles(): if fn.endswith(f.getName()): sidebar = includetemplate( self, f.retrieveFile(), {}) if sidebar: sidebar = req.getTAL("contenttypes/container.html", {"content": sidebar}, macro="addcolumn") else: sidebar = u"" if "item" in req.params: fpath = "{}html/{}".format(config.get("paths.datadir"), req.params.get("item")) if os.path.isfile(fpath): with codecs.open(fpath, "r", encoding='utf8') as c: content = c.read() if sidebar: return u'<div id="portal-column-one">{}</div>{}'.format( content, sidebar) return content spn = self.getStartpageFileNode(lang(req)) if spn: long_path = spn.retrieveFile() if os.path.isfile(long_path) and fileIsNotEmpty(long_path): content = includetemplate(self, long_path, {'${next}': link}) if content: if sidebar: return u'<div id="portal-column-one">{}</div>{}'.format( content, sidebar) return content return u'{}{}'.format(content, sidebar)
def __init__(self, file, link_params, language, fullstyle_name, separator=None): node = file sys_filetypes = [unicode(x) for x in node.get_sys_filetypes()] attachment = node.files.filter_by(filetype=u"attachment").first() if attachment is None: attachment = node.files.filter(~File.filetype.in_(sys_filetypes)).first() self.attachment = attachment self.datatype = node self.image = Markup(node.show_node_image()) self.text = Markup(node.show_node_text(separator=separator, language=language)) self.thumbnail = self.image if fullstyle_name: link_params["style"] = fullstyle_name self.link = node_url(**link_params) self.shopping_bag_link = u'shoppingBag(\'{}\')'.format(node.id) self.node = node
def nav_link(self, **param_overrides): """ params can be removed from the URL by setting them to None in param_overrides """ params = self.nav_params.copy() if self.liststyle_name: params["liststyle"] = self.liststyle_name if self.nodes_per_page_from_req: params["nodes_per_page"] = self.nodes_per_page_from_req if not ("before" in param_overrides or "after" in param_overrides): if self.before: params["before"] = self.before if self.after: params["after"] = self.after params.update(param_overrides) params = {k: v for k, v in iteritems(params) if v is not None} return node_url(**params)
def nav_link(self, **param_overrides): """ params can be removed from the URL by setting them to None in param_overrides """ params = self.nav_params.copy() if self.liststyle_name: params["liststyle"] = self.liststyle_name if self.nodes_per_page_from_req: params["nodes_per_page"] = self.nodes_per_page_from_req if not ("before" in param_overrides or "after" in param_overrides): if self.before: params["before"] = self.before if self.after: params["after"] = self.after params.update(param_overrides) params = {k: v for k, v in iteritems(params) if v is not None} return node_url(**params)
def addPaths(self, pathlist): if len(pathlist) > 0: self.addData( Paragraph( t(self.language, "print_preview_occurences") + ":", self.bp)) p = ' ' for path in pathlist: for item in path: p += u'<link href="http://{}{}">{}</link>'.format( self.host, node_url(item.id), item.getName()) if path.index(item) < len(path) - 1: p += ' > ' self.addData( Paragraph(p.replace('&', '&'), self.bv, bulletText=u'\267'.encode("utf-8"))) p = ' '
def select_style_link(self, style): version = self._node.tag if isinstance(self._node, version_class(Node)) else None return node_url(self.id, version=version, style=style)
def link_current_node(self): return node_url(self.content.id)
def search_link(self, mode="simple"): params = {k: v for k, v in iteritems(self.url_params) if k not in ("query", "searchmode", "id")} if mode != "simple": params["searchmode"] = mode return node_url(self.container.id, **params) if not self.edit else edit_node_url(self.container.id, **params)
def select_style_link(self, style): version = self._node.tag if isinstance(self._node, version_class(Node)) else None return node_url(self.id, version=version, style=style)
def link_current_node(self): return node_url(self.content.id)
def getLink(self): return node_url(self.node.id)
def getLink(self): return node_url(self.node.id)