ramaze 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -13,12 +13,13 @@
|
|
13
13
|
float: left;
|
14
14
|
cursor: pointer;
|
15
15
|
}
|
16
|
+
|
16
17
|
/* fix for IE6 */
|
17
18
|
* html div.hitarea {
|
18
19
|
background: #fff;
|
19
20
|
filter: alpha(opacity=0);
|
20
21
|
display: inline;
|
21
|
-
float:none;
|
22
|
+
float: none;
|
22
23
|
}
|
23
24
|
|
24
25
|
.treeview li {
|
@@ -34,14 +35,14 @@
|
|
34
35
|
|
35
36
|
.treeview .hover { color: red; cursor: pointer; }
|
36
37
|
|
37
|
-
.treeview li { background: url(
|
38
|
-
.treeview .collapsable { background-image: url(
|
39
|
-
.treeview .expandable { background-image: url(
|
40
|
-
.treeview .last { background-image: url(
|
41
|
-
.treeview .lastCollapsable { background-image: url(
|
42
|
-
.treeview .lastExpandable { background-image: url(
|
38
|
+
.treeview li { background: url(images/tv-item.gif) 0 0 no-repeat; }
|
39
|
+
.treeview .collapsable { background-image: url(images/tv-collapsable.gif); }
|
40
|
+
.treeview .expandable { background-image: url(images/tv-expandable.gif); }
|
41
|
+
.treeview .last { background-image: url(images/tv-item-last.gif); }
|
42
|
+
.treeview .lastCollapsable { background-image: url(images/tv-collapsable-last.gif); }
|
43
|
+
.treeview .lastExpandable { background-image: url(images/tv-expandable-last.gif); }
|
43
44
|
|
44
45
|
.filetree li { padding: 3px 0 1px 16px; }
|
45
46
|
.filetree span.folder, .filetree span.file { padding-left: 16px; display: block; height: 15px; }
|
46
|
-
.filetree span.folder { background: url(
|
47
|
-
.filetree span.file { background: url(
|
47
|
+
.filetree span.folder { background: url(images/folder.gif) 0 0 no-repeat; }
|
48
|
+
.filetree span.file { background: url(images/file.gif) 0 0 no-repeat; }
|
@@ -3,13 +3,13 @@
|
|
3
3
|
*
|
4
4
|
* http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
|
5
5
|
*
|
6
|
-
* Copyright (c)
|
6
|
+
* Copyright (c) 2007 Jörn Zaefferer
|
7
7
|
*
|
8
8
|
* Dual licensed under the MIT and GPL licenses:
|
9
9
|
* http://www.opensource.org/licenses/mit-license.php
|
10
10
|
* http://www.gnu.org/licenses/gpl.html
|
11
11
|
*
|
12
|
-
* Revision: $Id: jquery.treeview.js
|
12
|
+
* Revision: $Id: jquery.treeview.js 3752 2007-10-28 02:53:07Z joern.zaefferer $
|
13
13
|
*
|
14
14
|
*/
|
15
15
|
|
@@ -64,7 +64,7 @@
|
|
64
64
|
},
|
65
65
|
heightHide: function(animated, callback) {
|
66
66
|
if (animated) {
|
67
|
-
this.animate({ height: "hide" }, animated, callback)
|
67
|
+
this.animate({ height: "hide" }, animated, callback);
|
68
68
|
} else {
|
69
69
|
this.hide();
|
70
70
|
if (callback)
|
@@ -73,7 +73,7 @@
|
|
73
73
|
},
|
74
74
|
prepareBranches: function(settings) {
|
75
75
|
// mark last tree items
|
76
|
-
this.filter(":last-child").addClass(CLASSES.last);
|
76
|
+
this.filter(":last-child:not(ul)").addClass(CLASSES.last);
|
77
77
|
// collapse whole tree, or only those marked as closed, anyway except those marked as open
|
78
78
|
this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide();
|
79
79
|
// return all items with sublists
|
@@ -98,7 +98,7 @@
|
|
98
98
|
|
99
99
|
// create hitarea
|
100
100
|
this.prepend("<div class=\"" + CLASSES.hitarea + "\"/>")
|
101
|
-
.find("div." + CLASSES.hitarea).click( toggler )
|
101
|
+
.find("div." + CLASSES.hitarea).click( toggler );
|
102
102
|
},
|
103
103
|
treeview: function(settings) {
|
104
104
|
|
@@ -113,7 +113,7 @@
|
|
113
113
|
var callback = settings.toggle;
|
114
114
|
settings.toggle = function() {
|
115
115
|
return callback.apply($(this).parent()[0], arguments);
|
116
|
-
}
|
116
|
+
};
|
117
117
|
}
|
118
118
|
|
119
119
|
// factory for treecontroller
|
@@ -128,7 +128,7 @@
|
|
128
128
|
return filter ? $(this).parent("." + filter).length : true;
|
129
129
|
}) );
|
130
130
|
return false;
|
131
|
-
}
|
131
|
+
};
|
132
132
|
}
|
133
133
|
// click on first element to collapse tree
|
134
134
|
$(":eq(0)", control).click( handler(CLASSES.collapsable) );
|
@@ -1,16 +1,52 @@
|
|
1
|
-
|
1
|
+
var curfile = null;
|
2
|
+
var processing = false;
|
3
|
+
|
4
|
+
function setup() {
|
2
5
|
$('ul.filetree').treeview({
|
3
6
|
persist: 'location',
|
4
|
-
|
5
|
-
unique: true
|
6
|
-
collapsed: true
|
7
|
+
animated: 'fast',
|
8
|
+
unique: true
|
7
9
|
});
|
8
10
|
|
9
11
|
$("span.file").click(function(){
|
10
|
-
|
11
|
-
$('
|
12
|
-
|
12
|
+
processing = true;
|
13
|
+
file = $('a:eq(0)', this).attr('href').substr(1);
|
14
|
+
if (curfile != file) {
|
15
|
+
curfile = file;
|
16
|
+
$('a.selected').removeClass('selected');
|
17
|
+
$('#file_contents').load('/source'+curfile, {}, function(){ processing = false; });
|
18
|
+
$('a',this).eq(0).addClass('selected');
|
19
|
+
} else {
|
20
|
+
processing = false;
|
21
|
+
}
|
22
|
+
|
23
|
+
if (curfile) {
|
24
|
+
$('#repourl').empty().append(
|
25
|
+
$('<a/>').attr('href', 'http://darcs.ramaze.net/ramaze'+curfile)
|
26
|
+
.text('download '+curfile.substr(1))
|
27
|
+
);
|
28
|
+
urchinTracker(curfile);
|
29
|
+
}
|
13
30
|
});
|
14
31
|
|
15
32
|
$('a.selected').parent('span.file').click();
|
33
|
+
|
34
|
+
setInterval(function(){
|
35
|
+
if (processing) return;
|
36
|
+
|
37
|
+
curhash = document.location.hash.substr(1);
|
38
|
+
if(curfile != curhash) {
|
39
|
+
$("a[href='#"+curhash+"']").parents('ul, li').show().end()
|
40
|
+
.parent('span.file').click();
|
41
|
+
}
|
42
|
+
}, 100);
|
43
|
+
}
|
44
|
+
|
45
|
+
$(function(){
|
46
|
+
if (document.location.hash != '') {
|
47
|
+
curfile = document.location.hash.substr(1);
|
48
|
+
$('#file_contents').load('/source'+curfile, {}, setup);
|
49
|
+
} else {
|
50
|
+
setup();
|
51
|
+
}
|
16
52
|
});
|
@@ -4,26 +4,35 @@ require 'coderay'
|
|
4
4
|
require 'ramaze'
|
5
5
|
|
6
6
|
# where is the source
|
7
|
-
RAMAZE_SRC = File.expand_path(Ramaze::BASEDIR/'..')
|
7
|
+
RAMAZE_SRC = File.expand_path(Ramaze::BASEDIR/'..') unless defined? RAMAZE_SRC
|
8
|
+
|
9
|
+
# delete cached filetree when source changes
|
10
|
+
module Ramaze::SourceReloadHooks
|
11
|
+
module_function
|
12
|
+
def after_safe_load file
|
13
|
+
Ramaze::Cache.actions.delete '/filetree' if file =~ /^#{RAMAZE_SRC}/
|
14
|
+
end
|
15
|
+
end
|
8
16
|
|
9
17
|
class MainController < Ramaze::Controller
|
10
18
|
|
11
19
|
include Remarkably::Common
|
12
|
-
helper :partial, :inform, :cache
|
13
|
-
|
14
|
-
cache :filetree
|
20
|
+
helper :partial, :inform, :cache, :aspect
|
15
21
|
engine :None
|
16
|
-
|
17
|
-
def source
|
18
|
-
return if request['file'].nil? or request['file'] =~ /\.{2}/
|
19
22
|
|
20
|
-
|
21
|
-
if
|
22
|
-
inform :info, "Showing source for #{file}"
|
23
|
-
CodeRay.scan_file(file).html(:line_numbers => :inline)
|
24
|
-
end
|
23
|
+
def index *args
|
24
|
+
redirect "/#/#{args.join('/')}" if args.size > 0
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
|
+
def source *args
|
28
|
+
file = args.join('/')
|
29
|
+
return if file.empty? or file =~ /\.{2}/
|
30
|
+
|
31
|
+
file[0,0] = RAMAZE_SRC + '/'
|
32
|
+
CodeRay.scan_file(file).html(:line_numbers => :table) if FileTest.file? file
|
33
|
+
end
|
34
|
+
before(:source){ %(<link href='/coderay.css' rel='stylesheet' type='text/css' />) unless request.xhr? }
|
35
|
+
|
27
36
|
def filetree
|
28
37
|
ul :class => 'filetree treeview' do
|
29
38
|
Dir.chdir(RAMAZE_SRC) do
|
@@ -33,35 +42,29 @@ class MainController < Ramaze::Controller
|
|
33
42
|
end
|
34
43
|
end.to_s
|
35
44
|
end
|
36
|
-
|
37
|
-
|
38
|
-
response['Content-Type'] = 'text/css'
|
39
|
-
value_cache[:coderay] ||= CodeRay::Encoders[:html]::CSS.new.stylesheet
|
40
|
-
end
|
41
|
-
|
45
|
+
cache :filetree
|
46
|
+
|
42
47
|
private
|
43
48
|
|
44
49
|
def dir_listing dir
|
45
50
|
li do
|
46
51
|
span dir, :class => 'folder'
|
47
52
|
Dir.chdir(dir) do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
a d, :href => "##{file}"
|
59
|
-
end
|
53
|
+
ul :style => 'display: none;' do
|
54
|
+
a '', :href => "##{File.expand_path('.').sub(RAMAZE_SRC,'')}"
|
55
|
+
Dir['*'].sort.each do |d|
|
56
|
+
if FileTest.directory? d
|
57
|
+
dir_listing d
|
58
|
+
else
|
59
|
+
file = File.expand_path(d).sub(RAMAZE_SRC,'')
|
60
|
+
li do
|
61
|
+
span :class => 'file' do
|
62
|
+
a d, :href => "##{file}"
|
60
63
|
end
|
61
64
|
end
|
62
65
|
end
|
63
66
|
end
|
64
|
-
end
|
67
|
+
end if Dir['*'].any?
|
65
68
|
end
|
66
69
|
end
|
67
70
|
end
|
@@ -71,4 +74,4 @@ end
|
|
71
74
|
Ramaze.start :adapter => :mongrel,
|
72
75
|
:load_engines => :Haml,
|
73
76
|
:boring => /(js|gif|css)$/,
|
74
|
-
:port =>
|
77
|
+
:port => 9950
|
@@ -1,16 +1,22 @@
|
|
1
|
-
!!!
|
2
1
|
%html
|
3
2
|
%head
|
4
3
|
%title Ramaze Source Browser
|
5
|
-
|
6
|
-
%
|
4
|
+
|
5
|
+
%script{ :type => 'text/javascript', :src => '/jquery.js' }=''
|
6
|
+
%script{ :type => 'text/javascript', :src => '/jquery.treeview.js' }=''
|
7
|
+
%script{ :type => 'text/javascript', :src => '/sourceview.js?1.2' }=''
|
8
|
+
%script{ :type => 'text/javascript', :src => 'http://www.google-analytics.com/urchin.js' }=''
|
9
|
+
%script{ :type => 'text/javascript' }
|
10
|
+
_uacct = "UA-1005424-6";
|
11
|
+
|
7
12
|
%link{ :rel => 'stylesheet', :type => 'text/css', :href => '/coderay.css' }/
|
13
|
+
%link{ :rel => 'stylesheet', :type => 'text/css', :href => '/jquery.treeview.css' }/
|
8
14
|
%style{ :type => 'text/css' }
|
9
15
|
:sass
|
10
16
|
body
|
11
17
|
:font-family sans-serif
|
12
18
|
:margin 1.5em
|
13
|
-
|
19
|
+
|
14
20
|
a
|
15
21
|
:text-decoration none
|
16
22
|
:color #000
|
@@ -18,26 +24,36 @@
|
|
18
24
|
:color #f00
|
19
25
|
|
20
26
|
#dir_listing
|
21
|
-
:
|
22
|
-
|
27
|
+
:position absolute
|
28
|
+
:top 1.5em
|
29
|
+
:width 280px
|
30
|
+
|
23
31
|
.filetree
|
24
32
|
span.folder, span.file
|
25
33
|
:padding-left 19px
|
26
34
|
:margin-left 2px
|
27
|
-
|
35
|
+
|
28
36
|
#file_contents
|
29
37
|
:margin-left 290px
|
30
|
-
:white-space pre
|
31
38
|
:font-size 11pt
|
32
|
-
|
39
|
+
|
40
|
+
#welcome
|
41
|
+
:text-align center
|
42
|
+
:background-color #f8f8f8
|
43
|
+
:padding 1em
|
44
|
+
|
45
|
+
#repourl
|
46
|
+
:padding-top 4px
|
47
|
+
:text-align right
|
48
|
+
:font-size 10pt
|
49
|
+
a
|
50
|
+
:text-decoration underline
|
51
|
+
|
33
52
|
%body
|
34
|
-
#
|
35
|
-
|
36
|
-
#file_contents.CodeRay
|
37
|
-
%span{ :style => 'text-align: center' }
|
53
|
+
#file_contents
|
54
|
+
#welcome
|
38
55
|
%h1 Welcome to the Ramaze source code browser
|
39
56
|
%h3 pick a file on the left to view its contents
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
%script{ :type => 'text/javascript', :src => '/sourceview.js' }=""
|
57
|
+
#dir_listing
|
58
|
+
= render_partial('/filetree')
|
59
|
+
#repourl
|
@@ -1,24 +1,28 @@
|
|
1
1
|
require 'sequel'
|
2
|
-
require 'sequel/sqlite'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
begin
|
4
|
+
case $wikore_db
|
5
|
+
when :memory
|
6
|
+
DB = Sequel.sqlite
|
7
|
+
else
|
8
|
+
DB = Sequel.sqlite 'wikore.db'
|
9
|
+
end
|
10
|
+
rescue NoMethodError
|
11
|
+
raise LoadError, 'Install latest Sequel gem'
|
9
12
|
end
|
10
13
|
|
11
14
|
module Model
|
12
15
|
PAGE_SCHEMA = lambda{
|
16
|
+
primary_key :id
|
17
|
+
boolean :active, :default => true
|
18
|
+
text :text
|
19
|
+
integer :version
|
13
20
|
}
|
14
21
|
|
15
22
|
class Page < Sequel::Model(:page)
|
16
23
|
set_schema do
|
17
|
-
|
18
|
-
text
|
19
|
-
boolean :active, :default => true
|
20
|
-
text :text
|
21
|
-
integer :version
|
24
|
+
instance_eval &PAGE_SCHEMA
|
25
|
+
text :title, :unique => true, :null => false
|
22
26
|
end
|
23
27
|
|
24
28
|
def backup
|
@@ -37,11 +41,8 @@ module Model
|
|
37
41
|
|
38
42
|
class OldPage < Sequel::Model(:old_page)
|
39
43
|
set_schema do
|
40
|
-
|
41
|
-
text
|
42
|
-
boolean :active, :default => true
|
43
|
-
text :text
|
44
|
-
integer :version
|
44
|
+
instance_eval &PAGE_SCHEMA
|
45
|
+
text :title, :unique => false, :null => false
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
data/lib/proto/start.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
+
require 'rubygems'
|
4
5
|
require 'ramaze'
|
5
6
|
|
6
|
-
include Ramaze
|
7
|
-
|
8
7
|
require 'src/controller/main'
|
9
8
|
require 'src/element/page'
|
10
9
|
require 'src/model'
|
11
10
|
|
12
|
-
Ramaze.start
|
11
|
+
Ramaze.start :port => 7000
|
data/lib/ramaze.rb
CHANGED
@@ -34,6 +34,7 @@ require 'ramaze/sourcereload'
|
|
34
34
|
# Complete
|
35
35
|
require 'ramaze/dispatcher'
|
36
36
|
require 'ramaze/template/ezamar'
|
37
|
+
require 'ramaze/contrib'
|
37
38
|
|
38
39
|
module Ramaze
|
39
40
|
|
@@ -59,6 +60,8 @@ module Ramaze
|
|
59
60
|
trait[:essentials].each do |obj|
|
60
61
|
obj.startup(options)
|
61
62
|
end
|
63
|
+
else
|
64
|
+
Global.startup(options)
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|