You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2013/10/03 16:13:51 UTC
[38/42] git commit: updated refs/heads/master to a4d6cd4
add plugins plugin for Fauxton
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/492c9899
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/492c9899
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/492c9899
Branch: refs/heads/master
Commit: 492c98990f929dddc7de56fc0bb9582a5ce8d66b
Parents: f8509fa
Author: Jan Lehnardt <ja...@apache.org>
Authored: Mon Sep 9 11:22:01 2013 +0200
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Thu Oct 3 16:09:17 2013 +0200
----------------------------------------------------------------------
.gitignore | 1 +
src/fauxton/app/addons/plugins/base.js | 24 ++++++
src/fauxton/app/addons/plugins/resources.js | 26 ++++++
src/fauxton/app/addons/plugins/routes.js | 47 +++++++++++
.../app/addons/plugins/templates/plugins.html | 88 ++++++++++++++++++++
src/fauxton/settings.json.default | 3 +-
6 files changed, 188 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index c554e82..5f3c9df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -92,6 +92,7 @@ src/fauxton/app/load_addons.js
src/fauxton/app/addons/*
!src/fauxton/app/addons/activetasks
!src/fauxton/app/addons/config
+!src/fauxton/app/addons/plugins
!src/fauxton/app/addons/logs
!src/fauxton/app/addons/stats
!src/fauxton/app/addons/replication
http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/src/fauxton/app/addons/plugins/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/plugins/base.js b/src/fauxton/app/addons/plugins/base.js
new file mode 100644
index 0000000..140a1f8
--- /dev/null
+++ b/src/fauxton/app/addons/plugins/base.js
@@ -0,0 +1,24 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+ "app",
+ "api",
+ "addons/plugins/routes"
+],
+
+function(app, FauxtonAPI, plugins) {
+ plugins.initialize = function() {
+ FauxtonAPI.addHeaderLink({title: "Plugins", href: "#_plugins", icon: "fonticon-plugins", className: 'plugins'});
+ };
+ return plugins;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/src/fauxton/app/addons/plugins/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/plugins/resources.js b/src/fauxton/app/addons/plugins/resources.js
new file mode 100644
index 0000000..d00fada
--- /dev/null
+++ b/src/fauxton/app/addons/plugins/resources.js
@@ -0,0 +1,26 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+ "app",
+ "api"
+],
+
+function (app, FauxtonAPI) {
+ var plugins = FauxtonAPI.addon();
+
+ plugins.Hello = FauxtonAPI.View.extend({
+ template: "addons/plugins/templates/plugins"
+ });
+
+ return plugins;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/src/fauxton/app/addons/plugins/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/plugins/routes.js b/src/fauxton/app/addons/plugins/routes.js
new file mode 100644
index 0000000..24d47f0
--- /dev/null
+++ b/src/fauxton/app/addons/plugins/routes.js
@@ -0,0 +1,47 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+ "app",
+ "api",
+ "addons/plugins/resources"
+],
+function(app, FauxtonAPI, plugins) {
+ var PluginsRouteObject = FauxtonAPI.RouteObject.extend({
+ layout: "one_pane",
+
+ crumbs: [
+ {"name": "Plugins","link": "_plugins"}
+ ],
+
+ routes: {
+ "_plugins": "pluginsRoute"
+ },
+
+ selectedHeader: "Plugins",
+
+ roles: ["_admin"],
+
+ apiUrl:'plugins',
+
+ initialize: function () {
+ //put common views used on all your routes here (eg: sidebars )
+ },
+
+ pluginsRoute: function () {
+ this.setView("#dashboard-content", new plugins.Hello({}));
+ }
+ });
+
+ plugins.RouteObjects = [PluginsRouteObject];
+ return plugins;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/src/fauxton/app/addons/plugins/templates/plugins.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/plugins/templates/plugins.html b/src/fauxton/app/addons/plugins/templates/plugins.html
new file mode 100644
index 0000000..3a49c28
--- /dev/null
+++ b/src/fauxton/app/addons/plugins/templates/plugins.html
@@ -0,0 +1,88 @@
+ <div id="content">
+ <div class="row">
+ <h2>GeoCouch</h2>
+ <p>Version: <strong>couchdb1.2.x_v0.3.0-11-g66e6219</strong></p>
+ <p>Author: Volker Mische</p>
+ <p>
+ Available Erlang Versions:
+ <ul>
+ <li>CouchDB 1.4.0-XXX R15B01</li>
+ </ul>
+ </p>
+ <p>
+ <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"1.4.0": {"R15B03":"D5QPhrJTAifM42DXqAj4RxzfEtI="}}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-16-g66e6219">Install GeoCouch Now</button>
+ </p>
+ </div>
+ <div class="row">
+ <h2>CouchPerUser</h2>
+ <p>Version: <strong>1.0.0</strong></p>
+ <p>Author: Bob Ippolito</p>
+ <p>
+ Available Erlang Versions:
+ <ul>
+ <li>CouchDB 1.4.0-XXX R15B01</li>
+ </ul>
+ </p>
+ <p>
+ <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"1.4.0": {"R15B03":"Aj3mjC6M75NA62q5/xkP0tl8Hws="}}' data-name="couchperuser" data-version="1.0.0">Install CouchPerUser Now</button>
+ </p>
+ </div>
+ </div>
+ </div></body>
+ <script>
+ $('.install-plugin').each(function() {
+ var button = $(this);
+ var name = button.data('name');
+ var version = button.data('version');
+ $.get("/_config/plugins/" + name + "/", function(body, textStatus) {
+ body = JSON.parse(body);
+ if(body == version) {
+ button.html('Already Installed. Click to Uninstall');
+ button.data('delete', true);
+ } else {
+ button.html('Other Version Installed: ' + body);
+ button.attr('disabled', true);
+ }
+ });
+ });
+
+ $('.install-plugin').click(function(event) {
+ var button = $(this);
+ var delete_plugin = button.data('delete') || false;
+ var plugin_spec = JSON.stringify({
+ name: button.data('name'),
+ url: button.data('url'),
+ version: button.data('version'),
+ checksums: button.data('checksums'),
+ "delete": delete_plugin
+ });
+ var url = '/_plugins'
+ $.ajax({
+ url: url,
+ type: 'POST',
+ data: plugin_spec,
+ contentType: 'application/json', // what we send to the server
+ dataType: 'json', // expected from the server
+ processData: false, // keep our precious JSON
+ success: function(data, textStatus, jqXhr) {
+ if(textStatus == "success") {
+ var action = delete_plugin ? 'Uninstalled' : 'Installed';
+ button.html('Sucessfully ' + action);
+ button.attr('disabled', true);
+ } else {
+ button.html(textStatus);
+ }
+ },
+ beforeSend: function(xhr) {
+ xhr.setRequestHeader('Accept', 'application/json');
+ },
+ });
+ });
+ </script>
+ <style type="text/css">
+ .row {
+ background-color: #FFF;
+ padding:1em;
+ margin-bottom:1em;
+ }
+ </style>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/492c9899/src/fauxton/settings.json.default
----------------------------------------------------------------------
diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default
index 30088f0..4964135 100644
--- a/src/fauxton/settings.json.default
+++ b/src/fauxton/settings.json.default
@@ -4,7 +4,8 @@
{ "name": "config" },
{ "name": "logs" },
{ "name": "stats" },
- { "name": "replication" },
+ { "name": "replication" },
+ { "name": "plugins" },
{ "name": "contribute" },
{ "name": "permissions" },
{ "name": "auth" }