SlideShare una empresa de Scribd logo
1 de 68
Descargar para leer sin conexión
Does my <div/>
look big in this?
        Putting some DRY in Grails UI
                   with Glen Smith
Ancient Hacker Wisdom…

If the ax is dull and its edge unsharpened, more
 strength is needed, but skill will bring success.
                             Solomon, Ecclesiastes 10:10
Why this talk?
“The only thing I’m
addicted to right now is
       winning.”
Since we’re talking…
 Sort out the                             DRY up
mess of JS event                         Resources,
  handling…                            Forms & Nav…

                   JavaScript   HTML

                           CSS
DRY up CSS and
  standardise
 fonts/layout..
Best Case Outcomes
• Learn Grails Resources
• Pickup some UI Plugin Love
• Try Less CSS & Twitter Bootstrap
• Swap stories & have fun!
Could be handy…

https://github.com/glenasmith/shameless
App Demo
See Food Diet
Account

 Meal

   Picture
<html>
Refactoring Resources
Benefits
•   Much DRYer Grails views
•   Dependency management of view tier stuff
•   Bundle and Minify/Compress automagically
•   Stops duplicate inclusions
•   Defers JS for performance
•   Caching forever (intelligent hashing)
•   Makes plugins for UI play nice (standardised)
•   Blah, Blah, Blah, it’s worth it, ok?
The 3 Essentials
1. DEFINE (/grails-app/conf/MyAppResources.groovy *)
2. TEMPLATE (<r:layoutResources/> in head and body)
3. REQUIRE (target page <r:require modules=“growl”/>)
1. Define Modules
modules = {
     growl {
          dependsOn 'jquery‘
          // order is important
          resource url:'/css/growl/growl.css'
          resource url:'/js/growl/growl.js'
     }
}
Also: Disposition Tricks

resource url:'/js/growl/growl.js', disposition: ‘head'
2. Change the Template

   <r:layoutResources/>
3. Change the Page

<r:require modules=“a,b,c”/>
Look at the Chrome
X-Grails-Resources-Original-Src:
/bundle-bundle_jqplot_defer.js, /js/jqplot/exca
nvas.js, /js/jqplot/jquery.jqplot.js, /js/jqplot/jqp
lot.pieRenderer.js, /js/jqplot/jqplot.barRenderer.
js, /js/jqplot/jqplot.categoryAxisRenderer.js, /js
/jqplot/jqplot.pointLabels.js
Resources Demo
Lesser Known Goodness
• <r:img>
• <r:external>
• <r:script disposition=“head”>
• Module overrides
Debugging Resources
?_debugResources=y
grails.resources.debug = true
Tools that play nice…
• Cached-Resources
• Zipped-Resources
• And millions of 3 rd party library

  ones (blueprint, 960gs)
DRY Forms
Coming in Grails 2.x…
bean-fields
UNTIL THEN…
A Typical Grails form…
<ul class="errors" role="alert">
<g:eachError bean="${authorInstance}" var="error">
   <li <g:if test="${error in
org.springframework.validation.FieldError}">data-
field-id="${error.field}"</g:if>><g:message
error="${error}"/></li>
</g:eachError>
</ul>
Add tons of field code…
<tr class="prop">
    <td valign="top" class="name">
        <label for="name"><g:message
code="account.name.label" default="Name"
/></label>
    </td>
    <td valign="top" class="value
${hasErrors(bean: accountInstance, field:
'name', 'errors')}">
        <g:textField name="name"
maxlength="200"
value="${accountInstance?.name}" />
    </td>
</tr>
With bean-fields…

<bean:form
   beanName=“account”
   properties=“name,email”/>
Or Probably…
<bean:form beanName=“account”>
    <bean:field property=“name”/>
    <bean:field property=“email”/>
    <!-- etc -->
</bean:form>
Customisation…
Beans Demo
Strategy
• Create a GSP that contains all your
  <bean:xxxxTemplate> tags.
• In your layout do <g:render
  template=“/common/formconf"/>
• This will set up all your field styling for
  your pages.
TAMING THE DREADED…
navigation
Geez, you don’t want…
<div id="tabs">
  <ul>
            <li id="${request.forwardURI =~ /entries/recent/ ? 'current' : 'notcurrent'}"><a
