Exemple #1
0
def OnSelfAdded(event, wavelet):
  """Invoked when PeopleFinder is first added to the wave."""
  blip = event.blip

  wavelet.title = 'People-Finder Profile'
  blip.append_markup('<h2>Full Name</h2>')
  blip.append(element.Line())
  blip.append(element.Input('fullname', 'Your Name'))
  blip.append_markup('<h2>Interests</h2>')
  for (id, label) in INTERESTS:
    if id == '--':
      blip.append_markup('<h3>%s</h3>' % label)
    else:
      blip.append(element.Line())
      blip.append(element.Check(id, 'false'))
      blip.append(element.Label(id, label))

  blip.append(element.Line())
  blip.append_markup('<h2>Location</h2>')
  blip.append(element.Line())
  blip.append('You may optionally add a marker to the following map to note where you are coming from:')
  blip.append(element.Gadget('http://google-wave-resources.googlecode.com/svn/trunk/samples/extensions/gadgets/mappy/mappy.xml'))
  wavelet.tags.append(CONFERENCE_HASHTAG)
  wavelet.tags.append('google-profile')
  wavelet.participants.add('*****@*****.**')
Exemple #2
0
def MakeInfoWave(session, collection_key):
  if not session.name:
    logging.info('Error: No name. Not making wave')
    return

  SetupRobot()

  # Get collection object
  collection = model.Collection.get(collection_key)

  # Create session wave
  new_wave = MakeNewWave(collection)
  AddId(new_wave, session)
  new_wave.data_documents[WAVE_TYPE] = 'info'

  # Add content to session wave
  title = 'Google I/O 2010: %s' % session.name
  AddTitle(new_wave, title)

  # Add content
  blip = new_wave.root_blip
  blip.append(session.description + '\n')
  blip.append(element.Line(alignment='c'))
  blip.append('Have questions or want to discuss this session?',
              bundled_annotations=[('style/fontSize', '1.3em'),
                                   ('style/fontWeight', 'bold')])
  blip.append(element.Line(alignment='c'))
  blip.append('Join in on this wave', 
              bundled_annotations=[('style/fontSize', '1.3em'),
                                   ('style/fontWeight', 'bold')])
  blip.append('\n')
  blip.append(element.Line())
  blip.append('Speaker(s): ', bundled_annotations=[('style/fontWeight', 'bold')])
  for i in range(len(session.speakers)):
    speaker = session.speakers[i]
    blip.append(speaker.name, bundled_annotations=[('link/manual', speaker.link)])
    if i != len(session.speakers)-1:
      ModBlip(blip, ', ', [('link/manual', None)])

  blip.append('\n')
  AddInfoLine(blip, 'Time', session.time)
  AddInfoLine(blip, 'Day', session.day)
  AddInfoLine(blip, 'Location', session.location)
  blip.append('\n')
  AddInfoLine(blip, 'Session type', session.type)
  AddInfoLine(blip, 'Attendee requirements', session.prereqs)
  blip.append('\n')
  AddInfoLine(blip, 'Hashtag', session.hashtag)

  AddBackLink(new_wave, collection)
  AddTags(new_wave, session, collection)

  # Submit all operations on new wave
  myrobot.submit(new_wave)

  new_wave_ser = simplejson.dumps(new_wave.serialize())
  deferred.defer(MakeLiveWave, session, collection.key(), new_wave.wave_id,
                 new_wave_ser)
def AddToTOC(session, conference_key, wave_id):
    SetupRobot()
    conference = model.Conference.get(conference_key)
    # Re-create TOC wave
    toc_wave = myrobot.blind_wavelet(conference.toc_wave_ser)
    blip = toc_wave.root_blip
    # Add link to main wave
    ModBlip(blip, element.Line(line_type='li', indent=1))
    ModBlip(blip, session.name, [('link/wave', wave_id)])
    ModBlip(blip, element.Line(line_type='li', indent=2))
    info_text = ' (%s, %s)' % (session.day, session.time)
    ModBlip(blip, info_text, [('link/wave', None),
                              (wavedata.SESSION_ID, session.id)])
    myrobot.submit(toc_wave)
