PrePANã®Webã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ãAmon2ã«å¤æ´ãã¾ãããé²è¦§è çã«ã¯ä½ãå¤ããã¨ããã¯ãªãã®ã§ç¹ã«æå³ã¯ãªãã§ãããä»å¾ã®æ©è½éçºããããããªã£ãã®ã§ãçµæçã«ã¯ããå½±é¿ã¯ããã¨æå¾ ãã¦ããã¨ããã§ãã WAFã¯ãYAPC::Asia 2011ã§ã®cho45ããã®çºè¡¨ãã¼ãã®ããããããããããã®ããã¶ãã·ããã¼ããããµãã¼ããã¼ããã«ããããã«ãèããã¬ã¼ã ã¯ã¼ã¯ããããè¯ãã¨æè¿ã¯æãã¦ãã¾ããPrePANã¯ã¾ããç¹ã«å¤ãã£ããã¨ããã¦ããªãã¢ããªãªã®ã§ããã¡ã¤ã³ã¹ãã·ãã£ãã¯ã«å¯¾å¦ããã¹ããã¨ããªããã¾ããä¸æã«èªä½ããããããAmon2ã®æ¹ããã£ã¨ãããã®ã§ãããã¨ãæç½ãªã®ã§ãä»åã¯Amon2ã使ããã¨ã«ãã¾ããã ã¨ããããã§ãAmon2ä½è ã®tokuhiromããã«ãAmon2使ãã¾ãã!!1ãã¨è©±ããã®ãå®è¡ã§ããããPrePANã¯ããããã¨æ©è½è¿½å ã®
使ç¨ãã¼ã«ãªã© amon2(flavor=Basic) perl 5.16.3(plenv 使ç¨) carton Supervisor ï¼ä¸è¬ã¦ã¼ã¶ã¼åãhomepageã¨ãã¦ããï¼ ä»åã¯ãããã¤ã®ããã«amon2ã§ä½ã£ãã¢ããªããã¼ã¢ã³åãããã¨ãããã-Dãªãã·ã§ã³ã§ãã¼ã¢ã³åãã§ããªãã£ããããsupervisorãå°å ¥ãããã¨ã«ããã ï¼â»æ¦è¦ãªã©ã¯ãã¡ãã®ããã°ãåèã«ãã¦ã¿ã¦ãã ãããâãhttp://blog.hakutoitoi.com/?p=343) Supervisorã®ã¤ã³ã¹ãã¼ã« # yum install python-setuptools # easy_install pip # pip install supervisor å¿ è¦ãªãã£ã¬ã¯ããªãä½æ # mkdir /var/log/supervisord # mkdir /etc/supervisord.d
Amon2ããApache+mod_perlã§ã¯ã©ãã«ããã¾ãåãã¦ãããªãï¼ãã¼ã ãã£ã¬ã¯ããªãããããªãããããè¦æããã«ãã¹æå®ã«ããã³ã¼ãã®ä¿®æ£ãå¿ è¦ï¼ãApacheã®è¨å®ãæªããã ããããä½ãæªããã ãããããããªãã ããã§ãããããªãã¤ãã§ã«ãå ¨ãéãåä½ç°å¢ã試ãã¦ã¿ããã¨ã«ããã ããã¯ã以ä¸ã®ãã¼ã¸ã§è§£èª¬ããã¦ãã Supervisor ããã³ Starman ãç¨ããç°å¢ã§ããã supervisordã¨clelrydã®è¨å® FreeBSD㧠Supervisor ã使ã ãªãããµã¼ãã¼ã®OSã¯Ubuntu11.10ã§ããã ã¾ããeasy_installã§Supervisorãã¤ã³ã¹ãã¼ã«ããããã«ããããããpythonã®setuptoolsãå ¥ãã¦ããã apt-get install python-setuptools ãã®å¾ã«Supervisorã®ã¤ã³ã¹ãã¼
Perlã®ã¦ã§ãã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã®Amon2ã使ãã¨ãModelã£ã¦ã©ãããã®?ã£ã¦çåã沸ãã¾ããã?Largeãã¬ã¼ãã¼ä»¥å¤ã§ã»ããã¢ããããã¨ãã·ããã©ãªãã·ã¥ãªDispatcher(Router)ã§ã»ããã¢ãããããã®ã§ãåºæ¬çã«ã³ã³ããã¼ã©ã¼ã«å ¨é¨å®è£ ãã¦ãã¾ããããªã¼ã£ã¦æ°ã«ãªããã§ããã©ããããããªãMVCãæèããã±ã¼ã¹ã¯ã©ããããããªã¼ã¨ããæã®ãªã¬ãªã¬çæ³ã®è¦ä»¶ã§ãã MVCçãªWAFã®å®è£ ã«ã¤ã㦠ã¦ã§ãã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã使ãã¨ãM(ã¢ãã«)ã¨V(ãã¥ã¼)ã¨C(ã³ã³ããã¼ã©ã¼)ã®3ã¤ã«ããã¦ã¯ã©ã¹è¨è¨ãè¡ãã®ãåºæ¬ã¨è¨ããã¦ãã¾ãããç´°ããå®è£ ãã©ãã«æã£ã¦è¡ãããæ©ãã±ã¼ã¹ã«ãã°ãã°åºãããã¾ãããã¨ãã«ãèããã¬ã¼ã ã¯ã¼ã¯ã¨è¨ãããWAFã»ã©ãModelã«ã¤ãã¦ã¯ãã¼ã¿ããã§èªç±ãªè¨è¨ãéã«ã§ãããã¦æ©ãã§ãã¾ããã¨ããã°ãã°ã§ã¯ãªãã§
ãµã£ã¤ãã£ãã§ã! tokuhirom ã§ãã % amon2-setup.pl --flavor=Lite Foo ã¿ããã«ãã¦ããã¬ã¼ãã¼ãã¿ãªããæå®ãããã¨ãããã¾ãããããã®ã¤ããããã®è©±ãããããã¨ãããã¾ãã æ¨æºæ·»ä»ã®ãã¬ã¼ãã¼ ç¾å¨æ¨æºæ·»ä»ã® Flavor 㯠Amon2::Setup::Flavor::Basic 㨠Amon2::Setup::Flavor::Minimum ãã㦠Amon2::Setup::Flavor::Large ã§ãã ããããã®ã¤ãããããããããããªãã¨ãããã¨ãããããã®ã§ãããããã®ä½¿ãåããããããã«ããã次第ã§ãã Amon2::Setup::Flavor::Basic ãããä¸çªã®åºæ¬å½¢ã§ããBasic ã¨ãªã¥ãã¦ããã¨ãããããæç½ã§ãããããããã¾ãã«ããã©ã«ãã§ãã ã¨ãã«çç±ããªããã°ãããããããããªãã§ãããããã¨ã
1. ã¹ãã¼ããã©ã³åããµã¼ãã¹ã«ããã ãµã¼ããµã¤ãè¨è¨å ¥é 2012/09/28 hatak at YAPC::Asia Tokyo 2012 2. èªå·±ç´¹ä» ⢠hatak (HATAKEYAMA Hisashi) @hisashi hatak ⢠ãããåºåä¼ç¤¾ â ã½ã¼ã·ã£ã«ã²ã¼ã ä¼ç¤¾ ⢠ã¤ã³ãã©ãéç¨å¯ãã®ä»äºããã¦ããã¨ãå¤ãã§ã ⢠ããã¨ãªãã§ã ⢠ã¤ã³ãã© / MySQL / Perl ãªå ´æã«æã ãã¾ã 3. ãã®ãã¼ã¯ã®å 容 ⢠ä»å¹´æ¥ããæ°è¦ãµã¼ãã¹ã®ç«ã¡ä¸ããè¡ããã¨ã« ⢠å ã ã¤ã³ãã©ãéç¨ãã¡ã¤ã³ã ã£ãã®ã§ããããã試è¡é¯èª¤ãããã¨ã« ⢠ãã®ãµã¼ãã¹ãå®ä¾ã¨ãã¦ç´¹ä»ããªãã説æ ⢠ããããã¨æã£ãã®ã§ãããã¾ã ãªãªã¼ã¹ããã¦ããªããã ⢠代æ¿ã®ä¾ã¨ãã¦ã·ã³ãã«ãª SNS ãä½ãæµãã§æ´çã»èª¬æãã¾ã ⢠æ¦èª¬çã¨ããããPerl ã«éããªã話ãåºã¦
æ¬é£è¼ã§ã¯ç¬¬ä¸ç·ã®Perlããã«ã¼ãåæ¿ããã§å·çãã¦ããã¾ããä»åã¯æ®æ®µWebã¢ããªã±ã¼ã·ã§ã³ã®éçºãè¡ã£ã¦ããtokuhiromããã§ããã¼ãã¯Webã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯Amon2ã§ãã Amon2ã¨ã¯ï¼ ããã«ã¡ã¯ãtokuhiromã§ããæ¬ç¨¿ã§ã¯ãçè ãä¸å¿ã¨ãªã£ã¦éçºãé²ãã¦ããAmon2ã¨ããWebã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã«ã¤ãã¦èª¬æãã¾ãã Amon2ã¯ã次ã®ãããªç¹å¾´ãæã¤Webã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã§ãã PSGI/Plackãã¼ã¹ Amon2ã¯HTTP::Engine/PSGI/Plackã®éçºï¼å¶å®ã«åæã®ããããé¢ãã£ã¦ããçè ãä½æããWebã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã§ãããã®ãããPlackã®é¨åãã§ããéãå©ç¨ãããã¨ã«ãããå°ãªãã³ã¼ããã¼ã¹ã§Webã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ãå®ç¾ãã¦ãã¾ããããã«ããå¦ç¿ã³ã¹ããä½ããªã£ã¦ã
æè¿ãAmon2 ã®ãªã¢ã«ã¿ã¤ã Webãµãã¼ãããããªãã¾ããã ããã«ãããWebSocket ã Long poll ãã¤ããã¦ã§ãã¢ããªã±ã¼ã·ã§ã³ã Amon2 ã§ç°¡åã«ãããã¨ãã§ãã¾ãã ã¨ããããã¹ããªã¼ãã³ã°ãã¡ãã£ã¨ããã ãã§ãTatsumaki ãåå¼·ããªãããããªãã®ãé¢åã ã£ãã®ã§ãã¤ããã¾ããã Amon2::Plugin::Web::Streaming ã¨ãããã©ã®ã³ããä»åã®ãã¼ã¸ã§ã³ã§ã¤ãã¦ãã¾ãããããã¤ããã¨ããã¾ã§ Tatsumaki ã§ãã£ã¦ãããããªãã¨ããç°¡åã« Amon2 ã§ã§ããããã«ãªãã¾ãã MXHR ã«ã¯å¯¾å¿ãã¦ããªããã©ãWebSocket 㨠streaming ã«å¯¾å¿ããã®ã§ãAmon2 㧠Tatsumaki ããã£ã¦ããé åã¯ãµãã¼ãã§ããã¨ãããã¾ããã¨ãããèªåãã¤ãã£ã¦ãç¯å²ã§ã¯ããã§ååã§ãã 以ä¸ããã£ããã®ãµã³ãã«ã§
Amon2::Plugin::Web::WebSocket ã¨ãããã©ã°ã¤ã³ãã ãã¾ããã Amon2 ã®ä¸ã§é常ã«ç°¡åã« web socket ãã¤ããã¾ãã ãªããããããããä½æ³ã¨ããã¼ããªãã¦ãããã®ã§æ¥½ããããã å®è£ ä¾ã¯ä»¥ä¸ã®ã¨ããã§ããTwiggy ã§ãããããã¾ããã use strict; use warnings; use utf8; use Amon2::Lite; use Digest::MD5 (); get '/' => sub { my $c = shift; return $c->render('index.tt'); }; my $clients = {}; any '/echo2' => sub { my ($c) = @_; my $id = Digest::SHA1::sha1_hex(rand() . $$ . {} . time); $c->we
FacebookAPIã使ãè¦ä»¶ãåºã¦ããããªã®ã§ãããã調æ»ä¸ã perlã§FacebookAPIã使ãã«ã¯Facebook::Graphããããã§ããããï¼ Facebook::Graphã®ããã¥ã¡ã³ãã«ã¡ããã©ãã¥ã¼ããªã¢ã«ããã£ãã®ã§ 試ãã«ä»åã¯ãã®æé éãã«è¨å®ãã¦ããããã¨æãã¾ãã ãã ããã®ã¾ã¾ã§ã¯ãªãä¸é¨Amon2ç¨ã«ç½®ãæãã¦ã¾ãã ã¾ããä»åã¯è¡¨ç¤ºãããã¼ã¿ãèªåã®ãã¥ã¼ã¹ãã£ã¼ãã«ãã¦ã¿ã¾ããã ãã¨ãFacebook ã¢ããªç»é²ç»é¢ã£ã¦ãã°ã¤ã³ãããã³ã¡ããã¡ããå¤ãã£ã¦ã¦ ä»ã®ãµã¤ãã®è¨å®ç»é¢ãåèã«ãªããªãã£ããããã®ã§ ã¹ã¯ãªã¼ã³ã·ã§ãããæ·»ä»ãã¦ã¿ã¾ãããã Step 1: Set up the developer application on Facebook. https://developers.facebook.com/ ã«è¡ãã¾ãã Step
ã¢ãã³ãªæã㧠perl ã§ã¦ã§ãã¢ããªä½ããããªã¼ã¨æã£ã¦ã»ãã»ããã¦ã¾ããã¡ã¢æ¸ãã æè¿ã®æµè¡ãã§ã¯ãsystem perl ãªãã¦ãã使ããªãããã§ãèªå㧠perl ã make ãã¦å ¥ãããã®ããããç°¡åã«ç®¡çã§ããã®ãperlbrewãã§ãã¢ããªæ¯ã« perl ãå ¥ãã¦ããããªãã¨ã¯æã£ããã§ããããããã«ããã¾ã§ä»°ã ãããããã¯ãªããã§ããCPAN ã¢ã¸ã¥ã¼ã«ã«ã¤ãã¦ã¯ã¢ããªæ¯ã«ä¾åãç¡ãããã«ããã(ããã¢ããªãå¤ã«ãã¼ã¸ã§ã³ã¢ãããã¡ãã£ã¦ä»ãåããªãã¨ãå«)ã ã©ãããã®ãããããªã¼ã¨è²ã èãããã§ãããããããã° miyagawa ããã®Cartonã¨ããã®ããä¾åé¢ä¿ããã¼ã¸ã§ã³ãå«ã㦠CPAN ã¢ã¸ã¥ã¼ã«ç®¡çã§ããã¨ãããã¨ã§ãããã¢ããªæ¯ã«ä½¿ãã®ãæ£çµ±ã ãããªã¨æã£ãã®ã§ä½¿ã£ã¦ã¿ãã ã¾ã㯠perlbrew ã§ã¤ã³ã¹ãã¼ã« ããã¯èª¬æã®éãã $ curl
[1]http://d.hatena.ne.jp/ockeghem/20110907/p1[2]http://www.atmarkit.co.jp/fcoding/articles/webapp/05/webapp05a.html[3] http://msdn.microsoft.com/ja-jp/asp.net/ff713315[4] http://labs.cybozu.co.jp/blog/kazuho/archives/2007/01/cross-site_including.phpããããããã§ãJSON ã¨ã»ãã¥ãªãã£ã«ã¤ãã¦ããããã¦ã¿ãã ããã§ãæå¹ã¨ããã¦ãã対çã®ãã¡ while(1); ãå é ã«ä»ä¸ããPOST ã§ãã¹ã¦å¦çããã¨ãã£ããããã¯ãRESTful ã§ãªãããBK æãã²ã©ãã¨ãããæ¬è³ªçã§ã¯ãªãã®ã§ã§ããã ããããããªãã ã¾ããAmon2 ã§ã¯äºæ
Amon2 ã®ãã©ã°ã¤ã³ã®æ¸ãæ¹ãããããããªãã¨ãã話ããã¾ã«èãã®ã§ããã®ã¸ãã«ã¤ãã¦èª¬æãããã¨ãããã¾ãã åºæ¬çã«ã¯ãã©ã°ã¤ã³ã¯ãã ã® Perl ã¢ã¸ã¥ã¼ã«ã§ããã ä¸ã¤ã®è¦ç´ã«ããããã°åé¡ããã¾ããããã㯠'init'ã¨ããååã®ã¯ã©ã¹ã¡ã½ããããã£ã¦ããã¨ãããã¨ã§ãããã ããã ãã§ãã package MyPlugin; sub init { } 1;ããã§ãã²ã¨ã¤ã® valid ãªãã©ã°ã¤ã³ã§ãã ãã¦ããªã«ãããªããã©ã°ã¤ã³ãã¤ãã£ã¦ããããããªãã®ã§ãã¡ãã£ã¨æ©è½ãããã¦ã¿ã¾ãããã package MyPlugin; sub init { my ($class, $context) = @_; $context->add_trigger( AFTER_DISPATCH => sub { my ($self, $res) = @_; $res->header('X-
ååãã大åæéãçµã£ã¦ãã¾ãã¾ããããåçªã« Amon2+Teng ã§å¤§ããã®ã¢ããªãã¤ãããã¥ã¼ããªã¢ã«ã§ãã¯ããã¾ããããTeng ã¨ããã®ã¯ãO/R Mapper ã¨ãã°ãã種é¡ã®ã©ã¤ãã©ãªã§ãDB ã¸ã®ã¢ã¯ã»ã¹ãç°¡åã«ãã¦ããããã®ã§ãã ãã¦ãã¨ã«ãããæºåããã¯ããã¾ãããã % cpanm Amon2 Amon2::Setup::Flavor::Teng Teng㧠Amon2 ãã¤ã³ã¹ãã¼ã«ãã¾ãã % amon2-setup.pl --flavor=Large,Teng MyBBSã¨ããã¨ã¹ã±ã«ãã³ãã§ããããã¾ãã®ã§ % cd MyBBSã¨ãã¦ãããã¸ã§ã¯ãç¨ã®ãã£ã¬ã¯ããªã«ã¯ããã¾ãã %cpanm --installdeps .ã¨ããã¨ãä¾åã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ããã¾ãã % plackup app.psgi -R libã¨ãã¤ã¨ããµã¼ãã¼ããã»ã¹ãèµ·åãã¾ã
ãã¦ãæ²ç¤ºæ¿ãã¤ãã£ãã¨ã¯ãããããã ãã§ã¯ãããããããã¾ãããã ã¾ããã®æ²ç¤ºæ¿ã«ã¯é大ãªæ¬ é¥ãããã¾ããå ·ä½çã«ããã¨ããã¼ã¸ã³ã°ãããã¦ãã¾ããã ã¦ã§ãã¢ããªã±ã¼ã·ã§ã³ã«ããã¦ã¯ãã¼ã¸ã³ã°ã¯é常ã«éè¦ãªè¦ç´ ã§ãã ãªã«ããä¸è¦§è¡¨ç¤ºãããã¼ã¸ãã¤ããã¨ãã«ããã¼ã¸ã³ã°ã®ãã¨ãæãããã°ãªãããã§ã¯ä¸äººåã®ã¦ã§ãã¨ã³ã¸ãã¢ã¨ã¯ããã¾ããããã¼ã¸ã³ã°ãææãããã¨ããã¨ãã¨éããã¼ã¸ã«ãªã£ã¦æ³£ããã¨ã«ãªãã§ãããããã¼ã¸ã³ã°ã¯æåã®æ®µéã§ããã¦ããã®ãçµå±ã¯æ¥½ãªã®ã§ã(ã¨ããèªæ)ã ãã¦ãä»åã®æ²ç¤ºæ¿ã§ã¯ Teng ãã¤ãã£ã¦ããã®ã§é常ã«ãã¼ã¸ã£ã®å®è£ ã容æã«ãªã£ã¦ãã¾ããTeng ã§ã¯ãã¼ã¸ã£é¢é£ã®å®è£ ã¯ãã©ã°ã¤ã³ã¨ãªã£ã¦ãã¾ããããTeng ã« Teng::Plugin::Pager ããã¿ãã¾ãã¾ããããlib/MyBBS/DB.pm ã«ä»¥ä¸ã®ããã«ããã¾ãããã packa
DBã®è¨å®ãªã©ã¯ãã¡ãã«æ²¿ã£ã¦ãã¾ãã ä»åã¯ã以ä¸ã®ã³ãã³ãã§ã¢ããªã±ã¼ã·ã§ã³ã®éå½¢ãä½æããå ´åã§ãã $ amon2-setup.pl Hello config/development.plã®ç·¨é Tengç¨ã®è¨å®ãæ¸ãã¦ããã¾ãã +{ 'Teng' => { dsn => 'dbi:SQLite:dbname=hello.db', username => '', password => '', }, ... }; ã¹ãã¼ãä½æã¹ã¯ãªãã DBã®æ å ±ãèªã¿è¾¼ãã§ã¹ãã¼ããä½æããã¹ã¯ãªãããæ¸ãã¾ãã use strict; use warnings; use DBI; use FindBin; use File::Spec; use lib File::Spec->catdir($FindBin::Bin, '..', 'lib'); use lib File::Spec->ca
Amon2::Lite ãå¥ dist ã«åé¢ããã¾ãã(Amon2::Lite ãã¤ãã£ã¦ããã¢ããªã§ã¯ Amon2::Lite ã¸ã®ä¾åãæ示çã«è¨è¿°ããããã«ãã¦ãã ãã)å種ä¾åããããªããªãã¾ããXslate ã§ã¤ãã bridge ã®ããã©ã«ãã Star ã«ãªãã¾ããã Star ãã¤ããã«ããã£ããããå ´åã®ãè¦æ㯠#xslate ã¾ã§Pragma: no-cache; Cache-Control: no-cache ãããã©ã«ãã«ãã¦ãã¾ãããããªã«ãã¨åé¡ãããã®ã§ Cache-Control: private ãããã©ã«ãã«ãã¾ããcarton ãã¤ãã人ããµãã¦ããã ããã¨ããäºæ¸¬ã®ãã¨ãä¾åãã¸ããå¤æ´ããã¦ãã¾ããAmon2::Lite ãå¥ dist ã«ãªã£ãã®ãå¯ä¸ã®éäºæãªå¤æ´ãã¨ãããã¾ããAny::Moose ã®ããã¿ã§ Moose ãã¤ã³ã¹ãã¼ã«ã
http://prepan.org/module/3Yz7PYrByB åãã¦ã®Amon2å ¥éã !!1ã¨ããããæè¿ãªãªã¼ã¹ãããã°ããã®Amon2::Authã¢ã¸ã¥ã¼ã«ãã¤ãã£ã¦ãã¯ã¦ãªèªè¨¼ãå®è£ ãã¦ã¿ãã!!1PrePANã«ãç»é²ããã!!1ã¬ãã¥ã¼ãããã!!1 Amon2::Auth::Site::Hatena ã¸ã®ä¾åã Makefile.PL ã«è¨å®ãã!!1 requires => 'Amon2::Auth::Site::Hatena'; config/development.plã«è¨å®ããã!!1å®éã«ã¯ãµã¤ãä¸ã§åå¾ããconsumer_keyã¨consumer_secretãè¨å®ãã!!1redirect_uriã¯å®éã®URLã ã£!!1!!1å ·ä½çã«ã¯"http://localhost:5000/auth/hatena/callback"ãªã©ã«ãªãã ãã!!1 conf
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}