Exemplo n.º 1
0
 def _gen_wiki_links(self, wiki, label, a_class, url, wiki_page_template,
                     check=None):
     check_sign = None
     if WikiSystem(self.env).has_page(wiki.lstrip('/')):
         a_class += " page"
         title = _("Go to page %s") % wiki
         if check and check[0] == 'link':
             chrome_path = '/'.join([self.ref.req.base_path, 'chrome'])
             ok_img = 'wikicalendar/check_ok.png'
             ok = tag.image(src='/'.join([chrome_path, ok_img]),
                            alt='ok', title='ok')
             nok_img = 'wikicalendar/check_nok.png'
             nok = tag.image(src='/'.join([chrome_path, nok_img]),
                             alt='X', title='X')
             unk_img = 'wikicalendar/check_unknown.png'
             unk = tag.image(src='/'.join([chrome_path, unk_img]),
                             alt='?', title='?')
             result = self._do_check(check[1], wiki)
             check_sign = result and (result == 1 and ok or nok) or unk
     else:
         url += "?action=edit"
         # adding template name, if specified
         if wiki_page_template != "":
             url += "&template=" + wiki_page_template
         title = _("Create page %s") % wiki
     link = tag.a(tag(label), href=url)
     link(class_=a_class, title_=title)
     return tag(link, check_sign)
Exemplo n.º 2
0
 def _wiki_link(self, req, args, kwargs, wiki, label, a_class, check=None):
     """Build links to wiki pages."""
     check_sign = None
     url = self.env.href.wiki(wiki)
     if WikiSystem(self.env).has_page(wiki.lstrip("/")):
         a_class += " page"
         title = _("Go to page %s") % wiki
         if check and check[0] == "link":
             chrome_path = "/".join([req.base_path, "chrome"])
             ok_img = "wikicalendar/check_ok.png"
             ok = tag.image(src="/".join([chrome_path, ok_img]), alt="ok", title="ok")
             nok_img = "wikicalendar/check_nok.png"
             nok = tag.image(src="/".join([chrome_path, nok_img]), alt="X", title="X")
             unk_img = "wikicalendar/check_unknown.png"
             unk = tag.image(src="/".join([chrome_path, unk_img]), alt="?", title="?")
             result = self._do_check(check[1], wiki)
             check_sign = result and (result == 1 and ok or nok) or unk
     else:
         # The default (empty page) is used, if template name is invalid.
         url += "?action=edit"
         # Add page template to create new wiki pages, if specified.
         template = None
         if len(args) >= 6 or kwargs.has_key("base"):
             try:
                 template = kwargs["base"]
             except KeyError:
                 template = args[5]
         if template:
             url += "&template=" + template
         title = _("Create page %s") % wiki
     link = tag.a(tag(label), href=url)
     link(class_=a_class, title_=title)
     return tag(link, check_sign)
Exemplo n.º 3
0
 def _wiki_link(self, req, args, kwargs, wiki, label, a_class, check=None):
     """Build links to wiki pages."""
     check_sign = None
     url = self.env.href.wiki(wiki)
     if WikiSystem(self.env).has_page(wiki.lstrip('/')):
         a_class += " page"
         title = _("Go to page %s") % wiki
         if check and check[0] == 'link':
             chrome_path = '/'.join([req.base_path, 'chrome'])
             ok_img = 'wikicalendar/check_ok.png'
             ok = tag.image(src='/'.join([chrome_path, ok_img]),
                            alt='ok',
                            title='ok')
             nok_img = 'wikicalendar/check_nok.png'
             nok = tag.image(src='/'.join([chrome_path, nok_img]),
                             alt='X',
                             title='X')
             unk_img = 'wikicalendar/check_unknown.png'
             unk = tag.image(src='/'.join([chrome_path, unk_img]),
                             alt='?',
                             title='?')
             result = self._do_check(check[1], wiki)
             check_sign = result and (result == 1 and ok or nok) or unk
     else:
         # The default (empty page) is used, if template name is invalid.
         url += "?action=edit"
         # Add page template to create new wiki pages, if specified.
         template = None
         if len(args) >= 6 or kwargs.has_key('base'):
             try:
                 template = kwargs['base']
             except KeyError:
                 template = args[5]
         if template:
             url += "&template=" + template
         title = _("Create page %s") % wiki
     link = tag.a(tag(label), href=url)
     link(class_=a_class, title_=title)
     return tag(link, check_sign)
