Web Resources for XWiki

Version 3.1 by Vincent Massol on 2020/04/03 12:03

cogWeb Resources for the XWiki platform
TypeOther
CategoryOther
Developed by

XWiki Development Team

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Enterprise

Description

Provides the default web resources for the XWiki platform WAR:

  • Templates files (Velocity template files). A Template (vm file) defines a visual layout that should be used when rendering a URL (the template called depends on the Action defined in the URL: view, etc, see the URL Architecture for more).
  • JavaScript files. See Frontend Resources for more.
  • CSS files
  • Icons

Velocity Macros

The following Velocity Macros can be found in the macros.vm template file:

#verticalNavigation

  • Definition:
    #**
     * Generates a vertical menu from an object describing the categories
     *
     * Expected format of the object:
     * menu = vector of items
     * item = map with the following fields:
     *        'id'       : mandatory
     *        'name'     : the text displayed for the corresponding menu item;
     *                     optional, defaults to
     *                     $services.localization.render("$!{translationPrefix}${item.id}")
     *        'url'      : the "action" of the menu item; optional, defaults to #
     *        'cssClass' : a specific css class for the menu item for custom
     *                     styling; optional, defaults to ''
     *        'children' : vector of items, allowing to recursively define submenus
     *
     * @param $menu the menu object, in the format described above
     * @param $options a map of options, where the following entries are currently used:
     *        'translationPrefix' :  the translation prefix added to the id of each
     *                     item, in order to generate the name; ignored for items whose
     *                     name is specified
     *        'crtItemId': identifier of the current menu item (for differential styling)
     *        'cssClass' : specific css class for this menu
     *#
    #macro(verticalNavigation $menu $options)

    #**
     * Generates a vertical menu item from an object (a map)
     *
     * Expected format:
     * item = map with the following fields:
     *        'id'       : mandatory
     *        'name'     : the text displayed for the corresponding menu item;
     *                     optional, defaults to
     *                     $services.localization.render("$!{translationPrefix}${item.id}")
     *        'url'      : the "action" of the menu item; optional
     *        'cssClass' : a specific css class for the menu item for custom
     *                     styling; optional, defaults to ''
     *        'children' : vector of items, allowing to recursively define submenus
     *
     * @param $item the menu item object, in the format described above
     * @param $level the current level of the item, of the form '\*+'; the number of
     *        stars indicates the depth of the item in the menu
     * @param $options a map of options, where the following entries are currently used:
     *        'translationPrefix' :  the translation prefix added to the id of each
     *                     item, in order to generate the name; ignored for items whose
     *                     name is specified
     *        'crtItemId': identifier of the current menu item (for differential styling)
     *#
    #macro(verticalNavigationItem $item $level $options)
  • Example:
    {{velocity}}
    #set($adminMenu = [
      {
        'id' : 'lf',
        'icon': 'columns',
        'displayBeforeCategory': 'content',
        'children': [
           {'id' : 'Themes', 'perSpace' : true, 'order' : 100},
           {'id' : 'Panels.PanelWizard', 'perSpace' : true, 'order' : 300},
           {'id' : 'Presentation', 'perSpace' : true, 'order' : 600}
        ]
      },
      {
        'id' : 'usersgroups',
        'icon': 'group',
        'displayBeforeCategory': 'extensionmanager',
        'children': [
           {'id' : 'Users', 'order' : 100},
           {'id' : 'Groups', 'order' : 200},
           {'id' : 'Rights', 'perSpace' : false, 'order' : 300},
           {'id' : 'PageAndChildrenRights', 'perSpace' : true, 'order' : 300, 'global': false},
           {'id' : 'PageRights', 'perSpace' : true, 'order' : 350, 'global': false},
           {'id' : 'UserProfile', 'order' : 400},
           {'id' : 'Registration', 'order' : 500}
        ]
      },
      {
        'id' : 'other',
        'icon': 'wrench',
        'children' : []
      }
    ])

    #verticalNavigation($adminMenu {
      'id': 'administration-menu',
      'cssClass': 'admin-menu'
    })
    {{/velocity}}

    Result:

    verticalNavigation.png

Tags:
    

Get Connected