Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…depot/cbox-amazon-s3/trunk@2821 aa9c7f36-201a-0410-b936-d08bb24d9cb0
  • Loading branch information
lmajano committed Dec 2, 2009
1 parent 422d3e3 commit 75ddcbb
Show file tree
Hide file tree
Showing 44 changed files with 2,351 additions and 0 deletions.
67 changes: 67 additions & 0 deletions Application.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!-----------------------------------------------------------------------
********************************************************************************
Copyright 2005-2007 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
www.coldboxframework.com | www.luismajano.com | www.ortussolutions.com
********************************************************************************
Author : Luis Majano
Date : 10/16/2007
Description :
This is the Application.cfc for usage withing the ColdBox Framework.
Make sure that it extends the coldbox object:
coldbox.system.Coldbox
So if you have refactored your framework, make sure it extends coldbox.
----------------------------------------------------------------------->
<cfcomponent extends="coldbox.system.Coldbox" output="false">
<cfsetting enablecfoutputonly="yes">
<!--- APPLICATION CFC PROPERTIES --->
<cfset this.name = hash(getCurrentTemplatePath())>
<cfset this.sessionManagement = true>
<cfset this.sessionTimeout = createTimeSpan(0,0,30,0)>
<cfset this.setClientCookies = true>

<!--- COLDBOX STATIC PROPERTY, DO NOT CHANGE UNLESS THIS IS NOT THE ROOT OF YOUR COLDBOX APP --->
<cfset COLDBOX_APP_ROOT_PATH = getDirectoryFromPath(getCurrentTemplatePath())>

<!--- COLDBOX PROPERTIES --->
<cfset COLDBOX_CONFIG_FILE = "">

<!--- COLDBOX APPLICATION KEY OVERRIDE --->
<cfset COLDBOX_APP_KEY = "">

<!--- on Application Start --->
<cffunction name="onApplicationStart" returnType="boolean" output="false">
<cfscript>
//Load ColdBox
loadColdBox();
return true;
</cfscript>
</cffunction>

<!--- on Request Start --->
<cffunction name="onRequestStart" returnType="boolean" output="true">
<!--- ************************************************************* --->
<cfargument name="targetPage" type="string" required="true" />
<!--- ************************************************************* --->
<!--- Reload Checks --->
<cfset reloadChecks()>

<!--- Process A ColdBox Request Only --->
<cfif findNoCase('index.cfm', listLast(arguments.targetPage, '/'))>
<cfset processColdBoxRequest()>
</cfif>

<!--- WHATEVER YOU WANT BELOW --->
<cfreturn true>
</cffunction>

<!--- on Application End --->
<cffunction name="onApplicationEnd" returnType="void" output="false">
<!--- ************************************************************* --->
<cfargument name="applicationScope" type="struct" required="true">
<!--- ************************************************************* --->
<!--- WHATEVER YOU WANT BELOW --->
</cffunction>

</cfcomponent>
Binary file added amazon-s3-200911120900.zip
Binary file not shown.
20 changes: 20 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<project name="amazon-s3-build" basedir="." default="do.archive">
<!-- dynamic values for build -->
<tstamp prefix="start"/>
<property name="project.name" value="amazon-s3" />
<property name="build.label" value="${project.name}-${start.DSTAMP}${start.TSTAMP}"/>

<target name="cleanALL">
<delete>
<fileset dir="." includes="${project.name}-*.zip"/>
</delete>
</target>

<target name="do.archive" depends="cleanALL">
<zip destfile="${build.label}.zip">
<fileset dir="." excludes="build.xml" />
</zip>
</target>

