ProxyLocal ProxyLocal could proxy your local web-server and make it publicly available over the internet. ãã¼ã«ã«ã®Webãµã¼ãã¼ã«ä»äººã«ã¡ãã£ã¨ã¢ã¯ã»ã¹ãã¦æ¬²ããæ(ä½ãã®å®é¨ä¸ã¨ã)ã«ä¾¿å©ãªgemã # app.rb: require 'rubygems' require 'sinatra' get '/' do ' â(´ã¼ï½)â' end ããããç³ã¢ããªããã£ãã¨ãã¦ãã¾ããã¼ã«ã«ã§ç«ã¡ä¸ããã % ruby app.rb == Sinatra/1.2.6 has taken the stage on 4567 for development with backup from Thin >> Thin web server (v1.2.11 codename Bat-Shit
ã¯ã¾ã£ãã®ã§ã¡ã¢ã£ã¦ããã æ®éã«ä»¥ä¸ã®ããã«ããã¨ã¨ã©ã¼ã«ãªã£ã¦ãã¾ãã %script{:type => 'text/javascript'} $(function(){ $('#new_link').click(function(){ alert('clicked'); return false; }); }); ã§ãä»æ¹ãªã以ä¸ã®ããã«ãããã ãã©ãå¾®å¦ãããâ¦ã¨æã£ããã ãã %script{:type => 'text/javascript'} $(function(){ $('#new_link').click(function(){ alert('clicked'); return false; }); }); Hamlã®API Documentã«ããã¨Filterã¨ããæ©è½ããã£ã¦ä»¥ä¸ã®ããã«ããã¨ãã¾ãããã :javascript $(function(){ $('#
Sinatraã§æ¸ãã¦ããwebã¢ããªã«èªè¨¼æ©è½ãå¿ è¦ã«ãªã£ãã®ã§ãsinatra-authenticationãã使ã£ã¦ã¿ãã¡ã¢ã æ¦è¦Rubyã§webã¢ããªãæ¸ãã®ã«å¤§äººæ°ã®Sinatraãã§ãwebéçºã§å¿ è¦ã«ãªãæ©è½ã£ã¦ã©ããªãã¬ã¼ã ã¯ã¼ã¯ã§ãããã¾ãå¤ãããªãã®ã§ããã®ãã¡ãèªè¨¼æ©è½ãå¿ è¦ã ããããªãã¦ãã¨ã«ãªãã æåã¯Rack::Auth::Basicã使ã£ã¦ããã®ã ããã¦ã¼ã¶ã®è¿½å / å¤æ´ãé¢åã ã£ãããã©ããæåãä¸å®å®ã ã£ãã(ä¸å®æéãã°ã¤ã³ã§ããªããªãã¨ããè¬ã®ä¸å ·åãåºãã)ããã®ã§ãä»ã®ã©ã¤ãã©ãªãæ¤è¨ãã¦ã¿ãã èªåã§ãããªæãã®ãã®ãä½ããããªã¼ã¨ãæã£ãã®ã ããã¾ãã¯ãããã®ã使ã£ã¦ã¿ãããã¨ãããã¨ã§ãsinatra-authenticationããå°å ¥ãã¦ã¿ãã ç°å¢CentOS 5.4MySQL 5.1.47apache 2.2.14ruby 1.
ååã¯ãSinatraãã¼ã¸ã§ã³1.0ã®æ¦è¦ãå ¬å¼ããã¥ã¡ã³ããæãããã¨ãã¦ãSinatraãç´¹ä»ãã¾ãããããã¦æå¾ã«ããâ Sinatraã®å ã«ã¯ãã¾ã å°å³ããªããã¨è¨åãã¾ããã ä»åã¯ããâ å®ä¸çã®Sinatraãã¨é¡ãã¦ãå®éã«Sinatraãå©ç¨ãã¦éçºãã¦ããããã§ã®ãçè èªèº«ã®ãã¼ããããã示ãã¦ããã¾ãã Sinatraã¨ã¯ãã£ããä½ã ãããªãã§ãããSinatraã¨ã¯ãã£ããä½ãªã®ã§ãããã ããã¯æ ¹æ¬çãªåãã«ãªãã¾ãããSinatraã§éçºãé²ããåã«ãããããã£ããèãããã¨ãéè¦ã§ããã¨çè ã¯èãã¾ãã ç´ ç´ã«èãããªãã°ãSinatraã¯ãã¡ãããåºç¾©ã®Webã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã®ä¸ã¤ã§ãããã¨çããããã§ããããã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã®ããããã®å®ç¾©ãããâ å ±éé¨åãåå©ç¨å¯è½ã«ããéçºãå©ãããã®ãã§ãããªãã°ãSinatraããã®ä¾ã«
ã¯ãã㫠第7åã¯Rails以å¤ã®Webãã¬ã¼ã ã¯ã¼ã¯ã®ç°¡åãªç´¹ä»ã¨ãSinatraã§Hello Worldã¢ããªã±ã¼ã·ã§ã³ãåããã¨ããã¾ã§ã解説ãã¾ãããä»åã¯Sinatraã§å®éã®ã¢ããªã±ã¼ã·ã§ã³ãä½ããSequelã¨Hamlã¨ãã2ã¤ã®ã©ã¤ãã©ãªãç´¹ä»ãã¾ãã Sinatraã®ç¹å¾´ã¯ãCGIã¹ã¯ãªããã®ããã«ãã¡ã¤ã«ä¸ã¤ããã¢ããªã±ã¼ã·ã§ã³ãæ¸ããæ°è»½ãã§ããCGIã¹ã¯ãªããã¨ããã°ã代表çãªãã®ã¯ä½ã¨è¨ã£ã¦ãæ²ç¤ºæ¿ï¼BBSï¼ã§ããããã§ãä»åã¯Sinatraã§æ²ç¤ºæ¿ã¢ããªãä½ã£ã¦ã¿ã¾ãããã½ã¼ã¹ã³ã¼ããå°ãé·ããªã®ã§ãgithubã«ã¦å ¨æãå ¬éãã¦ãã¾ããé©å®åç §ããªããèªã¿é²ãã¦ä¸ããããã¡ã¤ã«æ§æã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãã¾ãã start.rb ã¢ããªã±ã¼ã·ã§ã³ã®æ¬ä½ã model/comment.rb æ²ç¤ºæ¿ã®æ¸ãè¾¼ã¿ã表ãã¢ãã«ã®å®ç¾©ã view/index.haml ãã
æè¿ã¯ä»äºã§Sinatraã¢ããªãæ¸ããããã¦ããã®ã§ãSinatraã¢ããªãåããããã«ã¯ã©ã®HTTPãµã¼ãã使ãã®ããã¹ããªã®ããæ°ã«ãªã£ã¦ãããï¼å ã«çµè«ãæ¸ãã¦ããããã©ãã©ãããã¹ããã¨ããå¯ä¸ã®é¸æè¢ã¯ä»ã®ã¨ããããã¾ãããé©æé©æã§ããï¼ Sinatraã¯Rackã®ä¸ã«æ§ç¯ããã¦ããã®ã§ãRackã«å¯¾å¿ããHTTPãµã¼ãã¼ã使ã£ã¦åããäºã«ãªãã®ã ãããã®æ°ããããã¨å¤ããã©ãã使ãã°ããã®ãè¿·ãã代表çãªãã®ãæããã ãã§ããWebRick, Mongrel, Thin, Unicorn, Passenger(Apacheã¨ãã«çµã¿è¾¼ãã§ä½¿ããã¤), FastCGI, (æ®éã®)CGIããããããã¯é¸æè¢ãããï¼ããã¤ãHTTPãµã¼ããããªãç©ãæ··ãã£ã¦ããããRackã対å¿ãã¦ãã¨ããç¹ã¯å ±éãã¦ããï¼ã WebRickã¯ããããããã©ã¼ãã³ã¹ã«éç¹ãç½®ãã¦ããªãããMo
PerlCasual#02ã®æ親ä¼ã§æãã¦ããã£ã軽éWEBã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ Dancer(å ¬å¼ãµã¤ã: http://perldancer.org/)ã試ãã¦ã¿ã¾ããã Dancerã£ã¦Rubyã®Sinatraããã¸ã§ã¯ãã®ç§»æ¤ã¨ãã¦å§ã¾ã£ãã¿ããã§ãããSinatraèªä½ã¯ä½¿ã£ããã¨ãªããã§ããåããã¾ãããWEBä¸ã®ãµã³ãã«ã³ã¼ããè¦ãã¨ãæ§æã¨ãä¼¼ãããã«è¦ãã¾ãã ã¨ãããããPODãåç §ããªããç°¡åã«å®é¨ãã¦ã¿ã¾ããã ã¤ã³ã¹ãã¼ã« ã¤ã³ã¹ãã¼ã«ã¯CPANããã cpan Dancer ç°¡åãªãµã³ãã« hello.pl #!/usr/bin/env perl use Dancer; get '/hello' => sub { "Hello, world" } dance; use strictãuse warningsã¯ãã§ã«Dancerã«ãã£ã¦ãã¼ãããã¦ããã®
ããªãã è¨ã£ã¦ãã°ãã£ãã¼ã¯å®ã¯ããå®æãã¦ããã ãã©ããªãããµã³ãã«ã¢ããªã®ã¤ãããä½ã£ã¦ããã¡ã«æ®µã ã¬ããªãã¬ã¼ã ã¯ã¼ã¯ã¨åãã¦ãã¦ã大ããã¢ããªãããªãã®ã«ä¸èº«ã¯æå¤ã¨è¤éã§ããããã°ã ãããã¿ãããªãã¨ã«ãªã£ã¦ãã¾ã£ãã ãã¼ãããå ¬éãã¦ããããã©åèã«ãªããã¼ããªãã¤ã飽ãããªã¼ã¨ãæã£ã¦å¥ã®éã³ãå§ãããæå¤ã¨ãã£ã¡ã楽ãããªã£ã¦ãã¡ãã£ã¦ããããªãã®ãåºæ¥ãã faultier's Asagao at master - GitHub ä½ãã Plackã使ã£ã¦Sinatraã£ã½ãæãã§Webã¢ããªãæ¸ããé°å²æ°ã®ãã¬ã¼ã ã¯ã¼ã¯ã¿ãããªï¼å¼±ã ããï¼ãä¸å¿README.jaãèªãã¨ã©ããªãã®ãã¯ä½ã¨ãªãä¼ããããããªãããããããã¥ã¡ã³ãã¨ãµã³ãã«ã¢ããªãããã¯ä½ã£ã¦ã¿ããã¨ã¯æãã¾ãããä½ãã§ããã試ãã¦ã¿ãéã«ã¯ã½ã¼ã¹èªãã§ãã ãããï¼è¿½è¨ï¼ç°¡åãªãµã³ãã«ã³ã¼ãã¨ããã¥ã¡ã³
Sinatraã¯ããã§ããã¦ã§ãã¢ããªéçºç¨ãã¬ã¼ã ã¯ã¼ã¯ã ã¨æããåã«ãæ¸ããããURLããå¼ã³åºãããã¡ã½ããã決å®ããã¨ãããããã§ãã¦ããããä¾åããã©ã¤ãã©ãªãRackã ããªã®ã§ä½¿ãããããbeforeãã£ã«ã¿ã®åå¨ãstatus, content_typeã¨ãã£ãã¡ã½ãããªã©ãç´°ããã¨ããã¾ã§éçºããããããããã«ä½ããã¦ããããã«æããã ããããSinatraã¯Rubyã§æ¸ããã¦ããã®ã§ãä»ã®è¨èªã§ã¯ä½¿ããªãã趣å³ã§æ¸ãã¦ãããªãRubyã使ãã°ãã話ãªã®ã ããä»äºã ã¨ããããããªããã¨ãããã ããã ããã§ãSinatraã«ä¼¼ãæãã§ä½¿ããããªãã¬ã¼ã ã¯ã¼ã¯ãæ¢ãã¦ã¿ãã â»ã³ã¡ã³ãæ¬ãªã©ã§æãã¦ããã ãããã®ãããã¤ã追å ãã¾ãããæè¬ï¼ sinatra-on-perl perlç¨ http://code.google.com/p/sinatra/ ååã®éããããªãS
ãµãã¨ã¯å½¼å¥³ã®èªå® è¿ããæ¹åå°é§ åã®ã¹ã¼ãã¼ãã¼ã±ããã§å¾ ã¡åãããããã彼女ã¯èªè»¢è»ã§å¾ãã追ãã¤ãã¨è¨ããåã¯å¤§ããªã³ã¤ã³ãã¼ãã³ã°ã¸è»ãåãããç èãä¸æ¬å¸ã£ã¦ããã¹ã¼ãã¼ãã¼ã±ããã¸åããã¨ãã²ã£ãããªãã«ä¸»å©¦çãªå¥³æ§ããã°ãã¡ãããå ¥ãå£ãåºããå ¥ã£ãããã¦ãããæå»ã¯åå¾5æã«ãªããæè¨ããç®ãä¸ããã¨ãå¾ ããã¡ãã£ãããã¨å¤§ãã¦æªã³ãã¦ãªãæ§åã§ãµããæã¶ãã§ãã£ã¦ããã ã礼ã«æçãä½ãã¨ã¯ããããµãã®å®¶ã«ã¯é£æãåå足ãã¦ããªããããããããã¦ã¹ã¼ãã¼ãã¼ã±ããã«å¯ããã¨ã«ãªã£ãããµãã¯éèã³ã¼ãã¼ããç²¾èã³ã¼ãã¼ã¾ã§ãã¾ãã§åªç§ãªã«ã¼ããã«å°ãããããã«ç¡é§ãªãç¹æ¤ãã¦ãã£ãã欲ããé£æãããã¨ã2ç§éç¨åº¦ããããåè¦ããä¸åº¦æã«åã£ããããããããè±èãããè¿·ããã¨ãªãåãæã£ã¦ããã«ã´ã«æ¾ãè¾¼ãã ãæå¾ã«ã¢ã«ã³ã¼ã«é£²æãå·ãããã¦ããæ£ã®åã¸è¡ãã¨ãç§ã飲ãããã¨ã
nginx 㨠thinã®çµã¿åãããéããããã®ã§å¤æ´ãã¦ã¿ããã¨ã«ããã ç¾å¨éç¨ãã¦ããã®ã¯ Railsã¢ã㪠x 2 Sinatraã¢ã㪠x1 Webdav (git) webdavã«ã¤ãã¦ã¯å¥éæ¸ãã¨ãã¦ã¨ããããrailsã¢ããªã¨Sinatraã¢ããªãthinã«ããªãã¼ã¹ãããã·ãnginxã«ãã¦ã¿ãã ã¡ãªã¿ã«ç°å¢ã¯CentOS 4.6 以ä¸ä½æ¥ãã° nginxã®ã¤ã³ã¹ãã¼ã« $ sudo su - # cd /usr/local/src # wget http://nginx.org/download/nginx-0.7.65.tar.gz # yum install pcre-devel zlib-devel openssl-devel # tar -zxvf nginx-0.7.65.tar.gz # cd nginx-0.7.65 // configure ã®åè
ææªã ã Sinatra ã CGI ã§åãããã¨ãã¦ãåå ä¸æã®ã¨ã©ã¼ãçºçããåå ãç¹å®ããã¾ã§ã«åæ¥ãããè¦ããã ã½ã¼ã¹ #! /usr/local/bin/ruby require 'rubygems' require 'sinatra' get '/' do 'Hello world!!' end å®è¡æ¹æ³ % ruby sinatra.rb ã¨ã©ã¼ã®å 容 ./sinatra.rb:6: undefined method `get' for main:Object (NoMethodError) from /home/yamamucho/local/lib/rubygems/custom_require.rb:31:in `gem_original_require' from /home/yamamucho/local/lib/rubygems/custom_require.r
Sinatraã0.9.2ã«updateããã¨ã以ä¸ã®ã¨ã©ã¼ã«ãªã£ã¦çµã¿è¾¼ã¿ã®WEBrickã§åããªããªã£ã¦ãã¾ã£ãã /usr/lib/ruby/gems/1.8/gems/sinatra-0.9.2/lib/sinatra/base.rb:930:in `detect_rack_handler': Server handler (thin,mongrel,webrick) not found. (RuntimeError) from /usr/lib/ruby/gems/1.8/gems/sinatra-0.9.2/lib/sinatra/base.rb:862:in `run!' from /usr/lib/ruby/gems/1.8/gems/sinatra-0.9.2/lib/sinatra/main.rb:34 ...sinatra/base.rbã®921è¡ç®ãdetect_r
SinatraãRailsã¯éçºã¯æ¥½ã ãã©ãããã¤æ¹æ³ããããããã£ã¦æ©ãã æè¿ã¯passengerã使ãæ¹æ³ãæµè¡ã£ã¦ããã©ãããã«ãå¦æ ¡ã«ç½®ãããµã¼ãã¼ã§ãµããã¡ã¤ã³ã使ããªãã®ã§åä¸ãã¹ãåã§apacheã¨å ±åããããããªãã passengerã§ãRailsBaseURIã ã£ããï¼ãè¨å®ããã°ãµããã£ã¬ã¯ããªã§Rack対å¿ã¢ããªãåããããã ä»åã¯1å¹´åããRails+mongrelã®ãããã¤ã«ä½¿ã£ã¦ããapache2ã®ãµããã£ã¬ã¯ããªãmongrelã§èµ·åãã¦ãrailsã«ãããã·ãã â æ©æ¬è©³è§£ã¨åãæ¹æ³ã§Sinatra+Thinããããã¤ããã Railsã§ã¯mongrel_clusterã§è¤æ°èµ·åãããrailsã«apache2ã®mod_proxy_balancerã§ã¢ã¯ã»ã¹ãå²ãæ¯ã£ãããåãè¨å®ã§sinatra+thinã«ãå²ãæ¯ããã çµæãæ©æ¬åä¼ Twitt
ç®æ¨çã«ã¯Railsã®ä¸ã«sinatraãããã«ã¦ã§ã¢ã¨ãã¦rackupããã¤ããã ç¾æç¹ã§ã¯åä½ã§åãããã°è¯ãã®ã§ãã®è¾ºãã¾ã§ããªã rack,sinatra,thinã¯ããã£ã¨gem installãã¦ããã¾ãããã¶ãã©ããå ¥ããã°rackãå ¥ãã¯ãããã°ã¨ã£ã¦ãªãã£ãã nginxã¯ã½ã¼ã¹ãã¡ã¤ã«ããã¤ã³ã¹ãã¼ã«ãã¾ããstableã§ãã # wget http://sysoev.ru/nginx/nginx-0.6.35.tar.gz # tar zxvf nginx-0.6.35.tar.gz # cd nginx-0.6.35 # ./configure --prefix=/usr/local/nginx --with-http_ssl_module # make # make install # cd /usr/local/nginx/conf # vi nginx.co
å人çã«Sinatraã¨Limonadeããã¤ãã¼ã ãªã®ã§ãããSinatraã«é¢ãã¦è¨ãã°ãCGIã§åããæ¹æ³ã¯(æ¬å®¶ã®ããã¥ã¡ã³ãã¨ãã§ã¯)ãã¾ããã©ãã¼ããã¦ããªãããã§ããå½å ã§ã¯ãããªãã«è¨äºããããããªã®ã§ãããçµå±ã½ã¼ã¹ã«æãå ¥ãã¦ãã¾ãï¼Sinatraã®ã½ã¼ã¹ã«ãRack::Handler::CGI.runãããã¿ã«æ¸ãï¼ããrackupã§å®è¡ããæ¹æ³ããå¤ãããã§ããåè ã¯CGIå°ç¨ã«ãªã£ã¦ãã¾ãã®ã§ãã¾ãã¡ã ããå¾è ã¯ã·ã§ã«ãï¼åå®è¡ãããã®ãã©ãã«ãç¾ããããã¾ããï¼ç¾å®çã«ã¯ãã¾ãåé¡ã«ãªããªãã®ããããã¾ãããï¼ã ããã§ããããããã£ã¦ã¿ãã¨ãããä½ã¨ãè¯ãããªæ¹æ³ãã§ãã¾ããã ã¾ãSinatraã®ã½ã¼ã¹ãé©å½ã§ãã require 'rubygems' require 'sinatra' set :run, true get '/?' do "hello"
Twitterã«ã¯ãã¹ããªã¼ãã³ã°APIã¨ãããããã·ã¥ã§ãªã¢ã«ã¿ã¤ã ã«æ å ±ãåãåããã¨ã®ã§ããAPIãç¨æããã¦ãã¾ãã ããã使ãã°ãå®æçã«ãã¼ãªã³ã°ãããããããã¨ãªãã誰ããçºè¨ããæç¹ã§å³åº§ã«ã¡ãã»ã¼ã¸ãåãåãã¾ãã ããããããã使ãããã«ã¯ãTCPæ¥ç¶ãTwitterã«å¯¾ãã¦å¼µãã£ã±ãªãã«ãã¦ããå¿ è¦ããããWebã¢ããªãªã©ã§ä½¿ãã®ã«æ·å± ãé«ãã¨æãã¦ãã人ãããã®ã§ã¯ãªãã§ããããã ä»åã¯ãããããªãã¨ãªãããè¶ ç°¡åã ããã¨ãããã¨ããRubyãã¼ã¹ã®ãµã³ãã«ã§ç¤ºãããã¨æãã¾ãã ãªããããªãã¨ãç°¡åã«ã§ããã®ãããã®ç§å¯ãå ã«ç¨®æããããã¨ãRubyç¨ã®Webãµã¼ãã¨ãã¦æ¥éã«äººæ°ãç²å¾ããããã¡ã¯ãã®åº§ãã¨ãã¤ã¤ãããThinãã¨ããWebãµã¼ãããå é¨çã«EventMachineã¨ããéåæãµã¼ãã使ç¨ãã¦ããã®ã§ããã®æ©è½ã使ããã¨ã§ãä»ã¾ã§ã®Webã¢ããª
This page is also available in English. å§ããã Sinatraã¯Rubyã§ä¸è¨ã®ãããªæå°å´åã§ææ©ãã¦ã§ãã¢ããªã±ã¼ã·ã§ã³ãä½æããããã®DSLã§ãã # myapp.rb require 'rubygems' require 'sinatra' get '/' do 'Hello world!' end gemãã¤ã³ã¹ãã¼ã«ãã¦åããã¦ã¿ãã sudo gem install sinatra ruby myapp.rb localhost:4567 ãè¦ãã ã«ã¼ã Sinatraã§ã¯ãã«ã¼ãã¯HTTPã¡ã½ããã¨URLãããã³ã°ãã¿ã¼ã³ããã¢ã«ãªã£ã¦ãã¾ãã ã«ã¼ãã¯ãããã¯ã«çµã³ä»ãããã¦ãã¾ãã get '/' do .. ä½ãè¦ãã .. end post '/' do .. ä½ãçæãã .. end put '/' do .. ä½ãæ´
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}