lazylandscape
clone your own copy | download snapshot

Snapshots | iceberg

No images in this repository’s iceberg at this time

Inside this repository

workspace.json
application/json

Download raw (36.2 KB)

[{"pk": 4, "model": "sh.shclasses", "fields": {"comment": "List Applications", "lang": "python", "name": "ListApps", "field": "Application", "parents": [], "deps": [], "public": false}}, {"pk": 5, "model": "sh.shclasses", "fields": {"comment": "This application aims to implement some kind of REST (well, really a kind of) interface to the landscape", "lang": "python", "name": "ShCommand", "field": "Service", "parents": [], "deps": [6], "public": false}}, {"pk": 6, "model": "sh.shclasses", "fields": {"comment": "Read POST &  GET data and make it available in an unified way", "lang": "python", "name": "HTTPRequest", "field": "Network", "parents": [], "deps": [], "public": false}}, {"pk": 7, "model": "sh.shclasses", "fields": {"comment": "Post things on HTTP, takes number of fields as GET'n'] arguments", "lang": "python", "name": "Post", "field": "Application", "parents": [], "deps": [6], "public": false}}, {"pk": 12, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "XHR", "field": "Network", "parents": [], "deps": [], "public": false}}, {"pk": 13, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "JSLoader", "field": "Util", "parents": [], "deps": [], "public": false}}, {"pk": 14, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "Commander", "field": "Util", "parents": [], "deps": [12, 18], "public": false}}, {"pk": 15, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "Workspace", "field": "Application", "parents": [], "deps": [13], "public": false}}, {"pk": 16, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "JQWidget", "field": "UiBase", "parents": [], "deps": [], "public": false}}, {"pk": 17, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "JQMethodWidget", "field": "UiBase", "parents": [], "deps": [16], "public": false}}, {"pk": 18, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "JQClassWidget", "field": "UiBase", "parents": [16], "deps": [], "public": false}}, {"pk": 19, "model": "sh.shclasses", "fields": {"comment": "Wrapper on a canvas element", "lang": "js", "name": "CanvasView", "field": "Graphic", "parents": [], "deps": [], "public": false}}, {"pk": 20, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "JQCanvasWidget", "field": "UiBase", "parents": [16], "deps": [], "public": false}}, {"pk": 21, "model": "sh.shclasses", "fields": {"comment": "Wrapper for os module", "lang": "python", "name": "OSCommand", "field": "Service", "parents": [], "deps": [6], "public": false}}, {"pk": 22, "model": "sh.shclasses", "fields": {"comment": "", "lang": "js", "name": "OSTerminal", "field": "UiBase", "parents": [16], "deps": [], "public": false}}, {"pk": 23, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "Fontforge", "field": "LGRU", "parents": [], "deps": [], "public": false}}, {"pk": 24, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "LGRU", "field": "Application", "parents": [], "deps": [], "public": false}}, {"pk": 25, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "Media", "field": "Service", "parents": [], "deps": [], "public": true}}, {"pk": 26, "model": "sh.shclasses", "fields": {"comment": "", "lang": "python", "name": "TestMedia", "field": "Application", "parents": [], "deps": [], "public": true}}, {"pk": 3, "model": "sh.shmethods", "fields": {"comment": "", "body": "htmlopen = r'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html lang=\"en\" dir=\"ltr\" xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"> <title>Lazy Landscape Shell</title> </head> <body>'\nhtmlClose = '</body></html>'\nstyle = r' <style> *{ border:none; padding:0; margin:0; } #wrapper{ width:90%; margin: 20px auto; } #page-title{ top:0; left:0; padding:12px; background-color:#000; color: #eee; font-family:sans-serif; } .app-box{ width: 300px; float:left; margin:12px; height:200px; } .app-title{ font-family:sans-serif; font-size:24pt; } .app-title a{ color:#f47; text-decoration:none; } .app-title-noexec a{ font-size:24pt; color:#a47; text-decoration:none; } .app-desc{ color:#aaa; font-style:italic; font-family:serif; font-size:12pt; } .app-noexec{ font-family:sans-serif; font-weight:bold; font-size:12pt; color:#000; } </style>'\ntitle = r' <h3 id=\"page-title\">Applications</h3> <div id=\"wrapper\"> '\n\nret = [htmlopen, style, title]\n\n\nfor c in ShClasses.objects.filter(lang='python').filter(field='Application'):\n    hasexec = False\n    for m in c.methods.all():\n        if m.name == 'app':\n            hasexec = True\n            break\n                \n    exec_warning = ''\n    if not hasexec:\n        exec_warning = '<div class=\"app-noexec\">This app lacks an \"app\" method.</div>'\n        \n    ret += r' <div class=\"app-box\"> <div class=\"app-title\"><a href=\"/Application/%s\">%s</a></div> <div class=\"app-desc\">%s</div> %s </div> ' % (c.name, c.name, c.comment, exec_warning)\n            \nret += '</div>'\nret += htmlClose\n\nresponse.write(''.join(ret))", "args": "", "name": "app", "cls": 4}}, {"pk": 4, "model": "sh.shmethods", "fields": {"comment": "", "body": "self._d = {}\r\nfor k in request.POST:\r\n    self._d[ k ] = request.POST[k]\r\n    \r\nfor k in request.GET:\r\n    self._d[ k ] = request.GET[k]", "args": "request", "name": "__init__", "cls": 6}}, {"pk": 5, "model": "sh.shmethods", "fields": {"comment": "", "body": "self.args = Network.HTTPRequest(request)\r\nself.parse()", "args": "", "name": "app", "cls": 5}}, {"pk": 6, "model": "sh.shmethods", "fields": {"comment": "", "body": "if self.args.has('command'):\r\n    if hasattr(self, self.args.command) and callable(getattr(self, self.args.command)):\r\n        getattr(self, self.args.command)()", "args": "", "name": "parse", "cls": 5}}, {"pk": 7, "model": "sh.shmethods", "fields": {"comment": "", "body": "tattr = attr\r\nif isinstance(attr, basestring):\r\n    tattr = [attr]\r\nfor i in tattr:\r\n    if  i not in self._d:\r\n        return False\r\nreturn True", "args": "attr", "name": "has", "cls": 6}}, {"pk": 8, "model": "sh.shmethods", "fields": {"comment": "", "body": "if not self.args.has(['field','name','lang']):\r\n    response.write(self.json.dumps({'error':'not enough args'}))\r\n    \r\ncls = ShClasses()\r\nfor i in ['field','name','comment','lang']:\r\n    if self.args.has(i):\r\n        setattr(cls, i, getattr(self.args, i))\r\n        \r\ncls.save()\r\nresponse.write('<h1>OK: %s.%s (%s) created</h1>%s'%(cls.field,cls.name,cls.lang,cls.comment))\r\n#response.write(self.json.dumps(cls))", "args": "", "name": "new_class", "cls": 5}}, {"pk": 9, "model": "sh.shmethods", "fields": {"comment": "", "body": "args = Network.HTTPRequest(request)\r\nif args.has(['app']):\r\n    app = args.app\r\n    ret = ['<form action=\"/app/'+app+'\" method=\"POST\">']\r\n    for a in args.all():\r\n        if a != 'app':\r\n            if getattr(args,a) == 't':\r\n                ret.append('<div>'+a+': <input type=\"text\" name=\"'+a+'\"/></div>')\r\n            else:\r\n                ret.append('<div>'+a+': <textarea name=\"'+a+'\"></textarea></div>')\r\n    ret.append('<input type=\"submit\" value=\"POST to %s\"/></form>'%(app))\r\n    response.write('\\n'.join(ret))", "args": "", "name": "app", "cls": 7}}, {"pk": 10, "model": "sh.shmethods", "fields": {"comment": "", "body": "return self._d.keys()", "args": "", "name": "all", "cls": 6}}, {"pk": 11, "model": "sh.shmethods", "fields": {"comment": "", "body": "if name in self._d:\r\n    return self._d[name]\r\nelse:\r\n    raise AttributeError('HTTPRequest.%s is not defined' % (name))", "args": "name", "name": "__getattr__", "cls": 6}}, {"pk": 12, "model": "sh.shmethods", "fields": {"comment": "", "body": "self.json = __import__('json', globals(), locals(), [], -1)", "args": "", "name": "__init__", "cls": 5}}, {"pk": 14, "model": "sh.shmethods", "fields": {"comment": "", "body": "this.xhr = new XMLHttpRequest();", "args": "", "name": "init", "cls": 12}}, {"pk": 15, "model": "sh.shmethods", "fields": {"comment": "", "body": "this.xhr.open(\"GET\", url, false);\r\nthis.xhr.send(null);", "args": "url", "name": "get", "cls": 12}}, {"pk": 16, "model": "sh.shmethods", "fields": {"comment": "", "body": "if(data != undefined)\r\nthis.xhr.data = data\r\nthis.xhr.addEventListener(\"load\", fn, false);\r\nreturn this;", "args": "fn, data", "name": "bind", "cls": 12}}, {"pk": 17, "model": "sh.shmethods", "fields": {"comment": "", "body": "this.xhr.open(\"POST\", url, false);\r\nthis.xhr.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\");\r\nthis.xhr.send(this.aToD(data));", "args": "url, data", "name": "post", "cls": 12}}, {"pk": 18, "model": "sh.shmethods", "fields": {"comment": "", "body": "jstr = []\r\nfor i in jlist:\r\n    jstr.append('<script src=\"/get/%s/%s\" type=\"text/javascript\"></script>'%(i[0], i[1]))\r\n\r\nself.js = '\\n'.join(jstr)", "args": "jlist", "name": "__init__", "cls": 13}}, {"pk": 19, "model": "sh.shmethods", "fields": {"comment": "", "body": "var ret = ''\r\nfor(var n in a)\r\n{\r\n    if(n != undefined && a[n] != undefined)\r\n        ret += encodeURIComponent(n) + '=' + encodeURIComponent(a[n]) + '&';\r\n}\r\nreturn ret;", "args": "a", "name": "aToD", "cls": 12}}, {"pk": 20, "model": "sh.shmethods", "fields": {"comment": "Takes a selector for the 'source' container of  commands and a callback to process whatever comes back from a command", "body": "var eList = document.querySelectorAll(source);\r\nif(eList.length > 0)\r\n{\r\n    var cont = eList[0];\r\n    var csource = document.createElement(\"input\");\r\n    var submit = document.createElement(\"span\");\r\n    submit.textContent = '|Get Class|';\r\n\tsubmit.setAttribute('class','command-submit link');\r\n    cont.appendChild(csource);\r\n    cont.appendChild(submit);\r\n    \r\n    submit.source = csource;\r\n    submit.xhr = Network.New('XHR');\r\n    submit.xhr.bind(this.handleCommand);\r\n    submit.addEventListener('click', function(e)\r\n    {\r\n\t\tvar cstr = this.source.value.split('/');\r\n\t\tvar data = {command :'get_class', field:cstr[0], name:cstr[1]};\r\n\t  this.xhr.post('/Service/ShCommand', data);\r\n    });\r\n    \r\n}\r\n", "args": "source", "name": "init", "cls": 14}}, {"pk": 21, "model": "sh.shmethods", "fields": {"comment": "", "body": "if not self.args.has(['field','name']):\r\n    response.write( self.json.dumps({'error':'not enough args'}))\r\n    \r\ntry:\r\n    cls = ShClasses.objects.get(field=self.args.field, name=self.args.name)\r\n    # list methods\r\n    ms = {}\r\n    for i in cls.methods.all():\r\n        ms[i.name] = {'name': i.name, 'id':i.id,'args':i.args, 'body':i.body, 'comment':i.comment, 'klass': cls.name}\r\n    o = {'id': cls.id,\r\n    'field': cls.field,\r\n    'name': cls.name,\r\n    'comment' : cls.comment,\r\n    'lang' : cls.lang,\r\n    'methods': ms,}\r\n    response.write( self.json.dumps(o))\r\nexcept:\r\n    response.write( self.json.dumps({'error':'Class does not exist for F(%s) N(%s)'%(self.args.field, self.args.name)}))\r\n    \r\n", "args": "", "name": "get_class", "cls": 5}}, {"pk": 22, "model": "sh.shmethods", "fields": {"comment": "", "body": "jscmd = Util.JSLoader([['Util', 'Commander'],['UiBase', 'JQMethodWidget'], ['UiBase','OSTerminal']])\nscript = \"\"\"\n<script>\n\njQuery(document).ready(function()\n{\n\tUtil.New('Commander', '#cont');\n\tUiBase.New('OSTerminal');\n});\n\n</script>\n<style>\n*{\n        margin:0;\n        padding:0;\n        border:none;\n        font-family:sans-serif;\n        font-size:10pt;\n}\nbody{\n        background-color:#ddd;\n}\n\n#cont input{\n    width:400px;\n    margin-right:1em;\n}\n.method-edit{\nwidth:90%;\nheight:90%;\npadding:5%;\n}\n.widget{\n        border:1px solid #555;\n        background-color:#fff;\n        box-shadow: 5px 5px 5px #ccc;\n}\n.widget-title{\n        color:white;\n        background-color:#666;\n        border-bottom:1px solid #555;\n        padding:2px;\n}\n\n.ui-draggable-dragging .widget-title{\n        color:#555;\n        background-color:#eee;\n        cursor:move;\n}\n\n.ui-resizable-se{\n        position:absolute;\n        width:10px;\n        height:10px;\n        background-color:#555;\n        border-top:1px solid #555;\n        border-left:1px solid #555;\n        right:0;\n        bottom:0;\n}\n.CodeMirror {\n  font-family: monospace;\n}\n\n.CodeMirror-scroll {\n  overflow: auto;\n min-height: 300px;\n  /* This is needed to prevent an IE[67] bug where the scrolled content\n     is visible outside of the scrolling box. */\n  position: relative;\nborder-top:1px solid #ccc;\nborder-bottom:1px solid #ccc;\n}\n\n.CodeMirror-gutter {\n  position: absolute; left: 0; top: 0;\n  z-index: 10;\n  background-color: #fff;\n  border-right: 1px solid #eee;\n  min-width: 2em;\n  height: 100%;\n}\n.CodeMirror-gutter-text {\n  color: #aaa;\n  text-align: right;\n  padding: .4em .2em .4em .4em;\n  white-space: pre !important;\n}\n.CodeMirror-lines {\n  padding: .4em;\n  font-family: monospace;\n}\n\n.CodeMirror-lines *{\n  font-family: monospace;\n}\n\n.CodeMirror pre {\n  -moz-border-radius: 0;\n  -webkit-border-radius: 0;\n  -o-border-radius: 0;\n  border-radius: 0;\n  border-width: 0; margin: 0; padding: 0; background: transparent;\n  font-family: inherit;\n  font-size: inherit;\n  padding: 0; margin: 0;\n  white-space: pre;\n  word-wrap: normal;\n}\n\n.CodeMirror-wrap pre {\n  word-wrap: break-word;\n  white-space: pre-wrap;\n}\n.CodeMirror-wrap .CodeMirror-scroll {\n  overflow-x: hidden;\n}\n\n.CodeMirror textarea {\n  font-family: inherit !important;\n  font-size: inherit !important;\n}\n\n.CodeMirror-cursor {\n  z-index: 10;\n  position: absolute;\n  visibility: hidden;\n  border-left: 1px solid black !important;\n}\n.CodeMirror-focused .CodeMirror-cursor {\n  visibility: visible;\n}\n\nspan.CodeMirror-selected {\n  background: #ccc !important;\n  color: HighlightText !important;\n}\n.CodeMirror-focused span.CodeMirror-selected {\n  background: Highlight !important;\n}\n\n.CodeMirror-matchingbracket {color: #0f0 !important;}\n.CodeMirror-nonmatchingbracket {color: #f22 !important;}\n\n\n\n.cm-s-default span.cm-keyword {color: #708;}\n.cm-s-default span.cm-atom {color: #219;}\n.cm-s-default span.cm-number {color: #164;}\n.cm-s-default span.cm-def {color: #00f;}\n.cm-s-default span.cm-variable {color: black;}\n.cm-s-default span.cm-variable-2 {color: #05a;}\n.cm-s-default span.cm-variable-3 {color: #085;}\n.cm-s-default span.cm-property {color: black;}\n.cm-s-default span.cm-operator {color: black;}\n.cm-s-default span.cm-comment {color: #a50;}\n.cm-s-default span.cm-string {color: #a11;}\n.cm-s-default span.cm-string-2 {color: #f50;}\n.cm-s-default span.cm-meta {color: #555;}\n.cm-s-default span.cm-error {color: #f00;}\n.cm-s-default span.cm-qualifier {color: #555;}\n.cm-s-default span.cm-builtin {color: #30a;}\n.cm-s-default span.cm-bracket {color: #cc7;}\n.cm-s-default span.cm-tag {color: #170;}\n.cm-s-default span.cm-attribute {color: #00c;}\n\n\t\t.text-comment{\n\t\t\tfont-size:12pt;\n\t\t\tline-height:15.6pt;\n\t\t}\n\t\t.CodeMirror{\n\t\t\tfont-size:10pt;\n\t\t\tline-height:13pt;\n\t\t}\n#util_bar{\nposition:absolute;\nright:0;\ntop:0;\nwidth:300px;\n}\n.widget-toolbox{\nfloat:right;\n}\n.widget-title-text{font-weight:bold;font-size:9pt;}\n.link{cursor:pointer;}\n.link:hover{color:blue;}\n.pdng_s{padding:6px;}\n</style>\n\"\"\"\n\n\nself.os = ' <html> <head> <title>Workspace</title> <script src=\"/Service/Media?get_media=lazylandscape/js/jquery/jquery.js\"></script> <script src=\"/Service/Media?get_media=lazylandscape/js/jquery/jquery-ui.js\"></script><script src=\"/Service/Media?get_media=lazylandscape/js/codemirror2/codemirror.js\"></script><script src=\"/Service/Media?get_media=lazylandscape/js/codemirror2/python.js\"></script><script src=\"/Service/Media?get_media=lazylandscape/js/codemirror2/javascript.js\"></script> '+jscmd.js+' '+script+' </head> <body> <div id=\"cont\"> </div> </body></html>'", "args": "", "name": "__init__", "cls": 15}}, {"pk": 23, "model": "sh.shmethods", "fields": {"comment": "", "body": "response.write(self.os)", "args": "", "name": "app", "cls": 15}}, {"pk": 24, "model": "sh.shmethods", "fields": {"comment": "", "body": "if(window._widget_reg == undefined)\n{\n        window._widget_reg = {};\n}\n\nif(window._widget_reg[id] != undefined)\n{\n\tvar ww = window._widget_reg[id];\n\tif(ww.minimized)\n\t\tww.restore();\n    return ww;\n}\n\nvar widget = jQuery('<div id=\"'+id+'\" class=\"widget\"></div>');\nvar titletext = jQuery('<span class=\"widget-title-text\">'+title+'</span>');\nvar title = jQuery('<div  class=\"widget-title\"></div>');\nvar viewport = jQuery('<div  class=\"widget-viewport\"></div>');\n\ntitle.append(titletext);\nwidget.append(title);\nwidget.append(viewport);\nviewport.css({ overflow: 'auto' });\nwidget.draggable({      \n                        addClasses:true,\n                        appendTo:\"parent\",\n                        axis:false,\n                        connectToSortable:false,\n                        containment:false,\n                        cursor:\"auto\",\n                        cursorAt:false,\n                        grid:false,\n                        handle:title,\n                        helper:\"original\",\n                        iframeFix:false,\n                        opacity:false,\n                        refreshPositions:false,\n                        revert:false,\n                        revertDuration:500,\n                        scope:\"default\",\n                        scroll:true,\n                        scrollSensitivity:20,\n                        scrollSpeed:20,\n                        snap:false,\n                        snapMode:\"both\",\n                        snapTolerance:20,\n                        stack:false,\n                        zIndex:0\n                });\nwidget.resizable({\n                alsoResize:viewport,\n                animate:false,\n              animateDuration:\"slow\",\n              animateEasing:\"swing\",\n              aspectRatio:false,\n              autoHide:false,\n              containment:false,\n              ghost:false,\n              grid:false,\n              handles:\"se\",\n              helper:false,\n              maxHeight:null,\n              maxWidth:null,\n              minHeight:10,\n              minWidth:10,\n              zIndex:0\n                });\n\nwidget.minimized = false;\n\nwidget.title = title;\nwidget.titletext = titletext;\nwidget.viewport = viewport;\nwidget.css({position:'absolute', width:'300px', top: '100px', left:'100px'});\njQuery('body').append(widget);\nwidget.restore = this.restore;\nwidget.minimize = this.minimize;\nwidget.close = this.close;\nthis.set_tools(widget);\nwindow._widget_reg[id] = widget;\nthis.widget = widget;\nreturn widget;", "args": "id, title", "name": "init", "cls": 16}}, {"pk": 25, "model": "sh.shmethods", "fields": {"comment": "", "body": "if not self.args.has(['id']):\r\n    response.write( self.json.dumps({'error':'not enough args'}))\r\n\r\nsh = __import__('sh')\r\ncls = None\r\ntry:\r\n    cls = sh.models.ShMethods.objects.get(pk=self.args.id)\r\nexcept:\r\n    response.write( self.json.dumps({'error':'No method with ID %s'%(self.args.id,)}))\r\n    return\r\n    \r\no = {'id': cls.id,\r\n'name': cls.name,\r\n'comment' : cls.comment,\r\n'args' : cls.args,\r\n'body': cls.body,\r\n'lang' : cls.cls.lang, }\r\nresponse.write( self.json.dumps(o))\r\n", "args": "", "name": "get_method", "cls": 5}}, {"pk": 26, "model": "sh.shmethods", "fields": {"comment": "", "body": "\nif(window._widget_reg['m_' + id] != undefined)\n{\n\tthis.base = window._widget_reg['m_' + id];\n\tthis.base.restore(this.base);\n}\nelse\n{\n\tthis.base = UiBase.New('JQWidget','m_' + id, title);\n\tthis.code_widget = jQuery('<textarea class=method-edit name=\"nn\"></textarea>');\n\tthis.submit =  jQuery('<div class=\"link submit\" type=\"submit\">save</div>');\n\t\n\tthis.base.widget.viewport.append(this.code_widget);\n\tthis.base.widget.viewport.append(this.submit);\n\t\n\tvar xhr = Network.New('XHR');\n\tvar data = {'command' : 'get_method', 'id': id};\n\txhr.bind(this.handleMethod, {'widget':this});\n\txhr.post('/Service/ShCommand', data);\n\t\n\tthis.submit.bind('click', {'mid':id, 'widget':this, 'callback' : this.handleMethod}, this.save_method);\n}\n", "args": "id, title", "name": "init", "cls": 17}}, {"pk": 27, "model": "sh.shmethods", "fields": {"comment": "", "body": "var data = JSON.parse(this.responseText);\n\nif(data.error == undefined)\n{\n    var that = this.data.widget;\n    that.code_widget.val(data.body);\n    var cm_opt = {};\n    if(data.lang == 'js')\n        cm_opt = {lineWrapping: true, mode: \"javascript\", lineNumbers: true, indentWithTabs: true, indentUnit: 4, tabMode: \"shift\", matchBrackets: true };\n    else\n        cm_opt = {lineWrapping: true, mode: {name: \"python\", version: 2, singleLineStringErrors: false}, lineNumbers: true, indentWithTabs: true, indentUnit: 4, tabMode: \"shift\", matchBrackets: true };\n    that.cm = CodeMirror.fromTextArea(that.code_widget[0], cm_opt);\n    that.base.widget.bind( \"resizestop\", function(event, ui) \n    {\n        var t = that.cm.getValue();\n        that.cm.setValue('');\n        that.cm.refresh();\n        that.cm.setValue(t);\n    });\n}\nelse\n    alert(data.error)", "args": "", "name": "handleMethod", "cls": 17}}, {"pk": 28, "model": "sh.shmethods", "fields": {"comment": "", "body": "var xhr = Network.New('XHR');\r\nvar data = {'command' : 'save_method', 'id': event.data.mid, 'body':event.data.widget.cm.getValue()};\r\nxhr.bind(event.data.widget.callback, {'widget':event.data.widget});\r\nxhr.post('/Service/ShCommand', data);", "args": "event", "name": "save_method", "cls": 17}}, {"pk": 29, "model": "sh.shmethods", "fields": {"comment": "", "body": "if not self.args.has(['id','body']):\n    response.write( self.json.dumps({'error':'not enough args'}))\n\nsh = __import__('sh')\ncls = None\ntry:\n    cls = sh.models.ShMethods.objects.get(pk=self.args.id)\nexcept:\n    response.write( self.json.dumps({'error':'No method with ID %s'%(self.args.id,)}))\n    return\n\ncls.body = self.args.body\ncls.save()\n    \no = {'id': cls.id,\n'name': cls.name,\n'comment' : cls.comment,\n'args' : cls.args,\n'body': cls.body,\n'lang' : cls.cls.lang }\nresponse.write( self.json.dumps(o))\n\n", "args": "", "name": "save_method", "cls": 5}}, {"pk": 30, "model": "sh.shmethods", "fields": {"comment": "", "body": "var util_bar = jQuery('#util_bar');\r\nif(util_bar.length == 0)\r\n{\r\n\tutil_bar = jQuery('<div id=\"util_bar\"></div>');\r\n\tjQuery('body').append(util_bar);\r\n}\r\nvar restorefunc = this.restore;\r\nvar widget = this;\r\nthis.titletext.click(function(){restorefunc(widget);});\r\nthis.titletext.addClass('link');\r\nthis.minimized = true;\r\nthis.storepos = {'left' : this.offset().left, 'top': this.offset().top};\r\nthis.storedim = {width: this.width(), height: this.height()};\r\nthis.viewport.hide();\r\nutil_bar.append(this);\r\nthis.css({position:'static', width: 'auto', height: 'auto'});\r\n", "args": "", "name": "minimize", "cls": 16}}, {"pk": 31, "model": "sh.shmethods", "fields": {"comment": "", "body": "jQuery('body').append(widget);\r\n\r\nwidget.titletext.unbind('click');\r\nwidget.titletext.removeClass('link');\r\nwidget.minimized = false;\r\nwidget.css({position :'relative'});\r\nwidget.width(widget.storedim.width);\r\nwidget.height(widget.storedim.height);\r\nwidget.offset(widget.storepos);\r\nwidget.viewport.show();", "args": "widget", "name": "restore", "cls": 16}}, {"pk": 32, "model": "sh.shmethods", "fields": {"comment": "", "body": "var toolbox = jQuery('<div class=\"widget-toolbox\">|</div>');\r\nvar close = jQuery('<span class=\"link widget-tool widget-tool-close\"> x </span>');\r\nvar minim = jQuery('<span  class=\"link widget-tool widget-tool-minimize\"> - </span>');\r\n\r\nclose.click(function(){widget.close();});\r\nminim.click(function(){widget.minimize();});\r\n\r\ntoolbox.append(close);\r\ntoolbox.append(minim);\r\nwidget.title.prepend(toolbox);", "args": "widget", "name": "set_tools", "cls": 16}}, {"pk": 33, "model": "sh.shmethods", "fields": {"comment": "", "body": "var id = this.attr('id');\r\ndelete window._widget_reg[id];\r\nthis.remove();", "args": "id", "name": "close", "cls": 16}}, {"pk": 34, "model": "sh.shmethods", "fields": {"comment": "", "body": "var wid = 'klass_' + cls.id;\nvar wtitle = cls.field + '.' + cls.name + ' ('+cls.lang+')';\nthis.Parent().init(wid, wtitle);\nthis.widget.viewport.addClass('pdng_s');\nthis.methodbox = jQuery('<div class=\"method-box\"></div>');\nthis.widget.viewport.append(this.methodbox);\nfor(var mn in cls.methods)\n{\n\tthis.method_item(cls.methods[mn]);\n}\n\nvar new_m = jQuery('<div class=\"method-new\"></div>');\nvar new_i = jQuery('<input type=\"text\" name=\"method-new\"/>');\nvar new_s = jQuery('<span class=\"link method-new-submit\">new</span>');\nnew_i.class_id = cls.id;\nnew_m.append(new_i);\nnew_m.append(new_s);\nnew_s.bind('click',{that:this,input:new_i},this.make_new);\nthis.widget.viewport.append(new_m);", "args": "cls", "name": "init", "cls": 18}}, {"pk": 35, "model": "sh.shmethods", "fields": {"comment": "", "body": "var that = event.data.that;\nif(event.data.input.val().length > 0)\n{\n\tjQuery.post('/Service/ShCommand', \n\t\t\t\t{command:'new_method',\n\t\t\t\t cls: event.data.input.class_id,\n\t\t\t\t name: event.data.input.val()},\n\t\t\t\tfunction(data){\n\t\t\t\t\tvar d = JSON.parse(data);\n\t\t\t\t\tif(d.error != undefined)\n\t\t\t\t\t\talert(d.error);\n\t\t\t\t\telse\n\t\t\t\t\t\tthat.method_item(d);\n\t\t\t\t});\n\tevent.data.input.val('');\n}", "args": "event", "name": "make_new", "cls": 18}}, {"pk": 36, "model": "sh.shmethods", "fields": {"comment": "Make an entry in the list of methods", "body": "var mcom = jQuery('<div class=\"link method-link\">'+method.name+'</div>');\nthis.methodbox.append(mcom);\nmcom.bind('click', {'mid': method.id, 'title': method.klass+'.'+method.name} ,function(event){\n\tUiBase.New('JQMethodWidget', event.data.mid, event.data.title);\n});\nvar minfo = jQuery('<div class=\"method-comment\">'+method.comment+'</div>');\nthis.methodbox.append(minfo);", "args": "method", "name": "method_item", "cls": 18}}, {"pk": 37, "model": "sh.shmethods", "fields": {"comment": "", "body": "var d = JSON.parse(this.responseText);\r\nif(d.error != undefined)\r\n\talert(d.error);\r\nelse\r\n{\r\n\tUiBase.New('JQClassWidget', d);\r\n}", "args": "data", "name": "handleCommand", "cls": 14}}, {"pk": 38, "model": "sh.shmethods", "fields": {"comment": "", "body": "var c = jQuery(cont);\nif(c.length > 0)\n{\n\tthis._canvas = jQuery('<canvas width=\"'+width+'\" height=\"'+height+'\"></canvas>');\n\tc.append(this._canvas);\n}\nreturn this;", "args": "cont, width, height", "name": "init", "cls": 19}}, {"pk": 39, "model": "sh.shmethods", "fields": {"comment": "", "body": "this.wid = 'cnvs_' + (Math.floor(Math.random() * 1000000000));\nthis.Parent().init(this.wid, wtitle);\nvar cont = jQuery('<div id=\"cont_'+this.wid+'\"></div>');\njQuery('body').append(cont);\nthis._cview = Graphic.New('CanvasView', 'cont_'+this.wid, 600, 600);\nthis.widget.viewport.append(this._cview._canvas);\nreturn this;\n", "args": "", "name": "init", "cls": 20}}, {"pk": 40, "model": "sh.shmethods", "fields": {"comment": "Return actual canvas element", "body": "", "args": "", "name": "canvas", "cls": 20}}, {"pk": 41, "model": "sh.shmethods", "fields": {"comment": "", "body": "self.os = __import__('os', globals(), locals(), [], -1)\nself.json = __import__('json', globals(), locals(), [], -1)", "args": "", "name": "__init__", "cls": 21}}, {"pk": 42, "model": "sh.shmethods", "fields": {"comment": "", "body": "args = Network.HTTPRequest(request)\nif args.has('command'):\n\trid = ''\n\tif args.has('rid'):\n\t\trid = args.rid\n    if hasattr(self.os, args.command) and callable(getattr(self.os, args.command)):\n\t\tlargs = []\n\t\tret = None\n\t\tif(args.has(['args'])):\n\t\t\tlargs = [x for x in args.args.split(',') if x]\n\t\t\t#largs = args.args.split(',')\n\t\ttry:\n\t\t\tif len(largs) == 0:\n\t\t\t\tret = getattr(self.os, args.command)()\n\t\t\telif len(largs) == 1:\n\t\t\t\tret = getattr(self.os, args.command)(largs[0])\n\t\t\telif len(largs) == 2:\n\t\t\t\tret = getattr(self.os, args.command)(largs[0], largs[1])\n\t\t\telif len(largs) == 3:\n\t\t\t\tret = getattr(self.os, args.command)(largs[0], largs[1], largs[2])\n\t\t\telif len(largs) == 4:\n\t\t\t\tret = getattr(self.os, args.command)(largs[0], largs[1], largs[2], largs[3])\n\t\texcept Exception as e:\n\t\t\tresponse.write(self.json.dumps({'rid': rid,'error' : '%s(%s) raised [%s]' % (args.command,largs,e)}))\n\t\t\treturn\n\t\t\t\n\t\tresponse.write(self.json.dumps({'rid': rid, 'result' : ret}))\n\telse:\n\t\tresponse.write(self.json.dumps({'rid': rid,'error':'%s not found' % (args.command,)}))\nelse:\n\tresponse.write(self.json.dumps({'rid': rid,'error' : 'No command'}))\n\t\t\t\n\t\t\t", "args": "", "name": "app", "cls": 21}}, {"pk": 43, "model": "sh.shmethods", "fields": {"comment": "", "body": "var id = (Math.floor(Math.random() * 1000000000));\nvar wid = 'osterm_' + id;\nvar rid = 'rb_' + id;\nvar wtitle = 'osTerminal';\nthis.Parent().init(wid, wtitle);\n\n\n\nthis.input = jQuery('<input type=\"text\"/>');\nthis.submit = jQuery('<span class=\"link\">submit</span>');\nthis.response_box = jQuery('<div id=\"'+rid+'\"></div>');\n\nthis.widget.viewport.append(this.input);\nthis.widget.viewport.append(this.submit);\nthis.widget.viewport.append(this.response_box);\n\nvar that = this;\nthis.submit.bind('click', \n\t\t\t\t {input : this.input, \n\t\t\t\t  responsebox  : this.response_box}, \n\t\t\t\t function(event)\n\t\t\t\t {\n\t\t\t\t\t var li = event.data.input.val().split(' ');\n\t\t\t\t\t if(li.length > 0)\n\t\t\t\t\t {\n\t\t\t\t\t\t var com = li.shift();\n\t\t\t\t\t\t var args = '';\n\t\t\t\t\t\t var sep = '';\n\t\t\t\t\t\t for(var i =0; i < li.length; i++)\n\t\t\t\t\t\t {\n\t\t\t\t\t\t\t args += sep + li[i];\n\t\t\t\t\t\t\t sep = ',';\n\t\t\t\t\t\t }\n\t\t\t\t\t\t jQuery.post('/Service/OSCommand',\n\t\t\t\t\t\t\t\t\t\t\t\t\t {rid:rid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t command:com,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  args:args},\n\t\t\t\t\t\t\t\t\t\t\t\t\tthat.handleResult);\n\t\t\t\t\t }\n\t\t\t\t });\n\n", "args": "", "name": "init", "cls": 22}}, {"pk": 44, "model": "sh.shmethods", "fields": {"comment": "", "body": "var data = JSON.parse(text);\nif(data.error != undefined)\n{\n\talert(data.error);\n}\nelse\n{\n\tvar rb = jQuery('#'+data.rid);\n\trb.append('<pre>'+data.result+'</pre>');\n}", "args": "text", "name": "handleResult", "cls": 22}}, {"pk": 45, "model": "sh.shmethods", "fields": {"comment": "Wrap Fontforge module", "body": "self.fontforge = __import__('fontforge')", "args": "", "name": "__init__", "cls": 23}}, {"pk": 46, "model": "sh.shmethods", "fields": {"comment": "", "body": "return getattr(self.fontforge, name)", "args": "name", "name": "__getattr__", "cls": 23}}, {"pk": 47, "model": "sh.shmethods", "fields": {"comment": "", "body": "if not self.args.has(['cls','name']):\n    response.write( self.json.dumps({'error':'not enough args'}))\n\t\nsh = __import__('sh')\t\ncls = None\ntry:\n\tcls = ShClasses(pk=self.args.cls)\nexcept Exception as e:\n\tresponse.write(self.json.dumps({'error':'No class with id = %s to attach this method to.\\n %s'%(self.args.cls,e,)}))\nelse:\n\tm = sh.models.ShMethods()\n\tm.cls = cls\n\tfor i in ['name','comment','args','body']:\n\t\tif self.args.has(i):\n\t\t\tsetattr(m, i, getattr(self.args, i))\n\t\t\t\n\tm.save()\n\to = {'id': m.id,\n\t'name': m.name,\n\t'comment' : m.comment,\n\t'args' : m.args,\n\t'body': m.body,\n\t'lang': m.cls.lang }\n\tresponse.write( self.json.dumps(o))\n", "args": "", "name": "new_method", "cls": 5}}, {"pk": 48, "model": "sh.shmethods", "fields": {"comment": "", "body": "", "args": "", "name": "__init__", "cls": 24}}, {"pk": 49, "model": "sh.shmethods", "fields": {"comment": "", "body": "", "args": "", "name": "test", "cls": 24}}, {"pk": 50, "model": "sh.shmethods", "fields": {"comment": "", "body": "ll = __import__('lazylandscape')\r\nself.root = ll.settings.MEDIA_ROOT\r\nif not self.root.endswith('/'):\r\n\tself.root = self.root + '/'\r\n\t\r\nself.mime = __import__('mimetypes')\r\nself.mime.init()\r\n\r\nself.os = __import__('os')\r\nself.json = __import__('json')", "args": "", "name": "__init__", "cls": 25}}, {"pk": 51, "model": "sh.shmethods", "fields": {"comment": "", "body": "os = __import__('os')\r\nif not os.path.exists(self.filepath(path)):\r\n\tresponse.status_code = '404 Not Found'\r\n\tresponse.write('<h1>File <em>%s</em> not found</h1>'%(self.filepath(path),))\r\n\treturn\r\nf = open(self.filepath(path), 'rb')\r\ntry:\r\n\tmt = self.mime.guess_type(self.filepath(path))\r\n\ttype = mt[0]\r\n\tenc = ''\r\n\tif mt[1]:\r\n\t\tenc = ';' + mt[1]\r\n\tresponse['Content-Type'] = type + enc\r\n\tresponse['Content-Length'] = self.os.path.getsize(self.filepath(path))\r\n\tresponse.write(f.read())\r\nexcept Exception as e:\r\n\tresponse.write('<h1>Exception occured</h1>%s'%(e,))\r\nfinally:\r\n\tf.close()", "args": "path", "name": "GetFile", "cls": 25}}, {"pk": 52, "model": "sh.shmethods", "fields": {"comment": "", "body": "json = __import__('json')\r\nif request.FILES and 'push_media' in request.FILES.keys():\r\n\tp = self.filepath(path)\r\n\tf = request.FILES['push_media']\r\n\tif not self.os.path.isdir(p):\r\n\t\ttry:\r\n\t\t\tself.os.makedirs(p)\r\n\t\texcept self.os.error:\r\n\t\t\tresponse.write(json.dumps({'error':'Cannot create dir'}))\r\n\t\t\treturn\r\n\tdestination = open(p + '/' +  f.name , 'wb+')\r\n\ttry:\r\n\t\tfor chunk in f.chunks():\r\n\t\t\tdestination.write(chunk)\r\n\texcept Exception:\r\n\t\tresponse.write(json.dumps({'error':'Cannot write'}))\r\n\tfinally:\r\n\t\tdestination.close()\r\nelse:\r\n\tresponse.write(json.dumps({'error':'Nothing to push dude'}))", "args": "path", "name": "PushFile", "cls": 25}}, {"pk": 54, "model": "sh.shmethods", "fields": {"comment": "", "body": "if 'get_media' in request.POST.keys():\r\n\treturn self.GetFile(request.POST['get_media'])\r\nelif 'get_media' in request.GET.keys():\r\n\treturn self.GetFile(request.GET['get_media'])\r\nif 'list_media' in request.POST.keys():\r\n\treturn self.ListFiles(request.POST['list_media'])\r\nif 'list_media' in request.GET.keys():\r\n\treturn self.ListFiles(request.GET['list_media'])\r\nelif 'push_media_path' in request.POST.keys():\r\n\treturn self.PushFile(request.POST['push_media_path'])\r\n\t\r\nresponse.write('<h1>???</h1>')", "args": "", "name": "app", "cls": 25}}, {"pk": 55, "model": "sh.shmethods", "fields": {"comment": "", "body": "r = \"\"\"\n<html>\n<head><title>TestMedia</title>\n<script src=\"/Service/Media?get_media=lazylandscape/js/jquery/jquery.js\"></script>\n<style>\n.dir{\ncursor:pointer;\ncolor:blue;\n}\n.file{\ncursor:pointer;\ncolor:#666;\n}\n</style>\n</head>\n<body>\n<form name=\"test\" action=\"/Service/Media\" method=\"POST\">\n<input type=\"text\" name=\"get_media\"/>\n<input type=\"submit\" value=\"Get Media\"/>\n</form>\n<form name=\"test\" action=\"/Service/Media\" method=\"POST\" enctype=\"multipart/form-data\">\n<input type=\"file\" name=\"push_media\"/>\n<input type=\"text\" name=\"push_media_path\">\n<input type=\"submit\" value=\"Push Media\"/>\n</form>\n<div id=\"list\"></div>\n</body>\n<script>\n$(document).ready(function(){\n\nvar rr = function(text)\n{\n\td=JSON.parse(text);\n\tret = '';\n\tfor(var i in d.dirs)\n\t{\n\t\tret += '<li class=\"dir\">'+d.dirs[i]+'</li>';\n\t}\n\tfor(var i in d.files)\n\t{\n\t\tret += '<li class=\"file\">'+d.files[i]+'</li>';\n\t}\n\t$('#list').empty();\n\t$('#list').append($('<ul>'+ret+'</ul>'));\n\t$('.dir').click(function(){\n\t\tvar p = $(this).text();\n\t\t$.post('/Service/Media?list_media='+p,rr);\n\t});\n\t$('.file').click(function(){\n\t\tvar p = $(this).text();\n\t\twindow.location = '/Service/Media?get_media='+p ;\n\t});\n}\n\n$.post('/Service/Media?list_media=',rr);\n});\n</script>\n</html>\n\"\"\"\n\nresponse.write(r)\n", "args": "", "name": "app", "cls": 26}}, {"pk": 56, "model": "sh.shmethods", "fields": {"comment": "", "body": "return self.root + p", "args": "p", "name": "filepath", "cls": 25}}, {"pk": 57, "model": "sh.shmethods", "fields": {"comment": "", "body": "p = self.filepath(path)\nl = self.os.listdir(p)\n\nfiles = []\ndirs = []\nfor i in l:\n\tif self.os.path.isdir(p+'/'+i):\n\t\tdirs.append(path + '/' +i)\n\telse:\n\t\tfiles.append(path + '/' +i)\n\t\t\nresponse.write(self.json.dumps({'dirs' : dirs, 'files': files}))", "args": "path", "name": "ListFiles", "cls": 25}}]