Beispiel #1
0
 def getMenu(self,activeItem:str):
     '''
     set up the menu for this application
     '''
     menu=Menu()
     menu.addItem(MenuItem("/","Home",mdiIcon="home"))
     menu.addItem(MenuItem("/archives","Archives"))
     menu.addItem(MenuItem("/folders","Folders"))
     menu.addItem(MenuItem("/documents","Documents"))
     menu.addItem(MenuItem("/scandir","Scan-Directory"))
     menu.addItem(MenuItem("/files","Scans"))
     menu.addItem(MenuItem('http://wiki.bitplan.com/index.php/scan2wiki',"Docs")),
     menu.addItem(MenuItem('https://github.com/WolfgangFahl/scan2wiki','github'))
     if current_user.is_anonymous:
         menu.addItem(MenuItem('/login','login',mdiIcon="login"))
     else:
         menu.addItem(MenuItem('/logout','logout',mdiIcon="logout"))
     if activeItem is not None:
         for menuItem in menu.items:
             if isinstance(menuItem,MenuItem):
                 if menuItem.title==activeItem:
                     menuItem.active=True
                 menuItem.url=self.basedUrl(menuItem.url)
     return menu
     return menu
Beispiel #2
0
    def testWidgets(self):
        '''
        test widget handling
        '''
        menu=Menu()
        menuItem1=MenuItem("http://test.bitplan.com","BITPlan testSite",True)
        menu.addItem(menuItem1)
        dropDownMenu=DropDownMenu("Dropdown")
        dropDownMenu.addItem(Link("http://www.bitplan.com","BITPlan webPage"))
        widgets=[
            Link("http://www.bitplan.com","BITPlan webPage",tooltip="BITPlan GmbH"),
            Image("http://wiki.bitplan.com/images/wiki/thumb/3/38/BITPlanLogoFontLessTransparent.png/132px-BITPlanLogoFontLessTransparent.png",alt='BITPlan Logo'),
            MenuItem("http://test.bitplan.com","BITPlan testSite",active=True),
            menu,
            dropDownMenu
        ]
        expectedHtml=[
            "<a href='http://www.bitplan.com' title='BITPlan GmbH'>BITPlan webPage</a>",
            "<img src='http://wiki.bitplan.com/images/wiki/thumb/3/38/BITPlanLogoFontLessTransparent.png/132px-BITPlanLogoFontLessTransparent.png' alt='BITPlan Logo'/>",
            """<!-- BITPlan testSite -->
<li class="nav-item active">
  <a class="nav-link" title="BITPlan testSite" href="http://test.bitplan.com">BITPlan testSite</a>
</li>
""",
            """<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav">
      <!-- BITPlan testSite -->
      <li class="nav-item">
        <a class="nav-link" title="BITPlan testSite" href="http://test.bitplan.com"><span class='material-icons headerboxicon'>True</span></a>
      </li>

    </ul>
  </div>   
</nav>""",
        """<div class="dropdown nav-item">
    <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
    <div class="dropdown-menu">
      <a href='http://www.bitplan.com' class="dropdown-item">BITPlan webPage</a>
    </div>
</div>"""
            ]
        for i,widget in enumerate(widgets):
            widget.useFlask=False
            self.assertTrue(isinstance(widget,Widget))
            html=widget.render()
            #self.debug=True
            if self.debug:
                print(html)
            self.assertEqual(expectedHtml[i],html)
            self.assertEqual(expectedHtml[i],str(widget))
        pass
    def testWidgets(self):
        '''
        test widget handling
        '''
        widgets = [
            Link("http://www.bitplan.com",
                 "BITPlan webPage",
                 tooltip="BITPlan GmbH"),
            Image(
                "http://wiki.bitplan.com/images/wiki/thumb/3/38/BITPlanLogoFontLessTransparent.png/132px-BITPlanLogoFontLessTransparent.png",
                alt='BITPlan Logo'),
            MenuItem("http://test.bitplan.com", "BITPlan testSite", True)
        ]
        expectedHtml = [
            "<a href='http://www.bitplan.com' title='BITPlan GmbH'>BITPlan webPage</a>",
            "<img src='http://wiki.bitplan.com/images/wiki/thumb/3/38/BITPlanLogoFontLessTransparent.png/132px-BITPlanLogoFontLessTransparent.png' alt='BITPlan Logo'/>",
            """<li class="nav-item active">
  <a class="nav-link" href="http://test.bitplan.com">BITPlan testSite</a>
</li>"""
        ]
        for i, widget in enumerate(widgets):
            self.assertTrue(isinstance(widget, Widget))
            html = widget.render()
            if self.debug:
                print(html)
            self.assertEqual(expectedHtml[i], html)
            self.assertEqual(expectedHtml[i], str(widget))
        pass
