From 27a63e657754ae5cfbb8fee2a88df2b7437a8a9b Mon Sep 17 00:00:00 2001 From: rgrp Date: Mon, 24 Oct 2011 16:00:28 +0100 Subject: [PATCH] [all][s]: (refs #1) refactor layout to be like standard js library rather than couch app. --- app.js | 120 ------------------ {attachments => demo}/images/bg_gradient.gif | Bin {attachments => demo}/images/couch.png | Bin .../images/large-spinner.gif | Bin .../images/small-spinner.gif | Bin {attachments/pages => demo}/index.html | 12 +- {attachments => demo}/style/data-table.css | 0 .../style/images/down-arrow.png | Bin .../style/images/edit-map.png | Bin .../style/images/loader-blue.gif | Bin {attachments => demo}/style/images/loader.gif | Bin .../style/images/menu-dropdown.png | Bin {attachments => demo}/style/reset.css | 0 {attachments => demo}/style/style.css | 0 .../script => src}/costco-csv-worker.js | 0 {attachments/script => src}/costco.js | 0 {attachments/script => src}/deps-min.js | 0 {attachments/script => src}/recline.js | 0 {attachments/script => src}/site.js | 0 {attachments/script => src}/util.js | 0 .../script/lib => vendor}/jquery-1.6.1.min.js | 0 .../jquery-ui-1.8.14.custom.min.js | 0 .../script/lib => vendor}/jquery.couch2.js | 0 .../script/lib => vendor}/jquery.hotkeys.js | 0 .../script/lib => vendor}/jquery.mustache.js | 0 .../script/lib => vendor}/microevent.js | 0 .../script/lib => vendor}/sammy-0.6.3.min.js | 0 .../script/lib => vendor}/traverse.js | 0 .../script/lib => vendor}/underscore.js | 0 29 files changed, 6 insertions(+), 126 deletions(-) delete mode 100755 app.js rename {attachments => demo}/images/bg_gradient.gif (100%) rename {attachments => demo}/images/couch.png (100%) rename {attachments => demo}/images/large-spinner.gif (100%) rename {attachments => demo}/images/small-spinner.gif (100%) rename {attachments/pages => demo}/index.html (97%) rename {attachments => demo}/style/data-table.css (100%) rename {attachments => demo}/style/images/down-arrow.png (100%) rename {attachments => demo}/style/images/edit-map.png (100%) rename {attachments => demo}/style/images/loader-blue.gif (100%) rename {attachments => demo}/style/images/loader.gif (100%) rename {attachments => demo}/style/images/menu-dropdown.png (100%) rename {attachments => demo}/style/reset.css (100%) rename {attachments => demo}/style/style.css (100%) rename {attachments/script => src}/costco-csv-worker.js (100%) rename {attachments/script => src}/costco.js (100%) rename {attachments/script => src}/deps-min.js (100%) rename {attachments/script => src}/recline.js (100%) rename {attachments/script => src}/site.js (100%) rename {attachments/script => src}/util.js (100%) rename {attachments/script/lib => vendor}/jquery-1.6.1.min.js (100%) rename {attachments/script/lib => vendor}/jquery-ui-1.8.14.custom.min.js (100%) rename {attachments/script/lib => vendor}/jquery.couch2.js (100%) rename {attachments/script/lib => vendor}/jquery.hotkeys.js (100%) rename {attachments/script/lib => vendor}/jquery.mustache.js (100%) rename {attachments/script/lib => vendor}/microevent.js (100%) rename {attachments/script/lib => vendor}/sammy-0.6.3.min.js (100%) rename {attachments/script/lib => vendor}/traverse.js (100%) rename {attachments/script/lib => vendor}/underscore.js (100%) diff --git a/app.js b/app.js deleted file mode 100755 index d9e5405a..00000000 --- a/app.js +++ /dev/null @@ -1,120 +0,0 @@ -var couchapp = require('couchapp') - , path = require('path') - ; - -ddoc = - { _id:'_design/recline' - , rewrites : - [ {from:"/", to:'pages/index.html'} - , {from:"/api/csv", to:'_list/csv/all'} - , {from:"/api/json", to:'_list/bulkDocs/all'} - , {from:"/api/headers", to:'_list/array/headers', query: {group: "true"}} - , {from:"/api/rows", to:'_view/all'} - , {from:"/api", to:'../../'} - , {from:"/api/*", to:'../../*'} - , {from:"/*", to:'*'} - ] - } - ; - -ddoc.views = { - /** - * A simple map function mocking _all, but allows usage with lists etc. - */ - all: { - map: function(doc) { - emit(doc._id, doc); - } - }, - headers: { - map: function(doc) { - var keys = []; - for (var key in doc) { - emit(key, 1); - } - }, - reduce: "_sum" - } -}; - -ddoc.lists = { - /** - * Generates a CSV from all the rows in the view. - * - * Takes in a url encoded array of headers as an argument. You can - * generate this by querying /_list/urlencode/headers. Pass it in - * as the headers get parameter, e.g.: ?headers=%5B%22_id%22%2C%22_rev%5D - * - * @author Max Ogden - */ - csv: function(head, req) { - if ('headers' in req.query) { - var headers = JSON.parse(unescape(req.query.headers)); - - var row, sep = '\n', headerSent = false, startedOutput = false; - - start({"headers":{"Content-Type" : "text/csv; charset=utf-8"}}); - send('"' + headers.join('","') + '"\n'); - while (row = getRow()) { - for (var header in headers) { - if (row.value[headers[header]]) { - if (startedOutput) send(","); - var value = row.value[headers[header]]; - if (typeof(value) == "object") value = JSON.stringify(value); - if (typeof(value) == "string") value = value.replace(/\"/g, '""'); - send("\"" + value + "\""); - } else { - if (startedOutput) send(","); - } - startedOutput = true; - } - startedOutput = false; - send('\n'); - } - } else { - send("You must pass in the urlencoded headers you wish to build the CSV from. Query /_list/urlencode/headers?group=true"); - } - }, - /** - * Returns an array of the view keys - * - * @author Max Ogden - */ - array: function(head, req) { - start({"headers":{"Content-Type" : "application/json; charset=utf-8"}}); - if ('callback' in req.query) send(req.query['callback'] + "("); - - var headers = []; - while (row = getRow()) { - headers.push(row.key); - } - send(JSON.stringify(headers)); - - if ('callback' in req.query) send(")"); - }, - /** - * A list function that outputs the same format that you use to post into the _bulk_docs API - * - * @author Max Ogden - */ - bulkDocs: function(head, req) { - var row, out, sep = '\n'; - - start({"headers":{"Content-Type" : "application/json"}}); - - if ('callback' in req.query) send(req.query['callback'] + "("); - - send('{"docs":['); - while (row = getRow()) { - out = JSON.stringify(row.value); - send(sep + out); - sep = ',\n'; - } - send("\n]}"); - if ('callback' in req.query) send(")"); - } -} - -couchapp.loadAttachments(ddoc, path.join(__dirname, 'attachments')); - -module.exports = ddoc; \ No newline at end of file diff --git a/attachments/images/bg_gradient.gif b/demo/images/bg_gradient.gif similarity index 100% rename from attachments/images/bg_gradient.gif rename to demo/images/bg_gradient.gif diff --git a/attachments/images/couch.png b/demo/images/couch.png similarity index 100% rename from attachments/images/couch.png rename to demo/images/couch.png diff --git a/attachments/images/large-spinner.gif b/demo/images/large-spinner.gif similarity index 100% rename from attachments/images/large-spinner.gif rename to demo/images/large-spinner.gif diff --git a/attachments/images/small-spinner.gif b/demo/images/small-spinner.gif similarity index 100% rename from attachments/images/small-spinner.gif rename to demo/images/small-spinner.gif diff --git a/attachments/pages/index.html b/demo/index.html similarity index 97% rename from attachments/pages/index.html rename to demo/index.html index 6b838302..e58363c5 100755 --- a/attachments/pages/index.html +++ b/demo/index.html @@ -7,11 +7,11 @@ - - - - - + + + + +
@@ -435,4 +435,4 @@
- \ No newline at end of file + diff --git a/attachments/style/data-table.css b/demo/style/data-table.css similarity index 100% rename from attachments/style/data-table.css rename to demo/style/data-table.css diff --git a/attachments/style/images/down-arrow.png b/demo/style/images/down-arrow.png similarity index 100% rename from attachments/style/images/down-arrow.png rename to demo/style/images/down-arrow.png diff --git a/attachments/style/images/edit-map.png b/demo/style/images/edit-map.png similarity index 100% rename from attachments/style/images/edit-map.png rename to demo/style/images/edit-map.png diff --git a/attachments/style/images/loader-blue.gif b/demo/style/images/loader-blue.gif similarity index 100% rename from attachments/style/images/loader-blue.gif rename to demo/style/images/loader-blue.gif diff --git a/attachments/style/images/loader.gif b/demo/style/images/loader.gif similarity index 100% rename from attachments/style/images/loader.gif rename to demo/style/images/loader.gif diff --git a/attachments/style/images/menu-dropdown.png b/demo/style/images/menu-dropdown.png similarity index 100% rename from attachments/style/images/menu-dropdown.png rename to demo/style/images/menu-dropdown.png diff --git a/attachments/style/reset.css b/demo/style/reset.css similarity index 100% rename from attachments/style/reset.css rename to demo/style/reset.css diff --git a/attachments/style/style.css b/demo/style/style.css similarity index 100% rename from attachments/style/style.css rename to demo/style/style.css diff --git a/attachments/script/costco-csv-worker.js b/src/costco-csv-worker.js similarity index 100% rename from attachments/script/costco-csv-worker.js rename to src/costco-csv-worker.js diff --git a/attachments/script/costco.js b/src/costco.js similarity index 100% rename from attachments/script/costco.js rename to src/costco.js diff --git a/attachments/script/deps-min.js b/src/deps-min.js similarity index 100% rename from attachments/script/deps-min.js rename to src/deps-min.js diff --git a/attachments/script/recline.js b/src/recline.js similarity index 100% rename from attachments/script/recline.js rename to src/recline.js diff --git a/attachments/script/site.js b/src/site.js similarity index 100% rename from attachments/script/site.js rename to src/site.js diff --git a/attachments/script/util.js b/src/util.js similarity index 100% rename from attachments/script/util.js rename to src/util.js diff --git a/attachments/script/lib/jquery-1.6.1.min.js b/vendor/jquery-1.6.1.min.js similarity index 100% rename from attachments/script/lib/jquery-1.6.1.min.js rename to vendor/jquery-1.6.1.min.js diff --git a/attachments/script/lib/jquery-ui-1.8.14.custom.min.js b/vendor/jquery-ui-1.8.14.custom.min.js similarity index 100% rename from attachments/script/lib/jquery-ui-1.8.14.custom.min.js rename to vendor/jquery-ui-1.8.14.custom.min.js diff --git a/attachments/script/lib/jquery.couch2.js b/vendor/jquery.couch2.js similarity index 100% rename from attachments/script/lib/jquery.couch2.js rename to vendor/jquery.couch2.js diff --git a/attachments/script/lib/jquery.hotkeys.js b/vendor/jquery.hotkeys.js similarity index 100% rename from attachments/script/lib/jquery.hotkeys.js rename to vendor/jquery.hotkeys.js diff --git a/attachments/script/lib/jquery.mustache.js b/vendor/jquery.mustache.js similarity index 100% rename from attachments/script/lib/jquery.mustache.js rename to vendor/jquery.mustache.js diff --git a/attachments/script/lib/microevent.js b/vendor/microevent.js similarity index 100% rename from attachments/script/lib/microevent.js rename to vendor/microevent.js diff --git a/attachments/script/lib/sammy-0.6.3.min.js b/vendor/sammy-0.6.3.min.js similarity index 100% rename from attachments/script/lib/sammy-0.6.3.min.js rename to vendor/sammy-0.6.3.min.js diff --git a/attachments/script/lib/traverse.js b/vendor/traverse.js similarity index 100% rename from attachments/script/lib/traverse.js rename to vendor/traverse.js diff --git a/attachments/script/lib/underscore.js b/vendor/underscore.js similarity index 100% rename from attachments/script/lib/underscore.js rename to vendor/underscore.js