From fbc7c8510962dc59bae147d63a63344f85936151 Mon Sep 17 00:00:00 2001 From: Tim Badolato Date: Wed, 9 Aug 2017 14:17:24 -0500 Subject: [PATCH] Quick tweaks --- README.md | 17 +--- config/Routes.cfm | 2 +- config/app.cfm | 82 ++++++++++++++++++- config/docker/local-mysql/docker-compose.yml | 31 ++++--- config/system.properties | 14 ---- events/functions.cfm | 9 -- events/onapplicationstart.cfm | 22 +++++ events/onerror.cfm | 16 ++-- events/onrequeststart.cfm | 11 ++- models/services/global/app/app.cfm | 2 +- models/services/global/global.cfm | 61 +------------- models/services/global/init/setinfo.cfm | 2 +- models/services/global/settings.cfm | 28 +++---- .../admin/views/_partials/_publicheadtags.cfm | 1 + modules/public/controllers/PublicPages.cfc | 2 +- urlrewrite.xml | 14 ++-- views/themes/light-theme/layout.cfm | 3 + 17 files changed, 170 insertions(+), 147 deletions(-) diff --git a/README.md b/README.md index d3b20fd..33dff6f 100644 --- a/README.md +++ b/README.md @@ -19,21 +19,6 @@ cd wheelie docker-compose -f config/docker/local-mysql/docker-compose.yml up ``` -Then go to the Lucee admin and add the Mysql Datasource running in Docker: -http://localhost:8080/lucee/admin/web.cfm?action=services.datasource - -``` -DB Type: Mysql -Datasource name: wheelie -Host/Server: wheelie_mysql -Database: wheeliedb -Username: root -Password: NOT_SECURE_CHANGE -``` - -You will also need to add an SMTP server otherwise you're going to have a bad time: -http://localhost:8080/lucee/admin/web.cfm?action=services.mail - Then access the application via: http://localhost:8080 @@ -44,6 +29,8 @@ Username: admin@getwheelie.com Password: wheelie ``` +Configure your app here: `config/docker/local-mysql/docker-compose.yml` + External MYSQL Connection Info: ``` diff --git a/config/Routes.cfm b/config/Routes.cfm index ff2c7b4..b106190 100755 --- a/config/Routes.cfm +++ b/config/Routes.cfm @@ -1,6 +1,6 @@ . - adminUrlPath = getSiteSetting("wheelsAdminUrlPath","/manager"); + adminUrlPath = getSiteSetting("WHEELIE_ADMINURLPATH","/manager"); application.wheels.adminUrlPath = adminUrlPath; // Custom routes diff --git a/config/app.cfm b/config/app.cfm index 77c6549..b20082a 100755 --- a/config/app.cfm +++ b/config/app.cfm @@ -4,11 +4,85 @@ include template="/models/services/global/app/systemvars.cfm"; this.runtimeconfig = setRuntimeSettings(); - include template="/models/services/global/settings.cfm"; - - this.applicationTimeout = "#createTimespan(30,0,0,0)#"; + this.applicationTimeout = createTimespan(30,0,0,0); this.sessionManagement = "true"; - this.sessionTimeout = "#createTimeSpan(30,0,0,0)#"; + this.sessionTimeout = createTimeSpan(30,0,0,0); this.name = "Wheelie"; rootPath = getDirectoryFromPath(getBaseTemplatePath()); + + request.muraInDocker=len(getSiteSetting('WHEELIE_DATASOURCE')) && len(getSiteSetting('WHEELIE_DATABASE')); + if(request.muraInDocker){ + this.tag.mail.server=getSiteSetting('WHEELIE_SMTP_SERVER'); + this.tag.mail.username=getSiteSetting('WHEELIE_SMTP_USERNAME'); + this.tag.mail.password=getSiteSetting('WHEELIE_SMTP_PASSWORD'); + this.tag.mail.port=getSiteSetting('WHEELIE_SMTP_PORT'); + this.tag.mail.usetls=getSiteSetting('WHEELIE_SMTP_USETLS'); + + if(server.coldfusion.productname == 'lucee'){ + driverVarName='type'; + + switch(getSiteSetting('WHEELIE_DBTYPE')){ + case 'mysql': + driverName='mysql'; + break; + case 'mssql': + driverName='mssql'; + break; + case 'oracle': + driverName='Oracle'; + break; + case 'postgresql': + driverName='PostgreSQL'; + break; + } + } else { + driverVarName='driver'; + + switch(getSiteSetting('WHEELIE_DBTYPE')){ + case 'mysql': + driverName='MySQL5'; + break; + case 'mssql': + driverName='MSSQLServer'; + break; + case 'oracle': + driverName='Oracle'; + break; + case 'postgresql': + driverName='PostgreSQL'; + break; + } + } + + this.datasources={ + '#getSiteSetting('WHEELIE_DATASOURCE')#' = { + '#driverVarName#' = driverName + , host = getSiteSetting('WHEELIE_DBHOST') + , database = getSiteSetting('WHEELIE_DATABASE') + , port = getSiteSetting('WHEELIE_DBPORT') + , username = getSiteSetting('WHEELIE_DBUSERNAME') + , password = getSiteSetting('WHEELIE_DBPASSWORD') + }, + nodatabase= { + '#driverVarName#' = driverName + , host = getSiteSetting('WHEELIE_DBHOST') + , database = '' + , port = getSiteSetting('WHEELIE_DBPORT') + , username = getSiteSetting('WHEELIE_DBUSERNAME') + , password = getSiteSetting('WHEELIE_DBPASSWORD') + } + }; + + this.webadminpassword=getSiteSetting('WHEELIE_ADMIN_PASSWORD'); + + } + + // this.datasources["App"] = { + // class: 'org.gjt.mm.mysql.Driver' + // , connectionString: 'jdbc:mysql://wheelie_mysql:3306/wheeliedb?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' + // , username: 'root' + // , password: "encrypted:2c66b1dd756f915a7984fc9fef742676a9d3c4f6466ff26c3e907fe026a50a70cde804b61f8d1eaa87a69ec4a09f4eb2" + // // optional settings + // , connectionLimit:100 // default:-1 + // }; diff --git a/config/docker/local-mysql/docker-compose.yml b/config/docker/local-mysql/docker-compose.yml index 2974c2e..32f0b0f 100755 --- a/config/docker/local-mysql/docker-compose.yml +++ b/config/docker/local-mysql/docker-compose.yml @@ -9,35 +9,44 @@ services: SSL_PORT: 8443 CFENGINE: lucee@5 CFCONFIG_ADMINPASSWORD: NOT_SECURE_CHANGE - WHEELIE_ADMIN_USERNAME: admin - WHEELIE_ADMIN_PASSWORD: admin - WHEELIE_ADMINEMAIL: example@localhost.com - WHEELIE_APPRELOADKEY: appreload + WHEELIE_APPRELOADPASS: woot + WHEELIE_DEFAULTEMAIL: default@getwheelie.com + WHEELIE_NOREPLYEMAIL: noreply@getwheelie.com + WHEELIE_ADMINEMAIL: admin@getwheelie.com + WHEELIE_ERROREMAILADDRESS: error@getwheelie.com + WHEELIE_ADMINFROMEMAIL: admin@getwheelie.com + WHEELIE_EMAILONERROR: "true" + WHEELIE_URLREWRITING: "on" + WHEELIE_REWRITEFILE: index.cfm + WHEELIE_PASSWORDSALT: OkIeKNKoIvbZMFPuMJ3EMQ== + WHEELIE_ADMINURLPATH: /manager WHEELIE_DATASOURCE: wheelie WHEELIE_DATABASE: wheeliedb WHEELIE_DBTYPE: mysql WHEELIE_DBUSERNAME: root WHEELIE_DBPASSWORD: NOT_SECURE_CHANGE - WHEELIE_DBHOST: wheelie_mysql + WHEELIE_DBHOST: wheelie_mysql_db WHEELIE_DBPORT: 3306 - WHEELIE_SITEIDINURLS: "false" - WHEELIE_INDEXFILEINURLS: "true" - WHEELIE_TESTBOX: "true" + WHEELIE_SMTP_SERVER: smtp.sendgrid.net + WHEELIE_SMTP_USERNAME: yoursendgridusername + WHEELIE_SMTP_PASSWORD: sendgridpass + WHEELIE_SMTP_PORT: 587 + WHEELIE_SMTP_USETLS: "true" volumes: - ../../../:/app ports: - "8080:8080" #MySQL - wheelie_mysql: + wheelie_mysql_db: image: mysql:latest environment: MYSQL_ROOT_PASSWORD: NOT_SECURE_CHANGE MYSQL_DATABASE: wheeliedb volumes: - - wheelie_mysql_data:/var/lib/mysql + - wheelie_mysql_db_data:/var/lib/mysql ports: - "55555:3306" volumes: - wheelie_mysql_data: + wheelie_mysql_db_data: diff --git a/config/system.properties b/config/system.properties index 4ce4897..a0db668 100644 --- a/config/system.properties +++ b/config/system.properties @@ -1,5 +1,3 @@ -passwordSalt=OkIeKNKoIvbZMFPuMJ3EMQ== - s3Enabled=false s3accessKeyId= s3awsSecretKey= @@ -7,17 +5,5 @@ s3defaultLocation=us s3host=s3.amazonaws.com s3defaultBucket= -wheelsDatasourceName=wheelie -wheelsReloadPassword=wheelie -wheelsUrlRewriting=On -wheelsRewriteFile=index.cfm -wheelsSendEmailOnError=true -wheelsAdminUrlPath=/manager - -noReplyEmail=noreply@wheelie.com -defaultEmail=admin@wheelie.com - youtubeDevKey= stripeKey= -sendgridusername= -sendgridpassword= \ No newline at end of file diff --git a/events/functions.cfm b/events/functions.cfm index 737f3c1..45a2234 100755 --- a/events/functions.cfm +++ b/events/functions.cfm @@ -1,16 +1,7 @@ request.fieldslist = ""; - include "/models/services/global/functions.cfm"; - - setSiteInfo(); - - settingsFilePath = "/views/themes/#request.site.theme#/settings.cfm"; - if(fileExists(expandPath(settingsFilePath))) - { - include "#settingsFilePath#"; - } diff --git a/events/onapplicationstart.cfm b/events/onapplicationstart.cfm index 9e2b2dc..8589086 100755 --- a/events/onapplicationstart.cfm +++ b/events/onapplicationstart.cfm @@ -1,5 +1,27 @@ + include template="/views/setup/check.cfm"; + // Initialize Shortcode plugins + include template="/models/services/global/settings.cfm"; + + setSiteInfo(); + + // Set User Permissions + if ( isNull(application.rbs.permissionsQuery) || isReload ) { + + var q = new query( datasource="wheelie" ); + q.addParam( name="lastModifiedTime", cfsqltype="cf_sql_timestamp", value=now()); + application.rbs.permissionsQuery = q.execute( sql="SELECT * FROM permissions" ).getResult(); + // Get role columns from permissions table - removed non role columns - convert array to remove list nulls - convert back to list + application.rbs.roleslist = ArrayToList(ListToArray(ReplaceList(lcase(application.rbs.permissionsQuery.columnList),lcase("CREATEDBY,UPDATEDBY,UPDATEDAT,CREATEDAT,DELETEDAT,DELETEDBY"),""))); + application.rbs.roleslist = replaceNoCase(application.rbs.roleslist, "ID,", ""); + for (var thisRole in listToArray(application.rbs.roleslist) ) { + for (var row in application.rbs.permissionsQuery ) { + application.rbs.permission[row.id][thisRole] = application.rbs.permissionsQuery[thisRole]; + } + } + } + application.shortcodes={}; include template="/views/plugins/plugins-init.cfm"; diff --git a/events/onerror.cfm b/events/onerror.cfm index 83ee270..ecf9b81 100755 --- a/events/onerror.cfm +++ b/events/onerror.cfm @@ -1,5 +1,11 @@ - - - - - + + + 500 Error + + + + + + + + diff --git a/events/onrequeststart.cfm b/events/onrequeststart.cfm index e612c77..190ef54 100755 --- a/events/onrequeststart.cfm +++ b/events/onrequeststart.cfm @@ -1,15 +1,20 @@ + include template="/views/setup/check.cfm"; setSiteInfo(); include "/models/services/global/settings.cfm"; + settingsFilePath = "/views/themes/#request.site.theme#/settings.cfm"; + if(fileExists(expandPath(settingsFilePath))) { + include "#settingsFilePath#"; + } + thisSiteUrl = "http://#request.site.domain#"; if( isNull(session.referer) AND len(trim(cgi.http_referer)) AND (len(cgi.http_referer) GTE thisSiteUrl AND Left(cgi.http_referer,len(thisSiteUrl)) NEQ thisSiteUrl OR len(cgi.http_referer) LT thisSiteUrl) - ) - { + ) { session.referer = cgi.http_referer; } @@ -42,5 +47,3 @@ ---> - - diff --git a/models/services/global/app/app.cfm b/models/services/global/app/app.cfm index 2163ca5..ce6891c 100755 --- a/models/services/global/app/app.cfm +++ b/models/services/global/app/app.cfm @@ -3,7 +3,7 @@ // Override pretty much any application setting here // Override admin scope set in /models/services/global/init/setinfo.cfm - infoAppend.adminUrlPath = getSiteSetting("wheelsAdminUrlPath","/manager"); + infoAppend.adminUrlPath = getSiteSetting("WHEELIE_ADMINURLPATH","/manager"); infoAppend.itemThumbPath = "/assets/uploads/items/"; infoAppend.propertyThumbPath = "/assets/uploads/mediafiles/"; infoAppend.fileItemThumbs = fixFilePathSlashes("#fileroot##infoAppend.itemThumbPath#"); diff --git a/models/services/global/global.cfm b/models/services/global/global.cfm index cb0653d..5db3533 100755 --- a/models/services/global/global.cfm +++ b/models/services/global/global.cfm @@ -12,33 +12,10 @@ !isNull(url.password) and !isNull(application.wheels.reloadPassword) and url.password eq application.wheels.reloadPassword - ) - { + ) { isReload = true; } - // if (!structKeyExists(application, 'markdown') or isReload) { - - // // Directory containing all the necessary jar files. - // jarDir = expandPath("/models/services/vendor/cfmarkdown"); - - // // Array of necessary classes - // jClass = [ - // "#jarDir#/parboiled-java-1.1.3.jar" - // ,"#jarDir#/asm-all-4.1.jar" - // ,"#jarDir#/parboiled-core-1.1.3.jar" - // ,"#jarDir#/pegdown-1.2.1.jar" - // ]; - // javaloader = createObject('component','models.services.vendor.javaloader.JavaLoader').init(jClass, false); - - // // Hex values for different extensions can be found in org.pegdown.Extensions.java (0x20 is for tables support) - - // // Output the HTML conversion ---> - // //#variables.pegdown.markdownToHtml(markdownString)# - // application.markdown = javaloader.create("org.pegdown.PegDownProcessor").init(javaCast("int", InputBaseN("0x20", 16)));; - // } - // markdown = application.markdown; - // Setup Underscore.cfc if (!structKeyExists(application, '_') or isReload) { application._ = CreateObject("component","models.services.vendor.underscore").init(); @@ -56,51 +33,17 @@ application.validateit = CreateObject("component","models.services.vendor.validateit").init(); } - /* Setup VideoConverter - if (!structKeyExists(application, 'videoConverter') or isReload) { - videoFileMgr = CreateObject("component","models.services.vendor.videoconverter.FileMgr").init(info.fileuploads,info.uploadsPath); - application.videoConverter = CreateObject("component","models.services.vendor.videoconverter.VideoConverter").init(videoFileMgr); - }*/ - // Setup filemanager application.fileMgr = CreateObject("component","models.services.vendor.filemgr").init(info.fileuploads,info.uploadsPath); - // Setup private filemanager - // if (!structKeyExists(application, 'privatefileMgr') or isReload) { - // application.privateFileMgr = CreateObject("component","models.services.vendor.filemgr").init(info.privateroot,info.privateRootPath); - // } - // Setup pagination application.pagination = CreateObject("component","models.services.vendor.pagination").init(); - //writeDump(application.pagination); abort; - // Make them accessible from local scope include "/models/services/global/init/setservices.cfm"; - - - - - q = new query( datasource="wheelie" ); - q.addParam( name="lastModifiedTime", cfsqltype="cf_sql_timestamp", value=now()); - application.rbs.permissionsQuery = q.execute( sql="SELECT * FROM permissions" ).getResult(); - - - - - - - - - application.rbs.permission["#id#"]["#thisRole#"] = application.rbs.permissionsQuery["#thisRole#"]; - - - - - + - diff --git a/models/services/global/init/setinfo.cfm b/models/services/global/init/setinfo.cfm index 017b5cd..080cde8 100755 --- a/models/services/global/init/setinfo.cfm +++ b/models/services/global/init/setinfo.cfm @@ -19,7 +19,7 @@ info.validCategoryModelsList = "itemcategory,propertycategory"; // lowercase info.serverIp = ""; - info.adminUrlPath = getSiteSetting("wheelsAdminUrlPath","/manager"); + info.adminUrlPath = getSiteSetting("WHEELIE_ADMINURLPATH","/manager"); info.domainshort = cgi.HTTP_HOST; siteUrl = info.domainshort; info.domain = "http://#info.domainshort#"; diff --git a/models/services/global/settings.cfm b/models/services/global/settings.cfm index 4a4273f..b392489 100644 --- a/models/services/global/settings.cfm +++ b/models/services/global/settings.cfm @@ -2,19 +2,15 @@ include template="/models/services/global/app/systemvars.cfm"; application.runtimeconfig = setRuntimeSettings(); - // Initialize system settings - sitecfg = application.runtimeconfig; - - application.wheels.reloadPassword = getSiteSetting("wheelsReloadPassword","wheelie"); - application.wheels.dataSourceName = getSiteSetting("wheelsdataSourceName","wheelie"); + application.wheels.reloadPassword = getSiteSetting("WHEELIE_APPRELOADPASS","wheelie"); + application.wheels.dataSourceName = getSiteSetting("WHEELIE_DATASOURCE","wheelie"); application.wheels.youtubeDevKey = getSiteSetting("youtubeDevKey"); application.wheels.stripeKey = getSiteSetting("stripeKey"); - application.wheels.passwordSalt = getSiteSetting("passwordSalt","OkIeKNKoIvbZMFPuMJ3EMQ=="); + application.wheels.passwordSalt = getSiteSetting("WHEELIE_PASSWORDSALT","OkIeKNKoIvbZMFPuMJ3EMQ=="); /* AES HEX Key // passcrypt(type="generateKey"); */ - include template="/views/setup/check.cfm"; - + sitecfg = application.runtimeconfig; if(sitecfg.containsKey("s3enabled") && sitecfg.s3enabled) { application.s3 = { @@ -28,13 +24,13 @@ }; } - application.wheels.defaultEmail = getSiteSetting("defaultEmail"); - application.wheels.noReplyEmail = getSiteSetting("noReplyEmail"); - application.wheels.adminEmail = application.wheels.defaultEmail; - application.wheels.errorEmailAddress = application.wheels.defaultEmail; - application.wheels.adminFromEmail = application.wheels.noReplyEmail; + application.wheels.defaultEmail = getSiteSetting("WHEELIE_DEFAULTEMAIL"); + application.wheels.noReplyEmail = getSiteSetting("WHEELIE_NOREPLYEMAIL"); + application.wheels.adminEmail = getSiteSetting("WHEELIE_ADMINEMAIL"); + application.wheels.errorEmailAddress = getSiteSetting("WHEELIE_ERROREMAILADDRESS"); + application.wheels.adminFromEmail = getSiteSetting("WHEELIE_ADMINFROMEMAIL"); - application.wheels.sendEmailOnError = getSiteSetting("wheelsSendEmailOnError",true); - application.wheels.urlRewriting = getSiteSetting("wheelsUrlRewriting","on"); - application.wheels.rewriteFile = getSiteSetting("wheelsRewriteFile","index.cfm"); + application.wheels.sendEmailOnError = getSiteSetting("WHEELIE_EMAILONERROR",true); + application.wheels.urlRewriting = getSiteSetting("WHEELIE_URLREWRITING","on"); + application.wheels.rewriteFile = getSiteSetting("WHEELIE_REWRITEFILE","index.cfm"); diff --git a/modules/admin/views/_partials/_publicheadtags.cfm b/modules/admin/views/_partials/_publicheadtags.cfm index 0afafb4..f4f2389 100644 --- a/modules/admin/views/_partials/_publicheadtags.cfm +++ b/modules/admin/views/_partials/_publicheadtags.cfm @@ -4,6 +4,7 @@ + diff --git a/modules/public/controllers/PublicPages.cfc b/modules/public/controllers/PublicPages.cfc index ca0788b..7814581 100755 --- a/modules/public/controllers/PublicPages.cfc +++ b/modules/public/controllers/PublicPages.cfc @@ -9,7 +9,7 @@ component extends="_main" output="false" function setCache() { - caches(actions="page,geolanding,index", time=300); + //caches(actions="page,geolanding,index", time=300); } function shared() { diff --git a/urlrewrite.xml b/urlrewrite.xml index 5451824..19bdab5 100755 --- a/urlrewrite.xml +++ b/urlrewrite.xml @@ -4,12 +4,14 @@ "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd"> - - If the request is for Lucee admin, don't process any further rules - ^/lucee/admin/server(.*) - /index.cfm - 404 - + CFWheels pretty URLs ^/(flex2gateway|jrunscripts|models/services/vendor|cfide|cfformgateway|cffileservlet|lucee|files|images|javascripts|miscellaneous|stylesheets|assets|views|robots.txt|favicon.ico|sitemap.xml|rewrite.cfm|index.cfm) diff --git a/views/themes/light-theme/layout.cfm b/views/themes/light-theme/layout.cfm index 832dca1..f492ba9 100644 --- a/views/themes/light-theme/layout.cfm +++ b/views/themes/light-theme/layout.cfm @@ -46,6 +46,9 @@ + + +