Exemple #1
0
    def mainloop(self):
        # we don't expect non-option arguments
        self.init_request()
        request = self.request
        # Checks for a template page and sets homepage_default_text
        if self.options.template_page and Page(
                self.request, self.options.template_page).exists():
            homepage_default_text = Page(
                self.request, self.options.template_page).get_raw_body()
            # replace is needed because substitution is done for request.user
            # see option --user
            homepage_default_text = homepage_default_text.replace(
                '@ME@', "%(username)s")
            homepage_default_text = homepage_default_text.replace(
                '@EMAIL@', "<<MailTo(%(obfuscated_mail)s)>>")
        else:
            homepage_default_text = '''#acl %(username)s:read,write,delete,revert Default

== %(username)s ==

Email: <<MailTo(%(obfuscated_mail)s)>>
## You can even more obfuscate your email address by adding more uppercase letters followed by a leading and trailing blank.

----
CategoryHomepage
'''
        # Check for user
        if self.options.homepage_creator:
            uid = user.getUserId(request, self.options.homepage_creator)
            request.user = user.User(request, uid)
        # Check for Group definition
        members = []
        if self.options.user_homepage:
            members = [
                self.options.user_homepage,
            ]
        elif self.options.name_of_group_page:
            members = request.groups.get(self.options.name_of_group_page, [])
        elif self.options.all_users:
            uids = user.getUserList(request)
            members = [user.User(request, uid).name for uid in uids]

        if not members:
            print "No user selected!"
            return

        # loop through members for creating homepages
        for name in members:
            uid = user.getUserId(request, name)
            account = user.User(request, uid)
            homepage_text = homepage_default_text % {
                "username": account.name,
                "obfuscated_mail": encodeSpamSafeEmail(account.email)
            }
            self.write_homepage(account, homepage_text)
Exemple #2
0
    def mainloop(self):
        # we don't expect non-option arguments
        self.init_request()
        request = self.request
        # Checks for a template page and sets homepage_default_text
        if self.options.template_page and Page(self.request, self.options.template_page).exists():
            homepage_default_text = Page(self.request, self.options.template_page).get_raw_body()
            # replace is needed because substitution is done for request.user
            # see option --user
            homepage_default_text = homepage_default_text.replace('@ME@', "%(username)s")
            homepage_default_text = homepage_default_text.replace('@EMAIL@', "<<MailTo(%(obfuscated_mail)s)>>")
        else:
            homepage_default_text = '''#acl %(username)s:read,write,delete,revert Default
#format wiki

== %(username)s ==

Email: <<MailTo(%(obfuscated_mail)s)>>
## You can even more obfuscate your email address by adding more uppercase letters followed by a leading and trailing blank.

----
CategoryHomepage
'''
        # Check for user
        if self.options.homepage_creator:
            uid = user.getUserId(request, self.options.homepage_creator)
            request.user = user.User(request, uid)
        # Check for Group definition
        members = []
        if self.options.user_homepage:
            members = [self.options.user_homepage, ]
        elif self.options.name_of_group_page:
            members = request.groups.get(self.options.name_of_group_page, [])
        elif self.options.all_users:
            uids = user.getUserList(request)
            members = [user.User(request, uid).name for uid in uids]

        if not members:
            print "No user selected!"
            return

        # loop through members for creating homepages
        for name in members:
            uid = user.getUserId(request, name)
            account = user.User(request, uid)
            homepage_text = homepage_default_text % {
                                                 "username": account.name,
                                                 "obfuscated_mail": encodeSpamSafeEmail(account.email)
                                                 }
            self.write_homepage(account, homepage_text)
