def article_to_xml(self, xml_article, rawdog, config, article): entry_info = article.entry_info id = entry_info.get("id", self.options["xmlurl"] + "#id" + article.hash) guid = xml_article.newChild(None, 'guid', string_to_html(id, config)) guid.setProp('isPermaLink', 'false') author = escape(self.feed_name(rawdog.feeds[article.feed], config)) xml_article.newChild(None, 'author', author) title = escape(self.feed_name(rawdog.feeds[article.feed], config)) s = detail_to_html(entry_info.get("title_detail"), True, config) if s is not None: title = s.encode('utf8') title = author + ": " + title xml_article.newChild(None, 'title', title) if article.date is not None: date = rfc822_date(gmtime(article.date)) xml_article.newChild(None, 'pubDate', date) s = entry_info.get("link") if s is not None and s != "": xml_article.newChild(None, 'link', string_to_html(s, config)) for key in ["content", "summary_detail"]: s = detail_to_html(entry_info.get(key), False, config) if s is not None: xml_article.newChild(None, 'description', escape(s)) break return True
def output(self, rawdog, config, feed, article, itembits): try: itembits["slash-department"] = string_to_html(article.entry_info['slash_department'], config) itembits["slash-section"] = string_to_html(article.entry_info['slash_section'], config) except KeyError: pass return True
def article_to_xml(self, xml_article, rawdog, config, article): entry_info = article.entry_info id = entry_info.get("id", self.options["xmlurl"] + "#id" + article.hash) guid = xml_article.newChild(None, 'guid', string_to_html(id, config)) guid.setProp('isPermaLink', 'false') title = escape(self.feed_name(rawdog.feeds[article.feed], config)) s = detail_to_html(entry_info.get("title_detail"), True, config) if s is not None: title = s.encode('utf8') xml_article.newChild(None, 'title', title) author = escape(self.feed_name(rawdog.feeds[article.feed], config)) xml_article.newChild(None, 'author', author) if article.date is not None: date = rfc822_date(gmtime(article.date)) xml_article.newChild(None, 'pubDate', date) s = entry_info.get("link") if s is not None and s != "": xml_article.newChild(None, 'link', string_to_html(s, config)) for key in ["content", "summary_detail"]: s = detail_to_html(entry_info.get(key), False, config) if s is not None: xml_article.newChild(None, 'description', escape(s)) break return True
def article_to_xml(self, xml_article, xml_doc, rawdog, config, article): entry_info = article.entry_info id = entry_info.get("id", self.options["xmlurl"] + "#id" + article.hash) guid = xml_doc.createElement('guid') guid_txt = xml_doc.createTextNode(string_to_html(id, config)) guid.setAttribute('isPermaLink', 'false') guid.appendChild(guid_txt) xml_article.appendChild(guid) title = self.feed_name(rawdog.feeds[article.feed], config) s = detail_to_html(entry_info.get("title_detail"), True, config) title = title.decode('utf-8') if s is not None: title += u": " + s title = title.encode('utf-8') xml_article_title = xml_doc.createElement('title') xml_article_title_txt = xml_doc.createTextNode(title) xml_article_title.appendChild(xml_article_title_txt) xml_article.appendChild(xml_article_title) if article.date is not None: date = rfc822_date(gmtime(article.date)) xml_article_date = xml_doc.createElement('pubDate') xml_article_date_txt = xml_doc.createTextNode(date) xml_article_date.appendChild(xml_article_date_txt) xml_article.appendChild(xml_article_date) s = entry_info.get("link") if s is not None and s != "": xml_article_link = xml_doc.createElement('link') xml_article_link_txt = xml_doc.createTextNode( string_to_html(s, config)) xml_article_link.appendChild(xml_article_link_txt) xml_article.appendChild(xml_article_link) for key in ["content", "summary_detail"]: s = detail_to_html(entry_info.get(key), False, config) if s is not None: xml_article_description = xml_doc.createElement('description') xml_article_description_txt = xml_doc.createTextNode(s) xml_article_description.appendChild( xml_article_description_txt) xml_article.appendChild(xml_article_description) break return True
def article_to_xml(self, xml_article, xml_doc, rawdog, config, article): entry_info = article.entry_info id = entry_info.get("id", self.options["xmlurl"] + "#id" + article.hash) guid = xml_doc.createElement('guid') guid_txt = xml_doc.createTextNode(string_to_html(id, config)) guid.setAttribute('isPermaLink', 'false') guid.appendChild(guid_txt) xml_article.appendChild(guid) title = self.feed_name(rawdog.feeds[article.feed], config) s = detail_to_html(entry_info.get("title_detail"), True, config) title = title.decode('utf-8') if s is not None: title += u": " + s title = title.encode('utf-8') xml_article_title = xml_doc.createElement('title') xml_article_title_txt = xml_doc.createTextNode(title) xml_article_title.appendChild(xml_article_title_txt) xml_article.appendChild(xml_article_title) if article.date is not None: date = rfc822_date(gmtime(article.date)) xml_article_date = xml_doc.createElement('pubDate') xml_article_date_txt = xml_doc.createTextNode(date) xml_article_date.appendChild(xml_article_date_txt) xml_article.appendChild(xml_article_date) s = entry_info.get("link") if s is not None and s != "": xml_article_link = xml_doc.createElement('link') xml_article_link_txt = xml_doc.createTextNode(string_to_html(s, config)) xml_article_link.appendChild(xml_article_link_txt) xml_article.appendChild(xml_article_link) for key in ["content", "summary_detail"]: s = detail_to_html(entry_info.get(key), False, config) if s is not None: xml_article_description = xml_doc.createElement('description') xml_article_description_txt = xml_doc.createTextNode(s) xml_article_description.appendChild(xml_article_description_txt) xml_article.appendChild(xml_article_description) break return True
def output(self, rawdog, config, feed, article, itembits): if not article.entry_info.has_key('slash_department'): return True dept = string_to_html(article.entry_info['slash_department'], config) itembits["description"] = self.html % (itembits["description"], dept) return True
def output_item_bits(self, rawdog, config, feed, article, bits): # Retrieve the local copy attribute we saved above. local_copy = article.entry_info.get("download_articles_local_copy") if local_copy is None: # There isn't one. pass else: # Add a localcopy field to the template. bits["localcopy"] = string_to_html(self.options["downloadurl"] + "/" + local_copy, config) return True
def enclosure(rawdog, config, feed, article, itembits): """Adds enclosure-href, enclosure-length and enclosure-type template parameters. """ for link in article.entry_info.get("links", []): if link["rel"] != "enclosure": continue for key in ("href", "length", "type", "title"): if key in link: itembits["enclosure-" + key] = string_to_html(link[key], config) return True
def date_output_bits(rawdog, config, bits): now = datetime.datetime.now() bits['generated'] = string_to_html(now.strftime("%Y-%m-%d %H:%M"), config)
def links_output_bits(rawdog, config, bits): links = "" for link in config['links']: links += '<a href="' + string_to_html(link[0], config) + '">' + string_to_html(link[1], config) + '</a>\n' bits['links'] = links