Exemple #1
0
 def render(self, name, value, attrs=None):
     return mark_safe(
          'Generate photo <input type="checkbox" name="%s" %s /> at <input type="text" name="%s" /> second or use custom: %s' % \
          (name + '_auto',
           value and ' ' or 'checked="true"',
           name + '_time',
           super(PhotoWidget, self).render(name, value, attrs),))
Exemple #2
0
def html2text(s, ignore_tags=(), indent_width=4, page_width=80):
    ignore_tags = [t.lower() for t in ignore_tags]
    parser = HTML2Text(ignore_tags, indent_width, page_width)
    parser.feed(s)
    parser.close()
    parser.generate()
    return mark_safe(parser.result)
Exemple #3
0
def html2text(s, ignore_tags=(), indent_width=4, page_width=80):
    ignore_tags = [t.lower() for t in ignore_tags]
    parser = HTML2Text(ignore_tags, indent_width, page_width)
    parser.feed(s)
    parser.close()
    parser.generate()
    return mark_safe(parser.result)
        def render(self, context):
            """
            Creates a renderable safe string for the tag.

            :Parameters:
               - `context`: current context information
            """
            style = "text"
            if len(self.vlist) > 0:
                style = resolve_variable(self.vlist[0], context)
            result = "<pre>" + str(self.nodelist.render(context)) + "</pre>"
            return mark_safe(result)
        def render(self, context):
            """
            Creates a renderable safe string for the tag.

            :Parameters:
               - `context`: current context information
            """
            style = "text"
            if len(self.vlist) > 0:
                style = resolve_variable(self.vlist[0], context)
            result = "<style>%s</style>" % HtmlFormatter().get_style_defs(".highlight")
            result += highlight(
                self.nodelist.render(context), get_lexer_by_name(style, encoding="UTF-8"), HtmlFormatter()
            )
            return mark_safe(result)
Exemple #6
0
    def __init__(self, po, *args, **kwargs):
        self.po = po
        self.base_fields = {}

        prev = None
        for msg in po.nodes:
            if isinstance(msg, PoNodeMsg):
                name = msg.input_name()
                if name != "":
                    if msg.is_multiline():
                        widget = admin_widgets.AdminTextareaWidget
                    else:
                        widget = admin_widgets.AdminTextInputWidget
                    help = mark_safe("\n<br/>".join(
                        prev.lines())) if msg else None
                    self.base_fields[name] = forms.CharField(
                        label=msg.input_label(),
                        widget=widget,
                        initial=msg.input_value(),
                        required=False,
                        help_text=help)
            prev = msg

        super(PoForm, self).__init__(*args, **kwargs)
Exemple #7
0
    def __init__(self, po, *args, **kwargs):
        self.po = po
        self.base_fields={}

        prev = None
        for msg in po.nodes:
            if isinstance(msg, PoNodeMsg):
                name = msg.input_name()
                if name!="":
                    if msg.is_multiline():
                        widget = admin_widgets.AdminTextareaWidget
                    else:
                        widget = admin_widgets.AdminTextInputWidget
                    help = mark_safe("\n<br/>".join(prev.lines())) if msg else None 
                    self.base_fields[name] = forms.CharField(
                                                label = msg.input_label(),
                                                widget = widget,
                                                initial = msg.input_value(),
                                                required = False,
                                                help_text = help
                                                )
            prev = msg
            
        super(PoForm, self).__init__(*args, **kwargs)
Exemple #8
0
def archive(release = True):
    '''Create a .tar.gz archive of the project directory.
The :func:`djpcms.contrib.jdep.utils.project` must have been called already
with the name of the project.'''
    import os
    import tarfile
    from django.template import loader, mark_safe
    utils.rmfiles(os.curdir, ext = 'pyc')
    filename = '%s.tar.gz' % env.project
    data = loader.render_to_string('jdep/server.txt', {'env':mark_safe('%s\n' % env), 'release': release})
    if release:
        f = open('server.py','w')
        f.write(data)
        f.close()
        t = tarfile.open(filename, mode = 'w:gz')
        t.add(env.project)
        t.add('requirements.txt')
        t.add('__init__.py')
        t.add('server.py')
        t.close()
        local('rm server.py')
    else:
        env.server_script = data
    return filename
Exemple #9
0
def render(self, context):
    return template.mark_safe(''.join(map(template.force_unicode,
                                          _render_nodelist_items(self,context))))
def render(self, context):
    return template.mark_safe(''.join(
        map(template.force_unicode, _render_nodelist_items(self, context))))
Exemple #11
0
 def human_msg(self):
     return mark_safe(u"%s %s %s:%s" % (self.user.username, self.get_action_display(), self.content_type.name, self.content_object))
Exemple #12
0
def buildtag(name, content, **attrs):
    return mark_safe('<%s %s>%s</%s>' % (name, " ".join('%s="%s"' % i for i in attrs.items()), unicode(content), name))
Exemple #13
0
def currency(value):
    #string = locale.currency(value, grouping=True)
    #return template.mark_safe(string)
    return template.mark_safe(money_format(value, curr="$", neg='(', trailneg=")"))
Exemple #14
0
def short_currency(value):
    output = template.mark_safe(money_format(value, places=2, curr="$", neg='(', trailneg=")"))
    if output.endswith(".00"):
        return output[:-3]
    else:
        return output
Exemple #15
0
def buildtag(name, content, **attrs):
    return mark_safe('<%s %s>%s</%s>' % (name, " ".join('%s="%s"' % i for i in attrs.items()), unicode(content), name))
Exemple #16
0
def hyperlink(url, title, **attrs):
    return mark_safe('<a href="%s" %s>%s</a>' % (url, " ".join('%s="%s"' % i for i in attrs.items()), title))
Exemple #17
0
def hyperlink(url, title, **attrs):
    return mark_safe('<a href="%s" %s>%s</a>' % (url, " ".join('%s="%s"' % i for i in attrs.items()), title))