Beispiel #4
0
 def adminMenuList(self,activeItem:str=None):
     '''
     get the list of menu items for the admin menu
     Args:
         activeItem(str): the active  menu item
     Return:
         list: the list of menu items
     '''
     menuList=[
         MenuItem('/','Home'),
         MenuItem('https://github.com/BITPlan/pyWikiCMS','github'),
         MenuItem('/generate/orth', 'Generator') # ToDo: Test Values
         ]
     if current_user.is_anonymous:
         menuList.append(MenuItem('/login','login'))
     else:
         menuList.append(MenuItem('/wikis','Wikis')),
         menuList.append(MenuItem('/frontends','Frontends')),
         menuList.append(MenuItem('/logout','logout'))
     
     if activeItem is not None:
         for menuItem in menuList:
             if menuItem.title==activeItem:
                 menuItem.active=True
             if menuItem.url.startswith("/"):
                 menuItem.url="%s%s" % (self.baseUrl,menuItem.url)
     return menuList
 def getMenu(self):
     '''
     get the Menu
     '''
     menu = Menu()
     for endpoint, title, mdiIcon, newTab in self.getMenuEntries():
         menu.addItem(
             MenuItem(self.basedUrl(url_for(endpoint)),
                      title=title,
                      mdiIcon=mdiIcon,
                      newTab=newTab))
     menu.addItem(
         MenuItem("https://bootstrap-flask.readthedocs.io/",
                  title="Documentation",
                  mdiIcon="description",
                  newTab=True))
     menu.addItem(
         MenuItem("https://github.com/greyli/bootstrap-flask",
                  title="greyli",
                  newTab=True))
     menu.addItem(
         MenuItem("https://github.com/WolfgangFahl/pyFlaskBootstrap4",
                  title="github",
                  newTab=True))
     if current_user.is_anonymous:
         menu.addItem(MenuItem('/login', 'login', mdiIcon="login"))
     else:
         menu.addItem(MenuItem('/logout', 'logout', mdiIcon="logout"))
     return menu
    def widgets(self):
        '''
        test widgets 
        '''
        dropDownMenu = DropDownMenu("Links")
        dropDownMenu.addItem(Link("http://www.bitplan.com", "BITPlan Website"))
        dropDownMenu.addItem(
            Link("https://bootstrap-flask.readthedocs.io/", "Docs"))
        dropDownMenu.addItem(
            Link("https://github.com/WolfgangFahl/pyFlaskBootstrap4",
                 "github"))
        dropDownMenu.addItem(Link("https://getbootstrap.com/", "bootstrap"))

        menu = Menu()
        menu.addItem(MenuItem("http://wiki.bitplan.com", "BITPlan Wiki", True))
        menu.addItem(
            MenuItem("https://bootstrap-flask.readthedocs.io/", "Docs"))
        menu.addItem(
            MenuItem(
                "https://github.com/WolfgangFahl/pyFlaskBootstrap4",
                "github",
            ))
        menu.addItem(dropDownMenu)

        lodDataGenerator = lambda n: [
            {
                'text': f'Text message {i}',
                'author': f"Author {i}",
                "Category": f"Category {i}",
                "create time": datetime.now() + timedelta(days=i)
            } for i in range(n)
        ]
        lodTable = LodTable(lodDataGenerator(5))
        lodDataTable = LodTable(lodDataGenerator(500), isDatatable=True)

        widgetList = [
            [
                Link("https://github.com/WolfgangFahl/pyFlaskBootstrap4",
                     "pyFlaskBootstrap4",
                     "Extended Flask + Bootstrap4 Library",
                     newTab=True),
                Link("http://wiki.bitplan.com/index.php/PyFlaskBootstrap4",
                     "Wiki",
                     "pyFlaskBootstrap4 wiki",
                     newTab=True),
                Link("https://github.com/greyli/bootstrap-flask",
                     "bootstrap-flask",
                     "Flask + Bootstrap4 Library by Grey Li",
                     newTab=True),
                Link("https://palletsprojects.com/p/flask/",
                     "flask",
                     "web application framework",
                     newTab=True),
                Link("https://getbootstrap.com/",
                     "bootstrap",
                     "Open source web toolkit",
                     newTab=True),
                Link("https://fonts.google.com/icons",
                     "Google material icons",
                     newTab=True)
            ],
            [
                Image(
                    "https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/299px-Tux.svg.png",
                    alt="Tux",
                    height=150,
                    title='Tux - the Linux kernel penguin mascot'),
                Image(
                    "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Eiffel_Tower_Paris.jpg/180px-Eiffel_Tower_Paris.jpg",
                    alt="Eiffel Tower",
                    height=150,
                    title='Eiffel Tower, Paris'),
                Image(
                    "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/Croce-Mozart-Detail.jpg/185px-Croce-Mozart-Detail.jpg",
                    alt="Mozart",
                    height=150,
                    title='Wolfgang Amadeus Mozart'),
                Image(
                    "https://upload.wikimedia.org/wikipedia/commons/thumb/7/78/The_Blue_Marble.jpg/240px-The_Blue_Marble.jpg",
                    alt="Earth",
                    width=150,
                    title='Earth as seen from Apollo 17 mission')
            ],
            [
                Icon("award"),
                Icon("battery"),
                Icon("book"),
                Icon("heart"),
                Icon("calculator", size=48),
                Icon("person", size=48, color='red'),
                Icon("wifi", size=64),
                Icon("wrench", size=64)
            ], [menu], [dropDownMenu], [lodTable, lodDataTable]
        ]
        return self.render_template('widgets.html', widgetList=widgetList)