Exemple #3
0
    def handle_variables(self, data, meta):
        """ Expand @VARIABLE@ in data, where variable is SIG, DATE, etc

        TODO: add a means for wiki admins and users to add custom variables.

        @param data: text of wikipage
        @param meta: meta of wikipage
        @rtype: string
        @return: new text of wikipage, variables replaced
        """
        logging.debug("handle_variable data: %r" % data)
        if self.contenttype not in CONTENTTYPE_VARIABLES:
            return data
        if '@' not in data:
            return data
        if not request.path.startswith('/+modify'):
            return data
        if TEMPLATE in meta['tags']:
            return data

        item_name = request.path.split('/', 2)[-1]
        signature = flaskg.user.name0 if flaskg.user.valid else request.remote_addr

        variables = {
            'PAGE': item_name,
            'ITEM': item_name,
            'TIMESTAMP': strftime("%Y-%m-%d %H:%M:%S %Z"),
            'TIME': "<<DateTime(%s)>>" % time(),
            'DATE': "<<Date(%s)>>" % time(),
            'ME': flaskg.user.name0,
            'USERNAME': signature,
            'USER': "******" % signature,
            'SIG': "-- %s <<DateTime(%s)>>" % (signature, time()),
        }

        email = flaskg.user.profile._meta.get('email', None)
        if email:
            obfuscated_email_address = encodeSpamSafeEmail(email)
            variables['MAILTO'] = "<<MailTo({0})>>".format(
                obfuscated_email_address)
            variables['EMAIL'] = "<<MailTo({0})>>".format(email)
        else:
            # penality for not being logged in is a mangled variable, else next user to save item may accidently reveal his email address
            variables['MAILTO'] = "@ EMAIl@"
            variables['EMAIL'] = "@ MAILTO@"

        for name in variables:
            data = data.replace(u'@{0}@'.format(name), variables[name])
        return data
Exemple #4
0
)
for page in pages:
    #  contents = Page(request, page).get_raw_body()

    print Page(request, page).getRevList()
    break
    mails = mail_dir.findall(contents)
    comment = ""
    if contents.find(u"#!python") != -1:
        contents = contents.replace(u"#!python", u"#!code python")
        comment = u"Fix coloreado"

    if mails:
        # print (u"Los mails para %s son: %s" % (page, ', '.join(mails))).encode('UTF-8')
        for mail in mails:
            contents = contents.replace(mail, u"<<MailTo(%s)>>" % sendmail.encodeSpamSafeEmail(mail))
        # print contents.encode('UTF-8')
        if comment:
            comment += u" y direcciones de mail sin Protecció"
        else:
            comment = u"Fix mail(s) sin protección"
    if comment:
        try:
            PageEditor(request, page).saveText(contents, 0, comment=comment)
            print ("%s: %s" % (page, comment)).encode("UTF-8")
        except:
            print "Sin Permisos para %s" % page

    if contents.find(u"mailto:") != -1:
        contents.replace(u"mailto:", "")
        print page.encode("UTF-8"),
 def testEncodeSpamSafeMailAndObfuscate(self):
     """mail.sendmail: encoding mail address by an obfuscate string to spam safe mail """
     for coded, expected in self._tests:
         expected = expected.replace(' AT ', ' AT SYCTE ')
         assert sendmail.encodeSpamSafeEmail(coded, 'SYCTE') == expected
 def testEncodeSpamSafeMail(self):
     """mail.sendmail: encoding mail address to spam safe mail"""
     for coded, expected in self._tests:
         assert sendmail.encodeSpamSafeEmail(coded) == expected
 def testEncodeSpamSafeMailAndObfuscate(self):
     """mail.sendmail: encoding mail address by an obfuscate string to spam safe mail """
     for coded, expected in self._tests:
         expected = expected.replace(' AT ', ' AT SYCTE ')
         assert sendmail.encodeSpamSafeEmail(coded, 'SYCTE') == expected
 def testEncodeSpamSafeMail(self):
     """mail.sendmail: encoding mail address to spam safe mail"""
     for coded, expected in self._tests:
         assert sendmail.encodeSpamSafeEmail(coded) == expected
Exemple #9
0
for page in pages:
    #  contents = Page(request, page).get_raw_body()

    print Page(request, page).getRevList()
    break
    mails = mail_dir.findall(contents)
    comment = ''
    if contents.find(u'#!python') != -1:
        contents = contents.replace(u'#!python', u'#!code python')
        comment = u"Fix coloreado"

    if mails:
        # print (u"Los mails para %s son: %s" % (page, ', '.join(mails))).encode('UTF-8')
        for mail in mails:
            contents = contents.replace(
                mail, u'<<MailTo(%s)>>' % sendmail.encodeSpamSafeEmail(mail))
    # print contents.encode('UTF-8')
        if comment:
            comment += u" y direcciones de mail sin Protecció"
        else:
            comment = u"Fix mail(s) sin protección"
    if comment:
        try:
            PageEditor(request, page).saveText(contents, 0, comment=comment)
            print("%s: %s" % (page, comment)).encode("UTF-8")
        except:
            print 'Sin Permisos para %s' % page

    if contents.find(u'mailto:') != -1:
        contents.replace(u'mailto:', '')
        print page.encode('UTF-8'),