Ejemplo n.º 1
0
 def __init__(self, items=None, header=None, **kwargs):
     self.init(kwargs)
     self.items = self.param(items, ObjectsParam, 'Items in the panel',
                             Objects())
     self.header = self.param(header, ObjectsParam, 'Header of the panel',
                              Objects())
     self.add_class('panel panel-default')
Ejemplo n.º 2
0
    def convert(cls, value, parent_object):
        if not isinstance(value, Objects):
            value = Objects(value)

        value._parent = parent_object

        return value
Ejemplo n.º 3
0
    def convert(cls, value, parent_object):
        if not isinstance(value, Objects):
            value = Objects(value)

        value._parent = parent_object

        return value
Ejemplo n.º 4
0
 def __init__(self, text=Default, level=1, subtext=Default, **kwargs):
     self.init(kwargs)
     self.text = self.param(text, ObjectsParam, 'Text of the heading',
                            Objects())
     self.level = self.param(level, IntegerParam,
                             'Size of the heading, 1 is largest')
     self.subtext = self.param(subtext, ObjectsParam,
                               'SubText of the heading', Objects())
Ejemplo n.º 5
0
 def __init__(self, title='', items=Default, buttons=Default, **kwargs):
     self.init(kwargs)
     self.title = self.param(title, StringParam,
                             'Title of the modal dialog')
     self.items = self.param(
         items, ObjectsParam,
         'Items that make up the modal dialog main area', Objects())
     self.buttons = self.param(buttons, ObjectsParam, 'Dialog\'s buttons',
                               Objects())
Ejemplo n.º 6
0
 def __init__(self, *args, microdata=True, **kwargs):
     self.init(kwargs)
     self.crumbs = Objects(args)
     self.microdata = self.param(
         microdata, BooleanParam,
         'Include microdata properties in the renderer. This might render the breadcrumbs in Google search results.'
     )
Ejemplo n.º 7
0
    def test_objects_param(self):
        obj = SimpleObject()
        obj.id_needed()

        def iprint(value):
            print(value.__class__.__name__, value, value._parent)
            for o in value:
                print('-', o.__class__.__name__, o, o._parent)

        iprint(ObjectsParam.convert(None, obj))
        iprint(ObjectsParam.convert(123, obj))
        iprint(ObjectsParam.convert("Test", obj))
        iprint(ObjectsParam.convert([None, None], obj))
        iprint(ObjectsParam.convert([123, 456], obj))
        iprint(ObjectsParam.convert(["Test", "ing"], obj))
        iprint(ObjectsParam.convert(SimpleObject(), obj))
        iprint(ObjectsParam.convert([SimpleObject(), Text("Test")], obj))

        objs = Objects()
        objs += None
        objs += 123
        objs += "Test"
        objs += [None]
        objs += [123, 456]
        objs += ["Test", "ing"]
        objs += SimpleObject()
        objs += [SimpleObject(), Text("Test")]
        objs += [SimpleObject() + Text("Test")]

        iprint(objs)
Ejemplo n.º 8
0
    def __init__(self, items=Default, colspan=0, rowspan=0, **kwargs):
        self.init(kwargs)
        self.items = self.param(items, ObjectsParam, 'Content of the column', Objects())
        self.colspan = self.param(colspan, StringParam, 'Columns the cell spans')
        self.rowspan = self.param(rowspan, StringParam, 'Rows the cell spans')

        self.add_attribute('colspan', self.colspan)
        self.add_attribute('rowspan', self.rowspan)
Ejemplo n.º 9
0
    def inline_render(self, web_object):
        if self.separator and len(self._rendering_to) and self._rendering_to[-1].endswith(self.separator):
            self._rendering_to[-1] = self._rendering_to[-1][:-len(self.separator)]
        if web_object:
            if not isinstance(web_object, Object) and not isinstance(web_object, Objects):
                web_object = Objects(web_object)

            old_separator = self.separator
            self.separator = ''
            old_indent = self.indent
            self.indent = 0
            web_object.get_html(self)
            self.indent = old_indent

            self.separator = old_separator

        self.omit_next_indent = True
