Exemple #1
0
    def goto(self, title):
        page = PageData.get_by(pagename=title)
        if page is None:
            log.info('New wiki page: [%s]' % title)
            PageData(pagename=title, data=u'')

        self.content.becomes(Page(title))
Exemple #2
0
    def goto(self, title):
        """Navigate to an other page

        In:
          - ``title`` -- title of the new page to display
        """
        # Retrieve the new page data from the database
        page = PageData.get_by(pagename=title)
        if page is None:
            # The new page doesn't exist, create it in database
            PageData(pagename=title, data=u'')

        # Permanently replace, into the component graph, the currently
        # displayed page by the new one
        self.content.becomes(Page(title))
Exemple #3
0
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content
Exemple #4
0
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content
Exemple #5
0
    def goto(self, title):
        page = PageData.get_by(pagename=title)
        if page is None:
            log.info('New wiki page: [%s]' % title)
            PageData(pagename=title, data=u'')

        self.content.becomes(Page(title))
Exemple #6
0
def init(self, url, *args):
    title = url[1]

    page = PageData.get_by(pagename=title)
    if page is None:
        raise presentation.HTTPNotFound()

    self.goto(title)
Exemple #7
0
def init(self, url, *args):
    title = url[1]

    page = PageData.get_by(pagename=title)
    if page is None:
        raise presentation.HTTPNotFound()

    self.goto(title)
Exemple #8
0
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            # Our security policy : a user needs to have the ``wiki.editor`` permission
            # to be able to modify the content of a page
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content
Exemple #9
0
    def _(self, user, perm, subject):
        if user.has_permission('wiki.admin'):
            return True

        creator = PageData.get_by(pagename=subject.title).creator
        if user.has_permission(perm) and (perm != 'wiki.editor' or (creator is None) or (creator == user.id)):
            return True

        return common.Denial()
Exemple #10
0
    def _(self, user, perm, subject):
        if user.has_permission('wiki.admin'):
            return True

        creator = PageData.get_by(pagename=subject.title).creator
        if user.has_permission(perm) and (perm != 'wiki.editor' or (creator is None) or (creator == user.id)):
            return True

        return common.Denial()
Exemple #11
0
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            # Our security policy : a user needs to have the ``wiki.editor`` permission
            # to be able to modify the content of a page
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content
Exemple #12
0
def render(self, h, comp, *args):
    page = PageData.get_by(pagename=self.title)

    with h.div:
        h << h.pre(page.data)

        # This link is added to every page displayed, to be able to edit it
        h << h.a("Edit this page").action(self.edit, comp)

    return h.root
Exemple #13
0
def render(self, h, comp, *args):
    h << h.span('Viewing ') << h.b(self.title) << h.br

    page = PageData.get_by(pagename=self.title)
    if page.creator:
        h << h.i('Created by ', page.creator) << h.br

    h << 'You can return to the ' << h.a('FrontPage', href='page/FrontPage')

    return h.root
Exemple #14
0
def render(self, h, comp, *args):
    h << h.span('Viewing ') << h.b(self.title) << h.br

    page = PageData.get_by(pagename=self.title)
    if page.creator:
        h << h.i('Created by ', page.creator) << h.br

    h << 'You can return to the ' << h.a('FrontPage', href='page/FrontPage')

    return h.root
Exemple #15
0
def render(self, h, comp, *args):
    page = PageData.get_by(pagename=self.title)

    with h.div:
        h << h.pre(page.data)

        # This link is added to every page displayed, to be able to edit it
        h << h.a('Edit this page').action(self.edit, comp)

    return h.root
Exemple #16
0
def render(self, h, comp, *args):
    page = PageData.get_by(pagename=self.title)

    content = docutils.core.publish_parts(page.data, writer_name='html')['html_body']
    content = wikiwords.sub(r'<wiki>\1</wiki>', content)
    html = h.parse_htmlstring(content, fragment=True)[0]

    for node in html.getiterator():
        if node.tag == 'wiki':
            a = h.a(node.text, href='page/' + node.text).action(comp.answer, unicode(node.text))
            node.replace(a)

    return (html, h.a('Edit this page', href='page/' + self.title).action(self.edit, comp))