href="<g:createLink controller='entries' action='recent'/>">Just In</a></li>
            <li id="${request.forwardURI =~ /entries/popular/ ? 'current' : 'notcurrent'}"><a
href="<g:createLink controller='entries' action='popular'/>">Popular</a></li>
            <li id="${request.forwardURI =~ /entries/lists/ ? 'current' : 'notcurrent'}"><a
href="<g:createLink controller='entries' action='lists'/>">The Lists</a></li>
            <li id="${request.forwardURI =~ /account/ ? 'current' : 'notcurrent'}"><a
href="<g:createLink controller='account' action='edit'/>">My Blogs</a></li>
  <ul>
</div>
Get DRY with Controllers
static navigation = [
              group:'tabs',
              order:99,
              title:'Admin',
              action:'index',
              isVisible: {
SpringSecurityUtils.ifAnyGranted("ROLE_ADMIN") }

      ]
And the markup…
<html> <head><nav:resources/></head>
<body>
     <div id="menu">
           <nav:render group="tabs"/>
     </div>
     <g:layoutBody/>
</body> </html>
Going Custom
<nav:eachItem group="tabs" var="item">
  <li class="${item.active ? 'active' : ''}">
       <g:link controller="${item.controller}"
             action="${item.action}">${item.title}
       </g:link>
  </li>
</nav:eachItem>
Navigation Demo
.css
I mean, what could be
     better than css?
CSS:
the death
of 1,000
cuts
How about Less css!?!?
Enter Less.css
• Variables
• Mixins (with parameters!)
• Nested Rules
• Functions & Operators
• Compiles to real CSS (or use as .less
  files with JS)
How It Works
              • Write source.less using variables,
myfile.less     mixins & nesting

              • Precompile (or use JavaScript compiler
 Lessc or
  less.js
                straight from the DOM)


              • Generate .css file for your browser
myfile.css
Compiling Less

grails install-plugin lesscss-resources
Variables
@color: #4D926F;
#header {
     color: @color;
}
h2 {
     color: @color;
}
Nested Resources
#header {
  h1 {
    font-size: 26px;
    font-weight: bold;
  }
  p { font-size: 12px;
    a { text-decoration: none;
      &:hover { border-width: 1px }
    }
  }
}
Mixins
.rounded-corners (@radius: 5px) {
     border-radius: @radius;
     -webkit-border-radius: @radius;
     -moz-border-radius: @radius;
}
#header { .rounded-corners; }
#footer { .rounded-corners(10px); }
Less.css Demo
Doing this stuff by hand
              …is for bozos
It’s time to get
 really, really,
  ridiculously
good looking…
Meet Twitter Bootstrap
• Grid system
• Fonts & Styling
• Forms
• Nav
• Alerts
Everything* you need to know
                                                 .span16
                                 .row
.container OR .container-fluid




                                           .span12                  .span4
                                 .row




                                                                      .span4
                                        .span6    .span6
                                 .row




                                                                     .offset4
                                                     * For very small values of everything
You do design on paper?
Integration Options
1. Plugin (but you’re stuck with updates)
2. CSS (but it’s hard to tweak)
3. LESS files (like a complete boss!)
Getting Jiggy with UI
  You’re going to like this…
</wrap>
What we’ve learned…
 Sort out the                             DRY up
mess of JS event                         Resources,
  handling…                            Forms & Nav…

                   JavaScript   HTML

                           CSS
DRY up CSS and
  standardise
 fonts/layout..
Thanks for Coming!
          @glen_a_smith




blogs.bytecode.com.au/glen
Image Credits
•   Hipster - http://www.flickr.com/photos/another_point_in_time/4743084835
•   The Knives - http://www.flickr.com/photos/mcdnry/2347884938
•   Giant Backbone - http://www.flickr.com/photos/25289142@N05/4559842516
•   Tangled Wires - http://www.flickr.com/photos/randomurl/440190706

Más contenido relacionado

La actualidad más candente

Performance as User Experience [An Event Apart Denver 2017]
Performance as User Experience [An Event Apart Denver 2017]Performance as User Experience [An Event Apart Denver 2017]
Performance as User Experience [An Event Apart Denver 2017]Aaron Gustafson
 