</project>
4 changes: 4 additions & 0 deletions config/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#apache access file to protect the config.xml.cfm file. Delete this if you do not use apache.
authtype Basic
deny from all
Options -Indexes
9 changes: 9 additions & 0 deletions config/Application.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-----------------------------------------------------------------------
Template : Application.cfm
Author : Luis Majano
Date : January 22, 2006
Description :
This is a protection Application cfm for the config file. You do not
need to modify this file
----------------------------------------------------------------------->
<cfabort>
27 changes: 27 additions & 0 deletions config/ModelMappings.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-----------------------------------------------------------------------
********************************************************************************
Copyright 2005-2008 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
www.coldboxframework.com | www.luismajano.com | www.ortussolutions.com
********************************************************************************
Author : Luis Majano
Date : 10/16/2007
Description :
This file is used by the BeanFactory plugin to read off model mappings.
This is a great place to alias model paths into names so when you
refactor you can easily do this.
All you need to do is call one method: addModelMapping(alias,path)
Alias : The alias to create
Path : The model class path to alias.
Example:
addModelMapping('FormBean',"security.test.FormBean");
----------------------------------------------------------------------->
<cfscript>
/* Add all the model mappings you want */
/* addModelMapping(alias="",path="") */
</cfscript>
17 changes: 17 additions & 0 deletions config/Routes.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<cfscript>
// General Properties
setUniqueURLS(false);
setAutoReload(true);
// Base URL
if( len(getSetting('AppMapping') ) lte 1){
setBaseURL("http://#cgi.HTTP_HOST#/index.cfm");
}
else{
setBaseURL("http://#cgi.HTTP_HOST#/#getSetting('AppMapping')#/index.cfm");
}
// Your Application Routes
addRoute(pattern="/bucket/:bucketname",handler="explorer",action="viewBucket");
addRoute(pattern=":handler/:action?");
</cfscript>
67 changes: 67 additions & 0 deletions config/coldbox.xml.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
For all possible configuration options please refer to the documentation:
http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbConfigGuide
-->
<Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.coldbox.org/schema/config_3.0.0.xsd">
<Settings>
<!-- Application Setup-->
<Setting name="AppName" value="S3 Explorer"/>
<!-- If you are using a coldbox app to power flex/remote apps, you NEED to set the AppMapping also. In Summary,
the AppMapping is either a CF mapping or the path from the webroot to this application root. If this setting
is not set, then coldbox will try to auto-calculate it for you. Please read the docs.
<Setting name="AppMapping" value="/MyApp"/> -->

<!-- Development Settings -->
<Setting name="DebugMode" value="true"/>
<Setting name="DebugPassword" value=""/>
<Setting name="ReinitPassword" value=""/>
<Setting name="HandlersIndexAutoReload" value="true"/>
<Setting name="HandlerCaching" value="false"/>
<Setting name="EventCaching" value="false"/>

<!-- Implicit Events -->
<Setting name="DefaultEvent" value="Explorer.index"/>
<Setting name="RequestStartHandler" value=""/>
<Setting name="RequestEndHandler" value=""/>
<Setting name="ApplicationStartHandler" value=""/>
<Setting name="SessionStartHandler" value=""/>
<Setting name="SessionEndHandler" value=""/>
<Setting name="MissingTemplateHandler" value=""/>

<!-- Error/Exception Handling -->
<Setting name="ExceptionHandler" value=""/>
<Setting name="onInvalidEvent" value=""/>
<Setting name="CustomErrorTemplate" value="" />
</Settings>

<YourSettings>
<!-- YOUR AMAZON CREDENTIALS -->
<Setting name="s3_accessKey" value="" />
<Setting name="s3_secretKey" value="" />
<Setting name="s3_ssl" value="false" />
</YourSettings>

<!--
ColdBox Logging via LogBox
Levels: -1=OFF,0=FATAL,1=ERROR,2=WARN,3=INFO,4=DEBUG
-->
<LogBox>
<Appender name="coldboxTracer" class="coldbox.system.logging.appenders.ColdboxTracerAppender" />
<Root levelMin="FATAL" levelMax="DEBUG" appenders="*" />
<Category name="coldbox.system" levelMax="INFO" />
</LogBox>

<Layouts>
<DefaultLayout>Layout.Main.cfm</DefaultLayout>
</Layouts>

<Interceptors>
<!-- USE AUTOWIRING -->
<Interceptor class="coldbox.system.interceptors.Autowire" />
<!-- USE SES -->
<Interceptor class="coldbox.system.interceptors.SES" />
</Interceptors>

