Python & Robot API - Annotating Blips

3 views
Skip to first unread message

atc

unread,
Oct 18, 2009, 1:15:19 PM10/18/09
to Google Wave API
Hi all,

Ok, I'm having a bad time trying to get the hang of annotations. The
pydoc (http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/
index.html) is quite bland - I can't seem to find anything that might
explain how to use them to say, bold text, add hyperlinks/hrefs. There
are types for images, gadgets and form elements but I can't seem to
find a descriptiojn of the basics - please help me.

I've followed the Java example on this thread (http://
groups.google.com/group/google-wave-api/browse_thread/thread/
eb334177c34c931f/ed1abe149d1ac6e4?lnk=gst&q=annotation
+documentation#ed1abe149d1ac6e4) but not had any luck - I just get a
blank blip posted by my robot...

I wrote the following code to try it:
doc = wavelet.CreateBlip().GetDocument()
doc.AnnotateDocument(Annotation("link/manual", "http://
www.google.com", Range()))
doc.SetText("THIS IS ANNOTATED TEXT")
As I said, I just end up with a blank blip - argh!

Firstly, what am I doing wrong?
Secondly, is there any documentation about annotations? If so, can
someone point me in the right documentation? :)

I want to first add nicely formatted hrefs because URLs I'm posting
are far too wrong - you can see for yourself by adding wave-
too...@appspot.com to a conversation and posting @news...

Thanks in advance,

atc

atc

unread,
Oct 18, 2009, 5:33:34 PM10/18/09
to Google Wave API
doc = wavelet.CreateBlip().GetDocument()
doc.SetAnnotation(Annotation(Range(0, 22), "link/manual", "http://
www.google.com"))
doc.SetText("THIS IS ANNOTATED TEXT")

I've tried with 'SetAnnotation' as pasted above, and I just get a
blank document. Can someone help this noob?
Message has been deleted
Message has been deleted
Message has been deleted

David Nesting

unread,
Oct 18, 2009, 8:34:26 PM10/18/09
to google-...@googlegroups.com
On Sun, Oct 18, 2009 at 10:15 AM, atc <alextc...@gmail.com> wrote:
               doc = wavelet.CreateBlip().GetDocument()
               doc.AnnotateDocument(Annotation("link/manual", "http://
www.google.com", Range()))
               doc.SetText("THIS IS ANNOTATED TEXT")
As I said, I just end up with a blank blip - argh!

I think your call to SetText is eliminating your annotations.  Try setting your annotations after you set the text.  You need to have content there in order to annotate it.  I agree that the documentation is a bit lacking still.

David

atc

unread,
Oct 18, 2009, 8:54:35 PM10/18/09
to Google Wave API
On Oct 19, 1:34 am, David Nesting <da...@fastolfe.net> wrote:
> I think your call to SetText is eliminating your annotations.  Try setting
> your annotations after you set the text.  You need to have content there in
> order to annotate it.  I agree that the documentation is a bit lacking
> still.

Thanks for your reply. Funnily enough that makes total sense. One
issue with my code was incorrect arguments to the SetAnnotation()
call, as well as an invalid rabnge

So, got it fixed now - code's below for anyone else pondering this!

doc = wavelet.CreateBlip().GetDocument()
doc.SetText("THIS IS ANNOTATED TEXT")
doc.SetAnnotation(Range(2, 12), "link/manual", "http://
www.google.com")

What other annotations are available? Where do I get the valid names
from?!

Thanks again for the help,

atc

David Nesting

unread,
Oct 18, 2009, 9:44:00 PM10/18/09
to google-...@googlegroups.com
On Sun, Oct 18, 2009 at 5:54 PM, atc <alextc...@gmail.com> wrote:
What other annotations are available? Where do I get the valid names
from?!

I haven't found a good authoritative source, but my own experimentation has yielded the following (self-explanatory?) annotations, just from styling text in the editor:

conv/title (marks the range of this annotation as the blip's title)
lang=en
style/fontWeight=bold
style/fontStyle=italic
style/textDecoration=underline
style/textDecoration=line-through
style/fontSize=2em
style/color=rgb(229, 51, 51)
style/backgroundColor=rgb(51, 127, 229)

The style/* annotations appear to mirror CSS, so it's possible more CSS properties can be expressed with these annotations, I don't know.

Notably absent are annotations for bullets, indentation, h1/h2/h3-style headings and left/center/right justification. These don't seem to be expressed through the Python API, but maybe someone else has had better luck with the Java.

David

pamela (Google Employee)

unread,
Oct 18, 2009, 9:59:47 PM10/18/09
to google-...@googlegroups.com
We haven't published an authoritative list of those annotations as we aren't confident in their stability. Feel free to use them for now, but keep in mind that they may change. Most likely, they will be documented as part of the wave-protocol, since they help define the data model, and we will then link to that list.

- pamela

atc

unread,
Oct 19, 2009, 1:34:58 AM10/19/09
to Google Wave API


On Oct 19, 2:44 am, David Nesting <da...@fastolfe.net> wrote:
> I haven't found a good authoritative source, but my own experimentation has
> yielded the following (self-explanatory?) annotations, just from styling
> text in the editor:
>
> conv/title (marks the range of this annotation as the blip's title)
> lang=en
> style/fontWeight=bold
> style/fontStyle=italic
> style/textDecoration=underline
> style/textDecoration=line-through
> style/fontSize=2em
> style/color=rgb(229, 51, 51)
> style/backgroundColor=rgb(51, 127, 229)
> link/manual=http://example.com/
>
> The style/* annotations appear to mirror CSS, so it's possible more CSS
> properties can be expressed with these annotations, I don't know.
>
> Notably absent are annotations for bullets, indentation, h1/h2/h3-style
> headings and left/center/right justification. These don't seem to be
> expressed through the Python API, but maybe someone else has had better luck
> with the Java.

David, that's infinitely helpful - thank you!

@Pamela, thanks for the explanation.

I'm off to do more hacking ;)

voidref

unread,
Oct 25, 2009, 12:35:21 AM10/25/09
to Google Wave API
Yes, the Python doc is completely underwhelming.

I find the Java documentation is much more complete, you just have to
translate.

I am using SetAnnotation(Range, Name, Value) instead. Perhaps try
that.

doc.SetAnnotation(document.Range(start, end), 'link/manual',
'http://www.google.com')

Alan

On Oct 18, 10:15 am, atc <alextcoll...@gmail.com> wrote:
> Hi all,
>
> Ok, I'm having a bad time trying to get the hang of annotations. The
> pydoc (http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/
> index.html) is quite bland - I can't seem to find anything that might
> explain how to use them to say, bold text, add hyperlinks/hrefs. There
> are types for images, gadgets and form elements but I can't seem to
> find a descriptiojn of the basics - please help me.
>
> I've followed the Java example on this thread (http://
> groups.google.com/group/google-wave-api/browse_thread/thread/
> eb334177c34c931f/ed1abe149d1ac6e4?lnk=gst&q=annotation
> +documentation#ed1abe149d1ac6e4) but not had any luck - I just get a
> blank blip posted by my robot...
>
> I wrote the following code to try it:
>                 doc = wavelet.CreateBlip().GetDocument()
>                 doc.AnnotateDocument(Annotation("link/manual", "http://www.google.com", Range()))
>                 doc.SetText("THIS IS ANNOTATED TEXT")
> As I said, I just end up with a blank blip - argh!
>
> Firstly, what am I doing wrong?
> Secondly, is there any documentation about annotations? If so, can
> someone point me in the right documentation? :)
>
> I want to first add nicely formatted hrefs because URLs I'm posting
> are far too wrong - you can see for yourself by adding wave-
> tool...@appspot.com to a conversation and posting @news...
>
> Thanks in advance,
>
> atc
Reply all
Reply to author
Forward
0 new messages