def message2Html(self, msg):
        '''
    Exports the given message to HTML and returns it as a list of lines
    in a html file. These can be joined using "".join(list).
    '''
        html = []
        html.append(u"""<div class="message">""")
        if 'from' in msg:
            html.append(u"""  <div class="from">""")
            html.append(self.user2Html(msg['from']))
            html.append(u"</div>\n")
        if 'message' in msg:
            html.append(u"""  <div class="body">""")
            html.append(HtmlHelper.escapeHtml(msg['message']))
            html.append(u"</div>\n")
        elif 'type' in msg and msg['type'] == 'photo' and 'story' in msg:
            html.append(u"""  <div class="body">""")
            html.append(HtmlHelper.escapeHtml(msg['story']))
            html.append(u"</div>\n")
        link = None
        if 'link' in msg:
            link = msg['link']
        addedImageWithLink = False
        if 'picture' in msg:
            gotImages = False
            if 'object_id' in msg:
                gotImages = self.downloadImageFromObjectID(msg['object_id'])
                html.append(self.image2Html(gotImages, link))
                if link != None:
                    addedImageWithLink = True
        if not addedImageWithLink and link != None:
            html.append(u"<div class=\"link\" target=\"_blank\"><a href=\"" +
                        link + u"\">" + link + u"</a></div>\n")
        if 'created_time' in msg:
            html.append(u"""  <div class="info">""")
            html.append(msg['created_time'])
            html.append(u"</div>\n")
        if 'likes' in msg:
            html.append(u"<div class=\"msgLikeCount\">Likes: " +
                        str(len(msg['likes']['data'])) + "</div>\n")
            html.append(u"""  <div class="likes">Likes: \n""")
            for user in msg['likes']['data']:
                html.append(u"""    <div class="like">""")
                html.append(self.user2Html(user))
                html.append(u"</div>\n")

            html.append(u"</div>\n")
        if 'like_count' in msg and msg['like_count'] > 0:
            html.append(u"<div class=\"likeCount\">Likes: " +
                        str(msg['like_count']) + u"</div>\n")
        if 'comments' in msg:
            html.append(u"""<div class="comments">""")
            html.append(self.messages2Html(msg['comments']['data']))
            html.append(u"</div> <!-- comments -->\n")
        html.append(u"</div>\n")  # /message
        return html
 def message2Html(self, msg):
   '''
   Exports the given message to HTML and returns it as a list of lines
   in a html file. These can be joined using "".join(list).
   '''
   html = []
   html.append(u"""<div class="message">""")
   if 'from' in msg:
     html.append(u"""  <div class="from">""")
     html.append(self.user2Html(msg['from']))
     html.append(u"</div>\n")
   if 'message' in msg:
     html.append(u"""  <div class="body">""")
     html.append(HtmlHelper.escapeHtml(msg['message']))
     html.append(u"</div>\n")
   elif 'type' in msg and msg['type'] == 'photo' and 'story' in msg:
     html.append(u"""  <div class="body">""")
     html.append(HtmlHelper.escapeHtml(msg['story']))
     html.append(u"</div>\n")
   link = None
   if 'link' in msg:
     link = msg['link']
   addedImageWithLink = False
   if 'picture' in msg:
     gotImages = False
     if 'object_id' in msg:
       gotImages = self.downloadImageFromObjectID(msg['object_id'])
       html.append(self.image2Html(gotImages, link))
       if link != None:
         addedImageWithLink = True
   if not addedImageWithLink and link != None:
     html.append(u"<div class=\"link\" target=\"_blank\"><a href=\"" + link + u"\">" + link + u"</a></div>\n")
   if 'created_time' in msg:
     html.append(u"""  <div class="info">""")
     html.append(msg['created_time'])
     html.append(u"</div>\n")
   if 'likes' in msg:
     html.append(u"<div class=\"msgLikeCount\">Likes: " + str(len(msg['likes']['data'])) + "</div>\n")
     html.append(u"""  <div class="likes">Likes: \n""")
     for user in msg['likes']['data']:
       html.append(u"""    <div class="like">""")
       html.append(self.user2Html(user))
       html.append(u"</div>\n")
     
     html.append(u"</div>\n")
   if 'like_count' in msg and msg['like_count'] > 0:
     html.append(u"<div class=\"likeCount\">Likes: " + str(msg['like_count']) + u"</div>\n")
   if 'comments' in msg:
     html.append(u"""<div class="comments">""")
     html.append(self.messages2Html(msg['comments']['data']))
     html.append(u"</div> <!-- comments -->\n")
   html.append(u"</div>\n") # /message
   return html
 def fieldToDiv(self, field, fieldName, className = None):
   '''
   Creates a html div with the given fieldClass with the contents of
   field[fieldName], if fieldName exists as a key in field.
   If not, an empty string is returned. 
   :param field: the dictionary containing multiple values.
   :param fieldName: the key expected to exist in the dict.
   :param className: the name of the css class to use. If not specified the
   fieldName is used instead.
   '''
   if not type(field) is dict:
     raise BaseException("Given field is not dict but '%s' with value '%s' and fieldName '%s'." % (type(field), str(field), fieldName))
   if className == None:
     className = fieldName
   if fieldName in field:
     html = []
     html.append(u"""<div class="%s">""" % className)
     html.append(HtmlHelper.escapeHtml(field[fieldName]))
     html.append(u"""</div>""")
     return "".join(html)
   else:
     return ""
 def fieldToDiv(self, field, fieldName, className=None):
     '''
 Creates a html div with the given fieldClass with the contents of
 field[fieldName], if fieldName exists as a key in field.
 If not, an empty string is returned. 
 :param field: the dictionary containing multiple values.
 :param fieldName: the key expected to exist in the dict.
 :param className: the name of the css class to use. If not specified the
 fieldName is used instead.
 '''
     if not type(field) is dict:
         raise BaseException(
             "Given field is not dict but '%s' with value '%s' and fieldName '%s'."
             % (type(field), str(field), fieldName))
     if className == None:
         className = fieldName
     if fieldName in field:
         html = []
         html.append(u"""<div class="%s">""" % className)
         html.append(HtmlHelper.escapeHtml(field[fieldName]))
         html.append(u"""</div>""")
         return "".join(html)
     else:
         return ""