def OnSelfAdded(event, wavelet): # Modify title wavelet.title = 'Ripple: ' wavelet.participants.add('*****@*****.**') blip = wavelet.root_blip blip.append('\n\n\n') url = 'http://i-like-it.googlecode.com/svn/trunk/ILikeIt.xml' gadget = element.Gadget(url) blip.append(gadget) query = db.Query(models.Rippler) query.filter('user ='******'*****@*****.**', wavelet.creator] profile_wave = robotty.new_wave(wavelet.domain, participants, submit=True) profile_wave.title = 'Profile for: %s' % wavelet.creator profile_wave.root_blip.append('Exciting profile info goes here.') url = 'http://ripple-bot.appspot.com/gadget_follow.xml' props = {'creator': wavelet.creator} gadget = element.Gadget(url, props) profile_wave.root_blip.append(gadget) profile_wave.submit_with(wavelet) rippler.profile_wave_id = profile_wave.wave_id rippler.num = rippler.num + 1 rippler.put() start = len(blip.text)+len(wavelet.title) blip.append('Visit Profile ') blip.range(start, start+6).annotate('link/wave', rippler.profile_wave_id) # Add to datastore ripple = models.Ripple() ripple.id = wavelet.wave_id SetRipple(ripple, wavelet)
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 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('*****@*****.**')
def AddModerator(blip): AddHeader(blip, text.SESSIONWAVE_QUESTIONS_HEADER) ModBlip( blip, element.Gadget( url='http://confrenzy.appspot.com/gadget_moderator.xml')) AddNewLine(blip)
def AddAttendees(blip): AddHeader(blip, text.SESSIONWAVE_ATTENDEES_HEADER) ModBlip( blip, element.Gadget( url='http://confrenzy.appspot.com/gadget_attendees.xml')) AddNewLine(blip)
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 OnSelfAdded(event, wavelet): blip = EnhancedBlip(wavelet.root_blip) # Deal with the case of people clicking 'New Wave' on robot in gallery waves if wavelet.robot_address.find('noudw') > -1: wavelet.title = message.ACC_TITLE blip.append(message.ACC_MESSAGE) return # Otherwise, assume that they want to submit an extension wavelet.title = message.TITLE blip.add_line() blip.append(element.Gadget(GADGET_URL)) blip.add_line() blip.append_markup(message.INTRO) blip.add_line() blip.add_line() blip.add_fields(message.DEV_FIELDS) blip.add_line() blip.append_markup(message.MIDDLE) blip.add_line() blip.add_line() blip.add_fields(message.EXT_FIELDS) blip.add_line() blip.add_questions(message.EXT_QS, wavelet.data_documents)
def FillWave(wavelet): # grab youtube json url = 'http://gdata.youtube.com/feeds/api/standardfeeds/most_recent_Animals?alt=json' json = fetchJSON(url) entries = json['feed']['entry'] num = random.randint(0, len(entries) - 1) entry = entries[num] title = entry['title']['$t'] descrip = entry['media$group']['media$description']['$t'] logging.info(entry) id = entry['id']['$t'] id = id.split('videos/')[1] gadget_url = 'http://everybodywave.appspot.com/gadget/WaveTube/main.xml' youtube_url = 'http://www.youtube.com/watch?v=%s' % id #maxage = '86400000' #size = '480x295' gadget_props = {'yturl': youtube_url} gadget = element.Gadget(url=gadget_url, props=gadget_props) wavelet.title = title wavelet.root_blip.append(descrip) wavelet.root_blip.append(gadget) msg = """Note: This wave contains a collaborative Youtube viewing gadget, called WaveTube. If you do start watching the video, it will share that with the other folks watching the wave. Enjoy!""" wavelet.root_blip.append(msg)
def OnWaveletCreated(event, wavelet): """Called when the robot creates a new wave.""" logging.info('OnWaveletCreated') # Recreate the wavelet in which context this new wavelet was # created (i.e. the one we were originally added to). This is a # "blind" wavelet since any operations applied to this wavelet # are done without us really knowing what the state of the wavelet # is (it might have changed on the server). This means we have # to be careful. org_wavelet = wavelet.robot.blind_wavelet(event.message) # add a gadget that embeds the newly created wave to the original # wavelet. gadget = element.Gadget('http://kitchensinky.appspot.com/public/embed.xml') gadget.waveid = wavelet.wave_id org_wavelet.root_blip.append(gadget) # insert some non standard ascii characters: # note: there seem to be some issues with the characters insertion org_wavelet.root_blip.append( '\nInserted a gadget: \xd0\xb0\xd0\xb1\xd0\xb2') # insert a reply, and add some text to the reply reply = org_wavelet.reply() reply.append('Replying from blind_wavelet works') # add a tag org_wavelet.tags.append('blindtag') # again we have to explicitly submit the operations to the other # wavelet org_wavelet.submit_with(wavelet)
def addGadget(wavelet): blip = wavelet.root_blip body = blip.text.split('\n', 2)[2] id = wavelet.wave_id query = db.Query(models.WaveExport) query.filter('id =', id) waveExport = query.get() server = os.environ['SERVER_NAME'] url = "http://" + server + "/export?waveId=" + id.replace("+", "%252B") + "&ext=.xml?rand=" + str(random.randint(0, 100000)) if waveExport is None: waveExport = models.WaveExport() else: if waveExport.body == body: #Nothing changed, do nothing #Blip_submitted gets called when gadget state changes as well return blip.all(element.Gadget).delete() gadget = element.Gadget(url) blip.append(gadget) waveExport.id = id waveExport.title = wavelet.title waveExport.body = body waveExport.put()
def on_wavelet_self_added(self, event, wavelet): new_blip = wavelet.reply("") new_gadget = element.Gadget(_GADGET_URL) new_blip.append(new_gadget) gadget = Gadget(new_blip.first(element.Gadget, url=_GADGET_URL)) waveid = wavelet.wave_id gadget.set_status(Gadget.LOGIN) gadget.submit()
def load(event, url): if event.blip: from waveapi import element event.blip.append(element.Gadget(url)) return True else: event.reply("can't find root blip.") return False
def MakeAdminWave(event, wavelet): wavelet.title = 'Admin Wave' gadget = element.Gadget(url=util.GetGadgetUrl()) wavelet.root_blip.append(gadget) collection = model.ConferenceCollection() collection.owner = wavelet.creator collection.admin_wave = wavelet.wave_id collection.put()
def MakeEventTemplateWave(wave, conference): AddTitle(wave, conference.name + ' ' + text.EVENTWAVE_TITLE) blip = wave.root_blip AddHeader(blip, text.EVENTWAVE_WHEN_HEADER) AddNewLine(blip) AddHeader(blip, text.EVENTWAVE_WHO_HEADER) ModBlip( blip, element.Gadget( url='http://wave-api.appspot.com/public/gadgets/areyouin/gadget.xml' )) AddNewLine(blip) AddHeader(blip, text.EVENTWAVE_WHERE_HEADER) ModBlip( blip, element.Gadget( url= 'http://google-wave-resources.googlecode.com/svn/trunk/samples/extensions/gadgets/mappy/mappy.xml' ))
def OnWaveletSelfAdded(event, wavelet): wavelet.title = 'Blog post for review: Title here' blip = wavelet.root_blip AppendLine(blip) AppendLabel(blip, 'Status') gadget = element.Gadget(url='http://blog-reviewey.appspot.com/gadget.xml') blip.append(gadget) AppendLine(blip) AppendLabel(blip, 'Authors') AppendLine(blip) AppendLabel(blip, 'Body') AppendLine(blip)
def OnSelfAdded(event, wavelet): domain = wavelet.domain robot_address = wavelet.robot_address if IsAdminWave(wavelet): MakeAdminWave(event, wavelet) return proxy_for = GetWaveType(wavelet) if proxy_for == '': wavelet.root_blip.append( 'Oops, nothing to see here. Enjoy waving at I/O!') return id = proxy_for.split('-')[0] collection = model.ConferenceCollection.get_by_id(int(id)) if collection.tags: wavelet.tags.append(collection.tags[0]) if collection.groups: wavelet.participants.add(collection.groups[0]) if collection.make_public: wavelet.participants.add('*****@*****.**') if IsBlankWave(wavelet): wavelet.title = collection.name + ' Wave: Topic' event.blip.append_markup(text.session_html) if IsEventWave(wavelet): wavelet.title = collection.name + ' Event Wave: EventName' event.blip.append('\nWhen is it?\n\n') event.blip.append('Who\'s coming?\n') event.blip.append( element.Gadget( url= 'http://wave-api.appspot.com/public/gadgets/areyouin/gadget.xml' )) event.blip.append('\n\n Where is it?') event.blip.append( element.Gadget( url= 'http://google-wave-resources.googlecode.com/svn/trunk/samples/extensions/gadgets/mappy/mappy.xml' ))
def MakeAdminWave(admin_wave, type='conference'): title = text.ADMINWAVE_TITLE if type == 'unconference': title = text.ADMINWAVE_UNTITLE AddTitle(admin_wave, title) gadget_url = '%s&type=%s' % (util.GetGadgetUrl(), type) gadget = element.Gadget(gadget_url) ModBlip(admin_wave.root_blip, gadget) conference = model.Conference() conference.owner = admin_wave.creator conference.type = type conference.admin_wave = admin_wave.wave_id conference.put()
def handle_gadgetconsole(bot, event): if event.bottype != "wave": event.reply("this command only works in google wave."); return wave = event.chan if wave.data.feeds and wave.data.dotitle: event.set_title("JSONBOT - %s #%s" % (" - ".join(wave.data.feeds), str(wave.data.nrcloned))) from waveapi import element #url = gadgeturls.data['loadiframe'] + "?&iframeurl=https://jsonbot.appspot.com" #event.reply('loading %s' % url) event.append("loading ...\n") #load(event, "http://jsonbot.appspot.com/iframe.xml") event.append( element.Gadget('http://jsonbot.appspot.com/console.xml?gadget_cache=0'))
def OnSelfAdded(event, wavelet): wavelet.title = ('Land Ho!') wavelet.root_blip.append( 'Arr, only a scurvy dog would hide his booty in the root blip.') teasure_blip = random.randint(1, 9) shark_blip = random.randint(1, 9) for i in range(10): if i == teasure_blip: blip = wavelet.reply('TREASURE!') elif i == shark_blip: blip = wavelet.reply('SHARK!!!') blip.append( element.Gadget( 'http://google-wave-resources.googlecode.com/svn/trunk/samples/extensions/gadgets/sharkattack/sharkattack.xml' )) else: wavelet.reply('Nothing to see here, matey!')
def OnSelfAdded(event, wavelet): blip = wavelet.root_blip # Don't modify an existing wave, if someone # accidentally adds it to one if len(blip.text) > 5: return wavelet.title = 'Submissions are closed!' return wavelet.title = 'Mashable Extension Submission' blip.append('\n') gadget = element.Gadget(GADGET_URL) blip.append(gadget) blip.append('\n') blip.append_markup(message.intro) AddFields(blip, message.team_fields) blip.append('\n\n') blip.append_markup(message.middle) AddFields(blip, message.ext_fields)
def MakeLiveWave(session, collection_key, session_wave_id, session_wave_ser): SetupRobot() collection = model.Collection.get(collection_key) new_wave = MakeNewWave(collection) #new_wave = myrobot.fetch_wavelet(session.waveid, # 'googlewave.com!conv+root') AddId(new_wave, session) new_wave.data_documents[WAVE_TYPE] = 'live' AddTitle(new_wave, 'Live Wave: ' + session.name) blip = new_wave.root_blip info = '%s, at %s, %s ' % (session.day, session.time, session.location) italic = ('style/fontStyle', 'italic') ModBlip(blip, info, [italic]) ModBlip(blip, '(', [italic]) ModBlip(blip, 'More Info', [italic, ('link/wave', session_wave_id)]) ModBlip(blip, ')', [italic, ('link/wave', None)]) ModBlip(blip, '\n', [('style/fontStyle', None)]) search_url = 'http://www.google.com/search?q=%s&hl=en&tbs=mbl:1' % session.hashtag bold = ('style/fontWeight', 'bold') ModBlip(blip, session.hashtag, [bold, ('link/manual', search_url)]) ModBlip(blip, ' | ', [bold, ('link/manual', None)]) wave_url = 'https://wave.google.com/wave/#restored:wave:%s' % new_wave.wave_id status = 'Live wave-ing: %s %s' % (wave_url, session.hashtag) tweet_url = 'http://twitter.com/home?status=%s' % urllib.quote_plus(status) ModBlip(blip, 'Tweet This', [bold, ('link/manual', tweet_url)]) ModBlip(blip, ' | ', [bold, ('link/manual', None)]) buzz_message = 'Live wave-ing the "%s" session! %s' % (session.name, session.hashtag) wave_url = 'https://wave.google.com/wave/#restored:wave:%s' % new_wave.wave_id.replace('+', '%252B') wave_url = wave_url.replace('#', '%23') title = new_wave.title.split(': ', 1)[1] buzz_message = 'Live wave-ing the "%s" session! %s' % (title, session.hashtag.replace('#', '%23')) buzz_url = 'http://www.google.com/buzz/post?message=%s&url=%s' % (buzz_message, wave_url) ModBlip(blip, 'Post to Google Buzz', [bold, ('link/manual', buzz_url)]) ModBlip(blip, '\n\n', [('link/manual', None)]) ModBlip(blip, 'Attendees:\n', [bold]) blip.append(element.Gadget(url='http://io2010-bot.appspot.com/gadget_attendees.xml')) ModBlip(blip, '\nQuestions:\n', [bold]) gadget_url = 'http://io2010-moderator.appspot.com/moderator_production.xml' blip.append(element.Gadget(url=gadget_url)) ModBlip(blip, '\n\nLive Notes:\n', [bold]) live_notes_text = 'A designated Googler will be taking notes during this session, but feel free to join in below!\n\n' ModBlip(blip, live_notes_text, [('style/fontWeight', None), ('style/fontStyle', 'italic')]) reply_blip = new_wave.reply('\n') ModBlip(reply_blip, 'Discuss this session below this blip.', [italic]) AddTags(new_wave, session, collection) AddBackLink(new_wave, collection) # Submit all operations on new wave myrobot.submit(new_wave) # Add link for this wave to session wave session_wave = myrobot.blind_wavelet(session_wave_ser) session_wave.root_blip.first('Join in on this wave').annotate('link/wave', new_wave.wave_id) myrobot.submit(session_wave) # Add links to TOC wave deferred.defer(AddToTOC, session, collection.key(), session_wave_id, new_wave.wave_id)
def OnSelfAdded(event, wavelet): blip = wavelet.root_blip blip.append( element.Gadget("http://jcgbot.appspot.com/static/gadget-final.xml"))
def OnSelfAdded(event, wavelet): if len(wavelet.title) < 2: wavelet.title = 'Bug Triage: %s' % strftime('%Y-%m-%d') wavelet.root_blip.append('\n') gadget = element.Gadget(url=util.GetGadgetUrl()) wavelet.root_blip.append(gadget)