Exemple #4
0
def AddToTOC(session, collection_key, session_wave_id, live_wave_id):
  SetupRobot()
  collection = model.Collection.get(collection_key)
  # Re-create TOC wave
  toc_wave = myrobot.blind_wavelet(collection.toc_wave_ser)
  blip = toc_wave.root_blip
  # Add link to main wave
  blip.append(element.Line(line_type='li', indent=1))
  blip.append(session.name, [('link/wave', None)])
  blip.append(element.Line(line_type='li', indent=2))
  ModBlip(blip, 'Info Wave', [('link/wave', session_wave_id)])
  ModBlip(blip, ' | ', [('link/wave', None)])
  ModBlip(blip, 'Live Wave', [('link/wave', live_wave_id)])
  info_text = ' (%s, %s)' % (session.time, session.location)
  ModBlip(blip, info_text, [('link/wave', None), (SESSION_ID, session.id)])
  myrobot.submit(toc_wave)
def ProcessWave(wavelet):
  # If we already processed, don't process again
  if PROCESSED in wavelet.data_documents.keys():
    return

  blip = wavelet.root_blip
  blip.append(element.Line())
  # Find all the line elements
  todo = []
  for start, end in blip.all(element.Line):
    todo.append(start)
  # Sort by which line is first
  todo.sort()
  # Skip first 2 lines, since that's the title
  todo = todo[2:]
  # Reverse sort, so that we process bottom-up
  # and don't worry about our indices getting skewed
  todo.reverse()
  for position in todo:
    inline_blip = blip.insert_inline_blip(position)
    inline_blip.append('Rate this!')
    inline_blip.append(element.Gadget(url='http://www.nebweb.com.au/wave/likey.xml'))

  # Mark that we've procesed it
  wavelet.data_documents[PROCESSED] = 'done'
def OnBlipSubmitted(event, wavelet):
    blip = event.blip
    blip_id = blip.blip_id

    # If we already linked to the blip, then do nothing
    if blip_id in wavelet.data_documents.keys():
        return
    # If this is the root blip, then do nothing
    if blip_id == wavelet.root_blip.blip_id:
        return

    # Find first line of blip to serve as title
    # Start after obligatory '\n'
    header_start = 1
    # Default to ending after all the text
    header_end = len(blip.text)
    for start, end in blip.all(element.Line):
        # If we're past the first obligatory Line element,
        # assume we've seen some useful text and mark as end
        if start > 1:
            header_end = start
            break
    title = blip.text[header_start:header_end]

    # Add link to root blip to blip
    # Format is waveid://google.com/w+8hpKCBQNA/~/conv+root/b+Qq3cIxvuQ
    domain = wavelet.domain
    wave_id = wavelet.wave_id.split('!')[1]
    blip_ref = 'waveid://%s/%s/~/conv+root/%s/' % (domain, wave_id, blip_id)
    wavelet.root_blip.append(element.Line(line_type='li', indent=1))
    wavelet.root_blip.append(title, [('link/manual', blip_ref)])
    wavelet.root_blip.append('', [('link/manual', None)])
    wavelet.data_documents[blip_id] = 'linked'
def AddLinkToTOC(wave):
    if wavedata.LINK_ADDED not in wave.data_documents.keys():
        SetupRobot()
        conference = GetConferenceForNewWave(wave)
        # Add link to main wave
        blind_wave = myrobot.blind_wavelet(
            conference.toc_wave_ser,
            proxy_for_id=wavedata.MAIN_PROXY(conference))
        line = element.Line(line_type='li', indent=1)
        ModBlip(blind_wave.root_blip, line)
        ModBlip(blind_wave.root_blip, wave.title,
                [('link/wave', wave.wave_id), (wavedata.TOC_LINK(wave), '')])
        ModBlip(blind_wave.root_blip, element.Line(), [('link/wave', None)])

        myrobot.submit(blind_wave)
        wave.data_documents[wavedata.LINK_ADDED] = 'yes'
