Skip to content

Commit

Permalink
more iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
julien51 committed Dec 19, 2012
1 parent 0ee9bc2 commit d4c3ee0
Show file tree
Hide file tree
Showing 11 changed files with 319 additions and 100 deletions.
8 changes: 6 additions & 2 deletions build/register.subtome.js
Original file line number Diff line number Diff line change
Expand Up @@ -1228,8 +1228,8 @@ Services.prototype.forEachDefaultService = function forEachDefaultService (itera
iterator('Google Reader', {
url: 'http://www.google.com/ig/add?feedurl={url}'
});
iterator('Newsblur', {
url: 'http://www.newsblur.com/?{url}'
iterator('NewsBlur', {
url: 'http://www.newsblur.com/?url={url}'
});
iterator('Bloglovin\'', {
url: 'http://www.bloglovin.com/en/subscriptions?{url}'
Expand All @@ -1242,6 +1242,10 @@ Services.prototype.forEach = function forEachServices(iterator) {
}
}

Services.prototype.uses = function usesService(name) {
return this.services[name] || false;
}

Services.prototype.setAsDefault = function setAsDefault(name, def) {
for(var n in this.services) {
delete this.services[n].default;
Expand Down
162 changes: 85 additions & 77 deletions build/settings.subtome.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,79 @@ exports.extname = function(path) {

});

require.define("/src/services.js", function (require, module, exports, __dirname, __filename) {
var Services = function Services() {
this.services = {};
this.load();
}

Services.prototype.load = function loadServices() {
var servicesString = localStorage.getItem('services');
if(servicesString) {
try {
this.services = JSON.parse(servicesString);
}
catch(error) {
console.error('Could not parse ' + servicesString);
}
}
}

Services.prototype.forEachDefaultService = function forEachDefaultService (iterator) {
iterator('Google Reader', {
url: 'http://www.google.com/ig/add?feedurl={url}'
});
iterator('NewsBlur', {
url: 'http://www.newsblur.com/?url={url}'
});
iterator('Bloglovin\'', {
url: 'http://www.bloglovin.com/en/subscriptions?{url}'
});
}

Services.prototype.forEach = function forEachServices(iterator) {
for(var name in this.services) {
iterator(name, this.services[name]);
}
}

Services.prototype.uses = function usesService(name) {
return this.services[name] || false;
}

Services.prototype.setAsDefault = function setAsDefault(name, def) {
for(var n in this.services) {
delete this.services[n].default;
}
if(name) {
this.services[name].default = def;
}
this.save();
}

Services.prototype.save = function saveServices() {
localStorage.setItem('services', JSON.stringify(this.services));
}

Services.prototype.removeService = function removeService(name) {
delete this.services[name];
this.save();
}

Services.prototype.register = function registerService(name, handler) {
if(!this.services[name]) {
this.services[name] = {
url: handler,
addedOn: Date.now()
}
this.save();
}
}

module.exports = new Services();

});

require.define("/node_modules/relative-date/package.json", function (require, module, exports, __dirname, __filename) {
module.exports = {"main":"./lib/relative-date"}
});
Expand Down Expand Up @@ -1263,75 +1336,6 @@ function lastBraceInKey(str) {

});

require.define("/src/services.js", function (require, module, exports, __dirname, __filename) {
var Services = function Services() {
this.services = {};
this.load();
}

Services.prototype.load = function loadServices() {
var servicesString = localStorage.getItem('services');
if(servicesString) {
try {
this.services = JSON.parse(servicesString);
}
catch(error) {
console.error('Could not parse ' + servicesString);
}
}
}

Services.prototype.forEachDefaultService = function forEachDefaultService (iterator) {
iterator('Google Reader', {
url: 'http://www.google.com/ig/add?feedurl={url}'
});
iterator('Newsblur', {
url: 'hhttp://www.newsblur.com/?url={url}'
});
iterator('Bloglovin\'', {
url: 'http://www.bloglovin.com/en/subscriptions?{url}'
});
}

Services.prototype.forEach = function forEachServices(iterator) {
for(var name in this.services) {
iterator(name, this.services[name]);
}
}

Services.prototype.setAsDefault = function setAsDefault(name, def) {
for(var n in this.services) {
delete this.services[n].default;
}
if(name) {
this.services[name].default = def;
}
this.save();
}

Services.prototype.save = function saveServices() {
localStorage.setItem('services', JSON.stringify(this.services));
}

Services.prototype.removeService = function removeService(name) {
delete this.services[name];
this.save();
}

Services.prototype.register = function registerService(name, handler) {
if(!this.services[name]) {
this.services[name] = {
url: handler,
addedOn: Date.now()
}
this.save();
}
}

module.exports = new Services();

});

require.define("/src/settings.js", function (require, module, exports, __dirname, __filename) {
var services = require('./services');
var relativeDate = require('relative-date');
Expand All @@ -1342,10 +1346,10 @@ function addService(name, handler) {
var s = '<tr>';
s += '<td><a href="' + urlParser.resolve(handler.url,'/').toString() + '">' + name + '</a></td>';
s += '<td>' + relativeDate(new Date(handler.addedOn)) + '</td>';
if(handler.default)
s += '<td>' + '<input type="radio" name="defaultRadios" checked>' + '</td>';
else
s += '<td>' + '<input type="radio" name="defaultRadios">' + '</td>';
// if(handler.default)
// s += '<td>' + '<input type="radio" name="defaultRadios" checked>' + '</td>';
// else
// s += '<td>' + '<input type="radio" name="defaultRadios">' + '</td>';

s += '<td>' + '<button type="button" class="btn btn-mini test">Test</button>' + '</td>';
s += '<td>' + '<button type="button" class="btn btn-mini btn-danger remove">Remove</button>' + '</td>';
Expand All @@ -1355,9 +1359,9 @@ function addService(name, handler) {
services.removeService(name);
line.remove();
});
line.find('input').click(function(evt) {
services.setAsDefault(name, line.find('input').is(':checked'));
});
// line.find('input').click(function(evt) {
// services.setAsDefault(name, line.find('input').is(':checked'));
// });
line.find('button.test').click(function() {
var redirect = handler.url.replace('{url}', 'http://blog.superfeedr.com/atom.xml');
services.register(name, handler.url);
Expand Down Expand Up @@ -1390,9 +1394,13 @@ $(document).ready(function() {
});

$('#registerProtocolHandler').click(function() {
var res = window.navigator.registerProtocolHandler("web+subscribe", 'http://0.0.0.0:8000/settings.html', "Subtome");
var res = navigator.registerProtocolHandler("web+subscribe", 'http://www.subtome.com/subscribe.html?resource=%s', "Subtome");
});

if(navigator.registerProtocolHandler) {
$('#protocolHandlerRegistration').show();
}

services.forEach(addService);
});

Expand Down
4 changes: 2 additions & 2 deletions build/subscribe.subtome.js
Original file line number Diff line number Diff line change
Expand Up @@ -1228,8 +1228,8 @@ Services.prototype.forEachDefaultService = function forEachDefaultService (itera
iterator('Google Reader', {
url: 'http://www.google.com/ig/add?feedurl={url}'
});
iterator('Newsblur', {
url: 'hhttp://www.newsblur.com/?url={url}'
iterator('NewsBlur', {
url: 'http://www.newsblur.com/?url={url}'
});
iterator('Bloglovin\'', {
url: 'http://www.bloglovin.com/en/subscriptions?{url}'
Expand Down
93 changes: 93 additions & 0 deletions developers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Subtome - Developers</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="src/bootstrap/css/bootstrap.css" rel="stylesheet">
<script src="src/jquery/jquery.js"></script>
<script src="src/bootstrap/js/bootstrap.js"></script>
<script src="/build/settings.subtome.js"></script>
<style type="text/css">
body {
padding-top: 20px;
padding-bottom: 40px;
}

/* Custom container */
.container-narrow {
margin: 0 auto;
max-width: 700px;
}
.container-narrow > hr {
margin: 30px 0;
}

</style>
<link href="src/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<!-- Fav and touch icons -->
<link rel="shortcut icon" href="src/ico/favicon.ico">
</head>

<body>

<div class="container-narrow">

<div class="masthead">
<ul class="nav nav-pills pull-right">
<li><a href="/">Home</a></li>
<li><a href="/settings.html">Settings</a></li>
<li><a href="/publishers.html">Publishers</a></li>
<li class="active" ><a href="/developers.html">Developers</a></li>
<li><a href="https://github.com/superfeedr/subtome">Source Code</a></li>
</ul>
<h3 class="muted">Subtome</h3>
</div>

<hr>
<h1>Developers</h1>
<h2>Allow your users to subscribe to content</h2>
<p>
If your application is able to handle user subscriptions, this section is for you.
</p>
<h3>Registration</h3>
<p>
Your users will click on subscribe buttons on some <a href="/publishers.html">publisher</a> pages. When they do so, a
list of the subscription services <em>they</em> used in the past is displayed. This list
was not curated by us, but stored in their browser (using localStorage) from services that registered their ability to perform
susbcriptions for that user.
</p>
<p>You too can quickly and easily register your application for your users by loading an iframe like this:
<script src="https://gist.github.com/4333876.js"></script>
Please note that this is completely transparent for the user!
</p>
<p>The <code>name</code> query string is the name of your application and the <code>url</code> is the url of the hander which will
be called in your application to perform a susbcription. This url should include a <code>{url}</code> placeholder where the url of the document on which the subscribe button was clicked will be placed.
<h3>Subscription handling</h3>

<p>When a user clicks on a Subtome button, he can pick his favorite subscription application. If it's yours, then, a new browser tab will be created and will point to your application's handler <code>url</code> (see previous section). Based on the <code>url</code> you've provided,
you will be able to extract the location of the page on which the button was clicked.</p>
<p>
Your application should then, perform the subscription, by extracting the content it needs. We recomand using the RSS/Atom feeds, but you could also very well extract the links to a Twitter profile for example allow the user to follow that profile. Possibilities are endless.
</p>
<hr>

<div class="footer">
<p>&copy; Superfeedr 2012</p>
</div>

</div> <!-- /container -->

<script src="src/jquery/jquery.js"></script>
<script src="src/bootstrap/js/bootstrap.js"></script>

</body>
</html>
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
<ul class="nav nav-pills pull-right">
<li class="active"><a href="/">Home</a></li>
<li><a href="/settings.html">Settings</a></li>
<li><a href="/publishers.html">Publishers</a></li>
<li><a href="/developers.html">Developers</a></li>
<li><a href="https://github.com/superfeedr/subtome">Source Code</a></li>
</ul>
<h3 class="muted">Subtome</h3>
Expand Down
4 changes: 2 additions & 2 deletions publisher/mypublisher.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ <h1>My publisher</h1>

var s = document.createElement('iframe');
var url = window.location.toString();
s.setAttribute('style','position:absolute;top:0px; left:0px; width:100%; height:100%; border:0px; background: transparent;');
s.setAttribute('src', proto + '://0.0.0.0:8000/subscribe.html?resource=' + window.location.toString());
s.setAttribute('style','position:absolute;top:0px; left:0px; width:100%; height:100%; border:0px; background: transparent; z-index: 2147483647');
s.setAttribute('src', proto + '://www.subtome.com/subscribe.html?resource=' + window.location.toString());
var loaded = false;
s.onload = function() {
if(loaded) {
Expand Down
Loading

0 comments on commit d4c3ee0

Please sign in to comment.