Ejemplo n.º 1
0
    def navigation_widget_breadcrumbs(self):
        """Views for the "breadcrumbs" display type, which is essentially the
           same as Kotti's default breadcrumbs display, except that here you
           have control of the associated label.
             - They each use the general navigation_widget_breadcrumbs()
               function.
        """
        resource_group.need()
        root = get_root()
        options = get_setting(self.location + "_options", default=[])
        include_root = "include_root" in options
        label = parse_label(self.context.title, get_setting(self.location + "_label"))

        # When the nav display is set to the beforebodyend slot, the class
        # for the containing div needs to be 'container' so it fits to the
        # middle span12 area for content. When nav is in any of the other
        # slots, no class is needed, because the inherited CSS works to fit
        # nav to the slot.
        use_container_class = self.location == "beforebodyend"

        lineage_items = get_lineage(self.context, self.request, self.location)
        if not include_root and root in lineage_items:
            lineage_items.remove(root)

        lineage_items.reverse()

        return {
            "location": self.location,
            "use_container_class": use_container_class,
            "label": label,
            "lineage_items": lineage_items,
        }
Ejemplo n.º 2
0
def navigation_widget_items(context, request, name=''):
    """Views for the "items" display type, a term used to avoid confusion
       that comes with calling this a "list" -- there are horizontal lists and
       there are vertical aspect lists. We distinguish here that the following
       views are not recursive and tree-like. They offer a limited list of
       items for the current context.
       - They each use the general navigation_widget_items() view function.
    """

    # Assume top location, unless name or request.path are available.
    location = 'top'

    if name:
        location = name[name.rfind('-') + 1:]
    elif 'navigation-widget' in request.path:
        location = location_from_path(request.path)

    resource_group.need()
    settings = navigation_settings()
    display_type = settings['{0}_display_type'.format(location)]
    show_menu = asbool(settings['{0}_show_menu'.format(location)])
    label = parse_label(context.title, settings['{0}_label'.format(location)])

    nav_class = 'nav nav-tabs'
    dropdowns = False

    if 'hor_' in display_type:

        tabs_or_pills = 'tabs' if 'tabs' in display_type else 'pills'
        nav_class = 'nav nav-{0}'.format(tabs_or_pills)
        dropdowns = True if display_type.endswith('downs') else False

    elif display_type == 'ver_list':

        nav_class = 'nav nav-list'
        dropdowns = True if display_type.endswith('downs') else False

    # When the nav display is set to the beforebodyend slot, the class for the
    # containing div needs to be 'container' so it fits to the middle span12
    # area for content. When nav is in any of the other slots, no class is
    # needed, because the inherited CSS works to fit nav to the slot.
    use_container_class = True if location == 'beforebodyend' else False

    items = get_children(context, request, location)

    allowed_children = []
    for item in items:
        ac = get_children(item, request, location)
        allowed_children.append(ac if ac else [])

    return {'location': location,
            'items': items,
            'display_type': display_type,
            'nav_class': nav_class,
            'use_container_class': use_container_class,
            'show_menu': show_menu,
            'allowed_children': allowed_children,
            'label': label,
            'show_item_dropdowns': dropdowns,
        }
