MCPcopy
hub / github.com/getpelican/pelican / _add_item_to_the_feed

Method _add_item_to_the_feed

pelican/writers.py:55–104  ·  view source on GitHub ↗
(self, feed, item)

Source from the content-addressed store, hash-verified

53 )
54
55 def _add_item_to_the_feed(self, feed, item):
56 title = Markup(item.title).striptags()
57 link = self.urljoiner(self.site_url, item.url)
58
59 if self.settings["FEED_APPEND_REF"]:
60 link = link + "?ref=feed"
61
62 if isinstance(feed, Rss201rev2Feed):
63 # RSS feeds use a single tag called 'description' for both the full
64 # content and the summary
65 content = None
66 if self.settings.get("RSS_FEED_SUMMARY_ONLY"):
67 description = item.summary
68 else:
69 description = item.get_content(self.site_url)
70
71 else:
72 # Atom feeds have two different tags for full content (called
73 # 'content' by feedgenerator) and summary (called 'description' by
74 # feedgenerator).
75 #
76 # It does not make sense to have the summary be the
77 # exact same thing as the full content. If we detect that
78 # they are we just remove the summary.
79 content = item.get_content(self.site_url)
80 description = item.summary
81 if description == content:
82 description = None
83
84 categories = []
85 if hasattr(item, "category"):
86 categories.append(item.category)
87 if hasattr(item, "tags"):
88 categories.extend(item.tags)
89
90 feed.add_item(
91 title=title,
92 link=link,
93 unique_id=get_tag_uri(link, item.date),
94 description=description,
95 content=content,
96 categories=categories or None,
97 author_name=getattr(item, "author", ""),
98 pubdate=set_date_tzinfo(item.date, self.settings.get("TIMEZONE", None)),
99 updateddate=set_date_tzinfo(
100 item.modified, self.settings.get("TIMEZONE", None)
101 )
102 if hasattr(item, "modified")
103 else None,
104 )
105
106 def _open_w(self, filename, encoding, override=False):
107 """Open a file to write some content to it.

Callers 1

write_feedMethod · 0.95

Calls 3

set_date_tzinfoFunction · 0.90
getMethod · 0.80
get_contentMethod · 0.80

Tested by

no test coverage detected