def process(self, req, start_response): self.do_init() templ = self.app.get_template('index.xml') cat = None v = UI.VContainer(spacing=0) # Sort plugins by name cats = self.categories cats = sorted(cats, key=lambda p: p.text) for fld in self.folder_ids: cat_vc = UI.VContainer(spacing=0) if self.folders[fld] == '': cat_folder = cat_vc # Omit wrapper for special folders else: cat_folder = UI.CategoryFolder( cat_vc, text=self.folders[fld], icon='/dl/core/ui/catfolders/' + fld + '.png' if self.folders[fld] != '' else '', id=fld) # cat_vc will be VContainer or CategoryFolder exp = False empty = True for c in cats: if c.folder == fld: # Put corresponding plugins in this folder empty = False if c == self.selected_category: cat_vc.append( UI.Category(icon=c.icon, name=c.text, id=c.get_name(), selected='true')) exp = True else: cat_vc.append( UI.Category(icon=c.icon, name=c.text, id=c.get_name())) if not empty: v.append(cat_folder) cat_folder['expanded'] = exp templ.appendChildInto('leftplaceholder', v) templ.appendChildInto('rightplaceholder', self.main_ui().elements()) templ.appendChildInto('version', UI.Label(text='Ajenti ' + version, size=2)) templ.appendChildInto( 'links', UI.HContainer( UI.LinkLabel(text='About', id='about'), UI.OutLinkLabel(text='License', url='http://www.gnu.org/licenses/lgpl.html'))) return templ.render()
def process(self, req, start_response): self.do_init() templ = self.app.get_template('index.xml') cat = None v = UI.VContainer(spacing=0) # Sort plugins by name cats = self.app.grab_plugins(ICategoryProvider) cats = sorted(cats, key=lambda p: p.text) for fld in self.folder_ids: cat_vc = UI.VContainer(spacing=0) if self.folders[fld] == '': cat_folder = cat_vc # Omit wrapper for special folders else: cat_folder = UI.CategoryFolder( cat_vc, text=self.folders[fld], icon='/dl/core/ui/catfolders/'+ fld + '.png' if self.folders[fld] != '' else '', id=fld ) # cat_vc will be VContainer or CategoryFolder exp = False empty = True for c in cats: if c.folder == fld: # Put corresponding plugins in this folder empty = False if c == self.selected_category: exp = True cat_vc.append(UI.Category( icon=c.icon, name=c.text, id=c.plugin_id, counter=c.get_counter(), selected=c == self.selected_category )) if not empty: v.append(cat_folder) cat_folder['expanded'] = exp for c in cats: if c.folder in ['top', 'bottom']: templ.append( 'topplaceholder-'+c.folder, UI.TopCategory( text=c.text, id=c.plugin_id, icon=c.icon, counter=c.get_counter(), selected=c==self.selected_category ) ) templ.append('_head', UI.HeadTitle(text='Ajenti @ %s'%platform.node())) templ.append('leftplaceholder', v) templ.append('version', UI.Label(text='Ajenti '+version(), size=2)) templ.insertText('cat-username', self.app.auth.user) templ.appendAll('links', UI.LinkLabel(text='About', id='about'), UI.OutLinkLabel(text='License', url='http://www.gnu.org/licenses/lgpl.html') ) return templ.render()