[pve-devel] r6090 - / pve2-api-doc pve2-api-doc/data pve2-api-doc/debian

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Jun 16 13:22:28 CEST 2011


Author: dietmar
Date: 2011-06-16 13:22:27 +0200 (Thu, 16 Jun 2011)
New Revision: 6090

Added:
   pve2-api-doc/
   pve2-api-doc/Makefile
   pve2-api-doc/data/
   pve2-api-doc/data/Makefile
   pve2-api-doc/data/PVEAPI.js
   pve2-api-doc/data/PVETable.js
   pve2-api-doc/data/apidoc.html
   pve2-api-doc/data/extractapi.pl
   pve2-api-doc/debian/
   pve2-api-doc/debian/README
   pve2-api-doc/debian/changelog
   pve2-api-doc/debian/compat
   pve2-api-doc/debian/control
   pve2-api-doc/debian/copyright
   pve2-api-doc/debian/pve2-api-doc.conf
   pve2-api-doc/debian/rules
Log:
initial import


Added: pve2-api-doc/Makefile
===================================================================
--- pve2-api-doc/Makefile	                        (rev 0)
+++ pve2-api-doc/Makefile	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,43 @@
+RELEASE=2.0
+
+VERSION=2.0
+PKGREL=1
+
+PACKAGE=pve2-api-doc
+
+ARCH=all
+DEB=${PACKAGE}_${VERSION}-${PKGREL}_${ARCH}.deb
+
+all: ${DEB}
+
+.PHONY: dinstall
+dinstall: deb
+	dpkg -i ${DEB}
+
+
+.PHONY: deb
+deb ${DEB}: 
+	rm -rf build
+	rsync -a --exclude .svn data/ build
+	rsync -a --exclude .svn debian/ build/debian
+	cd build; dpkg-buildpackage -rfakeroot -b -us -uc
+	lintian ${DEB}
+
+.PHONY: clean
+clean: 	
+	rm -rf *~ */*~ *.deb *.changes build ${PACKAGE}-*.tar.gz
+
+.PHONY: distclean
+distclean: clean
+
+
+.PHONY: upload
+upload: ${DEB}
+	umount /pve/${RELEASE}; mount /pve/${RELEASE} -o rw 
+	mkdir -p /pve/${RELEASE}/extra
+	rm -f /pve/${RELEASE}/extra/${PACKAGE}_*.deb
+	rm -f /pve/${RELEASE}/extra/Packages*
+	cp ${DEB} /pve/${RELEASE}/extra
+	cd /pve/${RELEASE}/extra; dpkg-scanpackages . /dev/null > Packages; gzip -9c Packages > Packages.gz
+	umount /pve/${RELEASE}; mount /pve/${RELEASE} -o ro
+

Added: pve2-api-doc/data/Makefile
===================================================================
--- pve2-api-doc/data/Makefile	                        (rev 0)
+++ pve2-api-doc/data/Makefile	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,27 @@
+PREFIX=/usr
+DOCDIR=${PREFIX}/share/pve2-api-doc/
+
+apidata.js: extractapi.pl
+	./extractapi.pl >$@
+
+JSSRC= apidata.js PVEAPI.js
+
+apidoc.js: ${JSSRC}
+	cat ${JSSRC} >$@
+
+all:
+
+.PHONY: install
+install: apidoc.js apidoc.html apidata.js
+	install -d -m 0755 ${DESTDIR}${DOCDIR}
+	install -D -m 0644 apidoc.html ${DESTDIR}${DOCDIR}/apidoc.html;
+	install -D -m 0644 apidoc.js ${DESTDIR}${DOCDIR}/apidoc.js;
+	install -D -m 0644 apidata.js ${DESTDIR}${DOCDIR}/apidata.js;
+
+#pvelib_DATA = apidoc.js apidoc.html
+#pvelibdir = ${WWW_ROOTDIR}
+
+clean:
+	-rm -rf *~ apidata.js apidoc.js
+
+

Added: pve2-api-doc/data/PVEAPI.js
===================================================================
--- pve2-api-doc/data/PVEAPI.js	                        (rev 0)
+++ pve2-api-doc/data/PVEAPI.js	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,262 @@
+Ext.require([
+    'Ext.tree.*',
+    'Ext.data.*',
+    'Ext.window.MessageBox'
+]);
+
+// avoid errors when running without development tools
+if (!Ext.isDefined(Ext.global.console)) {   
+    var console = { 
+        dir: function() {}, 
+        log: function() {} 
+    };
+}
+
+Ext.onReady(function() {
+
+    Ext.define('pve-param-schema', {
+        extend: 'Ext.data.Model',
+        fields:  [ 
+	    'name', 'type', 'typetext', 'description', 'enum', 
+	    'minimum', 'maximum', 'minLength', 'maxLength',
+	    'pattern', 'title', 'requires', 'format', 'default',
+	    'disallow', 'extends', 'links',
+	    {
+		name: 'optional',
+		type: 'boolean'
+	    }
+	]
+    });
+
+    var store = Ext.create('Ext.data.TreeStore', {
+	model: Ext.define('pve-api-doc', {
+            extend: 'Ext.data.Model',
+            fields:  [ 
+		'path', 'info', 'text',
+	    ]
+	}),
+        proxy: {
+            type: 'memory',
+            data: pveapi
+        },
+        sorters: [{
+            property: 'leaf',
+            direction: 'ASC'
+        }, {
+            property: 'text',
+            direction: 'ASC'
+        }]
+    });
+    
+    var render_text = function(value, metaData, record) {
+	var pdef = record.data;
+
+	metaData.style = 'white-space:pre-wrap;'
+
+	return  value;
+    };
+
+    var render_type = function(value, metaData, record) {
+	var pdef = record.data;
+
+	return pdef['enum'] ? 'enum' : (pdef.type || 'string');
+    };
+
+    var render_format = function(value, metaData, record) {
+	var pdef = record.data;
+
+	metaData.style = 'white-space:normal;'
+
+	if (pdef.typetext)
+	    return pdef.typetext;
+
+	if (pdef['enum'])
+	    return pdef['enum'].join(' | ');
+
+	if (pdef.format) 
+	    return pdef.format;
+
+	if (pdef.pattern) 
+	    return pdef.pattern;
+
+	return '';
+    };
+
+    var render_docu = function(data) {
+	var md = data.info;
+
+	console.log(data);
+
+	var items = [];
+
+	Ext.Array.each(['GET', 'POST', 'PUT', 'DELETE'], function(method) {
+	    var info = md[method];
+	    if (info) {
+
+		var sections = [
+		    {
+			title: 'Description',
+			html: info.description,
+			bodyPadding: 10
+		    }
+		];
+
+		if (info.parameters && info.parameters.properties) {
+
+		    var pstore = Ext.create('Ext.data.Store', {
+			model: 'pve-param-schema',
+			proxy: {
+			    type: 'memory'
+			},
+			groupField: 'optional',
+			sorters: [
+			    {
+				property: 'name',
+				direction: 'ASC'
+			    }
+			]
+		    });
+
+		    Ext.Object.each(info.parameters.properties, function(name, pdef) {
+			pdef.name = name;
+			pstore.add(pdef);
+		    });
+
+		    pstore.sort();
+
+		    var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
+			enableGroupingMenu: false,
+			groupHeaderTpl: '<tpl if="name">Optional</tpl><tpl if="!name">Required</tpl>'
+		    });
+
+		    sections.push({
+			xtype: 'gridpanel',
+			title: 'Parameters',
+			features: [groupingFeature],
+			store: pstore,
+			viewConfig: {
+			    trackOver: false,
+			    stripeRows: true
+			},
+			columns: [
+			    { 
+				header: 'Name',
+				dataIndex: 'name'
+			    },
+			    { 
+				header: 'Type',
+				dataIndex: 'type',
+				renderer: render_type,
+			    },
+			    { 
+				header: 'Format',
+				dataIndex: 'type',
+				renderer: render_format,
+				flex: 1
+			    },
+			    { 
+				header: 'Description',
+				dataIndex: 'description',
+				renderer: render_text,
+				flex: 2
+			    }
+			]
+		    });
+
+		}
+
+		if (info.returns) {
+
+		    var rtype = info.returns.type;
+		    if (!rtype && info.returns.items)
+			rtype = 'array';
+		    if (!rtype)
+			rtype = 'object';
+
+		    sections.push({
+			title: 'Returns: ' + rtype
+		    });
+		}
+
+		var permhtml = '';
+		if (!info.permissions) {
+		    permhtml = "Root only.";
+		} else if (info.permissions.user) {
+		    if (info.permissions.user === 'world') {
+			permhtml += "Accessible without any authententification.";
+		    } else if (info.permissions.user === 'all') {
+			permhtml += "Accessible by all authententicated users.";
+		    } else {
+			permhtml += 'Onyl accessible by user "' + 
+			    info.permissions.user + '"';
+		    }
+		} else if (info.permissions.path && info.permissions.privs) {
+		    permhtml += '<table><tr><td>Path:</td><td>' + 
+			info.permissions.path + '</td></tr>' +
+			'<tr><td style="padding-right:10px;">Permissions:</td><td>' + 
+			info.permissions.privs.join(' ') + 
+			'</td></tr></table>';
+		} else {
+		    permhtml += "Root only.";
+		}
+
+		sections.push({
+		    title: 'Required permissions',
+		    bodyPadding: 10,
+		    html: permhtml
+		});
+    
+  
+		items.push({
+		    title: method,
+		    autoScroll: true,
+		    defaults: {
+			border: false
+		    },
+		    items: sections
+		});
+	    }
+	});
+
+	var ct = Ext.getCmp('docview');
+	ct.setTitle("Path: " + data.path);
+	ct.removeAll(true);
+	ct.add(items);
+    };
+
+    var tree = Ext.create('Ext.tree.Panel', {
+        title: 'Resource Tree',
+        store: store,
+	width: 200,
+        region: 'west',
+        split: true,
+        margins: '5 0 5 5',
+        rootVisible: false,
+	listeners: {
+	    selectionchange: function(v, selections) {
+		if (!selections[0])
+		    return;
+		var rec = selections[0];
+		render_docu(rec.data);
+	    }
+	}
+    });
+
+    Ext.create('Ext.container.Viewport', {
+	layout: 'border',
+	renderTo: Ext.getBody(),
+	items: [
+	    tree,
+	    {
+		xtype: 'tabpanel',
+		title: 'Documentation',
+		id: 'docview',
+		region: 'center',
+		margins: '5 5 5 0',
+		layout: 'fit',
+		items: []
+	    }
+	]
+    });
+
+});

Added: pve2-api-doc/data/PVETable.js
===================================================================
--- pve2-api-doc/data/PVETable.js	                        (rev 0)
+++ pve2-api-doc/data/PVETable.js	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,99 @@
+// just a test - not usable now
+
+Ext.define('PVE.Table', {
+    extend: 'Ext.Component',
+
+    alias: 'widget.pvetable',
+
+    onRender: function() {
+        var me = this;
+
+	Ext.applyIf(me.renderData, {
+	    id: me.getId(),
+	    title: me.title,
+	    columns: me.columns
+	});
+
+	var rows = [];
+	me.store.each(function(record) {
+	    rows.push(record.data);
+	});
+
+ 
+	me.renderData.rows = rows;
+	me.callParent(arguments);
+    },
+
+    metaRowTpl: '<tr>' +
+	'<tpl for="columns">' +
+	'<td>{{dataIndex}}</td>' +
+	'</tpl>'+ 
+	'</tr>',
+
+     metaRenderTpl: '<h1>{title}</h1>' +
+	'<table border="1" cellspacing="0" cellpadding="0">' +
+	'<tr><tpl for="columns">' +
+	'<th><div id="{parent.id}-th-resize{#}" style="background-color:red;">{header}</div></th>' +
+	'</tpl></tr>'+ 
+        '{[this.openRows()]}' +
+	'{row}'+ 
+        '{[this.closeRows()]}' +
+	'</table>',
+   
+    initComponent : function() {
+        var me = this;
+
+	Ext.Array.each(me.columns, function(col, i) {
+	    if (!col.width)
+		col.width = 100;
+	    if (!col.minWidth || (col.minWidth < 10))
+		col.minWidth = 10;
+	    if (col.width < col.minWidth)
+		col.width = col.minWidth;
+	});
+
+	var metaRowTpl = Ext.create('Ext.XTemplate', me.metaRowTpl);
+        me.row = metaRowTpl.applyTemplate(me);
+
+	var metaTpl = Ext.create('Ext.XTemplate', me.metaRenderTpl, {
+	    openRows: function() {
+		return '<tpl for="rows">';
+	    },
+
+	    closeRows: function() {
+		return '</tpl>';
+	    }
+	});
+ 	var tpl = metaTpl.applyTemplate(me);
+
+	//console.log("TEST1 " + tpl);
+
+	Ext.apply(me, {
+	    renderTpl: tpl
+	});
+
+ 	me.callParent();
+
+	// only works with FF
+	me.on('afterrender', function() {
+	    Ext.Array.each(me.columns, function(col, i) {
+		var myid = me.getId() + '-th-resize' + (i+1);
+		var rz = Ext.create('Ext.resizer.Resizer', {
+		    el: myid,
+		    handles: 'e',
+		    minWidth: col.minWidth,
+		    transparent: true,
+		    listeners: {
+			resize: function(t, width, height) {
+			    var target = t.getTarget();
+			    var parent = target.parent();
+			    parent.setWidth(width);
+			    t.el.setWidth(parent.getWidth()-1);
+			}
+		    }
+		});
+		rz.resizeTo(col.width);
+	    });
+	});
+    }
+});

Added: pve2-api-doc/data/apidoc.html
===================================================================
--- pve2-api-doc/data/apidoc.html	                        (rev 0)
+++ pve2-api-doc/data/apidoc.html	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+    <title>Proxmox VE API Documentation</title>
+    <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-4.0.2/resources/css/ext-all.css" />
+
+    <script type="text/javascript" src="http://extjs.cachefly.net/ext-4.0.2/ext-all-debug.js"></script>
+    <script type="text/javascript" src="apidoc.js"></script>
+    
+</head>
+<body>
+</body>
+</html>

Added: pve2-api-doc/data/extractapi.pl
===================================================================
--- pve2-api-doc/data/extractapi.pl	                        (rev 0)
+++ pve2-api-doc/data/extractapi.pl	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,12 @@
+#!/usr/bin/perl -w
+
+use strict;
+use PVE::RESTHandler;
+use PVE::API2;
+use JSON;
+
+my $tree = PVE::RESTHandler::api_dump('PVE::API2');
+
+print "var pveapi = " . to_json($tree, {pretty => 1}) . ";\n\n";
+
+exit(0);


Property changes on: pve2-api-doc/data/extractapi.pl
___________________________________________________________________
Added: svn:executable
   + 

Added: pve2-api-doc/debian/README
===================================================================
--- pve2-api-doc/debian/README	                        (rev 0)
+++ pve2-api-doc/debian/README	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,11 @@
+To enable the apache site use:
+
+# a2ensite pve2-api-doc.conf
+# /etc/init.d/apache2 reload
+
+Now you should be able to access the documentation at:
+
+http://your-server/pve2-api-doc
+
+
+

Added: pve2-api-doc/debian/changelog
===================================================================
--- pve2-api-doc/debian/changelog	                        (rev 0)
+++ pve2-api-doc/debian/changelog	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,5 @@
+pve2-api-doc (2.0-1) unstable; urgency=low
+
+  * first try
+
+ -- root <root at maui.maurer-it.com>  Thu, 16 Jun 2011 11:55:06 +0200

Added: pve2-api-doc/debian/compat
===================================================================
--- pve2-api-doc/debian/compat	                        (rev 0)
+++ pve2-api-doc/debian/compat	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1 @@
+7

Added: pve2-api-doc/debian/control
===================================================================
--- pve2-api-doc/debian/control	                        (rev 0)
+++ pve2-api-doc/debian/control	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,12 @@
+Source: pve2-api-doc
+Section: doc
+Priority: extra
+Maintainer: Proxmox Support Team <support at proxmox.com>
+Build-Depends: debhelper (>= 7.0.50~), pve-manager (= 2.0-1)
+Standards-Version: 3.8.4
+
+Package: pve2-api-doc
+Architecture: all
+Depends: ${misc:Depends}
+Description: Proxmox VE API documentation
+ Contains the Proxmox VE API documentation viewer (ExtJS application).

Added: pve2-api-doc/debian/copyright
===================================================================
--- pve2-api-doc/debian/copyright	                        (rev 0)
+++ pve2-api-doc/debian/copyright	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,16 @@
+Copyright (C) 2010 Proxmox Server Solutions GmbH
+
+This software is written by Proxmox Server Solutions GmbH <support at proxmox.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.

Added: pve2-api-doc/debian/pve2-api-doc.conf
===================================================================
--- pve2-api-doc/debian/pve2-api-doc.conf	                        (rev 0)
+++ pve2-api-doc/debian/pve2-api-doc.conf	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,7 @@
+<Directory /usr/share/pve2-api-doc>
+	AllowOverride None
+	Order allow,deny
+        allow from all
+</Directory>
+
+Alias /pve2-api-doc /usr/share/pve2-api-doc/apidoc.html

Added: pve2-api-doc/debian/rules
===================================================================
--- pve2-api-doc/debian/rules	                        (rev 0)
+++ pve2-api-doc/debian/rules	2011-06-16 11:22:27 UTC (rev 6090)
@@ -0,0 +1,17 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+%:
+	dh $@ 
+
+override_dh_install:
+	dh_install
+	install -D -m 0644 debian/pve2-api-doc.conf ${DESTDIR}/etc/apache2/sites-available/pve2-api-doc.conf
\ No newline at end of file


Property changes on: pve2-api-doc/debian/rules
___________________________________________________________________
Added: svn:executable
   + 




More information about the pve-devel mailing list