def render(self, node, tags, selectedTag, defaultTag, categoryList, webItems, ): """ @param tags - list of all tags @param selectedTag - tag selected or None @param defaultTag - a Tag (e.g. inbox) @param webItems - list of WebItemNode of WebItemTagNode """ lSelectedTagName = selectedTag and selectedTag.name.lower() or '' # ------------------------------------------------------------------------ # tag list lst = [(tag.name.lower(), tag.name, tag.id) for tag in tags] lst = [(name,id) for _,name,id in sorted(lst)] lst = [('',None)] + lst node.tagListForm.atts['action'] = selectedTag and '/weblib/@%s' % selectedTag.id or '' node.tagListForm.tag.repeat(self.renderTag, lst, lSelectedTagName) # ------------------------------------------------------------------------ # default Tag node.defaultTag.atts['href'] = request.tag_url([defaultTag]) node.defaultTag.content = unicode(defaultTag) if defaultTag.match(selectedTag): node.defaultTag.atts['class'] = 'highlight' # Actually need to make sure it is not doing search # if not lTagSelected: # node.rootTag.atts['class'] = 'highlight' # category node.catList.repeat(self.renderCatItem, categoryList, lSelectedTagName) # ------------------------------------------------------------------------ # Matching message count = sum(1 for item in webItems if isinstance(item, WebItemNode)) node.found_msg.count.content = str(count) from minds import search_engine if search_engine.getEngines(): node.found_msg.search_engine.engine.repeat(self.renderSearchEngine, search_engine.getEngines()) node.found_msg.search_engine.querytxt.content = self.querytxt else: node.found_msg.search_engine.omit() if not webItems: node.web_items.omit() return # ------------------------------------------------------------------------ # webitems headerTemplate = node.web_items.headerTemplateHolder.headerTemplate # headerTemplateHolder is only a holder for headerTemplate, hide it node.web_items.headerTemplateHolder.omit() node.web_items.webItem.repeat(self.renderWebItem, enumerate(webItems), headerTemplate)
def render(self, node, base_url, tags, selectedTag, defaultTag, categoryList, upgrade_info, sort, webItems, ): """ @param base_url - base URL that invoke this page (without the sort parameter) @param tags - list of all tags @param selectedTag - tag selected or None @param defaultTag - a Tag (e.g. inbox) @param webItems - sequence of intermixed WebItemNode and WebItemTagNode """ lSelectedTagName = selectedTag and selectedTag.name.lower() or '' # ------------------------------------------------------------------------ # tag list lst = [(tag.name.lower(), tag.name, tag.id) for tag in tags] lst = [(name,id) for _,name,id in sorted(lst)] lst = [('',None)] + lst node.tagListForm.atts['action'] = selectedTag and '/weblib/@%s' % selectedTag.id or '' node.tagListForm.tag.repeat(self.renderTag, lst, lSelectedTagName) # ------------------------------------------------------------------------ # default Tag node.defaultTag.atts['href'] = request.tag_url([defaultTag]) node.defaultTag.content = unicode(defaultTag) if defaultTag.match(selectedTag): node.defaultTag.atts['class'] = 'highlight' # Actually need to make sure it is not doing search # if not lTagSelected: # node.rootTag.atts['class'] = 'highlight' # category node.catList.repeat(self.renderCatItem, categoryList, lSelectedTagName) # ------------------------------------------------------------------------ # upgrade info if not upgrade_info: node.upgrade_notification.omit() else: node.upgrade_notification.link.atts['href'] = upgrade_info.url node.upgrade_notification.link.title.content = upgrade_info.title node.upgrade_notification.link.summary.content = upgrade_info.summary # ------------------------------------------------------------------------ # Matching message count = sum(1 for item in webItems if isinstance(item, WebItemNode)) node.found_msg.count.content = str(count) from minds import search_engine if search_engine.getEngines(): node.found_msg.search_engine.engine.repeat(self.renderSearchEngine, search_engine.getEngines()) node.found_msg.search_engine.querytxt.content = self.querytxt else: node.found_msg.search_engine.omit() if not webItems: node.web_items.omit() return # ------------------------------------------------------------------------ # webitems Heading h = node.web_items.heading if '?' in base_url: s_url = base_url + '&sort=' else: s_url = base_url + '?sort=' if sort == SORT.TITLE_ASC: h.title.icon.atts['src'] = '/img/arrowUp.gif' h.title.atts['href'] = s_url + SORT.TITLE_DESC elif sort == SORT.TITLE_DESC: h.title.icon.atts['src'] = '/img/arrowDown.gif' h.title.atts['href'] = s_url + SORT.TITLE_ASC else: h.title.icon.omit(); h.title.atts['href'] = s_url + SORT.TITLE_ASC if sort == SORT.TAG_ASC: h.tag.icon.atts['src'] = '/img/arrowUp.gif' h.tag.atts['href'] = s_url + SORT.TAG_ASC # tag is only ordered one way elif sort == SORT.TAG_DESC: h.tag.icon.atts['src'] = '/img/arrowDown.gif' h.tag.atts['href'] = s_url + SORT.TAG_ASC else: h.tag.icon.omit(); h.tag.atts['href'] = s_url + SORT.TAG_ASC if sort == SORT.DATE_ASC: h.date.icon.atts['src'] = '/img/arrowUp.gif' h.date.atts['href'] = s_url + SORT.DATE_DESC elif sort == SORT.DATE_DESC: h.date.icon.atts['src'] = '/img/arrowDown.gif' h.date.atts['href'] = s_url + SORT.DATE_ASC else: h.date.icon.omit(); h.date.atts['href'] = s_url + SORT.DATE_ASC # ------------------------------------------------------------------------ # webitems headerTemplate = node.web_items.headerTemplateHolder.headerTemplate # headerTemplateHolder is only a holder for headerTemplate, hide it node.web_items.headerTemplateHolder.omit() node.web_items.webItem.repeat(self.renderWebItem, enumerate(webItems), headerTemplate)