├── bigrig ├── functions.cfm ├── public.cfm └── global.cfm ├── header.cfm ├── wheels ├── extends.cfm ├── global │ ├── cfml.cfm │ ├── internal.cfm │ └── public.cfm ├── model │ └── crud.cfm ├── controller │ ├── initialization.cfm │ └── rendering.cfm └── dispatch │ └── request.cfm ├── BigRig.cfc ├── README.md └── index.cfm /bigrig/functions.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /header.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /wheels/extends.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /BigRig.cfc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /wheels/global/cfml.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /bigrig/public.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BigRig 2 | 3 | This is a pre-alpha release with some critical limitations. Don't use BigRig if you expect it to work for your own projects at this point. 4 | 5 | For now, there is some initial configuration to get this all working. Mostly this is working towards a proof of concept for running multiple Wheels applications on a single server. 6 | 7 | ## Installation 8 | Drop zip in plugins folder(you can download the latest tag and rename it to just BigRig-someversionnumberfromtag.zip) 9 | 10 | Create a new folder to hold your rigs in your server's webroot(assuming that is where wheels is installed) - these parent folders will be referred to as BigRig folders. 11 | 12 | Add a Wheels application(or Wheels applications) to your newly created BigRig folder, each with their own folder(myrigs/blog, myrigs/calendar, etc...). 13 | 14 | Fix the Wheels.cfc in both the models and controllers folders for your applications so the relative path in the cfinclude points to your wheels install. 15 | 16 | Add a call to addRig(name="#bigRigFolderName#") to your config/routes.cfm file to give your apps the default routes. 17 | 18 | Any routes, settings etc in your rigs currently need to be moved to the main config/routes|settings|etc.cfm files... routes have some extra parameters that need to be set in order to work(see wiki). Looking into a solution for this still. 19 | 20 | ## Known Issues and Limitations 21 | 22 | Datasources must be shared with all apps, or set independently in each model(hoping a better solution for this will present itself). 23 | 24 | Static files are still being figured out. 25 | 26 | There is at least one major bug with the model caching(which makes BigRig unusable when running Wheels in production mode) at the moment. Basically it tries initializing the Model.cfc as full ORM objects, looking for a table in your DB. Working on a clean way to fix this. -------------------------------------------------------------------------------- /wheels/model/crud.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | //// bigrig: //// 8 | // var loc = {}; 9 | // loc.fileName = capitalize(variables.wheels.class.name); 10 | var loc = $getModelInitInfo(variables.wheels.class.name); 11 | loc.fileName = capitalize(loc.fileName); 12 | if(loc.fileName == "") { writeDump(loc);abort; } 13 | if (!ListFindNoCase(application.wheels.existingModelFiles, variables.wheels.class.name)) 14 | loc.fileName = "Model"; 15 | // loc.returnValue = $createObjectFromRoot(path=application.wheels.modelComponentPath, fileName=loc.fileName, method="$initModelObject", name=variables.wheels.class.name, properties=arguments.properties, persisted=arguments.persisted, row=arguments.row, base=arguments.base); 16 | // if this method is called with a struct we're creating a new object and then we call the afterNew callback. If called with a query we call the afterFind callback instead. If the called method does not return false we proceed and run the afterInitialize callback. 17 | loc.returnValue = $createObjectFromRoot(path=loc.modelComponentPath, fileName=loc.fileName, method="$initModelObject", name=variables.wheels.class.name, properties=arguments.properties, persisted=arguments.persisted, row=arguments.row, base=arguments.base); 18 | if ((IsQuery(arguments.properties) && loc.returnValue.$callback("afterFind")) || (IsStruct(arguments.properties) && loc.returnValue.$callback("afterNew"))) 19 | loc.returnValue.$callback("afterInitialization"); 20 | //// :bigrig //// 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /wheels/controller/initialization.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | //// bigrig: //// 5 | // var loc = {}; 6 | // loc.fileName = capitalize(variables.wheels.name); 7 | var loc = $getComponentInitInfo(variables.wheels.name); 8 | loc.fileName = capitalize(loc.fileName); 9 | //// :bigrig //// 10 | 11 | if (!ListFindNoCase(application.wheels.existingControllerFiles, variables.wheels.name)) 12 | loc.fileName = "Controller"; 13 | //// bigrig: //// 14 | // loc.returnValue = $createObjectFromRoot(path=application.wheels.controllerComponentPath, fileName=loc.fileName, method="$initControllerObject", name=variables.wheels.name, params=arguments.params); 15 | loc.returnValue = $createObjectFromRoot(path=loc.controllerComponentPath, fileName=loc.fileName, method="$initControllerObject", name=variables.wheels.name, params=arguments.params); 16 | //// :bigrig //// 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | //// bigrig: //// 26 | // var loc = {}; 27 | var loc = $getComponentInitInfo(arguments.name); 28 | // include controller specific helper files if they exist 29 | if (ListFindNoCase(application.wheels.existingHelperFiles, arguments.params.controller)) 30 | { 31 | //$include(template="#application.wheels.viewPath#/#arguments.params.controller#/helpers.cfm"); 32 | $include(template="#loc.viewPath#/#arguments.params.controller#/helpers.cfm"); 33 | } 34 | 35 | // get the app helper 36 | if($isBigRigRequest(loc.controllerName) && fileExists(expandPath("#loc.viewPath#/helpers.cfm"))) { 37 | $include(template="#loc.viewPath#/helpers.cfm"); 38 | } 39 | //// :bigrig //// 40 | 41 | loc.executeArgs = {}; 42 | loc.executeArgs.name = arguments.name; 43 | $simpleLock(name="controllerLock", type="readonly", execute="$setControllerClassData", executeArgs=loc.executeArgs); 44 | variables.params = arguments.params; 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /index.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | Docs 6 |
7 |
8 | 9 |

