Skip to content

Commit d6db9b1

Browse files
committed
Throwing in initial merb structure.
1 parent 8560fcb commit d6db9b1

29 files changed

Lines changed: 874 additions & 0 deletions

Rakefile

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
require 'rubygems'
2+
Gem.clear_paths
3+
Gem.path.unshift(File.join(File.dirname(__FILE__), "gems"))
4+
5+
require 'rake'
6+
require 'rake/rdoctask'
7+
require 'rake/testtask'
8+
require 'spec/rake/spectask'
9+
require 'fileutils'
10+
11+
require File.dirname(__FILE__)+'/config/boot.rb'
12+
require Merb::framework_root+'/tasks'
13+
include FileUtils
14+
15+
# Set these before any dependencies load
16+
# otherwise the ORM may connect to the wrong env
17+
Merb.root = File.dirname(__FILE__)
18+
Merb.environment = ENV['MERB_ENV'] if ENV['MERB_ENV']
19+
20+
# Get Merb plugins and dependencies
21+
require File.dirname(__FILE__)+'/config/dependencies.rb'
22+
Merb::Plugins.rakefiles.each {|r| require r }
23+
24+
#desc "Packages up Merb."
25+
#task :default => [:package]
26+
27+
desc "load merb_init.rb"
28+
task :merb_init do
29+
# deprecated - here for BC
30+
Rake::Task['merb_env'].invoke
31+
end
32+
33+
task :uninstall => [:clean] do
34+
sh %{sudo gem uninstall #{NAME}}
35+
end
36+
37+
desc 'Run unit tests'
38+
Rake::TestTask.new('test_unit') do |t|
39+
t.libs << 'test'
40+
t.pattern = 'test/unit/*_test.rb'
41+
t.verbose = true
42+
end
43+
44+
desc 'Run functional tests'
45+
Rake::TestTask.new('test_functional') do |t|
46+
t.libs << 'test'
47+
t.pattern = 'test/functional/*_test.rb'
48+
t.verbose = true
49+
end
50+
51+
desc 'Run all tests'
52+
Rake::TestTask.new('test') do |t|
53+
t.libs << 'test'
54+
t.pattern = 'test/**/*_test.rb'
55+
t.verbose = true
56+
end
57+
58+
desc "Run all specs"
59+
Spec::Rake::SpecTask.new('specs') do |t|
60+
t.spec_opts = ["--format", "specdoc", "--colour"]
61+
t.spec_files = Dir['spec/**/*_spec.rb'].sort
62+
end
63+
64+
desc "Run all model specs"
65+
Spec::Rake::SpecTask.new('model_specs') do |t|
66+
t.spec_opts = ["--format", "specdoc", "--colour"]
67+
t.spec_files = Dir['spec/models/**/*_spec.rb'].sort
68+
end
69+
70+
desc "Run all controller specs"
71+
Spec::Rake::SpecTask.new('controller_specs') do |t|
72+
t.spec_opts = ["--format", "specdoc", "--colour"]
73+
t.spec_files = Dir['spec/controllers/**/*_spec.rb'].sort
74+
end
75+
76+
desc "Run a specific spec with TASK=xxxx"
77+
Spec::Rake::SpecTask.new('spec') do |t|
78+
t.spec_opts = ["--format", "specdoc", "--colour"]
79+
t.libs = ['lib', 'server/lib' ]
80+
t.spec_files = ["spec/merb/#{ENV['TASK']}_spec.rb"]
81+
end
82+
83+
desc "Run all specs output html"
84+
Spec::Rake::SpecTask.new('specs_html') do |t|
85+
t.spec_opts = ["--format", "html"]
86+
t.libs = ['lib', 'server/lib' ]
87+
t.spec_files = Dir['spec/**/*_spec.rb'].sort
88+
end
89+
90+
desc "RCov"
91+
Spec::Rake::SpecTask.new('rcov') do |t|
92+
t.spec_opts = ["--format", "specdoc", "--colour"]
93+
t.spec_files = Dir['spec/**/*_spec.rb'].sort
94+
t.libs = ['lib', 'server/lib' ]
95+
t.rcov = true
96+
end
97+
98+
desc 'Run all tests, specs and finish with rcov'
99+
task :aok do
100+
sh %{rake rcov}
101+
sh %{rake spec}
102+
end
103+
104+
unless Gem.cache.search("haml").empty?
105+
namespace :haml do
106+
desc "Compiles all sass files into CSS"
107+
task :compile_sass do
108+
gem 'haml'
109+
require 'sass'
110+
puts "*** Updating stylesheets"
111+
Sass::Plugin.update_stylesheets
112+
puts "*** Done"
113+
end
114+
end
115+
end
116+
117+
##############################################################################
118+
# SVN
119+
##############################################################################
120+
121+
desc "Add new files to subversion"
122+
task :svn_add do
123+
system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
124+
end

app/controllers/application.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# all your other controllers should inherit from this one to share code.
2+
class Application < Merb::Controller
3+
end

app/controllers/exceptions.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Exceptions < Application
2+
3+
# handle NotFound exceptions (404)
4+
def not_found
5+
render :format => :html
6+
end
7+
8+
# handle NotAcceptable exceptions (406)
9+
def not_acceptable
10+
render :format => :html
11+
end
12+
13+
end

app/helpers/global_helper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Merb
2+
module GlobalHelper
3+
# helpers defined here available to all views.
4+
end
5+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= catch_content :layout %>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= catch_content :layout %>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= catch_content :layout %>
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
<html>
2+
<head>
3+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
4+
<title><%= @exception.name.humanize %></title>
5+
<style type="text/css" media="screen">
6+
body {
7+
font-family:arial;
8+
font-size:11px;
9+
}
10+
h1 {
11+
font-size:48px;
12+
letter-spacing:-4px;
13+
margin:0;
14+
line-height:36px;
15+
color:#333;
16+
}
17+
h1 sup {
18+
font-size: 0.5em;
19+
}
20+
h1 sup.error_500, h1 sup.error_400 {
21+
color:#990E05;
22+
}
23+
h1 sup.error_100, h1 sup.error_200 {
24+
color:#00BF10;
25+
}
26+
h1 sup.error_300 {
27+
/* pretty sure you cant 'see' status 300
28+
errors but if you could I think they
29+
would be blue */
30+
color:#1B2099;
31+
}
32+
h2 {
33+
font-size:36px;
34+
letter-spacing:-3px;
35+
margin:0;
36+
line-height:28px;
37+
color:#444;
38+
}
39+
a, a:visited {
40+
color:#00BF10;
41+
}
42+
.internalError {
43+
width:800px;
44+
margin:50px auto;
45+
}
46+
.header {
47+
border-bottom:10px solid #333;
48+
margin-bottom:1px;
49+
background-image: url("data:image/gif;base64,R0lGODlhAwADAIAAAP///8zMzCH5BAAAAAAALAAAAAADAAMAAAIEBHIJBQA7");
50+
padding:20px;
51+
}
52+
table.trace {
53+
width:100%;
54+
font-family:courier, monospace;
55+
letter-spacing:-1px;
56+
border-collapse: collapse;
57+
border-spacing:0;
58+
}
59+
table.trace tr td{
60+
padding:0;
61+
height:26px;
62+
font-size:13px;
63+
vertical-align:middle;
64+
}
65+
table.trace tr.file{
66+
border-top:2px solid #fff;
67+
background-color:#F3F3F3;
68+
}
69+
table.trace tr.source {
70+
background-color:#F8F8F8;
71+
display:none;
72+
}
73+
table.trace .open tr.source {
74+
display:table-row;
75+
}
76+
table.trace tr.file td.expand {
77+
width:23px;
78+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAAXCAIAAABvSEP3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdVJREFUeNqMVL+TwUAYxaRIOlEhlZHGDAUzzOQ61+AqXMV1lJSU7q/QRqm8KFUcJTNn5qJkaPyoKKVz7y4mF8na5Kt29tt9+/Z97/u81+vVQ4r9frdarS6Xi7ETDIZisRjxMGPfmk4niNPpZE+xLAugbPaZ53nzvtfMBe/3+/3dbuehBrAKhZdUKkVAWa9Xsiybv0CPZDJZLr/qa5/BwgwRjYqOKIvFYjQa/aNommZh0Ww2K5UqzwfoQOPxaLPZ3FAmk0+7lplMpt1u53J5OpBOR0eZEE9wHJfP5zud93g88QhluwWbjW+5VOmKBgKBer3eaDTDYeGBQF8+x7rqIYoiPgixWJazpA6HA+MSxRArkUgMh0M409g8Ho8+9wYxxCqVSq1W26EDHGM2m4HOHQrEc38f/Yn7cLmlIRhBENzcx8cVRZnPZ/YUep2BWkjTIfA+PKVpZAXR5QxsjiqCKvGEqqp443w+0dvy17swqD0HB3S73V5PpkNg1qBqt8kwGCjmPkinM0QJbIoEa7U6UG6ToVgs4V9G2g0ESoP5Aoi7KYX5oCgf8IKbkvn9/mr1LRQKESamzgJy0g0tSZIuB3nuGqRU9Vv9C4sKkUhEkp4soxvxI8AAhWrrtXa3X8EAAAAASUVORK5CYII=);
79+
background-position:top left;
80+
background-repeat:no-repeat;
81+
}
82+
table.trace .open tr.file td.expand {
83+
width:19px;
84+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAB1CAIAAAAqdO2mAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAXZJREFUeNrslK1ywkAUhcMOBomEOiSdqLxEBJX0NaijOsjyHGGmCGyQQYaiiiw4gktkcOmZbpsuuzQ/M5XnqJ2d3S/n3nM3rTzPLUP7/Tt0+pLcGQwG3W53OLyHzPMtjYL7q9UqSRLrD4E1Gj1orCvKYuFHUWTVkOM44/HjDcp8/lL4r6NerzeZPMm1KFw0QkDn83m5fP2lHA4fNQvRtNvtjsfDd0WzmSfb2e/fdTqdOvdh/HLJZLOn0+d2HJ+KRGzbdl23EpFlmed5cp2maRzHQq1lvQ5KMi6EUZBGfup6E1pTfd+vrGW7jbQ2C9hTt9BpqNyIWaAwAy6xg2eBz5iRC/NomiZhGN5sqmnkauo0BUGgVQoBjQ80oCACgNQdZHfTYBkF2mxCtWWAqunWpahxIDUt3QYUxIFQpJHyIWpXjinabKbbwItMHT+NyjchrP8QKaSQQgoppJBCCimkkEIKKaSQQgoppJBCCimkkEIKKaSo+hRgAEFD17X08O2NAAAAAElFTkSuQmCC);
85+
background-position:top left;
86+
background-repeat:no-repeat;
87+
}
88+
table.trace tr.source td.collapse {
89+
width:19px;
90+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAB1CAIAAAAqdO2mAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAVxJREFUeNrs0zFygkAUBmBlUkgJHdABlQwVkVJKKUxBYWbkALTxMJwhltyDFkss03IF8pudIcwaDaDl/6pd2P327b7d+eHwMXs4lNkzggoVKlSoUKFChQoVKlSoUKFChQoVKlSoUKFChQqVEYqm6ft9+qiSJEkYho7jTlcw2fd9NOI4nq4gEdFwXXe1Cqco63VkWVbXRTqLhTpOwQRpF7quR1E0TgGhqvLKUFCyoQqG/rks3O6kZKW/eRFpevOCoGTXVTcMQ5EyxyDEkML1c5RzuZOICIyXqn7JBVez6282MWrx731HOv2qB8Hri2lamNk0DfpVVdV1Peodappmmua8bdvzuc7zfNprzrLMth1FnGh/X8MjCAIQv/cFz/+65PcDh7rbvYv2ZUfdj+PxsyzLgVl0hKwgTqeqKApx2LeOc7t98zyv/1FWOgvx9RPii23bmL9cetJ8Ed8CDAC6aFW8bCzFhwAAAABJRU5ErkJggg==);
91+
background-position:bottom left;
92+
background-repeat:no-repeat;
93+
background-color:#6F706F;
94+
}
95+
table.trace tr td.path {
96+
padding-left:10px;
97+
}
98+
table.trace tr td.code {
99+
padding-left:35px;
100+
white-space: pre;
101+
line-height:9px;
102+
padding-bottom:10px;
103+
}
104+
table.trace tr td.code em {
105+
font-weight:bold;
106+
color:#00BF10;
107+
}
108+
table.trace tr td.code a {
109+
width: 20px;
110+
float: left;
111+
}
112+
table.trace tr td.code .more {
113+
color:#666;
114+
}
115+
table.trace tr td.line {
116+
width:30px;
117+
text-align:right;
118+
padding-right:4px;
119+
}
120+
.footer {
121+
margin-top:5px;
122+
font-size:11px;
123+
color:#444;
124+
text-align:right;
125+
}
126+
</style>
127+
</head>
128+
<body>
129+
<div class="internalError">
130+
131+
<div class="header">
132+
<h1><%= @exception.name.humanize %> <sup class="error_<%= @exception.class::STATUS %>"><%= @exception.class::STATUS %></sup></h1>
133+
<% if show_details = ::Merb::Config[:exception_details] -%>
134+
<h2><%== @exception.message %></h2>
135+
<% else -%>
136+
<h2>Sorry about that...</h2>
137+
<% end -%>
138+
<h3>Parameters</h3>
139+
<ul>
140+
<% controller.params[:original_params].each do |param, value| %>
141+
<li><strong><%= param %>:</strong> <%= value.inspect %></li>
142+
<% end %>
143+
<%= "<li>None</li>" if controller.params[:original_params].empty? %>
144+
</ul>
145+
146+
<h3>Session</h3>
147+
<ul>
148+
<% controller.params[:original_session].each do |param, value| %>
149+
<li><strong><%= param %>:</strong> <%= value.inspect %></li>
150+
<% end %>
151+
<%= "<li>None</li>" if controller.params[:original_session].empty? %>
152+
</ul>
153+
154+
<h3>Cookies</h3>
155+
<ul>
156+
<% controller.params[:original_cookies].each do |param, value| %>
157+
<li><strong><%= param %>:</strong> <%= value.inspect %></li>
158+
<% end %>
159+
<%= "<li>None</li>" if controller.params[:original_cookies].empty? %>
160+
</ul>
161+
</div>
162+
163+
<% if show_details %>
164+
<table class="trace">
165+
<% @exception.backtrace.each_with_index do |line, index| %>
166+
<tbody class="close">
167+
<tr class="file">
168+
<td class="expand">
169+
</td>
170+
<td class="path">
171+
<%= (line.match(/^([^:]+)/)[1] rescue 'unknown').sub(/\/((opt|usr)\/local\/lib\/(ruby\/)?(gems\/)?(1.8\/)?(gems\/)?|.+\/app\/)/, '') %>
172+
<% unless line.match(/\.erb:/) %>
173+
in "<strong><%= line.match(/:in `(.+)'$/)[1] rescue '?' %></strong>"
174+
<% else %>
175+
(<strong>ERB Template</strong>)
176+
<% end %>
177+
</td>
178+
<td class="line">
179+
<a href="txmt://open?url=file://<%=file = (line.match(/^([^:]+)/)[1] rescue 'unknown')%>&amp;line=<%= lineno = line.match(/:([0-9]+):/)[1] rescue '?' %>"><%=lineno%></a>&nbsp;
180+
</td>
181+
</tr>
182+
<tr class="source">
183+
<td class="collapse">
184+
</td>
185+
<td class="code" colspan="2"><% (__caller_lines__(file, lineno, 5) rescue []).each do |llineno, lcode, lcurrent| %>
186+
<a href="txmt://open?url=file://<%=file%>&amp;line=<%=llineno%>"><%= llineno %></a><%='<em>' if llineno==lineno.to_i %><%= lcode.size > 90 ? CGI.escapeHTML(lcode[0..90])+'<span class="more">......</span>' : CGI.escapeHTML(lcode) %><%='</em>' if llineno==lineno.to_i %>
187+
<% end %>
188+
189+
</td>
190+
</tr>
191+
</tbody>
192+
<% end %>
193+
</table>
194+
<script type="text/javascript" charset="utf-8">
195+
// swop the open & closed classes
196+
els = document.getElementsByTagName('td');
197+
for(i=0; i<els.length; i++){
198+
if(els[i].className=='expand' || els[i].className=='collapse'){
199+
els[i].onclick = function(e){
200+
tbody = this.parentNode.parentNode;
201+
if(tbody.className=='open'){
202+
tbody.className='closed';
203+
}else{
204+
tbody.className='open';
205+
}
206+
}
207+
}
208+
}
209+
</script>
210+
<% end %>
211+
<div class="footer">
212+
lots of love, from <a href="#">merb</a>
213+
</div>
214+
</div>
215+
</body>
216+
</html>

0 commit comments

Comments
 (0)