| #summary 'Sandworm' Newsfeed Module | |
| #labels Importance-Useful,Phase-Requirements,Contents-Draft | |
| = Introduction = | |
| A framework for customizable news feeds for various entity kinds that can be formatted on various site pages. Each newsfeed includes a subscription link, and through a 'subscribe' url pattern is used to render XML feeds. | |
| Because of the relatively simple nature of the initial project, some of the post-midterm development will include an auxiliary open source pubsub component meant to be deployed separately, and act as a hub allowing Melange instances to host chat, Google Wave updates, and other real-time activity. | |
| = Model = | |
| An individual FeedItem entity is created for each news feed update. A garbage collection task will delete old feed items, so they don't take over the datastore. | |
| The FeedItem model contains the following properties: | |
| * *sender* (db.Key) | |
| * *receivers* (db.KeyList) | |
| * *update_type* (created, deleted, modified) | |
| * *created* (datetime) | |
| The sender is the entity that was updated, and the receiver is the owner of the news feed that is being updated. | |
| = Logic = | |
| Newsfeed logic consists of two methods: | |
| * *addToFeed* takes a sender entity, a list of receiver entities, an update type, and an optional payload (like a text preview of a document). It adds all the receivers to a FeedItem with the specified payload. | |
| * *retrieveFeed* takes a receiever entity, and retrieves it's latest news feed updates, with an optional count kwarg. This method is cached, with a cache handler in the /cache folder. | |
| = Views = | |
| The newsfeed view is very simple at the moment, although the placement of the newsfeed template component in multiple templates seems to violate DRY. The newsfeed template itself is simply a table modeled after the blog template that lists each news feed update, which is added to the context dict through the retrieveFeed method. | |
| = Subscription = | |
| I've added a new url_path 'subscribe', so that a URL for requesting an ATOM feed would look like this: | |
| http://melange.appspot.com/site/subscribe/somesite | |
| This address is added to pages with a meta tag: | |
| <link rel="alternate" type="application/rss+xml" title="RSS" href="{{ feed_url }}"/> | |
| There is also a graphic subscribe icon on the corner of the newsfeed GUI module. | |
| The 'subscribe' path will also be the interface for any PubSub interactions, but those will only be activated on POST requests with a callback URL, otherwise the ATOM feed will be returned as normal. | |
| = Requirements = | |
| ** Before I continue to develop detailed specs and continue coding, I'd like to get some feedback about what Melange users would like to see from a news feed. Specifically, the following types of feedback: | |
| * Which entity types would you most like to have a newsfeed (for instance, programs, organizations, clubs, users, etc.) | |
| * What's more important to you - having the news feed contain detailed information about updates, or having an easy way to export the newsfeed to an external feed reader? | |
| * Are there any things you'd like to see in a news feed aside from updates about recently updated entities? | |
| = Issues/TODO = | |
| Redirects aren't happening properly because linkable redirect property seems to redirect to the scope of the entity, instead of entity as I expected. (see blog post) | |
| * The getProgram method for surveys has been superceded by getScope during onCreate, implemented for documents and surveys. | |
| * A garbage collection task for old FeedItem entities is needed. | |
| * A task calling getScope on all existing documents is needed. (Task API?) | |
| Right now, News Feed logic only applies to entities subclassed from the Work model. This is just so they can properly formatted in the news feed template. Investigate and implement to make the template more generic. | |
| ACL should be used, although the extent to which it will be necessary is unknown. For instance, a solution to many ACL issues would be allow the newsfeed to have public access, while not including any private information in the news feed. (This would also make it much easier to export the newsfeed in Atom format) |