2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"use strict" ;  
						 
					
						
							
								
									
										
										
										
											2015-01-13 03:18:13 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								angular  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  . module ( "myApp.build" ,  [ "ngRoute" ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-13 03:18:13 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  . config ( [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "$routeProvider" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    function  ( $routeProvider )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      $routeProvider . when ( "/build" ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        templateUrl :  "views/build/build.html" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        controller :  "BuildCtrl as Build" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-13 03:18:13 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  . controller ( "BuildCtrl" ,  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "$scope" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "$location" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "$timeout" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "Desirae" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    function  ( $scope ,  $location ,  $timeout ,  DesiraeService )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      var  scope  =  this , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        path  =  window . path ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      function  init ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        scope . extensions  =  [ "md" ,  "html" ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-15 21:56:14 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  DesiraeService . meta ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          . then ( function  ( desi )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            scope . blogdir  =  desi . blogdir . path . replace ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              /^\/(Users|home)\/[^\/]+\// , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              "~/" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            scope . site  =  desi . site ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-13 03:18:13 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! desi . site . base _url  ||  ! desi . site . base _path )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              window . alert ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                "Please go back to the site config and enter any mandatory missing fields (base_url, base_path)." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 02:41:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            scope . display _url  =  scope . production _url  = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              desi . site . base _url  +  path . join ( "/" ,  desi . site . base _path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( /dropbox/ . test ( scope . display _url ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              scope . display _url  +=  "/index.html" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-13 03:18:13 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // this is the responsibility of the build system (Dear Desi), not the library (Desirae)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            scope . development _url  = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              location . href . replace ( /\/(#.*)?$/ ,  "" )  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              path . join ( "/" ,  "compiled_dev" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-13 03:18:13 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  desi ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          . catch ( function  ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            window . alert ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              "An Error Occured. Most errors that occur in the init phase are parse errors in the config files or permissions errors on files or directories, but check the error console for details." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            console . error ( e ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            throw  e ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-13 03:18:13 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      scope . onError  =  function  ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . error ( e ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          window . confirm ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            "Encountered an error. Please inspect the console.\n\nWould you like to ignore the error and continue?" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          return  window . Promise . resolve ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 02:41:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          return  window . Promise . reject ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 02:41:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      scope . buildOne  =  function  ( envstr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  DesiraeService . reset ( ) . then ( function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          return  init ( ) . then ( function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            var  env ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-13 03:18:13 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // TODO is there a legitimate case where in addition to base_path (root of the blog)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // a user would need owner_base? i.e. school.edu/~/rogers/blog school.edu/~/rogers/assets
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( "production"  ===  envstr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              env  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                url :  scope . production _url , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                base _url :  scope . production _url . replace ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                  /(https?:\/\/[^\/#?]+).*/ , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                  "$1" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                base _path :  scope . production _url . replace ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                  /https?:\/\/[^\/#?]+/ , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                  "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                compiled _path :  "compiled" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                since :  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                onError :  scope . onError , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              env  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                url :  scope . development _url , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                base _url :  scope . development _url . replace ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                  /(https?:\/\/[^\/#?]+).*/ , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                  "$1" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                base _path :  scope . development _url . replace ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                  /https?:\/\/[^\/#?]+/ , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                  "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                compiled _path :  "compiled_dev" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                since :  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                onError :  scope . onError , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  DesiraeService . build ( env ) . then ( function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              DesiraeService . write ( env ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-21 02:41:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      } ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-13 03:18:13 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      scope . build  =  function  ( envs )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        window 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          . forEachAsync ( envs ,  function  ( env )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  scope . buildOne ( env ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          . then ( function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            window . alert ( "Build(s) Complete" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-13 03:18:13 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-08 20:30:15 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      init ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ] ) ;