Closed chrisvanpatten closed 10 years ago
@chrisvanpatten Data attributes should definitely be a way this is used. The only 'problem' at this point is finding which DOM element was clicked and triggered the load of the modal.
Also, using a a
tag is perfectly fine :) Any DOM element can be used to load SubToMe, as long as you can attach a event listener to it (onclick
) here.
Ok, I think that's now implemented :) in 6c7b4a1e98e3729f6d869b53005e6336f59c998f and 0dbbdb8bbd3d4e991b6745e2e4cd5a5c8d4ecf5d
I need to update the docs now, but you can do something like:
<input type="button" onclick="(function(btn){var z=document.createElement('script');document.subtomeBtn=btn;z.src='https://www.subtome.com/load.js';document.body.appendChild(z);})(this)" value="Subscribe" data-subtome-resource="http://blog.superfeedr.com" data-subtome-feeds="http://blog.superfeedr.com/atom.xml" data-subtome-suggested-service-name="FeedBin" data-subtome-suggested-service-url="https://feedbin.me/?subscribe={feed}" >
As you can see the <input>
tag now has several data-* attributes:
They're obviously all optional, but both suggested-service- should be used together. I'll update the docs on the site, and hopefully the WP plugin too so that these are completely configurable thru the short code for example!
@julien51 script location in example can not be http://subtome.com/load.js (this doesn't redirect as you'd expect). Needs to be https://www.subtome.com/load.js. Maybe that's just an oversight in your example, but it would be better if subtome.com also redirected as expected.
Have checked out https://github.com/superfeedr/subtome/commit/0dbbdb8bbd3d4e991b6745e2e4cd5a5c8d4ecf5d locally and its working just great. (Only using data-subtome-feeds
though).
Do you have any thoughts on when it will be live?
Ha, example fixed, sorry about that. This is actually already live, but since we use Appcache and have pretty aggressive caching it may take a couple hours to be visible to you. You can flush Appcache in your browser to see it as it is now!
Per my conversation last night with @julien51, I think it'd be cool for someone to experiment with HTML5 data attributes for subtome.
I'm wholly unskilled when it comes to JavaScript, so unfortunately that person isn't me... but I wanted to share the idea here anyway.
The current SubToMe code for publishers looks like so:
I'd love to see this evolve to something more like this:
I think this approach, instead of using custom javascript, is easier for publishers to understand and customize. I think it would also open the door for other cool customizations, like letting users specify the desired subscription URL, like so:
In this way, users can easily create follow buttons for their favourite or recommended websites, overriding SubToMe's default URL detection.
(Worth noting that I made my revised examples use the
a
tag instead of a button, but that's teeeechnically another issue entirely.)