SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
grooscript & grails 3
Jorge Franco Leza
Greach - Madrid - April 8th 2016
About me
Developer
Between Madrid & Sevilla
jorge.franco.leza@gmail.com
@jfrancoleza
About grooscript
Apache 2 library
In github, contribute!
Groovy code to javascript
Just a tool, not a framework
Use with Node.js or other java frameworks
Last version 1.2.3
Gradle plugin
http://grooscript.org/gradle/tasks.html
plugins {

id "org.grooscript.conversion" version "1.2.3"

}
Convert files
grooscript {

source = ['src/main/groovy/gs']

destination = 'grails-app/assets/javascripts/generated'

initialText = '//Grooscript converted file'

}
bootRun.dependsOn 'convertThread'

compileGroovy.dependsOn 'convert'
task convertMyScript(type: org.grooscript.gradle.ConvertTask) {

source = ['src/main/groovy/MyScript.groovy']

mainContextScope = ['$']

destination = 'src/main/webapp/js'

includeDependencies = true

}
Groovy markup templates
templates {

templatesPath = 'grails-app/views/gtpl'

templates = ['list-links.gml']

destinationFile = 'grails-app/assets/javascripts/' +

'generated/Templates.js'

}



bootRun.dependsOn 'templatesThread'

compileGroovy.dependsOn 'templatesJs'
* can’t use groovy markup templates with g:render
p model.title

ul(class: "list-links") {

model.list.each { item ->

li {

a(href: item.url) {

p item.text

}

}

}

}
import org.grooscript.templates.Templates



Templates.applyTemplate('list-links.gml',

[title: 'Controllers', list: [

[url: 'grails.org', text: 'Grails'],

[url: 'grooscript.org', text: 'grooscript']

]]

)
list-links.gml
Spy file changes
spy {

files = [

'grails-app/assets/stylesheets/app.css',

'grails-app/views/reload/index.gsp'

]



onChanges = { list ->

//Or simpler http request

springWebsocketTo('http://localhost:8080/stomp')

.data('reload').onChannel('/app/reload')

}

}



bootRun.dependsOn 'spyChanges'
Grails 3 plugin
compile "org.grails.plugins:grooscript:1.2.2"
Setup
<!doctype html>

<html>

<head>

<asset:stylesheet src="application.css"/>

<asset:javascript src="jquery-2.2.0.min.js"/>

<asset:javascript src="grooscript-grails.js"/>



<g:layoutHead/>

</head>

<body>



<g:layoutBody/>

<asset:deferredScripts/>



</body>

</html>
Groovy code
<asset:javascript src="generated/Hello"/>
<grooscript:code>

import gs.Hello



$('body').append '''<footer><p>

<a href="http://grooscript.org">Grooscript Home</a> &&

<a href="https://twitter.com/grooscript">Twitter</a>

</p></footer>'''

new Hello().world()

</grooscript:code>
<grooscript:code>

def sing = { name ->

console.log 'Singing...' + name

}



Closure doSomething = { mapOfClosures ->

mapOfClosures.each { key, value ->

value(key)

}

}



$(document).ready doSomething([groovy: sing, grails: sing, grooscript: sing])

</grooscript:code>
Templates
<grooscript:template>

ul {

5.times { number ->

li number + " li item"

}

}

</grooscript:template>
Websockets
class ReloadController {



def index() { }



@MessageMapping("/reload")

@SendTo("/topic/reload")

protected String colors() {

return 'reload!'

}

}
compile "org.grails.plugins:grails-spring-websocket:2.3.0"
<!doctype html>

<html>

<head>

<meta name="layout" content="main"/>

<title>Reloading</title>

<asset:javascript src="spring-websocket" />

</head>

<body>

<grooscript:reloadOn path="/topic/reload"/>

<p class="reload-message">Change something in this gsp
or in application.css!</p>

</body>

</html>
<grooscript:initSpringWebsocket>

println 'Websocket is up!'

GrooscriptGrails.sendWebsocketMessage '/app/colors'

</grooscript:initSpringWebsocket>



<grooscript:onServerEvent path="/topic/colors">

allCubes(data)

</grooscript:onServerEvent>



<grooscript:template functionName="allCubes" onLoad="false" itemSelector="body">