</Config>
62 changes: 62 additions & 0 deletions handlers/Explorer.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<cfcomponent extends="coldbox.system.EventHandler" output="false"> <cfproperty name="s3" type="coldbox:myplugin:AmazonS3" /> <cfset this.preHandler_except = "authenticate" /> <cffunction name="preHandler" output="false"> <cfargument name="event" required="true"> <cfscript> if(NOT len(getSetting("s3_accessKey")) OR NOT len(getSetting("s3_secretKey")) ){ event.overrideEvent('explorer.authenticate'); } </cfscript> </cffunction> <!--- authenticate --->
<cffunction name="authenticate" access="public" returntype="void" output="false" hint="">
<cfargument name="Event" type="any" required="yes">
<cfscript> var rc = event.getCollection(); if( event.valueExists('authButton') ){ // Save credentials setSetting("s3_accessKey",rc.accessKey); setSetting("s3_secretKey",rc.secretKey); // relocate setNextEvent('explorer'); }
event.setView("explorer/authenticate");
</cfscript>
</cffunction> <!--- Default Action ---> <cffunction name="index" returntype="void" output="false" hint="My main event"> <cfargument name="event" required="true"> <cfscript> var rc = event.getCollection(); rc.allBuckets = s3.listBuckets(); </cfscript> </cffunction> <!--- createBucket --->
<cffunction name="createBucket" access="public" returntype="void" output="false" hint="">
<cfargument name="Event" type="any" required="yes">
<cfscript>
var rc = event.getCollection(); s3.putBucket(rc.bucketName,rc.acl,rc.storage); getPlugin("MessageBox").setMessage(type="info", message="bucket created"); setNextEvent('explorer');
</cfscript>
</cffunction> <!--- removeBucket --->
<cffunction name="removeBucket" access="public" returntype="void" output="false" hint="">
<cfargument name="Event" type="any" required="yes">
<cfscript> var rc = event.getCollection();
if( s3.deleteBucket(rc.bucketName) ){ getPlugin("MessageBox").setMessage(type="info", message="Bucket Removed!"); } else{ getPlugin("MessageBox").setMessage(type="error", message="S3 service could not remove bucket. Please refer to debugging information."); } setNextEvent("explorer");
</cfscript>
</cffunction> <!--- viewBucket --->
<cffunction name="viewBucket" access="public" returntype="void" output="false" hint="">
<cfargument name="Event" type="any" required="yes">
<cfscript>
var rc = event.getCollection(); rc.allObjects = s3.getBucket(bucketName=replace(rc.bucketName,"|","/","all")); rc.allBuckets = s3.listBuckets();
</cfscript>
</cffunction> <!--- genAuthenticatedURL --->
<cffunction name="genAuthenticatedURL" access="public" returntype="void" output="false" hint="">
<cfargument name="Event" type="any" required="yes">
<cfscript>
var rc = event.getCollection(); rc.timedLink = s3.getAuthenticatedURL(bucketName=rc.bucketname,uri=rc.key,virtualHostStyle=true); rc.data = "<h2>Time Expired Secured Link</h2> <textarea cols='40' rows='5'>#rc.timedLink#</textarea>"; event.renderData(data=rc.data);
</cfscript>
</cffunction> <!--- getObjectInfo ---> <cffunction name="getObjectInfo" access="public" returntype="void" output="false" hint=""> <cfargument name="Event" type="any" required="yes"> <cfscript> var rc = event.getCollection(); rc.info = s3.getObjectInfo(rc.bucketname,rc.objectKey); event.renderData(data=renderView("explorer/objectInfo")); </cfscript> </cffunction> <!--- uploadFile --->
<cffunction name="upload" access="public" returntype="void" output="false" hint="">
<cfargument name="Event" type="any" required="yes">
<cfscript>
var rc = event.getCollection(); var fileInfo = getPlugin("Utilities").uploadFile(fileField="fileobject", destination=getSetting("ApplicationPath") & "/tmp", mode="666", NameConflict="overwrite"); // Inflate json metadata if( NOT len(event.getTrimValue("extraMetadata")) ){ rc.extrametadata = "{}"; } rc.extrametadata = getPlugin("JSON").decode(rc.extrametadata); try{ rc.results = s3.putObjectFile(bucketName=rc.bucketName, filePath=fileInfo.serverDirectory & "/" & fileInfo.serverFile, contentType=fileInfo.contentType, cacheControl=event.getTrimValue("cc"), expires=event.getTrimValue("expires"), acl=rc.acl, metaHeaders=rc.extrametadata); getPlugin("MessageBox").setMessage(type="info", message="Uploaded file with etag: #rc.results#"); } catch(Any e){ getPlugin("MessageBox").setMessage(type="error", message="Error uploading file: #e.message# #e.detail#"); log.error("Error putting file to S3",e); } // remove file fileDelete(getSetting("ApplicationPath") & "/tmp/#fileInfo.serverFile#"); // relocate setNextEvent(event="bucket/#urlEncodedFormat(rc.bucketName)#");
</cfscript>
</cffunction> <!--- removeObject --->
<cffunction name="removeObject" access="public" returntype="void" output="false" hint="">
<cfargument name="Event" type="any" required="yes">
<cfscript>
var rc = event.getCollection(); if( s3.deleteObject(rc.bucketName,rc.uri) ){ getPlugin("MessageBox").setMessage(type="info", message="#rc.uri# Removed!"); } else{ getPlugin("MessageBox").setMessage(type="error", message="S3 service could not remove object. Please refer to debugging information."); } setNextEvent(event="bucket/#urlEncodedFormat(rc.bucketName)#");
</cfscript>
</cffunction> <!--- copyDialog --->
<cffunction name="copyDialog" access="public" returntype="void" output="false" hint="">
<cfargument name="Event" type="any" required="yes">
<cfscript>
var rc = event.getCollection(); rc.allBuckets = s3.listBuckets(); event.renderData(data=renderView("explorer/copyDialog"));
</cfscript>
</cffunction> <!--- copyObject ---> <cffunction name="copyObject" access="public" returntype="void" output="false" hint=""> <cfargument name="Event" type="any" required="yes"> <cfscript> var rc = event.getCollection(); // Inflate json metadata if( len(event.getTrimValue("extraMetadata")) ){ rc.extrametadata = "{}"; } rc.extrametadata = getPlugin("JSON").decode(rc.extrametadata); // Copy rc.results = s3.copyObject(fromBucket=rc.fromBucket, fromURI=rc.fromURI, toBucket=rc.toBucket, toURI=rc.toURI, acl=rc.acl, copymetaData=rc.copyMetadata, metaHeaders=rc.extrametadata); getPlugin("MessageBox").setMessage(type="info", message="Object copied successfully"); // relocate setNextEvent(event="bucket/#urlEncodedFormat(rc.fromBucket)#"); </cfscript> </cffunction> <!--- objectACL --->
<cffunction name="objectACL" access="public" returntype="void" output="false" hint="">
<cfargument name="Event" type="any" required="yes">
<cfscript>
var rc = event.getCollection(); rc.grants = s3.getAcessControlPolicy(rc.objectName); event.renderData(data=renderView('explorer/objectACL'));
</cfscript>
</cffunction> <!--- docs --->
<cffunction name="docs" access="public" returntype="void" output="false" hint="">
<cfargument name="Event" type="any" required="yes">
<cfscript>
var rc = event.getCollection(); rc.viewer = getPlugin("CFCViewer").setup(dirpath="/#getSetting('appMapping')#/plugins", dirLink=event.buildLink('explorer.docs'), linkBaseURL=getSetting('sesBaseURL')); event.setView('explorer/docs');
</cfscript>
</cffunction><!------------------------------------------- PRIVATE EVENTS ------------------------------------------>
</cfcomponent>
Expand Down
43 changes: 43 additions & 0 deletions includes/css/sort.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* tables */
.tablesorter {
background-color: #CDCDCD;
margin:10px 0pt 15px;
font-size: 8pt;
width: 100%;
text-align: left;
}
.tablesorter thead tr th, .tablesorter tfoot tr th {
background-color: #E0EFEF;
border: 1px solid #FFF;
font-size: 8pt;
padding: 4px;
}
.tablesorter thead tr .header {
background-image: url(../images/bg.gif);
background-repeat: no-repeat;
background-position: center right;
cursor: pointer;
}
.tablesorter thead tr .headerSortUp {
background-image: url(../images/asc.gif);
}
.tablesorter thead tr .headerSortDown {
background-image: url(../images/desc.gif);
}
.tablesorter thead tr .headerSortDown, .tablesorter thead tr .headerSortUp {
background-color: #8dbdd8;
}
.tablesorter tbody td {
color: #3D3D3D;
padding: 4px;
vertical-align: top;
}
.tablesorter tbody tr.even{
background-color:#F0F0F0;
}.tablesorter tbody tr{
background-color:#fff;
padding: 5px;
}
.tablesorter tbody tr:hover { background: #d7eafe; }
.tablesorter tbody tr.center { text-align: center; }
.tablesorter tbody td a{ text-decoration: none; border: none;}
Loading

0 comments on commit 75ddcbb

Please sign in to comment.