blog/app/models/posts.py
def serialize(self):
        """ Returns a fancy version of a post. """

        # expand the hero image
        output = copy(self.record)
        try:
            output['hero_image'] = images.expand_image(output['hero_image'])
        except KeyError:
            output['hero_image'] = {'base_name': 'unknown_image.jpg'}

        output['html_hero_image'] = \
            '<img class="webfeedsFeaturedVisual" src="%s/images/%s" />' % (
                app.config['URL'],
                output['hero_image']['base_name']
            )

        # loop through attachment oids and expand
        output['attachments'] = []
        output['html_attachments'] = ""
        attachment_records = app.config['MDB'].attachments.find({
            'post_id': self._id
        })
        if attachment_records is not None:
            for a_rec in attachment_records:
                a_rec['image'] = images.expand_image(a_rec['image_id'])
                output['attachments'].append(a_rec)
                stub = '<img src="%s/images/%s" />'
                output['html_attachments'] += stub % (
                    app.config['URL'], a_rec['image']['base_name']
                )

        # now, create some HTML from the plaintext
        output['html_lede'] = util.fancy_html(output.get('lede', ''))
        output['html_body'] = util.fancy_html(output.get('body', ''))

        output['author'] = dict(self.get_author())
        output['tag_dictionary'] = list(self.get_tags())


        return output
 Returns a fancy version of a post. 
Returns a fancy version of a post.
Returns a fancy version of a post .
def serialize(self):
        output = copy(self.record)
        try:
            output['hero_image'] = images.expand_image(output['hero_image'])
        except KeyError:
            output['hero_image'] = {'base_name': 'unknown_image.jpg'}
        output['html_hero_image'] = \
            '<img class="webfeedsFeaturedVisual" src="%s/images/%s" />' % (
                app.config['URL'],
                output['hero_image']['base_name']
            )
        output['attachments'] = []
        output['html_attachments'] = ""
        attachment_records = app.config['MDB'].attachments.find({
            'post_id': self._id
        })
        if attachment_records is not None:
            for a_rec in attachment_records:
                a_rec['image'] = images.expand_image(a_rec['image_id'])
                output['attachments'].append(a_rec)
                stub = '<img src="%s/images/%s" />'
                output['html_attachments'] += stub % (
                    app.config['URL'], a_rec['image']['base_name']
                )
        output['html_lede'] = util.fancy_html(output.get('lede', ''))
        output['html_body'] = util.fancy_html(output.get('body', ''))
        output['author'] = dict(self.get_author())
        output['tag_dictionary'] = list(self.get_tags())
        return output
def serialize ( self ) : output = copy ( self . record ) try : output [ 'hero_image' ] = images . expand_image ( output [ 'hero_image' ] ) except KeyError : output [ 'hero_image' ] = { 'base_name' : 'unknown_image.jpg' } output [ 'html_hero_image' ] = '<img class="webfeedsFeaturedVisual" src="%s/images/%s" />' % ( app . config [ 'URL' ] , output [ 'hero_image' ] [ 'base_name' ] ) output [ 'attachments' ] = [ ] output [ 'html_attachments' ] = "" attachment_records = app . config [ 'MDB' ] . attachments . find ( { 'post_id' : self . _id } ) if attachment_records is not None : for a_rec in attachment_records : a_rec [ 'image' ] = images . expand_image ( a_rec [ 'image_id' ] ) output [ 'attachments' ] . append ( a_rec ) stub = '<img src="%s/images/%s" />' output [ 'html_attachments' ] += stub % ( app . config [ 'URL' ] , a_rec [ 'image' ] [ 'base_name' ] ) output [ 'html_lede' ] = util . fancy_html ( output . get ( 'lede' , '' ) ) output [ 'html_body' ] = util . fancy_html ( output . get ( 'body' , '' ) ) output [ 'author' ] = dict ( self . get_author ( ) ) output [ 'tag_dictionary' ] = list ( self . get_tags ( ) ) return output
Returns a fancy version of a post.
Returns a fancy version of a post .
""" Returns a fancy version of a post. """ # expand the hero image # loop through attachment oids and expand # now, create some HTML from the plaintext
self