table(id: "all-cubes") {

data.eachWithIndex { row, i ->

tr {

row.eachWithIndex { color, j ->

td(id: 'row-' + i + '-' + j,

class: 'cube ' + colors[color],

onmouseover: 'touch(' + i + ', ' + j + ')')

}

}

}

}

</grooscript:template>
Remote model
package rest
import grails.rest.Resource



@Resource(uri='/books', formats=['json'])

class Book {



String title

String author

}
* only json
<grooscript:code>

import rest.Book



def drawBooks = {

Book.list().then { list ->

$('#bookList').html ''

list.each {

appendBookToList(it)

}

}

}



def appendBookToList = { book ->

$('#bookList').append('<p>Title: '+book.title+' - Author: ‘
+ (book.author?: 'unknown') +'</p>')

}



def addBook = {

def title = $('#title').val()

def author = $('#author').val()

new Book(title: title, author: author).save().then {

appendBookToList(it)

}

}



$(document).ready {

drawBooks()

}


</grooscript:code>
Components
http://webcomponents.org
<asset:javascript src="webcomponents.min.js"/>
Custom elements - Shadow dom
<grooscript:component src="components.Counter" name="my-counter"/>
<p>Hello World!</p>

<my-counter></my-counter>

<my-counter value="3"></my-counter>
package components



class Counter {

static style = ''' 

div {

width: 100px;

}

'''

static renderAfter = ['inc', 'dec']

int value = 0

void inc() {

value++

}

void dec() {

value--

}

def render() {

div {

h1 value.toString()

p {

button(onclick: 'dec', '-')

button(onclick: 'inc', '+')

}

}

}

}
Links
Homepage: http://grooscript.org
Documentation: http://grooscript.org/doc
Github: http://github.com/chiquitinxx/grooscript
Demos: http://github.com/chiquitinxx/grooscript-demos
Gradle plugin: http://github.com/chiquitinxx/grooscript-gradle-plugin
Grails 3 plugin: http://grooscript.org/grails3-plugin/
All together: https://github.com/chiquitinxx/grails3-demo-grooscript
grooscript@gmail.com
@grooscript
Thank you!

Mais conteúdo relacionado

Mais procurados

GroovyFX - groove JavaFX Gr8Conf EU 2017
GroovyFX - groove JavaFX Gr8Conf EU 2017GroovyFX - groove JavaFX Gr8Conf EU 2017
GroovyFX - groove JavaFX Gr8Conf EU 2017sascha_klein
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeKAI CHU CHUNG
 
NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6Kostas Saidis
 
Groovy on the shell
Groovy on the shellGroovy on the shell
Groovy on the shellsascha_klein
 
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie..."How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...Fwdays
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.jsWebsecurify
 
Git Going for the Transylvania JUG
Git Going for the Transylvania JUGGit Going for the Transylvania JUG
Git Going for the Transylvania JUGMatthew McCullough
 
Take A Gulp at Task Automation
Take A Gulp at Task AutomationTake A Gulp at Task Automation
Take A Gulp at Task AutomationJoel Lord
 
The Gradle in Ratpack: Dissected
The Gradle in Ratpack: DissectedThe Gradle in Ratpack: Dissected
The Gradle in Ratpack: DissectedDavid Carr
 
Django & Buildout (en)
Django & Buildout (en)Django & Buildout (en)
Django & Buildout (en)zerok
 
淺談 Groovy 與 AWS 雲端應用開發整合
淺談 Groovy 與 AWS 雲端應用開發整合淺談 Groovy 與 AWS 雲端應用開發整合
淺談 Groovy 與 AWS 雲端應用開發整合Kyle Lin
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin WritingSchalk Cronjé
 

Mais procurados (18)

GroovyFX - groove JavaFX Gr8Conf EU 2017
GroovyFX - groove JavaFX Gr8Conf EU 2017GroovyFX - groove JavaFX Gr8Conf EU 2017
GroovyFX - groove JavaFX Gr8Conf EU 2017
 
Grunt.js introduction
Grunt.js introductionGrunt.js introduction
Grunt.js introduction
 
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with easeGDG Devfest 2019 - Build go kit microservices at kubernetes with ease
GDG Devfest 2019 - Build go kit microservices at kubernetes with ease
 
NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6
 
Gradle in 45min
Gradle in 45minGradle in 45min
Gradle in 45min
 
Groovy on the shell
Groovy on the shellGroovy on the shell
Groovy on the shell
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie..."How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.js
 
Git Going for the Transylvania JUG
Git Going for the Transylvania JUGGit Going for the Transylvania JUG
Git Going for the Transylvania JUG
 
Take A Gulp at Task Automation
Take A Gulp at Task AutomationTake A Gulp at Task Automation
Take A Gulp at Task Automation
 
groovy & grails - lecture 13
groovy & grails - lecture 13groovy & grails - lecture 13
groovy & grails - lecture 13
 
Web pack and friends
Web pack and friendsWeb pack and friends
Web pack and friends
 
The Gradle in Ratpack: Dissected
The Gradle in Ratpack: DissectedThe Gradle in Ratpack: Dissected
The Gradle in Ratpack: Dissected
 
Django & Buildout (en)
Django & Buildout (en)Django & Buildout (en)
Django & Buildout (en)
 
groovy & grails - lecture 10
groovy & grails - lecture 10groovy & grails - lecture 10
groovy & grails - lecture 10
 
淺談 Groovy 與 AWS 雲端應用開發整合
淺談 Groovy 與 AWS 雲端應用開發整合淺談 Groovy 與 AWS 雲端應用開發整合
淺談 Groovy 與 AWS 雲端應用開發整合
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin Writing
 

Destaque

From Grails to Android: A Simple Journey
From Grails to Android: A Simple JourneyFrom Grails to Android: A Simple Journey
From Grails to Android: A Simple JourneyAnnyce Davis
 
Mastering Grails 3 Plugins - Greach 2016
Mastering Grails 3 Plugins - Greach 2016Mastering Grails 3 Plugins - Greach 2016
Mastering Grails 3 Plugins - Greach 2016Alvaro Sanchez-Mariscal
 
Continuous Delivery As Code
Continuous Delivery As CodeContinuous Delivery As Code
Continuous Delivery As CodeAlex Soto
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovySteve Pember
 

Destaque (7)

Sobre GrooScript
Sobre GrooScriptSobre GrooScript
Sobre GrooScript
 
From Grails to Android: A Simple Journey
From Grails to Android: A Simple JourneyFrom Grails to Android: A Simple Journey
From Grails to Android: A Simple Journey
 
Greach 2016 dockerize your grails
Greach 2016   dockerize your grailsGreach 2016   dockerize your grails
Greach 2016 dockerize your grails
 
Geb for browser automation
Geb for browser automationGeb for browser automation
Geb for browser automation
 
Mastering Grails 3 Plugins - Greach 2016
Mastering Grails 3 Plugins - Greach 2016Mastering Grails 3 Plugins - Greach 2016
Mastering Grails 3 Plugins - Greach 2016
 
Continuous Delivery As Code
Continuous Delivery As CodeContinuous Delivery As Code
Continuous Delivery As Code
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of Groovy
 

Semelhante a grooscript & grails 3 overview

Django + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoDjango + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoJavier Abadía
 
AFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack EncoreAFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack EncoreEngineor
 
How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?Tomasz Bak
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part AKazuchika Sekiya
 
Custom gutenberg block development in react
Custom gutenberg block development in reactCustom gutenberg block development in react
Custom gutenberg block development in reactImran Sayed
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end WorkflowPagepro
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshowsblackman
 
20190118_NetadashiMeetup#8_React2019
20190118_NetadashiMeetup#8_React201920190118_NetadashiMeetup#8_React2019
20190118_NetadashiMeetup#8_React2019Makoto Mori
 
Javascript MVVM with Vue.JS
Javascript MVVM with Vue.JSJavascript MVVM with Vue.JS
Javascript MVVM with Vue.JSEueung Mulyana
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Matt Raible
 
Grooscript gr8conf
Grooscript gr8confGrooscript gr8conf
Grooscript gr8confGR8Conf
 
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsMeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsSimo Ahava
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalystsvilen.ivanov
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJsTudor Barbu
 
What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24Jim Jagielski
 
