[Kimchi-devel] [PATCH] [Wok 3/3] Bug fix #177: Fix Sample plugin according to latest changes on Wok

Aline Manera alinefm at linux.vnet.ibm.com
Mon Oct 31 18:56:03 UTC 2016


This patch:
    - moves API configuration from sample.conf.in to root.py
    - adds /config API to return Sample version
    - adds Wok log as Sample logo to be displayed when Sample is enabled
    - does not auto generate sample.conf from sample.conf.in
    - moves HTML files under ui/pages/tabs
    - updates tab-ext.xml file to add plugin color

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 .gitignore                                         |   1 -
 IBM-license-blacklist                              |   1 -
 src/wok/plugins/sample/__init__.py                 |  80 +---------
 src/wok/plugins/sample/model.py                    |  37 +++--
 src/wok/plugins/sample/po/POTFILES.in              |   4 +-
 src/wok/plugins/sample/po/en_US.po                 |  48 +++++-
 src/wok/plugins/sample/po/gen-pot                  |  28 ----
 src/wok/plugins/sample/po/pt_BR.po                 |  48 +++++-
 src/wok/plugins/sample/po/sample.pot               |  48 +++++-
 src/wok/plugins/sample/po/update-po                |  34 ++++
 src/wok/plugins/sample/po/zh_CN.po                 |  48 +++++-
 src/wok/plugins/sample/root.py                     | 171 +++++++++++++++++++++
 src/wok/plugins/sample/sample.conf                 |   3 +
 src/wok/plugins/sample/sample.conf.in              |  27 ----
 src/wok/plugins/sample/ui/config/tab-ext.xml       |  13 +-
 src/wok/plugins/sample/ui/images/sample.svg        |  45 ++++++
 src/wok/plugins/sample/ui/pages/i18n.json.tmpl     |   3 +-
 .../plugins/sample/ui/pages/sample-tab1.html.tmpl  |  32 ----
 .../plugins/sample/ui/pages/sample-tab2.html.tmpl  |  32 ----
 .../sample/ui/pages/tabs/sample-tab1.html.tmpl     |  39 +++++
 .../sample/ui/pages/tabs/sample-tab2.html.tmpl     |  39 +++++
 21 files changed, 553 insertions(+), 228 deletions(-)
 delete mode 100755 src/wok/plugins/sample/po/gen-pot
 create mode 100755 src/wok/plugins/sample/po/update-po
 create mode 100644 src/wok/plugins/sample/root.py
 create mode 100644 src/wok/plugins/sample/sample.conf
 delete mode 100644 src/wok/plugins/sample/sample.conf.in
 create mode 100644 src/wok/plugins/sample/ui/images/sample.svg
 delete mode 100644 src/wok/plugins/sample/ui/pages/sample-tab1.html.tmpl
 delete mode 100644 src/wok/plugins/sample/ui/pages/sample-tab2.html.tmpl
 create mode 100644 src/wok/plugins/sample/ui/pages/tabs/sample-tab1.html.tmpl
 create mode 100644 src/wok/plugins/sample/ui/pages/tabs/sample-tab2.html.tmpl

diff --git a/.gitignore b/.gitignore
index d06f936..8e2e115 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,7 +36,6 @@ src/wok/config.py
 tests/run_tests.sh
 tests/test_config.py
 src/wok/plugins/sample/po/POTFILES
