Introduction
The goal of the MyBusiness™ plugin is to add e-business (including e-commerce) functionality to a Grails 3.x web application.
We are currently porting features from our proprietary MyBusiness™ application to this plugin project.
Currently the plugin contains these features:
-
Security and Authentication using Spring-Security-Core
-
Contact form with Google Re-Captcha
-
eBay product listings with zooming images
-
Google business reviews
-
Notices for display by date range
-
RSS feeds for display of industry news artitcles, etc.
-
Secured admin home page with links to admin forms
Features yet to be ported over.
-
Products including categories, features, feature categories, and good identifications
-
Product movies
-
Specials
-
Blog
Planned new features
-
Content Management System or CMS to allow page content from the database.
Version Numbering
After version 1.0 we have changed to 4 digit system where the first 2 are Grails major.minor to more easily establish compatibility. The third is major version of this plugin, and fourth is patch versions. Plugin versions will increment on new features added.
<Grails major . Grails minor . Plugin major . patch>
Plugin Usage
Add Plugin to build.gradle
Add to dependencies section
compile "net.codebuilders.mybusiness:mybusiness:X.X.X"
Add Spring Security to application.groovy
Add to grails-app/config.application.groovy and review grails.plugin.springsecurity.controllerAnnotations.staticRules section and remove unused examples and verify security rules.
// for Spring Security Core plugin:
grails.plugin.springsecurity.userLookup.userDomainClassName = 'net.codebuilders.mybusiness.SecUser'
grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'net.codebuilders.mybusiness.SecUserSecRole'
grails.plugin.springsecurity.authority.className = 'net.codebuilders.mybusiness.SecRole'
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
[pattern: '/', access: ['permitAll']],
[pattern: '/error', access: ['permitAll']],
[pattern: '/index', access: ['permitAll']],
[pattern: '/index.gsp', access: ['permitAll']],
[pattern: '/shutdown', access: ['permitAll']],
[pattern: '/assets/**', access: ['permitAll']],
[pattern: '/**/js/**', access: ['permitAll']],
[pattern: '/**/css/**', access: ['permitAll']],
[pattern: '/**/images/**', access: ['permitAll']],
[pattern: '/**/favicon.ico', access: ['permitAll']],
[pattern: '/home/**', access: ['permitAll']],
[pattern: '/contact/**', access: ['permitAll']],
[pattern: '/ebay/**', access: ['permitAll']],
[pattern: '/constant/**', access: ['permitAll']],
[pattern: '/gapi/index', access: ['permitAll']],
// google reviews requires a privacy notice
[pattern: '/privacy', access: ['permitAll']],
// admin pages
[pattern: '/admin/**', access: ['ROLE_ADMIN', 'isFullyAuthenticated()']],
[pattern: '/dbconsole/**', access: ['ROLE_ADMIN', 'isFullyAuthenticated()']],
[pattern: '/notice/**', access: ['ROLE_ADMIN', 'isFullyAuthenticated()']],
[pattern: '/rssFeed/**', access: ['isFullyAuthenticated()']],
[pattern: '/blog/**', access: ['ROLE_ADMIN', 'isFullyAuthenticated()']],
[pattern: '/commentable/**', access: ['ROLE_ADMIN', 'isFullyAuthenticated()']],
// by default ckeditor is only used by admin role
[pattern: '/ck/standard/filemanager', access: ['ROLE_ADMIN', 'isFullyAuthenticated()']],
[pattern: '/ck/standard/uploader', access: ['ROLE_ADMIN', 'isFullyAuthenticated()']],
[pattern: '/ck/ofm/filemanager', access: ['ROLE_ADMIN', 'isFullyAuthenticated()']],
[pattern: '/ck/ofm/filetree', access: ['ROLE_ADMIN', 'isFullyAuthenticated()']],
// example for google webmaster verification and sitemaps
[pattern: '/google123456.html', access: ['permitAll']],
[pattern: '/robots.txt', access: ['permitAll']],
[pattern: '/sitemap.htm', access: ['permitAll']],
[pattern: '/sitemap.xml', access: ['permitAll']]
]
If you do not yet have a logout link and need to do it by URL, add the following also.
// for tutorial only - remove after logout gsp is created
grails.plugin.springsecurity.logout.postOnly = false
Contact Mail
Add e-mail addresses to grails-app/config.application.groovy. This is a map where keys are names to display in contact form and value is the email address.
// for mybusiness contact
mybusiness.contactMap = [
"Contact_Name_1" : "contact.name.1@changeme.com",
"Contact_Name_2" : "contact.name.2@changeme.com"
]
Configure Re-Captcha to be light or dark background.
// light or dark
mybusiness.recaptcha.style = "light"
Mail Plugin
Add mail server settings to grails-app/config.application.groovy See http://plugins.grails.org/plugin/mail for more information on the Mail plugin
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "youracount@gmail.com"
password = "yourpassword"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
Server URL
Add server URL to grails-app/config.application.groovy. If you are deploying as a SpringBoot runnable jar with an Apache HTTP frontend you can leave this "http://localhost:[PORT]".
environments {
production {
grails.serverURL = "http://localhost:8090"
}
}
Using Application Variables in Controllers
// may not be needed in grails 3
def grailsApplication
def myAction = {
def bar = grailsApplication.config.my.property
// map example
Map contactMap = grailsApplication.config.getProperty('mybusiness.contactMap', Map)
}
eBay Feature
You will need to setup your application with eBay https://go.developer.ebay.com/quick-start-guide .
Setup application variable in application.groovy
mybusiness.ebay.security.appname = "mybusiness-1234-5678-aaaa-bbbbccccdddd"
mybusiness.ebay.storeName = "mystorename"
Google Maps
Paste the location into the variable.
mybusiness.map.src = "https://www.google.com/maps/embed?pb=..."
Google Reviews
We use the Google Places Web API service. You will need to get a key from https://developers.google.com/places/web-service/intro and have a place id to display reviews.
mybusiness.places.key = "YOUR_API_KEY"
mybusiness.places.id = "YOUR_PLACES_ID"
Seed-Me
We use the Seed-Me plugin to add users for plugin testing with run-app. If enabled in the client app the user 'admin' with 'password' will be available in development mode. See seed-me plug for available options. http://plugins.grails.org/plugin/bertramlabs/seed-me