In How to embed gist samples in Google Sites I showed how to publish your source code in your web site. This still means that we need to create a Gist as well as maintain the code in Google Apps Script. this post about the scriptApp class shows how to publish your code from your Google Script through a web App. Now we want to embed that published code in a Google Site.
Well we can't simply put html generated by the Google Apps Html service (here's an example) in an iFrame gadget, because that results in this error "display forbidden by X-Frame-Options", so we have to figure out some other solution.
Here's the code, embedding itself in this gadget.
and the shared code from the mcpher library
For how to do this see