Ejemplo n.º 3
0
def navigation_widget_menu(context, request, name=''):
    """Views for the "menu" display type, which consists of a single button
       with a dropdown for presenting a full site context menu.
       - They each use the general navigation_widget_menu() view function.
       - The menu can be used standalone as the only nav display in a given
         location, or it can be combined with a label and/or another display
         type, e.g. a horizontal items nav display.
    """
    # Assume top location, unless name or request.path are available.
    location = 'top'

    if name:
        location = name[name.rfind('-') + 1:]
    elif 'navigation-widget' in request.path:
        location = location_from_path(request.path)

    resource_group.need()

    root = get_root()

    settings = navigation_settings()

    include_root = asbool(settings['{0}_include_root'.format(location)])

    # When the nav display is set to the beforebodyend slot, the class for the
    # containing div needs to be 'container' so it fits to the middle span12
    # area for content. When nav is in any of the other slots, no class is
    # needed, because the inherited CSS works to fit nav to the slot.
    use_container_class = True if location == 'beforebodyend' else False

    items = get_children(context, request, location)

    top_level_items = get_children(root, request, location)

    # The lineage function of pyramid is used to make a breadcrumbs-style
    # display for the context menu.
    lineage_items = get_lineage(context, request, location)
    if not include_root and root in lineage_items:
        lineage_items.remove(root)

    # The lineage comes back in root-last order, so reverse.
    lineage_items.reverse()

    # The lineage (breadcrumbs style) display in navigation.pt shows
    # lineage_items in an indented dropdown list, and below that has a li
    # repeat on items, indented beneath context.

    return {
        'root': root,
        'location': location,
        'items': items,
        'use_container_class': use_container_class,
        'include_root': include_root,
        'top_level_items': top_level_items,
        'lineage_items': lineage_items
    }
Ejemplo n.º 4
0
def navigation_widget_menu(context, request, name=''):
    """Views for the "menu" display type, which consists of a single button
       with a dropdown for presenting a full site context menu.
       - They each use the general navigation_widget_menu() view function.
       - The menu can be used standalone as the only nav display in a given
         location, or it can be combined with a label and/or another display
         type, e.g. a horizontal items nav display.
    """
    # Assume top location, unless name or request.path are available.
    location = 'top'

    if name:
        location = name[name.rfind('-') + 1:]
    elif 'navigation-widget' in request.path:
        location = location_from_path(request.path)

    resource_group.need()

    root = get_root()

    settings = navigation_settings()

    include_root = asbool(settings['{0}_include_root'.format(location)])

    # When the nav display is set to the beforebodyend slot, the class for the
    # containing div needs to be 'container' so it fits to the middle span12
    # area for content. When nav is in any of the other slots, no class is
    # needed, because the inherited CSS works to fit nav to the slot.
    use_container_class = True if location == 'beforebodyend' else False

    items = get_children(context, request, location)

    top_level_items = get_children(root, request, location)

    # The lineage function of pyramid is used to make a breadcrumbs-style
    # display for the context menu.
    lineage_items = get_lineage(context, request, location)
    if not include_root and root in lineage_items:
        lineage_items.remove(root)

    # The lineage comes back in root-last order, so reverse.
    lineage_items.reverse()

    # The lineage (breadcrumbs style) display in navigation.pt shows
    # lineage_items in an indented dropdown list, and below that has a li
    # repeat on items, indented beneath context.

    return {'root': root,
            'location': location,
            'items': items,
            'use_container_class': use_container_class,
            'include_root': include_root,
            'top_level_items': top_level_items,
            'lineage_items': lineage_items}
Ejemplo n.º 5
0
    def navigation_widget_menu(self):
        """Views for the "menu" display type, which consists of a single button
           with a dropdown for presenting a full site context menu.
           - They each use the general navigation_widget_menu() view function.
           - The menu can be used standalone as the only nav display in a given
             location, or it can be combined with a label and/or another
             display type, e.g. a horizontal items nav display.
        """
        resource_group.need()
        root = get_root()
        options = get_setting(self.location + "_options", default=[])
        include_root = "include_root" in options

        # When the nav display is set to the beforebodyend slot, the class
        # for the containing div needs to be 'container' so it fits to the
        # middle span12 area for content. When nav is in any of the other
        # slots, no class is needed, because the inherited CSS works to fit
        # nav to the slot.
        use_container_class = self.location == "beforebodyend"

        items = get_children(self.context, self.request, self.location)

        top_level_items = get_children(root, self.request, self.location)

        # The lineage function of pyramid is used to make a breadcrumbs-style
        # display for the context menu.
        lineage_items = get_lineage(self.context, self.request, self.location)
        if not include_root and root in lineage_items:
            lineage_items.remove(root)

        # The lineage comes back in root-last order, so reverse.
        lineage_items.reverse()

        # The lineage (breadcrumbs style) display in navigation.pt shows
        # lineage_items in an indented dropdown list, and below that has a li
        # repeat on items, indented beneath context.

        return {
            "root": root,
            "location": self.location,
            "items": items,
            "use_container_class": use_container_class,
            "include_root": include_root,
            "top_level_items": top_level_items,
            "lineage_items": lineage_items,
        }