Exemple #17
0
def init(self, url, *args):
    # Retrieve the page title. The condition of this generic
    # method already checks that the URL is of the form:
    # '.../page/<page title>'
    title = url[1]

    # Check if a page with the wanted title exists
    page = PageData.get_by(pagename=title)
    if page is None:
        raise presentation.HTTPNotFound()

    # Go to the page
    self.goto(title)
Exemple #18
0
def render(self, h, comp, *args):
    page = PageData.get_by(pagename=self.title)

    content = docutils.core.publish_parts(page.data, writer_name='html')['html_body']
    content = wikiwords.sub(r'<wiki>\1</wiki>', content)
    html = h.parse_htmlstring(content, fragment=True)[0]

    for node in html.getiterator():
        if node.tag == 'wiki':
            a = h.a(node.text, href='page/' + node.text).action(comp.answer, unicode(node.text))
            node.replace(a)

    return (html, h.a('Edit this page', href='page/' + self.title).action(self.edit, comp))
Exemple #19
0
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            log.info('New content for page [%s]: [%s...]' % (self.title, content[:50]))
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content

            # If the creator of the page is not already set, set it with the
            # current user
            if page.creator is None:
                page.creator = security.get_user().id
                log.debug('New creator for page [%s]: [%s]' % (page.pagename, page.creator))
Exemple #20
0
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            log.info('New content for page [%s]: [%s...]' % (self.title, content[:50]))
            security.check_permissions('wiki.editor', self)
            page = PageData.get_by(pagename=self.title)
            page.data = content

            # If the creator of the page is not already set, set it with the
            # current user
            if page.creator is None:
                page.creator = security.get_user().id
                log.debug('New creator for page [%s]: [%s]' % (page.pagename, page.creator))
Exemple #21
0
def render(self, h, comp, *args):
    content = var.Var()

    page = PageData.get_by(pagename=self.page.title)

    with h.form:
        with h.textarea(rows='10', cols='40').action(content):
            h << page.data
        h << h.br
        h << h.input(type='submit', value='Save').action(self.answer, comp, content)
        h << ' '
        h << h.input(type='submit', value='Cancel').action(comp.answer)

    return h.root
Exemple #22
0
def render(self, h, comp, *args):
    content = var.Var()

    page = PageData.get_by(pagename=self.page.title)

    with h.form:
        with h.textarea(rows='10', cols='40').action(content):
            h << page.data
        h << h.br
        h << h.input(type='submit', value='Save').action(self.answer, comp, content)
        h << ' '
        h << h.input(type='submit', value='Cancel').action(comp.answer)

    return h.root
Exemple #23
0
    def goto(self, title):
        """Navigate to an other page

        In:
          - ``title`` -- title of the new page to display
        """
        # Retrieve the new page data from the database
        page = PageData.get_by(pagename=title)
        if page is None:
            # The new page doesn't exist, create it in database
            PageData(pagename=title, data=u'')

        # Permanently replace, into the component graph, the currently
        # displayed page by the new one
        self.content.becomes(Page(title))
Exemple #24
0
def render(self, h, comp, *args):
    content = var.Var()  # Local functional variable that will keep the new page content

    # Retrieve the database object
    page = PageData.get_by(pagename=self.page.title)

    with h.form:
        with h.textarea(rows="10", cols="40").action(content):  # Calling ``content`` with a value set its
            h << page.data
        h << h.br
        # Clicking on 'Save', will answer the new content
        h << h.input(type="submit", value="Save").action(self.answer, comp, content)
        h << " "
        # Clicking on 'Cancel', will answer ``None``
        h << h.input(type="submit", value="Cancel").action(comp.answer)

    return h.root
Exemple #25
0
def render(self, h, comp, *args):
    content = var.Var(
    )  # Local functional variable that will keep the new page content

    # Retrieve the database object
    page = PageData.get_by(pagename=self.page.title)

    with h.form:
        with h.textarea(rows='10', cols='40').action(
                content):  # Calling ``content`` with a value set its
            h << page.data
        h << h.br
        # Clicking on 'Save', will answer the new content
        h << h.input(type='submit', value='Save').action(
            self.answer, comp, content)
        h << ' '
        # Clicking on 'Cancel', will answer ``None``
        h << h.input(type='submit', value='Cancel').action(comp.answer)

    return h.root