Exemplo n.º 4
0
 def _gen_wiki_links(self,
                     wiki,
                     label,
                     a_class,
                     url,
                     wiki_page_template,
                     check=None):
     check_sign = None
     if WikiSystem(self.env).has_page(wiki.lstrip('/')):
         a_class += " page"
         title = _("Go to page %s") % wiki
         if check and check[0] == 'link':
             chrome_path = '/'.join([self.ref.req.base_path, 'chrome'])
             ok_img = 'wikicalendar/check_ok.png'
             ok = tag.image(src='/'.join([chrome_path, ok_img]),
                            alt='ok',
                            title='ok')
             nok_img = 'wikicalendar/check_nok.png'
             nok = tag.image(src='/'.join([chrome_path, nok_img]),
                             alt='X',
                             title='X')
             unk_img = 'wikicalendar/check_unknown.png'
             unk = tag.image(src='/'.join([chrome_path, unk_img]),
                             alt='?',
                             title='?')
             result = self._do_check(check[1], wiki)
             check_sign = result and (result == 1 and ok or nok) or unk
     else:
         url += "?action=edit"
         # adding template name, if specified
         if wiki_page_template != "":
             url += "&template=" + wiki_page_template
         title = _("Create page %s") % wiki
     link = tag.a(tag(label), href=url)
     link(class_=a_class, title_=title)
     return tag(link, check_sign)
Exemplo n.º 5
0
    def __init__(self):
        # bind 'wikicalendar' catalog to the specified locale directory
        locale_dir = resource_filename(__name__, 'locale')
        add_domain(self.env.path, locale_dir)

        # Parse 'wikicalendar' configuration section for test instructions.
        # Valid options are written as check.<item>.<test name>, where item
        # is optional.  The value must be a SQL query with arguments depending
        # on the item it applies to.
        self.checks = {}
        conf_section = self.config['wikicalendar']
        for key, sql in conf_section.options():
            if key.startswith('check.'):
                check_type = key.split('.')
                if len(check_type) in range(2,4):
                    self.checks[check_type[-1]] = {'test': sql}
                    if len(check_type) == 3:
                        # We've got test type information too.
                        self.checks[check_type[-1]]['type'] = check_type[1]

        # Options in 'wikicalendar' configuration section take precedence over
        # those in old 'wikiticketcalendar' section.
        c = self.config
        if 'wikicalendar' in c.sections():
            # Rewrite option name for easier plugin upgrade.
            if c.has_option('wikicalendar', 'ticket.due_field.name'):
                self.env.log.debug('Old wikiticketcalendar option found.')
                c.set('wikicalendar', 'ticket.due_field',
                      c.get('wikicalendar', 'ticket.due_field.name'))
                c.remove('wikicalendar', 'ticket.due_field.name')
                c.save()
                self.env.log.debug('Updated to new option: ticket.due_field')

            self.tkt_due_field = self.ticket_due
            self.tkt_due_format = self.ticket_due_fmt
        else:
            self.tkt_due_field = self.due_field_name
            self.tkt_due_format = self.due_field_fmt

        # Read options from Trac configuration system, adjustable in trac.ini.
        #  [wiki] section
        self.sanitize = True
        if self.config.getbool('wiki', 'render_unsafe_content') is True:
            self.sanitize = False

        # TRANSLATOR: Keep macro doc style formatting here, please.
        self.doc_calendar = _(
    """Inserts a small calendar where each day links to a wiki page whose name
    matches `wiki-page-format`. The current day is highlighted, and days with
    Milestones are marked in bold. This version makes heavy use of CSS for
    formatting.
    
    Usage:
    {{{
    [[WikiCalendar([year, [month, [show-buttons, [wiki-page-format]]]])]]
    }}}
    
    Arguments:
     1. `year` (4-digit year) - defaults to `*` (current year)
     1. `month` (2-digit month) - defaults to `*` (current month)
     1. `show-buttons` (boolean) - defaults to `true`
     1. `wiki-page-format` (string) - defaults to `%Y-%m-%d`
    
    Examples:
    {{{
    [[WikiCalendar(2006,07)]]
    [[WikiCalendar(2006,07,false)]]
    [[WikiCalendar(*,*,true,Meeting-%Y-%m-%d)]]
    [[WikiCalendar(2006,07,false,Meeting-%Y-%m-%d)]]
    }}}
    """)
        self.doc_ticketcalendar = _(
    """Display Milestones and Tickets in a calendar view.

    displays a calendar, the days link to:
     - milestones (day in bold) if there is one on that day
     - a wiki page that has wiki_page_format (if exist)
     - create that wiki page if it does not exist
     - use page template (if exist) for new wiki page
    """)
