Skip to content

Commit

Permalink
Merge pull request #126 from simonbingham/develop
Browse files Browse the repository at this point in the history
Code formatting amendments
  • Loading branch information
Simon Bingham committed Jan 7, 2014
2 parents 2f25de5 + f56d42e commit 3bddadb
Show file tree
Hide file tree
Showing 107 changed files with 3,101 additions and 3,097 deletions.
155 changes: 78 additions & 77 deletions Application.cfc
Expand Up @@ -2,23 +2,23 @@ component extends="frameworks.org.corfield.framework"{

// ------------------------ APPLICATION SETTINGS ------------------------ //

this.applicationroot = getDirectoryFromPath( getCurrentTemplatePath() );
this.name = ListLast( this.applicationroot, "\/" ) & "_" & Hash( this.applicationroot );
this.applicationroot = getDirectoryFromPath(getCurrentTemplatePath());
this.name = ListLast(this.applicationroot, "\/") & "_" & Hash(this.applicationroot);
this.sessionmanagement = true;
// note: IsLocalHost on CF returns YES|NO which can't be passed to hibernate
this.development = IsLocalHost( CGI.REMOTE_ADDR ) ? true : false;
this.development = IsLocalHost(CGI.REMOTE_ADDR) ? true : false;
// prevent bots creating lots of sessions
if ( structKeyExists( cookie, "CFTOKEN" ) ) this.sessiontimeout = createTimeSpan( 0, 0, 20, 0 );
else this.sessiontimeout = createTimeSpan( 0, 0, 0, 1 );
this.mappings[ "/hoth" ] = this.applicationroot & "frameworks/hoth/";
this.mappings[ "/model" ] = this.applicationroot & "model/";
this.mappings[ "/ValidateThis" ] = this.applicationroot & "frameworks/ValidateThis/";
this.datasource = ListLast( this.applicationroot, "\/" );
if (structKeyExists(cookie, "CFTOKEN")) this.sessiontimeout = createTimeSpan(0, 0, 20, 0);
else this.sessiontimeout = createTimeSpan(0, 0, 0, 1);
this.mappings["/hoth"] = this.applicationroot & "frameworks/hoth/";
this.mappings["/model"] = this.applicationroot & "model/";
this.mappings["/ValidateThis"] = this.applicationroot & "frameworks/ValidateThis/";
this.datasource = ListLast(this.applicationroot, "\/");
this.ormenabled = true;
this.ormsettings = {
flushatrequestend = false
, automanagesession = false
, cfclocation = this.mappings[ "/model" ]
, cfclocation = this.mappings["/model"]
, eventhandling = true
, eventhandler = "model.aop.GlobalEventHandler"
, logsql = this.development
Expand All @@ -29,7 +29,7 @@ component extends="frameworks.org.corfield.framework"{

// create database and populate when the application starts in development environment
// you might want to comment out this code after the initial install
if( this.development && !isNull( url.rebuild ) ){
if(this.development && !isNull(url.rebuild)){
this.ormsettings.dbcreate = "dropcreate";
this.ormsettings.sqlscript = "_install/setup.sql";
}
Expand All @@ -47,8 +47,8 @@ component extends="frameworks.org.corfield.framework"{
, SESOmitIndex = false /* set this to true if you have url rewrite enabled */
, subsystemDelimiter = ":" // see note below
, routes = [
{ "news"="news", hint="Redirect to news feature" }
, { "enquiry"="enquiry", hint="Redirect to enquiry feature" }
{"news"="news", hint="Redirect to news feature"}
, {"enquiry"="enquiry", hint="Redirect to enquiry feature"}
]
};

Expand All @@ -62,81 +62,81 @@ component extends="frameworks.org.corfield.framework"{
void function setupApplication(){
// add exception tracker to application scope
var HothConfig = new hoth.config.HothConfig();
HothConfig.setApplicationName( getConfiguration().name );
HothConfig.setLogPath( this.applicationroot & "logs/hoth" );
HothConfig.setLogPathIsRelative( false );
HothConfig.setEmailNewExceptions( getConfiguration().exceptiontracker.emailnewexceptions );
HothConfig.setEmailNewExceptionsTo( getConfiguration().exceptiontracker.emailnewexceptionsto );
HothConfig.setEmailNewExceptionsFrom( getConfiguration().exceptiontracker.emailnewexceptionsfrom );
HothConfig.setEmailExceptionsAsHTML( getConfiguration().exceptiontracker.emailexceptionsashtml );
application.exceptiontracker = new Hoth.HothTracker( HothConfig );
HothConfig.setApplicationName(getConfiguration().name);
HothConfig.setLogPath(this.applicationroot & "logs/hoth");
HothConfig.setLogPathIsRelative(false);
HothConfig.setEmailNewExceptions(getConfiguration().exceptiontracker.emailnewexceptions);
HothConfig.setEmailNewExceptionsTo(getConfiguration().exceptiontracker.emailnewexceptionsto);
HothConfig.setEmailNewExceptionsFrom(getConfiguration().exceptiontracker.emailnewexceptionsfrom);
HothConfig.setEmailExceptionsAsHTML(getConfiguration().exceptiontracker.emailexceptionsashtml);
application.exceptiontracker = new Hoth.HothTracker(HothConfig);

// setup bean factory
var beanfactory = new frameworks.org.corfield.ioc( "/model", { singletonPattern = "(Service|Gateway)$" } );
setBeanFactory( beanfactory );
var beanfactory = new frameworks.org.corfield.ioc("/model", {singletonPattern = "(Service|Gateway)$"});
setBeanFactory(beanfactory);

// add validator bean to factory
var validatorconfig = { definitionPath="/model/", JSIncludes=false, resultPath="model.utility.ValidatorResult" };
beanFactory.addBean( "Validator", new ValidateThis.ValidateThis( validatorconfig ) );
var validatorconfig = {definitionPath="/model/", JSIncludes=false, resultPath="model.utility.ValidatorResult"};
beanFactory.addBean("Validator", new ValidateThis.ValidateThis(validatorconfig));

// add meta data bean to factory
beanFactory.addBean( "MetaData", new model.content.MetaData() );
beanFactory.addBean("MetaData", new model.content.MetaData());

// add config bean to factory
beanFactory.addBean( "config", getConfiguration() );
beanFactory.addBean("config", getConfiguration());
}

// ------------------------ CALLED WHEN PAGE REQUEST STARTS ------------------------ //

void function setupRequest(){
if( this.development && !isNull( url.rebuild ) ) ORMReload();
if(this.development && !isNull(url.rebuild)) ORMReload();

if( this.development ) writedump( var="*** Request Start - #TimeFormat( Now(), 'full' )# ***", output="console" );
if(this.development) writedump(var="*** Request Start - #TimeFormat(Now(), 'full')# ***", output="console");

// define base url
if( CGI.HTTPS eq "on" ) rc.basehref = "https://";
if(CGI.HTTPS eq "on") rc.basehref = "https://";
else rc.basehref = "http://";
rc.basehref &= CGI.HTTP_HOST & variables.framework.base;

// define default meta data
rc.MetaData = getBeanFactory().getBean( "MetaData" );
// define default meta data
rc.MetaData = getBeanFactory().getBean("MetaData");

// store config in request context
rc.config = getBeanFactory().getBean( "Config" );
rc.config = getBeanFactory().getBean("Config");
}

// ------------------------ CALLED WHEN VIEW RENDERING STARTS ------------------------ //

void function setupView(){
// get data need to build the navigation
if ( getSubsystem() == "public" ) rc.navigation = getBeanFactory().getBean( "ContentService" ).getNavigation();
// get data needed to build the navigation
if (getSubsystem() == "public") rc.navigation = getBeanFactory().getBean("ContentService").getNavigation();
}

// ------------------------ CALLED WHEN EXCEPTION OCCURS ------------------------ //

void function onError( Exception, event ){
if( StructKeyExists( application, "exceptiontracker" ) ) application.exceptiontracker.track( arguments.Exception );
super.onError( arguments.Exception, arguments.event );
void function onError(Exception, event){
if(StructKeyExists(application, "exceptiontracker")) application.exceptiontracker.track(arguments.Exception);
super.onError(arguments.Exception, arguments.event);
}

// ------------------------ CALLED WHEN VIEW IS MISSING ------------------------ //

any function onMissingView( required rc ){
any function onMissingView(required rc){
// Note: IIS and Apache report the CGI.PATH_INFO differently
var slug = LCase( ReReplace( Replace( CGI.PATH_INFO, CGI.SCRIPT_NAME, "" ), "^/", "", "one" ) );
if ( slug == "" ) slug = rc.config.page.defaultslug; // set default
rc.Page = getBeanFactory().getBean( "ContentService" ).getPageBySlug( slug );
if( !rc.Page.isPersisted() ){
var slug = LCase(ReReplace(Replace(CGI.PATH_INFO, CGI.SCRIPT_NAME, ""), "^/", "", "one"));
if (slug == "") slug = rc.config.page.defaultslug; // set default
rc.Page = getBeanFactory().getBean("ContentService").getPageBySlug(slug);
if(!rc.Page.isPersisted()){
var pagecontext = getPageContext().getResponse();
pagecontext.setStatus( 404 );
rc.MetaData.setMetaTitle( "Page Not Found" );
return view( "public#variables.framework.subsystemDelimiter#main/notfound" );
pagecontext.setStatus(404);
rc.MetaData.setMetaTitle("Page Not Found");
return view("public#variables.framework.subsystemDelimiter#main/notfound");
}else{
rc.breadcrumbs = getBeanFactory().getBean( "ContentService" ).getNavigationPath( rc.Page.getPageID() );
rc.MetaData.setMetaTitle( rc.Page.getMetaTitle() );
rc.MetaData.setMetaDescription( rc.Page.getMetaDescription() );
rc.MetaData.setMetaKeywords( rc.Page.getMetaKeywords() );
return view( "public#variables.framework.subsystemDelimiter#main/missingview" );
rc.breadcrumbs = getBeanFactory().getBean("ContentService").getNavigationPath(rc.Page.getPageID());
rc.MetaData.setMetaTitle(rc.Page.getMetaTitle());
rc.MetaData.setMetaDescription(rc.Page.getMetaDescription());
rc.MetaData.setMetaKeywords(rc.Page.getMetaKeywords());
return view("public#variables.framework.subsystemDelimiter#main/missingview");
}
}

Expand Down Expand Up @@ -174,16 +174,16 @@ component extends="frameworks.org.corfield.framework"{
, suppressdeletepage = "1" // comma delimited list of page ids for pages that cannot be deleted
, defaultslug = "home" // default 'slug' to use to get homepage
}
, revision = Hash( Now() )
, revision = Hash(Now())
, security = {
resetpasswordemailfrom = ""
, resetpasswordemailsubject = ""
, whitelist = "^admin#variables.framework.subsystemDelimiter#security,^public#variables.framework.subsystemDelimiter#" // list of unsecure actions - by default all requests require authentication
}
, version = "2014.1.4"
, version = "2014.1.7"
};
// override config in development mode
if( config.development ){
if(config.development){
config.enquiry.emailto = "";
config.exceptiontracker.emailnewexceptions = false;
config.security.resetpasswordemailfrom = "";
Expand All @@ -196,61 +196,62 @@ component extends="frameworks.org.corfield.framework"{
/**
* I override the FW/1 buildURL method to clean up the homepage URLs *
**/
public string function buildURL( string action = '.', string path = variables.magicBaseURL, any queryString = '' ) {
var theurl = super.buildURL( arguments.action, arguments.path, arguments.queryString );
theurl = ReReplace( theurl, "index\.cfm/#getBeanFactory().getBean( "Config" ).page.defaultslug#$", "" );
public string function buildURL(string action = '.', string path = variables.magicBaseURL, any queryString = '') {
var theurl = super.buildURL(arguments.action, arguments.path, arguments.queryString);
theurl = ReReplace(theurl, "index\.cfm/#getBeanFactory().getBean("Config").page.defaultslug#$", "");
return theurl;
}

// ------------------------ VIEW HELPERS ------------------------ //

string function snippet( content, charactercount=100 ){
var result = Trim( reReplace( arguments.content, "<[^>]{1,}>", " ", "all" ) );
if ( Len( result ) > arguments.charactercount + 10 ) return "<p>" & Trim( Left( result, arguments.charactercount ) ) & "&hellip;</p>";
string function snippet(content, charactercount=100){
var result = Trim(reReplace(arguments.content, "<[^>]{1,}>", " ", "all"));
if (Len(result) > arguments.charactercount + 10) return "<p>" & Trim(Left(result, arguments.charactercount)) & "&hellip;</p>";
else return result;
}

string function getTimeInterval( date, datemask="dddd dd mmmm yyyy" ){
string function getTimeInterval(date, datemask="dddd dd mmmm yyyy"){
var timeinseconds = 0;
var result = "";
var interval = "";
if( IsDate( arguments.date ) ){
timeinseconds = DateDiff( 's', arguments.date, Now() );
if(IsDate(arguments.date)){
timeinseconds = DateDiff('s', arguments.date, Now());
// less than a minute
if( timeinseconds < 60 ){
if(timeinseconds < 60){
result = " less than a minute ago";
}
// less than an hour
else if ( timeinseconds < 3600 ){
interval = Int( timeinseconds / 60 );
else if (timeinseconds < 3600){
interval = Int(timeinseconds / 60);
// more than 1 minute
if ( interval > 1 ) result = interval & " minutes ago";
if (interval > 1) result = interval & " minutes ago";
else result = interval & " minute ago";
}
// less than 24 hours
else if ( timeinseconds < ( 86400 ) && Hour( Now() ) >= Hour( arguments.date ) ){
interval = Int( timeinseconds / 3600 );
else if (timeinseconds < (86400) && Hour(Now()) >= Hour(arguments.date)){
interval = Int(timeinseconds / 3600);
// more than 1 hour
if ( interval > 1 ) result = interval & " hours ago";
if (interval > 1) result = interval & " hours ago";
else result = interval & " hour ago";
}
// less than 48 hours
else if ( timeinseconds < 172800 ){
result = "yesterday" & " at " & TimeFormat( arguments.date, "HH:MM" );
else if (timeinseconds < 172800){
result = "yesterday" & " at " & TimeFormat(arguments.date, "HH:MM");
}
// return the date
else{
result = DateFormat( arguments.date, arguments.datemask ) & " at " & TimeFormat( arguments.date, "HH:MM" );
result = DateFormat(arguments.date, arguments.datemask) & " at " & TimeFormat(arguments.date, "HH:MM");
}
}
return result;
}

boolean function isRoute( required slug ){
for ( var el in getRoutes() ){
if ( StructKeyExists( el, arguments.slug ) ) return true;
boolean function isRoute(required slug){
for (var el in getRoutes()){
if (StructKeyExists(el, arguments.slug)) return true;
}
return false;
}

}
}

12 changes: 4 additions & 8 deletions README.md
Expand Up @@ -32,8 +32,6 @@ Xindi uses the frameworks listed below.
* Adobe ColdFusion 9.0.1 or Railo 3.3
* MySQL 5 or MSSQL

Versions of Xindi with version numbers beginning with '2013' are tested solely on Railo 4 and MySQL 5.

## Quick Start

Clone the git repo - `git clone git@github.com:simonbingham/xindi.git` - or [download it] (https://github.com/simonbingham/xindi/zipball/master).
Expand All @@ -56,12 +54,10 @@ Xindi is authored by [Simon Bingham] (https://twitter.com/#!/simonbingham) with

If you experience any problems with Xindi please:

* [visit our Google Group for help and advice] (https://groups.google.com/forum/?hl=en&fromgroups#!forum/getxindi)
* [submit a ticket to our issue tracker] (https://github.com/simonbingham/xindi/issues)
* fix the error yourself and send us a pull request
* [visit the Google Group for help and advice] (https://groups.google.com/forum/?hl=en&fromgroups#!forum/getxindi)
* [submit a ticket to the issue tracker] (https://github.com/simonbingham/xindi/issues)
* fix the error yourself and submit a pull request

## Social Media

You'll find us on [Twitter] (https://twitter.com/#!/getxindi), [Facebook] (http://www.facebook.com/getxindi) and [Google+] (https://plus.google.com/112798469896267857099).

Finally, you can find a collection of [blog posts about Xindi on Simon Bingham's website] (http://www.simonbingham.me.uk/index.cfm/main/default/uuid/xindi-19).
You'll find Xindi on [Twitter] (https://twitter.com/#!/getxindi), [Facebook] (http://www.facebook.com/getxindi) and [Google+] (https://plus.google.com/112798469896267857099).
Binary file added _clientfiles/consulting/placeholder.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _clientfiles/design/placeholder.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _clientfiles/home/placeholder.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed _clientfiles/home/xindi-logo.gif
Binary file not shown.
Binary file added _clientfiles/news/placeholder-1.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _clientfiles/news/placeholder-2.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _clientfiles/news/placeholder-3.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _clientfiles/sample-page-1/placeholder.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _clientfiles/sample-page-2/placeholder.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _clientfiles/sample-page-3/placeholder.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _clientfiles/training/placeholder.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3bddadb

Please sign in to comment.