From 31565bfd53bcde28e1dced23c692476d2b28ca90 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Sat, 27 Jan 2024 09:19:02 -0600 Subject: [PATCH] bug fixes with layout and dependencies --- cms/cloud.py | 1 - cms/engine/__init__.py | 11 ++++-- index.py | 17 +++++++-- static/css/menu.css | 2 + static/css/themes/magazine.css | 21 ++++++++--- static/css/themes/oss.css | 12 +++--- static/js/menu.js | 23 +++++++++++- templates/dialog.html | 2 +- templates/index.html | 67 ++++++++++++++++++++++++++++++++-- templates/menu.html | 17 ++++++--- 10 files changed, 142 insertions(+), 31 deletions(-) diff --git a/cms/cloud.py b/cms/cloud.py index c2715bc..2454dde 100644 --- a/cms/cloud.py +++ b/cms/cloud.py @@ -103,7 +103,6 @@ def html (uri,_config) : # _link = '/'.join(['api/cloud/download?doc='+_prefix,'_images']) - print (uri) _html = _handler.get_file_contents(uri).decode('utf-8')#.replace('.attachments.', copy.deepcopy(_link)) # print ([uri,uri[-2:] ,uri[-2:] in ['md','MD','markdown']]) _handler.logout() diff --git a/cms/engine/__init__.py b/cms/engine/__init__.py index 18c283b..fe1f2aa 100644 --- a/cms/engine/__init__.py +++ b/cms/engine/__init__.py @@ -69,7 +69,7 @@ class Loader : del _item['uri'] _item = dict(_item,**_overwrite[text]) - if 'uri' in _item and _item['type'] != 'open': + if 'uri' in _item and 'type' in _item and _item['type'] != 'open': _item['uri'] = _item['uri'].replace(_layout['root'],'') _submenu[_index] = _item @@ -91,7 +91,7 @@ class Loader : _item = _system['routes'][_text] if 'menu' not in _item : continue - uri = f'{_context}/set/{_text}' + uri = f'{_context}/{_text}' # _items.append ({"text":_text,'uri':uri,'type':'open'}) _label = _item['menu'] if _label not in _menu : @@ -136,7 +136,7 @@ class Loader : if not os.path.exists(PATH) and self._location and os.path.exists(self._location) : # # overriding the location of plugins ... - PATH = self._location + PATH = os.sep.join([self._location, _config['layout']['root'],'_plugins']) _map = {} # if not os.path.exists(PATH) : @@ -149,6 +149,7 @@ class Loader : _path = os.sep.join([PATH,_key+".py"]) if not os.path.exists(_path): + print ([' ?? ',_path]) continue for _name in _conf[_key] : _pointer = self._load_plugin(path=_path,name=_name) @@ -213,6 +214,8 @@ class Getter (Loader): _icon = os.sep.join([_root,_icon]) _system['icon'] = _icon self._config['system'] = _system + if self._caller : + _system['caller'] = {'icon': self._caller.system()['icon']} def html(self,uri,id,_args={},_system={}) : """ This function reads a given uri and returns the appropriate html document, and applies environment context @@ -300,7 +303,7 @@ class Router : for _name in _system : _path = _system[_name]['path'] self._apps[_name] = Getter(path=_path,caller=_app,location=_path) - # self._apps[_name].load() + print ([_name, self._apps[_name].plugins().keys()]) self._apps['main'] = _app def set(self,_id): self._id = _id diff --git a/index.py b/index.py index d84ea08..dac1201 100644 --- a/index.py +++ b/index.py @@ -179,8 +179,13 @@ def cms_page(): _handler = _route.get() _config = _handler.config() - _uri = os.sep.join([_config['layout']['root'],request.headers['uri']]) - _id = request.headers['dom'] + # _uri = os.sep.join([_config['layout']['root'],request.headers['uri']]) + _uri = request.headers['uri'] + if 'dom' not in request.headers : + _id = _uri.split('/')[-1].split('.')[0] + else: + _id = request.headers['dom'] + print ([_id,_uri]) _args = {'layout':_config['layout']} if 'plugins' in _config: _args['routes'] = _config['plugins'] @@ -202,7 +207,7 @@ def _cms_page (): _handler = _route.get() _config = _handler.config() _uri = request.args['uri'] - _uri = os.sep.join([_config['layout']['root'],_uri]) + # _uri = os.sep.join([_config['layout']['root'],_uri]) _title = request.args['title'] if 'title' in request.args else '' _args = {'system':_handler.system()} #cms.components.get_system(_config) } # if 'plugins' in _config: @@ -217,7 +222,11 @@ def set(id): global _route _handler = _route.set(id) return redirect('/') - +@_app.route('/') +def _open(id): + global _route + _route.set(id) + return _index() # # Let us bootup the application SYS_ARGS = {} diff --git a/static/css/menu.css b/static/css/menu.css index 123e05e..a084c5c 100644 --- a/static/css/menu.css +++ b/static/css/menu.css @@ -10,6 +10,8 @@ align-items: center; } +.menu .icon {padding:4px;} +.menu .icon img {width:30px; height:30px;} .menu .item { font-weight:bold; cursor:pointer; diff --git a/static/css/themes/magazine.css b/static/css/themes/magazine.css index 9a4d869..dbe3211 100644 --- a/static/css/themes/magazine.css +++ b/static/css/themes/magazine.css @@ -4,7 +4,7 @@ display:grid; grid-template-columns: 50% 50% ; gap:4px; grid-template-rows: 48px 48px auto 32px; - font-family: helvetica; + font-family: sans-serif; font-weight: lighter; font-size:18px; line-height: 1.5; @@ -12,15 +12,23 @@ ; } .main .header { - height:48px; + grid-row:1; grid-column: 1 / span 2; + display:grid; + grid-template-columns: 50px auto; gap:4px; + line-height: 1; } - -.main .header img { width:40px; margin:4px;} -.main .menu { grid-row:2; grid-column: 1 / span 2; background-color: #f3f3f3; } +.main .header .title {font-size:28px; text-transform: capitalize; font-weight:bold} +.main .header .subtitle {font-size:14px} +.main .header img { width:44px; height:44px;} +.main .menu { grid-row:2; grid-column: 1 / span 2; background-color: #f3f3f3; + display:grid; grid-template-columns: 75px repeat(3,250px) ; gap:4px; + align-items: left; + padding:4px; +} .main .content { grid-row:3; grid-column: 1 ; @@ -47,6 +55,7 @@ border-left:3px dotted gray; grid-column: 2; font-family: sans-serif; + padding-left: 10px; } @@ -58,6 +67,8 @@ } .main .footer {grid-row:4; grid-column: 1 / span 2; font-size:13px; font-weight: lighter;} +blockquote { border-left:8px solid GRAY;margin-right:8px} +blockquote .code {padding:10px; font-size:16px; font-family: courier; background-color:black; color: #d3d3d3} /** * styling tables here */ diff --git a/static/css/themes/oss.css b/static/css/themes/oss.css index 90e949f..096643f 100644 --- a/static/css/themes/oss.css +++ b/static/css/themes/oss.css @@ -10,7 +10,7 @@ } .main .header { height:64px; display:grid; - grid-template-columns: 40px auto; + grid-template-columns: 50px auto; border-bottom: 2px double #CAD5E0; padding:4px; gap:4px; @@ -18,19 +18,19 @@ } -.main .header .icon {width:40px; height:40px;} -.main .header .icon img {width:40px; height:40px;} +.main .header .icon {width:50px; height:50px;} +.main .header .icon img {width:48px; height:48px;} .main .header .title { font-size:32px; text-transform: uppercase; font-weight:bold} .main .header .subtitle {font-style:italic;font-size:14px; color:gray; text-transform: capitalize;} -.main .header img {height:48px; margin:4px;} + .main .menu {border:0; background-color: #f3f3f3;} -.main .content img{ +/* .main .content img{ width:99%; border:1px solid #CAD5E0; padding:8px; background-color:#f3f3f3; -} +} */ /* .main .content table thead tr:first-child { padding:4px; diff --git a/static/js/menu.js b/static/js/menu.js index 4253b45..d963040 100644 --- a/static/js/menu.js +++ b/static/js/menu.js @@ -77,10 +77,31 @@ menu.apply_link =function(_args){ http.get('/dialog',function(x){ jx.modal.show({html:x.responseText,id:'dialog'}) + console.log([$('.jxmodal')]) + menu.runScript ('.jxmodal') }) } }else{ window.open(_args.url,_args.text) } -} \ No newline at end of file +} + +var _delegate = {scripts:{}} +menu.runScript = function(_id){ + var scripts = $(_id+' script') + + jx.utils.patterns.visitor(scripts,function(_item){ + if(_item.text.trim().length > 0){ + var _code = eval(_item.text) + var id = _id + if (_item.parentNode != null){ + var id = _item.parentNode.id == null?_item.parentNode.className : _item.parentNode.id + } + id = (id != null)?id : _id + + // _delegate.scripts[id] = _code + } + }) +} + diff --git a/templates/dialog.html b/templates/dialog.html index c352e39..a943a5d 100644 --- a/templates/dialog.html +++ b/templates/dialog.html @@ -3,5 +3,5 @@

-
{{html|safe}}
+
{{html|safe}}
diff --git a/templates/index.html b/templates/index.html index 11677ee..0cebd78 100644 --- a/templates/index.html +++ b/templates/index.html @@ -42,6 +42,67 @@ Vanderbilt University Medical Center @@ -51,7 +112,7 @@ Vanderbilt University Medical Center {%include "header.html" %} -