Ejemplo n.º 1
0
 def init(self):
     self.content(
         tags.Div(klass='page-header')(
             tags.H1()(self._data['content'].title)
         ),
         tags.Div(klass='site-content lead')(
             Escaped(markdown2.markdown(self._data['content'].text))
         )
     )
Ejemplo n.º 2
0
 def init(self):
     self.form = tags.Form(
         action="/signup", method='post', klass='omb_loginForm')(
             email=tags.Input('required',
                              typ="email",
                              name="email",
                              klass='form-control',
                              placeholder='Email'),
             l_email=tags.Label(_for='email', klass='sr-only')('Email'),
             username=tags.Input('required',
                                 'autofocus',
                                 typ="text",
                                 name="username",
                                 klass='form-control',
                                 placeholder='Username'),
             l_user=tags.Label(_for='username',
                               klass='sr-only')('Username'),
             password=tags.Input('required',
                                 typ="password",
                                 name="password",
                                 klass='form-control',
                                 placeholder='Password'),
             l_pwd=tags.Label(_for='password', klass='sr-only')('Password'),
             lb=tags.Button(
                 typ="submit",
                 klass='btn btn-lg btn-primary btn-block')('Sign Up'),
         )
     self.content(
         tags.Div(klass='omb_login')(
             tags.H3(klass='omb_authTitle')('Sign Up or ',
                                            tags.A(href='/login')('Login')),
             tags.Div(klass='row omb_row-sm-offset-3 omb_socialButtons')(
                 tags.Div(klass='col-xs-4 col-sm-3')(tags.A(
                     href='#',
                     klass='btn btn-lg btn-block omb_btn-facebook')(
                         tags.I(klass='fab fa-facebook visible-xs'),
                         tags.Span(klass='hidden-xs')(' Facebook'))),
                 tags.Div(klass='col-xs-4 col-sm-3')(tags.A(
                     href='#', klass='btn btn-lg btn-block omb_btn-google')(
                         tags.I(klass='fab fa-google-plus visible-xs'),
                         tags.Span(klass='hidden-xs')(' Google')))),
             tags.Div(klass='row omb_row-sm-offset-3 omb_loginOr')(
                 tags.Div(klass='col-xs-12 col-sm-6')(
                     tags.Hr(klass='omb_hrOr'),
                     tags.Span(klass='omb_spanOr')('or'))),
             tags.Div(klass='row omb_row-sm-offset-3')(
                 tags.Div(klass='col-xs-12 col-sm-6')(self.form)),
             tags.Div(klass='row omb_row-sm-offset-3')(tags.Div(
                 klass='col-xs-12 col-sm-6')(tags.Hr(klass='omb_hrOr'), )),
         ))
Ejemplo n.º 3
0
 def init(self):
     self.title = tags.Div(klass='navbar-header')(
         brand=tags.A(klass='navbar-brand mb-0 h1', href='/')(self._title),
         menu_btn=tags.Button(
             **{
                 'type': "button",
                 'class': "navbar-toggler",
                 'data-toggle': "collapse",
                 'data-target': "#navbarSupportedContent",
                 'aria-expanded': "false",
                 'aria-controls': "navbarSupportedContent",
                 'aria-label': "Toggle navigation"
             })(tags.Span(klass='navbar-toggler-icon'), ))
     self.menu = tags.Div(klass='collapse navbar-collapse',
                          id='navbarSupportedContent')
     self._make_menu(self.menu, 'MAIN')
     self(tags.Div(klass='container')(self.title, self.menu))
Ejemplo n.º 4
0
 def init(self):
     self.head(self.css(), self.js())
     self.head(tags.Meta(name="viewport", content="width=device-width, initial-scale=1"))
     self.head.title(self.page_title)
     self.navbar = NavBar(klass='navbar navbar-expand-lg navbar-dark bg-dark fixed-top')._make_menu()
     self.content = tags.Div(klass='container main-window')
     self.footer = tags.Footer(klass='footer footer-dark bg-dark')(
         tags.Div(klass='container')(
             tags.P(klass='text-muted')(
                 "created by Federico Cerchiari with ",
                 tags.Img(src=url_for('static', filename='img/brain.png'), height="17px"),
                 ", Python and TemPy. "
             ),
         )
     )
     self.body(
         self.navbar,
         self.content,
         self.footer
     )
