couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [22/50] [abbrv] git commit: add guide for writing addons
Date Mon, 11 Feb 2013 11:12:15 GMT
add guide for writing addons

Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/1592665d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/1592665d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/1592665d

Branch: refs/heads/fauxton
Commit: 1592665d19335d420b6b77d3de62971b628a9a0b
Parents: fd219f5
Author: Simon Metson <simon+github@cloudant.com>
Authored: Sun Jan 27 13:00:07 2013 +0100
Committer: Simon Metson <simon+github@cloudant.com>
Committed: Sun Jan 27 13:07:42 2013 +0100

----------------------------------------------------------------------
 src/fauxton/writing_addons.md |   55 ++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/1592665d/src/fauxton/writing_addons.md
----------------------------------------------------------------------
diff --git a/src/fauxton/writing_addons.md b/src/fauxton/writing_addons.md
new file mode 100644
index 0000000..b435566
--- /dev/null
+++ b/src/fauxton/writing_addons.md
@@ -0,0 +1,55 @@
+# Addons
+Addons allow you to extend Fauxton for a specific use case. Addons will usually
+have the following structure:
+
+ * templates/
+   * my_addon.html - _underscore template fragments_
+ * base.js - _entry point to the addon_
+ * resources.js - _models and collections of the addon_
+ * routes.js - _URL routing for the addon_
+ * views.js - _views that the model provides_
+
+## Generating an addon
+We have a grunt task that lets you create a skeleton addon, including all the
+boiler plate code. Run `bbb addon` and answer the questions it asks to create
+an addon:
+
+    ± bbb addon
+    path.existsSync is now called `fs.existsSync`.
+    Running "addon" task
+
+    Please answer the following:
+    [?] Add on Name (WickedCool) SuperAddon
+    [?] Location of add ons (app/addons)
+    [?] Do you need to make any changes to the above before continuing? (y/N)
+
+    Created addon SuperAddon in app/addons
+
+    Done, without errors.
+
+## Routes and hooks
+An addon can insert itself into fauxton in two ways; via a route or via a hook.
+
+### Routes
+An addon will override an existing route should one exist, but in all other
+ways is just a normal backbone route/view. This is how you would add a whole
+new feature.
+
+### Hooks
+Hooks let you modify/extend an existing feature. They modify a DOM element by
+selector for a named set of routes, for example:
+
+    var Search = new FauxtonAPI.addon();
+    Search.hooks = {
+      // Render additional content into the sidebar
+      "#sidebar-content": {
+        routes:[
+          "database/:database/_design/:ddoc/_search/:search",
+          "database/:database/_design/:ddoc/_view/:view",
+          "database/:database/_:handler"],
+        callback: searchSidebar
+      }
+    };
+    return Search;
+
+adds the `searchSidebar` callback to `#sidebar-content` for three routes.
\ No newline at end of file


Mime
View raw message