Permalink
Browse files

Fixed a lot of bugs

  • Loading branch information...
1 parent 03bd37a commit 20005c7800d5ec8376ea015786ba198eddca9921 @brokenseal committed May 29, 2010
View
@@ -1,7 +1,7 @@
(function(_){
var
__module__ = {},
- utils= require('broke/core/utils').extend,
+ utils= require('broke/core/utils'),
_isReady= false,
_bindEvents= function(){
@@ -40,7 +40,7 @@
};
// collect all the url changing elements
- forEach(settings.URL_CHANGING_ELEMENTS, function(key){
+ utils.forEach(settings.URL_CHANGING_ELEMENTS, function(key){
$(key)[settings.EVENT_BINDING](this.events.join(','), callback);
});
@@ -121,7 +121,7 @@
}
;
- forEach(settings.URL_CHANGING_ELEMENTS, function(key){
+ utils.forEach(settings.URL_CHANGING_ELEMENTS, function(key){
var elements= $(key),
elementsLength= elements.length;
@@ -142,10 +142,10 @@
;
// projects' locale paths
- populate(localePaths, getattr(BROKE_SETTINGS_OBJECT).LOCALE_PATHS);
+ localePaths= localePaths.concat(utils.getattr(BROKE_SETTINGS_OBJECT).LOCALE_PATHS));
//localePaths.each(function(){
- forEach(localePaths, function(){
+ utils.forEach(localePaths, function(){
translation.init({
url: this + localePath
});
@@ -188,25 +188,25 @@
;
// merge settings
- extend(settings, getattr(BROKE_SETTINGS_OBJECT));
- settings.SETTINGS_OBJECT= getattr(BROKE_SETTINGS_OBJECT);
+ utils.extend(settings, utils.getattr(BROKE_SETTINGS_OBJECT));
+ settings.SETTINGS_OBJECT= utils.getattr(BROKE_SETTINGS_OBJECT);
// init project's url patterns
// TODO: check that
- extend(broke.urlPatterns, getattr(settings.ROOT_URLCONF));
+ utils.extend(broke.urlPatterns, utils.getattr(settings.ROOT_URLCONF));
// init installed apps' models
- settings.INSTALLED_APPS= map(settings.INSTALLED_APPS, function(){
+ settings.INSTALLED_APPS= utils.map(settings.INSTALLED_APPS, function(){
var
app= this
;
if(app.constructor == String) {
- app= getattr(this);
+ app= utils.getattr(this);
}
// init model's storage
- forEach(app.models, function(key){
+ utils.forEach(app.models, function(key){
if(this.autoInit) {
// TODO: check that
broke.initStorage(this);
@@ -290,7 +290,7 @@
req= {}
;
- if(typeOf(args) === 'string') {
+ if(utils.typeOf(args) === 'string') {
// first case: broke.request('/entry/view/1/');
req.url= args;
} else {
@@ -335,7 +335,7 @@
settings= settings= require('broke/conf/settings'),
url= args.url || settings.JSON_URLS.getData.interpolate({
appLabel: model.appLabel,
- model: model.className.lower()
+ model: model.name.lower()
}),
filter= args.filter || {},
result
@@ -377,7 +377,7 @@
;
if('localStorage' in window) {
- extend(Storage.prototype, {
+ utils.extend(Storage.prototype, {
setObject: localStorageSetObject,
getObject: localStorageGetObject
});
@@ -411,7 +411,7 @@
}
};
})(),
- extend: extend,
+ extend: utils.extend,
fn: {},
storage: {},
shortcuts: {},
@@ -429,5 +429,5 @@
contextProcessors: {}
};
- extend(_, __module__);
+ utils.extend(_, __module__);
})(exports);
@@ -1,5 +1,6 @@
(function(_){
var
+ utils= require('broke/core/utils'),
exceptions= require('broke/core/exceptions'),
ImproperlyConfigured= exceptions.ImproperlyConfigured,
NotImplementedError= exceptions.NotImplementedError,
@@ -40,7 +41,7 @@
// result[this]= value;
// }
//});
- forEach(keys, function(){
+ utils.forEach(keys, function(){
var value= _this.get(this);
if(value !== null) {
@@ -64,7 +65,7 @@
timeout= timeout || null;
- forEach(data, function(key){
+ utils.forEach(data, function(key){
_this.set(key, this, timeout);
});
},
@@ -74,7 +75,7 @@
//keys.each(function(){
// _this['delete'](this);
//});
- forEach(keys, function(){
+ utils.forEach(keys, function(){
_this['delete'](this);
});
},
@@ -1,5 +1,6 @@
(function(_){
var
+ utils= require('broke/core/utils'),
InvalidCacheBackendError= require('broke/core/exceptions').InvalidCacheBackendError,
settings= require('broke/conf/settings'),
BACKENDS= {
@@ -31,7 +32,7 @@
name= args.scheme;
}
- cacheClass= getattr(name + '.CacheClass');
+ cacheClass= utils.getattr(name + '.CacheClass');
return new cacheClass(args);
},
View
@@ -1,34 +1,3 @@
-/****************************************************************************/
-/****************************** EVENT SYSTEM ********************************/
-/****************************************************************************/
-
-/*
- * events:
- * - broke.request
- * - broke.response
- *
- * request attributes:
- * - completeUrl
- * - event
- * - type: get|post
- * - url
- * - fromReload
- * - queryData
- *
- * response attributes:
- * - template
- * - context
- * - method
- * - htmlNode
- * - additionalProperties
- *
- * - event
- * - type: get|post
- * - url
- * - fromReload
- *
- */
-
(function(){
/*
* Request event handling
@@ -38,17 +7,19 @@
$(window).bind('broke.request', function(e, requestData){
var
+ utils= require('broke/core/utils'),
response= {},
view= null,
args= null,
urlMatchResult= [],
partialUrl,
target,
- parseQueryString= broke.urlResolvers.parseQueryString,
+ urlResolvers= require('broke/core/urlresolvers'),
+ parseQueryString= urlResolvers.parseQueryString,
queryString= {},
- resolve= broke.urlResolvers.resolve,
- BrowserHandler= broke.core.handlers.browser.BrowserHandler,
+ resolve= urlResolvers.resolve,
+ BrowserHandler= require('broke/core/jandlers/browser').BrowserHandler,
requestHandler= new BrowserHandler()
;
@@ -102,20 +73,25 @@
*
*/
$(window).bind('broke.response', function(e, response){
+ var
+ utils= require('broke/core/utils')
+ ;
// apply additional properties
- forEach(response.additionalProperties, function(key){
+ utils.forEach(response.additionalProperties, function(key){
response.element[key]= this;
});
// apply callback
- if(typeOf(response.callback) === 'function') {
+ if(utils.typeOf(response.callback) === 'function') {
response.callback.apply(response.element);
}
// --------- middleware fetching in reverse order ---------
- forEach(broke.conf.settings.MIDDLEWARE_CLASSES.reverse(), function(){
- var middleware= getattr(this);
+ utils.forEach(broke.conf.settings.MIDDLEWARE_CLASSES.reverse(), function(){
+ var
+ middleware= utils.getattr(this)
+ ;
if(middleware.processResponse !== undefined) {
middleware.processResponse(response);
@@ -1,5 +1,6 @@
(function(_){
- var
+ var
+ utils= require('broke/core/utils'),
Class= require('dependencies/class').Class,
settings= require('broke/conf/settings'),
exceptions= require('broke/core/exceptions'),
@@ -62,11 +63,11 @@
this.responseMiddleware= [];
this.exceptionMiddleware= [];
- forEach(settings.MIDDLEWARE_CLASSES, function(){
+ utils.forEach(settings.MIDDLEWARE_CLASSES, function(){
var middleware;
try {
- middleware= getattr(this);
+ middleware= utils.getattr(this);
} catch(e) {
throw exceptions.ImproperlyConfigured("%s isn't a middleware module" % this);
}
@@ -226,7 +227,7 @@
response, modifying the response in the process. Returns the new
response.
*/
- forEach(this.responseFixes, function(){
+ utils.forEach(this.responseFixes, function(){
response= this(request, response);
});
View
@@ -1,16 +1,17 @@
(function(_){
var
- extend= require('core/utils').extend,
+ utils= require('broke/core/utils'),
+ extend= require('broke/core/utils').extend,
gettext= require('broke/utils/translation').gettext,
NoReverseMatch= require('broke/core/exceptions').NoReverseMatch,
__module__= {}
;
__module__= {
patterns: function(prefix, urlPatterns) {
- urlPatterns= map(urlPatterns, function(){
+ urlPatterns= utils.map(urlPatterns, function(){
if(typeof this[1] === "string") {
- this[1]= getattr(prefix + "." + this[1]);
+ this[1]= utils.getattr(prefix + "." + this[1]);
}
return this;
});
@@ -19,7 +20,7 @@
},
include: function(urlObject){
if(typeof urlObject === "string") {
- return getattr(urlObject);
+ return utils.getattr(urlObject);
}
return urlObject;
},
@@ -32,7 +33,7 @@
queryString= queryString.split('&');
//queryString.each(function(){
- forEach(queryString, function(){
+ utils.forEach(queryString, function(){
var tmp= this.split('=');
result[tmp[0]]= tmp[1];
});
@@ -59,8 +60,8 @@
}
view= _this[1];
- if(typeOf(view) === "string") {
- view= getattr(view);
+ if(utils.typeOf(view) === "string") {
+ view= utils.getattr(view);
}
if(isFunction(view)) {
@@ -92,7 +93,7 @@
_this= urlPatterns[i];
if(typeOf(_this[1]) === "string") {
- _this[1]= getattr(_this[1]);
+ _this[1]= utils.getattr(_this[1]);
}
isInclude= isArray(_this[1]);
Oops, something went wrong.

0 comments on commit 20005c7

Please sign in to comment.