
From: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Add minimal UI just enough to re-produce issue 342. https://github.com/kimchi-project/kimchi/issues/342 Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- configure.ac | 2 ++ plugins/sample/__init__.py | 3 ++- plugins/sample/sample.conf | 17 +++++++++++++++++ plugins/sample/ui/Makefile.am | 2 +- plugins/sample/ui/config/tab-ext.xml | 8 ++++---- plugins/sample/ui/js/Makefile.am | 21 +++++++++++++++++++++ plugins/sample/ui/js/util.js | 33 +++++++++++++++++++++++++++++++++ plugins/sample/ui/pages/Makefile.am | 21 +++++++++++++++++++++ plugins/sample/ui/pages/i18n.json.tmpl | 9 +++++++++ plugins/sample/ui/pages/tab.html.tmpl | 30 ++++++++++++++++++++++++++++++ 10 files changed, 140 insertions(+), 6 deletions(-) create mode 100644 plugins/sample/ui/js/Makefile.am create mode 100644 plugins/sample/ui/js/util.js create mode 100644 plugins/sample/ui/pages/Makefile.am create mode 100644 plugins/sample/ui/pages/i18n.json.tmpl create mode 100644 plugins/sample/ui/pages/tab.html.tmpl diff --git a/configure.ac b/configure.ac index cc971e8..db87060 100644 --- a/configure.ac +++ b/configure.ac @@ -64,6 +64,8 @@ AC_CONFIG_FILES([ plugins/sample/Makefile plugins/sample/ui/Makefile plugins/sample/ui/config/Makefile + plugins/sample/ui/js/Makefile + plugins/sample/ui/pages/Makefile ui/Makefile ui/css/Makefile ui/css/novnc/Makefile diff --git a/plugins/sample/__init__.py b/plugins/sample/__init__.py index 3183898..2101aed 100644 --- a/plugins/sample/__init__.py +++ b/plugins/sample/__init__.py @@ -26,6 +26,7 @@ from kimchi.config import PluginPaths from kimchi.control.base import Collection, Resource +from kimchi.root import Root from plugins.sample.i18n import messages from plugins.sample.model import Model @@ -33,7 +34,7 @@ model = Model() -class Drawings(Resource): +class Drawings(Root): def __init__(self): Resource.__init__(self, model) self.description = Description(model) diff --git a/plugins/sample/sample.conf b/plugins/sample/sample.conf index c4e80f7..d4994e5 100644 --- a/plugins/sample/sample.conf +++ b/plugins/sample/sample.conf @@ -4,4 +4,21 @@ plugin_class = "Drawings" uri = "/plugins/sample" [/] +tools.nocache.on = True tools.trailing_slash.on = False +tools.sessions.on = True +tools.sessions.name = 'kimchi' +tools.sessions.httponly = True +tools.sessions.locking = 'explicit' +tools.sessions.storage_type = 'ram' + +[/description] +tools.kimchiauth.on = True + +[/rectangles] +tools.kimchiauth.on = True +tools.kimchiauth.admin_methods = ['POST', 'PUT'] + +[/circles] +tools.kimchiauth.on = True +tools.kimchiauth.admin_methods = ['POST', 'PUT'] diff --git a/plugins/sample/ui/Makefile.am b/plugins/sample/ui/Makefile.am index 0ee244f..37fec98 100644 --- a/plugins/sample/ui/Makefile.am +++ b/plugins/sample/ui/Makefile.am @@ -17,6 +17,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SUBDIRS = config +SUBDIRS = config js pages diff --git a/plugins/sample/ui/config/tab-ext.xml b/plugins/sample/ui/config/tab-ext.xml index 948fa07..8e0b3d3 100644 --- a/plugins/sample/ui/config/tab-ext.xml +++ b/plugins/sample/ui/config/tab-ext.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> -<!--<tabs-ext> +<tabs-ext> <tab> - <title>Test</title> - <filePath>plugins/sample/ui/tab.html</filePath> + <title>SampleTab</title> + <path>plugins/sample/tab.html</path> </tab> -</tabs-ext>--> \ No newline at end of file +</tabs-ext> diff --git a/plugins/sample/ui/js/Makefile.am b/plugins/sample/ui/js/Makefile.am new file mode 100644 index 0000000..c484049 --- /dev/null +++ b/plugins/sample/ui/js/Makefile.am @@ -0,0 +1,21 @@ +# +# Kimchi +# +# Copyright IBM Corp, 2014 +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +EXTRA_DIST = util.js + diff --git a/plugins/sample/ui/js/util.js b/plugins/sample/ui/js/util.js new file mode 100644 index 0000000..157ddde --- /dev/null +++ b/plugins/sample/ui/js/util.js @@ -0,0 +1,33 @@ +/* + * Project Kimchi + * + * Copyright IBM, Corp. 2014 + * + * 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. + */ + +sample = {}; + +sample.description = function(suc, err){ + kimchi.requestJSON({ + url : kimchi.url + 'plugins/sample/description', + type : 'GET', + contentType : 'application/json', + dataType : 'json', + resend : true, + success : suc, + error : err || function(data) { + kimchi.message.error(data.responseJSON.reason); + } + }); +}; diff --git a/plugins/sample/ui/pages/Makefile.am b/plugins/sample/ui/pages/Makefile.am new file mode 100644 index 0000000..f7a5c3c --- /dev/null +++ b/plugins/sample/ui/pages/Makefile.am @@ -0,0 +1,21 @@ +# +# Kimchi +# +# Copyright IBM Corp, 2014 +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +EXTRA_DIST = i18n.json.tmpl tab.html.tmpl + diff --git a/plugins/sample/ui/pages/i18n.json.tmpl b/plugins/sample/ui/pages/i18n.json.tmpl new file mode 100644 index 0000000..a153e2d --- /dev/null +++ b/plugins/sample/ui/pages/i18n.json.tmpl @@ -0,0 +1,9 @@ +#unicode UTF-8 +#import gettext +#from kimchi.cachebust import href +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang) +#silent _ = t.gettext +#silent _t = t.gettext +{ + "SampleTab": "$_("SampleTab")" +} diff --git a/plugins/sample/ui/pages/tab.html.tmpl b/plugins/sample/ui/pages/tab.html.tmpl new file mode 100644 index 0000000..4354d81 --- /dev/null +++ b/plugins/sample/ui/pages/tab.html.tmpl @@ -0,0 +1,30 @@ +#* + * Project Kimchi + * + * Copyright IBM, Corp. 2014 + * + * 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. + *# +#unicode UTF-8 +<!DOCTYPE html> +<html> +<script type="text/javascript" src="plugins/sample/js/util.js"></script> +<body> + <div id="samplebody"/> +</body> +<script> + sample.description(function(r){ + \$("#samplebody").html("name: " + r.name + " version: " + r.version); + }); +</script> +</html> -- 1.9.3