Skip to content

Commit cfd5133

Browse files
committed
first commit
0 parents  commit cfd5133

21 files changed

+3981
-0
lines changed

.classpath

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src/java"/>
4+
<classpathentry kind="src" path="src/groovy"/>
5+
<classpathentry excluding="spring/" kind="src" path="grails-app/conf"/>
6+
<classpathentry kind="src" path="grails-app/conf/spring"/>
7+
<classpathentry kind="src" path="grails-app/controllers"/>
8+
<classpathentry kind="src" path="grails-app/domain"/>
9+
<classpathentry kind="src" path="grails-app/i18n"/>
10+
<classpathentry kind="src" path="grails-app/services"/>
11+
<classpathentry kind="src" path="grails-app/taglib"/>
12+
<classpathentry kind="src" path="grails-app/utils"/>
13+
<classpathentry kind="src" path="grails-app/views"/>
14+
<classpathentry kind="src" path="test/integration"/>
15+
<classpathentry kind="src" path="test/unit"/>
16+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
17+
<classpathentry kind="con" path="org.grails.ide.eclipse.core.CLASSPATH_CONTAINER"/>
18+
<classpathentry kind="output" path="target/eclipseclasses"/>
19+
</classpath>

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
*.iws
2+
*Db.properties
3+
*Db.script
4+
.settings
5+
stacktrace.log
6+
/*.zip
7+
/plugin.xml
8+
/*.log
9+
/*DB.*
10+
/cobertura.ser
11+
.DS_Store
12+
/target/
13+
/out/
14+
/web-app/plugins
15+
/web-app/WEB-INF/classes
16+
/.link_to_grails_plugins/
17+
/target-eclipse/

.project

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>selfie</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.grails.ide.eclipse.core.nature</nature>
16+
<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
17+
<nature>org.eclipse.jdt.core.javanature</nature>
18+
</natures>
19+
</projectDescription>

README.markdown

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
Selfie
2+
======
3+
4+
Selfie is a Grails Image / File Upload Plugin. Use Selfie to attach files to your domain models, upload to a CDN, validate content, produce thumbnails.
5+
6+
* Domain Attachment
7+
* CDN Storage Providers (via Karman)
8+
* Image Resizing
9+
* Content Type Validation
10+
* GORM Bindings / Hibernate User Types Support
11+
12+
**NOTE: STILL IN EARLY DEVELOPMENT**
13+
14+
Usage
15+
-----
16+
17+
Currently this plugin is in the works. The plan is to leverage GORM's support for hibernate custom user types
18+
to make an elegant DSL for uploading and attaching files to your domains.
19+
20+
Example DSL:
21+
22+
```groovy
23+
class Book {
24+
25+
@AttachmentSizes([thumbnail: ‘50x50#’])
26+
Attachment photo
27+
28+
static mapping = {
29+
photo type: AttachmentUserType, {
30+
column name: “photo_file_name”
31+
column name: “photo_file_size”
32+
column name: "photo_content_type"
33+
}
34+
}
35+
36+
static constraints = {
37+
photo contentType: [‘png’,’jpg’]
38+
}
39+
}
40+
```
41+
42+
**Note:** This is an early DSL representation. The implementation is still in the works and not yet final.
43+
44+
45+
Things to be Done
46+
------------------
47+
48+
* Develop Hibernate 3 and Hibernate 4 User Types
49+
* Add Image Resize Logic via plugin
50+
* Provide Configuration DSL for the Karman Storage Provider
51+
* Support Secure Files
52+
* Create Bindings for seamless multipart upload
53+
* Add Custom Constraint Validators, such as contentType.
54+
* Provide Convenience taglibs
55+
* Support Attachment Size closure for dynamic sizes based on other properties
56+
* Provide method to rebuild thumbnails after sizes have changed
57+
* Stream Support (if possible)

SelfieGrailsPlugin.groovy

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
class SelfieGrailsPlugin {
2+
// the plugin version
3+
def version = "0.1.0"
4+
// the version or versions of Grails the plugin is designed for
5+
def grailsVersion = "2.3 > *"
6+
// resources that are excluded from plugin packaging
7+
def pluginExcludes = [
8+
"grails-app/views/error.gsp"
9+
]
10+
11+
def title = "Selfie Plugin"
12+
def author = "David Estes"
13+
def authorEmail = "[email protected]"
14+
def description = "Selfie is a Grails Image / File Upload Plugin. Use Selfie to attach files to your domain models, upload to a CDN, validate content, produce thumbnails."
15+
16+
// URL to the plugin's documentation
17+
def documentation = "https://github.com/bertramdev/selfie"
18+
def license = "APACHE"
19+
def organization = [name: "Bertram Labs", url: "http://www.bertramlabs.com/"]
20+
def issueManagement = [system: "GITHUB", url: "https://github.com/bertramdev/selfie/issues"]
21+
def scm = [url: "https://github.com/bertramdev/selfie"]
22+
23+
def doWithWebDescriptor = { xml ->
24+
// TODO Implement additions to web.xml (optional), this event occurs before
25+
}
26+
27+
def doWithSpring = {
28+
// TODO Implement runtime spring config (optional)
29+
}
30+
31+
def doWithDynamicMethods = { ctx ->
32+
// TODO Implement registering dynamic methods to classes (optional)
33+
}
34+
35+
def doWithApplicationContext = { ctx ->
36+
// TODO Implement post initialization spring config (optional)
37+
}
38+
39+
def onChange = { event ->
40+
// TODO Implement code that is executed when any artefact that this plugin is
41+
// watching is modified and reloaded. The event contains: event.source,
42+
// event.application, event.manager, event.ctx, and event.plugin.
43+
}
44+
45+
def onConfigChange = { event ->
46+
// TODO Implement code that is executed when the project configuration changes.
47+
// The event is the same as for 'onChange'.
48+
}
49+
50+
def onShutdown = { event ->
51+
// TODO Implement code that is executed when the application shuts down (optional)
52+
}
53+
}

application.properties

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Grails Metadata file
2+
#Mon Aug 25 10:13:28 EDT 2014
3+
app.grails.version=2.4.3
4+
app.name=selfie

grails-app/conf/BuildConfig.groovy

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
grails.project.class.dir = "target/classes"
2+
grails.project.test.class.dir = "target/test-classes"
3+
grails.project.test.reports.dir = "target/test-reports"
4+
5+
grails.project.fork = [
6+
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
7+
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
8+
9+
// configure settings for the test-app JVM, uses the daemon by default
10+
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
11+
// configure settings for the run-app JVM
12+
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
13+
// configure settings for the run-war JVM
14+
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
15+
// configure settings for the Console UI JVM
16+
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
17+
]
18+
19+
grails.project.dependency.resolver = "maven" // or ivy
20+
grails.project.dependency.resolution = {
21+
// inherit Grails' default dependencies
22+
inherits("global") {
23+
// uncomment to disable ehcache
24+
// excludes 'ehcache'
25+
}
26+
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
27+
repositories {
28+
grailsCentral()
29+
mavenLocal()
30+
mavenCentral()
31+
mavenRepo 'http://dl.bintray.com/karman/karman'
32+
// uncomment the below to enable remote dependency resolution
33+
// from public Maven repositories
34+
//mavenRepo "http://repository.codehaus.org"
35+
//mavenRepo "http://download.java.net/maven/2/"
36+
//mavenRepo "http://repository.jboss.com/maven2/"
37+
}
38+
dependencies {
39+
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
40+
// runtime 'mysql:mysql-connector-java:5.1.27'
41+
}
42+
43+
plugins {
44+
45+
46+
runtime ":karman:0.5.2"
47+
48+
if(System.getProperty('plugin.mode') != 'local') {
49+
runtime(':hibernate:3.6.10.16') {
50+
export = false
51+
}
52+
build(":release:3.0.1",
53+
":rest-client-builder:1.0.3") {
54+
export = false
55+
}
56+
}
57+
}
58+
}

grails-app/conf/Config.groovy

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// configuration for plugin testing - will not be included in the plugin zip
2+
3+
log4j = {
4+
// Example of changing the log pattern for the default console
5+
// appender:
6+
//
7+
//appenders {
8+
// console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
9+
//}
10+
11+
error 'org.codehaus.groovy.grails.web.servlet', // controllers
12+
'org.codehaus.groovy.grails.web.pages', // GSP
13+
'org.codehaus.groovy.grails.web.sitemesh', // layouts
14+
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
15+
'org.codehaus.groovy.grails.web.mapping', // URL mapping
16+
'org.codehaus.groovy.grails.commons', // core / classloading
17+
'org.codehaus.groovy.grails.plugins', // plugins
18+
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
19+
'org.springframework',
20+
'org.hibernate',
21+
'net.sf.ehcache.hibernate'
22+
}

grails-app/conf/DataSource.groovy

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
dataSource {
2+
pooled = true
3+
jmxExport = true
4+
driverClassName = "org.h2.Driver"
5+
username = "sa"
6+
password = ""
7+
}
8+
hibernate {
9+
cache.use_second_level_cache = true
10+
cache.use_query_cache = false
11+
// cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
12+
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
13+
singleSession = true // configure OSIV singleSession mode
14+
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
15+
}
16+
17+
// environment specific settings
18+
environments {
19+
development {
20+
dataSource {
21+
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
22+
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
23+
}
24+
}
25+
test {
26+
dataSource {
27+
dbCreate = "update"
28+
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
29+
}
30+
}
31+
production {
32+
dataSource {
33+
dbCreate = "update"
34+
url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
35+
properties {
36+
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
37+
jmxEnabled = true
38+
initialSize = 5
39+
maxActive = 50
40+
minIdle = 5
41+
maxIdle = 25
42+
maxWait = 10000
43+
maxAge = 10 * 60000
44+
timeBetweenEvictionRunsMillis = 5000
45+
minEvictableIdleTimeMillis = 60000
46+
validationQuery = "SELECT 1"
47+
validationQueryTimeout = 3
48+
validationInterval = 15000
49+
testOnBorrow = true
50+
testWhileIdle = true
51+
testOnReturn = false
52+
jdbcInterceptors = "ConnectionState"
53+
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
54+
}
55+
}
56+
}
57+
}

grails-app/conf/UrlMappings.groovy

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class UrlMappings {
2+
3+
static mappings = {
4+
"/$controller/$action?/$id?(.$format)?"{
5+
constraints {
6+
// apply constraints here
7+
}
8+
}
9+
10+
"/"(view:"/index")
11+
"500"(view:'/error')
12+
}
13+
}

grails-app/views/error.gsp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title><g:if env="development">Grails Runtime Exception</g:if><g:else>Error</g:else></title>
5+
<meta name="layout" content="main">
6+
<g:if env="development"><asset:stylesheet src="errors.css"/></g:if>
7+
</head>
8+
<body>
9+
<g:if env="development">
10+
<g:renderException exception="${exception}" />
11+
</g:if>
12+
<g:else>
13+
<ul class="errors">
14+
<li>An error has occurred</li>
15+
</ul>
16+
</g:else>
17+
</body>
18+
</html>

scripts/_Install.groovy

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// This script is executed by Grails after plugin was installed to project.
3+
// This script is a Gant script so you can use all special variables provided
4+
// by Gant (such as 'baseDir' which points on project base dir). You can
5+
// use 'ant' to access a global instance of AntBuilder
6+
//
7+
// For example you can create directory under project tree:
8+
//
9+
// ant.mkdir(dir:"${basedir}/grails-app/jobs")
10+
//

scripts/_Uninstall.groovy

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//
2+
// This script is executed by Grails when the plugin is uninstalled from project.
3+
// Use this script if you intend to do any additional clean-up on uninstall, but
4+
// beware of messing up SVN directories!
5+
//

scripts/_Upgrade.groovy

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// This script is executed by Grails during application upgrade ('grails upgrade'
3+
// command). This script is a Gant script so you can use all special variables
4+
// provided by Gant (such as 'baseDir' which points on project base dir). You can
5+
// use 'ant' to access a global instance of AntBuilder
6+
//
7+
// For example you can create directory under project tree:
8+
//
9+
// ant.mkdir(dir:"${basedir}/grails-app/jobs")
10+
//
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.bertramlabs.plugins.selfie
2+
3+
class Attachment {
4+
String fileName
5+
String contentType
6+
Long fileSize
7+
}

0 commit comments

Comments
 (0)