intro to Angular js
intro to Angular jsintro to Angular js
intro to Angular jsBrian Atkins
 
Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Joao Lucas Santana
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StoryKon Soulianidis
 

Semelhante a grooscript & grails 3 overview (20)

Django + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoDjango + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar Django
 
AFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack EncoreAFUP Lorraine - Symfony Webpack Encore
AFUP Lorraine - Symfony Webpack Encore
 
How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part A
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 
Custom gutenberg block development in react
Custom gutenberg block development in reactCustom gutenberg block development in react
Custom gutenberg block development in react
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end Workflow
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
 
20190118_NetadashiMeetup#8_React2019
20190118_NetadashiMeetup#8_React201920190118_NetadashiMeetup#8_React2019
20190118_NetadashiMeetup#8_React2019
 
Javascript MVVM with Vue.JS
Javascript MVVM with Vue.JSJavascript MVVM with Vue.JS
Javascript MVVM with Vue.JS
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017
 
Grooscript gr8conf
Grooscript gr8confGrooscript gr8conf
Grooscript gr8conf
 
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsMeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
 
What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24What's New and Newer in Apache httpd-24
What's New and Newer in Apache httpd-24
 
intro to Angular js
intro to Angular jsintro to Angular js
intro to Angular js
 
Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle Story
 
React
React React
React
 

Último

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
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
 
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
 
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
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Último (20)

H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
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
 
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
 
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)
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