BigRig

10 | 11 |

BigRig extends the Wheels convention for code organization, allowing you to implement your models, views and controllers in a customized, nested structure.

12 | 13 |

BigRig folders each require supporting named routes, and if they are not placed in the webroot a supporting mapping is required to function properly. There is a helper function, #bigRigHelperFunction#(), that can set up the base routes for you.

14 | 15 |
16 | 17 | 18 |

Quick Start

19 | 20 |

For this quick start guide, we're going to create a BigRig folder called apps, place a blog application in it and get it up and running. It is assumed you have installed wheels in the webroot of your server.

21 | 22 |
    23 |
  • Add the /apps folder to your webroot
  • 24 |
  • Add the /apps/blog folder
  • 25 |
  • Copy the /models, /views, and /controllers folder from a fresh wheels install
  • 26 |
  • Fix your Wheels.cfc files 27 |

    /apps/blog/controllers/Wheels.cfc

    28 |
    <cfcomponent output="false" displayName="Controller">
    29 | 	<cfinclude template="../../../wheels/controller.cfm">
    30 | </cfcomponent>
    31 |

    /apps/blog/models/Wheels.cfc

    32 |
    <cfcomponent output="false" displayName="Model">
    33 | 	<cfinclude template="../../../wheels/model.cfm">
    34 | </cfcomponent>
    35 |
  • 36 |
  • Add a call to #bigRigHelperFunction#(name, [keyword, singleAppFolder]) 37 |

    /config/routes.cfm

    38 |
    <cfset #bigrigHelperFunction#(name="apps") />
    39 | 40 |
  • 41 |
42 | 43 |

You can now use urls like this (assuming you had URL rewritting turned on)

44 | 45 |

http://example.com/apps/blog/feed - would get to the apps/blog/views/feed/index.cfm view.

