Benoit Chesneau avatar Benoit Chesneau committed a69e9c3

import couchapp base from sofa.

Comments (0)

Files changed (7)

 {
-   "title": "Carnet d'un artisan web.",
-   "env": {
-        "benoitc.local": {
-            "static_url": "static",
-            "show_url": "show",
-            "list_url": "list",
-            "dbname": "benoitc-dev",
-            "dname": "benoitc",
-            "cookie_path": "/"
-        }
-    }
+   "title": "Carnet d'un artisan web."
 }
     <link rel="openid.server" href="http://www.myopenid.com/server">
     <link rel="openid.delegate" href="http://bchesneau.myopenid.com/">
     <link rel="home index" href="http://benoitc.org/" type="text/html">
-    <link rel="me author" href="http://benoitc.org/apropos.html" type="text/html">
+    <link rel="me author" href="http://benoitc.org/benoitc.html" type="text/html">
 
     <link rel="stylesheet" href="<%= assets %>/css/screen.css" type="text/css" media="screen, projection" />
 
 <body>
     <header>
         <h1>
-            <a rel="me author" href="<%= assets %>/about.html">Benoît Chesneau</a>
+            <a rel="me author" href="<%= assets %>/benoitc.html">Benoît Chesneau</a>
         </h1>
     </header>
     <section id="items">

vendor/couchapp/couchapp.js

+// this stuff should be properly namespaced etc

vendor/couchapp/date.js

+function f(n) {    // Format integers to have at least two digits.
+    return n < 10 ? '0' + n : n;
+}
+
+Date.prototype.rfc3339 = function() {
+    return this.getUTCFullYear()   + '-' +
+         f(this.getUTCMonth() + 1) + '-' +
+         f(this.getUTCDate())      + 'T' +
+         f(this.getUTCHours())     + ':' +
+         f(this.getUTCMinutes())   + ':' +
+         f(this.getUTCSeconds())   + 'Z';
+};
+
+// This is a format that collates in order and tends to work with
+// JavaScript's new Date(string) date parsing capabilities, unlike rfc3339.
+Date.prototype.toJSON = function() {
+    return this.getUTCFullYear()   + '/' +
+         f(this.getUTCMonth() + 1) + '/' +
+         f(this.getUTCDate())      + ' ' +
+         f(this.getUTCHours())     + ':' +
+         f(this.getUTCMinutes())   + ':' +
+         f(this.getUTCSeconds())   + ' +0000';
+};
+
+Date.prototype.setRFC3339 = function(dString){
+    var regexp = /(\d\d\d\d)(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)(\.\d+)?(Z|([+-])(\d\d)(:)?(\d\d))/;
+
+    if (dString.toString().match(new RegExp(regexp))) {
+        var d = dString.match(new RegExp(regexp));
+        var offset = 0;
+
+        this.setUTCDate(1);
+        this.setUTCFullYear(parseInt(d[1],10));
+        this.setUTCMonth(parseInt(d[3],10) - 1);
+        this.setUTCDate(parseInt(d[5],10));
+        this.setUTCHours(parseInt(d[7],10));
+        this.setUTCMinutes(parseInt(d[9],10));
+        this.setUTCSeconds(parseInt(d[11],10));
+        if (d[12])
+            this.setUTCMilliseconds(parseFloat(d[12]) * 1000);
+        else
+            this.setUTCMilliseconds(0);
+        if (d[13] != 'Z') {
+            offset = (d[15] * 60) + parseInt(d[17],10);
+            offset *= ((d[14] == '-') ? -1 : 1);
+            this.setTime(this.getTime() - offset * 60 * 1000);
+        }
+    } else {
+        this.setTime(Date.parse(dString));
+    }
+    return this;
+};

vendor/couchapp/metadata.json

+{"scm": "git", "update_url": "git://github.com/jchris/sofa.git"}

vendor/couchapp/path.js

+// from couch.js
+function encodeOptions(options) {
+  var buf = []
+  if (typeof(options) == "object" && options !== null) {
+    for (var name in options) {
+      if (!options.hasOwnProperty(name)) continue;
+      var value = options[name];
+      if (name == "key" || name == "startkey" || name == "endkey") {
+        value = toJSON(value);
+      }
+      buf.push(encodeURIComponent(name) + "=" + encodeURIComponent(value));
+    }
+  }
+  if (!buf.length) {
+    return "";
+  }
+  return "?" + buf.join("&");
+}
+
+function concatArgs(array, args) {
+  for (var i=0; i < args.length; i++) {
+    array.push(args[i]);
+  };
+  return array;
+};
+
+function makePath(array) {
+  var options, path;
+  
+  if (typeof array[array.length - 1] != "string") {
+    // it's a params hash
+    options = array.pop();
+  }
+  path = array.map(function(item) {return encodeURIComponent(item)}).join('/');
+  if (options) {
+    return path + encodeOptions(options);
+  } else {
+    return path;    
+  }
+};
+
+function assetPath() {
+  var parts = ['',req.path[0], '_design', req.path[2]];
+  return makePath(concatArgs(parts, arguments));
+};
+
+function showPath() {
+  var parts = ['',req.path[0], '_show', req.path[2]];
+  return makePath(concatArgs(parts, arguments));
+};
+
+function listPath() {
+  var parts = ['',req.path[0], '_list', req.path[2]];
+  return makePath(concatArgs(parts, arguments));
+};
+
+function olderPath(info) {
+  if (!info) return null;
+  var q = req.query;
+  q.startkey = info.prev_key;
+  q.skip=1;
+  return listPath('index','recent-posts',q);
+}
+
+function makeAbsolute(req, path) {
+  return 'http://' + req.headers.Host + path;
+}

vendor/couchapp/template.js

+// Simple JavaScript Templating
+// John Resig - http://ejohn.org/ - MIT Licensed
+var cache = {};
+
+function template(str, data){
+  // Figure out if we're getting a template, or if we need to
+  // load the template - and be sure to cache the result.
+  var fn = cache[str] ||
+
+  // Generate a reusable function that will serve as a template
+  // generator (and which will be cached).
+    new Function("obj",
+      "var p=[],print=function(){p.push.apply(p,arguments);};" +
+          
+            // Introduce the data as local variables using with(){}
+            "with(obj){p.push('" +
+          
+            // Convert the template into pure JavaScript
+            str
+            .replace(/\n/g, "\\n")
+            .replace(/[\r\t]/g, " ")
+            .replace(/'(?=[^%]*%>)/g,"\t")
+            .split("'").join("\\'")
+            .split("\t").join("'")
+            .replace(/<%=(.+?)%>/g, "',$1,'")
+            .split("<%").join("');")
+            .split("%>").join("p.push('")
+            + "');}return p.join('');");
+  cache[str] = fn;
+  
+  // Provide some basic currying to the user
+  return data ? fn( data ) : fn;
+};
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.