def thumbnail(span, *content): ''' Returns the HTML code for a single thumbnail element that can contain any HTML. Can contain one or multiple elements if needed. ''' return classed_li(SPAN_CLASS + span, *([classed_div(THUMBNAIL_CLASS, *content)] if len(elements) > 1 else content) )
def thumbnail(span, *content): ''' Returns the HTML code for a single thumbnail element that can contain any HTML. Can contain one or multiple elements if needed. ''' return classed_li( SPAN_CLASS + span, *([classed_div(THUMBNAIL_CLASS, *content)] if len(elements) > 1 else content))
def progress_factory(style, active, *bars): ''' Returns the HTML code for a progress bar based on the style and width provided. Multiple bars can be included, see bar_factory() and info_bar(), warning_bar(), success_bar(), etc. for child elements. ''' return classed_div( [PROGRESS_CLASS] + style if style else [] + [ACTIVE_CLASS] if active else [], *bars )
def bar_factory(style, width): ''' Returns the HTML code for a section within a progress bar based on the style and width provided. Width must be a float between 0 and 1, this makes no guarantees as to the total width of all bar elements within a progress bar, so make sure your math adds up! ''' return classed_div([BAR_CLASS] + style if style else [], {"style": "width: %%" % width}, "" )
def alert_factory(is_long, title, *content): ''' Returns the HTML code for a generic alert message. Really only to be used internally, use alert() or long_alert() ''' return classed_div(ALERT_CLASS, *content, prepend=[classed_button(CLOSE_CLASS, { "type": BUTTON_CLASS, "data-dismiss": ALERT_CLASS }, "x" ), strong(title) if is_long else h4(title)], )
def alert_factory(is_long, title, *content): ''' Returns the HTML code for a generic alert message. Really only to be used internally, use alert() or long_alert() ''' return classed_div( ALERT_CLASS, *content, prepend=[ classed_button(CLOSE_CLASS, { "type": BUTTON_CLASS, "data-dismiss": ALERT_CLASS }, "x"), strong(title) if is_long else h4(title) ], )
def media(img_url, title, link_url, *content): ''' Returns the HTML for a basic formatter for a "media object" like a video or something. It kind of looks like a Facebook post. ''' return classed_div(MEDIA_CLASS, *media_content(img_url, title, link_url, *content ) def media_list(*content): ''' A list that handles media items (even nested!) gracefully. Use media_list_item to generate them. ''' return classed_ul(MEDIA_LIST_CLASS, *content) def media_list_item(img_url, title, link_url, *content): ''' A single list item in a media list (see media_list() for something that is designed to gracefully hold them). ''' return classed_li(MEDIA_CLASS, *media_content(img_url, title, link_url, *content) ) def media_content(img_url, title, link_url, *content): ''' Returns the content to a media block. Should only be used internally, use media() or media_list() + media_list_item(). ''' return [ classed_a(PULL_LEFT, href(link_url), img({"src": img_url, "class": MEDIA_OBJECT_CLASS}) ), classed_div(MEDIA_BODY_CLASS, h4(classes(MEDIA_HEADING_CLASS), title), *content ) ]
def small_well(*content): ''' Returns the HTML code for a small well. Like a grey-background blockquote. ''' return classed_div([WELL_CLASS, SMALL_WELL_CLASS], *content)
def container(*content): ''' Returns the HTML code for a basic div container. ''' return classed_div(CONTAINER_CLASS, *content)
def well(*content): ''' Returns the HTML code for a well. Like a grey-background blockquote. ''' return classed_div(WELL_CLASS, *content)
def large_well(*content): ''' Returns the HTML code for a large well. Like a grey-background blockquote. ''' return classed_div([WELL_CLASS, LARGE_WELL_CLASS], *content)
def button_group(*content): ''' Returns the HTML code for a button group that contains the given buttons. ''' return classed_div(BUTTON_GROUP_CLASS, *content)
def button_toolbar(*content): ''' Returns the HTML code for a toolbar that contains the given buttons. ''' return classed_div(BUTTON_TOOLBAR_CLASS, *content)
def tab_pane(tab_id, *content): ''' Returns a single content pane for tab navigation. ''' return classed_div(TAB_PANE_CLASS, ID(tab_id), *content))
def pagination(*content): ''' Returns the HTML for a pagination element. Fill with an unordered list (I know, right? Unordered?) to display properly. ''' return classed_div(PAGINATION_CLASS, *content)
def tab_container(*content): ''' Returns a container for tab-pane elements. ''' return classed_div(TAB_CONTENT_CLASS, *content)
def hero_unit(*content): ''' Returns the HTML code for a 'Hero Unit', like a big marketing banner on a front page. ''' return classed_div(HERO_UNIT_CLASS, *elements)
def tab_navigation(*content): ''' Returns the HTML code for a tab navigation container using the supplied tabs and container (see tabs() and tab_container()). ''' return classed_div(TABBABLE_CLASS, *content)
def page_header(title, subtitle): ''' Returns the HTML for a page header or title, with a subtitle. ''' return classed_div(PAGE_HEADER_CLASS, h1(title, small(subtitle) )