Ejemplo n.º 10
0
 def example(cls):
     return Objects([
         Heading('Heading level 1', 1, 'SubText level 1'),
         Heading('Heading level 2', 2, 'SubText level 2'),
         Heading('Heading level 3', 3, 'SubText level 3'),
         Heading('Heading level 4', 4, 'SubText level 4'),
         Heading('Heading level 5', 5, 'SubText level 5'),
         Heading('Heading level 6', 6, 'SubText level 6')
     ])
Ejemplo n.º 11
0
    def inline_render(self, web_object):
        if self.separator and len(
                self._rendering_to) and self._rendering_to[-1].endswith(
                    self.separator):
            self._rendering_to[-1] = self._rendering_to[-1][:-len(self.
                                                                  separator)]
        if web_object:
            if not isinstance(web_object, Object) and not isinstance(
                    web_object, Objects):
                web_object = Objects(web_object)

            old_separator = self.separator
            self.separator = ''
            old_indent = self.indent
            self.indent = 0
            web_object.get_html(self)
            self.indent = old_indent

            self.separator = old_separator

        self.omit_next_indent = True
Ejemplo n.º 12
0
    def __init__(self, items=Default, colspan=0, rowspan=0, align='', **kwargs):
        self.init(kwargs)
        self.items = self.param(items, ObjectsParam, 'Content of the column', Objects())
        self.colspan = self.param(colspan, IntegerParam, 'Span number of columns')
        self.rowspan = self.param(rowspan, IntegerParam, 'Span number of rows')
        self.align = self.param(align, StringParam, 'Align left, right or center')

        if self.colspan:
            self.add_attribute('colspan', self.colspan)
        if self.rowspan:
            self.add_attribute('rowspan', self.rowspan)
        if self.align:
            self.add_style('text-align: {};'.format(self.align))
Ejemplo n.º 13
0
 def __init__(self, background_url='', items=Default, speed=3, **kwargs):
     self.init(kwargs)
     self.background_url = self.param(background_url, UrlParam,
                                      'URL to the background image')
     self.items = self.param(items, ObjectsParam,
                             'The items in the section', Objects())
     self.speed = self.param(
         speed, FloatParam,
         'The speed of the parallax, higher numbers is slower. 1 is normal page speed, 2 is half speed, etc.'
     )
     self.add_style(
         'background: url({}) 50% 0/100% fixed; height: auto; margin: 0 auto; width: 100%; position: relative;'
         .format(self.background_url))
     self.id_needed()
Ejemplo n.º 14
0
 def __init__(self, head=None, rows=Default, table_style=None, **kwargs):
     self.init(kwargs)
     self.head = self.param(head, TableHead, 'Table Header')
     self.rows = self.param(rows, ObjectsParam, 'Rows in the table', Objects())
     self.table_style = self.param(table_style, TableStyle, 'Style for the table')
     self.add_class('table')
     if isinstance(self.table_style, str):
         self.add_class('table-' + self.table_style)
     elif isinstance(self.table_style, Iterable):
         for s in self.table_style:
             if not s == TableStyle.default:
                 self.add_class('table-' + TableStyle.name(s))
     elif isinstance(self.table_style, int):
         if not self.table_style == TableStyle.default:
             self.add_class('table-' + TableStyle.name(self.table_style))
Ejemplo n.º 15
0
 def __init__(self,
              img_url='',
              width=None,
              height=None,
              alt='',
              items=Default,
              **kwargs):
     self.init(kwargs)
     self.img_url = self.param(img_url, UrlParam, 'Link to the image')
     self.width = self.param(width, CssAttributeParam, 'Image width')
     self.height = self.param(height, CssAttributeParam, 'Image height')
     self.alt = self.param(alt, StringParam, 'Alt text')
     self.items = self.param(items, ObjectsParam, 'Items under the image',
                             Objects())
     self.add_class('thumbnail')
Ejemplo n.º 16
0
 def __init__(self,
              items=None,
              quick_float=None,
              centered=False,
              clearfix=False,
              **kwargs):
     self.init(kwargs)
     self.items = self.param(items, ObjectsParam, 'Items in the row',
                             Objects())
     self.quick_float = self.param(quick_float, QuickFloat,
                                   'Quick float to pull div left or right')
     self.centered = self.param(centered, BooleanParam,
                                'Whether the div is center block')
     self.clearfix = self.param(clearfix, BooleanParam,
                                'indicates whether to use clearfix')
     if self.quick_float:
         self.add_class(QuickFloat.name(self.quick_float))
     if self.centered:
         self.add_class('center-box')
     if self.clearfix:
         self.add_class('clearfix')
