Merge branch 'master' of git://github.com/rmehta/wnframework
This commit is contained in:
commit
e279c8fc81
4 changed files with 106 additions and 34 deletions
98
cgi-bin/get_module_js.cgi
Executable file
98
cgi-bin/get_module_js.cgi
Executable file
|
|
@ -0,0 +1,98 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import cgi
|
||||
import datetime
|
||||
import os
|
||||
|
||||
try:
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
out = ''
|
||||
out_buf, str_out = '', ''
|
||||
jsdir='../js'
|
||||
jsonout= {}
|
||||
|
||||
# Traceback
|
||||
# ---------
|
||||
def getTraceback():
|
||||
import sys, traceback, string
|
||||
type, value, tb = sys.exc_info()
|
||||
body = "Traceback (innermost last):\n"
|
||||
list = traceback.format_tb(tb, None) \
|
||||
+ traceback.format_exception_only(type, value)
|
||||
body = body + "%-20s %s" % (string.join(list[:-1], ""), list[-1])
|
||||
return body
|
||||
|
||||
def load_js_from_file(module_name):
|
||||
global out
|
||||
global jsonout
|
||||
import webnotes.utils.jsnamespace as jsn
|
||||
filename = jsn.jsNamespace.modname_to_filename(module_name,jsdir)
|
||||
import os
|
||||
try:
|
||||
f = open(os.path.join(filename))
|
||||
try:
|
||||
out = f.read()
|
||||
finally:
|
||||
f.close()
|
||||
except IOError,e:
|
||||
out = "Not Found: %s" % filename
|
||||
jsonout[module_name]=out
|
||||
|
||||
def load_js_module(module_name):
|
||||
global jsonout
|
||||
from webnotes import defs
|
||||
devmode = getattr(defs,'developer_mode')
|
||||
if devmode:
|
||||
import compilejs
|
||||
compilejs.wnJSCompiler.compilejs(jsdir)
|
||||
if module_name not in jsonout:
|
||||
dependent_mods = get_dependencies(module_name)
|
||||
for module in dependent_mods:
|
||||
load_js_from_file(module)
|
||||
load_js_from_file(module_name)
|
||||
|
||||
def get_dependencies(module_name):
|
||||
import webnotes.utils.jsdependency as jsd
|
||||
ret = jsd.jsDependencyBuilder.build_dependency(jsdir,module_name)
|
||||
return ret
|
||||
|
||||
|
||||
def compress_string(buf):
|
||||
import gzip, cStringIO
|
||||
zbuf = cStringIO.StringIO()
|
||||
zfile = gzip.GzipFile(mode = 'wb', fileobj = zbuf, compresslevel = 5)
|
||||
zfile.write(buf)
|
||||
zfile.close()
|
||||
return zbuf.getvalue()
|
||||
|
||||
compress = 0
|
||||
try:
|
||||
if string.find(os.environ["HTTP_ACCEPT_ENCODING"], "gzip") != -1:
|
||||
compress = 1
|
||||
except:
|
||||
pass
|
||||
|
||||
load_js_module(form.getvalue('module'))
|
||||
#load_js_module('wn.modules')
|
||||
|
||||
if compress and len(out)>512:
|
||||
out_buf = compress_string(str_out)
|
||||
print "Content-Encoding: gzip"
|
||||
print "Content-Length: %d" % (len(out_buf))
|
||||
|
||||
print "Content-Type: text/javascript"
|
||||
|
||||
# Headers end
|
||||
print
|
||||
|
||||
if out_buf:
|
||||
sys.stdout.write(out_buf)
|
||||
elif out:
|
||||
import json
|
||||
print json.dumps(jsonout)
|
||||
|
||||
except Exception, e:
|
||||
print "Content-Type: text/javascript"
|
||||
print
|
||||
print getTraceback()#.replace('\n','<br>')
|
||||
38
cgi-bin/getjsfile.cgi
Executable file → Normal file
38
cgi-bin/getjsfile.cgi
Executable file → Normal file
|
|
@ -9,8 +9,6 @@ try:
|
|||
form = cgi.FieldStorage()
|
||||
out = ''
|
||||
out_buf, str_out = '', ''
|
||||
jsdir='../js'
|
||||
jsonout= {}
|
||||
|
||||
# Traceback
|
||||
# ---------
|
||||
|
|
@ -23,40 +21,18 @@ try:
|
|||
body = body + "%-20s %s" % (string.join(list[:-1], ""), list[-1])
|
||||
return body
|
||||
|
||||
def load_js_from_file(module_name):
|
||||
def load_js_file():
|
||||
global out
|
||||
global jsonout
|
||||
import webnotes.utils.jsnamespace as jsn
|
||||
filename = jsn.jsNamespace.modname_to_filename(module_name,jsdir)
|
||||
filename = form.getvalue('filename')
|
||||
import os
|
||||
try:
|
||||
f = open(os.path.join(filename))
|
||||
f = open(os.path.join('../js/', filename))
|
||||
try:
|
||||
out = f.read()
|
||||
finally:
|
||||
f.close()
|
||||
except IOError,e:
|
||||
out = "Not Found: %s" % filename
|
||||
jsonout[module_name]=out
|
||||
|
||||
def load_js_module(module_name):
|
||||
global jsonout
|
||||
from webnotes import defs
|
||||
devmode = getattr(defs,'developer_mode')
|
||||
if devmode:
|
||||
import compilejs
|
||||
compilejs.wnJSCompiler.compilejs(jsdir)
|
||||
if module_name not in jsonout:
|
||||
dependent_mods = get_dependencies(module_name)
|
||||
for module in dependent_mods:
|
||||
load_js_from_file(module)
|
||||
load_js_from_file(module_name)
|
||||
|
||||
def get_dependencies(module_name):
|
||||
import webnotes.utils.jsdependency as jsd
|
||||
ret = jsd.jsDependencyBuilder.build_dependency(jsdir,module_name)
|
||||
return ret
|
||||
|
||||
|
||||
def compress_string(buf):
|
||||
import gzip, cStringIO
|
||||
|
|
@ -73,8 +49,7 @@ try:
|
|||
except:
|
||||
pass
|
||||
|
||||
load_js_module(form.getvalue('module'))
|
||||
#load_js_module('wn.modules')
|
||||
load_js_file()
|
||||
|
||||
if compress and len(out)>512:
|
||||
out_buf = compress_string(str_out)
|
||||
|
|
@ -89,10 +64,9 @@ try:
|
|||
if out_buf:
|
||||
sys.stdout.write(out_buf)
|
||||
elif out:
|
||||
import json
|
||||
print json.dumps(jsonout)
|
||||
print out
|
||||
|
||||
except Exception, e:
|
||||
print "Content-Type: text/javascript"
|
||||
print
|
||||
print getTraceback()#.replace('\n','<br>')
|
||||
print getTraceback().replace('\n','<br>')
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ wn.widgets.Dialog = function(opts) {
|
|||
this.wrapper = $a(popup_cont, 'div', 'dialog_wrapper');
|
||||
|
||||
if(this.opts.width)
|
||||
$w(this.wrapper, this.opts.width + 'px');
|
||||
this.wrapper.style.width = this.opts.width + 'px';
|
||||
|
||||
this.make_head();
|
||||
this.body = $a(this.wrapper, 'div', 'dialog_body');
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ return ret;}
|
|||
this.set_value=function(key,val){var f=this.fields_dict[key];if(f){f.set_input(val);f.refresh_mandatory();}}
|
||||
this.set_values=function(dict){for(var key in dict){if(this.fields_dict[key]){this.set_value(key,dict[key]);}}}}
|
||||
wn.widgets.Dialog=function(opts){this.opts=opts;this.display=false;this.make=function(opts){if(opts)this.opts=opts;this.wrapper=$a(popup_cont,'div','dialog_wrapper');if(this.opts.width)
|
||||
$w(this.wrapper,this.opts.width+'px');this.make_head();this.body=$a(this.wrapper,'div','dialog_body');if(this.opts.fields)
|
||||
this.wrapper.style.width=this.opts.width+'px';this.make_head();this.body=$a(this.wrapper,'div','dialog_body');if(this.opts.fields)
|
||||
this.make_fields(this.body,this.opts.fields);}
|
||||
this.make_head=function(){var me=this;this.head=$a(this.wrapper,'div','dialog_head');var t=make_table(this.head,1,2,'100%',['100%','16px'],{padding:'2px'});$y($td(t,0,0),{paddingLeft:'16px',fontWeight:'bold',fontSize:'14px',textAlign:'center'});$y($td(t,0,1),{textAlign:'right'});var img=$a($td(t,0,01),'img','',{cursor:'pointer'});img.src='images/icons/close.gif';this.title_text=$td(t,0,0);this.set_title(this.opts.title);img.onclick=function(){if(me.oncancel)me.oncancel();me.hide();}
|
||||
this.cancel_img=img;}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue