Saturday, May 25, 2013

Google Reader to TT-RSS - coping with 3rd party apps and services

Here's a guide to replacing Google Reader with Tiny Tiny RSS, but with more detail on the greater tragedy (travesty?) of Google's continued bulldozing of open internet standards with the termination of Reader, the interaction with other services and software on which we used to depend.  I'm starting with a couple of simple but important services, though I'd like to flesh this out over time.

Infrastructure

The problem we all face isn't installing the software (granted, TT-RSS is a non-trivial install, but I consider that to be outside the scope of this guide). The problem we face is the need for hosting. And most of the hosting solutions that will meet our needs require us to configure a hosted server of some kind.

My solution was to start with a Bitnami stack.  Specifically, I started with the LAMP stack.  However, the Bitnami portion of this process will soon become very simple. Tiny Tiny RSS won the regular contest Bitnami holds to decide on new stacks and is expected to be released soon.  Keep an eye on it here: http://bitnami.com/product/tiny-tiny-rss

Next, I signed up a free "developer" class account with Bitnami Cloud Hosting.

Bitnami will allow you to deploy your stack to the Amazon EC2 service automatically and provides documentation for getting your Amazon account set up and ready:  http://wiki.bitnami.com/Amazon_cloud/prepare_aws_account

If this is your first foray into AWS, the first year of your EC2 micro-instance is free.

Software

Now, onto the part where you actually use TT-RSS.


There's plenty of howto links around for installing TT-RSS itself, so I keep the redundancy to a minimum.  The official guide is over here: http://tt-rss.org/redmine/projects/tt-rss/wiki/InstallationNotes


The guide for how to set up automatic updating of your feeds: http://tt-rss.org/redmine/projects/tt-rss/wiki/UpdatingFeeds

I'm not going to bother with details on how I rigged this up in my Bitnami stack as most of it will be soon be moot with the introduction of the TT-RSS stack. If you're a good Linux user and you do want to wait for the bitnami release, here's the summary with no training wheels.

  • Run gnu screen.
  • I used /opt/bitnami/mysql/bin/mysql_setpermission to set up the tt-rss db and configure a user to be able to access it.
  • Extract the tt-rss source tarball into /opt/bitnami/apache2/html/ and rename directory to tt-rss.
  • Slurp in the mysql schema.
  • Configure tt-rss according to the install guide.
  • Because the update_daemon2.php script needs to be run as the daemon user, I added a minimal ~daemon/.bashrc (just the path from ~bitnami/.bashrc):
    • PATH="/opt/bitnami/memcached/bin:/opt/bitnami/varnish/bin:/opt/bitnami/redis/bin:/opt/bitnami/nodejs/bin:/opt/bitnami/mercurial/bin:/opt/bitnami/perl/bin:/opt/bitnami/git/bin:/opt/bitnami/nginx/sbin:/opt/bitnami/frameworks/laravel/app/Console:/opt/bitnami/frameworks/cakephp/app/Console:/opt/bitnami/frameworks/codeigniter/bin:/opt/bitnami/frameworks/symfony/bin:/opt/bitnami/frameworks/zendframework/app/Console:/opt/bitnami/sphinx/bin:/opt/bitnami/sqlite/bin:/opt/bitnami/apps/django/bin:/opt/bitnami/php/bin::/opt/bitnami/java/bin:/opt/bitnami/mysql/bin:/opt/bitnami/postgresql/bin:/opt/bitnami/apache2/bin:/opt/bitnami/python/bin:/opt/bitnami/subversion/bin:/opt/bitnami/ruby/bin:/opt/bitnami/common/bin:$PATH"
      export PATH
  • In another screen window, become the daemon user
    • sudo su - daemon -c bash
  • Run the update script.
    • cd /opt/bitnami/apache2/html/tt-rss/
    • ./update_daemon2.php

That's pretty much it.  Filling in the blanks is left to the more experienced user.

On to the more important pieces...

Exporting from Google Reader

Here is an excellent guide for how to export your Google Reader data:
How to painlessly export your Google Reader feeds

Importing your rss subscriptions to TT-RSS

Extract the file you downloaded from Google Takeout.  Inside, the important item is the subscriptions.xml file.  Log into your TT-RSS instance and go into Preferences, then click into your Feeds tab. Expand OPML, the 2nd accordion item. Click the Import my OPML button and select the subscriptions.xml file you extracted. If you're interested in preserving your starred items from Reader, expand Import starred or shared items from Google Reader, the last accordion item. Select the starred.json file you extracted and click the Import my Starred Items button.

Android

App

The official TT-RSS App has been under very active development and is maturing very quickly.  It's been perfectly stable and usable for me. The only downside is the lack of a launcher widget allow you to read feed article titles right on your homescreen.

Widget

My solution for the lack of a widget is a little complicated, but it's working great. It's made possible because TT-RSS is not just a feed reader, it is also a feed publisher. In your TT-RSS instance, put the feeds you want to appear in your widget into a category.  I used the Favorites for my category name. After you create and populate your new category, click on it.  Positioned underneath the Preferences link, you'll see Favorites and the RSS icon. Click directly on the RSS icon and it will pop up a long link.  Copy down this url, you'll need it later.

Next, install Simple RSS Widget.

Yahoo Pipes

You'll be feeding Simple RSS Widget from Yahoo Pipes.  Log into your Yahoo Pipes account and create a new pipe.

Since I have several feeds under my Favorites category in TT-RSS, I wanted to give each item title a little visual distinction so I would know from which feed the individual article came.  This made the Yahoo Pipe I created a bit more complicated than it needed to be, but the end result is exactly what I wanted.

From the Sources section, Drag out an Item Builder object.

