diff --git a/app.rb b/app.rb index 22e554f..d77c7d7 100644 --- a/app.rb +++ b/app.rb @@ -3,6 +3,7 @@ require "erb" class YoutubeException < Exception; end +class FacebookException < Exception; end get "/" do @@ -53,6 +54,25 @@ class YoutubeException < Exception; end end end +get "/facebook" do + if /facebook\.com\/(?[^\/\?#]+)/ =~ params[:q] + # https://www.facebook.com/celldweller/info?tab=overview + else + return "That doesn't look like a facebook url. Sorry." + end + + response = HTTParty.get("https://graph.facebook.com/#{name}") + if response.code == 404 + return "Can't find a page with that name. Sorry." + end + if not response.success? + raise FacebookException, response + end + facebook_id = response.parsed_response["id"] + + redirect "https://www.facebook.com/feeds/page.php?format=rss20&id=#{facebook_id}" +end + get "/favicon.ico" do redirect "/img/icon32.png" end diff --git a/views/index.erb b/views/index.erb index 1e0f706..8ff3ed8 100644 --- a/views/index.erb +++ b/views/index.erb @@ -15,6 +15,14 @@ + ">
@@ -27,8 +35,16 @@
-
YouTube
- +
+ + + + +
+ +
+
+ @@ -37,9 +53,9 @@

About

-

Some services like YouTube and Facebook have publicly available RSS feeds, and this page makes it easier to find them.

+

Some services like YouTube and Facebook have publicly available RSS feeds, but the problem is that these feeds are difficult to find. This page makes looks up the url for you.

-

YouTube lets you subscribe to a channels recent videos.

+

YouTube lets you subscribe to a channel's recent videos.

Facebook lets you subscribe to the activity of public pages (not groups or users!).