I am trying to create a Google Apps Script Gadget for my google sites page. The gadget should display a list of 3 URLs to links within the site based on a search string.
e.g. a site contains many articles on dogs. A user opens up an article on “how to train your dog”. At the bottom of the page would be the gadget listing 3 other articles with similar key words.
//global constants
var SEARCH_KEY = "train your dog"
// Script-as-app template.
function doGet() {
var app = UiApp.createApplication();
var mySite = SitesApp.getSite('mysite.com','mysite');
var advancedArgs = {max:"3"};
var page = mySite.search(SEARCH_KEY, advancedArgs);
for (i = 0; i < page.length;i++)
{
app.add(app.createHTML('<a href=\"' + page[i].getUrl() + '\">' + page[i].getTitle() + '</a>'));
app.create
}
return app;
}
However, the createHTML function only seems to accept basic formatting such as bold, itallic. Does anyone have any ideas on how to create a list of URLs within a gadget?
There is a special widget for this purpose : createAnchor(“a link”, “www.google.com”);
in which you can define the shown string and the link…
EDIT : for info, here is a list of allowed HTML tags in UiApp HTML widget 🙁release note March 7, 2012)
Added the ability to include a limited set of HTML tags when working with UiApp widgets, in response to this issue. Here is the list of HTML tags that are permitted: B, BLOCKQUOTE, BODY, BR, CENTER, CAPTION, CITE, CODE, DIV, EM, H1, H2, H3, H4, H5, H6, HR, I, LABEL, LEGEND, LI, OL, P, SPAN, STRONG, SUB, SUP, TABLE, TBODY, TD, THEAD, TITLE, TR, TT, UL