Permalink
Browse files

updates

  • Loading branch information...
1 parent db4b6ee commit 0a986b598a7395d35fc1220cf24d19c69381d39e bry4n committed Nov 13, 2009
View
@@ -1,15 +1,11 @@
require 'rubygems'
require 'sinatra'
require 'configs/deps'
-require 'configs/settings'
-Dir.glob("controllers/*.rb") {|file| require file}
-Dir.glob("models/*.rb") {|file| require file}
-Dir.glob("helpers/*.rb") {|file| require file}
+load 'configs/settings.rb'
-get '/css/:name.css' do
- content_type 'text/css', :charset => 'utf-8'
- sass :"css/#{params[:name]}"
-end
+Dir.glob("app/controllers/*.rb") {|file| load file}
+Dir.glob("app/models/*.rb") {|file| load file}
+Dir.glob("helpers/*.rb") {|file| load file}
-require "configs/routes"
+load "configs/routes.rb"
@@ -0,0 +1,4 @@
+get "/auth/test/?" do
+ authorize!
+ "You are authorized!"
+end
@@ -0,0 +1,3 @@
+get "/bench/?" do
+ liquid :"bench/index"
+end
@@ -2,3 +2,8 @@
name = "Hello World"
liquid :"hello/index", :locals => {'name' => name}
end
+
+get "/hello.json" do
+ content_type "text/plain"
+ JSON.dump({:name => "Hello World"})
+end
File renamed without changes.
@@ -0,0 +1,8 @@
+<p>Rails: <a href="http://ffiirree.com:3000/">click here</a></p>
+<p>Merb: <a href="http://ffiirree.com:4000/">click here</a></p>
+<p>Sinatra-MVC: <a href="http://ffiirree.com/">click here</a></p>
+<p>Ramaze: <a href="http://ffiirree.com:5000/">click here</a></p>
+
+<p>Results: <a href="http://grab.by/x7q">click here</a></p>
+
+
@@ -1 +1,2 @@
<h1>{{ name }}</h1>
+This is test...
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ <title>Test</title>
+ <link rel="stylesheet" href="http://static.ffiirree.com/css/reset.css" type="text/css" media="screen" charset="utf-8">
+ <link rel="stylesheet" href="http://static.ffiirree.com/css/960.css" type="text/css" media="screen" charset="utf-8">
+ <link ref="stylesheet" href="/css/main.css" type="text/css" media="screen" charset="utf-8">
+ <style>
+ h1 { color: maroon; }
+ </style>
+</head>
+<body>
+<div class="container_16">
+{{ content }}
+</div>
+<div class="container_16 clearfix">
+ <div class="grid_14 footer">
+ <center>Powered by Sinatra-MVC</center>
+ </div>
+</div>
+</body>
+</html>
View
@@ -1,3 +1,4 @@
require 'sinatra/base'
require 'liquid'
require 'sequel'
+require 'json'
View
@@ -1,8 +1,15 @@
-set :environment, "development"
+set :environment, :development
set :server, "thin"
-set :port, 8080
+set :host, "0.0.0.0"
+set :port, 8181
-set :views, 'views'
-set :public, 'static'
+set :views, 'app/views'
+set :public, 'public'
+set :static, true
+set :raise_errors, true
+set :logging, true
+set :dump_errors, true
+
+enable :sessions
View
@@ -0,0 +1,24 @@
+worker_processes 4
+#listen 'app.sock', :backlog => 1
+listen 8181, :tcp_nopush => true
+timeout 30
+pid "tmp/unicorn.pid"
+
+preload_app true
+
+before_fork do |server, worker|
+ old_pid = "#{server.config[:pid]}.oldbin"
+ if old_pid != server.pid
+ begin
+ sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
+ Process.kill(sig, File.read(old_pid).to_i)
+ rescue Errno::ENOENT, Errno::ESRCH
+ end
+ end
+ sleep 1
+end
+
+after_fork do |server, worker|
+ server.listen("127.0.0.1:#{8080 + worker.nr}", :tries => -1, :delay => 5, :tcp_nopush => true)
+end
+
View
@@ -0,0 +1,14 @@
+module Sinatra
+ module Authorization
+ def authorized?
+ session[:authorized]
+ end
+ def authorize!
+ redirect "/authorized" unless authorized?
+ end
+ get "/authorized" do
+ "Authorized user only!"
+ end
+ end
+ helpers Authorization
+end
File renamed without changes.
View
@@ -0,0 +1,3 @@
+body { background-color: #f3f3f3; }
+h1 { color: #E51E26; }
+.footer { font-size: 12px; }
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
View
@@ -1,7 +0,0 @@
-body
- background-color: #f2f2f2
-
-h1
- font-size: 40px
- color: maroon
-
View
@@ -1,14 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-<head>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8">
- <title>Test</title>
- <link ref="stylesheet" href="/css/main.css" type="text/css" media="screen" charset="utf-8" />
-</head>
-<body>
-
-{{ content }}
-
-</body>
-</html>

0 comments on commit 0a986b5

Please sign in to comment.