ebook img

Google Apps Script: Web Application Development Essentials PDF

269 Pages·2014·5.38 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Google Apps Script: Web Application Development Essentials

Google Apps Script James Ferreira Preface If you are reading this book, there is a good chance you have heard of Google and its powerful office productivity suite, Google Apps. Google offers search, email, word processing, and hundreds of other cloud applications and services that are available to individuals but can scale all the way up to serve massive corporations and governments. As one of Google’s most popular services, Google Apps offers some of the best online office products available; they’re an excellent example of web-based applications that outperform legacy desktop software. This book is about Google Apps Script, which is a service that runs from Google Apps, like Sites and Documents. Google Apps Script is extremely powerful when automating many of the tasks required by day-to-day spreadsheet operations, but it also scales up to provide a complete application platform. If you are coming from a Microsoft Office environment, you can think of it as the macros for Google Docs, but unlike simple macros in MS Office, Google Apps Script has a mature online editor with all the features one would expect in a development platform. Unleash Google Script’s user interface capability and you can create entire data-driven websites and applications that run across most modern browsers, including mobile ones. In addition to the integrated development environment (IDE), Google Apps Script comes with a manager for organizing scripts, built-in debugging, automatic code completion, timed event triggers, and automated revisioning, to name a few features. What really caught this author’s attention was that everything is web-based. There is no need to download and configure a code editor or transport development files from computer to computer, wasting time resynchronizing files and reconnecting libraries. Simply sign into your Google account and start creating. Google Apps Scripts are written in JavaScript, so there is no need to compile the code, making application development very fast. With its own set of libraries, Google Apps Script can interact with most of the services provided by Google, making it the “Swiss Army knife” behind the main products. Other application-building methods for accessing Google products, such as App Engine and the gData APIs (offered in many different languages), all require a place for you to develop and deploy your code. With Google Apps Script, you are building the code into the existing Google platform, and that provides a robust experience where your products inherit Google’s legendary 99.9 percent availability. Because there is no need to have anything more than a basic Internet-connected browser, development on this platform is something anyone can get started with, without any up-front expense. Google Apps Script is not locked inside Google, where it can only talk to Google servers; rather, it can communicate through JDBC, JSON, and SOAP, and it has a urlFetch method, making it very versatile when communicating across the Web. At Google I/O 2012 a new feature called HTML Service was unveiled, giving Google Apps Script programmers the ability to build custom user interfaces that can run inside a spreadsheet window as a Google gadget or completely independently in a browser. Talk about earth-shattering: a cloud programing platform that can access just about any web-based service and has the ability to create AJAX-style web pages? That is noteworthy. To date, Google Apps Script is the only way to gain full access to Gmail at the message level, and more services are added every year. This book will focus on teaching you how to build powerful web applications using Google Apps Script. It is laid out in sections that explain how the different parts of Google Apps Script work and puts all these together in a series of fully functional applications that you can put to work right away. Who Should Read This Book This book is perfect for anyone who wants to extend what can be done with Google Apps but is not ready to dive into the complicated world of the Google Web Toolkit and Java APIs. You don’t have to be a webmaster or programmer to grasp the concepts in this book. Google Apps Script takes care of server configuration, gives you a place to save your projects, and allows you to start developing immediately. This book is approachable by anyone with basic coding skills and a fundamental understanding of JavaScript. If you have never used JavaScript, I recommend having a copy of Head First JavaScript (O’Reilly) close at hand to help you through concepts like variables, arrays, and objects. All the application examples have highly detailed explanations, so if you are a Google Apps power user, you should not have difficulty grasping the content in this book and writing incredible applications using Google Apps Script. What You Will Need You will need a web browser (I recommend Chrome) and any type of Google account. That’s it! Google Apps Script is a completely web-based solution that is free and ready for you to start programming today. Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, and file extensions. Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords. Constant width bold Shows commands or other text that should be typed literally by the user. Constant width italic Shows text that should be replaced with user-supplied values or by values determined by context. TIP This element signifies a tip or suggestion. NOTE This element signifies a general note. WARNING This element indicates a warning or caution. Using Code Examples At the end of each chapter you will find the full code used to create that chapter’s project. In addition, you may access all the files used to create this book in the book’s Drive folder. This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD- ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Google Apps Script by James Ferreira (O’Reilly). Copyright 2014 James Ferreira, 978-1-491-94618-3.” If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at [email protected]. Safari® Books Online Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business. Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training. Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online. How to Contact Us Please address comments and questions concerning this book to the publisher: O’Reilly Media, Inc. 1005 Gravenstein Highway North Sebastopol, CA 95472 800-998-9938 (in the United States or Canada) 707-829-0515 (international or local) 707-829-0104 (fax) We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://oreil.ly/google-script. To comment or ask technical questions about this book, send email to [email protected]. For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com. Find us on Facebook: http://facebook.com/oreilly Follow us on Twitter: http://twitter.com/oreillymedia Watch us on YouTube: http://www.youtube.com/oreillymedia Part I. Understanding Google Apps Script Chapter 1. First Steps in Google Apps Script What is Google Apps Script and why should you use it to build applications? Simply put, Google Apps Script is an easy way to figuratively glue Google and other web services together to form one powerful, interactive web application. Just ahead, you’ll get a more in-depth explanation of Google Apps Script and how to use it to enhance existing Google Apps. You will also learn the basics of building an application. This first chapter should get your feet firmly planted on the ground floor of the Google Apps Script development platform and demystify its usage. Google Apps Script Is… Google Apps Script is a coding and application development platform built into Google Apps, enabling you to add functionality to spreadsheets, Gmail, Sites, and other services from Google. For example, if your spreadsheet needs a menu item in the toolbar for creating a pivot table, you can write a Google Apps Script that adds it to the menu and performs the task. Google Apps Scripts can be created as standalone files in Drive, inside a document or spreadsheet (these are known as container-bound), or in a Google Site. This book will focus extensively on the concept of using Google Apps Script to build applications that present themselves as web services running independently of other interfaces. You will learn how to use Google Apps Script to build apps that run from a spreadsheet, in a browser window, or within a Google Site; from the user’s perspective, they will appear to be complete applications such as you might expect when using a web service like Picasa or Gmail. There are some real advantages to having your scripts (i.e., applications) stored in one of the Google Apps services. Primarily, security is already built in, meaning you do not need to worry about implementing that component in your application as you would if it were running on a legacy web server needing patches and constant monitoring for malicious attacks. As part of Google Apps, Google Apps Script also offers you the same collaborative development abilities that are part of the Apps suite. What is truly exciting about Google Apps Script is that it is a 100 percent web development environment that requires no transferring of files from computer to computer, backups, revision control, uploads to a production server, updating of development software, or many of the other tedious aspects of development that get in the way of actually writing applications. These parts are all built in, allowing you to focus on creating products for your business, school or club, or anything else that needs to run on the Web. TIP If you are an advanced developer coming from Google App Engine, don’t worry; there is a plug-in for Eclipse that will allow you to work on the files locally, and they will automatically be pushed up to Google. There are three ways to create user interfaces (UIs) in Google Apps Script: with the older UiApp Service, as gadgets for Google Sites, and using the HTML Service. The UiApp Service, which stands for User Interface App, was released in early 2010 as a way to allow developers to collect user input that could be sent back to a script for processing. UiApp uses the Google Web Toolkit (GWT) widget set as the framework for building an interface. Widgets allow you to create things like text boxes and submit buttons, as well as more complex items like flex tables and listboxes. Everything you see in a Google Apps Script UI is a widget cleverly arranged within a frame in the page. The only other elements— panels—are the containers that hold all your widgets…and that is truly all there is to the visual part of a Google Apps Script UI. If you are familiar with GWT, you will be right at home creating UIs in Google Apps Script using UiApp. At the 2013 Google I/O, Google Apps Script received a major update to the way UIs are presented. The new HTML Service uses standard HTML, Cascading Style Sheets (CSS), and JavaScript to display pages. This means you don’t need to worry about learning the intricacies of GWT, and you can use many existing JavaScript libraries, like jQuery. As of this writing Google is using Caja, which

Description:
Learn how to create dynamic web applications with Google Apps Script and take full advantage of your Google-hosted services. If you have basic coding skills and some JavaScript experience, this practical book shows you how Apps Script works, and provides step-by-step guidance for building applicatio
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.