How to use Google Apps Script to serve a Google Calendar/Email gadget? - gmail

I would like to develop a calendar/gmail gadget for our Google Apps for Business domain using Apps Script to leverage all of the benefits it affords.
When replicating the Hello World gadget example:
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="hello world example" />
<Content type="html">
<![CDATA[
Hello, world!
]]>
</Content>
</Module>
Using a template XML doGet():
function doGet(e) {
var output = ContentService.createTextOutput();
var xml = '<?xml version="1.0" encoding="UTF-8" ?>\n<Module>\n<ModulePrefs title="Calendar Gadget" />\n<Content type="html"><![CDATA[\nHello, world!\n]]></Content>\n</Module>';
output.setContent(xml);
output.setMimeType(ContentService.MimeType.XML);
return output;
}
The resultant served content is identical to the example Gadget which installs fine, but served from GAS it isn't recognised as valid. Calendar ignores it and GMail declares it invalid.
Invalid gadget specification. Ensure that URL is correct and the gadget does not contain errors.
Is part of the requirement for a Google Apps Gadget that it be served using an *.xml filename?

doGet() does not return the XML (or HTML) verbatim. There is a difference in the exact content provided to the browser and the content returned by doGet().
So, the answer to your question is - yes, you need to have an XML file for a Google Gadget and cannot use Apps Script. What you can perhaps do is use Apps Script to write out the XML file.

The content served using the ContentService should be identical to the input provided. Please ensure that the web app is configured to allow anonymous access.

Related

Gmail Apps Marketplace contextual gadget only HelloWorld extractor works

I'm developing a google contextual gadget for Apps Marketplace based on this resource https://developers.google.com/gmail/contextual_gadgets.
I've enabled all the necessary APIs, and after configuring the Apps Marketplace SDK and setting up the contextual gadget extractor to google.com:HelloWorld was able to see the gadget on an email containing "Hello World" in the subject and body.
The problem is that none of the other extractors make the gadget appear. I have tried different combinations of Extractor Urls, params and scopes. The gadget won't appear in the email.
The content of the test.xml
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="MessageID" description="" height="20" author="personal" author_email="..." author_location="local">
<Require feature="dynamic-height"/>
<Require feature="google.contentmatch">
<Param name="extractors">
google.com:MessageIDExtractor
</Param>
</Require>
</ModulePrefs>
<Content type="html" view="card">
<![CDATA[
<script type="text/javascript">
document.body.appendChild(document.createTextNode("messageId test"));
</script>
]]>
</Content>
</Module>
extractor configuration
Thanks.
I made to work other extractors, try to follow this pattern: gadget settings
Supported values for Extractor param name: from_email, to_email, cc_email, bcc_email, date_sent, date_received, subject, body, id, list_id, list_unsubscribe

Google Sites Gadget with Javascript

I created a simple slideshow script to include on a Google Site for Google+ albums (it uses a library found at: https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/picasa-services). The test version worked except for the fact that if publish for anonymous access, it displays that aweful "This application was not created by Google" nonsense at the top. As this is a slideshow, I tried finding a way to avoid this. Thus I decided to try my hand at a Gadget. I opted to use Google Gadget Editor and combed through the internet to see how to do this (I am a complete noob with regards to gadgets, so excuse my ignorance...)
In the end I came up with this: http://hosting.gmodules.com/ig/gadgets/file/117039901033759910299/google-plus-slider.xml
Once I insert the gadget, I do not get any error messages and the frame does display on my google site (without the warning message, as far as I can tell), but nothing else happens. And I have no idea why.
Some notes:
the javascript works when it is a google apps script, published and then inserted in my site (but the warning message is ugly)
I have no idea whether it is even possible to call typical GAS calls such as Ui.App in XML gadget - if not, then I will have to learn, but don't know where.
Obviously the library that I am using needs to be loaded - I researched as much as I could but cannot find any way to load the library. The only option I could find was to include specific predefined libraries with the Required tag.
I hope you have all the info and that someone can help! Thanks in advance.
Do you get any Cross-Domain warnings in your console?
I would try and include the external library in your gadget-name.xml file. You're free to include (mostly) whatever JS you like under
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs
title="Slider"
height="50"
width="200"
border="none"
/>
<Content type="html">
<![CDATA[
<script type="text/javascript">
function my-slide-show(){
//Dump your lib JS here
}
</script>
<div class="slideshowHtml"></div>
]]>
</Content>
</Module>
This will at least avoid any scoping / Cross origin worries you might be having

