Procházet zdrojové kódy

new app ready to fly

version-14
Rushabh Mehta před 13 roky
rodič
revize
5a4fd43b31
11 změnil soubory, kde provedl 221 přidání a 21 odebrání
  1. +14
    -5
      README.md
  2. +23
    -0
      conf/app.js
  3. +172
    -0
      conf/build.json
  4. +1
    -1
      js/core.js
  5. +3
    -3
      js/core.min.js
  6. +3
    -2
      js/legacy/app.js
  7. +1
    -1
      js/wn/request.js
  8. +1
    -0
      js/wn/views/pageview.js
  9. +2
    -2
      py/build/bundle.py
  10. +1
    -1
      py/webnotes/auth.py
  11. +0
    -6
      py/webnotes/boot.py

+ 14
- 5
README.md Zobrazit soubor

@@ -6,14 +6,23 @@ Projects: [erpnext](http://erpnext.org) | [webnotes/erpnext](https://github.com/

## Setup

- In your application root, set wnframework folder as the "lib" folder.
- Copy index.cgi, build.json, wnf.py in the application root
- update "conf.py" with database, email authentication info
To start a new project, in the application root:

1. Set wnframework folder as the `lib` folder.
1. Copy the following files from lib/conf: `index.cgi`, `build.json`, `conf.py`.
1. Create folders `js`, `css`, `modules`, `modules/startup`. These folders contain the js, css assets and modules folder is where all the new application modules will be created.
1. Update database name/password in conf.py and set modules folder to "modules".
1. Run `$ lib/wnf.py --install dbrootpassword newdbname lib/conf/Framework.sql` to install a fresh database.
1. Create `app.js` containing basic application info (see `lib/conf`)
1. Create empty files `__init__.py` and `event_handlers.py` in `modules/startup`. This is where you write all events (like, onlogin, onlogout etc)
1. Run `$ lib/wnf.py -b` to build js and css assets from `build.json`.
1. Go to the browser and go to your application folder. The admin username is "Administrator" and password is "admin"

enjoy!

## wnf.py

wnf.py is the command line utility to build client side files. Usually all client-side files
that are common are build in js/all-web.js (for non logged in users) or js/all-app.js (for logged in users)
`$ lib/wnf.py --help` for more info

## License


+ 23
- 0
conf/app.js Zobrazit soubor

@@ -0,0 +1,23 @@
wn.app = {
name: 'Yourapp',
license: 'GNU/GPL - Usage Condition: All "yourapp" branding must be kept as it is',
source: 'https://github.com/webnotes/yourapp',
publisher: 'Your Company',
copyright: '© Your Company',
version: window._version_number
}

// call startup when ready
$(document).bind('ready', function() {
startup();
});

$(document).bind('toolbar_setup', function() {
$('.brand').html('yourbrand\
<i class="icon-home icon-white navbar-icon-home" ></i>')
.hover(function() {
$(this).find('.icon-home').addClass('navbar-icon-home-hover');
}, function() {
$(this).find('.icon-home').removeClass('navbar-icon-home-hover');
});
});

+ 172
- 0
conf/build.json Zobrazit soubor

@@ -0,0 +1,172 @@
[
{
"lib/js/core.min.js": [
"lib/js/wn/class.js",
"lib/js/wn/provide.js",
"lib/js/wn/versions.js",
"lib/js/wn/assets.js",
"lib/js/wn/require.js",
"lib/js/wn/dom.js",
"lib/js/wn/model.js",
"lib/js/wn/misc/tools.js",
"lib/js/wn/misc/user.js",
"lib/js/lib/json2.js",
"lib/js/wn/router.js",
"lib/js/wn/ui/listing.js",
"lib/js/wn/views/container.js",
"lib/js/wn/views/doclistview.js",
"lib/js/wn/views/pageview.js",
"lib/js/wn/views/formview.js",
"lib/js/wn/views/reportview.js",
"lib/js/wn/request.js",
"lib/js/core.js"
]
},

{
"lib/js/wn/ui/toolbar.min.js": [
"lib/js/wn/ui/toolbar/selector_dialog.js",
"lib/js/wn/ui/toolbar/new.js",
"lib/js/wn/ui/toolbar/search.js",
"lib/js/wn/ui/toolbar/report.js",
"lib/js/wn/ui/toolbar/recent.js",
"lib/js/wn/ui/toolbar/toolbar.js"
]
},
{
"lib/js/legacy/report.compressed.js": [
"lib/js/legacy/widgets/report_builder/report_builder.js",
"lib/js/legacy/widgets/report_builder/datatable.js",
"lib/js/legacy/widgets/report_builder/calculator.js"
]
},

{
"css/all-web.css": [
"lib/css/legacy/body.css",
"lib/css/legacy/messages.css",
"lib/css/legacy/dialog.css",
"lib/css/bootstrap/headings.css",
"lib/css/bootstrap/buttons.css",
"lib/css/bootstrap/navbar.css",
"lib/css/bootstrap/dropdown.css",
"lib/css/bootstrap/tooltip.css",
"lib/css/ui/fonts.css",
"lib/css/ui/list.css"
]
},
{
"css/all-app.css": [
"lib/css/legacy/body.css",
"lib/css/legacy/messages.css",
"lib/css/legacy/forms.css",
"lib/css/legacy/grid.css",
"lib/css/legacy/listing.css",
"lib/css/legacy/report.css",
"lib/css/legacy/dialog.css",
"lib/css/legacy/tabs.css",
"lib/css/legacy/sidebar.css",
"lib/css/Aristo/aristo.selected.css",
"lib/css/ui/list.css",
"lib/css/ui/views.css",
"lib/css/ui/fonts.css",
"lib/css/bootstrap/headings.css",
"lib/css/bootstrap/buttons.css",
"lib/css/bootstrap/navbar.css",
"lib/css/bootstrap/dropdown.css",
"lib/css/bootstrap/tooltip.css",
"lib/css/bootstrap/label.css",
"lib/css/bootstrap/icons.css",
"lib/css/bootstrap/popover.css",
]
},

{
"js/all-web.js": [
"lib/js/lib/history/history.min.js:concat",
"lib/js/lib/bootstrap.min.js:concat",
"lib/js/core.min.js:concat",
"lib/js/legacy/globals.js",
"lib/js/legacy/utils/datatype.js",
"lib/js/legacy/utils/datetime.js",
"lib/js/legacy/utils/dom.js",
"lib/js/legacy/utils/handler.js",
"lib/js/legacy/utils/msgprint.js",
"lib/js/wn/ui/appframe.js",
"lib/js/wn/ui/dialog.js",
"lib/js/legacy/widgets/dialog.js",
"lib/js/wn/ui/listing.js",
"lib/js/legacy/webpage/page_header.js",
"lib/js/legacy/webpage/spinner.js",
"lib/js/legacy/webpage/loaders.js",
"lib/js/legacy/wn/widgets/footer.js",
"lib/js/legacy/model/local_data.js",
"lib/js/legacy/model/doclist.js",
"lib/js/legacy/app.js",
"js/app.js"
]
},
{
"js/all-app.js": [
"lib/js/lib/history/history.min.js:concat",
"lib/js/lib/jquery/jquery.ui.core.js:concat",
"lib/js/lib/jquery/jquery.ui.datepicker.js:concat",
"lib/js/lib/jquery/jquery.ui.autocomplete.js:concat",
"lib/js/lib/tiny_mce_33/jquery.tinymce.js:concat",
"lib/js/lib/bootstrap.min.js:concat",
"lib/js/lib/sprintf.js",
"lib/js/core.min.js:concat",
"lib/js/legacy/globals.js",
"lib/js/legacy/utils/datatype.js",
"lib/js/legacy/utils/datetime.js",
"lib/js/legacy/utils/dom.js",
"lib/js/legacy/utils/handler.js",
"lib/js/legacy/utils/msgprint.js",
"lib/js/legacy/utils/printElement.js",
"lib/js/legacy/widgets/form/fields.js",
"lib/js/wn/ui/appframe.js",
"lib/js/wn/ui/dialog.js",
"lib/js/wn/ui/button.js",
"lib/js/legacy/widgets/dialog.js",
"lib/js/legacy/widgets/layout.js",
"lib/js/legacy/widgets/tabbedpage.js",
"lib/js/legacy/webpage/page_header.js",
"lib/js/legacy/widgets/tags.js",
"lib/js/legacy/widgets/export_query.js",
"lib/js/legacy/webpage/search.js",
"lib/js/legacy/webpage/spinner.js",
"lib/js/legacy/webpage/error_console.js",
"lib/js/legacy/webpage/loaders.js",
"lib/js/legacy/webpage/uploader.js",
"lib/js/legacy/wn/page_layout.js",
"lib/js/legacy/wn/widgets/page_sidebar.js",
"lib/js/legacy/wn/widgets/footer.js",
"lib/js/legacy/model/local_data.js",
"lib/js/legacy/model/doclist.js",
"lib/js/wn/ui/toolbar.min.js:concat",
"lib/js/wn/views/breadcrumbs.js",
"lib/js/legacy/widgets/form/fields.js",
"lib/js/legacy/widgets/form/form_dialog.js",
"lib/js/legacy/widgets/form/form_header.js",
"lib/js/legacy/widgets/form/form.js",
"lib/js/legacy/widgets/form/form_fields.js",
"lib/js/legacy/widgets/form/grid.js",
"lib/js/legacy/widgets/form/form_grid.js",
"lib/js/legacy/widgets/form/print_format.js",
"lib/js/legacy/widgets/form/email.js",
"lib/js/legacy/widgets/form/clientscriptAPI.js",
"lib/js/legacy/widgets/form/form_comments.js",
"lib/js/legacy/wn/widgets/form/sidebar.js",
"lib/js/legacy/wn/widgets/form/comments.js",
"lib/js/legacy/wn/widgets/form/attachments.js",
"lib/js/legacy/wn/widgets/form/assign_to.js",
"lib/js/legacy/app.js",
"js/app.js"
]
}
]


+ 1
- 1
js/core.js Zobrazit soubor

@@ -25,7 +25,7 @@
if(!console) {
var console = {
log: function(txt) {
errprint(txt);
alert(txt);
}
}
}


+ 3
- 3
js/core.min.js Zobrazit soubor

@@ -287,7 +287,7 @@ if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';da
/*
* lib/js/wn/views/pageview.js
*/
wn.provide('wn.views.pageview');wn.views.pageview={pages:{},with_page:function(name,callback){if(!locals.Page[name]){wn.call({method:'webnotes.widgets.page.getpage',args:{'name':name},callback:callback});}else{callback();}},show:function(name){wn.views.pageview.with_page(name,function(){if(!wn.pages[name]){wn.views.pageview.pages[name]=new wn.views.Page(name);}
wn.provide('wn.views.pageview');wn.views.pageview={pages:{},with_page:function(name,callback){if(!locals.Page[name]){wn.call({method:'webnotes.widgets.page.getpage',args:{'name':name},callback:callback});}else{callback();}},show:function(name){if(!name)return;wn.views.pageview.with_page(name,function(){if(!wn.pages[name]){wn.views.pageview.pages[name]=new wn.views.Page(name);}
wn.container.change_to(name);});}}
wn.views.Page=Class.extend({init:function(name){this.name=name;var me=this;this.pagedoc=locals.Page[this.name];this.wrapper=wn.container.add_page(this.name);this.wrapper.label=this.pagedoc.title||this.pagedoc.name;this.wrapper.innerHTML=this.pagedoc.content;wn.dom.eval(this.pagedoc.__script||this.pagedoc.script||'');wn.dom.set_style(this.pagedoc.style);this.trigger('onload');$(this.wrapper).bind('show',function(){cur_frm=null;me.trigger('onshow');me.trigger('refresh');});},trigger:function(eventname){var me=this;try{if(pscript[eventname+'_'+this.name]){pscript[eventname+'_'+this.name](me.wrapper);}else if(me.wrapper[eventname]){me.wrapper[eventname](me.wrapper);}}catch(e){console.log(e);}}})
/*
@@ -311,7 +311,7 @@ wn.provide('wn.request');wn.request.url='index.cgi';wn.request.prepare=function(
throw"Incomplete Request";}}
wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(opts.show_spinner)hide_loading();if(opts.freeze)unfreeze();if(wn.boot.sid&&wn.get_cookie('sid')!=wn.boot.sid){msgprint('Session expired');setTimeout('redirect_to_login()',3000);return;}
if(r.server_messages)msgprint(r.server_messages)
if(r.exc){errprint(r.exc);console.log(r.exc);};if(r.docs)LocalDB.sync(r.docs);}
if(r.exc){console.log(r.exc);};if(r.docs)LocalDB.sync(r.docs);}
wn.request.call=function(opts){wn.request.prepare(opts);$.ajax({url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus)
if(opts.error)opts.error(xhr)}})}
wn.call=function(opts){var args=$.extend({},opts.args)
@@ -321,5 +321,5 @@ wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,f
/*
* lib/js/core.js
*/
if(!console){var console={log:function(txt){errprint(txt);}}}
if(!console){var console={log:function(txt){alert(txt);}}}
wn.versions.check();$(document).bind('ready',function(){var base=window.location.href.split('#')[0];$.each($('a[softlink!="false"]'),function(i,v){if(v.href.substr(0,base.length)==base){var path=(v.href.substr(base.length));if(path.substr(0,1)!='#'){v.href=base+'#'+path;}}});if(!wn.settings.no_history&&window.location.hash){wn.page.set(window.location.hash.substr(1));}});

+ 3
- 2
js/legacy/app.js Zobrazit soubor

@@ -52,7 +52,8 @@ function startup() {
if(wn.control_panel.custom_startup_code)
eval(wn.control_panel.custom_startup_code);
} catch(e) {
errprint(e);
console.log('Error in evaluating custom startup code:');
console.log(e);
}
// open an existing page or record
@@ -100,7 +101,7 @@ function to_open() {
function logout() {
$c('logout', args = {}, function(r,rt) {
if(r.exc) {
msgprint(r.exc);
console.log(r.exc);
return;
}
redirect_to_login();


+ 1
- 1
js/wn/request.js Zobrazit soubor

@@ -64,7 +64,7 @@ wn.request.cleanup = function(opts, r) {
if(r.server_messages) msgprint(r.server_messages)
// show errors
if(r.exc) { errprint(r.exc); console.log(r.exc); };
if(r.exc) { console.log(r.exc); };
// sync docs
if(r.docs) LocalDB.sync(r.docs);


+ 1
- 0
js/wn/views/pageview.js Zobrazit soubor

@@ -14,6 +14,7 @@ wn.views.pageview = {
}
},
show: function(name) {
if(!name) return;
wn.views.pageview.with_page(name, function() {
if(!wn.pages[name]) {
wn.views.pageview.pages[name] = new wn.views.Page(name);


+ 2
- 2
py/build/bundle.py Zobrazit soubor

@@ -79,14 +79,14 @@ class Bundle:
"""
Build (stitch + compress) the file defined in build.json
"""
import os, sys, json
import os, sys
from build import no_minify
# open the build.json file and read
# the dict
print "making %s ..." % bpath
with open(bpath, 'r') as bfile:
bdata = json.loads(bfile.read())
bdata = eval(bfile.read())
path = os.path.dirname(bpath)


+ 1
- 1
py/webnotes/auth.py Zobrazit soubor

@@ -177,7 +177,7 @@ class LoginManager:
getattr(event_handlers, method)(self)
return
except ImportError, e:
webnotes.errprint(str(e))
pass
# deprecated
self.load_control_panel()


+ 0
- 6
py/webnotes/boot.py Zobrazit soubor

@@ -48,7 +48,6 @@ def get_bootinfo():

if webnotes.session['user'] != 'Guest':
import webnotes.widgets.menus
bootinfo['dt_labels'] = get_dt_labels()
bootinfo['user_info'] = get_fullnames()
bootinfo['sid'] = webnotes.session['sid'];
@@ -111,8 +110,3 @@ def get_home_page(bootinfo, doclist):
bootinfo['home_page_html'] = page_doclist[0].content

bootinfo['home_page'] = home_page or ''

def get_dt_labels():
import webnotes
res = webnotes.conn.sql("select name, dt_label from `tabDocType Label`")
return dict(res)

Načítá se…
Zrušit
Uložit