-src/wok/plugins/sample/sample.conf
 ui/pages/help/*/*.html
 po/POTFILES
 po/gen-pot
diff --git a/IBM-license-blacklist b/IBM-license-blacklist
index e0188ba..79243a9 100644
--- a/IBM-license-blacklist
+++ b/IBM-license-blacklist
@@ -34,7 +34,6 @@ src/wok/plugins/sample/API.json
 src/wok/plugins/sample/po/LINGUAS
 src/wok/plugins/sample/po/POTFILES.in
 src/wok/plugins/sample/po/sample.pot
-src/wok/plugins/sample/sample.conf.in
 src/wok/plugins/sample/ui/config/tab-ext.xml
 src/wok/plugins/sample/ui/pages/help/en_US/.*.html
 ui/base64/README.md
diff --git a/src/wok/plugins/sample/__init__.py b/src/wok/plugins/sample/__init__.py
index ff96b15..3baf416 100644
--- a/src/wok/plugins/sample/__init__.py
+++ b/src/wok/plugins/sample/__init__.py
@@ -19,81 +19,5 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
-import json
-import os
-from cherrypy import expose
-
-
-from wok.config import PluginPaths
-from wok.control.base import Collection, Resource
-from wok.root import WokRoot
-
-
-from plugins.sample.i18n import messages
-from plugins.sample.model import Model
-
-
-model = Model()
-
-
-class Drawings(WokRoot):
-    def __init__(self, wok_options):
-        Resource.__init__(self, model)
-        self.description = Description(model)
-        self.rectangles = Rectangles(model)
-        self.circles = Circles(model)
-        self.paths = PluginPaths('sample')
-        self.domain = 'sample'
-        self.messages = messages
-        self.api_schema = json.load(open(os.path.join(os.path.dirname(
-                                    os.path.abspath(__file__)), 'API.json')))
-
-    @expose
-    def index(self):
-        return 'This is a sample plugin for Wok'
-
-
-class Description(Resource):
-    def __init__(self, model):
-        super(Description, self).__init__(model)
-
-    @property
-    def data(self):
-        return {'name': 'sample', 'version': '0.1'}
-
-
-class Circles(Collection):
-    def __init__(self, model):
-        super(Circles, self).__init__(model)
-        self.resource = Circle
-        self.admin_methods = ['POST', 'PUT']
-
-
-class Rectangles(Collection):
-    def __init__(self, model):
-        super(Rectangles, self).__init__(model)
-        self.resource = Rectangle
-        self.admin_methods = ['POST', 'PUT']
-
-
-class Circle(Resource):
-    def __init__(self, model, ident):
-        super(Circle, self).__init__(model, ident)
-        self.update_params = ['radius']
-
-    @property
-    def data(self):
-        ret = {'name': self.ident}
-        ret.update(self.info)
-        return ret
-
-
-class Rectangle(Resource):
-    def __init__(self, model, ident):
-        super(Rectangle, self).__init__(model, ident)
-        self.update_params = ['length', 'width']
-
-    @property
-    def data(self):
-        self.info.update({'name': self.ident})
-        return self.info
+from wok.plugins.sample.root import Sample
+__all__ = [Sample]
diff --git a/src/wok/plugins/sample/model.py b/src/wok/plugins/sample/model.py
index 489aa15..6bfc6b1 100644
--- a/src/wok/plugins/sample/model.py
+++ b/src/wok/plugins/sample/model.py
@@ -23,6 +23,14 @@ from wok.basemodel import BaseModel
 from wok.exception import InvalidOperation, NotFoundError
 
 
+class ConfigModel(object):
+    def __init__(self):
+        pass
+
+    def lookup(self, *name):
+        return {'version': '2.3.0'}
+
+
 class CirclesModel(object):
     def __init__(self):
         self._circles = {}
@@ -110,18 +118,6 @@ class RectangleModel(object):
             pass
 
 
-class Model(BaseModel):
-    def __init__(self):
-        circles = CirclesModel()
-        circle = CircleModel(circles)
-
-        rectangles = RectanglesModel()
-        rectangle = RectangleModel(rectangles)
-
-        return super(Model, self).__init__(
-            [circle, circles, rectangle, rectangles])
-
-
 class Rectangle(object):
     def __init__(self, length, width):
         self.length = length
@@ -131,3 +127,20 @@ class Rectangle(object):
 class Circle(object):
     def __init__(self, radius):
         self.radius = radius
+
+
+"""
+All model instances must be grouped into one Model class as below.
+"""
+class Model(BaseModel):
+    def __init__(self):
+        config = ConfigModel()
+
+        circles = CirclesModel()
+        circle = CircleModel(circles)
+
+        rectangles = RectanglesModel()
+        rectangle = RectangleModel(rectangles)
+
+        return super(Model, self).__init__(
+            [config, circle, circles, rectangle, rectangles])
diff --git a/src/wok/plugins/sample/po/POTFILES.in b/src/wok/plugins/sample/po/POTFILES.in
index 0aaf102..1055573 100644
--- a/src/wok/plugins/sample/po/POTFILES.in
+++ b/src/wok/plugins/sample/po/POTFILES.in
@@ -1,2 +1,2 @@
-# List of source files which contain translatable strings.
-src/wok/plugins/sample/ui/pages/*.tmpl
+../ui/pages/*.tmpl
+../i18n.py
diff --git a/src/wok/plugins/sample/po/en_US.po b/src/wok/plugins/sample/po/en_US.po
index 40b23e9..c035905 100644
--- a/src/wok/plugins/sample/po/en_US.po
+++ b/src/wok/plugins/sample/po/en_US.po
@@ -17,5 +17,49 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: pygettext.py 1.5\n"
 
-msgid "SampleTab"
-msgstr "SampleTab"
+msgid "SampleTab1"
+msgstr "Sample Tab 1"
+
+msgid "SampleTab2"
+msgstr "Sample Tab 2"
+
+#, python-format
+msgid "Unkown parameter specified %(value)s"
+msgstr ""
+
+#, python-format
+msgid "The specified value %(value)s is not a positive number"
+msgstr ""
+
+#, python-format
+msgid "Circle %(name)s does not exist"
+msgstr ""
+
+msgid "Specify name and radius to create a Circle"
+msgstr ""
+
+msgid "Circle name must be a string"
+msgstr ""
+
+msgid "Circle radius must be a positive number"
+msgstr ""
+
+#, python-format
+msgid "Rectangle %(name)s already exists"
+msgstr ""
+
+#, python-format
+msgid "Rectangle %(name)s does not exist"
+msgstr ""
+
+msgid "Specify name, length and width to create a Rectangle"
+msgstr ""
+
+msgid "Rectangle name must be a string"
+msgstr ""
+
+msgid "Rectangle length must be a positive number"
+msgstr ""
+
+msgid "Rectangle width must be a positive number"
+msgstr ""
diff --git a/src/wok/plugins/sample/po/gen-pot b/src/wok/plugins/sample/po/gen-pot
deleted file mode 100755
index e16bf25..0000000
--- a/src/wok/plugins/sample/po/gen-pot
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-#
-# Project Wok
-#
-# Copyright IBM Corp, 2015-2016
-#
-# Code derived from Project Kimchi
-#
-# 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
-
-for src in $@; do
-    if [ ${src: -3} == ".py" ]; then
-        cat $src
-    else
-        cat $src | cheetah compile -
-    fi
-done | xgettext --no-location -o sample.pot -L Python -
diff --git a/src/wok/plugins/sample/po/pt_BR.po b/src/wok/plugins/sample/po/pt_BR.po
index 715fdb3..b91fd5b 100644
--- a/src/wok/plugins/sample/po/pt_BR.po
+++ b/src/wok/plugins/sample/po/pt_BR.po
@@ -20,5 +20,49 @@ msgstr ""
 "X-Poedit-Language: Portuguese\n"
 "X-Poedit-SourceCharset: utf-8\n"
 
-msgid "SampleTab"
-msgstr "Tab de exemplo"
+msgid "SampleTab1"
+msgstr "Aba de Exemplo 1"
+
+msgid "SampleTab2"
+msgstr "Aba de Exemplo 2"
+
+#, python-format
+msgid "Unkown parameter specified %(value)s"
+msgstr ""
+
+#, python-format
+msgid "The specified value %(value)s is not a positive number"
+msgstr ""
+
+#, python-format
+msgid "Circle %(name)s does not exist"
+msgstr ""
+
+msgid "Specify name and radius to create a Circle"
+msgstr ""
+
+msgid "Circle name must be a string"
+msgstr ""
+
+msgid "Circle radius must be a positive number"
+msgstr ""
+
+#, python-format
+msgid "Rectangle %(name)s already exists"
+msgstr ""
+
+#, python-format
+msgid "Rectangle %(name)s does not exist"
+msgstr ""
+
+msgid "Specify name, length and width to create a Rectangle"
+msgstr ""
+
+msgid "Rectangle name must be a string"
+msgstr ""
+
+msgid "Rectangle length must be a positive number"
+msgstr ""
+
+msgid "Rectangle width must be a positive number"
+msgstr ""
diff --git a/src/wok/plugins/sample/po/sample.pot b/src/wok/plugins/sample/po/sample.pot
index 661fd74..701939f 100644
--- a/src/wok/plugins/sample/po/sample.pot
+++ b/src/wok/plugins/sample/po/sample.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2016-06-24 09:46-0300\n"
+"POT-Creation-Date: 2016-10-31 16:22-0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
 "Language-Team: LANGUAGE <LL at li.org>\n"
@@ -17,5 +17,49 @@ msgstr ""
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "SampleTab"
+msgid "SampleTab1"
+msgstr ""
+
+msgid "SampleTab2"
+msgstr ""
+
+#, python-format
+msgid "Unkown parameter specified %(value)s"
+msgstr ""
+
+#, python-format
+msgid "The specified value %(value)s is not a positive number"
+msgstr ""
+
+#, python-format
+msgid "Circle %(name)s does not exist"
+msgstr ""
+
+msgid "Specify name and radius to create a Circle"
+msgstr ""
+
+msgid "Circle name must be a string"
+msgstr ""
+
+msgid "Circle radius must be a positive number"
+msgstr ""
+
+#, python-format
+msgid "Rectangle %(name)s already exists"
+msgstr ""
+
+#, python-format
+msgid "Rectangle %(name)s does not exist"
+msgstr ""
+
+msgid "Specify name, length and width to create a Rectangle"
+msgstr ""
+
+msgid "Rectangle name must be a string"
+msgstr ""
+
+msgid "Rectangle length must be a positive number"
+msgstr ""
+
+msgid "Rectangle width must be a positive number"
 msgstr ""
diff --git a/src/wok/plugins/sample/po/update-po b/src/wok/plugins/sample/po/update-po
new file mode 100755
index 0000000..b9c464f
--- /dev/null
+++ b/src/wok/plugins/sample/po/update-po
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# Project Wok
+#
+# Copyright IBM Corp, 2016
+#
+# Code derived from Project Kimchi
+#
+# 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
+
+for src in `cat POTFILES.in`; do
+    if [ ${src: -3} == ".py" ]; then
+        cat $src
+    else
+        cat $src | cheetah compile -
+    fi
+done | xgettext --no-location -o sample.pot -L Python -
+
+for lingua in `cat LINGUAS`; do
+    msgmerge --update --no-fuzzy-matching --backup=off $lingua.po sample.pot 
+    msgfmt -c --statistics --verbose -o $lingua.gmo $lingua.po
+done
+
diff --git a/src/wok/plugins/sample/po/zh_CN.po b/src/wok/plugins/sample/po/zh_CN.po
index ddf2d83..6f16bfb 100644
--- a/src/wok/plugins/sample/po/zh_CN.po
+++ b/src/wok/plugins/sample/po/zh_CN.po
@@ -20,5 +20,49 @@ msgstr ""
 "X-Poedit-Language: Chinese\n"
 "X-Poedit-SourceCharset: utf-8\n"
 
-msgid "SampleTab"
-msgstr "示例标签"
+msgid "SampleTab1"
+msgstr "示例标签 1"
+
+msgid "SampleTab2"
+msgstr "示例标签 2"
+
+#, python-format
+msgid "Unkown parameter specified %(value)s"
+msgstr ""
+
+#, python-format
+msgid "The specified value %(value)s is not a positive number"
+msgstr ""
+
+#, python-format
+msgid "Circle %(name)s does not exist"
+msgstr ""
+
+msgid "Specify name and radius to create a Circle"
+msgstr ""
+
+msgid "Circle name must be a string"
+msgstr ""
+
+msgid "Circle radius must be a positive number"
+msgstr ""
+
+#, python-format
+msgid "Rectangle %(name)s already exists"
+msgstr ""
+
+#, python-format
+msgid "Rectangle %(name)s does not exist"
+msgstr ""
+
+msgid "Specify name, length and width to create a Rectangle"
+msgstr ""
+
+msgid "Rectangle name must be a string"
+msgstr ""
+
+msgid "Rectangle length must be a positive number"
+msgstr ""
+
+msgid "Rectangle width must be a positive number"
+msgstr ""
diff --git a/src/wok/plugins/sample/root.py b/src/wok/plugins/sample/root.py
new file mode 100644
index 0000000..ae974ac
--- /dev/null
+++ b/src/wok/plugins/sample/root.py
@@ -0,0 +1,171 @@
+#
+# Project Wok
+#
+# Copyright IBM Corp, 2016
+#
+# Code derived from Project Kimchi
+#
+# 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
+
+import json
+import os
+
+from wok.config import CACHEEXPIRES, PluginConfig, PluginPaths
+from wok.control.base import Collection, Resource
+from wok.control.utils import UrlSubNode
+from wok.plugins.sample.i18n import messages
+from wok.plugins.sample.model import Model
+from wok.root import WokRoot
+
+
+samplePaths = PluginPaths('sample')
+
+
+"""
+The main class must be the plugin name starting with upper case. In this case,
+Sample. The Sample class is a WokRoot instance with plugin specific details.
+
+Each class attribute which is a Resource or a Collection will be translated as
+a new REST API. So self.config to /config API, self.description to
+/description API and so on.
+
+self.paths represents the plugin paths. Usually it is PluginPath(<plugin-name>)
+
+self.domain is the gettext domain name. Usually it is the plugin name.
+
+self.messages is a list of all i18n messages used on backend side.
+The messages used on UI are placed at ui/pages/i18n.json.tmpl
+
+self.api_schema is the JSON Schema document necessary to validate each REST API
+created by the plugin.
+"""
+class Sample(WokRoot):
+    def __init__(self, wok_options):
+        self.model = Model()
+        super(Sample, self).__init__(self.model)
+        self.config = Config(self.model)
+        self.description = Description(self.model)
+        self.rectangles = Rectangles(self.model)
+        self.circles = Circles(self.model)
+
+        self.paths = samplePaths
+        self.domain = 'sample'
+        self.messages = messages
+        self.api_schema = json.load(open(os.path.join(os.path.dirname(
+                                    os.path.abspath(__file__)), 'API.json')))
+
+
+    """
+    Re-write get_custom_conf() to expose static directories and files.
+    It is for those APIs which do not rely on any backend logic to exist.
+    """
+    def get_custom_conf(self):
+        return SampleConfig()
+
+
+"""
+Static directories and files configuration for Sample plugin.
+
+The configuration is a dictionary supported by cherrypy.
+"""
+class SampleConfig(PluginConfig):
+    def __init__(self):
+        super(SampleConfig, self).__init__('sample')
+
+        custom_config ={
+            '/js': {
+                'tools.staticdir.on': True,
+                'tools.staticdir.dir': os.path.join(samplePaths.ui_dir, 'js'),
+                'tools.wokauth.on': False,
+                'tools.nocache.on': False,
+                'tools.expires.on': True,
+                'tools.expires.secs': CACHEEXPIRES
+            },
+            '/images': {
+                'tools.wokauth.on': False,
+                'tools.nocache.on': False,
+                'tools.staticdir.dir': os.path.join(samplePaths.ui_dir,
+                                                    'images'),
+                'tools.staticdir.on': True
+            },
+            '/help': {'tools.nocache.on': True,
+                      'tools.staticdir.dir': os.path.join(samplePaths.ui_dir,
+                                                          'pages/help'),
+                      'tools.staticdir.on': True},
+        }
+
+        self.update(custom_config)
+
+
+
+"""
+All the classes below correspond to a REST API.
+"""
+class Config(Resource):
+    def __init__(self, model):
+        super(Config, self).__init__(model)
+
+    @property
+    def data(self):
+        return self.info
+
+
+
+class Description(Resource):
+    def __init__(self, model):
+        super(Description, self).__init__(model)
+
+    @property
+    def data(self):
+        return {'name': 'sample', 'version': '2.3.0'}
+
+
+ at UrlSubNode('circles', True)
+class Circles(Collection):
+    def __init__(self, model):
+        super(Circles, self).__init__(model)
+        self.resource = Circle
+        self.admin_methods = ['POST', 'PUT']
+
+
+ at UrlSubNode('rectangles', True)
+class Rectangles(Collection):
+    def __init__(self, model):
+        super(Rectangles, self).__init__(model)
+        self.resource = Rectangle
+        self.admin_methods = ['POST', 'PUT']
+
+
+class Circle(Resource):
+    def __init__(self, model, ident):
+        super(Circle, self).__init__(model, ident)
+        self.update_params = ['radius']
+
+    @property
+    def data(self):
+        ret = {'name': self.ident}
+        ret.update(self.info)
+        return ret
+
+
+class Rectangle(Resource):
+    def __init__(self, model, ident):
+        super(Rectangle, self).__init__(model, ident)
+        self.update_params = ['length', 'width']
+
+    @property
+    def data(self):
+        self.info.update({'name': self.ident})
+        return self.info
diff --git a/src/wok/plugins/sample/sample.conf b/src/wok/plugins/sample/sample.conf
new file mode 100644
index 0000000..fcbefe9
--- /dev/null
+++ b/src/wok/plugins/sample/sample.conf
@@ -0,0 +1,3 @@
+[wok]
+# Enable Sample plugin on Wok server (values: True|False)
+enable = False
diff --git a/src/wok/plugins/sample/sample.conf.in b/src/wok/plugins/sample/sample.conf.in
deleted file mode 100644
index 75ea5b0..0000000
--- a/src/wok/plugins/sample/sample.conf.in
+++ /dev/null
@@ -1,27 +0,0 @@
-[wok]
-enable = False
-plugin_class = "Drawings"
-uri = "/plugins/sample"
-
-[/]
-tools.nocache.on = True
-tools.trailing_slash.on = False
-tools.sessions.on = True
-tools.sessions.name = 'wok'
-tools.sessions.httponly = True
-tools.sessions.locking = 'explicit'
-tools.sessions.storage_type = 'ram'
-
-[/description]
-tools.wokauth.on = True
-
-[/rectangles]
-tools.wokauth.on = True
-
-[/circles]
-tools.wokauth.on = True
-
-[/help]
-tools.staticdir.on = True
-tools.nocache.on = True
-tools.staticdir.dir = wok.config.PluginPaths('sample').ui_dir + '/pages/help'
diff --git a/src/wok/plugins/sample/ui/config/tab-ext.xml b/src/wok/plugins/sample/ui/config/tab-ext.xml
index aff0d14..e3d2336 100644
--- a/src/wok/plugins/sample/ui/config/tab-ext.xml
+++ b/src/wok/plugins/sample/ui/config/tab-ext.xml
@@ -1,17 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>
 <tabs-ext>
+    <functionality colorTab1="#B404AE" colorTab2="#DF01D7">Sample</functionality>
     <tab>
         <access role="admin" mode="admin"/>
         <access role="user" mode="none"/>
-
-        <title>SampleTab 1</title>
-        <path>plugins/sample/sample-tab1.html</path>
+        <title>SampleTab1</title>
+        <path>plugins/sample/tabs/sample-tab1.html</path>
+        <order>85</order>
     </tab>
     <tab>
         <access role="admin" mode="admin"/>
         <access role="user" mode="none"/>
-
-        <title>SampleTab 2</title>
-        <path>plugins/sample/sample-tab2.html</path>
+        <title>SampleTab2</title>
+        <path>plugins/sample/tabs/sample-tab2.html</path>
+        <order>90</order>
     </tab>
 </tabs-ext>
diff --git a/src/wok/plugins/sample/ui/images/sample.svg b/src/wok/plugins/sample/ui/images/sample.svg
new file mode 100644
index 0000000..44c516b
--- /dev/null
+++ b/src/wok/plugins/sample/ui/images/sample.svg
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg version="1.1" id="Wok" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
+     <title
+     id="title">Wok</title>
+    <metadata
+     id="license">
+        <rdf:RDF>
+            <cc:Work rdf:about="">
+            <dc:format>image/svg+xml</dc:format>
+            <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+            <dc:title>Wok</dc:title>
+            <cc:license rdf:resource="http://www.apache.org/licenses/LICENSE-2.0" />
+            <dc:date>2016</dc:date>
+            <dc:creator>
+                <cc:Agent>
+                    <dc:title>IBM, Corp.</dc:title>
+                </cc:Agent>
+            </dc:creator>
+            <dc:rights>
+                <cc:Agent>
+                    <dc:title>IBM, Corp.</dc:title>
+                </cc:Agent>
+            </dc:rights>
+            <dc:publisher>
+                <cc:Agent>
+                    <dc:title>IBM, Corp.</dc:title>
+                </cc:Agent>
+            </dc:publisher>
+            <dc:contributor>
+                <cc:Agent>
+                    <dc:title>https://github.com/kimchi-project/wok</dc:title>
+                </cc:Agent>
+            </dc:contributor>
+            <dc:description>Wok is a cherrypy-based web framework with HTML5 support originated from Kimchi. It can be extended by plugins which expose functionality through REST APIs.</dc:description>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+<style type="text/css">
+    .st0{fill:#F73434;}
+</style>
+<g>
+    <path class="st0" d="M439.2,176.3c0.4-5.1,0.7-10.3,0.7-15.6h-6.3h-16.3H82.7h-7.2H60.1c0,5.3,0.3,10.5,0.7,15.6H24.4v31.4h41.9
+        c20.9,77.5,92.9,131.6,183.7,131.6s162.9-54,183.7-131.6h41.9v-31.4H439.2z"/>
+</g>
+</svg>
\ No newline at end of file
diff --git a/src/wok/plugins/sample/ui/pages/i18n.json.tmpl b/src/wok/plugins/sample/ui/pages/i18n.json.tmpl
index 124ac30..cab58ee 100644
--- a/src/wok/plugins/sample/ui/pages/i18n.json.tmpl
+++ b/src/wok/plugins/sample/ui/pages/i18n.json.tmpl
@@ -24,5 +24,6 @@
 #silent _ = t.gettext
 #silent _t = t.gettext
 {
-    "SampleTab": "$_("SampleTab")"
+    "SampleTab1": "$_("SampleTab1")",
+    "SampleTab2": "$_("SampleTab2")"
 }
diff --git a/src/wok/plugins/sample/ui/pages/sample-tab1.html.tmpl b/src/wok/plugins/sample/ui/pages/sample-tab1.html.tmpl
deleted file mode 100644
index 2777848..0000000
--- a/src/wok/plugins/sample/ui/pages/sample-tab1.html.tmpl
+++ /dev/null
@@ -1,32 +0,0 @@
-#*
- * Project Wok
- *
- * Copyright IBM Corp, 2015-2016
- *
- * Code derived from Project Kimchi
- *
- * 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>
diff --git a/src/wok/plugins/sample/ui/pages/sample-tab2.html.tmpl b/src/wok/plugins/sample/ui/pages/sample-tab2.html.tmpl
deleted file mode 100644
index 2777848..0000000
--- a/src/wok/plugins/sample/ui/pages/sample-tab2.html.tmpl
+++ /dev/null
@@ -1,32 +0,0 @@
-#*
- * Project Wok
- *
- * Copyright IBM Corp, 2015-2016
- *
- * Code derived from Project Kimchi
- *
- * 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>
diff --git a/src/wok/plugins/sample/ui/pages/tabs/sample-tab1.html.tmpl b/src/wok/plugins/sample/ui/pages/tabs/sample-tab1.html.tmpl
new file mode 100644
index 0000000..9a0d678
--- /dev/null
+++ b/src/wok/plugins/sample/ui/pages/tabs/sample-tab1.html.tmpl
@@ -0,0 +1,39 @@
+#*
+ * Project Wok
+ *
+ * Copyright IBM Corp, 2016
+ *
+ * Code derived from Project Kimchi
+ *
+ * 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>
+<head>
+    <link rel="stylesheet" href="plugins/sample/css/sample.css">
+    <script type="text/javascript" src="plugins/sample/js/util.js"></script>
+</head>
+<body>
+  <div id="sample-root-container">
+    <div id="samplebody"/>
+</div>
+</body>
+<script>
+    sample.description(function(r){
+        \$("#samplebody").html("name: " + r.name + " version: " + r.version);
+    });
+</script>
+</html>
diff --git a/src/wok/plugins/sample/ui/pages/tabs/sample-tab2.html.tmpl b/src/wok/plugins/sample/ui/pages/tabs/sample-tab2.html.tmpl
new file mode 100644
index 0000000..9a0d678
--- /dev/null
+++ b/src/wok/plugins/sample/ui/pages/tabs/sample-tab2.html.tmpl
@@ -0,0 +1,39 @@
+#*
+ * Project Wok
+ *
+ * Copyright IBM Corp, 2016
+ *
+ * Code derived from Project Kimchi
+ *
+ * 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>
+<head>
+    <link rel="stylesheet" href="plugins/sample/css/sample.css">
+    <script type="text/javascript" src="plugins/sample/js/util.js"></script>
+</head>
+<body>
+  <div id="sample-root-container">
+    <div id="samplebody"/>
+</div>
+</body>
+<script>
+    sample.description(function(r){
+        \$("#samplebody").html("name: " + r.name + " version: " + r.version);
+    });
+</script>
+</html>
-- 
2.7.4




More information about the Kimchi-devel mailing list