Making alias creation a first class citizen of Ubiquity

9 views
Skip to first unread message

lrbabe

unread,
Feb 10, 2009, 9:18:08 PM2/10/09
to ubiquity-firefox
Hello everybody,

As I told you last week, I am working on extending the CmdUtils API to
make it easier to create aliases for existing Ubiquity command both
programmaticaly and _from the command line_.

I would like to show you what I have achieved so far, hoping that you
will be interested enough to help me a little bit, as I am quite an
Ubiquity beginner (but proud to make my first steps in the Mozilla
universe : )

Currently in Ubiquity it is already possible to define synonyms for a
command, but it is impossible for any one else than the creator of the
command to do so, because it requires to modify directly the source
code of the command, and changes will be overwritten as soon as the
feed will be updated.

I am trying to make it possible for a developer to create an alias for
a command, and possibly to define pre-filled argument for the original
command. The user would then be able to define for example an alias
named "en-fr" for the command "translate", that will "behave" just
like the original command but translating directly the input text from
English to French.

(The code of the following functions is availaible on gist:
http://gist.github.com/61752 )

I have already created two low level functions to achieve that:
CmdUtils.executeCommand and CmdUtils.previewCommand that do exactly
what you expect them to do, and that can be used in any ubiquity
command, for any purpose (command chaining for example).

I am trying to create a high level function to make it dead easy to
create an alias: CmdUtils.CreateAlias. Just a quick example of how we
could use this function when it will be ready:
CmdUtils.CreateAlias({
name: 'test2',
for: 'translate',
modifiers: {
from: {data: 'fr', text: 'french'},
to: {data: 'en', text: 'english'}
}
});

I have some problem with this function:
- It is not possible to create an alias for a command created in the
Ubiquity Command Editor, because it is not part of the list of
available command when the alias is being created : (
- Usually when a command is created, its arguments are parsed: a
collection like
{"from": noun_type_language, "to": noun_type_language }
becomes
{
from: {_name: "language", getLangName: function(), suggest: function
()},
to: {_name: "language", getLangName: function(), suggest: function
()},
}
For some reason this "transformation" doesn't occur when using
CreateAlias, although I am using the standard CreateCommand function
with the same arguments : (


Once those problems will be solved, I will create a new Ubiquity
command named "create-alias", to give the power of alias creation to
end-users : ). Something like "create-alias fr-en for translate with
from french to english",
but I am not sure about the syntax yet. I already foresee a
difficulty: I will have to parse the string provided to the "with"
modifiers as arguments for the original command.

Again, your feedback and help will be greatly appreciated !

Thank you in advance,
Louis-Rémi Babé

lrbabe

unread,
Feb 24, 2009, 11:40:19 AM2/24/09
to ubiquity-firefox
I've found some time to work on the above problems and I've fixed
small bugs that were preventing my code to work.
I'm now proud to announce that the CmdUtils.createAlias function now
works as expected. The only restriction is that it doesn't work for
command created in the command editor, only with built-in commands
(still working on that).
The updated code is available at the same address: http://gist.github.com/61752

Now I have to create a new command to make definition of alias
possible from the command line : )

Blair McBride

unread,
Feb 24, 2009, 3:08:28 PM2/24/09
to ubiquity...@googlegroups.com
Impressive!! We'll see about getting this into Ubiquity.

- Blair

lrbabe

unread,
Feb 26, 2009, 1:01:55 PM2/26/09
to ubiquity-firefox
I've added a first draft of a working create-alias command at the end
of this code: http://gist.github.com/61752
Hopefully I'll find some time to finish it this Week-End.

As always, feedback is appreciated : )

Lr

lrbabe

unread,
Feb 26, 2009, 1:06:30 PM2/26/09
to ubiquity-firefox
I forgot to provide an example:
"create-alias fr-en for translate from french to english"
it uses Ubiquity's parser so you can also write
"alias fr-en for tran from fr to en"

lrbabe

unread,
Mar 4, 2009, 8:46:40 PM3/4/09
to ubiquity-firefox
I have just updated the code and it's documentation.
Performances of the create-alias command should be greatly improved by
caching the cloned parser.

I'm searching for members of the community willing to test it and
provide some feedback before applying for an inclusion into a future
version of Ubiquity (if it proves to be useful enough, of course).

Regards,
Louis-Rémi Babé

On Feb 26, 6:06 pm, lrbabe <lrb...@gmail.com> wrote:
> I forgot to provide an example:
> "create-aliasfr-en for translate from french to english"
> it uses Ubiquity's parser so you can also write
> "aliasfr-en for tran from fr to en"
>
> On Feb 26, 6:01 pm, lrbabe <lrb...@gmail.com> wrote:
>
> > I've added a first draft of a working create-aliascommand at the end
Reply all
Reply to author
Forward
0 new messages