Skip to content
Browse files

initial layout

  • Loading branch information...
0 parents commit b4a569bf386c6fc2394ae3a15fcb3c39f63ee6db @darobin committed Jan 17, 2012
Showing with 80 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +1 −0 README.md
  3. +1 −0 index.js
  4. +21 −0 lib/express-browserid.js
  5. +14 −0 package.json
  6. +31 −0 public/js/browserid-helper.js
  7. +8 −0 test/basic.js
  8. +2 −0 test/mocha.opts
2 .gitignore
@@ -0,0 +1,2 @@
+node_modules
+npm-debug.log
1 README.md
@@ -0,0 +1 @@
+
1 index.js
@@ -0,0 +1 @@
+module.exports = require("./lib/express-browserid");
21 lib/express-browserid.js
@@ -0,0 +1,21 @@
+
+var path = require("path");
+
+exports.plugAll = function (app, opts) {
+ this.plugHelperScript(app, opts);
+};
+
+exports.plugHelperScript = function (app, opts) {
+ opts = opts || {};
+ var route = opts.helperScriptPath || makePath("/js/browserid-helper.js", opts)
+ , filepath = path.join(module.filename, "../public/js/browserid-helper.js");
+ ;
+ app.get(route, function (req, res, next) {
+ res.sendfile(filepath);
+ });
+};
+
+function makePath (path, opts) {
+ var base = opts.basePath || "/browserid";
+ return base + path;
+}
14 package.json
@@ -0,0 +1,14 @@
+{
+ "name": "express-browserid"
+, "description": "Pluggable browserid helpers"
+, "version": "0.0.1"
+, "author": "Robin Berjon <robin@berjon.com>"
+, "dependencies": {
+ }
+, "devDependencies": {
+ "mocha": "*"
+ , "should": "*"
+ }
+, "repository": "git://github.com/darobin/express-browserid"
+, "main": "index"
+}
31 public/js/browserid-helper.js
@@ -0,0 +1,31 @@
+
+(function ($) {
+ "use strict";
+
+ var options = {
+ auto: true
+ , verifier: "/browserid/verify"
+ , selector: "#browserid-login"
+ };
+ $("script").each(function () {
+ var $scr = $(this);
+ if (/js\/browserid-helper\.js(?:\?.+)?$/.test($scr.attr("src"))) {
+ if ("false" === $scr.attr("data-auto")) options.auto = false;
+ options.verifier = $scr.attr("data-verifier") || options.verifier;
+ options.selector = $scr.attr("data-selector") || options.selector;
+ return false;
+ }
+ });
+ $(options.selector).click(function () {
+
+ });
+
+ window.BrowserIDHelper = {
+ // listen to clicks on a given selector
+ // on click call the browserid site
+ // on success, call the verify URL (defaults to this lib's default)
+ // if that works, trigger success cb, or go to redir URL, or reload
+ // on error
+ // trigger error cb, or alert error
+ };
+})(jQuery);
8 test/basic.js
@@ -0,0 +1,8 @@
+var foo = require("../");
+describe("Foo", function () {
+ describe("foo", function () {
+ it("should do something", function () {
+ foo.doSomething().should.equal("something");
+ });
+ });
+});
2 test/mocha.opts
@@ -0,0 +1,2 @@
+--require should
+--reporter spec

0 comments on commit b4a569b

Please sign in to comment.
Something went wrong with that request. Please try again.