moksha/middleware
by John (J5) Palmieri
moksha/middleware/connector.py | 17 ++++++++++++++++-
moksha/middleware/extensionpoint.py | 16 +++++++++++++++-
moksha/middleware/middleware.py | 23 +++++++++++++++++++----
3 files changed, 50 insertions(+), 6 deletions(-)
New commits:
commit 84844a1437c216976d6701b0fe818c30b5cf9b9b
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Tue Apr 14 14:41:53 2009 -0400
strip the SCRIPT_NAME environ variable so we can work when mounted on any path
diff --git a/moksha/middleware/connector.py b/moksha/middleware/connector.py
index eca14b2..f940b94 100644
--- a/moksha/middleware/connector.py
+++ b/moksha/middleware/connector.py
@@ -48,13 +48,28 @@ class MokshaConnectorMiddleware(object):
self.application = application
self.load_connectors()
+ def strip_script(self, environ, path):
+ # Strips the script portion of a url path so the middleware works even
+ # when mounted under a path other than root
+ if path.startswith('/') and 'SCRIPT_NAME' in environ:
+ prefix = environ.get('SCRIPT_NAME')
+ if prefix.endswith('/'):
+ prefix = prefix[:-1]
+
+ if path.startswith(prefix):
+ path = path[len(prefix):]
+
+ return path
+
def __call__(self, environ, start_response):
request = Request(environ)
- if request.path.startswith('/moksha_connector'):
+ path = self.strip_script(environ, request.path)
+ if path.startswith('/moksha_connector'):
s = request.path.split('/')[2:]
+
# since keys are not unique we need to condense them
# into an actual dictionary with multiple entries becoming lists
p = request.params
diff --git a/moksha/middleware/extensionpoint.py b/moksha/middleware/extensionpoint.py
index a88250d..081e2b9 100644
--- a/moksha/middleware/extensionpoint.py
+++ b/moksha/middleware/extensionpoint.py
@@ -187,11 +187,25 @@ class MokshaExtensionPointMiddleware(object):
s = '[' + ','.join(value) + ']'
self.__extension_cache[key] = s
+ def strip_script(self, environ, path):
+ # Strips the script portion of a url path so the middleware works even
+ # when mounted under a path other than root
+ if path.startswith('/') and 'SCRIPT_NAME' in environ:
+ prefix = environ.get('SCRIPT_NAME')
+ if prefix.endswith('/'):
+ prefix = prefix[:-1]
+
+ if path.startswith(prefix):
+ path = path[len(prefix):]
+
+ return path
+
def __call__(self, environ, start_response):
request = Request(environ)
- if request.path.startswith('/moksha_extension_point'):
+ path = self.strip_script(environ, request.path)
+ if path.startswith('/moksha_extension_point'):
exttype = request.params.get('exttype')
if not exttype:
response = Response('')
diff --git a/moksha/middleware/middleware.py b/moksha/middleware/middleware.py
index 0438e71..bdb03f1 100644
--- a/moksha/middleware/middleware.py
+++ b/moksha/middleware/middleware.py
@@ -70,13 +70,28 @@ class MokshaMiddleware(object):
moksha.feed_storage = Shove(config['feed_cache'], compress=True)
moksha.feed_cache = Cache(moksha.feed_storage)
+ def strip_script(self, environ, path):
+ # Strips the script portion of a url path so the middleware works even
+ # when mounted under a path other than root
+ if path.startswith('/') and 'SCRIPT_NAME' in environ:
+ prefix = environ.get('SCRIPT_NAME')
+ if prefix.endswith('/'):
+ prefix = prefix[:-1]
+
+ if path.startswith(prefix):
+ path = path[len(prefix):]
+
+ return path
+
def __call__(self, environ, start_response):
self.register_stomp(environ)
request = Request(environ)
- if request.path.startswith('/apps/') or \
- request.path.startswith('/widget') or \
- request.path.startswith('/docs/') or \
- request.path.startswith('/moksha_admin/'):
+
+ path = self.strip_script(environ, request.path)
+ if path.startswith('/apps/') or \
+ path.startswith('/widget') or \
+ path.startswith('/docs/') or \
+ path.startswith('/moksha_admin/'):
response = request.get_response(self.mokshaapp)
else:
response = request.get_response(self.application)
15 years, 2 months
moksha/public
by John (J5) Palmieri
moksha/public/javascript/ui/moksha.ui.tabs.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
New commits:
commit 25957b45b4e0a4735d96c38d9b17c21ee3098ab8
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Tue Apr 14 13:52:09 2009 -0400
link needed to be converted to a jQuery object
diff --git a/moksha/public/javascript/ui/moksha.ui.tabs.js b/moksha/public/javascript/ui/moksha.ui.tabs.js
index e588944..1c965d5 100644
--- a/moksha/public/javascript/ui/moksha.ui.tabs.js
+++ b/moksha/public/javascript/ui/moksha.ui.tabs.js
@@ -74,8 +74,9 @@ $.widget("ui.mokshatabs", {
self.$panels = self.$panels.add(a.hash);
// remote tab
else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#"
- $.data(a, 'href.tabs', a.attr('href')); // required for restore on destroy
- $.data(a, 'load.tabs', a.attr('href')); // mutable
+ var href = $(a).attr('href')
+ $.data(a, 'href.tabs', href); // required for restore on destroy
+ $.data(a, 'load.tabs', href); // mutable
var id = self.tabId(a);
a.href = '#' + id;
var $panel = $('#' + id + ':first', self.element);
15 years, 2 months
moksha/public
by John (J5) Palmieri
moksha/public/javascript/ui/moksha.ui.tabs.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 97f503f1cb6ca994ff7ac67d2a4d5b8677ce9d68
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Tue Apr 14 13:48:06 2009 -0400
get the href attr instead of the fully qualified url
* this allows us to check if the link was relative since we only rewrite
relative URLs
diff --git a/moksha/public/javascript/ui/moksha.ui.tabs.js b/moksha/public/javascript/ui/moksha.ui.tabs.js
index 40683c4..e588944 100644
--- a/moksha/public/javascript/ui/moksha.ui.tabs.js
+++ b/moksha/public/javascript/ui/moksha.ui.tabs.js
@@ -74,8 +74,8 @@ $.widget("ui.mokshatabs", {
self.$panels = self.$panels.add(a.hash);
// remote tab
else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#"
- $.data(a, 'href.tabs', a.href); // required for restore on destroy
- $.data(a, 'load.tabs', a.href); // mutable
+ $.data(a, 'href.tabs', a.attr('href')); // required for restore on destroy
+ $.data(a, 'load.tabs', a.attr('href')); // mutable
var id = self.tabId(a);
a.href = '#' + id;
var $panel = $('#' + id + ':first', self.element);
15 years, 2 months
moksha/public
by John (J5) Palmieri
moksha/public/javascript/ui/moksha.ui.tabs.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit dac53c40cbd1f768e7543c4b55aae1d8a8abd955
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Tue Apr 14 13:33:46 2009 -0400
rewrite urls so we work on mounted directories
diff --git a/moksha/public/javascript/ui/moksha.ui.tabs.js b/moksha/public/javascript/ui/moksha.ui.tabs.js
index d7104c3..40683c4 100644
--- a/moksha/public/javascript/ui/moksha.ui.tabs.js
+++ b/moksha/public/javascript/ui/moksha.ui.tabs.js
@@ -603,7 +603,7 @@ $.widget("ui.mokshatabs", {
}
$a.addClass(o.loadingClass);
setTimeout(function() { // timeout is again required in IE, "wait" for id being restored
- self.xhr = moksha.html_load(moksha.csrf_rewrite_url(url), {}, success_cb, self.$overlay_div)
+ self.xhr = moksha.html_load(moksha.url(url), {}, success_cb, self.$overlay_div)
}, 0);
},
15 years, 2 months
moksha/api moksha/public
by John (J5) Palmieri
moksha/api/widgets/grid.py | 6 +++++-
moksha/public/javascript/ui/moksha.ui.popup.js | 17 ++++++++++-------
2 files changed, 15 insertions(+), 8 deletions(-)
New commits:
commit e4d71f081fe44a9acdb7e0f87a9fa5099163f959
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Tue Apr 14 13:27:17 2009 -0400
make popups work in grids
diff --git a/moksha/api/widgets/grid.py b/moksha/api/widgets/grid.py
index e62b4ed..e89bccd 100644
--- a/moksha/api/widgets/grid.py
+++ b/moksha/api/widgets/grid.py
@@ -16,8 +16,12 @@ moksha_ui_grid_js = JSLink(filename='public/javascript/ui/moksha.ui.grid.js',
jquery_template_js,
jquery_json_js])
+moksha_ui_popup_js = JSLink(filename='public/javascript/ui/moksha.ui.popup.js',
+ modname='moksha',
+ javascript=[jquery_ui_core_js])
+
class Grid(FormField):
- javascript=[jquery_ui_core_js, moksha_ui_grid_js]
+ javascript=[jquery_ui_core_js, moksha_ui_grid_js, moksha_ui_popup_js]
params= ['rows_per_page', 'page_num', 'total_rows',
'filters', 'unique_key', 'sort_key', 'sort_order',
'row_template', 'resource', 'resource_path',
diff --git a/moksha/public/javascript/ui/moksha.ui.popup.js b/moksha/public/javascript/ui/moksha.ui.popup.js
index b5bce08..8c473e5 100644
--- a/moksha/public/javascript/ui/moksha.ui.popup.js
+++ b/moksha/public/javascript/ui/moksha.ui.popup.js
@@ -1,5 +1,5 @@
/*
- * Moksha UI Popup - Popup a block on user interactions such as mouse hover and click.
+ * Moksha UI Popup - Popup a block on user interactions such as mouse hover and click.
* Can be used to create popup menus
*
* Copyright (c) 2009 Red Hat, Inc.
@@ -12,7 +12,7 @@
*/
(function ($) {
$.widget("ui.moksha_popup", {
-
+
_init: function() {
// create popup
this._createpopup();
@@ -32,13 +32,14 @@ $.widget("ui.moksha_popup", {
var $e = this.element;
var o = this.options;
this.timer = null;
+
$e.children(':first').addClass(o.selectedClass);
- if (this.showFx) {
+ if (this.showFx) {
this.$panel.animate(this.showFx, this.showFx.duration || this.baseFx.duration);
} else {
this.$panel.show();
}
-
+
},
hidePopup: function() {
@@ -55,6 +56,7 @@ $.widget("ui.moksha_popup", {
_startHover: function() {
var self = this;
var o = this.options;
+ moksha.debug('Hover Started');
this.timer = setTimeout(function () {self.showPopup.apply(self)}, o.hoverTimeout);
},
@@ -83,13 +85,14 @@ $.widget("ui.moksha_popup", {
}
this.$panel = $panel.addClass(o.panelClass);
-
+ this.$panel.hide()
+
// set up animations
var hideFx, showFx, baseFx = { 'min-height': 0, duration: 1 }, baseDuration = 'normal';
if (o.fx && o.fx.constructor == Array)
hideFx = o.fx[0] || baseFx, showFx = o.fx[1] || baseFx;
else
- hideFx = showFx = o.fx || baseFx;
+ hideFx = showFx = o.fx
this.hideFx = hideFx;
this.showFx = showFx;
@@ -101,7 +104,7 @@ $.widget("ui.moksha_popup", {
var self = this;
$e.hover(function () {self._startHover.apply(self)}, function () {self._endHover.apply(self)});
}
-
+
}
});
15 years, 2 months
moksha/api
by John (J5) Palmieri
moksha/api/widgets/containers/templates/layout_applist.mak | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 6940d0de54c6922dac035827dde39d913af1dcd0
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Tue Apr 14 13:25:58 2009 -0400
rewrite URL so we can work on a mounted directory
diff --git a/moksha/api/widgets/containers/templates/layout_applist.mak b/moksha/api/widgets/containers/templates/layout_applist.mak
index 4e12fa0..3a77fa8 100644
--- a/moksha/api/widgets/containers/templates/layout_applist.mak
+++ b/moksha/api/widgets/containers/templates/layout_applist.mak
@@ -22,7 +22,7 @@
}
$(document).ready(function () {
- moksha.html_load(moksha.csrf_rewrite_url("${app['url']}"),
+ moksha.html_load(moksha.url("${app['url']}"),
${app['params']},
success,
$('#${app["id"]}_overlay')
15 years, 2 months
moksha/public
by John (J5) Palmieri
moksha/public/javascript/moksha.extensions.js | 5 ++++-
moksha/public/javascript/moksha.js | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
New commits:
commit f1e941786ec24472d1f8c13e0c2ead0acd9bbc9c
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Mon Apr 13 16:14:07 2009 -0400
make moksha work without firebug on and give extensions a loading overlay
diff --git a/moksha/public/javascript/moksha.extensions.js b/moksha/public/javascript/moksha.extensions.js
index 9d79f89..85092d1 100644
--- a/moksha/public/javascript/moksha.extensions.js
+++ b/moksha/public/javascript/moksha.extensions.js
@@ -27,7 +27,7 @@ _extensions.prototype = {
data = data.replace(/'/g, "\"");
data = data.replace(/\n/g, "");
data = $.secureEvalJSON(data);
- console.log(data);
+
moksha.extensions.load_extensions(data);
}
);
@@ -73,6 +73,9 @@ _extensions.prototype = {
var div = block_element.attr("id", d.uid);
append_div.append(div);
+ var overlay = jQuery('<div><span class="message"></span></div>');
+ div.append(overlay);
+ d.overlay = overlay;
//run the script and parse in the results
var result = obj_list[i].run(d);
diff --git a/moksha/public/javascript/moksha.js b/moksha/public/javascript/moksha.js
index d6e8271..dd16072 100644
--- a/moksha/public/javascript/moksha.js
+++ b/moksha/public/javascript/moksha.js
@@ -363,7 +363,7 @@ moksha = {
},
debug: function(msg) {
- if (typeof(moksha_debug) != 'undefined' && moksha_debug) {
+ if (typeof(console) != 'undefined' && typeof(console.log) != 'undefined' && typeof(moksha_debug) != 'undefined' && moksha_debug) {
// TODO: make this configurable (or perhaps just overriding this
// method is enough
15 years, 2 months
moksha/connector
by John (J5) Palmieri
moksha/connector/connector.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit e0dc6c2da93e744969971234100fd6dbcaa514c6
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Mon Apr 13 15:39:14 2009 -0400
forgot to return the results
diff --git a/moksha/connector/connector.py b/moksha/connector/connector.py
index 8d45e6f..a4b00e6 100644
--- a/moksha/connector/connector.py
+++ b/moksha/connector/connector.py
@@ -81,7 +81,7 @@ class IConnector(object):
if op in ('request_data', 'call', 'query', 'query_model'):
return getattr(self, op)(resource_path, params, _cookies, **kwds)
elif op in self._method_paths:
- self._method_paths[op](self, resource_path, params, _cookies, **kwds)
+ return self._method_paths[op](self, resource_path, params, _cookies, **kwds)
return None
15 years, 2 months
moksha/connector moksha/middleware
by John (J5) Palmieri
moksha/connector/connector.py | 2 +-
moksha/middleware/connector.py | 32 ++++++++++++++++++--------------
2 files changed, 19 insertions(+), 15 deletions(-)
New commits:
commit 7f6c0a5e164f68b2b17d9215d81267abe1861c0c
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Mon Apr 13 15:14:29 2009 -0400
fix up some issues with calling connector methods without extra path info
diff --git a/moksha/connector/connector.py b/moksha/connector/connector.py
index e06ddd2..8d45e6f 100644
--- a/moksha/connector/connector.py
+++ b/moksha/connector/connector.py
@@ -81,7 +81,7 @@ class IConnector(object):
if op in ('request_data', 'call', 'query', 'query_model'):
return getattr(self, op)(resource_path, params, _cookies, **kwds)
elif op in self._method_paths:
- _method_paths[op](params, resource_path, _cookies, **kwds)
+ self._method_paths[op](self, resource_path, params, _cookies, **kwds)
return None
diff --git a/moksha/middleware/connector.py b/moksha/middleware/connector.py
index 4b5bbc2..eca14b2 100644
--- a/moksha/middleware/connector.py
+++ b/moksha/middleware/connector.py
@@ -85,24 +85,28 @@ class MokshaConnectorMiddleware(object):
# check last part of path to see if it is json data
dispatch_params = {};
- p = urllib.unquote_plus(path[-1].lstrip())
- if p.startswith('{'):
- dp = json.loads(p)
+ if len(path) > 0:
+ p = urllib.unquote_plus(path[-1].lstrip())
+ if p.startswith('{'):
+ dp = json.loads(p)
- f = dp.get('filters')
- if isinstance(f, basestring):
- dp['filters'] = json.loads(f)
- path = path[:-1]
+ f = dp.get('filters')
+ if isinstance(f, basestring):
+ dp['filters'] = json.loads(f)
+ path = path[:-1]
- # scrub dispatch_params keys of unicode so we can pass as keywords
- for (k, v) in dp.iteritems():
- dispatch_params[str(k)] = v
+ # scrub dispatch_params keys of unicode so we can pass as keywords
+ for (k, v) in dp.iteritems():
+ dispatch_params[str(k)] = v
- # prevent trailing slash
- if not p:
- path = path[:-1]
+ # prevent trailing slash
+ if not p:
+ path = path[:-1]
+
+ path = '/'.join(path)
+ else:
+ path = ''
- path = '/'.join(path)
conn = self._connectors.get(conn)
# pretty print output
15 years, 2 months
moksha/connector
by John (J5) Palmieri
moksha/connector/connector.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit bc02f6d3fcbd73112aff9cf9f0a355a5be3b721d
Author: John (J5) Palmieri <johnp(a)redhat.com>
Date: Mon Apr 13 15:01:53 2009 -0400
typo
diff --git a/moksha/connector/connector.py b/moksha/connector/connector.py
index dcb6bd7..e06ddd2 100644
--- a/moksha/connector/connector.py
+++ b/moksha/connector/connector.py
@@ -55,7 +55,7 @@ class IConnector(object):
raise NotImplementedError
@classmethod
- def register_method(self, method_path, method):
+ def register_method(cls, method_path, method):
cls._method_paths[method_path] = method
def _dispatch(self, op, resource_path, params, _cookies = None, **kwds):
15 years, 2 months