Skip to content

Commit

Permalink
path updates to allow for deep nesting of modules
Browse files Browse the repository at this point in the history
  • Loading branch information
jclausen committed Sep 26, 2016
1 parent 6bdf3f2 commit 1e19ff5
Show file tree
Hide file tree
Showing 17 changed files with 341 additions and 36 deletions.
4 changes: 2 additions & 2 deletions includes/jsdev/models/RelaxAPI.js
Expand Up @@ -11,15 +11,15 @@ define([
/**
* The API Path of the model ( sans the ID value )
*/
urlRoot: '/relax/apidoc'
urlRoot: window.relax.apiDocBaseUrl
/**
* ----------------------------------------------
* Initializes this model
* ----------------------------------------------
*/
,initialize:function( attributes, options ){

if( typeof( moduleAPIRoot ) === 'undefined' ) moduleAPIRoot = '/relax/';
if( typeof( moduleAPIRoot ) === 'undefined' ) moduleAPIRoot = window.relax.baseUrl;

this.urlRoot = moduleAPIRoot + 'apidoc';

Expand Down
2 changes: 1 addition & 1 deletion includes/jsdev/views/widgets/sidebar.js
Expand Up @@ -41,7 +41,7 @@ define(
,initialize:function( options ){
var _this = this;

if( typeof( moduleAPIRoot ) === 'undefined' ) moduleAPIRoot = '/relax/';
if( typeof( moduleAPIRoot ) === 'undefined' ) moduleAPIRoot = window.relax.baseUrl;

if( !_.isUndefined( options.apis ) ){
_this.availableAPIs = options.apis;
Expand Down
10 changes: 5 additions & 5 deletions modules/relax/ModuleConfig.cfc
Expand Up @@ -35,18 +35,18 @@ component{
routes = [
// APIDoc API Routes
{
pattern="/apidoc/:api?",
pattern="apidoc/:api?",
handler="APIDoc",
action={"GET":"index","POST":"create","PUT":"update","PATCH":"update","DELETE":"delete"}

},
//Direct API requests
{ pattern="/export/:action/:apiname?", handler="Export", action="index" },
{ pattern="/api/:apiname?", handler="Home", action="index" },
{ pattern="export/:action/:apiname?", handler="Export", action="index" },
{ pattern="api/:apiname?", handler="Home", action="index" },
// Module Entry Point
{ pattern="/", handler="Home", action="index" },
{ pattern="", handler="Home", action="index" },
// Convention Route
{ pattern="/:handler/:action?" }
{ pattern=":handler/:action?" }
];

}
Expand Down
30 changes: 14 additions & 16 deletions modules/relax/handlers/BaseHandler.cfc
Expand Up @@ -38,34 +38,32 @@ component {
"css":[]
};

prc.addCSS = function( assetPath ){
// workaround for ACF11 closure support
var prc = application.cbController.getRequestService().getContext().getCollection( private=true );
arrayAppend( prc.runtimeAssets.css, assetPath );
};

prc.addJS = function( assetPath ){
// workaround for ACF11 closure support
var prc = application.cbController.getRequestService().getContext().getCollection( private=true );
arrayAppend( prc.runtimeAssets.js, assetPath );
};

// Naming convention is: {handler}.css
var cssPathCheck = cssViewPath & "#lcase(handler)#.css";
if( fileExists( expandPath( cssPathCheck )) ){ prc.addCSS( cssPathCheck ); }
if( fileExists( expandPath( cssPathCheck )) ){ addCSS( cssPathCheck ); }

// Naming convention is: {handler}-{action}.css
var cssPathCheck = cssViewPath & "#lcase(handler)#-#action#.css";
if( fileExists( expandPath( cssPathCheck )) ){ prc.addCSS( cssPathCheck ); }
if( fileExists( expandPath( cssPathCheck )) ){ addCSS( cssPathCheck ); }

// Naming convention is: {handler}.js
var jsPathCheck = jsViewPath & "#lcase(handler)#.js";
if( fileExists( expandPath(jsPathCheck) ) ){ prc.addJS( jsPathCheck ); }
if( fileExists( expandPath(jsPathCheck) ) ){ addJS( jsPathCheck ); }

// Naming convention is: {handler}.{action}.js
var jsPathCheck = jsViewPath & "#lcase(handler)#.#action#.js";
if( fileExists( expandPath(jsPathCheck) ) ){ prc.addJS( jsPathCheck ); }
if( fileExists( expandPath(jsPathCheck) ) ){ addJS( jsPathCheck ); }

}

function addCSS( assetPath ){
var prc = getController().getRequestService().getContext().getCollection( private=true );
arrayAppend( prc.runtimeAssets.css, assetPath );
};

function addJS( assetPath ){
var prc = getController().getRequestService().getContext().getCollection( private=true );
arrayAppend( prc.runtimeAssets.js, assetPath );
}

}
6 changes: 3 additions & 3 deletions modules/relax/includes/js/models/RelaxAPI.js
@@ -1,10 +1,10 @@
/*! Copyright 2016 - Ortus Solutions (Compiled: 23-03-2016) */
/*! Copyright 2016 - Ortus Solutions (Compiled: 15-09-2016) */
define([ "Backbone" ], function(Backbone) {
"use strict";
var Model = Backbone.Model.extend({
urlRoot: "/relax/apidoc",
urlRoot: window.relax.apiDocBaseUrl,
initialize: function(attributes, options) {
if (typeof moduleAPIRoot === "undefined") moduleAPIRoot = "/relax/";
if (typeof moduleAPIRoot === "undefined") moduleAPIRoot = window.relax.baseUrl;
this.urlRoot = moduleAPIRoot + "apidoc";
if (typeof attributes !== "undefined") this.set(attributes);
return this;
Expand Down
2 changes: 1 addition & 1 deletion modules/relax/includes/js/models/RelaxerHistory.js
@@ -1,4 +1,4 @@
/*! Copyright 2016 - Ortus Solutions (Compiled: 23-03-2016) */
/*! Copyright 2016 - Ortus Solutions (Compiled: 15-09-2016) */
define([ "Backbone" ], function(Backbone) {
"use strict";
var Model = Backbone.Model.extend({
Expand Down
2 changes: 1 addition & 1 deletion modules/relax/includes/js/views/export.html.js
@@ -1,4 +1,4 @@
/*! Copyright 2016 - Ortus Solutions (Compiled: 23-03-2016) */
/*! Copyright 2016 - Ortus Solutions (Compiled: 15-09-2016) */
define([ "Backbone", "clipboard", "messenger", "views/home.index" ], function(Backbone, Clipboard, Messenger, APIView) {
"use strict";
var View = Backbone.View.extend({
Expand Down
2 changes: 1 addition & 1 deletion modules/relax/includes/js/views/home.index.js
@@ -1,4 +1,4 @@
/*! Copyright 2016 - Ortus Solutions (Compiled: 23-03-2016) */
/*! Copyright 2016 - Ortus Solutions (Compiled: 15-09-2016) */
define([ "Backbone", "views/widgets/relaxer", "views/widgets/sidebar", "models/RelaxAPI", "clipboard", "messenger", "scrollify" ], function(Backbone, Relaxer, SidebarWidget, APIModel, Clipboard, Messenger, scrollify) {
"use strict";
var View = Backbone.View.extend({
Expand Down
2 changes: 1 addition & 1 deletion modules/relax/includes/js/views/home.openapidocs.js
@@ -1,4 +1,4 @@
/*! Copyright 2016 - Ortus Solutions (Compiled: 23-03-2016) */
/*! Copyright 2016 - Ortus Solutions (Compiled: 15-09-2016) */
define([ "Backbone" ], function(Backbone) {
"use strict";
var View = Backbone.View.extend({
Expand Down
2 changes: 1 addition & 1 deletion modules/relax/includes/js/views/relaxer.index.js
@@ -1,4 +1,4 @@
/*! Copyright 2016 - Ortus Solutions (Compiled: 23-03-2016) */
/*! Copyright 2016 - Ortus Solutions (Compiled: 15-09-2016) */
define([ "Backbone", "views/widgets/relaxer", "views/widgets/sidebar", "models/RelaxAPI" ], function(Backbone, RelaxerWidget, SidebarWidget, APIModel) {
"use strict";
var View = Backbone.View.extend({
Expand Down
2 changes: 1 addition & 1 deletion modules/relax/includes/js/views/widgets/relaxer.js
@@ -1,4 +1,4 @@
/*! Copyright 2016 - Ortus Solutions (Compiled: 23-03-2016) */
/*! Copyright 2016 - Ortus Solutions (Compiled: 15-09-2016) */
define([ "Backbone", "models/RelaxerHistory" ], function(Backbone, HistoryModel) {
"use strict";
var Relaxer = Backbone.View.extend({
Expand Down
4 changes: 2 additions & 2 deletions modules/relax/includes/js/views/widgets/sidebar.js
@@ -1,4 +1,4 @@
/*! Copyright 2016 - Ortus Solutions (Compiled: 23-03-2016) */
/*! Copyright 2016 - Ortus Solutions (Compiled: 15-09-2016) */
define([ "Backbone", "models/RelaxAPI", "models/RelaxerHistory" ], function(Backbone, APIModel, HistoryModel) {
"use strict";
var View = Backbone.View.extend({
Expand All @@ -12,7 +12,7 @@ define([ "Backbone", "models/RelaxAPI", "models/RelaxerHistory" ], function(Back
},
initialize: function(options) {
var _this = this;
if (typeof moduleAPIRoot === "undefined") moduleAPIRoot = "/relax/";
if (typeof moduleAPIRoot === "undefined") moduleAPIRoot = window.relax.baseUrl;
if (!_.isUndefined(options.apis)) {
_this.availableAPIs = options.apis;
_this.defaultAPI = options.default;
Expand Down
7 changes: 7 additions & 0 deletions modules/relax/layouts/inc/HTMLBodyEnd.cfm
Expand Up @@ -73,7 +73,14 @@
<script type="application/javascript">
require(['#prc.root#/includes/js/es6-shim.js'],function(){
require(['#prc.root#/includes/js/globals.js'],function(globals){
require.config( {
baseUrl : '#prc.root#/includes/js/',
} );
window[ "_" ] = _;
window[ "relax" ] = {
baseUrl:"#prc.root#/",
apiDocBaseUrl:"#prc.root#/apidoc"
}
require(
[
'#prc.root#/includes/js/jsonlint.js',
Expand Down
2 changes: 1 addition & 1 deletion modules/relax/layouts/inc/HTMLHead.cfm
Expand Up @@ -31,7 +31,7 @@
<!--- <cfdump var="#event#" abort> --->
<script type="application/javascript">
var rootAssetPath = '#prc.root#';
var moduleAPIRoot = '/relax/';
var moduleAPIRoot = '#(len( getSetting( "AppMapping" ) ) ? '/' & getSetting( "AppMapping" ) : '')#/relax/';
</script>
</cfoutput>

Expand Down

0 comments on commit 1e19ff5

Please sign in to comment.