#215 Fix handling of title-less Planet posts
Merged 3 years ago by pingou. Opened 3 years ago by bcotton.
fedora-infra/ bcotton/ansible issue9251_fix_rss_parsing  into  master

@@ -36,14 +36,20 @@ 

      <div class="row">

  """

      cnt = 0

-     # Getting at least 4 items in case of some python exceptions.

+     # Getting at least 6 items in case of some python exceptions.

      for item in feed["items"][:6]:

          if int(cnt) % 2 == 0:

              HTML += u"""

      <div class="col-sm-6 blog-headlines">

      """

          item.title = item.title.replace("&", "&#38;")

-         author, title = item.title.split(':', 1)

+         # If a blog post doesn't have a title for some reason, it breaks the way

+         # we try to parse out the author and title. Let's say it's untitled in

+         # order for it to appear on the page without breaking the script.

+         if ":" in item.title:

+             author, title = item.title.split(':', 1)

+         else:

+             author, title = item.title, "(untitled post)"

          link = item.links[0]['href']

          # Remove image tag from beginning

          try:

Some platforms can give us a post without a title. When that happens,
Planet's RSS feed title is "$author" instead of "$author.title", which
causes our split to blow up. Instead, we check to see if there is a ':',
and if so split like normal. If not, explicitly set the title to
"(untitled post)" in order for it to still render.

While I'm at it, update a comment so that it reflects what the code is
actually doing.

Fixes #9251

Signed-off-by: Ben Cotton bcotton@fedoraproject.org

:thumbsup: for me

Do you have permissions to merge or shall I?

rebased onto dff3869f7b5170e57b3a5a28bfefab0b39ecdb09

3 years ago

Do you have permissions to merge or shall I?

I do not. I have rebased it and you may merge at your pleasure.

rebased onto 9a22d42a409135823225e706afdfbb3b229ba1e2

3 years ago

rebased onto 9a22d42a409135823225e706afdfbb3b229ba1e2

3 years ago

rebased onto 46d4f10

3 years ago

rebased onto 46d4f10

3 years ago

Pull-Request has been merged by pingou

3 years ago