Skip to content

Commit

Permalink
first commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
halfbaked committed Jun 25, 2012
1 parent d740203 commit d1bfd34
Show file tree
Hide file tree
Showing 25 changed files with 1,654 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .classpath
@@ -0,0 +1,14 @@
<classpath>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="src/groovy"/>
<classpathentry kind="src" path="grails-app/conf"/>
<classpathentry kind="src" path="grails-app/controllers"/>
<classpathentry kind="src" path="grails-app/domain"/>
<classpathentry kind="src" path="grails-app/services"/>
<classpathentry kind="src" path="grails-app/taglib"/>
<classpathentry kind="src" path="test/integration"/>
<classpathentry kind="src" path="test/unit"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="com.springsource.sts.grails.core.CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="web-app/WEB-INF/classes"/>
</classpath>
19 changes: 19 additions & 0 deletions .project
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>grails-font-awesome-resources</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.springsource.sts.grails.core.nature</nature>
<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
73 changes: 73 additions & 0 deletions GrailsFontAwesomeResourcesGrailsPlugin.groovy
@@ -0,0 +1,73 @@
class GrailsFontAwesomeResourcesGrailsPlugin {
// the plugin version
def version = "0.1"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "2.0 > *"
// the other plugins this plugin depends on
def dependsOn = [:]
// resources that are excluded from plugin packaging
def pluginExcludes = [
"grails-app/views/error.gsp"
]

// TODO Fill in these fields
def title = "Grails Font Awesome Resources Plugin" // Headline display name of the plugin
def author = "Eamonn O'Connell"
def authorEmail = "eamonnoconnell@gmail.com"
def description = '''\
Like the jquery-resources plugin that pulls in the jquery javascript lib as a resource, this plugin pulls in Font Awesome.
Font Awesome is a very popular font based icon set. Font based icons are a very convenient means of incorporating icons into a web application and the technique is growing in popularity.
Font Awesome probably works best when used with the twitter bootstrap UI framework for which it was designed.
'''

// URL to the plugin's documentation
def documentation = "https://github.com/halfbaked/grails-font-awesome-resources"

// 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: "Joe Bloggs", email: "joe@bloggs.net" ]]

// Location of the plugin's issue tracker.
def issueManagement = [ system: "GitHub", url: "https://github.com/halfbaked/grails-font-awesome-resources/issues" ]

// Online location of the plugin's browseable source code.
def scm = [ url: "https://github.com/halfbaked/grails-font-awesome-resources" ]

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)
}
}
24 changes: 23 additions & 1 deletion README.md
@@ -1,4 +1,26 @@
grails-font-awesome-resources
=============================

Provides the twitter bootstrap compatible awesome font based icon set font-awesome.
Provides the twitter bootstrap compatible awesome font based icon set font-awesome.

## Background
[Font Awesome](http://fortawesome.github.com/Font-Awesome/) is an iconic font designed for use with Twitter Bootstrap. Twitter Bootstrap comes with an icon set (Gliphicons) built in. This set is rendered using image sprites. Font based icons are a very convenient means of incorporating icons into a web application and the technique is growing in popularity. One of its plus points is how easy it is to manipulate an icon with css. A few lines of the most basic css can change the size and color of an icon, or set of icons. Try doing that with an image sprite!

## Usage
To add font-awesome resource to your project

* Install the plugin by adding the appropriate plugin dependency in your Build.config
* Reference the font-awesome resource from within your ApplicationResources file or directly in a gsp page/layout
Example

// ApplicationResources.groovy
customBootstrap {
dependsOn 'bootstrap', 'fontawesome'
}

// main.gsp
<r:require module="customBootstrap" />


The above example assumes you also have the [grails twitter bootstrap plugin](http://grails.org/plugin/twitter-bootstrap) installed.

4 changes: 4 additions & 0 deletions application.properties
@@ -0,0 +1,4 @@
#Grails Metadata file
#Mon Jun 25 10:42:48 CEST 2012
app.grails.version=2.0.1
app.name=grails-font-awesome-resources
31 changes: 31 additions & 0 deletions grails-app/conf/BuildConfig.groovy
@@ -0,0 +1,31 @@
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.6
//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 {
grailsCentral()
grailsPlugins()
grailsHome()
grailsCentral()
grailsRepo "http://grails.org/plugins"
}
dependencies {
}

plugins {
build(":tomcat:$grailsVersion",
":release:1.0.0") {
export = false
}
compile ":lesscss-resources:1.3.0.3"
}
}
24 changes: 24 additions & 0 deletions grails-app/conf/Config.groovy
@@ -0,0 +1,24 @@
// configuration for plugin testing - will not be included in the plugin zip

