jparyani / Tiny-Tiny-RSS

A PHP and Ajax feed reader
http://tt-rss.org/
GNU General Public License v2.0
10 stars 6 forks source link

Register TT-RSS as a feed reader in Firefox #4

Open jinnko opened 9 years ago

jinnko commented 9 years ago

TT-RSS has a feature in Preferences>Feeds>Firefox integration to add it as a feed reader, allowing one to easily add RSS subscriptions to the TT-RSS instance. Unfortunately this doesn't work as expected within Sandstorm.

I found it's possible to make this work manually using the Inspect Element>Console feature. I took the code off the "Click here to register this site as a feed reader" button and modified it to contain the correct URL, then ran this via the Console.

The code in the page reads as follows:

window.navigator.registerContentHandler("application/vnd.mozilla.maybe.feed", "http://localhost:33413/public.php?op=subscribe&feed_url=%s",  "Tiny Tiny RSS")

Replacing the localhost then running the code in the Console achieves the desired result:

window.navigator.registerContentHandler("application/vnd.mozilla.maybe.feed", "https://URL_TO_YOUR/grain/RANDOM_ID/public.php?op=subscribe&feed_url=%s",  "Tiny Tiny RSS")

Note that editing the code inline then re-pressing the button doesn't work. I don't know why.

As there's no other easy way to register an RSS reader I expect this feature within TT-RSS to work.

jparyani commented 9 years ago

Hmm so this is problematic because due to the security constraints of Sandstorm, a grain doesn't actually know its own grainId/URL.

2 possible solutions here:

  1. We build in a way for sandstorm to set RSS readers from apps (probably through the postMessage API that we use for setting title and other various things, see https://github.com/sandstorm-io/sandstorm/blob/0afd4d1be092b38d73159c3b308988fe51e75fa9/shell/shared/grain.js#L848)
  2. We alter TinyTinyRSS to on button press, prompt the user for the grain url and then proceed as normal.

Pinging @kentonv to see which is more reasonable. Option 2 seems like the wrong way to go, but is certainly easier to get working.

jparyani commented 9 years ago

So reading https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerContentHandler leads me to believe that option 2 may not even work. Each session to a grain is hosted on a random subdomain, and the note says "Web sites may only register content handlers for themselves". I'm not sure if subdomains are allowed to registerContentHandler with a url pointing to a parent domain or not.

kentonv commented 9 years ago

Yeah, it seems like this would need to be another postMessage API mediated through the shell.

jinnko commented 9 years ago

Could the URL be constructed in javascript on the client side rather than on the server side? I guess you'd then be able to use document.location or some such. (it's been a long time since i've done js dev, so please excuse any ignorance).

kentonv commented 9 years ago

@jinnko Afraid not. The app is in an iframe where it does not have access to the top-level document.location.

QJKX commented 6 years ago

registerContentHandler has been removed from Firefox.

https://www.fxsitecompat.com/en-CA/docs/2018/navigator-registercontenthandler-has-been-removed/ https://bugzilla.mozilla.org/show_bug.cgi?id=1398169