Changeset
src/wok/root.py | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
Git apply log
Switched to a new branch '20170303011231.431-1-alinefm@linux.vnet.ibm.com'
Applying: Allow a plugin extends any HTML page from another one instead of only tabs content
To https://github.com/patchew-project/kimchi-wok
 + 635e6f6...99dc51b patchew/20170303011231.431-1-alinefm@linux.vnet.ibm.com -> patchew/20170303011231.431-1-alinefm@linux.vnet.ibm.com (forced update)
Test passed: Unit Tests

loading

[Kimchi-devel] [PATCH] [Wok] Allow a plugin extends any HTML page from another one instead of only tabs content
Posted by Aline Manera, 37 weeks ago
Before this patch, a plugin could only extend anothers tab content.
With this patch, a plugin can extend any HTML page from others.

This is needed due the Ginger sidebar and Ginger s390x dependency.

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
---
 src/wok/root.py | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/wok/root.py b/src/wok/root.py
index c01c7d1..ea88c8c 100644
--- a/src/wok/root.py
+++ b/src/wok/root.py
@@ -101,6 +101,7 @@ class Root(Resource):
 
     @cherrypy.expose
     def default(self, page, **kwargs):
+        kwargs['scripts'] = self._get_scripts(page)
         if page.endswith('.html'):
             return template.render(page, kwargs)
         if page.endswith('.json'):
@@ -121,13 +122,7 @@ class Root(Resource):
 
         data = {}
         data['ui_dir'] = paths.ui_dir
-
-        data['scripts'] = []
-        for plugin, app in cherrypy.tree.apps.iteritems():
-                if app.root.extends is not None:
-                    scripts = app.root.extends.get(script_name, {})
-                    if page in scripts.keys():
-                        data['scripts'].append(scripts[page])
+        data['scripts'] = self._get_scripts(page)
 
         if page.endswith('.html'):
             context = template.render('/tabs/' + page, data)
@@ -136,6 +131,16 @@ class Root(Resource):
             return context
         raise cherrypy.HTTPError(404)
 
+    def _get_scripts(self, page):
+        result = []
+        script_name = cherrypy.request.app.script_name or "/"
+        for plugin, app in cherrypy.tree.apps.iteritems():
+            if app.root.extends is not None:
+                scripts = app.root.extends.get(script_name, {})
+                if page in scripts.keys():
+                    result.append(scripts[page])
+        return result
+
 
 class WokRoot(Root):
     def __init__(self, model, dev_env=False):
-- 
2.9.3

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel
Re: [Kimchi-devel] [PATCH] [Wok] Allow a plugin extends any HTML page from another one instead of only tabs content
Posted by Daniel Henrique Barboza, 37 weeks ago
Reviewed-by: Daniel Barboza <danielhb@linux.vnet.ibm.com>
Tested-by: Daniel Barboza <danielhb@linux.vnet.ibm.com>

On 03/02/2017 10:12 PM, Aline Manera wrote:
> Before this patch, a plugin could only extend anothers tab content.
> With this patch, a plugin can extend any HTML page from others.
>
> This is needed due the Ginger sidebar and Ginger s390x dependency.
>
> Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
> ---
>   src/wok/root.py | 19 ++++++++++++-------
>   1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/src/wok/root.py b/src/wok/root.py
> index c01c7d1..ea88c8c 100644
> --- a/src/wok/root.py
> +++ b/src/wok/root.py
> @@ -101,6 +101,7 @@ class Root(Resource):
>   
>       @cherrypy.expose
>       def default(self, page, **kwargs):
> +        kwargs['scripts'] = self._get_scripts(page)
>           if page.endswith('.html'):
>               return template.render(page, kwargs)
>           if page.endswith('.json'):
> @@ -121,13 +122,7 @@ class Root(Resource):
>   
>           data = {}
>           data['ui_dir'] = paths.ui_dir
> -
> -        data['scripts'] = []
> -        for plugin, app in cherrypy.tree.apps.iteritems():
> -                if app.root.extends is not None:
> -                    scripts = app.root.extends.get(script_name, {})
> -                    if page in scripts.keys():
> -                        data['scripts'].append(scripts[page])
> +        data['scripts'] = self._get_scripts(page)
>   
>           if page.endswith('.html'):
>               context = template.render('/tabs/' + page, data)
> @@ -136,6 +131,16 @@ class Root(Resource):
>               return context
>           raise cherrypy.HTTPError(404)
>   
> +    def _get_scripts(self, page):
> +        result = []
> +        script_name = cherrypy.request.app.script_name or "/"
> +        for plugin, app in cherrypy.tree.apps.iteritems():
> +            if app.root.extends is not None:
> +                scripts = app.root.extends.get(script_name, {})
> +                if page in scripts.keys():
> +                    result.append(scripts[page])
> +        return result
> +
>   
>   class WokRoot(Root):
>       def __init__(self, model, dev_env=False):

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel
Re: [Kimchi-devel] [PATCH] [Wok] Allow a plugin extends any HTML page from another one instead of only tabs content
Posted by Aline Manera, 37 weeks ago
Applied. Thanks.

Regards,

Aline Manera

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel