diff --git a/cms/disk.py b/cms/disk.py index 4437a61..65e94d1 100644 --- a/cms/disk.py +++ b/cms/disk.py @@ -97,11 +97,10 @@ def read (**_args): # Inferring the type of the data to be returned _mimeType = 'application/octet-stream' _extension = _uri.split('.')[-1] - if _extension in ['css','js','csv'] : + if _extension in ['css','js','csv','html'] : _mimeType = f'text/{_extension}' elif _extension in ['png','jpg','jpeg'] : _mimeType = f'image/{_extension}' - return _stream, _mimeType return None,_mimeType def exists(**_args): @@ -123,6 +122,7 @@ def html(_uri,_config) : if not _config : _api = os.sep.join(['api/disk/read?uri=',_layout['root']]) else: + _api = os.sep.join([f'{_context}/api/disk/read?uri=',_layout['root']]) if f"{_layout['root']}{os.sep}" in _html : _html = _html.replace(f"{_layout['root']}",_api) diff --git a/cms/engine/basic.py b/cms/engine/basic.py index 8dd5b2f..7a1da60 100644 --- a/cms/engine/basic.py +++ b/cms/engine/basic.py @@ -170,6 +170,7 @@ class Initializer : _index = 0 for _item in _submenu : text = _item['text'].strip() + if text in _overwrite : if 'uri' in _item and 'url' in _overwrite[text] : del _item['uri'] @@ -204,6 +205,7 @@ class Initializer : # # If there are missing items in the sorting _missing = list(set(self._menu.keys()) - set(_sortedmenu)) + if _missing : for _name in _missing : _menu[_name] = self._menu[_name] @@ -234,6 +236,13 @@ class Initializer : # # update the menu items and the configuration # + _keys = list(_menu.keys()) + # for _key in _keys : + # if len(_menu[_key]) == 0 : + # del _menu[_key] + # # + # # doing some house-keeping work here to make sure the front-end gets clean data + # # _layout['menu'] = _menu self._config['layout'] = _layout def _ilogo(self): diff --git a/cms/index.py b/cms/index.py index b6be9e3..5dc3236 100644 --- a/cms/index.py +++ b/cms/index.py @@ -130,9 +130,9 @@ def _aindex (app,resource=None): # """ # global _config # return "0",200 - -@_app.route('/dialog') -def _dialog (): +@_app.route('//dialog') +@_app.route('/dialog',defaults={'app':'main'}) +def _dialog (app): # global _config global _route _handler = _route.get() @@ -140,7 +140,7 @@ def _dialog (): _id = request.headers['dom'] # _html = ''.join(["
",str( e.render(**_args)),'
']) - _args = _route.render(_uri,'html',session.get('app_id','main')) + _args = _route.render(_uri,'html',app) #session.get('app_id','main')) _args['title'] = _id return render_template('dialog.html',**_args) #title=_id,html=_html) diff --git a/cms/static/js/menu.js b/cms/static/js/menu.js index 7dc0972..2ffb331 100644 --- a/cms/static/js/menu.js +++ b/cms/static/js/menu.js @@ -117,7 +117,7 @@ menu.events._dialog = function (_item,_context){ http.get(_context+'/dialog',function(x){ jx.modal.show({html:x.responseText,id:'dialog'}) - // menu.events.finalize ('.jxmodal') + menu.events.finalize ('.jxmodal') }) } @@ -129,6 +129,7 @@ menu.events._open = function (id,uri,_context){ $('.content').children().slideUp() $('#'+id).remove() + var httpclient = HttpClient.instance() _context = (_context == null)?'':_context; httpclient.setHeader('uri',uri) @@ -138,14 +139,13 @@ menu.events._open = function (id,uri,_context){ var _html = x.responseText var _dom = $(_html) - if(jx.dom.exists(pid) && jx.dom.exists(id)){ jx.dom.remove(id) } $(pid).append(_dom) var ref = pid + ' #'+id - menu.events.finalize (ref) + // menu.events.finalize (ref) $(pid).children().slideUp('fast', function(){ $(ref ).slideDown('fast',function(){ @@ -174,6 +174,20 @@ menu.utils = {} menu.utils.format = function(text){ return text.replace(/(-|_)/g,' ').trim() } +menu.utils._delegate = function (_id,_itemIndex,_index) { + if ($(_id).children().length >= _itemIndex ){ + var _node = $(_id).children()[_itemIndex ] + if ($(_node).children().length >= _index ){ + var _node = $(_node).children()[_index] + _node = $(_node).find('.active') + if ($(_node).length > 0 ){ + $(_node)[0].click() + } + } + + + } +} menu.events.finalize = function (ref) { var scripts = $(ref+' script') @@ -202,6 +216,7 @@ var QCMSBasic= function(_layout,_context,_clickEvent) { this._make = function (_items){ var _panes = [] var _context = this._context ; + _items.forEach(_item=>{ var _div = jx.dom.get .instance('DIV') @@ -215,8 +230,7 @@ var QCMSBasic= function(_layout,_context,_clickEvent) { $(_div).on('click', function (){ // // how do we process this ... - - if(this.data.uri) { + if(this.data.uri && this.data.type != 'open') { if (this.data.type == 'dialog') { menu.events._dialog(this.data,_context) @@ -224,7 +238,11 @@ var QCMSBasic= function(_layout,_context,_clickEvent) { menu.events._open(menu.utils.format(this.data.text),this.data.uri,_context) } }else{ - window.open(this.data.url,menu.utils.format(this.data.text)) + if (this.data.uri != null){ + window.open(this.data.uri,'_self') + }else{ + window.open(this.data.url,menu.utils.format(this.data.text)) + } } }) @@ -242,6 +260,7 @@ var QCMSBasic= function(_layout,_context,_clickEvent) { // Object.keys(this._layout.menu) _names.forEach(function(_name){ + var _div = _me._make(_layout.menu[_name]) ;