Permalink
Browse files

Posted beta version of the plugin

  • Loading branch information...
1 parent a4e50af commit 13664458dec3e6d6aebc85721f342b1f4713849b @sergeyy committed Feb 28, 2012
@@ -0,0 +1,89 @@
+class MongodbGridfsGrailsPlugin {
+
+ // the plugin version
+ def version = "0.4.beta"
+ // the version or versions of Grails the plugin is designed for
+ def grailsVersion = "2.0 > *"
+ // the other plugins this plugin depends on
+ def dependsOn = [
+ 'mongodb': "* > 1.0.0.RC3",
+ 'burning-image': "* > 0.5.0"
+ ]
+ // resources that are excluded from plugin packaging
+ def pluginExcludes = [
+ "grails-app/views/error.gsp"
+ ]
+
+ // TODO Fill in these fields
+ def title = "Mongodb Gridfs Plugin" // Headline display name of the plugin
+ def author = "Sergei Yunzhakov"
+ def authorEmail = "iglas.sys@@gmail.com"
+ def description = '''\
+ The plugin includes can:
+ -- listing files
+ -- upload files
+ -- download files
+ -- remove files
+ -- grouped files for a parents id
+ -- support multi configure for level a servletContext, a user session, a requests or params
+ -- support multi database
+ -- connect a control access
+ -- get of a user dir icon for a extension file
+ -- makes a thumbnails for images
+
+ Plugins in use:
+ -- mongodb
+ -- burning-image
+ '''
+
+ // URL to the plugin's documentation
+ def documentation = "https://github.com/sergeyy/Grails-plugin-mongodb-gridfs/wiki"
+
+ // Extra (optional) plugin metadata
+
+ // License: one of 'APACHE', 'GPL2', 'GPL3'
+ def license = "APACHE"
+
+ // Details of company behind the plugin (if there is one)
+// def organization = [ name: "My Company", url: "http://www.my-company.com/" ]
+
+ // Any additional developers beyond the author specified above.
+ def developers = [ [ name: "Sergei Yunzhakov", email: "iglas.sys@@gmail.com" ]]
+
+ // Location of the plugin's issue tracker.
+// def issueManagement = [ system: "JIRA", url: "http://jira.grails.org/browse/GPMYPLUGIN" ]
+
+ // Online location of the plugin's browseable source code.
+// def scm = [ url: "http://svn.grails-plugins.codehaus.org/browse/grails-plugins/" ]
+
+ def doWithWebDescriptor = { xml ->
+ // TODO Implement additions to web.xml (optional), this event occurs before
+ }
+
+ def doWithSpring = {
+ // TODO Implement runtime spring config (optional)
+ }
+
+ def doWithDynamicMethods = { ctx ->
+ // TODO Implement registering dynamic methods to classes (optional)
+ }
+
+ def doWithApplicationContext = { applicationContext ->
+ // TODO Implement post initialization spring config (optional)
+ }
+
+ def onChange = { event ->
+ // TODO Implement code that is executed when any artefact that this plugin is
+ // watching is modified and reloaded. The event contains: event.source,
+ // event.application, event.manager, event.ctx, and event.plugin.
+ }
+
+ def onConfigChange = { event ->
+ // TODO Implement code that is executed when the project configuration changes.
+ // The event is the same as for 'onChange'.
+ }
+
+ def onShutdown = { event ->
+ // TODO Implement code that is executed when the application shuts down (optional)
+ }
+ }
View
85 README
@@ -0,0 +1,85 @@
+ <big>Adding the setting you're file path/to/app/grails-app/config/Config.groovy</big>
+
+ gridfsConfig.db.host = "localhost" // host for mongodb
+ gridfsConfig.db.name = "myGridfs" // db name
+ gridfsConfig.db.collection = "files" // collections for files
+
+
+ gridfsConfig.iconsdir = "images/icons" // dir for icons // url prefix for files
+ gridfsConfig.imagestype = ["jpg","gif","png","bmp"] // extensions images for thumbs
+ gridfsConfig.allowedExtensions = ["jpg","gif","png","bmp","doc","rtf","zip"] // allowedExtensions
+ gridfsConfig.tmpdir = "tmp/files" // tmp dir
+ gridfsConfig.defaulticon = "images/icons/empty.png" // icon default
+ gridfsConfig.thumbconfig = [
+ publicdir:"tmp/imagesthumb/[idparent]", //template for dirs users thumbnails files
+ x_size:128,
+ y_size:128
+ ]
+ gridfsConfig.maxSize = 2000000
+ gridfsConfig.controllers.errorController = "gridfs" // errors controller
+ gridfsConfig.controllers.errorAction = "help"
+
+ gridfsConfig.controllers.successRemoveController = "gridfs" // controller for the success remove
+ gridfsConfig.controllers.successRemoveAction = "help"
+
+ gridfsConfig.controllers.successController = "gridfs" // controller for the success upload
+ gridfsConfig.controllers.successAction = "help"
+
+ gridfsConfig.controllers.accessController = "gridfs" // controller for the access deny
+ gridfsConfig.controllers.accesssAction = "help"
+
+ gridfsConfig.accessClass = "org.iglas.grails.utils.ExampleAccess" // class name for access control
+ gridfsConfig.accessMethod = "check" // method name for access control
+
+ gridfsConfig.indexes = [
+ "metadata.idparent":1,
+ "metadata.parentclass":1]
+
+
+ <big> Exsamle controler:</big>
+
+ class TestController {
+
+ def index() {
+ UserConfig gridfsConfig = new org.iglas.grails.utils.UserConfig("gridfsConfig")
+ gridfsConfig.set([controllers:[successController: "test",successAction:"index"]])
+ def list = new org.iglas.grails.gridfs.GridfsService().list([idparent: "myid",relative:true,icon:true])
+ render(view:"index", model:[listFiles: list ]
+ )
+
+ <big> Example gsp:</big>
+
+ <gridfs:form idparent="myid" parentclass="user" accesspolitic="['public','private','hidden']"
+ errorAction="index" errorController="test"
+ successAction="index" successController="test">
+ Description: <g:textField name="text" />
+ </gridfs:form >
+ <g:each in="${listFiles}">
+
+ name -> ${it.filename} <br />
+ text-> ${it.metadata?.text} <br />
+ // formatting size
+ size -> <gridfs:prettysize size="${it.size}" /> <br />
+
+ // get icon file path in list (invoke params icon=true)
+ icon -> <img src="${it.iconUrl}" /> <br />
+
+ // get link for download file
+ file- <gridfs:download filename="${it.filename}">${it.metadata.originalFilename}</gridfs:download>
+
+ // get icon custom size
+ <gridfs:getIcon filename="${it.filename}" title="myicon 150x200" x="150" y="200"/>
+ <gridfs:getIcon filename="${it.filename}" title="myicon 50x50" x="50" y="50"/>
+
+ // get link for file
+ <img src="${gridfs.createLink(filename:it.filename)}" width="200">
+
+ <br />
+ // get link for remove file
+ <gridfs:remove filename="${it.filename}">remove</gridfs:remove>
+
+ //using custom controllers action
+ <gridfs:remove filename="${it.filename}" errorAction="index" errorController="test">remove custom Controler</gridfs:remove>
+ <hr />
+
+ </g:each>
View
@@ -0,0 +1,7 @@
+#Grails Metadata file
+#Sun Feb 26 23:05:07 YAKT 2012
+app.grails.version=2.0.1
+app.name=mongodb-gridfs
+plugins.burning-image=0.5.0
+plugins.mongodb=1.0.0.RC4
+plugins.svn=1.0.1
View
@@ -0,0 +1,39 @@
+grails.project.class.dir = "target/classes"
+grails.project.test.class.dir = "target/test-classes"
+grails.project.test.reports.dir = "target/test-reports"
+grails.project.target.level = 1.7
+//grails.project.war.file = "target/${appName}-${appVersion}.war"
+
+grails.project.dependency.resolution = {
+ // inherit Grails' default dependencies
+ inherits("global") {
+ // uncomment to disable ehcache
+ // excludes 'ehcache'
+ }
+ log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
+ repositories {
+ grailsPlugins()
+ grailsHome()
+ grailsCentral()
+ // uncomment the below to enable remote dependency resolution
+ // from public Maven repositories
+ mavenCentral()
+ //mavenLocal()
+ //mavenRepo "http://snapshots.repository.codehaus.org"
+ //mavenRepo "http://repository.codehaus.org"
+ //mavenRepo "http://download.java.net/maven/2/"
+ //mavenRepo "http://repository.jboss.com/maven2/"
+ }
+ dependencies {
+ // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
+
+ // runtime 'mysql:mysql-connector-java:5.1.5'
+ }
+
+ plugins {
+ build(":tomcat:$grailsVersion",
+ ":release:1.0.0") {
+ export = false
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 1366445

Please sign in to comment.