def format_date_and_time(self, c, x, y, framesize): if 'date' in self.metadata: datestring = format_date(self.metadata["date"], True) if 'dtstart' in self.__event.contents: datestring += " @ %s" % time.strftime("%I:%M %p", self.__event.dtstart.value.timetuple()).lstrip("0") if 'dtend' in self.__event.contents: datestring += " (till %s)" % time.strftime("%I:%M %p", self.__event.dtend.value.timetuple()).lstrip("0") c.setFont("Helvetica", 12) # choose some colors c.setStrokeColorRGB(0, 0, 0) c.setFillColorRGB(0, 0, 0) c.drawString(x, y, datestring) y -= (0.3 * inch) return y
def build_html_abstract_display (self, doc, icon_cid): fp = StringIO() dict = doc.get_metadata() pubdate = dict.get("date") date = re.sub(" 0|^0", " ", time.strftime("%d %b %Y, %I:%M %p", time.localtime(id_to_time(doc.id)))) name = doc.id page_count = dict.get('page-count') summary = '<i>(No summary available.)</i>' if dict: if dict.has_key('title'): name = dict.get('title') elif dict.has_key('name'): name = '[' + dict.get('name') + ']' fp.write(u'<table border=0><tr><td>') fp.write(u'<center>') fp.write(u'<a href="https://%s:%d/action/basic/dv_show?doc_id=%s" border=0>' % (self.ip, doc.repo.secure_port(), doc.id)) fp.write(u'<img src="cid:%s">' % icon_cid) fp.write(u'</a><p><small><font color="%s">(%s)</font></small></center></td><td> </td>' % (STANDARD_DARK_COLOR, date)) fp.write(u'<td valign=top><h3>%s</h3>' % htmlescape(name)) if dict.has_key(u'authors') or pubdate: fp.write(u'<p><small>') if dict.has_key('authors'): fp.write(u'<b> %s</b>' % (re.sub(' and ', ', ', dict['authors']))) if pubdate: formatted_date = format_date(pubdate, True) fp.write(u' <i><font color="%s">%s</font></i>' % (STANDARD_DARK_COLOR, formatted_date)) fp.write(u'</small>\n') if dict.has_key('comment'): summary = htmlescape(dict.get('comment', '')) elif dict.has_key('abstract'): summary = "<i>" + htmlescape(dict.get('abstract', '')) + '</i>' elif dict.has_key('summary'): summary = '<font color="%s">' % STANDARD_DARK_COLOR + htmlescape(dict.get('summary')) + '</font>' fp.write(u'<P>%s' % summary) if page_count: fp.write(u'<small><i><font color="%s"> · (%s page%s)' % (STANDARD_DARK_COLOR, page_count, ((int(page_count) != 1) and "s") or "")) fp.write(u'</font></i></small>\n') cstrings = doc.get_category_strings() fp.write(u'<p>Categories: ') if cstrings: fp.write(string.join([htmlescape(s) for s in cstrings], u' · ')) else: fp.write('(none)') typ = doc.get_metadata("apparent-mime-type") if typ: mtype = ' · <small>%s</small>' % typ else: mtype = '' fp.write(u'<p><a href="https://%s:%s/action/externalAPI/fetch_original?doc_id=%s&browser=true"><font color="%s">(Original%s)</font></a>' % (self.ip, doc.repo.secure_port(), doc.id, STANDARD_DARK_COLOR, mtype)) fp.write(u' · <a href="https://%s:%s/action/basic/doc_pdf?doc_id=%s"><font color="%s">(PDF)</font></a>' % (self.ip, doc.repo.secure_port(), doc.id, STANDARD_DARK_COLOR)) if not mtype.lower().startswith("text/html"): fp.write(u' · <a href="https://%s:%s/action/basic/doc_html?doc_id=%s"><font color="%s">(HTML)</font></a>' % (self.ip, doc.repo.secure_port(), doc.id, STANDARD_DARK_COLOR)) fp.write(u'</td></tr></table>') d = fp.getvalue() fp.close() return d, name