Permalink
Browse files

Sample application

  • Loading branch information...
1 parent ce9e972 commit b32761e439f373bf6a440199887b63fbab5b3b34 @lucastex lucastex committed Jul 24, 2009
View
@@ -1,7 +1,8 @@
#utf-8
-#Fri Jul 24 12:33:07 BRT 2009
+#Fri Jul 24 17:34:54 BRT 2009
app.grails.version=1.2-M1
app.name=grails-file-uploader-sample
app.servlet.version=2.4
app.version=0.1
+plugins.file-uploader=1.0
plugins.hibernate=1.2-M1
@@ -69,5 +69,15 @@ log4j = {
warn 'org.mortbay.log'
}
-
-
+fileuploader {
+ avatar {
+ maxSize = 1024 * 256 //256 kbytes
+ allowedExtensions = ["jpg","jpeg","gif","png"]
+ path = "/tmp/avatar/"
+ }
+ docs {
+ maxSize = 1000 * 1024 * 4 //4 mbytes
+ allowedExtensions = ["doc", "docx", "pdf", "rtf"]
+ path = "/tmp/docs/"
+ }
+}
@@ -0,0 +1,8 @@
+import com.lucastex.grails.fileuploader.UFile
+
+class AvatarController {
+
+ def index = {
+ [files: UFile.list()]
+ }
+}
@@ -0,0 +1,8 @@
+import com.lucastex.grails.fileuploader.UFile
+
+class DocsController {
+
+ def index = {
+ [files: UFile.list()]
+ }
+}
@@ -0,0 +1,55 @@
+<html>
+ <head>
+ <title>Grails File-Uploader Avatar Demo</title>
+ <meta name="layout" content="main" />
+ </head>
+ <body>
+ <h1 style="margin-left:20px;">Grails File-Uploader Plugin Avatar Demo</h1>
+ <p style="margin-left:20px;width:80%">
+ <fileuploader:form upload="avatar"
+ successAction="index"
+ successController="avatar"
+ errorAction="index"
+ errorController="avatar"/>
+ </p>
+ <br /><br />
+ <h3 style="margin-left:20px;">Uploaded files</h3>
+ <p style="margin-left:20px;width:80%">
+ <g:each var="f" in="${files}">
+ <table>
+ <tr>
+ <td><b>Name</b></td>
+ <td>${f.name}</td>
+ </tr>
+ <tr>
+ <td><b>Path</b></td>
+ <td>${f.path}</td>
+ </tr>
+ <tr>
+ <td><b>Size</b></td>
+ <td>${f.size}</td>
+ </tr>
+ <tr>
+ <td><b>Extension</b></td>
+ <td>${f.extension}</td>
+ </tr>
+ <tr>
+ <td><b>Downloaded</b></td>
+ <td>${f.downloads}</td>
+ </tr>
+ <tr>
+ <td><b>Date uploaded</b></td>
+ <td><g:formatDate format="MM/dd/yyyy HH:mm" date="${f.dateUploaded}" /></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ <fileuploader:download id="${f.id}"
+ errorAction="index"
+ errorController="avatar">Click here to download</fileuploader:download></td>
+ </tr>
+ </table>
+ </g:each>
+ </p>
+ </body>
+</html>
@@ -0,0 +1,55 @@
+<html>
+ <head>
+ <title>Grails File-Uploader Docs Demo</title>
+ <meta name="layout" content="main" />
+ </head>
+ <body>
+ <h1 style="margin-left:20px;">Grails File-Uploader Plugin Docs Demo</h1>
+ <p style="margin-left:20px;width:80%">
+ <fileuploader:form upload="docs"
+ successAction="index"
+ successController="docs"
+ errorAction="index"
+ errorController="docs"/>
+ </p>
+ <br /><br />
+ <h3 style="margin-left:20px;">Uploaded docs</h3>
+ <p style="margin-left:20px;width:80%">
+ <g:each var="f" in="${files}">
+ <table>
+ <tr>
+ <td><b>Name</b></td>
+ <td>${f.name}</td>
+ </tr>
+ <tr>
+ <td><b>Path</b></td>
+ <td>${f.path}</td>
+ </tr>
+ <tr>
+ <td><b>Size</b></td>
+ <td>${f.size}</td>
+ </tr>
+ <tr>
+ <td><b>Extension</b></td>
+ <td>${f.extension}</td>
+ </tr>
+ <tr>
+ <td><b>Downloaded</b></td>
+ <td>${f.downloads}</td>
+ </tr>
+ <tr>
+ <td><b>Date uploaded</b></td>
+ <td><g:formatDate format="MM/dd/yyyy HH:mm" date="${f.dateUploaded}" /></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ <fileuploader:download id="${f.id}"
+ errorAction="index"
+ errorController="docs">Click here to download</fileuploader:download></td>
+ </tr>
+ </table>
+ </g:each>
+ </p>
+ </body>
+</html>
View
@@ -1,20 +1,13 @@
<html>
<head>
- <title>Welcome to Grails</title>
+ <title>Grails File-Uploader Demo</title>
<meta name="layout" content="main" />
</head>
<body>
- <h1 style="margin-left:20px;">Welcome to Grails</h1>
- <p style="margin-left:20px;width:80%">Congratulations, you have successfully started your first Grails application! At the moment
- this is the default page, feel free to modify it to either redirect to a controller or display whatever
- content you may choose. Below is a list of controllers that are currently deployed in this application,
- click on each to execute its default action:</p>
- <div class="dialog" style="margin-left:20px;width:60%;">
- <ul>
- <g:each var="c" in="${grailsApplication.controllerClasses}">
- <li class="controller"><g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link></li>
- </g:each>
- </ul>
- </div>
+ <h1 style="margin-left:20px;">Grails File-Uploader Plugin Demo</h1>
+ <p style="margin-left:20px;width:80%">
+ <g:link controller="avatar" action="index">Avatar upload</g:link> <br />
+ <g:link controller="docs" action="index">Document upload</g:link>
+ </p>
</body>
</html>
@@ -11,6 +11,9 @@
<img src="${resource(dir:'images',file:'spinner.gif')}" alt="Spinner" />
</div>
<div class="logo"><img src="${resource(dir:'images',file:'grails_logo.jpg')}" alt="Grails" /></div>
- <g:layoutBody />
+ <g:if test="${flash.message}">
+ <div class="message">${flash.message}</div>
+ </g:if>
+ <g:layoutBody />
</body>
</html>
@@ -0,0 +1,15 @@
+import grails.test.*
+
+class AvatarControllerTests extends ControllerUnitTestCase {
+ protected void setUp() {
+ super.setUp()
+ }
+
+ protected void tearDown() {
+ super.tearDown()
+ }
+
+ void testSomething() {
+
+ }
+}
@@ -0,0 +1,15 @@
+import grails.test.*
+
+class DocsControllerTests extends ControllerUnitTestCase {
+ protected void setUp() {
+ super.setUp()
+ }
+
+ protected void tearDown() {
+ super.tearDown()
+ }
+
+ void testSomething() {
+
+ }
+}
Oops, something went wrong.

0 comments on commit b32761e

Please sign in to comment.