Ejemplo n.º 17
0
    def __init__(self,
                 text=Default,
                 url='',
                 bss=ButtonStyle.default,
                 size=Size.default,
                 state=ButtonState.none,
                 as_button=False,
                 microdata=False,
                 new_window=Default,
                 **kwargs):
        self.init(kwargs)
        self.text = self.param(text, ObjectsParam, 'Text of the link',
                               Objects())
        self.url = self.param(url, UrlParam, 'Action when clicked', '')
        self.bss = self.param(bss, ButtonStyle, 'Visual style of the button')
        self.size = self.param(size, Size, 'indicate size when used as button')
        self.state = self.param(
            state, ButtonState,
            'indicates the button state when used as button')
        self.as_button = self.param(as_button, BooleanParam,
                                    'Whether the anchor be used as button')
        self.microdata = self.param(
            microdata, BooleanParam,
            'This anchor is part of a microdata html part.')
        self.new_window = self.param(new_window, BooleanParam,
                                     'Open in a new window.', Default)

        if self.as_button:
            self.role = "button"
            self.add_class('btn {button_type}'.format(
                button_type='btn-' + ButtonStyle.name(self.bss)))
            if self.size:
                self.add_class('btn-' + Size.name(self.size))
            if self.state:
                if ButtonState.name(self.state) == 'active':
                    self.add_class('active')
                elif ButtonState.name(self.state) == 'disabled':
                    self.add_class('disabled')
Ejemplo n.º 18
0
 def __init__(self, items=Default, **kwargs):
     self.init(kwargs)
     self.items = self.param(items, ObjectsParam, 'Items in the <main>',
                             Objects())
Ejemplo n.º 19
0
 def __init__(self, columns=Default, action=None, **kwargs):
     self.init(kwargs)
     self.columns = self.param(columns, ObjectsParam, 'Columns in the table', Objects())
     self.url = self.param(action, UrlParam, 'Action to do when clicked')
Ejemplo n.º 20
0
 def __init__(self, columns=Default, **kwargs):
     self.init(kwargs)
     self.columns = self.param(columns, ObjectsParam, 'Columns in the table', Objects())
Ejemplo n.º 21
0
 def __init__(self, items=None, **kwargs):
     self.init(kwargs)
     self.items = self.param(items, ObjectsParam, 'Items in the <footer>',
                             Objects())
Ejemplo n.º 22
0
 def example(cls):
     return Objects([
         Paragraph('Before the divider'),
         Hr(),
         Paragraph('After the divider')
     ])
Ejemplo n.º 23
0
 def example(cls):
     return Objects(Paragraph('First paragraph...'), Spacer(40),
                    Paragraph('Second paragraph after extra space.'))
Ejemplo n.º 24
0
 def example(cls):
     return Objects(['Line 1', Br(), 'Line 2'])
Ejemplo n.º 25
0
 def __init__(self, **kwargs):
     self.init(kwargs)
     self.id_needed()
     self.items = Objects()
     self.data = VueData(self, **kwargs)
Ejemplo n.º 26
0
 def __init__(self, items=Default, **kwargs):
     self.init(kwargs)
     self.items = self.param(items, ObjectsParam, 'Content of <dd>',
                             Objects())
Ejemplo n.º 27
0
 def __init__(self, items=Default, **kwargs):
     self.init(kwargs)
     self.items = self.param(items, ObjectsParam, 'List items in <ol>',
                             Objects())
Ejemplo n.º 28
0
 def __init__(self, items=Default, **kwargs):
     self.init(kwargs)
     self.items = self.param(items, ObjectsParam, 'List items in list',
                             Objects())
     self.add_class('horizontal-list')
Ejemplo n.º 29
0
 def __init__(self, items=Default, **kwargs):
     self.init(kwargs)
     self.items = self.param(items, ObjectsParam, 'Items in the container',
                             Objects())
     self.add_class('jumbotron')