I wasn’t completely satisfied with the distribution method for the assets associated with my first Apps Script book and subsequent video course. Most of the assets were Apps Script files, and the delivery method was via GitHub or as part of the downloadable package, or the DVD for the video course.
The problem with the GitHub approach is that Apps Script files are simply links and cant be executed outside the context of Drive, so it meant you had to pull the links from github to Drive, then open them and make a copy of the script project or Doc. As an additional option, I also published all the source code on Github, but of course that means reconstructing the project files from each individual script file.
Drive is great for collaborating, but not so good for distributing – where the intention is for users to have their own private copy of the assets so they can edit them and play around with them in their own time. I decided I needed to do something in addition for my next video course, ‘Google Apps Script for Beginners’, which will be published by O’Reilly media later this year, especially since those unfamiliar with Apps Script could have some difficulty with the concept of copying a script to get their own version.
To solve this problem, I put together a webapp in Apps Script, that would copy assets in a folder to a users own Drive. That way, copies of assets can be delivered by simply clicking on a link. See here
for details of how that works.
Using the already published webapp.
If you want to use this mechanism to deliver copies of your own assets, then one way is to re-use the already published webapp. The example below copies the source code and documentation of the webapp to a folder in your Drive. To create a link to copy your own assets, simply set the sourceid parameter to the folder id of the folder you wish to share (you also need to set the sharing mode of that folder to public, or at least specifically to the people you want to have access of course), and the target parameter to the name of a folder you’d like to be created on the user’s Drive to hold a copy of your files.
To distribute, and fix to a specific set of parameters, you may want to first visit goo.gl and create a shortened version of the complete URL. In any case, you would simply distribute the long or shortened link, and this would happen when the user clicked on the link.
Creating your own version of the webapp
If you’d prefer to have your own version of the webapp, first you’d need to get the source code. The simplest way to do that is to use the webapp itself to deliver a copy of its own source code using this link.
Alternatively you can pick it up from github
and build your own.
- open the script
- go to manage versions and save a version of the script
- authorize and publish as a webapp, setting the access appropriately, and choosing to run as the user
Thereafter use your published weblink instead of mine.