Ejemplo n.º 6
0
    def navigation_widget_tree(self):
        """Views for display type "tree", continued:
          - These are the main views for the tree display type, each using the
            general navigation_widget_tree() view function.
          - The nav recurse view above is called from nav_widget_tree.pt,
            used in each of these.
        """
        resource_group.need()
        root = get_root()

        display_type = get_setting(self.location + '_display_type')
        options = get_setting(self.location + '_options')
        if 'dropdowns' in options:
            dropdown_resource_group.need()

        include_root = 'include_root' in options
        show_menu = 'show_menu' in options
        label = get_setting(self.location + '_label')
        if label:
            label = parse_label(self.context.title, label)

        # When the nav display is set to the beforebodyend slot, the class
        # for the containing div needs to be 'container' so it fits to the
        # middle span12 area for content. When nav is in any of the other
        # slots, no class is needed, because the inherited CSS works to fit
        # nav to the slot.
        use_container_class = self.location == 'beforebodyend'

        items = get_children(root, self.request, self.location)
        tree_is_open_all = 'open_all' in options
        nav_class = get_nav_class(self.location)

        return {'location': self.location,
                'root': root,
                'display_type': display_type,
                'include_root': include_root,
                'show_menu': show_menu,
                'show_divider': show_menu and self.location != 'top' and items,
                'nav_class': nav_class,
                'tree_is_open_all': tree_is_open_all,
                'is_node_open': is_node_open,
                'use_container_class': use_container_class,
                'items': items,
                'label': label,
                'dropdowns': 'dropdowns' in options,
                'hidden': ''}
Ejemplo n.º 7
0
    def navigation_widget_tree(self):
        """Views for display type "tree", continued:
          - These are the main views for the tree display type, each using the
            general navigation_widget_tree() view function.
          - The nav recurse view above is called from nav_widget_tree.pt,
            used in each of these.
        """
        resource_group.need()
        root = get_root()

        display_type = get_setting(self.location + "_display_type")
        options = get_setting(self.location + "_options")

        include_root = "include_root" in options
        show_menu = "show_menu" in options
        label = get_setting(self.location + "_label")
        if label:
            label = parse_label(self.context.title, label)

        # When the nav display is set to the beforebodyend slot, the class
        # for the containing div needs to be 'container' so it fits to the
        # middle span12 area for content. When nav is in any of the other
        # slots, no class is needed, because the inherited CSS works to fit
        # nav to the slot.
        use_container_class = self.location == "beforebodyend"

        items = get_children(root, self.request, self.location)
        tree_is_open_all = "open_all" in options
        nav_class = get_nav_class(options)

        return {
            "location": self.location,
            "root": root,
            "display_type": display_type,
            "include_root": include_root,
            "show_menu": show_menu,
            "show_divider": show_menu and self.location != "top" and items,
            "nav_class": nav_class,
            "tree_is_open_all": tree_is_open_all,
            "is_node_open": is_node_open,
            "use_container_class": use_container_class,
            "items": items,
            "label": label,
        }