I populated mine with the following attributes:

title = Favorites
description = Items from my Favorites category
link = http://pipes.yahoo.com/<username>/<placeholder>?_render=rss (replace this with the link to your resulting yahoo pipe when you're done.
author = aharrison

From the Operators section, drag out a Loop object. Back under Sources, drag out a Fetch Data object and drop it in the middle of the Loop object you just dragged out. For the url, you're going to drop in the long url you copied earlier. However, you're going to modify the url. Your url will look something like:


http://my-ttrss-instance.bitnamiapp.com/tt-rss/public.php?op=rss&id=26&is_cat=1&key=abcdef1234568901234567890123456789012345

Modify it slightly:

http://my-ttrss-instance.bitnamiapp.com/tt-rss/public.php?op=rss&id=26&is_cat=1&format=json&view-mode=adaptive&key=abcdef1234568901234567890123456789012345


Add the item I put in bold and leave everything else the same.  In the Path to item list field, type: articles

Also worth noting, if you're using https:// for your TT-RSS instance, you need to drop the s to allow Yahoo Pipes to hit your feed without ssl. Likely this is simply because the default ssl certficates in your bitnami stack are just self-signed examples. If you want Yahoo Pipes to be able to use ssl, you're probably going to have to buy your own ssl certificate and rig it up inside your Bitnami stack. (If you really want to do this, here's an old guide that will help you get there: How to activate ssl / Security

Inside your Loop object, choose the radio button emit and the all dropdown choice.

Click and drag the botton of your Item Builder object to the top of your Loop object to connect them together.

If you don't want to bother altering the item titles to reflect the feed, you can now connect the bottom of this Loop object to the top of the Pipe Output object and you're done.  If you also want the indication of which feed the item is from, proceed.

Drag out a Rename object.  Connect the Loop object to this new Rename object.

For the mapping, choose item.link from the field choices, then Copy As from the drop down, and type in the last field: titleprefix

Drag out a Regex object.  It should read:
In item.titleprefix replace ^http[:][/][/](.*?)[.](com|net|org).*$ with [$1]
Connect the Rename object to this new Regex object.

Drag out another Loop object. Connect the Regex object to this new Loop object.

Grab another String Builder object and drop it in the middle of the new Loop object. Populate it like so:

  • item.titleprefix
  • <blank spot>
  • item.title

Grab another String Builder object, but this time, drop it outside the Loop object, not inside.
Inside the new String Builder object, just enter ' - ' (without the quotes).  That's a space, a dash, and another space.

From the bottom of this new String Builder object, click and drag to connect it to the little bubble to the right of your empty field inside your Loop object's String Builder object. Now in your inner String Builder object, instead of the empty field, it should turn gray and read 'text [wired]' because the empty field will now pull from the outer String Builder object sitting off to the side.

To finish with our Loop object, instead of the emit results radio button, choose the assign result to radio button and select item.title from the choices.

Click and drag from the bottom of this Loop object and connect it to the top of the Pipe Output object.

You're done creating your Pipe, so click Save and then go back to your pipes page.

Click on your new pipe.  Inside, you'll see a link Get as RSS. Right click it and copy it.

Edit the pipe you just created.  Remember back up in the Item Builder object where I said you'd replace the url?  Paste the url there.

Also, send this link to your Android device so that you'll be able to configure it there as well.

Take that link, and configure it inside the Simple RSS Widget you installed. Now when you drop the widget onto your homescreen, you'll see all of your favorite items.

I made an example of this pipe available for reference:
http://pipes.yahoo.com/ahinmaine/examplettrssfavorites

ifttt.com

Another frustration of the Reader retirement is all the awesome things you can do with your feeds at ifttt.com.  Fortunately, all is not lost. For example, I had an ifttt trigger to push any of my starred items to Pocket automatically. Instead, you can use the simple version of the above Yahoo Pipe example to accomplish the same thing. For your Fetch Data object, use this example url instead.

http://my-ttrss-instance.bitnamiapp.com/tt-rss/public.php?op=rss&id=-1&format=json&view-mode=adaptive&is_cat=&key=abcdef1234568901234567890123456789012345

Notice the id is -1, this automatically chooses your starred items feed. And instead of is_cat being 1, leave it blank.

Why the Pipes?

You may have already wondered, why would I use Yahoo Pipes to access feeds I've published in my TT-RSS instance rather than accessing them by my TT-RSS url directly?  Simple, if you have multiple apps and services polling your TT-RSS instance, this is going to greatly increase the amount of traffic to your EC2 instance. There are usage limits to these micro-instances and you'll hit them a lot faster if you let it get hit from lots of different sources. Yahoo Pipes is an effective way of keeping your costs down. For example, if your Simple RSS Widget is set to poll every 5 minutes, Yahoo Pipes is NOT going to hit your TT-RSS instance every time, it's just going to serve up the results since Pipes last polled it.

The Pipes Regex object

Yes, I know the regular expression I used for an article title prefix isn't very robust.  I'm lazily grabbing the hostname from the domain of the url of the feed. Improving the appearance of your feeds by having fun with Pipes is left as an exercise for the reader.

2 comments:

  1. Care to give an update about usability & costs after 1 year of usage ?

    ReplyDelete
  2. I was paying around $15/month. But I recently noticed that the newer t2.micro instance type was almost $5 cheaper a month, so I switched. Although due to a weird issue with some attribute of my account (something about being unable to establish a default vpc), I had to tear it down and create a fresh account. I didn't actually try to cheat, I filled in the same account information, but it started me over with a fresh year of free again. Not only that, you can do an RDS for free too, so just for fun I spun up a mysql RDS instance and pointed tt-rss over to that. :)

    ReplyDelete