Own Your Front-end Performance: Tools, Not Rules
Own Your Front-end Performance: Tools, Not RulesOwn Your Front-end Performance: Tools, Not Rules
Own Your Front-end Performance: Tools, Not RulesFunctional Imperative
 
Own Your Front-end Performance: Tools, Not Rules
Own Your Front-end Performance: Tools, Not RulesOwn Your Front-end Performance: Tools, Not Rules
Own Your Front-end Performance: Tools, Not RulesFunctional Imperative
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in ComponentsFITC
 
jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009Ralph Whitbeck
 
Accessibility - A feature you can build
Accessibility - A feature you can buildAccessibility - A feature you can build
Accessibility - A feature you can buildMonika Piotrowicz
 
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...Daosheng Mu
 
Scaling Drupal @ iMoney - DrupalCamp Singapore 2014
Scaling Drupal @ iMoney - DrupalCamp Singapore 2014Scaling Drupal @ iMoney - DrupalCamp Singapore 2014
Scaling Drupal @ iMoney - DrupalCamp Singapore 2014imoneytech
 
BOOM Performance
BOOM PerformanceBOOM Performance
BOOM Performancedapulse
 
Html5 - the new kid on the block
Html5 - the new kid on the blockHtml5 - the new kid on the block
Html5 - the new kid on the blockMarian Borca
 
Real World Web components
Real World Web componentsReal World Web components
Real World Web componentsJarrod Overson
 
Mashup University 4: Intro To Mashups
Mashup University 4: Intro To MashupsMashup University 4: Intro To Mashups
Mashup University 4: Intro To MashupsJohn Herren
 
Skillville Games CodeChix Presentation
Skillville Games CodeChix PresentationSkillville Games CodeChix Presentation
Skillville Games CodeChix Presentationjasontravisclark
 
"Designing for the Mobile Web" by Michael Dick (December 2010)
"Designing for the Mobile Web" by Michael Dick (December 2010)"Designing for the Mobile Web" by Michael Dick (December 2010)
"Designing for the Mobile Web" by Michael Dick (December 2010)Mike Brenner
 
Wordpress Beyond Websites
Wordpress Beyond WebsitesWordpress Beyond Websites
Wordpress Beyond WebsitesScott Saunders
 
Idea2app
Idea2appIdea2app
Idea2appFlumes
 
Rails Performance Tricks and Treats
Rails Performance Tricks and TreatsRails Performance Tricks and Treats
Rails Performance Tricks and TreatsMarshall Yount
 
Heroku addons development - Nov 2011
Heroku addons development - Nov 2011Heroku addons development - Nov 2011
Heroku addons development - Nov 2011Leonardo Borges
 

La actualidad más candente (19)

Performance as User Experience [An Event Apart Denver 2017]
Performance as User Experience [An Event Apart Denver 2017]Performance as User Experience [An Event Apart Denver 2017]
Performance as User Experience [An Event Apart Denver 2017]
 
Own Your Front-end Performance: Tools, Not Rules
Own Your Front-end Performance: Tools, Not RulesOwn Your Front-end Performance: Tools, Not Rules
Own Your Front-end Performance: Tools, Not Rules
 
Own Your Front-end Performance: Tools, Not Rules
Own Your Front-end Performance: Tools, Not RulesOwn Your Front-end Performance: Tools, Not Rules
Own Your Front-end Performance: Tools, Not Rules
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in Components
 
jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009
 
Accessibility - A feature you can build
Accessibility - A feature you can buildAccessibility - A feature you can build
Accessibility - A feature you can build
 
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
Using The New Flash Stage3D Web Technology To Build Your Own Next 3D Browser ...
 
Scaling Drupal @ iMoney - DrupalCamp Singapore 2014
Scaling Drupal @ iMoney - DrupalCamp Singapore 2014Scaling Drupal @ iMoney - DrupalCamp Singapore 2014
Scaling Drupal @ iMoney - DrupalCamp Singapore 2014
 
BOOM Performance
BOOM PerformanceBOOM Performance
BOOM Performance
 
Html5 - the new kid on the block
Html5 - the new kid on the blockHtml5 - the new kid on the block
Html5 - the new kid on the block
 
Real World Web components
Real World Web componentsReal World Web components
Real World Web components
 