Possible to upload a public GoogleDoc using Google Docs List API?

I am creating a web app where I would like the user to be able to manipulate contents of a spreadsheet that do not get saved to the original spreadsheet-- in effect so that multiple users can access the same spreadsheet and the data/formulas contained without interfering with one another.
If my spreadsheet is public, is there a way for users to upload it programmatically using the docs list API? That way they have a copy saved where they can make whatever changes desired.
Thank you!
You can copy a spreadsheet by issuing a POST request as documented here:
POST https://docs.google.com/feeds/default/private/full
Authorization: <your authorization header here>
Content-Type: application/atom+xml
[Additional headers]
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
<id>[SELF_LINK_OF_THE_ORIGINAL_DOCUMENT]</id>
<title>My Copy</title>
</entry>

how to see ready HTML after xsl-transformation in a browser?

I have xml with header xml-stylesheet that indicates to xsl
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="1.xsl" type="text/xsl"?>
<root>
......
</root>
In a browser this will transform to html. How to see ready HTML after xsl-transformation in the browser? If I choose View Source I see XML of course. I'm interested in Firefox and Explorer
You can use the DOM inspector instead of source viewer.
You could install the FireBug plugin in Firefox, this shows you the currently active DOM, which is your generated HTML.
https://addons.mozilla.org/de/firefox/addon/1843/

How do I create a SharePoint 2007 list from a template via web service?

I have a SharePoint 2007 custom list that I have saved as a list template. I am looking for a way to create a new list from the saved template via a web service call from an outside application.
I have already looked into the the basic web services available for SharePoint 2007 http://msdn.microsoft.com/en-us/library/bb862916(office.12).aspx but a call to that just creates a simple, empty custom list.
How do I instantiate a list from a specific template? How do I locate the Feature ID for the template?
You can use a HTTP debugger like fiddler2 to analyze the web service and remote procedure calls that SharePoint Designer makes to find this out.
For example, to get the available list templates, SPD makes an HTTP request using the DisplayPost RPC command, e.g.
POST http://[server]/[web]/_vti_bin/owssvr.dll?Cmd=DisplayPost
with an xml payload of:
<?xml version="1.0" encoding="UTF-8"?>
<ows:Batch OnError="Return" Version="12.0.0.000">
<Method ID="0,GetProjSchema">
<SetVar Name="Cmd">GetProjSchema</SetVar>
</Method>
</ows:Batch>
SPD then parses the ListTemplates node in the response to obtain a list of template names, types, and feature IDs.
To create the list from a specific template type or feature ID, SPD uses the same DisplayPost command, this time with a message body similar to:
<?xml version="1.0" encoding="UTF-8"?>
<ows:Batch OnError="Return" Version="12.0.0.000">
<Method ID="0,NewList">
<SetVar Name="Cmd">NewList</SetVar>
<SetVar Name="ListTemplate">108</SetVar>
<SetVar Name="Title">Discussion Board</SetVar>
<SetVar Name="FeatureId">00bfea716a4943fab535d15c05500108</SetVar>
<SetVar Name="RootFolder" />
<SetVar Name="LangID">1033</SetVar>
</Method>
</ows:Batch>
For an example of how to use the RPC protocol see this post on uploading files to a SharePoint document library (it uses the author.dll rather than the owssvr.dll, but the technique is similar).

Resources