Ejemplo n.º 8
0
    def navigation_widget_items(self):
        """Views for the "items" display type, a term used to avoid confusion
           that comes with calling this a "list" -- there are horizontal lists
           and there are vertical aspect lists. We distinguish here that the
           following views are not recursive and tree-like. They offer a
           limited list of items for the current context.
           - They each use the general navigation_widget_items() view function.
        """
        resource_group.need()

        display_type = get_setting(self.location + '_display_type')
        options = get_setting(self.location + '_options', default=[])
        nav_class = get_nav_class(self.location)

        # When the nav display is set to the beforebodyend slot, the class
        # for the containing div needs to be 'container' so it fits to the
        # middle span12 area for content. When nav is in any of the other
        # slots, no class is needed, because the inherited CSS works to fit
        # nav to the slot.
        use_container_class = self.location == 'beforebodyend'

        items = get_children(self.context, self.request, self.location)

        allowed_children = []
        for item in items:
            ac = get_children(item, self.request, self.location)
            allowed_children.append(ac if ac else [])

        label = parse_label(self.context.title,
                            get_setting(self.location + '_label'))

        careted = (display_type == 'items') and\
                    ('dropdowns' in options)

        return {'location': self.location,
                'items': items,
                'display_type': display_type,
                'nav_class': nav_class,
                'use_container_class': use_container_class,
                'show_menu': 'show_menu' in options,
                'allowed_children': allowed_children,
                'label': label,
                'dropdowns': 'dropdowns' in options,
            }
Ejemplo n.º 9
0
def navigation_widget_breadcrumbs(context, request, name=''):
    """Views for the "breadcrumbs" display type, which is essentially the
       same as Kotti's default breadcrumbs display, except that here you have
       control of the associated label.
         - They each use the general navigation_widget_breadcrumbs() function.
    """
    # Assume top location, unless name or request.path are available.
    location = 'top'

    if name:
        location = name[name.rfind('-') + 1:]
    elif 'navigation-widget' in request.path:
        location = location_from_path(request.path)

    resource_group.need()

    root = get_root()

    settings = navigation_settings()

    include_root = asbool(settings['{0}_include_root'.format(location)])

    label = parse_label(context.title, settings['{0}_label'.format(location)])

    # When the nav display is set to the beforebodyend slot, the class for the
    # containing div needs to be 'container' so it fits to the middle span12
    # area for content. When nav is in any of the other slots, no class is
    # needed, because the inherited CSS works to fit nav to the slot.
    use_container_class = True if location == 'beforebodyend' else False

    lineage_items = get_lineage(context, request, location)
    if not include_root and root in lineage_items:
        lineage_items.remove(root)

    lineage_items.reverse()

    return {
        'location': location,
        'use_container_class': use_container_class,
        'label': label,
        'lineage_items': lineage_items
    }
Ejemplo n.º 10
0
def navigation_widget_breadcrumbs(context, request, name=''):
    """Views for the "breadcrumbs" display type, which is essentially the
       same as Kotti's default breadcrumbs display, except that here you have
       control of the associated label.
         - They each use the general navigation_widget_breadcrumbs() function.
    """
    # Assume top location, unless name or request.path are available.
    location = 'top'

    if name:
        location = name[name.rfind('-') + 1:]
    elif 'navigation-widget' in request.path:
        location = location_from_path(request.path)

    resource_group.need()

    root = get_root()

    settings = navigation_settings()

    include_root = asbool(settings['{0}_include_root'.format(location)])

    label = parse_label(context.title, settings['{0}_label'.format(location)])

    # When the nav display is set to the beforebodyend slot, the class for the
    # containing div needs to be 'container' so it fits to the middle span12
    # area for content. When nav is in any of the other slots, no class is
    # needed, because the inherited CSS works to fit nav to the slot.
    use_container_class = True if location == 'beforebodyend' else False

    lineage_items = get_lineage(context, request, location)
    if not include_root and root in lineage_items:
        lineage_items.remove(root)

    lineage_items.reverse()

    return {'location': location,
            'use_container_class': use_container_class,
            'label': label,
            'lineage_items': lineage_items}