Mashup University 4: Intro To Mashups
Mashup University 4: Intro To MashupsMashup University 4: Intro To Mashups
Mashup University 4: Intro To Mashups
 
Skillville Games CodeChix Presentation
Skillville Games CodeChix PresentationSkillville Games CodeChix Presentation
Skillville Games CodeChix Presentation
 
"Designing for the Mobile Web" by Michael Dick (December 2010)
"Designing for the Mobile Web" by Michael Dick (December 2010)"Designing for the Mobile Web" by Michael Dick (December 2010)
"Designing for the Mobile Web" by Michael Dick (December 2010)
 
Wordpress Beyond Websites
Wordpress Beyond WebsitesWordpress Beyond Websites
Wordpress Beyond Websites
 
Object width
Object widthObject width
Object width
 
Idea2app
Idea2appIdea2app
Idea2app
 
Rails Performance Tricks and Treats
Rails Performance Tricks and TreatsRails Performance Tricks and Treats
Rails Performance Tricks and Treats
 
Heroku addons development - Nov 2011
Heroku addons development - Nov 2011Heroku addons development - Nov 2011
Heroku addons development - Nov 2011
 

Destacado

The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.jsThe MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.jsMongoDB
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSM R Rony
 
Introduction to the MEAN stack
Introduction to the MEAN stackIntroduction to the MEAN stack
Introduction to the MEAN stackYoann Gotthilf
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentationJohn Staveley
 
Building single page applications
Building single page applicationsBuilding single page applications
Building single page applicationsSC5.io
 
Get MEAN! Node.js and the MEAN stack
Get MEAN!  Node.js and the MEAN stackGet MEAN!  Node.js and the MEAN stack
Get MEAN! Node.js and the MEAN stackNicholas McClay
 
Introduction To Single Page Application
Introduction To Single Page ApplicationIntroduction To Single Page Application
Introduction To Single Page ApplicationKMS Technology
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architectureGabriele Falace
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS ArchitectureEyal Vardi
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2Knoldus Inc.
 

Destacado (15)

The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.jsThe MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJS
 
Introduction to the MEAN stack
Introduction to the MEAN stackIntroduction to the MEAN stack
Introduction to the MEAN stack
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
 
MEAN Stack
MEAN StackMEAN Stack
MEAN Stack
 
Building single page applications
Building single page applicationsBuilding single page applications
Building single page applications
 
Get MEAN! Node.js and the MEAN stack
Get MEAN!  Node.js and the MEAN stackGet MEAN!  Node.js and the MEAN stack
Get MEAN! Node.js and the MEAN stack
 
Single Page Applications
Single Page ApplicationsSingle Page Applications
Single Page Applications
 
Introduction To Single Page Application
Introduction To Single Page ApplicationIntroduction To Single Page Application
Introduction To Single Page Application
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 

Similar a Does my DIV look big in this?

Bootstrap Workout 2015
Bootstrap Workout 2015Bootstrap Workout 2015
Bootstrap Workout 2015Rob Davarnia
 
Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebJames Rakich
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsMark Rackley
 
Scout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoScout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoknaddison
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideMark Rackley
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup PerformanceJustin Cataldo
 
Getting the most out of Radiant
Getting the most out of RadiantGetting the most out of Radiant
Getting the most out of Radiantjomz83
 
Modern Front-End Development
Modern Front-End DevelopmentModern Front-End Development
Modern Front-End Developmentmwrather
 
JavaScript For People Who Don't Code
JavaScript For People Who Don't CodeJavaScript For People Who Don't Code
JavaScript For People Who Don't CodeChristopher Schmitt
 
Render Caching for Drupal 8
Render Caching for Drupal 8Render Caching for Drupal 8
Render Caching for Drupal 8John Doyle
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Ryan Price
 
Performance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best PracticesPerformance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best PracticesDoris Chen
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracketjnewmanux
 
Buildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbBuildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbMongoDB APAC
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalabilityTwinbit
 
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkins
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_WilkinsMongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkins
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkinskiwilkins
 
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012Bastian Grimm
 

Similar a Does my DIV look big in this? (20)

Bootstrap Workout 2015
Bootstrap Workout 2015Bootstrap Workout 2015
Bootstrap Workout 2015
 
Everything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the Web
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
 
