Exemple #1
0
 def handle(self, req):
     req.wmi = False # Will be set to True by `WikingManagementInterface' if needed.
     preview_mode_param = req.param(self._PREVIEW_MODE_PARAM)
     if preview_mode_param is not None:
         req.set_cookie(self._PREVIEW_MODE_COOKIE, preview_mode_param == '1' and '1' or None)
     wiking.module.CachedTables.reload_info(req)
     wiking.module.Config.configure(req)
     modname = self._resolve_modname(req)
     if modname:
         return req.forward(wiking.module(modname))
     else:
         try:
             return super(Application, self).handle(req)
         except wiking.Forbidden:
             # The parent method raises Forbidden when there are no menu items to redirect to.
             if req.check_roles(Roles.CONTENT_ADMIN):
                 # Give the administrator some hints on a fresh install.
                 if wiking.module.Pages.empty(req):
                     return wiking.Document(
                         title=_("Welcome to Wiking CMS"),
                         content=lcg.Container((lcg.p("There are currently no pages."),
                                                lcg.p(lcg.link("/?action=insert",
                                                               _("Create a new page"))))),
                     )
                 elif not self.preview_mode(req):
                     req.message(_("There are no published pages. "
                                   "You need to switch to the Preview mode "
                                   "to be able to access the unpublished pages."),
                                 req.WARNING)
             raise
Exemple #2
0
 def handle(self, req):
     req.wmi = False  # Will be set to True by `WikingManagementInterface' if needed.
     preview_mode_param = req.param(self._PREVIEW_MODE_PARAM)
     if preview_mode_param is not None:
         req.set_cookie(self._PREVIEW_MODE_COOKIE, preview_mode_param == '1' and '1' or None)
     wiking.module.CachedTables.reload_info(req)
     wiking.module.Config.configure(req)
     modname = self._resolve_modname(req)
     if modname:
         return req.forward(wiking.module(modname))
     else:
         try:
             return super(Application, self).handle(req)
         except wiking.Forbidden:
             # The parent method raises Forbidden when there are no menu items to redirect to.
             if req.check_roles(Roles.CONTENT_ADMIN):
                 # Give the administrator some hints on a fresh install.
                 if wiking.module.Pages.empty(req):
                     return wiking.Document(
                         title=_("Welcome to Wiking CMS"),
                         content=lcg.Container((lcg.p("There are currently no pages."),
                                                lcg.p(lcg.link("/?action=insert",
                                                               _("Create a new page"))))),
                     )
                 elif not self.preview_mode(req):
                     req.message(_("There are no published pages. "
                                   "You need to switch to the Preview mode "
                                   "to be able to access the unpublished pages."),
                                 req.WARNING)
             raise
Exemple #3
0
 def _result_item(self, item):
     sample = item.sample()
     link = lcg.link(item.uri(), label=item.title(), descr=sample,)
     if sample is None:
         result_item = lcg.p((link,))
     else:
         result_item = lcg.dl(((link, sample),))
     return result_item
Exemple #4
0
    def bottom_bar_right_content(self, req):
        """Return the content displayed on the right side of the bottom bar above the page footer.

        Any content acceptable by 'lcg.coerce()' may be returned.

        """
        return lcg.join((lcg.link('/privacy-policy', _("Privacy policy")),
                         self._accessibility_statement_link(req)), separator=' \u2022 ')
Exemple #5
0
    def footer_content(self, req):
        """Return the content displayed in page footer as 'lcg.Content' element(s).

        Any content acceptable by 'lcg.coerce()' may be returned.

        """
        return lcg.p(_("Contact:"), ' ',
                     lcg.link("mailto:" + wiking.cfg.webmaster_address,
                              wiking.cfg.webmaster_address))
Exemple #6
0
 def spec_link(spec_name, title=None):
     if title is None:
         try:
             view_spec = resolver.get(spec_name, 'view_spec')
         except pytis.util.ResolverError as e:
             title = spec_name
         else:
             title = view_spec.title()
     return lcg.link('help:spec/%s' % spec_name, title)
Exemple #7
0
    def footer_content(self, req):
        """Return the content displayed in page footer as 'lcg.Content' element(s).

        Any content acceptable by 'lcg.coerce()' may be returned.

        """
        return lcg.p(_("Contact:"), ' ',
                     lcg.link("mailto:" + wiking.cfg.webmaster_address,
                              wiking.cfg.webmaster_address))