def OnBlipSubmitted(event, wavelet):
    group = '*****@*****.**'
    if wavelet.title.find('Live Notes') > 0:
        wavelet.participants.set_role(group,
                                      wavelet.participants.ROLE_READ_ONLY)
        wavelet.tags.append('io2010')

    if WAVE_TYPE in wavelet.data_documents.keys(
    ) and wavelet.data_documents[WAVE_TYPE] == 'info':
        wavelet.participants.set_role(group,
                                      wavelet.participants.ROLE_READ_ONLY)

    if IsBlankWave(wavelet) or IsEventWave(wavelet):
        if LINK_ADDED not in wavelet.data_documents.keys():
            SetupOauth(wavelet)
            id = GetWaveId(wavelet)
            # Get collection object
            collection = model.ConferenceCollection.get_by_id(int(id))

            # Add link to main wave
            blind_wave = myrobot.blind_wavelet(collection.toc_wave_ser)
            line = element.Line(line_type='li', indent=1)
            blind_wave.root_blip.append(line)
            blind_wave.root_blip.append(wavelet.title,
                                        bundled_annotations=[
                                            ('link/wave', wavelet.wave_id)
                                        ])
            myrobot.submit(blind_wave)
            wavelet.data_documents[LINK_ADDED] = 'yes'
Exemple #9
0
def OnBlipSubmitted(event, wavelet):
  """The map gadget can only be edited when the blip
  is in write mode, so we can safely handle updates
  to the user location in the BlipSubmitted event.
  """
  blip = event.blip

  mapgadget = blip.all(element.Gadget).value()
  coord = None
  for key in mapgadget.keys():
    if key.startswith('overlay-'):
      mapdata = simplejson.loads(getattr(mapgadget, key))
      if mapdata['type'] == 'point':
        coord = mapdata['coordinates'][0]

  profile = Profile.get_or_insert(wavelet.wave_id)
  oldlocation = profile.location
  if coord:
    profile.location = db.GeoPt(coord['lat'], coord['lng']) 
    profile.update_location()
    logging.debug(profile.location)
    if ( oldlocation is None ) or ( oldlocation != profile.location ):
      if oldlocation:
        logging.debug(oldlocation)
      # search for gtugs
      logging.debug(profile.location)
      results = GTUG.proximity_fetch(
          GTUG.all(),
          profile.location,
          max_results=5,
          max_distance=80467
          ) 
      if results:
        gtugblip = blip.reply()
        gtugblip.append_markup("<p>Great news, we found a Google Technology User Group near you!</p>")
        gtugblip.append(element.Line())
        gtugblip.append(element.Line())
        gtugblip.append_markup("<p>The group name is </p>")
        gtugblip.append(results[0].key().name(), [
          ('link/manual', results[0].url)
          ])
  profile.put()