46 | -------------------------------------------------------------------------------- /wheels/global/internal.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | //// bigrig: //// 5 | // var loc = {}; 6 | // loc.fileName = capitalize(arguments.name); 7 | var loc = $getComponentInitInfo(arguments.name); 8 | 9 | if(loc.fileName EQ ""){ 10 | writeDump(loc);abort; 11 | } 12 | 13 | loc.fileName = capitalize(loc.fileName); 14 | //// :bigrig //// 15 | 16 | // check if the controller file exists and store the results for performance reasons 17 | if (!ListFindNoCase(application.wheels.existingControllerFiles, arguments.name) && !ListFindNoCase(application.wheels.nonExistingControllerFiles, arguments.name)) 18 | { 19 | //// bigrig: //// 20 | // if (FileExists(ExpandPath("#application.wheels.controllerPath#/#loc.fileName#.cfc"))) 21 | // application.wheels.existingControllerFiles = ListAppend(application.wheels.existingControllerFiles, arguments.name); 22 | if (FileExists(ExpandPath("#loc.controllerPath#/#loc.fileName#.cfc")) || FileExists(ExpandPath(".#loc.controllerPath#/#loc.fileName#.cfc"))){ 23 | application.wheels.existingControllerFiles = ListAppend(application.wheels.existingControllerFiles, arguments.name); 24 | } 25 | //// :bigrig //// 26 | else { 27 | application.wheels.nonExistingControllerFiles = ListAppend(application.wheels.nonExistingControllerFiles, arguments.name); 28 | } 29 | } 30 | 31 | // check if the controller's view helper file exists and store the results for performance reasons 32 | if (!ListFindNoCase(application.wheels.existingHelperFiles, arguments.name) && !ListFindNoCase(application.wheels.nonExistingHelperFiles, arguments.name)) 33 | { 34 | //// bigrig: //// 35 | // if (FileExists(ExpandPath("#application.wheels.viewPath#/#LCase(arguments.name)#/helpers.cfm"))) 36 | if (FileExists(ExpandPath("#loc.viewPath#/#LCase(loc.fileName)#/helpers.cfm"))) 37 | //// :bigrig //// 38 | application.wheels.existingHelperFiles = ListAppend(application.wheels.existingHelperFiles, arguments.name); 39 | else 40 | application.wheels.nonExistingHelperFiles = ListAppend(application.wheels.nonExistingHelperFiles, arguments.name); 41 | } 42 | if (!ListFindNoCase(application.wheels.existingControllerFiles, arguments.name)) 43 | loc.fileName = "Controller"; 44 | //// bigrig: //// 45 | //application.wheels.controllers[arguments.name] = $createObjectFromRoot(path=application.wheels.controllerComponentPath, fileName=loc.fileName, method="$initControllerClass", name=arguments.name); 46 | application.wheels.controllers[arguments.name] = $createObjectFromRoot(path=listChangeDelims(loc.controllerComponentPath, ".", "/"), fileName=loc.fileName, method="$initControllerClass", name=arguments.name); 47 | //// :bigrig //// 48 | loc.returnValue = application.wheels.controllers[arguments.name]; 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | //// bigrig: //// 57 | // var loc = {}; 58 | // loc.fileName = capitalize(arguments.name); 59 | var loc = $getModelInitInfo(arguments.name); 60 | loc.fileName = capitalize(loc.fileName); 61 | //if (FileExists(ExpandPath("#application.wheels.modelPath#/#loc.fileName#.cfc"))) 62 | //application.wheels.existingModelFiles = ListAppend(application.wheels.existingModelFiles, arguments.name); 63 | if (FileExists(ExpandPath("#loc.modelPath#/#loc.fileName#.cfc"))) 64 | application.wheels.existingModelFiles = ListAppend(application.wheels.existingModelFiles, arguments.name); 65 | else 66 | loc.fileName = "Model"; 67 | // application.wheels.models[arguments.name] = $createObjectFromRoot(path=application.wheels.modelComponentPath, fileName=loc.fileName, method="$initModelClass", name=arguments.name); 68 | // loc.returnValue = application.wheels.models[arguments.name]; 69 | application.wheels.models[arguments.name] = $createObjectFromRoot(path=loc.modelComponentPath, fileName=loc.fileName, method="$initModelClass", name=loc.fileName); 70 | 71 | loc.returnValue = application.wheels.models[arguments.name]; 72 | //// :bigrig //// 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | var loc = {}; 86 | arguments.returnVariable = "loc.returnValue"; 87 | arguments.component = arguments.path & "." & arguments.fileName; 88 | StructDelete(arguments, "path"); 89 | StructDelete(arguments, "fileName"); 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /bigrig/global.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | var loc = {}; 28 | loc.controllerPath = application.wheels.controllerPath; 29 | loc.controllerComponentPath = application.wheels.controllerComponentPath; 30 | loc.include = application.wheels.viewPath; 31 | loc.viewPath = application.wheels.viewPath; 32 | loc.fileName = arguments.name; 33 | loc.controllerName = arguments.name; 34 | 35 | loc.folderName = Reverse(ListRest(Reverse(loc.fileName), "/")); 36 | 37 | if (ListLen(loc.fileName, "/") >= 2) { 38 | loc.controllerName = listGetAt(loc.controllerName, 1, "/"); 39 | 40 | if($isBigRigRequest(loc.controllerName)) { 41 | loc.folderName = $getComponentName(loc.folderName); 42 | } 43 | else if($isBigRigRequest(variables.wheels.name)) { 44 | loc.controllerName = $getPackageName(variables.wheels.name) & "." & $getAppName(variables.wheels.name) & "." & loc.controllerName; 45 | } 46 | // extracts the file part of the path and replace ending ".cfm"; 47 | loc.fileName = Spanexcluding(Reverse(ListFirst(Reverse(loc.fileName), "/")), ".") & ".cfm";; 48 | } 49 | 50 | if(arguments.type == "partial") { 51 | loc.controllerName = variables.wheels.name; 52 | loc.fileName = Spanexcluding(Reverse(ListFirst(Reverse(loc.fileName), "/")), ".") & ".cfm"; 53 | } 54 | 55 | if ($isBigRigRequest(loc.controllerName)) { 56 | loc.package = $getPackageName(loc.controllerName); 57 | loc.app = $getAppName(loc.controllerName); 58 | 59 | // fix the controller name for partials, now that we're done with referencing it 60 | if(arguments.type == "partial") { 61 | loc.controllerName = $getComponentName(loc.controllerName); 62 | // fix the filename if it is still a 3 key value(for controllers) 63 | } else if($isBigRigRequest(loc.fileName)) { 64 | loc.fileName = $getComponentName(loc.fileName); 65 | } 66 | 67 | loc.controllerPath = "/#loc.package#/#loc.app#/#loc.controllerPath#"; 68 | loc.controllerComponentPath = "#loc.package#.#loc.app#.#loc.controllerComponentPath#"; 69 | loc.viewPath = "/#loc.package#/#loc.app#/#loc.viewPath#"; 70 | 71 | if(listFind("layout,partial", arguments.type)) { 72 | loc.include = "#loc.package#/#loc.app#/#loc.include#"; 73 | } else { 74 | loc.include = "#loc.package#/#loc.app#/#loc.include#/"; 75 | } 76 | } 77 | 78 | return loc; 79 | 80 | 81 | 82 | 83 | 84 | 85 | var loc = {}; 86 | var temp = ""; 87 | 88 | loc.fileName = arguments.name; 89 | if ($isBigRigRequest(loc.fileName)) { 90 | loc.controllerName = loc.fileName; 91 | loc.fileName = $getComponentName(loc.fileName); 92 | } 93 | else if (isDefined("variables.wheels.name")) 94 | { 95 | temp = $getRequestController(); 96 | 97 | if($isBigRigRequest(temp) AND !$isBigRigRequest(variables.wheels.name)) 98 | { 99 | loc.controllerName = $getPackageName(temp) & "." & $getAppName(temp) & "." & variables.wheels.name; 100 | } 101 | else 102 | { 103 | loc.controllerName = variables.wheels.name; 104 | } 105 | } 106 | else if (isDefined("variables.wheels.class.name")) 107 | { 108 | temp = $getRequestController(); 109 | 110 | if($isBigRigRequest(temp)) 111 | { 112 | loc.controllerName = $getPackageName(temp) & "." & $getAppName(temp) & "." & variables.wheels.class.name; 113 | } 114 | else 115 | { 116 | loc.controllerName = variables.wheels.class.name; 117 | } 118 | } 119 | loc.modelPath = application.wheels.modelPath; 120 | loc.modelComponentPath = application.wheels.modelComponentPath; 121 | 122 | 123 | if ($isBigRigRequest(loc.controllerName)) { 124 | loc.package = $getPackageName(loc.controllerName); 125 | loc.app = $getAppName(loc.controllerName); 126 | 127 | loc.name = "#loc.package#.#loc.app#.#loc.fileName#"; 128 | loc.modelPath = "/#loc.package#/#loc.app#/#loc.modelPath#"; 129 | loc.modelComponentPath = "#loc.package#.#loc.app#.#loc.modelComponentPath#"; 130 | } 131 | 132 | return loc; 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /wheels/dispatch/request.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | var loc = {}; 4 | if (application.wheels.showDebugInformation) 5 | $debugPoint("setup"); 6 | 7 | // set route from incoming url, find a matching one and create the params struct 8 | loc.route = $getRouteFromRequest(); 9 | loc.foundRoute = $findMatchingRoute(route=loc.route); 10 | loc.params = $createParams(route=loc.route, foundRoute=loc.foundRoute); 11 | 12 | // set params in the request scope as well so we can display it in the debug info outside of the controller context 13 | request.wheels.params = loc.params; 14 | 15 | // create an empty flash unless it already exists 16 | if (!StructKeyExists(session, "flash")) 17 | session.flash = {}; 18 | 19 | ///// bigrig: //// 20 | if(StructKeyExists(loc.foundRoute, "name")) { 21 | // add to params - for cases where there is no matching variable in the foundRoute.pattern 22 | if(!StructKeyExists(loc.params, singularize(loc.foundroute.name)) && StructKeyExists(loc.foundRoute, singularize(loc.foundroute.name))) { 23 | loc.params[singularize(loc.foundroute.name)] = loc.foundRoute[singularize(loc.foundroute.name)]; 24 | } 25 | // see if the controller needs to be modified - only modify if the route explicitly has parameter 26 | // overriding controller name to support packages (apps) through routes 27 | if (structKeyExists(loc.params, singularize(loc.foundRoute.name)) && (ListFind(loc.foundRoute.variables, singularize(loc.foundroute.name)) || StructKeyExists(loc.foundRoute, singularize(loc.foundroute.name)))) { 28 | loc.params.controller = "#loc.foundroute.name#.#loc.params[singularize(loc.foundroute.name)]#.#loc.params.controller#"; 29 | } 30 | } 31 | //// :bigrig //// 32 | 33 | // create the requested controller 34 | loc.controller = $controller(loc.params.controller).$createControllerObject(loc.params); 35 | 36 | if (application.wheels.showDebugInformation) 37 | $debugPoint("setup,beforeFilters"); 38 | 39 | // run verifications and before filters if they exist on the controller 40 | $runVerifications(controller=loc.controller, actionName=loc.params.action, params=loc.params); 41 | $runFilters(controller=loc.controller, type="before", actionName=loc.params.action); 42 | 43 | if (application.wheels.showDebugInformation) 44 | $debugPoint("beforeFilters,action"); 45 | 46 | // call action on controller if it exists 47 | loc.actionIsCachable = false; 48 | if (application.wheels.cacheActions && StructIsEmpty(session.flash) && StructIsEmpty(form)) 49 | { 50 | loc.cachableActions = loc.controller.$getCachableActions(); 51 | loc.iEnd = ArrayLen(loc.cachableActions); 52 | for (loc.i=1; loc.i <= loc.iEnd; loc.i++) 53 | { 54 | if (loc.cachableActions[loc.i].action == loc.params.action) 55 | { 56 | loc.actionIsCachable = true; 57 | loc.timeToCache = loc.cachableActions[loc.i].time; 58 | } 59 | } 60 | } 61 | if (loc.actionIsCachable) 62 | { 63 | loc.category = "action"; 64 | loc.key = "#request.cgi.script_name##request.cgi.path_info##request.cgi.query_string#"; 65 | loc.lockName = loc.category & loc.key; 66 | loc.conditionArgs = {}; 67 | loc.conditionArgs.key = loc.key; 68 | loc.conditionArgs.category = loc.category; 69 | loc.executeArgs = {}; 70 | loc.executeArgs.controller = loc.controller; 71 | loc.executeArgs.controllerName = loc.params.controller; 72 | loc.executeArgs.actionName = loc.params.action; 73 | loc.executeArgs.key = loc.key; 74 | loc.executeArgs.time = loc.timeToCache; 75 | loc.executeArgs.category = loc.category; 76 | request.wheels.response = $doubleCheckedLock(name=loc.lockName, condition="$getFromCache", execute="$callActionAndAddToCache", conditionArgs=loc.conditionArgs, executeArgs=loc.executeArgs); 77 | } 78 | else 79 | { 80 | $callAction(controller=loc.controller, controllerName=loc.params.controller, actionName=loc.params.action); 81 | } 82 | if (application.wheels.showDebugInformation) 83 | $debugPoint("action,afterFilters"); 84 | $runFilters(controller=loc.controller, type="after", actionName=loc.params.action); 85 | if (application.wheels.showDebugInformation) 86 | $debugPoint("afterFilters"); 87 | 88 | // clear the flash (note that this is not done for redirectTo since the processing does not get here) 89 | StructClear(session.flash); 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | var loc = {}; 100 | 101 | if (Left(arguments.actionName, 1) == "$" || ListFindNoCase(application.wheels.protectedControllerMethods, arguments.actionName)) 102 | $throw(type="Wheels.ActionNotAllowed", message="You are not allowed to execute the `#arguments.actionName#` method as an action.", extendedInfo="Make sure your action does not have the same name as any of the built-in Wheels functions."); 103 | 104 | if (StructKeyExists(arguments.controller, arguments.actionName)) 105 | $invoke(componentReference=arguments.controller, method=arguments.actionName); 106 | if (!StructKeyExists(request.wheels, "response")) 107 | { 108 | // a render function has not been called yet so call it here 109 | try 110 | { 111 | arguments.controller.renderPage(); 112 | } 113 | catch(Any e) 114 | { 115 | //// bigrig: //// 116 | loc.viewPath = $getViewPath(controller=arguments.controllerName, action=arguments.actionName); 117 | // if (FileExists(ExpandPath("#application.wheels.viewPath#/#LCase(arguments.controllerName)#/#LCase(arguments.actionName)#.cfm"))) 118 | if (FileExists(ExpandPath(loc.viewPath)) || FileExists(ExpandPath("/"&loc.viewPath))) 119 | //// :bigrig //// 120 | { 121 | $throw(object=e); 122 | } 123 | else 124 | { 125 | if (application.wheels.showErrorInformation) 126 | { 127 | //// bigrig: //// 128 | loc.viewPath = reverse(listRest(reverse(loc.viewPath), "/")); 129 | // $throw(type="Wheels.ViewNotFound", message="Could not find the view page for the `#arguments.actionName#` action in the `#arguments.controllerName#` controller.", extendedInfo="Create a file named `#LCase(arguments.actionName)#.cfm` in the `views/#LCase(arguments.controllerName)#` directory (create the directory as well if it doesn't already exist)."); 130 | $throw(type="Wheels.ViewNotFound", message="Could not find the view page for the `#arguments.actionName#` action in the `#arguments.controllerName#` controller.", extendedInfo="Create a file named `#LCase(arguments.actionName)#.cfm` in the `#loc.viewPath#` directory (create the directory as well if it doesn't already exist)."); 131 | //// :bigrig //// 132 | } 133 | else 134 | { 135 | $header(statusCode="404", statusText="Not Found"); 136 | $includeAndOutput(template="#application.wheels.eventPath#/onmissingtemplate.cfm"); 137 | $abort(); 138 | } 139 | } 140 | } 141 | } 142 | 143 | -------------------------------------------------------------------------------- /wheels/global/public.cfm: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | var loc = {}; 22 | loc.params = {}; 23 | if (StructKeyExists(variables, "params")) 24 | StructAppend(loc.params, variables.params, true); 25 | if (application.wheels.showErrorInformation) 26 | { 27 | if (arguments.onlyPath && (Len(arguments.host) || Len(arguments.protocol))) 28 | $throw(type="Wheels.IncorrectArguments", message="Can't use the `host` or `protocol` arguments when `onlyPath` is `true`.", extendedInfo="Set `onlyPath` to `false` so that `linkTo` will create absolute URLs and thus allowing you to set the `host` and `protocol` on the link."); 29 | } 30 | 31 | // get primary key values if an object was passed in 32 | if (IsObject(arguments.key)) 33 | { 34 | arguments.key = arguments.key.key(); 35 | } 36 | 37 | // build the link 38 | loc.returnValue = application.wheels.webPath & ListLast(request.cgi.script_name, "/"); 39 | 40 | //// bigrig: //// 41 | // no route was requested, there is a matching route defined for this request and this request is for a BigRig controller 42 | if (!Len(arguments.route) && StructKeyExists(loc.params, "route") && $isBigRigRequest(loc.params.controller)) { 43 | arguments.route = loc.params.route; 44 | arguments[singularize(arguments.route)] = loc.params[singularize(arguments.route)]; 45 | if(arguments.controller EQ "") { 46 | arguments.controller = $getComponentName(loc.params.controller); 47 | } 48 | } 49 | //// :bigrig //// 50 | 51 | if (Len(arguments.route)) 52 | { 53 | // link for a named route 54 | loc.route = $findRoute(argumentCollection=arguments); 55 | if (application.wheels.URLRewriting == "Off") 56 | { 57 | loc.returnValue = loc.returnValue & "?controller="; 58 | if (Len(arguments.controller)) 59 | loc.returnValue = loc.returnValue & REReplace(REReplace(arguments.controller, "([A-Z])", "-\l\1", "all"), "^-", "", "one"); 60 | else 61 | loc.returnValue = loc.returnValue & REReplace(REReplace(loc.route.controller, "([A-Z])", "-\l\1", "all"), "^-", "", "one"); 62 | loc.returnValue = loc.returnValue & "&action="; 63 | if (Len(arguments.action)) 64 | loc.returnValue = loc.returnValue & REReplace(REReplace(arguments.action, "([A-Z])", "-\l\1", "all"), "^-", "", "one"); 65 | else 66 | loc.returnValue = loc.returnValue & REReplace(REReplace(loc.route.action, "([A-Z])", "-\l\1", "all"), "^-", "", "one"); 67 | loc.iEnd = ListLen(loc.route.variables); 68 | for (loc.i=1; loc.i <= loc.iEnd; loc.i++) 69 | { 70 | loc.property = ListGetAt(loc.route.variables, loc.i); 71 | if (loc.property != "controller" && loc.property != "action") 72 | loc.returnValue = loc.returnValue & "&" & loc.property & "=" & $URLEncode(arguments[loc.property]); 73 | } 74 | } 75 | else 76 | { 77 | loc.iEnd = ListLen(loc.route.pattern, "/"); 78 | for (loc.i=1; loc.i <= loc.iEnd; loc.i++) 79 | { 80 | loc.property = ListGetAt(loc.route.pattern, loc.i, "/"); 81 | if (loc.property Contains "[") 82 | { 83 | loc.property = Mid(loc.property, 2, Len(loc.property)-2); 84 | if (application.wheels.showErrorInformation && !StructKeyExists(arguments, loc.property)) 85 | $throw(type="Wheels", message="Incorrect Arguments", extendedInfo="The route chosen by Wheels `#loc.route.name#` requires the argument `#loc.property#`. Pass the argument `#loc.property#` or change your routes to reflect the proper variables needed."); 86 | loc.param = $URLEncode(arguments[loc.property]); 87 | if (loc.property == "controller" || loc.property == "action") 88 | loc.param = REReplace(REReplace(loc.param, "([A-Z])", "-\l\1", "all"), "^-", "", "one"); 89 | else if (application.wheels.obfuscateUrls) 90 | loc.param = obfuscateParam(loc.param); 91 | loc.returnValue = loc.returnValue & "/" & loc.param; // get param from arguments 92 | } 93 | else 94 | { 95 | loc.returnValue = loc.returnValue & "/" & loc.property; // add hard coded param from route 96 | } 97 | } 98 | } 99 | } 100 | else 101 | { 102 | // link based on controller/action/key 103 | if (!Len(arguments.controller) && !Len(arguments.action) && StructKeyExists(loc.params, "action")) 104 | arguments.action = loc.params.action; // when no controller or action was passed in we link to the current page (controller/action only, not query string etc) by default 105 | if (!Len(arguments.controller) && StructKeyExists(loc.params, "controller")) 106 | arguments.controller = loc.params.controller; // use the current controller as the default when none was passed in by the developer 107 | loc.returnValue = loc.returnValue & "?controller=" & REReplace(REReplace(arguments.controller, "([A-Z])", "-\l\1", "all"), "^-", "", "one"); 108 | if (Len(arguments.action)) 109 | loc.returnValue = loc.returnValue & "&action=" & REReplace(REReplace(arguments.action, "([A-Z])", "-\l\1", "all"), "^-", "", "one"); 110 | if (Len(arguments.key)) 111 | { 112 | loc.param = $URLEncode(arguments.key); 113 | if (application.wheels.obfuscateUrls) 114 | loc.param = obfuscateParam(loc.param); 115 | loc.returnValue = loc.returnValue & "&key=" & loc.param; 116 | } 117 | } 118 | 119 | if (application.wheels.URLRewriting != "Off") 120 | { 121 | loc.returnValue = Replace(loc.returnValue, "?controller=", "/"); 122 | loc.returnValue = Replace(loc.returnValue, "&action=", "/"); 123 | loc.returnValue = Replace(loc.returnValue, "&key=", "/"); 124 | } 125 | if (application.wheels.URLRewriting == "On") 126 | { 127 | loc.returnValue = Replace(loc.returnValue, "rewrite.cfm", ""); 128 | loc.returnValue = Replace(loc.returnValue, "//", "/"); 129 | } 130 | 131 | if (Len(arguments.params)) 132 | loc.returnValue = loc.returnValue & $constructParams(arguments.params); 133 | if (Len(arguments.anchor)) 134 | loc.returnValue = loc.returnValue & "##" & arguments.anchor; 135 | 136 | if (!arguments.onlyPath) 137 | { 138 | if (arguments.port != 0) 139 | loc.returnValue = ":" & arguments.port & loc.returnValue; // use the port that was passed in by the developer 140 | else if (request.cgi.server_port != 80 && request.cgi.server_port != 443) 141 | loc.returnValue = ":" & request.cgi.server_port & loc.returnValue; // if the port currently in use is not 80 or 443 we set it explicitly in the URL 142 | if (Len(arguments.host)) 143 | loc.returnValue = arguments.host & loc.returnValue; 144 | else 145 | loc.returnValue = request.cgi.server_name & loc.returnValue; 146 | if (Len(arguments.protocol)) 147 | loc.returnValue = arguments.protocol & "://" & loc.returnValue; 148 | else 149 | loc.returnValue = SpanExcluding(request.cgi.server_protocol, "/") & "://" & loc.returnValue; 150 | } 151 | loc.returnValue = LCase(loc.returnValue); 152 | 153 | 154 | -------------------------------------------------------------------------------- /wheels/controller/rendering.cfm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | //// bigrig: // 6 | // var loc = {}; 7 | // 8 | // loc.include = application.wheels.viewPath; 9 | // loc.fileName = Spanexcluding(Reverse(ListFirst(Reverse(arguments.$name), "/")), ".") & ".cfm"; // extracts the file part of the path and replace ending ".cfm" 10 | // 11 | // if (arguments.$type == "partial") 12 | // loc.fileName = Replace("_" & loc.fileName, "__", "_", "one"); // replaces leading "_" when the file is a partial 13 | // 14 | // loc.folderName = Reverse(ListRest(Reverse(arguments.$name), "/")); 15 | var loc = $getComponentInitInfo(name=arguments.$name, type=arguments.$type);; 16 | if (arguments.$type == "partial") { 17 | loc.fileName = Replace("_" & loc.fileName, "__", "_", "one"); // replaces leading "_" when the file is a partial 18 | } 19 | if (Left(arguments.$name, 1) == "/"){ 20 | loc.include = loc.include & loc.folderName & "/" & loc.fileName; // Include a file in a sub folder to views 21 | } 22 | else if (arguments.$name Contains "/"){ 23 | // loc.include = loc.include & "/" & variables.params.controller & "/" & loc.folderName & "/" & loc.fileName; // Include a file in a sub folder of the current controller 24 | loc.include = loc.include & "/" & loc.controllerName & "/" & loc.folderName & "/" & loc.fileName; // Include a file in a sub folder of the current controller 25 | } 26 | else { 27 | // loc.include = loc.include & "/" & variables.params.controller & "/" & loc.fileName; // Include a file in the current controller's view folder 28 | loc.include = loc.include & "/" & loc.controllerName & "/" & loc.fileName; // Include a file in the current controller's view folder 29 | } 30 | //// :bigrig //// 31 | 32 | arguments.$template = loc.include; 33 | 34 | if (arguments.$type == "partial") 35 | { 36 | loc.pluralizedName = pluralize(arguments.$name); 37 | if (StructKeyExists(arguments, loc.pluralizedName) && IsQuery(arguments[loc.pluralizedName])) 38 | { 39 | loc.query = arguments[loc.pluralizedName]; 40 | loc.returnValue = ""; 41 | loc.iEnd = loc.query.recordCount; 42 | if (Len(arguments.$group)) 43 | { 44 | // we want to group based on a column so loop through the rows until we find, this will break if the query is not ordered by the grouped column 45 | loc.tempSpacer = "}|{"; 46 | loc.groupValue = ""; 47 | loc.groupQueryCount = 1; 48 | arguments.group = QueryNew(loc.query.columnList); 49 | if (application.wheels.showErrorInformation && !ListFindNoCase(loc.query.columnList, arguments.$group)) 50 | $throw(type="Wheels.GroupColumnNotFound", message="Wheels couldn't find a query column with the name of `#arguments.$group#`.", extendedInfo="Make sure your finder method has the column `#arguments.$group#` specified in the `select` argument. If the column does not exist, create it."); 51 | for (loc.i=1; loc.i <= loc.iEnd; loc.i++) 52 | { 53 | if (loc.i == 1) 54 | { 55 | loc.groupValue = loc.query[arguments.$group][loc.i]; 56 | } 57 | else if (loc.groupValue != loc.query[arguments.$group][loc.i]) 58 | { 59 | // we have a different group for this row so output what we have 60 | loc.returnValue = loc.returnValue & $includeAndReturnOutput(argumentCollection=arguments); 61 | if (StructKeyExists(arguments, "$spacer")) 62 | loc.returnValue = loc.returnValue & loc.tempSpacer; 63 | loc.groupValue = loc.query[arguments.$group][loc.i]; 64 | arguments.group = QueryNew(loc.query.columnList); 65 | loc.groupQueryCount = 1; 66 | } 67 | loc.dump = QueryAddRow(arguments.group); 68 | loc.jEnd = ListLen(loc.query.columnList); 69 | for (loc.j=1; loc.j <= loc.jEnd; loc.j++) 70 | { 71 | loc.property = ListGetAt(loc.query.columnList, loc.j); 72 | arguments[loc.property] = loc.query[loc.property][loc.i]; 73 | loc.dump = QuerySetCell(arguments.group, loc.property, loc.query[loc.property][loc.i], loc.groupQueryCount); 74 | } 75 | arguments.current = (loc.i+1) - arguments.group.recordCount; 76 | loc.groupQueryCount++; 77 | } 78 | // if we have anything left at the end we need to render it too 79 | if (arguments.group.RecordCount > 0) 80 | { 81 | loc.returnValue = loc.returnValue & $includeAndReturnOutput(argumentCollection=arguments); 82 | if (StructKeyExists(arguments, "$spacer") && loc.i < loc.iEnd) 83 | loc.returnValue = loc.returnValue & loc.tempSpacer; 84 | } 85 | // now remove the last temp spacer and replace the tempSpacer with $spacer 86 | if (Right(loc.returnValue, 3) == loc.tempSpacer) 87 | loc.returnValue = Left(loc.returnValue, Len(loc.returnValue) - 3); 88 | loc.returnValue = Replace(loc.returnValue, loc.tempSpacer, arguments.$spacer, "all"); 89 | } 90 | else 91 | { 92 | for (loc.i=1; loc.i <= loc.iEnd; loc.i++) 93 | { 94 | arguments.current = loc.i; 95 | loc.jEnd = ListLen(loc.query.columnList); 96 | for (loc.j=1; loc.j <= loc.jEnd; loc.j++) 97 | { 98 | loc.property = ListGetAt(loc.query.columnList, loc.j); 99 | arguments[loc.property] = loc.query[loc.property][loc.i]; 100 | } 101 | loc.returnValue = loc.returnValue & $includeAndReturnOutput(argumentCollection=arguments); 102 | if (StructKeyExists(arguments, "$spacer") && loc.i < loc.iEnd) 103 | loc.returnValue = loc.returnValue & arguments.$spacer; 104 | } 105 | } 106 | } 107 | else if (StructKeyExists(arguments, arguments.$name) && IsObject(arguments[arguments.$name])) 108 | { 109 | loc.object = arguments[arguments.$name]; 110 | StructAppend(arguments, loc.object.properties(), false); 111 | } 112 | else if (StructKeyExists(arguments, loc.pluralizedName) && IsArray(arguments[loc.pluralizedName])) 113 | { 114 | loc.originalArguments = Duplicate(arguments); 115 | loc.array = arguments[loc.pluralizedName]; 116 | loc.returnValue = ""; 117 | loc.iEnd = ArrayLen(loc.array); 118 | for (loc.i=1; loc.i <= loc.iEnd; loc.i++) 119 | { 120 | arguments.current = loc.i; 121 | loc.properties = loc.array[loc.i].properties(); 122 | for (loc.key in loc.originalArguments) 123 | if (StructKeyExists(loc.properties, loc.key)) 124 | StructDelete(loc.properties, loc.key); 125 | StructAppend(arguments, loc.properties, true); 126 | loc.returnValue = loc.returnValue & $includeAndReturnOutput(argumentCollection=arguments); 127 | if (StructKeyExists(arguments, "$spacer") && loc.i < loc.iEnd) 128 | loc.returnValue = loc.returnValue & arguments.$spacer; 129 | } 130 | } 131 | } 132 | if (!StructKeyExists(loc, "returnValue")){ 133 | loc.returnValue = $includeAndReturnOutput(argumentCollection=arguments); 134 | } 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | //// bigrig: //// 144 | // var loc = {}; 145 | // $renderLayout doesn't expect a trailing slash 146 | var loc = $getComponentInitInfo(name=variables.params.controller, type="layout"); 147 | //// :bigrig //// 148 | if ((IsBoolean(arguments.$layout) && arguments.$layout) || (!IsBoolean(arguments.$layout) && Len(arguments.$layout))) 149 | { 150 | request.wheels.contentForLayout = arguments.$content; // store the content in a variable in the request scope so it can be accessed by the contentForLayout function that the developer uses in layout files (this is done so we avoid passing data to/from it since it would complicate things for the developer) 151 | 152 | //// bigrig: //// 153 | // loc.include = application.wheels.viewPath; 154 | //// :bigrig //// 155 | if (IsBoolean(arguments.$layout)) 156 | { 157 | 158 | if (!ListFindNoCase(application.wheels.existingLayoutFiles, variables.params.controller) && !ListFindNoCase(application.wheels.nonExistingLayoutFiles, variables.params.controller)) 159 | { 160 | //// bigrig: //// 161 | //if (FileExists(ExpandPath("#application.wheels.viewPath#/#LCase(variables.params.controller)#/layout.cfm"))) 162 | if (FileExists(ExpandPath("#loc.viewPath#/#LCase(loc.fileName)#/layout.cfm"))) 163 | //// :bigrig //// 164 | application.wheels.existingLayoutFiles = ListAppend(application.wheels.existingLayoutFiles, variables.params.controller); 165 | else 166 | application.wheels.nonExistingLayoutFiles = ListAppend(application.wheels.nonExistingLayoutFiles, variables.params.controller); 167 | } 168 | if (ListFindNoCase(application.wheels.existingLayoutFiles, variables.params.controller)) 169 | { 170 | //// bigrig: //// 171 | // loc.include = loc.include & "/" & variables.params.controller & "/" & "layout.cfm"; 172 | loc.include = loc.include & "/" & loc.fileName & "/" & "layout.cfm"; 173 | //// :bigrig //// 174 | } 175 | else 176 | { 177 | loc.include = loc.include & "/" & "layout.cfm"; 178 | } 179 | 180 | loc.returnValue = $includeAndReturnOutput($template=loc.include); 181 | } 182 | else 183 | { 184 | loc.returnValue = $includeFile($name=arguments.$layout, $type="layout"); 185 | } 186 | } 187 | else 188 | { 189 | loc.returnValue = arguments.$content; 190 | } 191 | 192 | 193 | --------------------------------------------------------------------------------