Exemplo n.º 6
0
    def __init__(self):
        # bind 'wikicalendar' catalog to the specified locale directory
        locale_dir = resource_filename(__name__, 'locale')
        add_domain(self.env.path, locale_dir)

        # Parse 'wikicalendar' configuration section for test instructions.
        # Valid options are written as check.<item>.<test name>, where item
        # is optional.  The value must be a SQL query with arguments depending
        # on the item it applies to.
        self.checks = {}
        conf_section = self.config['wikicalendar']
        for key, sql in conf_section.options():
            if key.startswith('check.'):
                check_type = key.split('.')
                if len(check_type) in range(2, 4):
                    self.checks[check_type[-1]] = {'test': sql}
                    if len(check_type) == 3:
                        # We've got test type information too.
                        self.checks[check_type[-1]]['type'] = check_type[1]

        # Options in 'wikicalendar' configuration section take precedence over
        # those in old 'wikiticketcalendar' section.
        c = self.config
        if 'wikicalendar' in c.sections():
            # Rewrite option name for easier plugin upgrade.
            if c.has_option('wikicalendar', 'ticket.due_field.name'):
                self.env.log.debug('Old wikiticketcalendar option found.')
                c.set('wikicalendar', 'ticket.due_field',
                      c.get('wikicalendar', 'ticket.due_field.name'))
                c.remove('wikicalendar', 'ticket.due_field.name')
                c.save()
                self.env.log.debug('Updated to new option: ticket.due_field')

            self.tkt_due_field = self.ticket_due
            self.tkt_due_format = self.ticket_due_fmt
        else:
            self.tkt_due_field = self.due_field_name
            self.tkt_due_format = self.due_field_fmt

        # Read options from Trac configuration system, adjustable in trac.ini.
        #  [wiki] section
        self.sanitize = True
        if self.config.getbool('wiki', 'render_unsafe_content') is True:
            self.sanitize = False

        # TRANSLATOR: Keep macro doc style formatting here, please.
        self.doc_calendar = _(
            """Inserts a small calendar where each day links to a wiki page whose name
    matches `wiki-page-format`. The current day is highlighted, and days with
    Milestones are marked in bold. This version makes heavy use of CSS for
    formatting.
    
    Usage:
    {{{
    [[WikiCalendar([year, [month, [show-buttons, [wiki-page-format]]]])]]
    }}}
    
    Arguments:
     1. `year` (4-digit year) - defaults to `*` (current year)
     1. `month` (2-digit month) - defaults to `*` (current month)
     1. `show-buttons` (boolean) - defaults to `true`
     1. `wiki-page-format` (string) - defaults to `%Y-%m-%d`
    
    Examples:
    {{{
    [[WikiCalendar(2006,07)]]
    [[WikiCalendar(2006,07,false)]]
    [[WikiCalendar(*,*,true,Meeting-%Y-%m-%d)]]
    [[WikiCalendar(2006,07,false,Meeting-%Y-%m-%d)]]
    }}}
    """)
        self.doc_ticketcalendar = _(
            """Display Milestones and Tickets in a calendar view.

    displays a calendar, the days link to:
     - milestones (day in bold) if there is one on that day
     - a wiki page that has wiki_page_format (if exist)
     - create that wiki page if it does not exist
     - use page template (if exist) for new wiki page
    """)