bug fixes and updates (menu) and added file references

v2.2
Steve Nyemba 2 weeks ago
parent 1b3a458b23
commit 5180838e18

@ -1,3 +1,2 @@
REM python .\qcms-sandbox\Scripts\qcms %1 %2 %3 %4 %5 %6
cd /D "%~dp0"
python qcms %1 %2 %3 %4 %5 %6

@ -68,14 +68,16 @@ def build (_config, keep=[]): #(_path,_content):
def _realpath (uri,_config) :
_layout = _config['layout']
_uri = copy.copy(uri)
if _layout['root'] not in _uri :
_uri = os.sep.join([_layout['root'],_uri])
if 'location' in _layout and _layout['location']:
_loc = _layout['location'].strip()
if _loc.endswith(os.sep) and _uri.endswith(os.sep) :
_uri = os.sep.join(_uri.split(os.sep)[1:])
print (' *********************************** ')
_uri = os.sep.join([_layout['location'],_uri])
return _uri
def _format (uri,_config):
@ -88,12 +90,13 @@ def read (**_args):
This will read binary files from disk, and allow the location or not to be read
@TODO: add permissions otherwise there can be disk-wide reads
"""
request = _args['request']
request = _args['request'] if 'request' in _args else None
_layout = _args['config']['layout']
_uri = request.args['uri'] # if 'location' in _layout :
_uri = request.args['uri'] if request else _args['uri'] # if 'location' in _layout :
# _uri = os.sep.join([_layout['location'],_uri])
_uri = _realpath(_uri, _args['config'])
_mimeType = 'text/plain'
if os.path.exists(_uri):
f = open(_uri,mode='rb')
_stream = f.read()
@ -141,6 +144,8 @@ def html(_uri,_config) :
# _html = _html.replace(f'{os.sep}{_layout["root"]}',_layout['root'])
return _html
pass
def plugins (**_args):
"""
This function will load plugins from disk given where they come from

@ -44,6 +44,14 @@ def _getId(app_id,app_x):
def _setHandler (app_id,resource) :
session['app_id'] = _getId(app_id,resource)
@_app.route("/favicon.ico")
@_app.route("/<app>/favicon.ico")
def favicon (app):
global _qcms
_site = _qcms.get (app)
print([' **** ',_site.get('layout.location'),_site.get('system.icon')])
return
@_app.route("/<_id>/robots.txt")
@_app.route("/robots.txt",defaults={'_id':None})
def robots_txt(_id):
@ -106,7 +114,16 @@ def _altIndex(app,resource):
_site = _qcms.get(_id)
_uri = os.sep.join([_site.get('layout.root'),_site.get('layout.index')])
return render_template('index.html',**_qcms.render(_uri,'index',_id)),200
@_app.route('/files/<path:file>',defaults={'app':None,'module':None})
@_app.route('/<app>/files/<path:file>', defaults=[{'module':None}])
@_app.route('/<app>/<module>/files/<path:file>')
def _read(app,module,file):
global _qcms
_id = _getId(app,module)
_site = _qcms.get(_id)
_stream,_mimeType = _site.read(file)
return io.BytesIO(_stream),200,{'Content-Type':_mimeType}
@_app.route('/<app>/dialog')
@_app.route('/dialog',defaults={'app':None})
def _getdialog(app):

@ -318,6 +318,9 @@ class Site(Initialization) :
_handler = cloud if self.get('system.source.id') == 'cloud' else disk
_html = _handler.html(_uri, self.get(None))
return " ".join([f'<div id="{_id}"> ',_html,"</div>"])
def read(self,_uri) :
_handler = cloud if self.get('system.source.id') == 'cloud' else disk
return _handler.read(uri=_uri, config=self.get(None))
class QCMS:
def __init__(self,**_args):
@ -346,5 +349,4 @@ class QCMS:
def set(self,_id):
self._id = _id
def get(self,_id=None):
return self._sites[self._id] if not _id else self._sites[_id]

