Ejemplo n.º 1
0
def preview():
    """Returns a preview of a blog post. Use with an Ajax request"""
    args = request.form
    # Mimic post object
    post = dict(
        slug=normalize(args['title']), 
        title=args['title'],
        markup=args['markup'],
        visible=True,
        html=convert_markup(args['markup']),
        datetime=datetime.datetime.fromtimestamp(int(args['datetime'])),
        # Mimic the tag relationship field of post
        tags=[dict(name=tag) for tag in normalize_tags(args['tags'])],
        # Mimic the category relationship field of post
        categories=[dict(name=name) for name in 
            filter(lambda x: x != '', set(args['categories'].split(',')))],
    )
    return render_template('admin/_preview.html', post=post)
Ejemplo n.º 2
0
def preview():
    """Returns a preview of a blog post. Use with an Ajax request"""
    args = request.form
    # Mimic post object
    post = dict(
        slug=normalize(args['title']),
        title=args['title'],
        markup=args['markup'],
        visible=True,
        html=convert_markup(args['markup']),
        datetime=datetime.datetime.fromtimestamp(int(args['datetime'])),
        # Mimic the tag relationship field of post
        tags=[dict(name=tag) for tag in normalize_tags(args['tags'])],
        # Mimic the category relationship field of post
        categories=[
            dict(name=name) for name in filter(
                lambda x: x != '', set(args['categories'].split(',')))
        ],
    )
    return render_template('admin/_preview.html', post=post)
Ejemplo n.º 3
0
 def _set_markup(self, markup):
     """Constrain markup with html so html is never set directly"""
     self._markup = markup
     self._html = convert_markup(markup)
Ejemplo n.º 4
0
 def _set_markup(self, markup):
     """Constrain markup with html so html is never set directly"""
     self._markup = markup
     self._html = convert_markup(markup)