Opened 6 years ago

Closed 4 years ago

#8275 closed enhancement (implemented)

Add blog feed to tpo homepage

Reported by: jmtodaro Owned by: jmtodaro
Priority: Medium Milestone:
Component: Webpages/Website Version:
Severity: Keywords: blog
Cc: jmtodaro@… Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

It has been suggested by Kelley that we add a live blog feed to the tpo homepage. I like the idea and think this will a) generally raise awareness of the blog and b) add an element of freshness to the homepage.

I tentatively suggest that it would fit nicely either above or below the "Events" section.

Technical Considerations:
I'm thinking we just set up a cron script to download a local copy of the rss feed hourly or whatever. Then we can parse it how ever we like (probably javascript).

Thoughts?

Child Tickets

Attachments (4)

blogfeed.py (2.3 KB) - added by jmtodaro 6 years ago.
Fetches and parses desired data from the blog rss feed
blogfeed.cron.sample (199 bytes) - added by jmtodaro 6 years ago.
An example of usage from a cron script. The full paths will need to be updated relative to the production web server, of course.
8275.patch (5.1 KB) - added by jmtodaro 4 years ago.
8275-rss-crawler.patch (4.7 KB) - added by jmtodaro 4 years ago.
Alternate patch only requiring LWP::Simple

Download all attachments as: .zip

Change History (12)

comment:1 Changed 6 years ago by jmtodaro

Owner: set to jmtodaro
Status: newassigned

comment:2 Changed 6 years ago by jmtodaro

I've decided the best way to handle this is by periodically generating an html file (blogfeed.html) from the rss feed and simply displaying the contents via iframe on the home page. No javascript required! It will however require that python-feedparser is installed on the server and a cron job to run blogfeed.py every 15 minutes or as often as desired.

Here's a test page displaying how it would look in action: http://tor.jmtodaro.com/test/

Changed 6 years ago by jmtodaro

Attachment: blogfeed.py added

Fetches and parses desired data from the blog rss feed

Changed 6 years ago by jmtodaro

Attachment: blogfeed.cron.sample added

An example of usage from a cron script. The full paths will need to be updated relative to the production web server, of course.

comment:3 Changed 6 years ago by phobos

My general thought is we should do something that integrates into the existing wml build system, rather than other kludges. We build the website regularly, so on build, the wml should pull in and parse the rss feed from the blog, it then writes it out as an integrated function.

Basically, we modify index.wml to include blog.wml, or we have the wml parse the current rss feed at build time.

The website should not have any dynamic parts on it, so serving up static html is our only option. The site needs to work for clients without javascript enabled.

I think replacing the current Announcements section is the best bet here. I don't like the position of the feed in the demo page you created. It completely distracts from the site itself.

comment:4 Changed 4 years ago by jmtodaro

I've taken a fresh look at this ticket and come up with workable code. I've inserted a perl construct into index.wml that will hit the rss feed any time it is recompiled. However, I did have to install "libxml-rss-perl" and it's dependencies before the site would compile (I used XML::RSS to parse the feed).

If this is an issue, we can still do this using only LWP::Simple (assuming it is available) and crawling the page directly for the data, but this will require tweaking if the html formatting of the blog changes (i.e. if we switch blog platforms it would likely need fixing).

I have a test page here: http://jmtodaro.com/tor-blogwidget
And the code is available here: http://github.com/jmtodaro/tor-blogwidget

I am also attaching a patch in case you want to give it a go.

Changed 4 years ago by jmtodaro

Attachment: 8275.patch added

comment:5 Changed 4 years ago by jmtodaro

Actually, it wasn't too difficult to parse the feed without XML::rss. Here is an alternate branch that only needs LWP::Simple, which is hopefully already installed.

https://github.com/jmtodaro/tor-blogwidget/tree/rss-crawler

I've also attached an alternate patch using this code instead.

Changed 4 years ago by jmtodaro

Attachment: 8275-rss-crawler.patch added

Alternate patch only requiring LWP::Simple

comment:6 Changed 4 years ago by phobos

I think it's a great solution. On the index page for www.torproject.org, can we drop the "Announcements" section and replace it with the last 4 blog posts?

comment:7 Changed 4 years ago by phobos

actually, I just edited the perl and wml directly.

comment:8 Changed 4 years ago by phobos

Resolution: implemented
Status: assignedclosed
Note: See TracTickets for help on using tickets.