@ -21,14 +21,14 @@ qcms.menu.Common = function (){
if($(`${_parentId} #${_domId}`).length){
$(`${_parentId} #${_domId}`).remove()
}
$(`${_parentId}`).children().slideUp('fast',()=>{
$(`${_parentId}`).append(_dom)
var _found = qcms.html.hasNode ($(`${_parentId}`),$(_domId))
if (_found == 0){
$(`${_parentId}`).children().slideUp('fast',()=>{
$(`${_parentId}`).append(_dom)
this._finalize(`${_parentId} #${_domId}`)
this._finalize(`${_parentId} #${_domId}`)
//
// we should finalize the scripts
})
})
}
})
@ -72,7 +72,6 @@ qcms.menu.Basic = function (_layout,_outputId,_domId){
$(_div).on('click', function (){
//
// how do we process this ...
console.log(this.data)
if (this.data.type == 'redirect') {
window.open(this.data.url,_me._format(this.data.text))
}else if (this.data.type == 'dialog'){
@ -173,9 +172,8 @@ qcms.menu.Tabs = function (_layout,_outputId,_domId){
// var _parentId = this._parentId
var _me = this ;
$(_label).on('click',function (){
alert('....')
// _me._open(this.data.id,this.data.uri,_me._parentId)
console.log([_me._format(this.data.text),this.data.uri,_parentId])
_me._open(_me._format(this.data.text),this.data.uri,_parentId)
})
@ -187,7 +185,6 @@ qcms.menu.Tabs = function (_layout,_outputId,_domId){
// Object.keys(_layout.menu).
_names.forEach(function(_text){
_item = _layout.menu[_text]
// console.log([_item])
_tabItem = this._build(_text,_item)
$(tabs).append(_tabItem)

@ -31,8 +31,15 @@ qcms.page.Observer = function (_parentId,_domId,_uri){
http.post(`${qcms.context}/page`,function(x){
var _dom = $(x.responseText)
$(_id).append (_dom)
_finalize(_id)
var _found = qcms.html.hasNode( $(_id), $(_dom))
if (_found == 0){
$(_id).append (_dom)
_finalize(_id)
}
_caller.notify()
})

@ -3,42 +3,21 @@ if (!qcms){
}
qcms.html = {}
qcms.html.Common = function (){
this._format = function (text){
return text.replace(/(-|_)/g,' ').trim()
qcms.html.hasNode = function (_parent,_child){
var _found = 0
if ($(_child).length == 0){
return 0
}
this._open = function (text,uri,_parentId){
var _domId = text.replace(/ /g,'-')
var http = HttpClient.instance()
http.setHeader('dom',_domId)
http.setHeader('uri',uri)
http.post(`${qcms.context}/page`,(x)=>{
//
// @TODO: In case of an error
var _dom = $(x.responseText)
if($(`${_parentId} #${_domId}`).length){
$(`${_parentId} #${_domId}`).remove()
}
$(`${_parentId}`).children().slideUp('fast',()=>{
$(`${_parentId}`).append(_dom)
$(_parent).each((_index)=>{
var _node = $(_parent)[_index]
this._finalize(`${_parentId} #${_domId}`)
//
// we should finalize the scripts
})
if ( $(_node)[0].innerHTML == $(_child)[0].outerHTML){
_found = 1
}
})
})
}
this._finalize = function (_id){
var _script = $(`${_id} script`)
return _found
if (_script.lenth > 0){
_script.each( (_index)=>{
var _code = $(_script)[_index].text
eval(_code)
})
}
}
}

@ -5,10 +5,12 @@
{% else %}
{% set _backURI = system.parentContext%}
{% endif %}
<div class="icon active">
<div align="center" class="button" onclick="window.open('{{_backURI}}','_self')" style="display:grid; grid-template-columns:auto auto; gap:4px; align-items:center ">
<i class="fa-solid fa-chevron-left" style="color:darkgray; display:block"></i>
<img src="{{system.caller.icon}}" style="height:100%"/>
<div class="icon" style="margin:0px" >
<div align="left" class="back-button active" onclick="window.open('{{_backURI}}','_self')" >
<div style="display:grid; align-items:center; grid-template-columns: auto auto;">
<i class="fa-solid fa-chevron-left" style="color:darkgray;"></i>
<img src="{{system.caller.icon}}"/>
</div>
</div>
</div>
{% else %}

Loading…
Cancel
Save