
on 2014/06/10 21:24, Aline Manera wrote:
On 06/09/2014 11:20 PM, Zhou Zheng Sheng wrote:
on 2014/06/10 03:21, Aline Manera wrote:
On 06/09/2014 07:08 AM, shaohef@linux.vnet.ibm.com wrote:
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> --- plugins/sample/__init__.py | 3 ++- plugins/sample/sample.conf | 5 +++++ plugins/sample/ui/config/tab-ext.xml | 8 ++++---- plugins/sample/ui/pages/i18n.json.tmpl | 9 +++++++++ plugins/sample/ui/pages/tab.html.tmpl | 6 ++++++ 5 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 plugins/sample/ui/pages/i18n.json.tmpl create mode 100644 plugins/sample/ui/pages/tab.html.tmpl
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..78a9f4e 100644 --- a/plugins/sample/sample.conf +++ b/plugins/sample/sample.conf @@ -5,3 +5,8 @@ uri = "/plugins/sample"
[/] 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' 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> The UI files should be in a dedicated dir, as we have for kimchi And we could remove tab.html (which does not have any meaning) to sampleplugin.html or something like that
Hi, this file is not handle by back-end. It's just served by back-end, and the front-end parses this file to get the clue on where the html file of the plugin is.
So "plugins/sample/ui/tab.html" here is a virtual URI, which is mapped to pages/tab.html under the specific ui dir of this plugin.
1. This patch set uses plugins/sample/tab/html instead of plugins/sample/ui/tab.html
Sorry! I wanted to say "plugins/sample/tab.html is virtual URI", and "plugins/sample/ui/tab.htmls" is the real file. Sorry for the misleading.
2. Where is the map to pages/tab.html?
It works like this: 1. plugins.sample.Drawings inherits Root, and it is mounted on URI "/plugins/sample". It also sets "self.paths = PluginPaths('sample')" 2. GET plugins/sample/tab.html -> Drawings(Root).default("tab.html") -> template.render("tab.html"). 3. When the template needs to get the actual template file name, it calls paths = cherrypy.request.app.root.paths filename = paths.get_template_path(resource) So here paths is actually "PluginPaths('sample')", and calling paths.get_template_path() returns the result of os.path.join(self.ui_dir, 'pages/%s.tmpl' % resource) So actually the filename is self.ui_dir + 'pages/tab.html' and PluginPaths.__init__ sets self.ui_dir = self.add_prefix(os.path.join(self.plugin_dir, 'ui')) so at last the filename is 'plugins/sample/ui' + 'pages/tab.html' Let me add Mark Wu to the cc list. He is the designer of the plugin framework.
It's ok that we change it to sampleplugin.html, but since it's under the plugin specific ui dir already, a tab.html is also ok I think.
</tab> -</tabs-ext>--> \ No newline at end of file +</tabs-ext> 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..49fc4ec --- /dev/null +++ b/plugins/sample/ui/pages/tab.html.tmpl @@ -0,0 +1,6 @@ +<!DOCTYPE html> +<html> +<body> +Hello, world +</body> +</html>
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
-- Zhou Zheng Sheng / 周征晟 E-mail: zhshzhou@linux.vnet.ibm.com Telephone: 86-10-82454397