passiomatic / coldsweat

Web RSS aggregator and reader compatible with the Fever API
MIT License
145 stars 21 forks source link

Add new feeds with a GET method #70

Closed jeffmikels closed 10 years ago

jeffmikels commented 10 years ago

I have modified the frontend.py function to allow adding feeds using a GET request. Here is the diff.

diff --git a/coldsweat/frontend.py b/coldsweat/frontend.py
index 774ef7f..18331c9 100644
--- a/coldsweat/frontend.py
+++ b/coldsweat/frontend.py
@@ -303,11 +303,18 @@ class FrontendApp(WSGIApp):
         form_message = ''
         groups = get_groups(self.user)

-        if request.method == 'GET':
+        # MODIFIED BY JEFF MIKELS TO ALLOW FEED ADDING BY GET METHODS ALSO
+        if request.method == 'GET' and 'self_link' not in request.GET:
             return self.respond_with_template('_feed_add_wizard_1.html', locals())
-
+
         # Handle postback
-        self_link = request.POST['self_link'].strip()
+        if 'self_link' in request.GET:
+            self_link = request.GET['self_link'].strip()
+        else:
+            self_link = request.POST['self_link'].strip()
+
+        # END MODIFICATIONS
+
         if not is_valid_url(self_link):
             form_message = u'ERROR Error, please specify a valid web address'
             return self.respond_with_template('_feed_add_wizard_1.html', locals())
passiomatic commented 10 years ago

What's the rationale behind this?

jeffmikels commented 10 years ago

The google chrome RSS extension is designed to work with Get Requests for adding feeds. Additionally, a get request allows for the creation of bookmarklets to easily add feeds from any site.

(from my phone) On Jul 23, 2014 4:05 AM, "Andrea Peltrin" notifications@github.com wrote:

What's the rationale behind this?

— Reply to this email directly or view it on GitHub https://github.com/passiomatic/coldsweat/issues/70#issuecomment-49844257 .

passiomatic commented 10 years ago

I don't know if this mixes well with feed auto-discovery (sooner or later it will arrive).

I dream about a bookmarklet, but it should handle authentication too. That is, if a user is logged off it should land on a special page (not the current modal dialog) with the ability to specify link, username and password, then submit data and start subscription routine.

On the pedantic side, when possible a POST action should be preferred to alter database contents. Sometimes there are side-effects after a GET (think "mark as read" after an entry view) but ideally I would like to avoid that.

jeffmikels commented 10 years ago

The change does not bypass authentication. If you are logged in, the bookmarklet works. If you are not, you will be sent to the login page.

(from my phone) On Jul 23, 2014 10:24 AM, "Andrea Peltrin" notifications@github.com wrote:

I don't know if this mixes well with feed auto-discovery (sooner or later it will arrive).

I dream about a bookmarklet, but it should handle authentication too. That is, if a user is logged off it should land on a special page (not the current modal dialog) with the ability to specify link, username and password, the submit data and start subscription routine.

On the pedantic side, when possible a POST action should be preferred to alter database contents. Sometimes there are side-effects after a GET (think "mark as read" after an entry view) but ideally I would like to avoid that.

— Reply to this email directly or view it on GitHub https://github.com/passiomatic/coldsweat/issues/70#issuecomment-49880507 .

passiomatic commented 10 years ago

I've made some changes to the frontend code. Not sure if it's really what you need but now the URL:

{the application url}/feeds/add?self_link={the feed url}

Shows the feed subscription modal with the feed URL text field populated. I've also added a bookmarket and commented because right now it is rather useless, since it just passes the page document.location and not a valid feed address.

Note though, that you still cannot add a feed wth a GET.

jeffmikels commented 10 years ago

Thanks. Your method turns my one click system into a two-click system, but it makes sense, so thank you.

(from my phone) On Aug 10, 2014 10:18 AM, "Andrea Peltrin" notifications@github.com wrote:

I've made some changes to the frontend code. Not sure if it's really what you need but now the URL:

{the application url}/feeds/add?self_link={the feed url}

Shows the feed subscription modal with the feed URL text field populated. I've also added a bookmarket and commented because right now it is rather useless, since it just passes the page document.location and not a valid feed address.

Note though, that you still cannot add a feed wth a GET.

— Reply to this email directly or view it on GitHub https://github.com/passiomatic/coldsweat/issues/70#issuecomment-51716074 .