Monday, October 19, 2009

g-osc-user-cont (Ubiquity command)

function open_usercontributionspage(arguments) {

if(arguments.object.text!="")
Utils.focusUrlInBrowser("http://se.bigbuddysociety.net/wiki/index.php?title=Special:Contributions/"
+ arguments.object.text);
else
Utils.focusUrlInBrowser("http://se.bigbuddysociety.net/wiki/index.php?title=Main_Page");
}

CmdUtils.CreateCommand({

names: ["g-osc-user-cont"],
author: { name: "Mostafa ELkhouly", email: "mostafa-khouly@hotmail.com"},
description: "Go to the G-OSC User contributions page.",
arguments: [{role: "object", nountype: noun_arb_text,label: "Username"}],
execute: open_usercontributionspage,
icon: "http://se.bigbuddysociety.net/wiki/images/c/c4/GOSC-Logo-135.png",
preview: function (pblock){
pblock.innerHTML = "Go to the G-OSC User contributions page\t"
+'<http://se.bigbuddysociety.net/wiki/images/c/c4/GOSC-Logo-135.png/>';}
})


This is the code of my first Ubiquity command, it is called "g-osc-user-cont", it is a very simple command it takes a username as an argument, and opens the contribution page of this username (if it is a valid username), but if the command is used without an argument it just opens the g-osc home page in a new tab. The command also uses the g-osc logo as an icon and it also appears in the preview window along with some text.

Now I am going to talk about the implementation of the command, I think that the action of "names", "author", "description" and "icon" are quite obvious, so I am going to start with the "preview" which contains a function that adds some text and g-osc logo to the preview page of the command. The second part is the "execute" which calls the "open_usercontributionspage" with the arguments if any, this function checks the argument and extracts the text from it, if the text is empty it just goes to the g-osc home page, in any other case it uses the text of the argument to open the contributions page for the given text (even if it isn't a valid username), and that's it.

One more thing I would like to thank Abdallah Elgindy for his blog post about using Utils.focusUrlInBrowser() instead of Utils.openUrlInBrowser().

My first post

Hello,
First of all I am going to start by introducing myself. My name is Mostafa Elkhouly, I'm a computer science graduate from the GUC and currently I'm doing my pre-masters courses. This is my first post on a blog on my first blog, and I don't even like blogs :D. I'm just going to say what comes to my mind about this course (Open Source Development course), I am going to start by talking about the reviews I hate them !!!, and till now I don't know why are we doing them, and the best thing about the reviews is that my review was removed from the topics :D what an "egoboo". Btw after sharing my feelings towards this course on the blog I feel much better, maybe this blog will help me survive this course :). One more thing, the best thing in course up till now is the cookies : D.

Soon I will post a feedback about my g-osc-user-cont (ubiquity command), and about the last lab, I didn’t have my laptop so I worked with Eng. Omar Roushdy, he is a very nice person, I hope we stay friends forever.