FLORIAN LOITSCH: Thanks.
So my name is Florian, and I want
to present you how to write Google Apps Scripts in Dart.
So I have only two slides, and one of them was the title.
Mainly it's because I want to make
sure you understand the difference between Google Apps
Script and Google APIs.
So one of them, the Google App Scripts,
is the scripting language you use
or the scripts you use to control Google Drive, Gmail,
spreadsheets, docs, and so on, and Google APIs is
a RESTful service where you can access many--
a RESTful API where you can access many, many more Google
services.
I use both in this talk.
So Google APIs, that's the REST, and Google Apps Scripts,
that's controlling the docs, and so on.
So what-- no, that's not the one.
So what is a Google Apps Script?
So here I have a spreadsheet.
And if we go to Tools, Script Editor,
we can write a small script-- let's
say, a spreadsheet app that gets UI and dot alert "Hello world."
We save it.
This is, somewhere, the Run button.
Run.
And we have a hello world on the spreadsheet.
I mean, this is the easiest thing to do.
So there are two things we don't like
about the way this is written with the Google Apps Editor.
One is it's JavaScript--
[AUDIENCE LAUGHING]
--and the second one is--
so, no, no, it's not Dart.
And the second one is it's not using the editor that we like,
and it's not using Git, and so on.
So for the first thing, not using Dart,
we can actually make that work quite nicely
by using Dart-to-JavaScript and compiling to JavaScript.
So here I have a demo ready where it's just compiled
with Dart-to-JavaScript.
And the important thing here is that when
you compile for Google Apps Script,
you need to use the CSP flag, but once you
have that and a few other things, it kind of works.
And now, the second part we want is we want to take that code
and actually get this ready for--
get this deployed on our scripts.
And for that, I wrote another app that watches a specific
directory-- so in this case, the file that it just compiled--
then automatically uploads it using Google APIs--
so we just use the thing to connect to the drive--
and then creates a script on our Google Drive.
So once we do that and we load--
I should load it like this--
and we load the apps, you can see
there is an add-ons up behind the work in this add-ons
in Help, and once it has loaded enough,
it actually adds now a new menu item that we created.
And when I run this one, we now run the Dart Hello World.
And I can show you the actual code for that.
It's here, down there.
And if I changed it, let's say, "Hello Dartconf."
Save it.
Recompile it.
And watch in the background the script that uploads.
Once it's compiled, it automatically
detects that it has been changed, uploads it again.
And if you now go back to the spreadsheet,
we can now run that thing again, and it's now "Hello Dartconf."
[APPLAUSE]
Thank you.
So pretty much, that's the most important thing
about the Google Apps scripting.
It's a very nice workflow and so on.
But I have prepared two more demos.
So if we go to the demo 2--
and again, in the background, I should show this.
If I compile now, it will automatically
upload in the background--
uploading done.
And if we now--
there it is-- run it again, we should get--
this is a little bit bigger.
This is now a script that just modified the columns, and so
on, and set the background color.
[APPLAUSE]
And the last demo just shows that it's
not just Google spreadsheets that we can control.
We can also modify and create Google Docs.
But let's see that.
So the first thing it's going to do it will show as a sidebar.
So you can write sidebars.
Those are actually HTML, so there's a little bit of HTML,
and so on.
So if I now select or some other things--
some old dialogs-- so this one now
connects back to the server.
Then there's a script that runs, which is, again, Dart script.
In this case, I created a document,
and that document now shows us that we also have a document--
Google Docs that can be controlled from Dart.
And with that, I finished my talk.
Thank you.
[APPLAUSE]
Oh yes-- it's not open source yet,
but I will try to make that happen.
SPEAKER 1: That's great.
Thanks.