def nav_dropdown(title, *content): ''' A button to open a dropdown menu in a navbar. Give it a menu in the content for it to actually work. WARNING: Unlike other functions, this one can't take extra classes right now :( ''' return classed_li(DROPDOWN_CLASS, classed_a( combine(DROPDOWN_CLASS, "toggle"), toggle(DROPDOWN_CLASS), title, classed_b("caret"), *content ) )
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classes, classed_a, classed_div, classed_ul, classed_li, combine # Convenience methods for generating Twitter Bootstrap media elements. # http://twitter.github.com/bootstrap/components.html#media MEDIA_CLASS = "media" MEDIA_LIST_CLASS = combine(MEDIA_CLASS, "list") MEDIA_BODY_CLASS = combine(MEDIA_CLASS, "body") MEDIA_OBJECT_CLASS = combine(MEDIA_CLASS, "object") MEDIA_HEADING_CLASS = combine(MEDIA_CLASS, "heading") PULL_LEFT = "pull-left" 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. '''
import sys sys.path.append("../dynamo") from dynamo import * from button_groups import zm_button, button_group from dropdowns import dropdown_menu, DROPDOWN_CLASS from common import extract_attributes, classed_span, classed_button, combine # Convenience methods for generating Twitter Bootstrap button dropdown HTML # code. See http://twitter.github.com/bootstrap/components.html#buttonDropdowns # for examples. BUTTON_CLASS = "btn" BUTTON_GROUP_CLASS = combine(BUTTON_CLASS, "group") DROPDOWN_TOGGLE_CLASS = combine(DROPDOWN_CLASS, "toggle") def button_dropdown(text, *menu_items): """ Returns the HTML code for a button with a caret and a dropdown menu containing the given menu items. """ return button_group(zm_button(text), caret_button(), dropdown_menu(*menu_items)) def button_dropup(text, *menu_items): """ Returns the HTML code for a button with a caret and a drop-up menu containing the given menu items. """ return button_dropup_group(zm_button(text), caret_button(), dropdown_menu(*menu_items))
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_div, classed_a, combine, href # Convenience methods for generating miscellaneous Twitter Bootstrap elements. # http://twitter.github.com/bootstrap/components.html#misc WELL_CLASS = "well" LARGE_WELL_CLASS = combine(WELL_CLASS, "large") SMALL_WELL_CLASS = combine(WELL_CLASS, "small") CONTAINER_CLASS = "container" CLOSE_CLASS = "close" 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 small_well(*content):
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_div, classed_button, classes, combine # Convenience methods for generating Twitter Bootstrap button group HTML code. # http://twitter.github.com/bootstrap/components.html#buttonGroup for examples. BUTTON_CLASS = "btn" BUTTON_GROUP_CLASS = combine(BUTTON_CLASS, "group") BUTTON_TOOLBAR_CLASS = combine(BUTTON_CLASS, "toolbar") BUTTON_GROUP_VERTICAL_CLASS = combine(BUTTON_GROUP_CLASS, "vertical") # *sigh* button() is already taken by straight HTML buttons. Jerks. def zm_button(text): ''' Returns the HTML code for a Twitter Bootstrap-ready button. ''' return classed_button(BUTTON_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 vertical_button_group(*content):
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_div, classed_button, classes, combine, SUCCESS, INFO, ERROR # Convenience methods for generating Twitter Bootstrap alert elements. # http://twitter.github.com/bootstrap/components.html#alerts ALERT_CLASS = "alert" ALERT_BLOCK_CLASS = ALERT_CLASS + "-block" CLOSE_CLASS = "close" BUTTON_CLASS = "button" ALERT_ERROR_CLASS = combine(ALERT_CLASS, ERROR) ALERT_SUCCESS_CLASS = combine(ALERT_CLASS, SUCCESS) ALERT_INFO_CLASS = combine(ALERT_CLASS, INFO) def alert(title, *content): ''' Returns the HTML code for a small, yellow alert message. ''' return alert_factory(False, title, *content) def long_alert(title, *content): ''' Returns the HTML code for a long, yellow alert message. ''' return alert_factory(True, title, *content)
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_li, classed_ul, untabbable, classes, combine, untabbable # Convenience methods for generating Twitter Bootstrap dropdown menu HTML code. # http://twitter.github.com/bootstrap/components.html#dropdowns for examples. DROPDOWN_CLASS = "dropdown" DROPUP_CLASS = "dropup" MENU_CLASS = combine(DROPDOWN_CLASS, "menu") SUBMENU_CLASS = combine(DROPDOWN_CLASS, "submenu") DIVIDER_CLASS = "divider" def dropdown_menu(*items): """ Returns the HTML code for a dropdown menu containing the given menu items. """ return classed_ul(MENU_CLASS, {"role": "menu", "aria-labelledBy": "dropdownMenu"}, *items) def menu_item(*content): """ Returns the HTML code for a menu item in a dropdown menu. """ return classed_li(*content)
import sys sys.path.append("../dynamo") from dynamo import * from common import classed_span, classes, combine, SUCCESS, WARNING, IMPORTANT, INFO, INVERSE # Convenience methods for generating Twitter Bootstrap labels and badges. # http://twitter.github.com/bootstrap/components.html#labels-badges LABEL_CLASS = "label" BADGE_CLASS = "badge" LABEL_SUCCESS_CLASS = combine(LABEL_CLASS, SUCCESS) LABEL_WARNING_CLASS = combine(LABEL_CLASS, WARNING) LABEL_IMPORTANT_CLASS = combine(LABEL_CLASS, IMPORTANT) LABEL_INFO_CLASS = combine(LABEL_CLASS, INFO) LABEL_INVERSE_CLASS = combine(LABEL_CLASS, INVERSE) BADGE_SUCCESS_CLASS = combine(BADGE_CLASS, SUCCESS) BADGE_WARNING_CLASS = combine(BADGE_CLASS, WARNING) BADGE_IMPORTANT_CLASS = combine(BADGE_CLASS, IMPORTANT) BADGE_INFO_CLASS = combine(BADGE_CLASS, INFO) BADGE_INVERSE_CLASS = combine(BADGE_CLASS, INVERSE) def default_label(*content): ''' Returns the HTML code for a grey-coloured label. ''' return classed_span(LABEL_CLASS, *content) def success_label(*content): ''' Returns the HTML code for a successfully-green coloured label. '''
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_ul, classed_div, classes, combine, active, disabled, ID # Convenience methods for generating Twitter Bootstrap navigation elements # HTML code - http://twitter.github.com/bootstrap/components.html#navs. NAV_CLASS = "nav" NAV_TABS_CLASS = combine(NAV_CLASS, "tabs") NAV_PILLS_CLASS = combine(NAV_CLASS, "pills") NAV_STACKED_CLASS = combine(NAV_CLASS, "stacked") TABBABLE_CLASS = "tabbable" TAB_CLASS = "tab" TAB_LEFT_CLASS = combine(TAB_CLASS, "left") TAB_RIGHT_CLASS = combine(TAB_CLASS, "right") TAB_BELOW_CLASS = combine(TAB_CLASS, "below") TAB_CONTENT_CLASS = combine(TAB_CLASS, "content") TAB_PANE_CLASS = combine(TAB_CLASS, "pane") def generic_nav(*content): ''' Returns the HTML code for a set of tab navigaiton elements using the set of given tabs. ''' return classed_ul([NAV_CLASS, NAV_TABS_CLASS], *content) def pills(*content): ''' Returns the HTML code for a set of "pill" navigaiton elements using the set of given tabs. '''
import sys import collections sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_div, combine, ACTIVE, SUCCESS, WARNING, DANGER # Convenience methods for generating Twitter Bootstrap progress bar elements. # http://twitter.github.com/bootstrap/components.html#progress PROGRESS_CLASS = "progress" BAR_CLASS = "bar" STRIPED = "striped" PROGRESS_STRIPED_CLASS = combine(PROGRESS_CLASS, STRIPED) PROGRESS_INFO_CLASS = combine(PROGRESS_CLASS, INFO) PROGRESS_WARNING_CLASS = combine(PROGRESS_CLASS, SUCCESS) PROGRESS_SUCCESS_CLASS = combine(PROGRESS_CLASS, WARNING) PROGRESS_DANGER_CLASS = combine(PROGRESS_CLASS, DANGER) SUCCESS_BAR_CLASS = combine(BAR_CLASS, WARNING) WARNING_BAR_CLASS = combine(BAR_CLASS, SUCCESS) DANGER_BAR_CLASS = combine(BAR_CLASS, DANGER) def progress_bar(*bars): ''' Returns the HTML code for a blue progress bar. ''' return progresss_factory(None, False, *bars) def striped_progress_bar(*bars): ''' Returns the HTML code for a blue, striped progress bar. '''
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_div, classes, combine, LARGE, SMALL, MINI # Convenience methods for generating Twitter Bootstrap pagination elements. # http://twitter.github.com/bootstrap/components.html#pagination PAGINATION_CLASS = "pagination" PAGINATION_LARGE_CLASS = combine(PAGINATION_CLASS, LARGE) PAGINATION_SMALL_CLASS = combine(PAGINATION_CLASS, SMALL) PAGINATION_MINI_CLASS = combine(PAGINATION_CLASS, MINI) 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 large_pagination(*content): ''' Returns the HTML for a huge pagination element. Fill with an unordered list to display properly. ''' return pagination(classes(PAGINATION_LARGE_CLASS), *content) def small_pagination(*content): ''' Returns the HTML for a small pagination element. Fill with an unordered list to display properly. '''
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_div, combine # Convenience methods for generating Twitter Bootstrap typographic elements. # http://twitter.github.com/bootstrap/components.html#typography HERO_UNIT_CLASS = combine("hero", "unit") PAGE_HEADER_CLASS = combine("page", "header") 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 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) )
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_div, classed_a, combine, href # Convenience methods for generating miscellaneous Twitter Bootstrap elements. # http://twitter.github.com/bootstrap/components.html#misc WELL_CLASS = "well" LARGE_WELL_CLASS = combine(WELL_CLASS, "large") SMALL_WELL_CLASS = combine(WELL_CLASS, "small") CONTAINER_CLASS = "container" CLOSE_CLASS = "close" 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 small_well(*content): ''' Returns the HTML code for a small well. Like a grey-background
import sys sys.path.append("../dynamo") from dynamo import * from button_groups import zm_button, button_group from dropdowns import dropdown_menu, DROPDOWN_CLASS, from common import extract_attributes, classed_span, classed_button, combine # Convenience methods for generating Twitter Bootstrap button dropdown HTML # code. See http://twitter.github.com/bootstrap/components.html#buttonDropdowns # for examples. BUTTON_CLASS = "btn" BUTTON_GROUP_CLASS = combine(BUTTON_CLASS, "group") DROPDOWN_TOGGLE_CLASS = combine(DROPDOWN_CLASS, "toggle") def button_dropdown(text, *menu_items): ''' Returns the HTML code for a button with a caret and a dropdown menu containing the given menu items. ''' return button_group( zm_button(text), caret_button(), dropdown_menu(*menu_items), ) def button_dropup(text, *menu_items): ''' Returns the HTML code for a button with a caret and a drop-up menu
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_a, classed_ul, classed_li, classed_input, classed_form, classed_p, combine, classed_span from buttons import BUTTON_CLASS from dropdowns import DROPDOWN_CLASS # Convenience methods for generating Twitter Bootstrap navigation bars. # http://twitter.github.com/bootstrap/components.html#navbar NAVBAR_CLASS = "navbar" NAVBAR_INNER_CLASS = combine(NAVBAR_CLASS, "inner") NAVBAR_INVERSE_CLASS = combine(NAVBAR_CLASS, "inverse") NAVBAR_FIXED_TOP_CLASS = combine(NAVBAR_CLASS, "fixed", "top") NAVBAR_BUTTON_CLASS = combine(BUTTON_CLASS, NAVBAR_CLASS) BRAND_CLASS = "brand" PULL_LEFT_CLASS = combine("pull", "left") PULL_RIGHT_CLASS = combine("pull", "right") NAVBAR_FORM_CLASS = combine(NAVBAR_CLASS, "form") NAVBAR_SEARCH_CLASS = combine(NAVBAR_CLASS, "search") NAVBAR_TEXT_CLASS = combine(NAVBAR_FORM_CLASS, "text") SEARCH_INPUT_CLASS = combine("search", "query") NAV_CLASS = "nav" NAV_HEADER_CLASS = combine(NAV_CLASS, "header") DIVIDER_CLASS = combine("divider", "vertical")
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_li, classed_ul, untabbable, classes, combine, untabbable # Convenience methods for generating Twitter Bootstrap dropdown menu HTML code. # http://twitter.github.com/bootstrap/components.html#dropdowns for examples. DROPDOWN_CLASS = "dropdown" DROPUP_CLASS = "dropup" MENU_CLASS = combine(DROPDOWN_CLASS, "menu") SUBMENU_CLASS = combine(DROPDOWN_CLASS, "submenu") DIVIDER_CLASS = "divider" def dropdown_menu(*items): ''' Returns the HTML code for a dropdown menu containing the given menu items. ''' return classed_ul(MENU_CLASS, { "role": "menu", "aria-labelledBy": "dropdownMenu", }, *items) def menu_item(*content): ''' Returns the HTML code for a menu item in a dropdown menu. ''' return classed_li(*content)
import sys sys.path.append("../dynamo") from dynamo import * from common import extract_attributes, classed_div, classed_button, classes, combine, SUCCESS, INFO, ERROR # Convenience methods for generating Twitter Bootstrap alert elements. # http://twitter.github.com/bootstrap/components.html#alerts ALERT_CLASS = "alert" ALERT_BLOCK_CLASS = ALERT_CLASS + "-block" CLOSE_CLASS = "close" BUTTON_CLASS = "button" ALERT_ERROR_CLASS = combine(ALERT_CLASS, ERROR) ALERT_SUCCESS_CLASS = combine(ALERT_CLASS, SUCCESS) ALERT_INFO_CLASS = combine(ALERT_CLASS, INFO) def alert(title, *content): ''' Returns the HTML code for a small, yellow alert message. ''' return alert_factory(False, title, *content) def long_alert(title, *content): ''' Returns the HTML code for a long, yellow alert message. ''' return alert_factory(True, title, *content) def alert_factory(is_long, title, *content): ''' Returns the HTML code for a generic alert message. Really only to be