Ejemplo n.º 5
0
 def init(self):
     self.head(self.css(), self.js())
     self.head(
         tags.Meta(name="viewport",
                   content="width=device-width, initial-scale=1"))
     self.head.title(self.page_title)
     self.navbar = NavBar(
         self._request,
         klass='navbar navbar-expand-lg navbar-dark bg-dark fixed-top')
     self.content = tags.Div(klass='container main-window')
     self.footer = tags.Footer(klass='footer footer-dark bg-dark')(
         tags.Div(klass='container')(tags.P(klass='text-muted')(
             "Created by Federico Cerchiari with ",
             tags.Img(src=self._request.static_url('app:img/brain.png'),
                      height="17px"), ", Python, Pyramid and ",
             tags.A(href='https://github.com/Hrabal/TemPy',
                    target='blank')('TemPy'),
             ". Deployed on AWS Lambda using Zappa. ",
             tags.A(href='https://github.com/Hrabal/Dobry',
                    target='blank')('Code on GitHub ',
                                    tags.I(klass='fab fa-github'))), ))
     self.body(self.navbar, self.content, self.footer)
Ejemplo n.º 6
0
 def wrong(self, what):
     self.form.prepend(
         tags.Div(klass='alert alert-danger')('Wrong ', what.title()))
     return self
Ejemplo n.º 7
0
 def init(self):
     self.content(
         tags.Div(klass='row')(
             tags.Div(klass='col-sm-12 col-lg-3')(tags.Img(
                 src=url_for('static',
                             filename=f'img/profile_pics/{g.user.pic}'),
                 klass='profile-user-pic')),
             tags.Div(klass='col')(tags.Div(klass='container')(
                 tags.Div(klass='row')(tags.Div(klass='col')(tags.H1()(
                     g.user.username, f' - Level {g.user.level}')), ),
                 tags.Div(klass='row')(tags.Div(klass='col')(tags.H2()(
                     g.user.tagline)), ),
                 tags.Div(klass='row')(
                     tags.Div(klass='col-12 col-sm-2')('Joined:'),
                     tags.Div(klass='col')(format_date(
                         g.user.joined,
                         format='short',
                         locale=g.user.country)),
                 ),
                 tags.Div(klass='row')(
                     tags.Div(klass='col-12 col-sm-2')('E-mail:'),
                     tags.Div(klass='col')(g.user.email),
                 ),
                 tags.Div(klass='row')
                 (tags.Div(klass='col-12 col-sm-2')('Country:'),
                  tags.Div(klass='col')(
                      tags.Span(
                          klass=f'flag-icon flag-icon-{g.user.country}'),
                      ' ',
                      pycountry.countries.get(
                          alpha_2=g.user.country.upper()).official_name)),
                 tags.Div(klass='row')(
                     tags.Div(klass='col-12 col-sm-2')('Birthday:'),
                     tags.Div(klass='col')(
                         format_date(g.user.birth,
                                     format='long',
                                     locale=g.user.country)),
                 ),
                 tags.Div(klass='row')(
                     tags.Div(klass='col-12 col-sm-2')('Age:'),
                     tags.Div(klass='col')(relativedelta(
                         date.today(), g.user.birth).years),
                 ),
             ))),
         tags.Div(klass='row')(tags.Div(klass='col')(tags.H2()('Stats'))),
         tags.Div(klass='row')(tags.Div(klass='col-12 col-lg-4')(
             tags.Div(klass='container')(
                 tags.Div(klass='row')(tags.Div(klass='col')(tags.H4()(
                     'Played ', len(g.user.games), ' games'))),
                 tags.Div(klass='row')(tags.Div(klass='col')(tags.H4()(
                     tags.Span(klass='flag-icon flag-icon-us'), ' ',
                     sum(1 for g in g.user.games
                         if g.faction == 'us'))), tags.Div(klass='col')(
                             tags.H4()(
                                 tags.Span(klass='flag-icon flag-icon-su'),
                                 ' ',
                                 sum(1 for g in g.user.games
                                     if g.faction == 'su')))),
                 tags.Div(klass='row')(tags.Div(klass='col')(tags.H4()(
                     'Currently in ',
                     sum(1 for g in g.user.games if not g.game.ended),
                     ' games.'))),
                 tags.Div(klass='row')(tags.Div(klass='col')(tags.H4()(
                     sum(1 for g in g.user.games if g.score == 20),
                     ' games won.'))),
             )), tags.Div(klass='col-12 col-lg-4')(),
                               tags.Div(klass='col-12 col-lg-4')()))