<commit_before>// Build mast objects and set defaults
Mast = _.extend(Backbone,
{
		
	// CSS class for Mast rows in a Table
	rowCSSClass: 'mast-row',
		
	// Route map that will be populated by user definitions
	routes: {},
		
	// Model/collection dictionary that will be populated by user definitions
	models: {},
		
	// Component dictionary that will be populated by user definitions
	components: {},	
		
	// Mast.raise() instantiates the Mast library with the specified options
	raise: function (options,afterLoadFn) {
			
		// Extend defaults
		options = options || {};
		options = _.extend({
			socket: true
		},options);
			
		// Convert options.routes into a format Backbone's router will accept
		// (can't have key:function(){} style routes, must use a string function name)
		var routerConfig = {
			routes:{}
		};
		var indexRoute = null;
			
		// If external router is specified in options, use it
		if (options.router) {
			Mast.routes = options.router;
		}
			
		// Decorate and interpret routes
		_.each(Mast.routes,function(action,query) {
			// "routes" is a reserved word
			if (query=="routes") throw new Error("Can't define a route using reserved word: '"+query+"'!");
				
			// Save index route for the end
			if (query=="index") {
				indexRoute = action;
			}
			routerConfig.routes[query] = query;
			routerConfig[query] = action;
		});

		// Define default (index) route
		routerConfig.routes[""] = "index";
		routerConfig.index = indexRoute;

			
		// Extend and instantiate main router
		var AppRouter = Mast.Router.extend(routerConfig);
		Mast.app = new AppRouter();
			
		// Mast makes the assumption that you want to trigger
		// the route handler.  This can be overridden
		Mast.navigate = function(query,options) {
			return Mast.app.navigate(query,_.extend({
				trigger:true
			},options));
		}
			
		// when document is ready
		$(function(){
			// Launch history manager 
			Mast.history.start();
		});

	
		// Initialize Socket
		// Override default base URL if one was specified
		if (this.Socket && options.socket) {
			this.Socket.baseurl = (options && options.baseurl) || this.Socket.baseurl;
			this.Socket.initialize();
		}
	
	
		// Add outerHtml to jQuery
		jQuery.fn.outerHTML = function(s) {
			return s
			? this.before(s).remove()
			: jQuery("<p>").append(this.eq(0).clone()).html();
		};
					
			
		// Prepare template library
		// HTML templates can be manually assigned here
		// otherwise they can be loaded from DOM elements
		// or from a URL
		Mast.TemplateLibrary = {}
			
		// TODO: Go ahead and absorb all of the templates in the library 
		// right from the get-go
			
		// Set up template settings
		_.templateSettings = {
			//				variable: 'data',
			interpolate : /\{\{(.+?)\}\}/g,
			escape : /\{\{-(.+?)\}\}/g,
			evaluate : /\{\%(.+?)\%\}/g
		};
				
			
		// When Mast and $.document are ready, 
		// trigger afterLoad callback (if specified)
		$(function(){
			afterLoadFn && _.defer(afterLoadFn);
		})
			
	}
},
Backbone.Events);<commit_msg>Added beforeRouting event to Mast.raise()<commit_after>// Build mast objects and set defaults
Mast = _.extend(Backbone,
{
		
	// CSS class for Mast rows in a Table
	rowCSSClass: 'mast-row',
		
	// Route map that will be populated by user definitions
	routes: {},
		
	// Model/collection dictionary that will be populated by user definitions
	models: {},
		
	// Component dictionary that will be populated by user definitions
	components: {},	
		
	// Mast.raise() instantiates the Mast library with the specified options
	raise: function (options,afterLoadFn,beforeRouteFn) {
			
		// Extend defaults
		options = options || {};
		options = _.extend({
			socket: true
		},options);
		
		
			
		// Convert options.routes into a format Backbone's router will accept
		// (can't have key:function(){} style routes, must use a string function name)
		var routerConfig = {
			routes:{}
		};
		var indexRoute = null;
			
		// If external router is specified in options, use it
		if (options.router) {
			Mast.routes = options.router;
		}
			
		// Decorate and interpret routes
		_.each(Mast.routes,function(action,query) {
			// "routes" is a reserved word
			if (query=="routes") throw new Error("Can't define a route using reserved word: '"+query+"'!");
				
			// Save index route for the end
			if (query=="index") {
				indexRoute = action;
			}
			routerConfig.routes[query] = query;
			routerConfig[query] = action;
		});

		// Define default (index) route
		routerConfig.routes[""] = "index";
		routerConfig.index = indexRoute;

			
		// Extend and instantiate main router
		var AppRouter = Mast.Router.extend(routerConfig);
		Mast.app = new AppRouter();
			
		// Mast makes the assumption that you want to trigger
		// the route handler.  This can be overridden
		Mast.navigate = function(query,options) {
			return Mast.app.navigate(query,_.extend({
				trigger:true
			},options));
		}
	
		// Initialize Socket
		// Override default base URL if one was specified
		if (this.Socket && options.socket) {
			this.Socket.baseurl = (options && options.baseurl) || this.Socket.baseurl;
			this.Socket.initialize();
		}
	
	
		// Add outerHtml to jQuery
		jQuery.fn.outerHTML = function(s) {
			return s
			? this.before(s).remove()
			: jQuery("<p>").append(this.eq(0).clone()).html();
		};
					
			
		// Prepare template library
		// HTML templates can be manually assigned here
		// otherwise they can be loaded from DOM elements
		// or from a URL
		Mast.TemplateLibrary = {}
			
		// TODO: Go ahead and absorb all of the templates in the library 
		// right from the get-go
			
		// Set up template settings
		_.templateSettings = {
			//				variable: 'data',
			interpolate : /\{\{(.+?)\}\}/g,
			escape : /\{\{-(.+?)\}\}/g,
			evaluate : /\{\%(.+?)\%\}/g
		};
		
		// when document is ready
		$(function(){
			
			// Before routing, trigger beforeRouteFn callback (if specified)
			beforeRouteFn && _.defer(beforeRouteFn);
			
			// Launch history manager 
			Mast.history.start();
			
			// When Mast and $.document are ready, 
			// trigger afterLoad callback (if specified)
			afterLoadFn && _.defer(afterLoadFn);
		});

			
	}
},
Backbone.Events);
{'fraction_non_alphanumeric': 0.13268450932684508, 'fraction_numerical': 0.00032441200324412003, 'mean_word_length': 2.8155940594059405, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '267475', 'n_tokens_mistral': 2213, 'n_tokens_neox': 1845, 'n_words': 591}