This extension is part of the Sinatra::Contrib project. Run gem install sinatra-contrib to have it available. Sinatra::ConfigFile¶ â Sinatra::ConfigFile is an extension that allows you to load the applicationâs configuration from YAML files. It automatically detects if the files contain specific environment settings and it will use those corresponding to the current one. You can access those optio
ã¢ã»ãããã¤ãã©ã¤ã³ãªã©ã§ä½¿ããã¨ãã¦è©±é¡ã® Sprockets gem ãèªååãã¾ã¨ãã確èªããªãã§æ¸ãã¦ããã¨ãããããã¾ãã ã¢ã»ãããã¤ãã©ã¤ã³ãæ¯ããæè¡ â sprockets Sprockets: Rack-based asset packaging Web assets ãå ·ä½çã«ã¯ä¸»ã« CSS 㨠JavaScript ã®å§ç¸®/ä¾åæ§ã®è§£æ±º/å種ã½ã¼ã¹ããã®å¤æããµãã¼ãããããã® Rubygem ã asset ã¨ã¯è³ç£ã財ç£ã®æã å·çæç¹ç¾å¨ã®ãã¼ã¸ã§ã³ã¯ 2.0.3 ããªãã rack-sprockets gem ã¯ããsprockets( å ·ä½çã«ã¯ã require 'sprockets' map '/assets' do environment = Sprockets::Environment.new environment.append_path 'ap
application.css.scss P��\�U @) _�U @import "bootstrap"; body { padding-top: 80px; } application.haml �f�]�U p��]�U !!! %html %head %meta{:charset => "utf-8"} %title Sinatra, sprockets, compass, bootstrap-sass playing together %link{ rel: 'stylesheet', href: stylesheet_path('application.css') }/ %body .container = yield config.ru �f�]�U p��]�U require './swc_application' use Rack::Cache, verbose: f
ã¡ãã£ã¨ jQuery ã¨ç°¡åãªãµã¼ããµã¤ãã®å¦çãçµã¿åãããå¦çã試ãã«æ¸ãã¦ã¿ãã・・・ãªãã¦æã«ããã¡ãã¡ jQuery ãåã£ã¦ã㦠HTML ãæ¸ã㦠script ã¿ã°ãæ¸ãã¦ãã¼ãã㦠sinatra ç«ã¡ä¸ãã¦äºã ・・・ã¨ããã®ãæ¯åº¦é¢åãªã®ã§ãã²ãªå½¢ã«ãªãã¢ããªã±ã¼ã·ã§ã³ãä½ã£ãã https://github.com/naoya/boilerplate ã²ã¨ã¾ã sinatra ã§ãµã¼ãã¼ãµã¤ããæ¸ããHTML 㯠slim ã§ãCSS 㯠sass ãJavaScript 㯠CoffeeScriptã§æ¸ãã«ããã£ã¦ jQueryãunderscoreãBackbone ããã¼ããã¦ãããã¨ãããããªæ§æã«ãã¦ããã¾ãã ã¾ãããã®é¡ã®ãã¨ã¯äººããããèªåãªãã«ã«ã¹ã¿ãã¤ãºãã¦ãã£ã¦ããã¨æãã¾ãããã©ãããã³ã³ãã¼ãã³ãã§æ§æãã¦ãããããåå¿é²ãå ¼ãã¦ã¡ãã£ã¨ç´¹
Webã¢ããªã¨åãããã»ã¹ã«workerå ¥ãã¦ãéãç¯ç´ã§ããã Webã¢ããªã¯ âãªã¯ã¨ã¹ãæ¥ãâãµã¼ãã¼ã§å¦çâã¬ã¹ãã³ã¹è¿ãâ ã¨ããã®ãç¹°ãè¿ãããã ãããµã¼ãã¼ã§ã®å¦çã«æéããããå ´åã«ãããå¥ã®ããã»ã¹ã«ä»»ãã¦ãå ã«ã¬ã¹ãã³ã¹ãè¿ãã¦ããã¦ããã¨ã§çµæã¯åãã«æ¥ã¦ããã¨ããå®è£ ãããäºãããã æéããããå¦çã¯2ã¤ã«å¤§å¥ã§ããã åç»ãã¨ã³ã³ã¼ãããã¨ããCPUè² è·ãé«ãã¦æéããããã®ã§Webãµã¼ãã¼ã¨ã¯å¥ã®å ´æã§åãããã Twitter APIã10åããã使ã£ãçµæãã¾ã¨ãã¦è¿ãã¨ããCPUè² è·ã¯ä½ããã©IOå¾ ã¡ãé·ã 2ã®æ¹ã«ã¤ãã¦ãHerokuã®Rubyç°å¢ã§å®ãä¸ããæ¹æ³ãã¾ã¨ããã ææ³ Herokuã®cedarã¹ã¿ãã¯ã§Ruby使ãæã¯webãµã¼ãã¼ã¨ãã¦Thinãèµ·åããã Thinã¯EventMachineã®ä¸ã§åãã¦ãã®ã§ãEM::deferçã使ã
ååã¯Rubyã®ã¤ã³ã¹ãã¼ã«ããç°¡åã«åã¡ã¿è¨èªã®ä½¿ãæ¹ãç´¹ä»ããã¦é ãã¾ãããä»åã¯å¿ç¨ç·¨ãç´¹ä»ãããã¨æãã¾ãã ã³ã³ãã¤ã«ããè¨è¿°ãä¸ã¤ã«ã¾ã¨ãã ååç´¹ä»ããæ¹æ³ã¯ä¸çªã·ã³ãã«ãªæ¹æ³ã§ãããGETãªã¯ã¨ã¹ãã¨ãã¹ã®çµã¿åããã«ä¸ã¤ã®hamlãã¡ã¤ã«ãç´ä»ãã¦ããããããã®ã¾ã¾ã§ã¯ãã¡ã¤ã«ãå¢ããæ¯ã«è¨è¿°ãã³ããããªãã¦ã¯ããã¾ããã get '/' do haml :index end # aboutãã¼ã¸ã欲ãããªã£ããâ¦ï¼ get '/about' do haml :about end ããã§ã¯ãã¾ãã¢ãã³ãªã¨ã¯è¨ããããã§ããããã¨ããããã§è¨è¿°ãçç¥ã§ããæ¹æ³ã§ãããgetã¡ã½ããã«ãã¹ãä¸ãã¦ããé¨åãæ£è¦è¡¨ç¾ã«ããã°å®ç¾åºæ¥ã¾ãã è¦ããã«ä»¥ä¸ã®ããã«è¨è¿°ããã°ããã®ã§ãã get %r{^/(.*)\.html$} do haml :"#{ params[:captu
以åSinatraããDataMapperã使ãè¨äºãæ¸ãããã©ãä»åã¯Sinatraã®O/Rãããã¼é¨åã«ActiveRecord 3ã使ã£ã¦ã¿ããActiveRecord 3èªä½ã®ä½¿ãæ¹ã«ã¤ãã¦ã¯ããã®è¨äºããããããããããã£ãã Sinatraã¢ããªã«å¿ è¦ãªãã¡ã¤ã«ãç¨æãã ã¾ãã¯ãSinatraã¢ããªãå®è¡ããã®ã«å¿ è¦ãªæä½éã®ãã¡ã¤ã«ç¾¤(Gemfile, config.ru, app.rb)ãä½æãããä»åã¯åºæ¬çã«ãã¹ã¦Bundlerçµç±ã§æä½ããã®ã§ãã·ã¹ãã å´ã«Bundlerã®gemãã¤ã³ã¹ãã¼ã«ããã¦ããå¿ è¦ãããã Gemfile ä»å使ç¨ããgemã¯ãããªæããã¨ããããSinatraã§ActiveRecord 3ã使ãå ´åã¯activerecordã¨sinatra-activerecordã¨sqlite3ãå¿ è¦ã§ãä»å使ã£ããã¼ã¸ã§ã³ã¯ããããã3.0.6ã0.
railsç·¨ã¯ä»¥åæ¸ããã®ã§sinatraã§ãã£ã¦ã¿ã ç¨éã¨ãã¦ã¯DBã¨ããããªãã¹ã¿ãã£ãã¯ãªãµã¤ãã®æ§ç¯ã§ãã§ãhtmlãcssãjsãçã§æ¸ãã®ã¨ãèããããªããphpã¯ãã¸åå¼ã¿ãããªã¨ãã«ãããã¦ã¾ããã£ã¦æãã®ãã¨ãæ¸ãã¾ãã ï¼bundlerã®ä½¿ãæ¹ã£ã¦ãããrubyã§ã®webå¶ä½å ¨è¬ã£ã¦æãã§ããâ¦ï¼ ã¾ãé©å½ãªå ´æã«ããã¸ã§ã¯ãã®ãã£ã¬ã¯ããªãä½ãã¾ãã hogeã¨ããã¢ã¬ãªãã§ãã¼ããã©ãªãªã«ãã¨ãã¾ãã $ cd ~/Web $ mkdir portfolio $ cd portfolio ã§ããã¸ã§ã¯ãã®ã«ã¼ãã§Gemfileãã¤ãã $ bundle init Writing new Gemfile to /Users/kozo/Web/portfolio/Gemfile ä¸èº«ã¯ãããªæãã ãã... $ vim Gemfile # A sample Gemfi
ã·ã³ãã«ãªåãåãããã©ã¼ã ã¢ããªãSilexã使ã£ã¦ä½ã£ã¦ã¿ã¾ããã®ã§ãã®ç´¹ä»ã Silexã¨ã¯ï¼ Silexã¨ã¯PHPã§æ¸ããããã¤ã¯ããã¬ã¼ã ã¯ã¼ã¯ã§ããRubyã®sinatoraã«ã¤ã³ã¹ãã¤ã¢ããã¦Symfony2ã®ãªã¼ããã¼ã¸ã£ã¼(Lead Merger)ã§ãããã¡ãã¢ã³ãããä½ã£ã¦ãã¾ããç¹å¾´ã¨ãã¦åå空éãããã使ã£ã¦ãããããã®ã§PHP5.3.2以ä¸ã§ãªãã¨åãã¾ããã ã¨ããã¨ãSymfony2ã£ã½ãã¨æãããæ¹ãããã¨æãã¾ããããã®Silexã®ã©ã¤ãã©ãªã¯Symfony2ã§ãå©ç¨ãã¦ããã³ã³ãã¼ãã³ãé¡ã®ä¸é¨ãå©ç¨ãã¦ä½æããã¦ãã¾ããããã°Symfony2ã®å¦¹åã¨ãã£ãã¨ããã§ããããã ãã¨ãã©ã¤ãã©ãªãpharã¢ã¼ã«ã¤ãã§é å¸ãã¦ããã®ã§åºæ¬silex.pharã®1ãã¡ã¤ã«ããããã°åããã¾ãã åè«ã®ãããªã¢ããªãã¨æã£ã¦ãããæå¤(失礼)ã¨æ¬æ°ã®ããã§å ¬å¼ãµ
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}