Scout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoScout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicago
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuide
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
Getting the most out of Radiant
Getting the most out of RadiantGetting the most out of Radiant
Getting the most out of Radiant
 
Modern Front-End Development
Modern Front-End DevelopmentModern Front-End Development
Modern Front-End Development
 
JavaScript For People Who Don't Code
JavaScript For People Who Don't CodeJavaScript For People Who Don't Code
JavaScript For People Who Don't Code
 
Django at Scale
Django at ScaleDjango at Scale
Django at Scale
 
Render Caching for Drupal 8
Render Caching for Drupal 8Render Caching for Drupal 8
Render Caching for Drupal 8
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011
 
Performance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best PracticesPerformance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best Practices
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracket
 
Buildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbBuildingsocialanalyticstoolwithmongodb
Buildingsocialanalyticstoolwithmongodb
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
 
Death of a Themer
Death of a ThemerDeath of a Themer
Death of a Themer
 
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkins
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_WilkinsMongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkins
MongoDB Revised Sharding Guidelines MongoDB 3.x_Kimberly_Wilkins
 
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
 

Último

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Último (20)

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

Does my DIV look big in this?

  • 1. Does my <div/> look big in this? Putting some DRY in Grails UI with Glen Smith
  • 2. Ancient Hacker Wisdom… If the ax is dull and its edge unsharpened, more strength is needed, but skill will bring success. Solomon, Ecclesiastes 10:10
  • 4. “The only thing I’m addicted to right now is winning.”
  • 5. Since we’re talking… Sort out the DRY up mess of JS event Resources, handling… Forms & Nav… JavaScript HTML CSS DRY up CSS and standardise fonts/layout..
  • 6.
  • 7. Best Case Outcomes • Learn Grails Resources • Pickup some UI Plugin Love • Try Less CSS & Twitter Bootstrap • Swap stories & have fun!
  • 10. See Food Diet Account Meal Picture
  • 12.
  • 14. Benefits • Much DRYer Grails views • Dependency management of view tier stuff • Bundle and Minify/Compress automagically • Stops duplicate inclusions • Defers JS for performance • Caching forever (intelligent hashing) • Makes plugins for UI play nice (standardised) • Blah, Blah, Blah, it’s worth it, ok?
  • 15. The 3 Essentials 1. DEFINE (/grails-app/conf/MyAppResources.groovy *) 2. TEMPLATE (<r:layoutResources/> in head and body) 3. REQUIRE (target page <r:require modules=“growl”/>)
  • 16. 1. Define Modules modules = { growl { dependsOn 'jquery‘ // order is important resource url:'/css/growl/growl.css' resource url:'/js/growl/growl.js' } }
  • 17.
  • 18.
  • 19. Also: Disposition Tricks resource url:'/js/growl/growl.js', disposition: ‘head'
  • 20. 2. Change the Template <r:layoutResources/>
  • 21. 3. Change the Page <r:require modules=“a,b,c”/>
  • 22. Look at the Chrome X-Grails-Resources-Original-Src: /bundle-bundle_jqplot_defer.js, /js/jqplot/exca nvas.js, /js/jqplot/jquery.jqplot.js, /js/jqplot/jqp lot.pieRenderer.js, /js/jqplot/jqplot.barRenderer. js, /js/jqplot/jqplot.categoryAxisRenderer.js, /js /jqplot/jqplot.pointLabels.js
  • 24. Lesser Known Goodness • <r:img> • <r:external> • <r:script disposition=“head”> • Module overrides
  • 26. Tools that play nice… • Cached-Resources • Zipped-Resources • And millions of 3 rd party library ones (blueprint, 960gs)
  • 30. A Typical Grails form… <ul class="errors" role="alert"> <g:eachError bean="${authorInstance}" var="error"> <li <g:if test="${error in org.springframework.validation.FieldError}">data- field-id="${error.field}"</g:if>><g:message error="${error}"/></li> </g:eachError> </ul>
  • 31. Add tons of field code… <tr class="prop"> <td valign="top" class="name"> <label for="name"><g:message code="account.name.label" default="Name" /></label> </td> <td valign="top" class="value ${hasErrors(bean: accountInstance, field: 'name', 'errors')}"> <g:textField name="name" maxlength="200" value="${accountInstance?.name}" /> </td> </tr>
  • 32. With bean-fields… <bean:form beanName=“account” properties=“name,email”/>
  • 33. Or Probably… <bean:form beanName=“account”> <bean:field property=“name”/> <bean:field property=“email”/> <!-- etc --> </bean:form>
  • 36. Strategy • Create a GSP that contains all your <bean:xxxxTemplate> tags. • In your layout do <g:render template=“/common/formconf"/> • This will set up all your field styling for your pages.
  • 38.
  • 39. Geez, you don’t want… <div id="tabs"> <ul> <li id="${request.forwardURI =~ /entries/recent/ ? 'current' : 'notcurrent'}"><a href="<g:createLink controller='entries' action='recent'/>">Just In</a></li> <li id="${request.forwardURI =~ /entries/popular/ ? 'current' : 'notcurrent'}"><a href="<g:createLink controller='entries' action='popular'/>">Popular</a></li> <li id="${request.forwardURI =~ /entries/lists/ ? 'current' : 'notcurrent'}"><a href="<g:createLink controller='entries' action='lists'/>">The Lists</a></li> <li id="${request.forwardURI =~ /account/ ? 'current' : 'notcurrent'}"><a href="<g:createLink controller='account' action='edit'/>">My Blogs</a></li> <ul> </div>
  • 40. Get DRY with Controllers static navigation = [ group:'tabs', order:99, title:'Admin', action:'index', isVisible: { SpringSecurityUtils.ifAnyGranted("ROLE_ADMIN") } ]
  • 41. And the markup… <html> <head><nav:resources/></head> <body> <div id="menu"> <nav:render group="tabs"/> </div> <g:layoutBody/> </body> </html>
  • 42.
  • 43. Going Custom <nav:eachItem group="tabs" var="item"> <li class="${item.active ? 'active' : ''}"> <g:link controller="${item.controller}" action="${item.action}">${item.title} </g:link> </li> </nav:eachItem>
  • 45. .css
  • 46.
  • 47. I mean, what could be better than css?
  • 49. How about Less css!?!?
  • 50. Enter Less.css • Variables • Mixins (with parameters!) • Nested Rules • Functions & Operators • Compiles to real CSS (or use as .less files with JS)
  • 51. How It Works • Write source.less using variables, myfile.less mixins & nesting • Precompile (or use JavaScript compiler Lessc or less.js straight from the DOM) • Generate .css file for your browser myfile.css
  • 53. Variables @color: #4D926F; #header { color: @color; } h2 { color: @color; }
  • 54. Nested Resources #header { h1 { font-size: 26px; font-weight: bold; } p { font-size: 12px; a { text-decoration: none; &:hover { border-width: 1px } } } }
  • 55. Mixins .rounded-corners (@radius: 5px) { border-radius: @radius; -webkit-border-radius: @radius; -moz-border-radius: @radius; } #header { .rounded-corners; } #footer { .rounded-corners(10px); }
  • 57. Doing this stuff by hand …is for bozos
  • 58. It’s time to get really, really, ridiculously good looking…
  • 59. Meet Twitter Bootstrap • Grid system • Fonts & Styling • Forms • Nav • Alerts
  • 60.
  • 61. Everything* you need to know .span16 .row .container OR .container-fluid .span12 .span4 .row .span4 .span6 .span6 .row .offset4 * For very small values of everything
  • 62. You do design on paper?
  • 63. Integration Options 1. Plugin (but you’re stuck with updates) 2. CSS (but it’s hard to tweak) 3. LESS files (like a complete boss!)
  • 64. Getting Jiggy with UI You’re going to like this…
  • 66. What we’ve learned… Sort out the DRY up mess of JS event Resources, handling… Forms & Nav… JavaScript HTML CSS DRY up CSS and standardise fonts/layout..
  • 67. Thanks for Coming! @glen_a_smith blogs.bytecode.com.au/glen
  • 68. Image Credits • Hipster - http://www.flickr.com/photos/another_point_in_time/4743084835 • The Knives - http://www.flickr.com/photos/mcdnry/2347884938 • Giant Backbone - http://www.flickr.com/photos/25289142@N05/4559842516 • Tangled Wires - http://www.flickr.com/photos/randomurl/440190706