Exemplo n.º 1
0
        returns their average.  But if there have been no votes, returns a
        default rating of 1. This is so we can represent negative ratings
        with a standard simple five-star graphic. (New pages have 1 star,
        no stars means a bad page.)
        """
        if self.hasVotes():
            return float(sum(map(int,self.votes().values())))/self.voteCount()
        else:
            return 1

    # UI methods

    security.declareProtected(Permissions.View, 'ratingStyle')
    def ratingStyle(self,rating=''):
        """
        Return the CSS rating class for this page, or for the specified rating.
        """
        if rating == '' or rating == None: rating = self.rating()
        return ['lowrated','neutralrated','highrated'][cmp(rating,0)+1]

    security.declareProtected(Permissions.View, 'styledNumericRating')
    def styledNumericRating(self,rating=''):
        """
        A HTML fragment displaying this page's or the specified rating, styled.
        """
        if rating == '' or rating == None: rating = self.rating()
        return '<span class="%s">(%s)</span>' % (self.ratingStyle(rating),rating)

InitializeClass(PluginRating) 
registerPlugin(PluginRating)
Exemplo n.º 2
0
                'id': p.id,
                'description': self.toencoded(descriptionfunc(pobj)),
                'date': datefunc(pobj).rfc822(),  # be robust here
            }
        t += """\
</channel>
</rss>
"""
        return t

    def title_quote(self, title):
        """
        Quote a string suitable for a title element in an RSS feed.
        We replace only &, > and <
        this is according to RSS specs in
        http://www.rssboard.org/rss-profile#data-types-characterdata
        Nonetheless, http://feedvalidator.org/ claims there is html in 
        those encoded titles.
        """
        title = title.replace('&', '&#x26;', -1)
        title = title.replace('<', '&#x3C;', -1)
        title = title.replace('>', '&#x3E;', -1)
        return title

    # backwards compatibility
    changes_rss = edits_rss


InitializeClass(PageRSSSupport)
registerPlugin(PageRSSSupport)
Exemplo n.º 3
0
        #    t = text
        #    t = re.sub(r'(?im)<table class="fit"',r'<_fittable',t)
        #    t = re.sub(r'(?im)<table',r'<_ordinarytable',t)
        #    t = re.sub(r'(?im)<_fittable',r'<table class="fit"',t)
        #    t = self._runFitInternallyOn(t)
        #    t = re.sub(r'(?im)<_ordinarytable',r'<table',t)
        #    return t

        def runFitTestsIn(self,text):
            """
            Run fit on tables in text.

            Modified fit to test only certain tables (though it parses all).
            """
            return self._runFitInternallyOn(text)

        security.declareProtected(Permissions.View, 'hasFitTests')
        def hasFitTests(self): return hasFitTests(self)


except ImportError:
    BLATHER('did not find fit in the PYTHONPATH, skipping')
    class PluginFit:
        security = ClassSecurityInfo()
        security.declareProtected(Permissions.View, 'hasFitTests')
        def hasFitTests(self): return hasFitTests(self)
        def runFitTestsIn(self,text): return text

InitializeClass(PluginFit)
registerPlugin(PluginFit)
Exemplo n.º 4
0
    security.declareProtected(Permissions.View, 'ratingStyle')
    def ratingStyle(self,rating=''):
        """
        Return the CSS rating class for this page, or for the specified rating.
        """
        if rating == '' or rating == None: rating = self.rating()
        return ['lowrated','neutralrated','highrated'][cmp(rating,0)+1]

    security.declareProtected(Permissions.View, 'styledNumericRating')
    def styledNumericRating(self,rating=''):
        """
        A HTML fragment displaying this page's or the specified rating, styled.
        """
        if rating == '' or rating == None: rating = self.rating()
        return '<span class="%s">(%s)</span>' % (self.ratingStyle(rating),rating)

    security.declarePrivate('ensureVotesIsBtree')
    def ensureVotesIsBtree(self):
        """
        Move from a dictionary to a OOBTree.
        """
        if isinstance(self._votes, DictionaryType):
            temp_dict = self._votes.copy()
            self._votes = OOBTree()
            for k,v in temp_dict.iteritems():
                self._votes[k] = v

InitializeClass(PluginRating) 
registerPlugin(PluginRating)
Exemplo n.º 5
0
        """
        firstpart = lambda s: re.sub(r'[:-].*', '', s)
        return nub(map(firstpart, self.issueCategories()))

    def issueOpenStatuses(self):
        """List those issue statuses which are considered "open" for
        the overview report etc. Looks for an issue_open_statuses
        property, otherwise returns just the first of the issue
        statuses.
        """
        return list(
            getattr(self.folder(), 'issue_open_statuses',
                    self.issueStatuses()[:1]))


InitializeClass(PluginTracker)
registerPlugin(PluginTracker)

# register some upgrade hooks
from Products.ZWiki.Admin import upgrade_hooks, upgradeId_hooks

# install issue properties if missing, eg if this page is being
# viewed as an issue for the first time
addHook(upgrade_hooks, PluginTracker.upgradeIssueProperties)

# convert old-style IssueNNNN ... page names to #NNNN ...
# when checking page id. Leaves non-issue page names unchanged.
addHook(
    upgradeId_hooks, lambda self: self.pageNameFromIssueNumberAndName(
        self.issueNumber(), self.issueName()))
Exemplo n.º 6
0
    def setupTinyMCE(self):
        """
        Setup ZTinyMCE - if installed - with a useful config object.
        """
        if not 'ZTinyMCE' in self.Control_Panel.Products.objectIds():
            return 'ZTinyMCE is not installed.'  # XXX proper page, localize
        folder = self.folder()
        if 'TinyMCE' not in folder.objectIds():
            folder.manage_addProduct['ZTinyMCE'].manage_addZTinyMCE( \
                'TinyMCE', 'WYSIWYG Editor Plugin')
        if 'tinymce.conf' not in folder.objectIds():
            conftext = """mode : "textareas",
theme : "advanced",
plugins : "table,advimage,advlink,emotions,contextmenu,paste,directionality,noneditable",
theme_advanced_buttons2_add : "forecolor,backcolor",
theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_buttons3_add : "emotions,separator,ltr,rtl,separator",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]" """
            folder.manage_addProduct['ZTinyMCE'].manage_addZTinyConfiguration(
                'tinymce.conf',
                conftext,
                optimize=True,
                title='TinyMCE in ZWiki config')


InitializeClass(TinyMCESupport)
registerPlugin(TinyMCESupport)
Exemplo n.º 7
0
            
            existingprops = map(lambda x:x['id'], self._properties)
            for prop, values, default in [
                ['category','issue_categories',None],
                ['severity','issue_severities','normal'],
                ['status','issue_statuses',None],
                ]:
                if not prop in existingprops:
                    self.manage_addProperty(prop,values,'selection')
                    if default: setattr(self,prop,default)
                    changed = 1

        return changed

InitializeClass(PluginTracker)
registerPlugin(PluginTracker)

# register some upgrade hooks
from Products.ZWiki.Admin import upgrade_hooks, upgradeId_hooks

# install issue properties if missing, eg if this page is being
# viewed as an issue for the first time
addHook(upgrade_hooks, PluginTracker.upgradeIssueProperties)

# convert old-style IssueNNNN ... page names to #NNNN ...
# when checking page id. Leaves non-issue page names unchanged.
addHook(upgradeId_hooks,
        lambda self:
        self.pageNameFromIssueNumberAndName(self.issueNumber(),
                                            self.issueName()))