ramaze 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +13 -7
- data/doc/README +1 -1
- data/doc/README.html +729 -0
- data/doc/meta/users.kml +61 -59
- data/doc/readme_chunks/installing.txt +1 -1
- data/examples/auth/auth.rb +13 -8
- data/examples/element.rb +1 -2
- data/examples/ramaise.rb +139 -0
- data/examples/simple.rb +2 -5
- data/examples/sourceview/public/coderay.css +104 -0
- data/examples/sourceview/public/jquery.treeview.css +10 -9
- data/examples/sourceview/public/jquery.treeview.js +7 -7
- data/examples/sourceview/public/sourceview.js +43 -7
- data/examples/sourceview/sourceview.rb +36 -33
- data/examples/sourceview/template/index.haml +33 -17
- data/examples/wikore/spec/wikore.rb +1 -0
- data/examples/wikore/src/controller.rb +0 -1
- data/examples/wikore/src/model.rb +17 -16
- data/lib/proto/src/controller/main.rb +1 -1
- data/lib/proto/start.rb +2 -3
- data/lib/ramaze.rb +3 -0
- data/lib/ramaze/contrib/auto_params.rb +3 -3
- data/lib/ramaze/contrib/gzip_filter.rb +3 -4
- data/lib/ramaze/contrib/route.rb +5 -0
- data/lib/ramaze/controller/resolve.rb +1 -1
- data/lib/ramaze/dispatcher/action.rb +1 -1
- data/lib/ramaze/dispatcher/error.rb +7 -4
- data/lib/ramaze/gestalt.rb +1 -2
- data/lib/ramaze/helper.rb +8 -4
- data/lib/ramaze/helper/auth.rb +1 -1
- data/lib/ramaze/helper/cache.rb +4 -0
- data/lib/ramaze/helper/identity.rb +2 -2
- data/lib/ramaze/snippets/{string/DIVIDE.rb → divide.rb} +11 -8
- data/lib/ramaze/snippets/string/unindent.rb +7 -0
- data/lib/ramaze/snippets/thread/into.rb +5 -12
- data/lib/ramaze/spec/helper/wrap.rb +1 -1
- data/lib/ramaze/template/haml.rb +4 -14
- data/lib/ramaze/template/sass.rb +4 -14
- data/lib/ramaze/trinity/request.rb +34 -1
- data/lib/ramaze/version.rb +1 -1
- data/rake_tasks/coverage.rake +46 -0
- data/rake_tasks/spec.rake +1 -1
- data/spec/contrib/auto_params.rb +6 -1
- data/spec/contrib/route.rb +0 -2
- data/spec/contrib/sequel/fill.rb +6 -4
- data/spec/ramaze/controller/resolve.rb +31 -0
- data/spec/ramaze/helper/cache.rb +14 -7
- data/spec/ramaze/template/haml.rb +14 -0
- data/spec/ramaze/template/sass.rb +23 -1
- data/spec/ramaze/trinity/request.rb +19 -0
- data/spec/snippets/{string/DIVIDE.rb → divide.rb} +5 -1
- data/spec/snippets/kernel/__dir__.rb +1 -1
- data/spec/snippets/string/unindent.rb +22 -0
- data/spec/snippets/thread/into.rb +21 -0
- metadata +90 -80
data/doc/meta/users.kml
CHANGED
@@ -1,62 +1,64 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<kml xmlns="http://earth.google.com/kml/2.
|
3
|
-
<
|
4
|
-
<
|
5
|
-
|
6
|
-
|
2
|
+
<kml xmlns="http://earth.google.com/kml/2.2">
|
3
|
+
<Document>
|
4
|
+
<Placemark>
|
5
|
+
<name>manveru</name>
|
6
|
+
<description><![CDATA[ <img src="http://manveru.mine.nu/public/me.png" /><br />
|
7
|
+
Tokyo, Japan ]]>
|
8
|
+
</description>
|
9
|
+
<Point>
|
10
|
+
<coordinates>139.667846,35.614759</coordinates>
|
11
|
+
</Point>
|
12
|
+
</Placemark>
|
13
|
+
<Placemark>
|
14
|
+
<name>Pistos</name>
|
15
|
+
<description>
|
16
|
+
<![CDATA[
|
17
|
+
<img src="http://purepistos.net/favicon32.png" alt="Pistos" /><br />
|
18
|
+
Toronto, Canada<br />
|
19
|
+
<a href="http://blog.purepistos.net">blog.purepistos.net</a>
|
20
|
+
]]>
|
7
21
|
</description>
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<
|
27
|
-
|
28
|
-
|
29
|
-
<
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
<
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
<
|
43
|
-
<
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
</description>
|
51
|
-
<Point>
|
52
|
-
<coordinates>-71.084371,42.365975,0</coordinates>
|
53
|
-
</Point>
|
54
|
-
</Placemark>
|
55
|
-
<Placemark>
|
56
|
-
<name>riffraff</name>
|
57
|
-
<description><![CDATA[ Rome, Italia ]]></description>
|
58
|
-
<Point>
|
59
|
-
<coordinates>41.993372,12.087193,0</coordinates>
|
60
|
-
</Point>
|
61
|
-
</Placemark>
|
22
|
+
<Point>
|
23
|
+
<coordinates>-79.386985,43.642515,0</coordinates>
|
24
|
+
</Point>
|
25
|
+
</Placemark>
|
26
|
+
<Placemark>
|
27
|
+
<name>MonoDelDiablo</name>
|
28
|
+
<description><![CDATA[ Seattle, Washington, United States ]]></description>
|
29
|
+
<Point>
|
30
|
+
<coordinates>-122.266881,47.682765,0</coordinates>
|
31
|
+
</Point>
|
32
|
+
</Placemark>
|
33
|
+
<Placemark>
|
34
|
+
<name>Kashia</name>
|
35
|
+
<description><![CDATA[ Helsinki, Etela-Suomen Laani, Finland ]]></description>
|
36
|
+
<Point>
|
37
|
+
<coordinates>8.447204,49.028928,0</coordinates>
|
38
|
+
</Point>
|
39
|
+
</Placemark>
|
40
|
+
<Placemark>
|
41
|
+
<name>zenix</name>
|
42
|
+
<description><![CDATA[ Gaithersburg, Maryland, United States ]]></description>
|
43
|
+
<Point>
|
44
|
+
<coordinates>-77.183338,39.137049,0</coordinates>
|
45
|
+
</Point>
|
46
|
+
</Placemark>
|
47
|
+
<Placemark>
|
48
|
+
<name>tmm1</name>
|
49
|
+
<description><![CDATA[ <img src="http://tmm1.net/me.jpg" /><br />
|
50
|
+
Boston, Massachussetts ]]>
|
51
|
+
</description>
|
52
|
+
<Point>
|
53
|
+
<coordinates>-71.084371,42.365975,0</coordinates>
|
54
|
+
</Point>
|
55
|
+
</Placemark>
|
56
|
+
<Placemark>
|
57
|
+
<name>riffraff</name>
|
58
|
+
<description><![CDATA[ Rome, Italia ]]></description>
|
59
|
+
<Point>
|
60
|
+
<coordinates>41.993372,12.087193,0</coordinates>
|
61
|
+
</Point>
|
62
|
+
</Placemark>
|
63
|
+
</Document>
|
62
64
|
</kml>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
To get the latest and sweetest, you can just pull from the repository and run
|
13
13
|
Ramaze that way.
|
14
14
|
|
15
|
-
$ darcs get --partial http://
|
15
|
+
$ darcs get --partial http://darcs.ramaze.net/ramaze
|
16
16
|
|
17
17
|
Please read the man page or `darcs help` for more information about updating
|
18
18
|
and creating your own patches.
|
data/examples/auth/auth.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'sequel
|
2
|
+
require 'sequel'
|
3
|
+
|
4
|
+
begin
|
5
|
+
DB = Sequel.sqlite
|
6
|
+
rescue NoMethodError
|
7
|
+
raise LoadError, 'Install latest Sequel gem'
|
8
|
+
end
|
3
9
|
|
4
|
-
DB = Sequel.sqlite
|
5
10
|
class User < Sequel::Model(:users)
|
6
11
|
set_schema do
|
7
12
|
primary_key :id
|
@@ -20,23 +25,23 @@ require 'ramaze'
|
|
20
25
|
class MainController < Ramaze::Controller
|
21
26
|
helper :auth
|
22
27
|
layout :layout
|
23
|
-
|
28
|
+
|
24
29
|
before(:index) { login_required }
|
25
|
-
|
30
|
+
|
26
31
|
def index
|
27
32
|
"Hello #{session[:username]}"
|
28
33
|
end
|
29
|
-
|
34
|
+
|
30
35
|
private
|
31
|
-
|
36
|
+
|
32
37
|
def login_required
|
33
38
|
flash[:error] = 'login required to view that page' unless logged_in?
|
34
39
|
super
|
35
40
|
end
|
36
|
-
|
41
|
+
|
37
42
|
def check_auth user, pass
|
38
43
|
return false if (not user or user.empty?) and (not pass or pass.empty?)
|
39
|
-
|
44
|
+
|
40
45
|
if User[:username => user, :password => pass].nil?
|
41
46
|
flash[:error] = 'invalid username or password'
|
42
47
|
false
|
data/examples/element.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'ramaze'
|
2
|
-
include Ramaze
|
3
2
|
|
4
3
|
class Page < Ezamar::Element
|
5
4
|
def render
|
@@ -27,7 +26,7 @@ class SideBar < Ezamar::Element
|
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
|
-
class MainController < Controller
|
29
|
+
class MainController < Ramaze::Controller
|
31
30
|
map '/'
|
32
31
|
|
33
32
|
def index
|
data/examples/ramaise.rb
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
# Ramaise, the Ramaze version of Reprise, a minimal hAtom blog
|
2
|
+
#
|
3
|
+
# http://redflavor.com/reprise.rb
|
4
|
+
# http://www.rubyinside.com/reprise-a-ruby-powered-blogging-app-in-
|
5
|
+
# 100-lines-including-templates-646.html
|
6
|
+
#
|
7
|
+
# Usage:
|
8
|
+
#
|
9
|
+
# 1. gem install ramaze haml bluecloth rubypants -y
|
10
|
+
# 2. wget http://darcs.ramaze.net/ramaze/examples/ramaise.rb
|
11
|
+
# 3. mkdir entries
|
12
|
+
# 4. vi entries/YYYY.MM.DD.Title.Goes.Here
|
13
|
+
# 5. ruby ramaise.rb
|
14
|
+
|
15
|
+
%w(rubygems ramaze bluecloth rubypants haml).each { |lib| require lib }
|
16
|
+
|
17
|
+
class BlogPost
|
18
|
+
DIR = __DIR__/:entries
|
19
|
+
|
20
|
+
def initialize filename
|
21
|
+
raise 'Invalid BlogPost filename' unless File.exists?(filename)
|
22
|
+
@filename, filename = filename, File.basename(filename)
|
23
|
+
@date = Date.strptime(filename, '%Y.%m.%d').to_s
|
24
|
+
@title = filename[11..-1].tr('.', ' ')
|
25
|
+
end
|
26
|
+
|
27
|
+
def body
|
28
|
+
RubyPants.new(BlueCloth.new(File.read(@filename)).to_html).to_html
|
29
|
+
end
|
30
|
+
|
31
|
+
def slug
|
32
|
+
@slug ||= title.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_reader :date, :title
|
36
|
+
|
37
|
+
class << self
|
38
|
+
include Enumerable
|
39
|
+
|
40
|
+
def each
|
41
|
+
Dir[DIR/'*'].sort.reverse.each do |file| yield BlogPost.new(file) end
|
42
|
+
end
|
43
|
+
|
44
|
+
def [] key
|
45
|
+
BlogPost.find{|post| post.slug == key }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class String
|
51
|
+
def unindent
|
52
|
+
strip.gsub(/^#{ self.split("\n")[1][/^(\s+)/,1] }/, '')
|
53
|
+
end
|
54
|
+
alias ui unindent
|
55
|
+
end
|
56
|
+
|
57
|
+
class MainController < Ramaze::Controller
|
58
|
+
|
59
|
+
TITLE = 'Ramaise'
|
60
|
+
AUTHOR = { :name => 'Aman Gupta', :url => 'http://ramaze.net' }
|
61
|
+
|
62
|
+
engine :Haml
|
63
|
+
|
64
|
+
def index slug = nil
|
65
|
+
if slug.nil?
|
66
|
+
@posts = BlogPost.collect
|
67
|
+
raise Ramaze::Error::NoAction,
|
68
|
+
'No blog posts found, create
|
69
|
+
entries/YYYY.MM.DD.My.First.Blog.Post' unless @posts.any?
|
70
|
+
else
|
71
|
+
raise Ramaze::Error::NoAction,
|
72
|
+
'Invalid blog post' unless post = BlogPost[slug]
|
73
|
+
@title = post.title
|
74
|
+
@posts = [ post ]
|
75
|
+
end
|
76
|
+
|
77
|
+
%(
|
78
|
+
%h1
|
79
|
+
- if @title
|
80
|
+
%a{ :href => '/' } #{TITLE}
|
81
|
+
- else
|
82
|
+
#{TITLE}
|
83
|
+
|
84
|
+
- @posts.each do |post|
|
85
|
+
.hentry
|
86
|
+
%h2
|
87
|
+
%abbr.updated{ :title => Time.parse(post.date).iso8601 }= post.date
|
88
|
+
%a.entry-title{ :href => '/'+post.slug, :rel => 'bookmark' }= post.title
|
89
|
+
.entry-content= post.body
|
90
|
+
).ui
|
91
|
+
end
|
92
|
+
|
93
|
+
def error
|
94
|
+
%(
|
95
|
+
%h1 #{TITLE}: Resource not found
|
96
|
+
%h2= Ramaze::Dispatcher::Error.current.message + '.'
|
97
|
+
|
98
|
+
Go back to the
|
99
|
+
%a{ :href => '/' } the front
|
100
|
+
page.
|
101
|
+
).ui
|
102
|
+
end
|
103
|
+
|
104
|
+
def layout
|
105
|
+
%(
|
106
|
+
!!!
|
107
|
+
%html
|
108
|
+
%head
|
109
|
+
%title
|
110
|
+
#{TITLE}
|
111
|
+
- if @title
|
112
|
+
= ': ' + @title
|
113
|
+
%style{ :type => 'text/css' }
|
114
|
+
:sass
|
115
|
+
body
|
116
|
+
font-size: 90%
|
117
|
+
line-height: 1.4
|
118
|
+
width: 94%
|
119
|
+
margin: auto
|
120
|
+
abbr
|
121
|
+
border: 0
|
122
|
+
.entry-content
|
123
|
+
-moz-column-width: 30em
|
124
|
+
-moz-column-gap: 1.5em
|
125
|
+
-webkit-column-width: 30em
|
126
|
+
-webkit-column-gap: 1.5em
|
127
|
+
h2
|
128
|
+
border-bottom: 0.05em solid #999
|
129
|
+
%body
|
130
|
+
= @content
|
131
|
+
%address.author.vcard
|
132
|
+
%a.url.fn{ :href => '#{AUTHOR[:url]}' } #{AUTHOR[:name]}
|
133
|
+
).ui
|
134
|
+
end
|
135
|
+
layout :layout
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
Ramaze.start :sessions => false #, :adapter => :mongrel, :port => 3000
|
data/examples/simple.rb
CHANGED
@@ -19,10 +19,7 @@ require 'ramaze'
|
|
19
19
|
# - How to map your controllers to urls [ /other ]
|
20
20
|
# - Also try out the error-page, just pass something odd ;)
|
21
21
|
|
22
|
-
|
23
|
-
include Ramaze
|
24
|
-
|
25
|
-
class SimpleController < Controller
|
22
|
+
class SimpleController < Ramaze::Controller
|
26
23
|
map '/'
|
27
24
|
|
28
25
|
def index
|
@@ -50,7 +47,7 @@ class SimpleController < Controller
|
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
53
|
-
class OtherController < Controller
|
50
|
+
class OtherController < Ramaze::Controller
|
54
51
|
map '/other'
|
55
52
|
|
56
53
|
def index
|
@@ -0,0 +1,104 @@
|
|
1
|
+
.CodeRay {
|
2
|
+
background-color: #f8f8f8;
|
3
|
+
border: 1px solid silver;
|
4
|
+
font-family: monospace;
|
5
|
+
color: #100;
|
6
|
+
}
|
7
|
+
.CodeRay pre { margin: 0px }
|
8
|
+
|
9
|
+
div.CodeRay { }
|
10
|
+
|
11
|
+
span.CodeRay { white-space: pre; border: 0px; padding: 2px }
|
12
|
+
|
13
|
+
table.CodeRay { border-collapse: collapse; padding: 2px }
|
14
|
+
table.CodeRay td { padding: 2px 4px; vertical-align: top }
|
15
|
+
|
16
|
+
.CodeRay .line_numbers, .CodeRay .no {
|
17
|
+
background-color: #def;
|
18
|
+
color: gray;
|
19
|
+
text-align: right;
|
20
|
+
}
|
21
|
+
.CodeRay .line_numbers tt { font-weight: bold }
|
22
|
+
.CodeRay .no { padding: 0px 4px }
|
23
|
+
.CodeRay .code { width: 100% }
|
24
|
+
|
25
|
+
ol.CodeRay { font-size: 10pt }
|
26
|
+
ol.CodeRay li { white-space: pre }
|
27
|
+
|
28
|
+
.CodeRay .code pre { overflow: auto }
|
29
|
+
|
30
|
+
.CodeRay .af { color:#00C }
|
31
|
+
.CodeRay .an { color:#007 }
|
32
|
+
.CodeRay .av { color:#700 }
|
33
|
+
.CodeRay .aw { color:#C00 }
|
34
|
+
.CodeRay .bi { color:#509; font-weight:bold }
|
35
|
+
.CodeRay .c { color:#888 }
|
36
|
+
|
37
|
+
.CodeRay .ch { color:#04D }
|
38
|
+
.CodeRay .ch .k { color:#04D }
|
39
|
+
.CodeRay .ch .dl { color:#039 }
|
40
|
+
|
41
|
+
.CodeRay .cl { color:#B06; font-weight:bold }
|
42
|
+
.CodeRay .co { color:#036; font-weight:bold }
|
43
|
+
.CodeRay .cr { color:#0A0 }
|
44
|
+
.CodeRay .cv { color:#369 }
|
45
|
+
.CodeRay .df { color:#099; font-weight:bold }
|
46
|
+
.CodeRay .di { color:#088; font-weight:bold }
|
47
|
+
.CodeRay .dl { color:black }
|
48
|
+
.CodeRay .do { color:#970 }
|
49
|
+
.CodeRay .ds { color:#D42; font-weight:bold }
|
50
|
+
.CodeRay .e { color:#666; font-weight:bold }
|
51
|
+
.CodeRay .en { color:#800; font-weight:bold }
|
52
|
+
.CodeRay .er { color:#F00; background-color:#FAA }
|
53
|
+
.CodeRay .ex { color:#F00; font-weight:bold }
|
54
|
+
.CodeRay .fl { color:#60E; font-weight:bold }
|
55
|
+
.CodeRay .fu { color:#06B; font-weight:bold }
|
56
|
+
.CodeRay .gv { color:#d70; font-weight:bold }
|
57
|
+
.CodeRay .hx { color:#058; font-weight:bold }
|
58
|
+
.CodeRay .i { color:#00D; font-weight:bold }
|
59
|
+
.CodeRay .ic { color:#B44; font-weight:bold }
|
60
|
+
|
61
|
+
.CodeRay .il { background: #eee }
|
62
|
+
.CodeRay .il .il { background: #ddd }
|
63
|
+
.CodeRay .il .il .il { background: #ccc }
|
64
|
+
.CodeRay .il .idl { font-weight: bold; color: #888 }
|
65
|
+
|
66
|
+
.CodeRay .in { color:#B2B; font-weight:bold }
|
67
|
+
.CodeRay .iv { color:#33B }
|
68
|
+
.CodeRay .la { color:#970; font-weight:bold }
|
69
|
+
.CodeRay .lv { color:#963 }
|
70
|
+
.CodeRay .oc { color:#40E; font-weight:bold }
|
71
|
+
.CodeRay .on { color:#000; font-weight:bold }
|
72
|
+
.CodeRay .op { }
|
73
|
+
.CodeRay .pc { color:#038; font-weight:bold }
|
74
|
+
.CodeRay .pd { color:#369; font-weight:bold }
|
75
|
+
.CodeRay .pp { color:#579 }
|
76
|
+
.CodeRay .pt { color:#339; font-weight:bold }
|
77
|
+
.CodeRay .r { color:#080; font-weight:bold }
|
78
|
+
|
79
|
+
.CodeRay .rx { background-color:#fff0ff }
|
80
|
+
.CodeRay .rx .k { color:#808 }
|
81
|
+
.CodeRay .rx .dl { color:#404 }
|
82
|
+
.CodeRay .rx .mod { color:#C2C }
|
83
|
+
.CodeRay .rx .fu { color:#404; font-weight: bold }
|
84
|
+
|
85
|
+
.CodeRay .s { background-color:#fff0f0 }
|
86
|
+
.CodeRay .s .s { background-color:#ffe0e0 }
|
87
|
+
.CodeRay .s .s .s { background-color:#ffd0d0 }
|
88
|
+
.CodeRay .s .k { color:#D20 }
|
89
|
+
.CodeRay .s .dl { color:#710 }
|
90
|
+
|
91
|
+
.CodeRay .sh { background-color:#f0fff0 }
|
92
|
+
.CodeRay .sh .k { color:#2B2 }
|
93
|
+
.CodeRay .sh .dl { color:#161 }
|
94
|
+
|
95
|
+
.CodeRay .sy { color:#A60 }
|
96
|
+
.CodeRay .sy .k { color:#A60 }
|
97
|
+
.CodeRay .sy .dl { color:#630 }
|
98
|
+
|
99
|
+
.CodeRay .ta { color:#070 }
|
100
|
+
.CodeRay .tf { color:#070; font-weight:bold }
|
101
|
+
.CodeRay .ts { color:#D70; font-weight:bold }
|
102
|
+
.CodeRay .ty { color:#339; font-weight:bold }
|
103
|
+
.CodeRay .v { color:#036 }
|
104
|
+
.CodeRay .xt { color:#444 }
|