å€ã«ã¯ãGoogleãµã³ãããã¯ã¹ã«æåŸ ãããŸããã ãããããã®éåžžã«ãµã³ãããã¯ã¹ã«ã¯ããããã®äººãããŠããã¹ãŠã®æ³¢ã¯å ¬éãããŠããŠãç§ã®è²§ãããããããã¯ã¯ãã¹ãŠã®ã¢ã¯ãã£ããã£ã倧ããªããã¿ã§æ¶åããã ãã ã£ãã®ã§ãå°ãéãã§ããµã³ãããã¯ã¹ãç²åŸããŸãã:)
ãããŠæè¿ãç§ã®ãµã³ãããã¯ã¹ã¢ã«ãŠã³ããã©ã€ããã¬ãã¥ãŒã¢ã«ãŠã³ãã«å€ãããŸãããç§ã¯ãå°çãã人ã«æåŸ ç¶ãéä¿¡ããå°ãªããšã1人ã®å人ãæåŸ ããã®ãåŸ ã£ãŠãããããããAPIã«å¯ŸåŠããŸããã
æç¶ãã®çµæããã®ãããªåºæ¬çãªãããããäœæãããŸããïŒbakarobo@appsot.comã
ã³ãã³ãã§ïŒbrïŒborïŒ bashããã©ã³ãã ãªåŒçšãååŸãã
ã³ãã³ãã§ïŒbrïŒrbïŒ rosbestã§ãã®æ¥ã®åçãæ®ã
ã³ãã³ãäžïŒbrïŒBakaRoboïŒ å¿ç:)
ãªãã¿ã®ãªããã¹ãŠã®ããŒã ã«å¿ããŠèªãã
ãããŠãäœæã®éçšã§ãç§ã¯é¢çœãããšãå®çŸããŸããïŒå€§ãããŠã¯ãŒã«ãªã¢ãã¬ããããŠã§ãŒãããããçšã«éçºãããŸãã...çŸæç¹ã§ã¯ã»ãšãã©ææžåãããŠããŸãã:)å°ãªããšãPython APIã®ãªãã¡ã¬ã³ã¹ã¯ã¯ã©ã¹ãšé¢æ°ã®äžè¬çãªãªã¹ãã§ãããå®éã«ã¯äœãæ確ã§ã¯ãããŸããã
ã ãããããŸããŸãªããã¯ããµã³ãã«ãèªãã®ã«æéãè²»ãããŠãããçš®ã®æçšãªãããããäœãããã«å¿ èŠãªåºæ¬çãªæ å ±ãç¹å®ããããã«æããŸãã ãããŠããããã®å¿ èŠãªãã¹ãŠã®ããšãäŒãããã§ãã
ãŸãããããããGoogle App Engineã«é 眮ããå¿ èŠããããŸã ã ããã«ã¢ããªã±ãŒã·ã§ã³ãäœæããã³ãŒãã³ãããçšã®ããŒã«ãããŠã³ããŒãããæ¹æ³ã«ã€ããŠã¯èª¬æããŸããããã¹ãŠãããã§æ確ã«èª¬æãããŠããŸãã
ãã®ãããããŒã«ãããŠã³ããŒããããã£ã¹ã¯äžã®ç¹å®ã®ãã©ã«ããŒã«æ¬¡ã®ãããªãã®ãååŸããŸããã
.
..
google_appengine
our_robot
our_robotã¯ãããããã眮ããããã©ã«ããŒã§ãã ãããŠããã®ãã©ã«ããŒã§code.google.comãããã®ã¢ãŒã«ã€ããããŠã³ããŒãããŠè§£åããŸããããã¯å®éã«ã¯Pythonã¢ã«ãŠã³ãã§ãã
ããã§ãå®éã®éçºã®æºåãæŽããŸããã
念ã®ããïŒã¢ããªãžã®ã³ãŒãã®ã³ãããã¯æ¬¡ã®ããã«è¡ãããŸãã
python ./google_appengine/appcfg.py update ./our_robot/-ãã®åŸãç³é¹žãšãã¹ã¯ãŒãã«ã€ããŠè³ªåãããã¡ã€ã«ãã¢ããããŒãããŸãã
åºæ¬ã±ãŒã¹ã§ã¯ããããžã§ã¯ãã«3ã€ã®äž»ãªãã¡ã€ã«ããããŸãã
our_robot.py-å®éã«ã¯ãããããã®ã³ãŒã app.yaml-ãããã§ã¹ãã®ãããªãã® _wave / capabilities.xml-ããããããªãã¹ã³ããã€ãã³ãã宣èšãããã¡ã€ã«ã
Farcaller ã¢ããªã³ ïŒ
Python APIã¯ãrobot.Robotã®åŒæ°ã«åºã¥ããŠxml-ku castatièªäœãçæããŸãããjavaã¯pensã§èšè¿°ããå¿ èŠããããŸã ã
ãããã£ãŠãæããã«ãéçºããã»ã¹ã§ã®äžå®éã®äœã®åãã¯æŸæ£ãããå¯èœæ§ããããŸãã
ããã§ã€ãã³ãã®ãªã¹ããèŠãããšãã§ããŸãããç§ã®æèŠã§ã¯ãããããã«ãšã£ãŠæãéèŠãªãã®ã¯æ¬¡ã®ãšããã§ãã
WAVELET_SELF_ADDED-ãããããWaveã«è¿œå ããããšãã«ããªã¬ãŒãããŸãããã®æç¹ã§ã䜿çšã«é¢ããå°ããªæ å ±ã衚瀺ãããšäŸ¿å©ã§ãã
BLIP_SUBMITTED -wave blipãäœæ/ç·šéããããšããæžã蟌ã¿æã§ã¯ãªããDoneãã¿ã³ãæ¢ã«ç¹æ» ããŠãããšãã«ããªã¬ãŒãããŸãã
ããã«é²ã¿ãŸãããã
app.yamlãããã§ã¹ãã¯ãcode.google.comã®ãã¥ãŒããªã¢ã«ã§å€æãããšã次ã®ããã«ãªããŸãã
application: our_robot
version: 1
runtime: python
api_version: 1
handlers:
- url: /_wave/.*
script: our_robot.py
- url: /assets
static_dir: assets
- url: / icon.png
static_files: icon.png
upload: icon.png
ããã§ã¯ãã¹ãŠãæãããªããã§ãã ããããã®ååãèµ·åããããŒãžã§ã³ãAPIã®ããŒãžã§ã³ãããŸããŸãªURLã®ãã³ãã©ãŒã
泚æããå¿ èŠãããã®ã¯ããã³ãã©ã»ã¯ã·ã§ã³ã®ã-urlïŒ/icon.pngãã ãã§ãã ããã¯ããã¥ãŒããªã¢ã«ã«ã¯å«ãŸããŠããªãããã§ãããã¶ã€ã³ã§ã¯ãããããã¢ã€ã³ã³ã®åŠçæ¹æ³ãæå®ã§ããŸãã pngshkaã«æç»ããrobotãã©ã«ããŒã«ä¿åããpythonãã¡ã€ã«å ã§å®£èšããŸã:)
ãã¥ãŒããªã¢ã«ã§ããcapabilities.xmlãç°¡åã«èŠããŸãã
<? xml version ="1.0" encoding ="utf-8" ? >
< w:robot xmlns:w ="http://wave.google.com/extensions/robots/1.0" >
< w:capabilities >
< w:capability name ="WAVELET_SELF_ADDED" content ="true" />
< w:capability name ="BLIP_SUBMITTED" content ="true" />
</ w:capabilities >
< w:version > 1 </ w:version >
</ w:robot >
* This source code was highlighted with Source Code Highlighter .
å®éããã®ãã¡ã€ã«ã§å€æŽãããã®ã¯ã»ãšãã©ãããŸãããããŒãžã§ã³çªå·ãšãªãã¹ã³ããã€ãã³ãã®ã¿ã§ãã
ãããããã®äºåçãªæ··ä¹±ããã¹ãŠçµãã£ãåŸãå®éã«ã¯ãããããã®Pythonã³ãŒããæžãããšã«éåžžã«æ¥œããéšããèµ·ãããŸããã
ãŸããäŸãšãã¥ãŒããªã¢ã«ã§ç€ºãããŠããããã«ãã³ãŒãã®äžè¬çãªæ§é ã説æããŸãã次ã«ããã¥ãŒããªã¢ã«ã«ãªãããããçš®é¡ã®ãã€ããŒãªæçšæ§ãã¹ããŒããŸããåèæç®ã§ãã®äžã«å°éããå¿ èŠããããããäŸããããããæœåºããå¿ èŠããããŸããã
ãããã£ãŠãäžè¬ã«ãããããã®ç©ºçœã®ã³ãŒãã¯æ¬¡ã®ããã«ãªããŸãã
from waveapi import events
from waveapi import model
from waveapi import robot
def OnRobotAdded(properties, context):
pass
def OnBlipSubmitted(properties, context):
pass
if __name__ == '__main__' :
myRobot = robot.Robot( 'our_robot' ,
image_url= 'http://our_robot.appspot.com/icon.png' , #
version= '2.3' , #
profile_url= 'http://our_robot.appspot.com/' ) #
# :
myRobot.RegisterHandler(events.WAVELET_SELF_ADDED, OnRobotAdded)
myRobot.RegisterHandler(events.BLIP_SUBMITTED, OnBlipSubmitted)
#
myRobot.Run()
* This source code was highlighted with Source Code Highlighter .
ãããŠããã¹ãŠãçŽ æŽããããç解ã§ãããã®ããã«ã ããããã€ãã³ãã®æ©èœãæžãå§ãããšãããšãã°ãè²ä»ãã匷調ã¯ãã¡ããã®ããšãããã¹ããå¥ã®ããã¹ãã«çœ®ãæããæ¹æ³ãå®å šã«äžæ確ã§ããããšãããããŸãã
ããã»ã©é·ãã¯ãªãããããªããã€ãããšãã»ã€ã®çµæãšããŠãç§ã¯ãããããæžãã®ã«ååãªäŸ¿å©ãªã¡ãœããã®ãªã¹ããæããŸããã
æåã«ãã€ãã³ãåŠçé¢æ°ã§ã€ãã³ããçºçããããªãããååŸããããã«ïŒãã¡ããããã®ã€ãã³ããããªããã§çºçããå Žåãé€ãïŒã
blip = context.GetBlipByIdïŒããããã£['blipId']ïŒ
第äºã«ãããªããããã¹ããååŸããŠæäœããããã«ã
doc = blip.GetDocumentïŒïŒ
å 容= doc.GetTextïŒïŒ
ãããã£ãŠãããã¹ãã®äžéšãå¥ã®ããã¹ãã«çœ®ãæããã«ã¯ãçµæã®ããã¥ã¡ã³ãã䜿çšããŸã
doc.SetTextInRangeïŒmodel.document.RangeïŒSTARTãENDïŒãæ°ããããã¹ãïŒ
ããã¹ããã©ããã«æ¿å ¥ããã«ã¯ïŒ
doc.InsertTextïŒSTARTãTEXTïŒ
æåŸã«ããã¹ããè¿œå ããã«ã¯ïŒ
doc.AppendTextïŒTEXTïŒ
ç»åãæ¿å ¥ããã«ã¯ïŒ
æåŸã«-doc.AppendElementïŒmodel.document.ImageïŒPICTURE ADDRESSãWIDTHãHEIGHTãATTACHMENT_IDãALTïŒïŒ
ç¹å®ã®å Žæãž-doc.InsertElementïŒSTARTãmodel.document.ImageïŒPICTURE ADDRESSãWIDTHãHEIGHTãATTACHMENT_IDãALTïŒïŒ
äžè¬ã«ãããã¥ã¡ã³ãã§äœãã§ããããç¥ãã«ã¯ã ãã®ãªãã¡ã¬ã³ã¹ãåç §ãããšäŸ¿å©ã§ãã äœæã§ããèŠçŽ ã®ã¿ã€ããèŠã€ããããã«ãwaveapi.documentã®åç §ã調ã¹ãŸã*-ImageãLinkãããã«ã¯GadgetããããŸãã
é ãã ããªããã®ãã¹ãŠã®ãã¶ã€ã³ããã³ãã®ä»ã®ããŸããŸãªæçšæ§ã¯ããããã泚éã«ä¿åãããŸãã 圌女ã®ãã¹ãŠã¯ã·ã³ãã«ã§ãã
doc.SetAnnotationïŒmodel.document.RangeïŒSTARTãENDïŒãTYPEãVALUEïŒ
ããã«ãTYPEã¯è¿œå ãã泚éã®çš®é¡ãèšè¿°ãããã®ã§ãã æãéèŠãªIMHOã¯ãstyle / STYLE_PROPãã§ããSTYLE_PROPã¯js圢åŒã®csså±æ§ã¬ã³ãŒãã§ãã
çªç¶ã誰ãç¥ããªã-ããã¯jsã¹ã¯ãªããã§äœ¿çšãããå€æãããcssããããã£ã¬ã³ãŒãã§ãããäŸã䜿çšããŠãã®æ¬è³ªãç°¡åã«è¡šç€ºã§ããŸããããšãã°ãè²ã¯åãªãè²ã§ãããfont-sizeã¯fontSizeã§ãã ã€ãŸããcssã«ãã€ãã³ãããå Žåããã®ãšã³ããªã«ã¯ãã€ãã³ã¯ãããŸããããæåã®åèªãé€ããã¹ãŠã®åèªã¯å€§æåã§å§ãŸããŸãã backgroundColorãbackgroundImageãmarginTopãªã©ã
ããããç°¡åãªæ¹æ³ã§åé€ãããŸã;äŸãã°ããã©ã³ãã®è²ãèæ¯è²ãªã©ãåãã¿ã€ãã®ãã¹ãŠã®æ³šéãããã®ãããªãã¡ã³ã¯ã§æãã«æ®ºãããšãã§ããŸãïŒ
doc.DeleteAnnotationsByNameïŒTYPEïŒ
ãŸããç¹å®ã®ã¿ã€ãã®æ³šéããç¹å®ã®ç¯å²ã®ããã¹ãã®ã¿ãæ¶å»ã§ããŸãã
doc.DeleteAnnotationsInRangeïŒmodel.document.RangeïŒSTARTãENDïŒãTYPEïŒ
泚éã¯ããã®ã¡ãã»ãŒãžã«é¢é£ããæ å ±ãä¿åã§ããããã䟿å©ã§ãã
ããªããå šäœã«æ³šéãä»ããã«ã¯ã次ã䜿çšããŸãã
doc.AnnotateDocumentïŒTYPEãVALUEïŒ
ããªããã«äœããã®ã¿ã€ãã®æ³šéããããã©ããã調ã¹ãããã«ããããåŒã³åºãããŸã
doc.HasAnnotationïŒTYPEïŒ
ããã®ã©ããã§ããã®ãããªã»ããã¯ãç§ã«ãšã£ãŠã¯ããã§ã«äœãæçšãªããšãã§ãããããããäœæã§ããããã«æããŸãã ãã¡ãããããšãã°GAEããŒã¿ããŒã¹ã·ã¹ãã ããã®ä»ã®å¿«é©ãªãã®ã®äœ¿çšã¯ããã¹ãã®ç¯å²å€ã§ããããã§ããã°ããã¹ããå®å šã«åœ¹ã«ç«ããªãããšã¯ãªãã§ãããã
PSïŒãšããã§ãæåã¯éçºã倧ãã劚ããŠãããã°ã«æ°ä»ããŸãããappspotïŒå©çšå¯èœãªå¯äžã®ãããã°ããŒã«ïŒã®ãã°ã¿ãã§ãããã©ã«ãã§è¡šç€ºãããã¡ãã»ãŒãžã®ã¬ãã«ã¯Errorã«èšå®ãããŠããŸãã ãã€ã³ãã¯ãããšãã°Infoãªã©ã®ã¬ãã«ã®äžéšãæåã«ãã°ã¬ã³ãŒãã«è¡šç€ºããããã®åŸãšã©ãŒã®ããäžéšã®ã¿ã衚瀺ãããå Žåããã®ãããªã¬ã³ãŒãã¯è¡šç€ºãããªããšããããšã§ãã ãã®ããããããã°ã®ã¢ã©ãŒãã®ã¬ãã«ãåé 眮ããçºçãããã¹ãŠã®ãšã©ãŒãæ€èšããæ©äŒã«åãã§ããŸãã
PPSïŒããããšããé©åãªããã°ã«ç§»åããŸããã