Changes

Jump to: navigation, search

Labs/Ubiquity/Locked-Down Feed Tutorial

831 bytes added, 17:33, 17 March 2009
Added more
== A Lot Like Regular Feeds ==
LD Feeds are best thought of as a strict subset of regular feeds. For instance, commands are created using <code>CmdUtils.CreateCommand()</code> and <code>displayMessage()</code> works too, so the code for our "Hello World" example is exactly the same as in our [[Labs/Ubiquity/Ubiquity_Source_Tip_Author_Tutorial#Using_CreateCommand|Author Tutorial]]for regular feeds:
<pre>
CmdUtils.CreateCommand({
name: "hello-world",
preview: "Displays a <i>salutary</i> greeting to the planet.",
execute: function() {
displayMessage("Hello, World!");
});
</pre>
 
Setting the selection works [[Labs/Ubiquity/Ubiquity_Source_Tip_Author_Tutorial#Setting_the_Selection|the same way]] too, as does [[Labs/Ubiquity/Ubiquity_Source_Tip_Author_Tutorial#Documentation_and_Metadata|documentation and metadata]]:
 
<pre>
CmdUtils.CreateCommand({
name: "date",
homepage: "http://azarask.in/",
author: {name: "Aza Raskin", email: "aza@mozilla.com"},
contributors: ["Atul Varma"],
license: "MPL",
description: "Inserts today's date.",
help: ("If you're in an editable text area, inserts " +
"today's date, formatted for the current locale."),
 
execute: function() {
var date = new Date();
CmdUtils.setSelection(date.toLocaleDateString());
}
});
</pre>
 
== Telling Ubiquity The Feed Type ==
The only thing we really need to change is to tell Ubiquity that it should interpret the code as a LD Feed instead of a regular one. You can do this in Ubiquity's built-in command editor by specifying "locked-down-commands" in the feed type drop-down menu. When [[Labs/Ubiquity/Ubiquity_Source_Tip_Author_Tutorial#Sharing_it_with_the_World|sharing it with the world]], you use a value of <code>locked-down-commands</code> for the <code>rel</code> attribute in the <code>link</code> tag:
874
edits

Navigation menu