Ejemplo n.º 11
0
def navigation_widget_tree(context, request, name=''):
    """Views for display type "tree", continued:
      - These are the main views for the tree display type, each using the
        general navigation_widget_tree() view function.
      - The nav recurse view above is called from nav_widget_tree.pt,
        used in each of these.
    """
    # Assume top location, unless name or request.path are available.
    location = 'top'

    if name:
        location = name[name.rfind('-') + 1:]
    elif 'navigation-widget' in request.path:
        location = location_from_path(request.path)

    resource_group.need()

    root = get_root()

    settings = navigation_settings()

    # Set defaults:
    display_type = 'ver_tabs_stacked'
    include_root = False
    show_menu = False
    label = ''

    display_type_key = '{0}_display_type'.format(location)

    if display_type_key in settings:
        display_type = settings[display_type_key]

    include_root_key = '{0}_include_root'.format(location)
    if include_root_key in settings:
        include_root = asbool(settings[include_root_key])

    show_menu_key = '{0}_show_menu'.format(location)
    if show_menu_key in settings:
        show_menu = asbool(settings[show_menu_key])

    label_key = '{0}_label'.format(location)
    if label_key in settings:
        label = parse_label(context.title, settings[label_key])

    # When the nav display is set to the beforebodyend slot, the class for the
    # containing div needs to be 'container' so it fits to the middle span12
    # area for content. When nav is in any of the other slots, no class is
    # needed, because the inherited CSS works to fit nav to the slot.
    use_container_class = True if location == 'beforebodyend' else False

    items = get_children(root, request, location)

    tabs_or_pills = 'tabs' if 'tabs' in display_type else 'pills'
    nav_class = 'nav nav-{0} nav-stacked'.format(tabs_or_pills)
    tree_is_open_all = True if display_type.endswith('open_all') else False

    return {
        'location': location,
        'root': root,
        'display_type': display_type,
        'include_root': include_root,
        'show_menu': show_menu,
        'nav_class': nav_class,
        'tree_is_open_all': tree_is_open_all,
        'is_node_open': is_node_open,
        'use_container_class': use_container_class,
        'items': items,
        'label': label
    }
Ejemplo n.º 12
0
def navigation_widget_items(context, request, name=''):
    """Views for the "items" display type, a term used to avoid confusion
       that comes with calling this a "list" -- there are horizontal lists and
       there are vertical aspect lists. We distinguish here that the following
       views are not recursive and tree-like. They offer a limited list of
       items for the current context.
       - They each use the general navigation_widget_items() view function.
    """

    # Assume top location, unless name or request.path are available.
    location = 'top'

    if name:
        location = name[name.rfind('-') + 1:]
    elif 'navigation-widget' in request.path:
        location = location_from_path(request.path)

    resource_group.need()
    settings = navigation_settings()
    display_type = settings['{0}_display_type'.format(location)]
    show_menu = asbool(settings['{0}_show_menu'.format(location)])
    label = parse_label(context.title, settings['{0}_label'.format(location)])

    nav_class = 'nav nav-tabs'
    dropdowns = False

    if 'hor_' in display_type:

        tabs_or_pills = 'tabs' if 'tabs' in display_type else 'pills'
        nav_class = 'nav nav-{0}'.format(tabs_or_pills)
        dropdowns = True if display_type.endswith('downs') else False

    elif display_type == 'ver_list':

        nav_class = 'nav nav-list'
        dropdowns = True if display_type.endswith('downs') else False

    # When the nav display is set to the beforebodyend slot, the class for the
    # containing div needs to be 'container' so it fits to the middle span12
    # area for content. When nav is in any of the other slots, no class is
    # needed, because the inherited CSS works to fit nav to the slot.
    use_container_class = True if location == 'beforebodyend' else False

    items = get_children(context, request, location)

    allowed_children = []
    for item in items:
        ac = get_children(item, request, location)
        allowed_children.append(ac if ac else [])

    return {
        'location': location,
        'items': items,
        'display_type': display_type,
        'nav_class': nav_class,
        'use_container_class': use_container_class,
        'show_menu': show_menu,
        'allowed_children': allowed_children,
        'label': label,
        'show_item_dropdowns': dropdowns,
    }
