Sinatra

  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Sinatra as PDF for free.

More details

  • Words: 197
  • Pages: 42
Sinatra Zero & XDite

惡搞、惡搞、惡搞

Make Ur Calendar Icon

Yes, Make our own!

秘技

上上下下左右左右BA

UUDDLRLRBA

自我介紹

itsZero

• Full-time student • Works in hypo • http://itszero.org/ • http://twitter.com/itszero

山寨傑洛 我不會說日文也不會兩段跳...

這可以幹嘛?

Sinatra + RMagick

#!/usr/bin/ruby require 'rubygems' require 'sinatra' require 'RMagick' include Magick   FONTPATH = File.dirname(File.expand_path(__FILE__)) + "/ Aller/Aller_Bd.ttf"   get '/' do   open('public/index.html').read end   get '/gen_icon' do   headers['Content-Type'] = 'image/png'   [some nasty RMagick code...]     canvas.format = 'png'   canvas.to_blob end  

http://makeyourcalicon.heroku.com http://tr.im/j9DH

Another Example

Oh, Dear Mr IE6...

PHP / CodeIgniter

無法顯示中文

?

幾千行 debug 個鬼啊... by XDite

require ‘twitter_search’

require 'rubygems' require 'sinatra' require 'twitter_search' get '/' do @client = TwitterSearch::Client.new 'politweets' @results = @client.query :q => '@MrIE6' erb :home end

10 行搞定 !

db & paginate

activerecord will_paginate

多寫了 40 行

Deployment!

Passenger • (可以想成) Ruby 的 mod_php • Supports Rack!

Rack Handler • Mongrel • WEBrick • FastCGI • Passenger

Adapters • Camping • Sinatra • Merb •... •...

Sinatra on Passenger 1 2 3 4 5 6 7 8 9 10 11

require 'rubygems' require 'sinatra' Sinatra::Application.default_options.merge!( :run => false, :environment => :production ) require 'make_your_cal_icon.rb' run Sinatra::Application

=> config.ru

Java on GAE

JRuby + Sinatra + GAE

URLFetching Bumble Will_paginate

http://gae.mrie6.com http://tr.im/j9DK

Related Documents