grooscript & grails 3 overview

  • 1. grooscript & grails 3 Jorge Franco Leza Greach - Madrid - April 8th 2016
  • 2. About me Developer Between Madrid & Sevilla jorge.franco.leza@gmail.com @jfrancoleza
  • 3. About grooscript Apache 2 library In github, contribute! Groovy code to javascript Just a tool, not a framework Use with Node.js or other java frameworks Last version 1.2.3
  • 4. Gradle plugin http://grooscript.org/gradle/tasks.html plugins {
 id "org.grooscript.conversion" version "1.2.3"
 }
  • 5. Convert files grooscript {
 source = ['src/main/groovy/gs']
 destination = 'grails-app/assets/javascripts/generated'
 initialText = '//Grooscript converted file'
 } bootRun.dependsOn 'convertThread'
 compileGroovy.dependsOn 'convert' task convertMyScript(type: org.grooscript.gradle.ConvertTask) {
 source = ['src/main/groovy/MyScript.groovy']
 mainContextScope = ['$']
 destination = 'src/main/webapp/js'
 includeDependencies = true
 }
  • 6. Groovy markup templates templates {
 templatesPath = 'grails-app/views/gtpl'
 templates = ['list-links.gml']
 destinationFile = 'grails-app/assets/javascripts/' +
 'generated/Templates.js'
 }
 
 bootRun.dependsOn 'templatesThread'
 compileGroovy.dependsOn 'templatesJs' * can’t use groovy markup templates with g:render
  • 7. p model.title
 ul(class: "list-links") {
 model.list.each { item ->
 li {
 a(href: item.url) {
 p item.text
 }
 }
 }
 } import org.grooscript.templates.Templates
 
 Templates.applyTemplate('list-links.gml',
 [title: 'Controllers', list: [
 [url: 'grails.org', text: 'Grails'],
 [url: 'grooscript.org', text: 'grooscript']
 ]]
 ) list-links.gml
  • 8. Spy file changes spy {
 files = [
 'grails-app/assets/stylesheets/app.css',
 'grails-app/views/reload/index.gsp'
 ]
 
 onChanges = { list ->
 //Or simpler http request
 springWebsocketTo('http://localhost:8080/stomp')
 .data('reload').onChannel('/app/reload')
 }
 }
 
 bootRun.dependsOn 'spyChanges'
  • 9. Grails 3 plugin compile "org.grails.plugins:grooscript:1.2.2"
  • 10. Setup <!doctype html>
 <html>
 <head>
 <asset:stylesheet src="application.css"/>
 <asset:javascript src="jquery-2.2.0.min.js"/>
 <asset:javascript src="grooscript-grails.js"/>
 
 <g:layoutHead/>
 </head>
 <body>
 
 <g:layoutBody/>
 <asset:deferredScripts/>
 
 </body>
 </html>
  • 11. Groovy code <asset:javascript src="generated/Hello"/> <grooscript:code>
 import gs.Hello
 
 $('body').append '''<footer><p>
 <a href="http://grooscript.org">Grooscript Home</a> &&
 <a href="https://twitter.com/grooscript">Twitter</a>
 </p></footer>'''
 new Hello().world()
 </grooscript:code> <grooscript:code>
 def sing = { name ->
 console.log 'Singing...' + name
 }
 
 Closure doSomething = { mapOfClosures ->
 mapOfClosures.each { key, value ->
 value(key)
 }
 }
 
 $(document).ready doSomething([groovy: sing, grails: sing, grooscript: sing])
 </grooscript:code>
  • 12. Templates <grooscript:template>
 ul {
 5.times { number ->
 li number + " li item"
 }
 }
 </grooscript:template>
  • 13. Websockets class ReloadController {
 
 def index() { }
 
 @MessageMapping("/reload")
 @SendTo("/topic/reload")
 protected String colors() {
 return 'reload!'
 }
 } compile "org.grails.plugins:grails-spring-websocket:2.3.0"
  • 14. <!doctype html>
 <html>
 <head>
 <meta name="layout" content="main"/>
 <title>Reloading</title>
 <asset:javascript src="spring-websocket" />
 </head>
 <body>
 <grooscript:reloadOn path="/topic/reload"/>
 <p class="reload-message">Change something in this gsp or in application.css!</p>
 </body>
 </html>
  • 15. <grooscript:initSpringWebsocket>
 println 'Websocket is up!'
 GrooscriptGrails.sendWebsocketMessage '/app/colors'
 </grooscript:initSpringWebsocket>
 
 <grooscript:onServerEvent path="/topic/colors">
 allCubes(data)
 </grooscript:onServerEvent>
 
 <grooscript:template functionName="allCubes" onLoad="false" itemSelector="body">
 table(id: "all-cubes") {
 data.eachWithIndex { row, i ->
 tr {
 row.eachWithIndex { color, j ->
 td(id: 'row-' + i + '-' + j,
 class: 'cube ' + colors[color],
 onmouseover: 'touch(' + i + ', ' + j + ')')
 }
 }
 }
 }
 </grooscript:template>
  • 16. Remote model package rest import grails.rest.Resource
 
 @Resource(uri='/books', formats=['json'])
 class Book {
 
 String title
 String author
 } * only json
  • 17. <grooscript:code>
 import rest.Book
 
 def drawBooks = {
 Book.list().then { list ->
 $('#bookList').html ''
 list.each {
 appendBookToList(it)
 }
 }
 }
 
 def appendBookToList = { book ->
 $('#bookList').append('<p>Title: '+book.title+' - Author: ‘ + (book.author?: 'unknown') +'</p>')
 }
 
 def addBook = {
 def title = $('#title').val()
 def author = $('#author').val()
 new Book(title: title, author: author).save().then {
 appendBookToList(it)
 }
 }
 
 $(document).ready {
 drawBooks()
 } 
 </grooscript:code>
  • 18. Components http://webcomponents.org <asset:javascript src="webcomponents.min.js"/> Custom elements - Shadow dom <grooscript:component src="components.Counter" name="my-counter"/> <p>Hello World!</p>
 <my-counter></my-counter>
 <my-counter value="3"></my-counter>
  • 19. package components
 
 class Counter {
 static style = ''' 
 div {
 width: 100px;
 }
 '''
 static renderAfter = ['inc', 'dec']
 int value = 0
 void inc() {
 value++
 }
 void dec() {
 value--
 }
 def render() {
 div {
 h1 value.toString()
 p {
 button(onclick: 'dec', '-')
 button(onclick: 'inc', '+')
 }
 }
 }
 }
  • 20. Links Homepage: http://grooscript.org Documentation: http://grooscript.org/doc Github: http://github.com/chiquitinxx/grooscript Demos: http://github.com/chiquitinxx/grooscript-demos Gradle plugin: http://github.com/chiquitinxx/grooscript-gradle-plugin Grails 3 plugin: http://grooscript.org/grails3-plugin/ All together: https://github.com/chiquitinxx/grails3-demo-grooscript grooscript@gmail.com @grooscript