示例#1
0
    def get(self):
        address = self.request.get('address') or '*****@*****.**'
        callback = self.request.get('callback')
        # create a new wave, submit immediately
        wavelet = self._robot.new_wave(domain=domain,
                                       participants=[address],
                                       submit=True)
        wavelet.title = ('Land Ho!')
        wavelet.root_blip.append(
            'Arr, only a scurvy dog would hide his booty in the root blip.')

        rand_blip = random.randint(1, 4)
        for i in range(5):
            if i == rand_blip:
                blip = wavelet.reply('TREASURE!')
                blip.append(
                    element.Image(
                        'http://www.iconeasy.com/icon/thumbnails/Movie%20&%20TV/Jolly%20Roger/Pirate%20Treasure%20Icon.jpg'
                    ))
            else:
                wavelet.reply('Nothing to see here, matey!')
        self._robot.submit(wavelet)

        if wavelet.wave_id:
            json = '{"status": "success", "wave_id": "%s"}' % wavelet.wave_id
        else:
            json = '{"status": "error"}'
        if callback:
            self.response.out.write(callback + '(' + json + ')')
        else:
            self.response.out.write(json)
示例#2
0
def OnSelfAdded(event, wavelet):
    for blip_id in wavelet.blips:
        blip = wavelet.blips[blip_id]
        if blip.text.find('TREASURE') > -1:
            blip.append('\nYARRR, TIS MINE, SCALLYWAGS!')
            blip.append(
                element.Image(
                    'http://www.iconeasy.com/icon/thumbnails/Movie%20&%20TV/Jolly%20Roger/Pirate%20Treasure%20Icon.jpg'
                ))
示例#3
0
def AppendTweet(blip, start, tweetId):
    api = twitter.Api(cred.username, cred.password)
    status = api.GetStatus(tweetId)
    image = element.Image(status.user.profile_image_url)
    username = status.user.screen_name
    username_url = 'http://www.twitter.com/' + username
    text = status.text
    blip.append('...')  #buffer
    blip.at(start).insert('\n')
    blip.at(start + 1).insert(image)
    blip.at(start + 3).insert(username + ': ' + text)
    blip.all(username + ': ').annotate('link/manual', username_url)
示例#4
0
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 update_preferences_wavelet(wavelet, participant=None, force=False):
    if not force and wavelet.data_documents[VERSION_DATA_DOC] == PREFERENCES_VERSION: return

    participant = find_participant(wavelet, participant)
    pp = model.ParticipantPreferences.get_by_pk(participant)
    logging.debug('Updating preferences wave content for %s', participant)
    if force:
        pp.preferences_wave_id = wavelet.wave_id
        pp.put()

    content = []

    content += [ element.Image(url=constants.ROBOT_LOGO, width=200, height=100, caption=constants.ROBOT_NAME.title()) ]
    content.append('\n')
    content += [ element.Check('notify', pp.notify), ' Notify me to this email:\n', element.Input('email', str(pp.email)), '\n' ]
    content += [ element.Check('notify_initial', pp.notify_initial), ' Send initial notifications', '\n' ]
    content.append('\n')
    content += [ 'Phone activation code: %s\n' % pp.activation ]

    if pp.account_id:
        content += [ 'Phone account id: %s\n' % pp.account_id ]

        query = model.Phone.all()
        query.filter('account_id =', pp.account_id)
        content += [ 'Phones associated with this account: %s\n' % len(list(query)) ]

        query = model.ParticipantPreferences.all()
        query.filter('account_id =', pp.account_id)
        content += [ 'Google wave accounts associated: ' ]
        content += [ ','.join([ '%s' % pp2.participant for pp2 in query ]) ]
        content.append('\n')

    content.append('\n')

    content += [ element.Button('save_pp', 'Save'), ' ', element.Button('refresh_pp', 'Refresh'), '\n' ]
    content.append('\n')
    content += [ 'Execute global commands: (try "help")', element.Input('command', ''), element.Button('exec_pp', 'Exec') ]

    wavelet.root_blip.all().delete()

    wavelet.data_documents[PARTICIPANT_DATA_DOC] = participant
    wavelet.data_documents[VERSION_DATA_DOC] = PREFERENCES_VERSION

    wavelet.title = 'Notifiy global preferences'

    for c in content:
        wavelet.root_blip.append(c)
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)
示例#7
0
def Bannerize(phrase):
    url = 'http://www.google.com/chart?chst=d_bubble_texts_big&chld=bb|49D130|FFFFFF|%s' % phrase.replace(
        ' ', '+').replace('&', '%26')
    image = element.Image(url=url)
    return image