def AddToGallery(wavelet):
    group = '*****@*****.**'
    pamela = '*****@*****.**'
    public = '*****@*****.**'
    domain = 'googlewave.com'

    # Get info
    blip = wavelet.root_blip
    installer_url = GetInputValue(blip, 'installer_url')
    extension_name = GetInputValue(blip, 'name')
    extension_summary = GetInputValue(blip, 'summary')
    extension_description = GetTextAreaValue(blip, 'description')
    extension_screenshot = GetInputValue(blip, 'screenshot')
    if installer_url:
        extension_thumbnail = installerchecker.get_thumbnail(installer_url)
    else:
        extension_thumbnail = 'http://wave-samples-gallery.appspot.com/static/img/project_gallery_logo.png'

    # Create installer wave
    # Create discussion wave
    participants = [pamela, public]
    discussion_wave = submitty.new_wave(domain, participants, submit=True)
    discussion_wave.title = 'Discuss: %s' % extension_name
    blip = discussion_wave.root_blip
    blip.append('\n%s\n\n' % extension_description)
    if installer_url:
        blip.append(element.Installer(installer_url))
    gadget_url = 'http://mashable-submitty.appspot.com/gadget_ratings.xml'
    blip.append(element.Gadget(gadget_url))
    gadget_url = 'http://mashable-submitty.appspot.com/gadget_twitter.xml'
    props = {'wavetitle': extension_name}
    blip.append(element.Gadget(gadget_url, props))
    submitty.submit(discussion_wave)

    # Add to TOC wave
    toc_wave_id = 'googlewave.com!w+DYz-iagTK'
    toc_wavelet_id = 'googlewave.com!conv+root'
    toc_wavelet = submitty.fetch_wavelet(toc_wave_id, toc_wavelet_id)
    blip = toc_wavelet.root_blip
    line = element.Line(line_type='h2')
    blip.append(line)
    blip.append(extension_name)
    blip.append('\n')
    image = element.Image(url=extension_thumbnail, width=120, height=120)
    blip.append(image)
    blip.append("\n%s\n" % extension_summary)
    AddLink(blip, discussion_wave.title, discussion_wave.wave_id)
    blip.append('\n\n')
    blip.at(len(blip.text) - 2).clear_annotation('style/fontStyle')
    blip.at(len(blip.text) - 2).clear_annotation('link/wave')
    blip.at(len(blip.text) - 2).clear_annotation('link/manual')
    submitty.submit(toc_wavelet)
def OnSelfAdded(event, wavelet):
    """Invoked when any participants have been added/removed from the wavelet."""
    logging.info('OnSelfAdded')
    blip = event.blip
    wavelet.title = 'A wavelet title'
    blip.append(
        element.Image(url='http://www.google.com/logos/clickortreat1.gif',
                      width=320,
                      height=118))
    blip.append(element.Line(line_type='li', indent='2'))
    blip.append('bulleted!')
    blip.append(
        element.Installer(
            'http://wave-skynet.appspot.com/public/extensions/areyouin/manifest.xml'
        ))

    # add a reply to the blip authored by a proxy. Effectively
    # the address on this will be [email protected].
    # Note that as a side effect this will also add this
    # participant to the wave.
    wavelet.proxy_for('proxy').reply().append('hi from douwe')
    inlineBlip = blip.insert_inline_blip(5)
    inlineBlip.append('hello again!')

    # Create a new wave. The new wave will have its own operation queue.
    # new_wave also takes an optional 'message' parameter which can be
    # set to an arbitrary string. By setting it to the serialized version
    # of the current wave, we can reconstruct the current wave when the
    # other wave is constructed and update the current wave.
    new_wave = sinky.new_wave(wavelet.domain,
                              wavelet.participants,
                              message=wavelet.serialize())
    new_wave.participants.set_role(wavelet.creator,
                                   wavelet_mod.Participants.ROLE_READ_ONLY)
    new_wave.root_blip.append('A new day and a new wave')
    new_wave.root_blip.append_markup(
        '<p>Some stuff!</p><p>Not the <b>beautiful</b></p>')

    # since the new wave has its own operation queue, we need to submit
    # it explicitly through the active gateway, or, as in this case,
    # submit it together with wavelet, which will handle the submit
    # automatically.
    new_wave.submit_with(wavelet)
Exemple #12
0
def AppendLine(blip):
    blip.append(element.Line())
    blip.append(element.Line())
def AddLink(blip, link_text, link_id):
    line = element.Line(line_type='li')
    blip.append(line)
    blip.append(link_text, bundled_annotations=[('link/wave', link_id)])
    blip.append('\n', bundled_annotations=[])