The other day, I showed how to prettify Google Apps Script snippets and scriptDB contents, include them in web sites, blogs and google sites, and encode them in jSon and jSonP using the GAS content service and html service. This provides a simple way to share your code.
I figured that I could probably take Gist samples via Google Apps Script and pass them through the same prettifier. Here is the container that does that. What we are looking at here is a little bit of html code embedded in this blog as follows.
<iframe height="400" src="https://storage.googleapis.com/toasty/p/gaspubcontainer.html?source=gist&library=4117688&module=gaspubcontainer.html" width="100%"></iframe>
What is happening here?
Using exactly the same technique as with publishing the Apps Script, I’m using a Google Apps Script template to output the gist code, which has been read by GAS. Here’s the entire library code (inserted with the code below)
<iframe height="400" src="https://storage.googleapis.com/toasty/p/gaspubcontainer.html?source=script&library=mcpher&module=gasPub" width="100%"></iframe>
Parameters
For a full description of the parameters, see the Excel Liberation site.
In the case of the above we use source=gist or source=script to indicate where the source data is coming from, library=mcpher or library=4117688 to identify either the GAS library or the gist ID, and module=gasPub or module=gaspubcontainer.html to identify the module name or the gist fileName. If this is blank for source=gist, then all code in all filenames in that Gist will be shown.
https://storage.googleapis.com/toasty/p/gaspubcontainer.html? is typically used for embedding in preference to calling the GAS module directly. This gets round cross domain problems associated with the GAS content service. If you are only embedding Gists, then you can use all this with no changes. Just use the gaspubcontainer.html as described, with your parameters. If you are planning to publish your own GAS code or scriptDB contents, you will need need to copy the GAS code and attach your own libraries as described on the Excel Liberation site.