Exemple #8
0
 def _result_item(self, item):
     sample = item.sample()
     link = lcg.link(
         item.uri(),
         label=item.title(),
         descr=sample,
     )
     if sample is None:
         result_item = lcg.p((link, ))
     else:
         result_item = lcg.dl(((link, sample), ))
     return result_item
Exemple #9
0
 def handle(self, req):
     req.wmi = False # Will be set to True by `WikingManagementInterface' if needed.
     preview_mode_param = req.param(self._PREVIEW_MODE_PARAM)
     if preview_mode_param is not None:
         req.set_cookie(self._PREVIEW_MODE_COOKIE, preview_mode_param == '1' and '1' or None)
     wiking.module.CachedTables.reload_info(req)
     wiking.module.Config.configure(req)
     if req.unresolved_path:
         try:
             modname = self._mapping[req.unresolved_path[0]]
         except KeyError:
             modname = 'Pages'
         else:
             # Consume the unresolved path if it was in static mapping or
             # leave it for further resolution when passing to Pages.
             del req.unresolved_path[0]
     elif req.param('action'):
         if req.param('_manage_cms_panels') == '1':
             modname = 'Panels'
         else:
             modname = 'Pages'
     else:
         try:
             return super(Application, self).handle(req)
         except wiking.Forbidden:
             # The parent method raises Forbidden when there are no menu items to redirect to.
             if req.check_roles(Roles.CONTENT_ADMIN):
                 # Give the administrator some hints on a fresh install.
                 if wiking.module.Pages.empty(req):
                     raise wiking.Abort(_("Welcome to Wiking CMS"),
                                        lcg.Container((lcg.p("There are currently no pages."),
                                                       lcg.p(lcg.link("/?action=insert",
                                                                      _("Create a new page"))))))
                 elif not self.preview_mode(req):
                     req.message(_("There are no published pages. "
                                   "You need to switch to the Preview mode "
                                   "to be able to access the unpublished pages."),
                                 req.WARNING)
             raise
     return req.forward(wiking.module(modname))
Exemple #10
0
    def _content(self, lang):
        import wiking
        import wiking.cms

        def descr(option):
            content = [lcg.em(option.description())]
            doc = option.documentation()
            if doc:
                content.append(lcg.p(doc))
            content.append(lcg.p("*Default value:*", formatted=True))
            content.append(lcg.PreformattedText(option.default_string()))
            return content

        import lcg
        # Initial text is taken from configuration module docstring.
        intro = lcg.Parser().parse(lcg.unindent_docstring(wiking.cfg.__doc__))
        # Construct sections according to module and subsections with the config options
        sections = [
            lcg.Section(title=title,
                        content=[
                            lcg.Section(title="Option '%s'" % o.name(),
                                        id=o.name(),
                                        descr=o.description(),
                                        content=descr(o))
                            for o in cfg.options(sort=True) if o.visible()
                        ])
            for title, cfg in (("Wiking Configuration Options", wiking.cfg),
                               ("Wiking CMS Configuration Options",
                                wiking.cms.cfg))
        ]
        overview = [
            lcg.Section(title=section.title() + " Overview",
                        content=lcg.ul(
                            lcg.coerce((lcg.link(s, s.id()), ": ", s.descr()))
                            for s in section.sections()))
            for section in sections
        ]
        return dict(content=intro + overview + sections)
Exemple #11
0
 def _breadcrumbs(self, context):
     links = [lcg.link(n).export(context) for n in context.node().path()[1:]]
     # Translators: A label followed by location information in webpage navigation
     return _("You are here:") + ' ' + lcg.concat(links, separator=' / ')
Exemple #12
0
 def _breadcrumbs(self, context):
     links = [lcg.link(n).export(context) for n in context.node().path()[1:]]
     # Translators: A label followed by location information in webpage navigation
     return _("You are here:") + ' ' + lcg.concat(links, separator=' / ')
Exemple #13
0
 def _powered_by_wiking(self, req):
     import wiking
     # Translators: Website idiom. This is followed by information on the underlying software
     # tools.  Means: This website runs on [...this and that software...].
     return (_("Powered by"), ' ',
             lcg.link('http://www.freebsoft.org/wiking', 'Wiking'), ' ', wiking.__version__)
Exemple #14
0
 def _powered_by_wiking(self, req):
     import wiking
     # Translators: Website idiom. This is followed by information on the underlying software
     # tools.  Means: This website runs on [...this and that software...].
     return (_("Powered by"), ' ',
             lcg.link('http://www.freebsoft.org/wiking', 'Wiking'), ' ', wiking.__version__)