text: /*	Miso layout page
  
  	This layout determines the HTML surround for each of your mvc routes.
  	Feel free to modify as you see fit - as long as the attachemnt node is 
  	present, it should work.
  
  	Note: this is the only mvc that does not require a controller.
  */
  var m = require('mithril'),
  	sugartags = require('mithril.sugartags')(m),
  	authentication = require('../system/api/authentication/api.server.js')(m);
  
  //	The header - this can also be rendered client side
  module.exports.headerContent = function(ctrl){
  	with(sugartags) {
  		return DIV({"class": 'cw cf'}, [
  			DIV({"class": 'logo'},
  				A({alt: 'MISO', href:'/', config: m.route}, [
  					IMG({src: '/img/miso_logo.png'})
  				])
  			),
  			NAV({"class": "left"}, UL([
  				LI(A({href: "http://misojs.com/docs", target: "_blank"}, "Documentation"))
  			])),
  			NAV({"class": "right"}, UL([
  				LI(A({href: "https://github.com/jsguy/misojs", target: "_blank"}, "Github")),
  				//	This link could go to an account 
  				//	page or something like that
  
  				(ctrl.misoGlobal.authenticationEnabled?
  					(ctrl.misoGlobal.isLoggedIn && ctrl.misoGlobal.userName? 
  						LI(A({onclick: function(e){
  								console.log('logging out, please wait...');
  								authentication.logout({}).then(function(data){
  									console.log("You've been logged out");
  									m.route("/login");
  								});
  
  								e.preventDefault();
  								return false;
  							}, href: "#", id: "misoUserName"},
  							"Logout " + ctrl.misoGlobal.userName)
  						):
  						LI(A({href: "/login"}, "Login"))
  					): 
  					""
  				)
  
  			]))
  		]);
  	}
  };
  
  //	The full layout - always only rendered server side
  module.exports.view = function(ctrl){
  	with(sugartags) {
  		return [
  			m.trust("<!doctype html>"),
  			HTML([
  				HEAD([
  					LINK({href: '/css/reset.css', rel:'stylesheet'}),
  					LINK({href: '/css/style.css', rel:'stylesheet'}),
  					//	Add in the misoGlobal object...
  					SCRIPT("var misoGlobal = "+(ctrl.misoGlobal? JSON.stringify(ctrl.misoGlobal): {})+";")
  				]),
  				BODY({"class": 'fixed-header' }, [
  					HEADER({id: "misoHeaderNode"}, ctrl.headerContent(ctrl)),
  					SECTION({id: ctrl.misoAttachmentNode}, ctrl.content),
  					SECTION({id: "loader"}, [
  						DIV({"class": "loader"})
  					]),
  					SECTION({id: "footer"}, [
  						DIV({"class": 'cw cf'}, m.trust("Copyright &copy; 2015 jsguy"))
  					]),
  					//SCRIPT({src: '/miso.js' + (ctrl.reload? "?cacheKey=" + (new Date()).getTime(): "")}),
  					SCRIPT({src: '/miso.js'}),
  					(ctrl.reload? SCRIPT({src: '/reload.js'}): "")
  				])
  			])
  		];
  	}
  };