def test_startMenuSetsTabURLs(self): """ L{Tabs<Tab>} which have C{None} for a C{linkURL} attribute should have a value set for that attribute based on the L{IWebTranslator} passed to L{startMenu}. """ tab = webnav.Tab('alpha', 123, 0) webnav.startMenu(FakeTranslator(), [tab], tags.span()) self.assertEqual(tab.linkURL, '/link/123')
def test_startMenuSetsTabURLs(self): """ L{Tabs<Tab>} which have C{None} for a C{linkURL} attribute should have a value set for that attribute based on the L{IWebTranslator} passed to L{startMenu}. """ tab = webnav.Tab("alpha", 123, 0) webnav.startMenu(FakeTranslator(), [tab], tags.span()) self.assertEqual(tab.linkURL, "/link/123")
def render_startmenu(self, ctx, data): """ Add start-menu style navigation to the given tag. @see {xmantissa.webnav.startMenu} """ return startMenu(self.translator, self.pageComponents.navigation, ctx.tag)
def render_startmenu(self, ctx, data): """ Add start-menu style navigation to the given tag. @see {xmantissa.webnav.startMenu} """ return startMenu( self.translator, self.pageComponents.navigation, ctx.tag)
def render_startmenu(self, ctx, data): """ For authenticated users, add the start-menu style navigation to the given tag. For unauthenticated users, remove the given tag from the output. @see L{xmantissa.webnav.startMenu} """ if self.username is None: return '' translator = self._getViewerPrivateApplication() pageComponents = translator.getPageComponents() return startMenu(translator, pageComponents.navigation, ctx.tag)
def test_startMenuRenders(self): """ Test that the L{startMenu} renderer creates a tag for each tab, filling its I{href}, I{name}, and I{kids} slots. """ tabs = [webnav.Tab("alpha", 123, 0), webnav.Tab("beta", 234, 0)] node = tags.span[tags.div(pattern="tab")] tag = webnav.startMenu(FakeTranslator(), tabs, node) self.assertEqual(tag.tagName, "span") navTags = list(tag.slotData["tabs"]) self.assertEqual(len(navTags), 2) alpha, beta = navTags self.assertEqual(alpha.slotData["name"], "alpha") self.assertEqual(alpha.slotData["href"], "/link/123") self.assertEqual(alpha.slotData["kids"], "") self.assertEqual(beta.slotData["name"], "beta") self.assertEqual(beta.slotData["href"], "/link/234") self.assertEqual(beta.slotData["kids"], "")
def test_startMenuRenders(self): """ Test that the L{startMenu} renderer creates a tag for each tab, filling its I{href}, I{name}, and I{kids} slots. """ tabs = [ webnav.Tab('alpha', 123, 0), webnav.Tab('beta', 234, 0)] node = tags.span[tags.div(pattern='tab')] tag = webnav.startMenu(FakeTranslator(), tabs, node) self.assertEqual(tag.tagName, 'span') navTags = list(tag.slotData['tabs']) self.assertEqual(len(navTags), 2) alpha, beta = navTags self.assertEqual(alpha.slotData['name'], 'alpha') self.assertEqual(alpha.slotData['href'], '/link/123') self.assertEqual(alpha.slotData['kids'], '') self.assertEqual(beta.slotData['name'], 'beta') self.assertEqual(beta.slotData['href'], '/link/234') self.assertEqual(beta.slotData['kids'], '')