Ejemplo n.º 13
0
def navigation_widget_tree(context, request, name=''):
    """Views for display type "tree", continued:
      - These are the main views for the tree display type, each using the
        general navigation_widget_tree() view function.
      - The nav recurse view above is called from nav_widget_tree.pt,
        used in each of these.
    """
    # Assume top location, unless name or request.path are available.
    location = 'top'

    if name:
        location = name[name.rfind('-') + 1:]
    elif 'navigation-widget' in request.path:
        location = location_from_path(request.path)

    resource_group.need()

    root = get_root()

    settings = navigation_settings()

    # Set defaults:
    display_type = 'ver_tabs_stacked'
    include_root = False
    show_menu = False
    label = ''

    display_type_key = '{0}_display_type'.format(location)

    if display_type_key in settings:
        display_type = settings[display_type_key]

    include_root_key = '{0}_include_root'.format(location)
    if include_root_key in settings:
        include_root = asbool(settings[include_root_key])

    show_menu_key = '{0}_show_menu'.format(location)
    if show_menu_key in settings:
        show_menu = asbool(settings[show_menu_key])

    label_key = '{0}_label'.format(location)
    if label_key in settings:
        label = parse_label(context.title, settings[label_key])

    # When the nav display is set to the beforebodyend slot, the class for the
    # containing div needs to be 'container' so it fits to the middle span12
    # area for content. When nav is in any of the other slots, no class is
    # needed, because the inherited CSS works to fit nav to the slot.
    use_container_class = True if location == 'beforebodyend' else False

    items = get_children(root, request, location)

    tabs_or_pills = 'tabs' if 'tabs' in display_type else 'pills'
    nav_class = 'nav nav-{0} nav-stacked'.format(tabs_or_pills)
    tree_is_open_all = True if display_type.endswith('open_all') else False

    return {'location': location,
            'root': root,
            'display_type': display_type,
            'include_root': include_root,
            'show_menu': show_menu,
            'nav_class': nav_class,
            'tree_is_open_all': tree_is_open_all,
            'is_node_open': is_node_open,
            'use_container_class': use_container_class,
            'items': items,
            'label': label}
Ejemplo n.º 14
0
def navigation_widget(context, request, name=''):

    resource_group.need()

    settings = navigation_settings()

    root = get_root()

    top_level_items = []

    include_root = asbool(settings['include_root'])
    display_type = settings['display_type']
    slot = settings['slot']
    show_context_menu = asbool(settings['show_context_menu'])
    show_dropdown_menus = asbool(settings['show_dropdown_menus'])
    label = settings['label']

    before_context = ''
    after_context = ''

    if display_type == 'tree':
        items = get_children(root, request)
    else:
        top_level_items = get_children(root, request)
        items = get_children(context, request)

    if label:
        label_lower = label.lower()

        if label_lower == 'context':
            label = context.title
        elif ('context' in label
              or 'Context' in label
              or 'CONTEXT' in label):
            before_context, after_context = split_label_on_context(label)
            label = before_context + context.title + after_context

    # When the nav display is set to the beforebodyend slot, the class for the
    # containing div needs to be 'container' so it fits to the middle span12
    # area for content. When nav is in any of the other slots, no class is
    # needed, because the inherited CSS works to fit nav to the slot.
    use_container_class = True if slot == 'beforebodyend' else False

    allowed_children = []
    for item in items:
        ac = get_children(item, request)
        allowed_children.append(ac if ac else [])

    # The lineage function of pyramid is used to make a breadcrumbs-style
    # display for the context menu.
    lineage_items = get_lineage(context, request)
    if not include_root:
        lineage_items.remove(root)

    # The lineage comes back in root-last order, so reverse.
    lineage_items.reverse()

    # The lineage (breadcrumbs style) display in navigation.pt shows
    # lineage_items in an indented dropdown list, and below that has a li
    # repeat on items, indented beneath context.

    return {'root': root,
            'slot': slot,
            'use_container_class': use_container_class,
            'include_root': include_root,
            'display_type': display_type,
            'items': items,
            'show_context_menu': show_context_menu,
            'top_level_items': top_level_items,
            'lineage_items': lineage_items,
            'allowed_children': allowed_children,
            'label': label,
            'show_dropdown_menus': show_dropdown_menus,
        }