log4j = {
// Example of changing the log pattern for the default console
// appender:
//
//appenders {
// console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
//}

error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate'

warn 'org.mortbay.log'
}
43 changes: 43 additions & 0 deletions grails-app/conf/DataSource.groovy
@@ -0,0 +1,43 @@
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
}
7 changes: 7 additions & 0 deletions grails-app/conf/FontAwesomePluginResources.groovy
@@ -0,0 +1,7 @@
modules = {

'fontawesome' {
resource url:[dir: 'less', file: 'font-awesome.less'], attrs:[rel: "stylesheet/less", type:'css']
}

}
13 changes: 13 additions & 0 deletions grails-app/conf/UrlMappings.groovy
@@ -0,0 +1,13 @@
class UrlMappings {

static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}

"/"(view:"/index")
"500"(view:'/error')
}
}
20 changes: 20 additions & 0 deletions grails-app/resourceMappers/FontAwesomePluginResourceMapper.groovy
@@ -0,0 +1,20 @@
import org.grails.plugin.resource.mapper.MapperPhase


// Removes the warning seen in the Chrome debugger:
// ‘Resource interpreted as Font but transferred with MIME type application/octet-stream’
// http://kalikallin.tumblr.com/post/25182657116/setting-grails-content-type-for-a-given-file-extension
class FontAwesomeResourceMapper {

static phase = MapperPhase.ALTERNATEREPRESENTATION
static defaultIncludes = [ '**/*.woff' ]

def map(resource, config) {
resource.requestProcessors << { req, resp ->
resp.setHeader('Content-Type', 'font/opentype')
}
}

}


11 changes: 11 additions & 0 deletions grails-app/views/error.gsp
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<title>Grails Runtime Exception</title>
<meta name="layout" content="main">
<link rel="stylesheet" href="${resource(dir: 'css', file: 'errors.css')}" type="text/css">
</head>
<body>
<g:renderException exception="${exception}" />
</body>
</html>
10 changes: 10 additions & 0 deletions scripts/_Install.groovy
@@ -0,0 +1,10 @@
//
// This script is executed by Grails after plugin was installed to project.
// This script is a Gant script so you can use all special variables provided
// by Gant (such as 'baseDir' which points on project base dir). You can
// use 'ant' to access a global instance of AntBuilder
//
// For example you can create directory under project tree:
//
// ant.mkdir(dir:"${basedir}/grails-app/jobs")
//
5 changes: 5 additions & 0 deletions scripts/_Uninstall.groovy
@@ -0,0 +1,5 @@
//
// This script is executed by Grails when the plugin is uninstalled from project.
// Use this script if you intend to do any additional clean-up on uninstall, but
// beware of messing up SVN directories!
//
10 changes: 10 additions & 0 deletions scripts/_Upgrade.groovy
@@ -0,0 +1,10 @@
//
// This script is executed by Grails during application upgrade ('grails upgrade'
// command). This script is a Gant script so you can use all special variables
// provided by Gant (such as 'baseDir' which points on project base dir). You can
// use 'ant' to access a global instance of AntBuilder
//
// For example you can create directory under project tree:
//
// ant.mkdir(dir:"${basedir}/grails-app/jobs")
//
33 changes: 33 additions & 0 deletions web-app/WEB-INF/applicationContext.xml
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<bean id="grailsApplication" class="org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBean">
<description>Grails application factory bean</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="grailsResourceLoader" ref="grailsResourceLoader" />
</bean>

<bean id="pluginManager" class="org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean">
<description>A bean that manages Grails plugins</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="application" ref="grailsApplication" />
</bean>

<bean id="grailsConfigurator" class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator">
<constructor-arg>
<ref bean="grailsApplication" />
</constructor-arg>
<property name="pluginManager" ref="pluginManager" />
</bean>

<bean id="grailsResourceLoader" class="org.codehaus.groovy.grails.commons.GrailsResourceLoaderFactoryBean" />

<bean id="characterEncodingFilter" class="org.springframework.web.filter.CharacterEncodingFilter">
<property name="encoding">
<value>utf-8</value>
</property>
</bean>
</beans>
14 changes: 14 additions & 0 deletions web-app/WEB-INF/sitemesh.xml
@@ -0,0 +1,14 @@
<sitemesh>
<page-parsers>
<parser content-type="text/html"
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
<parser content-type="text/html;charset=ISO-8859-1"
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
<parser content-type="text/html;charset=UTF-8"
class="org.codehaus.groovy.grails.web.sitemesh.GrailsHTMLPageParser" />
</page-parsers>

<decorator-mappers>
<mapper class="org.codehaus.groovy.grails.web.sitemesh.GrailsLayoutDecoratorMapper" />
</decorator-mappers>
</sitemesh>

0 comments on commit d1bfd34

Please sign in to comment.