Exemple #26
0
def render(self, h, comp, *args):
    page = PageData.get_by(pagename=self.title)

    # Translate the content in ``page.data`` to HTML
    content = docutils.core.publish_parts(page.data, writer_name='html')['html_body']

    # For each WikiWords found, create a pseudo tag '<wiki>WikiWord</<wiki>'
    content = wikiwords.sub(r'<wiki>\1</wiki>', content)

    # Parse the HTML into a elements tree
    html = h.parse_htmlstring(content, fragment=True)[0]

    # Found the '<wiki>' elements into the tree and transform them into active links
    for node in html.getiterator():
        if node.tag == 'wiki':
            # Clicking on a WikiWord will answer the WikiWord unicode string
            a = h.a(node.text).action(comp.answer, unicode(node.text))
            # Replace the node
            node.replace(a)

    return (html, h.a('Edit this page').action(self.edit, comp))
Exemple #27
0
def render(self, h, comp, *args):
    page = PageData.get_by(pagename=self.title)

    # Translate the content in ``page.data`` to HTML
    content = docutils.core.publish_parts(page.data, writer_name='html')['html_body']

    # For each WikiWords found, create a pseudo tag '<wiki>WikiWord</<wiki>'
    content = wikiwords.sub(r'<wiki>\1</wiki>', content)

    # Parse the HTML into a elements tree
    html = h.parse_htmlstring(content, fragment=True)[0]

    # Found the '<wiki>' elements into the tree and transform them into active links
    for node in html.getiterator():
        if node.tag == 'wiki':
            # Clicking on a WikiWord will answer the WikiWord unicode string
            a = h.a(node.text).action(comp.answer, unicode(node.text))
            # Replace the node
            node.replace(a)

    return (html, h.a('Edit this page').action(self.edit, comp))
Exemple #28
0
    def edit(self, comp):
        """Edit the content of this page:

           1. a page editor is created
           2. the page editor temporary replace the page in the component graph
           3. it will return (and restore the page) with the new content of the
              page

        In:
          - ``comp`` -- this component
        """
        # A ``PageEditor`` object is created for ``self``
        # It temporary replaces the current component (the page displayed)
        content = comp.call(PageEditor(self))

        # ``content`` is the new content for the page
        # or ``None`` if the user canceled the modification
        if content is not None:
            # Retrieve the database object
            page = PageData.get_by(pagename=self.title)
            # Change the content
            page.data = content
Exemple #29
0
    def edit(self, comp):
        """Edit the content of this page:

           1. a page editor is created
           2. the page editor temporary replace the page in the component graph
           3. it will return (and restore the page) with the new content of the
              page

        In:
          - ``comp`` -- this component
        """
        # A ``PageEditor`` object is created for ``self``
        # It temporary replaces the current component (the page displayed)
        content = comp.call(PageEditor(self))

        # ``content`` is the new content for the page
        # or ``None`` if the user canceled the modification
        if content is not None:
            # Retrieve the database object
            page = PageData.get_by(pagename=self.title)
            # Change the content
            page.data = content
Exemple #30
0
def render(self, h, comp, *args):
    page = PageData.get_by(pagename=self.title)

    content = docutils.core.publish_parts(page.data,
                                          writer_name='html')['html_body']
    content = wikiwords.sub(r'<wiki>\1</wiki>', content)
    html = h.parse_htmlstring(content, fragment=True)[0]

    for node in html.getiterator():
        if node.tag == 'wiki':
            a = h.a(node.text,
                    href='page/' + node.text).action(comp.answer,
                                                     unicode(node.text))
            node.replace(a)

    h << html

    # We check the user has the ``wiki.editor`` permission on this page
    # to display the "edit" link
    if security.has_permissions('wiki.editor', self):
        h << h.a('Edit this page', href='page/' + self.title).action(
            self.edit, comp)

    return h.root
Exemple #31
0
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            page = PageData.get_by(pagename=self.title)
            page.data = content
Exemple #32
0
    def edit(self, comp):
        content = comp.call(PageEditor(self))

        if content is not None:
            page = PageData.get_by(pagename=self.title)
            page.data = content
Exemple #33
0
    def goto(self, title):
        page = PageData.get_by(pagename=title)
        if page is None:
            PageData(pagename=title, data=u'')

        self.content.becomes(Page(title))
Exemple #34
0
    def goto(self, title):
        page = PageData.get_by(pagename=title)
        if page is None:
            PageData(pagename=title, data=u'')

        self.content.becomes(Page(title))