ginatra 2.2.1 → 2.2.3
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/.gitignore +1 -1
- data/Gemfile +11 -0
- data/README.md +6 -2
- data/Rakefile +18 -67
- data/bin/ginatra +2 -2
- data/bin/ginatra-daemon +2 -2
- data/bin/ginatra-directory +3 -3
- data/bin/ginatra-server +5 -10
- data/config.ru +2 -4
- data/features/pages.feature +18 -16
- data/features/step_definitions/app_steps.rb +7 -0
- data/ginatra.gemspec +18 -0
- data/lib/ginatra.rb +19 -41
- data/lib/ginatra/config.rb +14 -17
- data/lib/ginatra/helpers.rb +0 -26
- data/lib/ginatra/repo.rb +6 -7
- data/rackup.ru +2 -4
- data/spec/repo_list_spec.rb +0 -1
- data/spec/repo_spec.rb +1 -2
- data/spec/spec_helper.rb +6 -20
- data/views/blob.erb +2 -2
- data/views/commit.erb +1 -1
- data/views/layout.erb +22 -30
- metadata +76 -41
- data/.gitattributes +0 -2
data/.gitignore
CHANGED
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
Ginatra
|
2
|
-
|
1
|
+
# Ginatra
|
2
|
+
[](http://stillmaintained.com/lenary/ginatra)
|
3
|
+
|
3
4
|
|
4
5
|
This project is to make a clone of gitweb in Ruby and Sinatra. It serves git
|
5
6
|
repositories out of a set of specified directories using an array of glob-based
|
@@ -96,6 +97,9 @@ Attribution
|
|
96
97
|
- Elia Schito (elia)
|
97
98
|
- Scott Wisely (Syd)
|
98
99
|
- Jonathan Stott (namelessjon)
|
100
|
+
- Michael James (umjames)
|
101
|
+
|
102
|
+
In a new spirit of openness, all those who submit a patch that gets applied will gain commit access to the main (lenary/ginatra) repository.
|
99
103
|
|
100
104
|
**Thanks**
|
101
105
|
|
data/Rakefile
CHANGED
@@ -1,88 +1,39 @@
|
|
1
|
-
require
|
1
|
+
require "bundler"
|
2
|
+
Bundler.setup(:default, :development)
|
2
3
|
require 'cucumber/rake/task'
|
3
|
-
require '
|
4
|
+
require 'rspec/core/rake_task'
|
4
5
|
|
5
|
-
|
6
|
+
task :default => ['rake:spec', 'rake:features']
|
6
7
|
|
7
|
-
require "ginatra"
|
8
8
|
|
9
|
-
|
9
|
+
desc "Clones the Test Repository"
|
10
|
+
task :repo do |t|
|
11
|
+
FileUtils.cd(File.join(File.dirname(__FILE__), "repos")) do
|
12
|
+
puts `git clone git://github.com/atmos/hancock-client.git test`
|
13
|
+
end
|
14
|
+
end
|
10
15
|
|
11
16
|
desc "Runs the Cucumber Feature Suite"
|
12
17
|
Cucumber::Rake::Task.new(:features) do |t|
|
13
|
-
t.cucumber_opts = "--format pretty"
|
18
|
+
t.cucumber_opts = ["--format pretty", "features"]
|
14
19
|
end
|
15
|
-
|
16
20
|
namespace :features do
|
17
|
-
|
18
21
|
desc "Runs the `@current` feature(s) or scenario(s)"
|
19
22
|
Cucumber::Rake::Task.new(:current) do |c|
|
20
|
-
c.cucumber_opts = "--format pretty -t current"
|
23
|
+
c.cucumber_opts = ["--format pretty", "-t current", "features"]
|
21
24
|
end
|
22
|
-
|
23
25
|
end
|
24
26
|
|
25
27
|
desc "Runs the RSpec Test Suite"
|
26
|
-
|
27
|
-
r.
|
28
|
-
r.
|
28
|
+
RSpec::Core::RakeTask.new(:spec) do |r|
|
29
|
+
r.pattern = 'spec/*_spec.rb'
|
30
|
+
r.rspec_opts = ['--color']
|
29
31
|
end
|
30
|
-
|
31
32
|
namespace :spec do
|
32
|
-
|
33
33
|
desc "RSpec Test Suite with pretty output"
|
34
|
-
|
35
|
-
r.
|
36
|
-
r.
|
37
|
-
end
|
38
|
-
|
39
|
-
desc "RSpec Test Suite with html output"
|
40
|
-
Spec::Rake::SpecTask.new(:html) do |r|
|
41
|
-
r.spec_files = FileList['spec/*_spec.rb']
|
42
|
-
r.spec_opts = ['--color', '--format html:spec/html_spec.html']
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
namespace :setup do
|
48
|
-
|
49
|
-
desc "Clones the Test Repository"
|
50
|
-
task :repo do |t|
|
51
|
-
FileUtils.cd(File.join(Dir.pwd, "repos")) do
|
52
|
-
puts `git clone git://github.com/atmos/hancock-client.git test`
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
desc "Installs the Required Gems"
|
57
|
-
task :gems do |t|
|
58
|
-
gems = %w(grit kematzy-sinatra-cache)
|
59
|
-
puts %x(gem install #{gems.join(" ")})
|
60
|
-
end
|
61
|
-
|
62
|
-
desc "Installs the Test Gems"
|
63
|
-
task :test do |t|
|
64
|
-
gems = %w(rspec webrat rack-test cucumber)
|
65
|
-
puts %x(gem install #{gems.join(" ")})
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
begin
|
71
|
-
require 'jeweler'
|
72
|
-
Jeweler::Tasks.new do |gemspec|
|
73
|
-
gemspec.name = "ginatra"
|
74
|
-
gemspec.summary = "A Gitweb Clone in Sinatra and Grit"
|
75
|
-
gemspec.description = "Host your own git repository browser through the power of Sinatra and Grit"
|
76
|
-
gemspec.email = "sam@lenary.co.uk"
|
77
|
-
gemspec.homepage = "http://lenary.github.com/ginatra"
|
78
|
-
gemspec.authors = ["Sam Elliott", "Ryan Bigg"]
|
79
|
-
gemspec.version = Ginatra::VERSION
|
80
|
-
gemspec.add_dependency('sinatra', '>=0.9.4')
|
81
|
-
gemspec.add_dependency('grit', '>=1.1.1')
|
82
|
-
gemspec.add_dependency('vegas', '>=0.1.0')
|
83
|
-
gemspec.add_dependency('open4', '>= 0.9.6')
|
34
|
+
RSpec::Core::RakeTask.new(:long) do |r|
|
35
|
+
r.pattern = 'spec/*_spec.rb'
|
36
|
+
r.rspec_opts = ['--color', '--format documentation']
|
84
37
|
end
|
85
|
-
rescue LoadError
|
86
|
-
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
87
38
|
end
|
88
39
|
|
data/bin/ginatra
CHANGED
data/bin/ginatra-daemon
CHANGED
data/bin/ginatra-directory
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require "bundler"
|
4
|
+
Bundler.setup(:default)
|
5
5
|
require "ginatra"
|
6
6
|
require "logger"
|
7
7
|
|
@@ -19,7 +19,7 @@ module Ginatra::Directory
|
|
19
19
|
Usage: ginatra-directory [ list | add <globs> | remove <globs> ]
|
20
20
|
|
21
21
|
Commands:
|
22
|
-
add - Adds the <globs> to the array of dirs that Ginatra
|
22
|
+
add - Adds the <globs> to the array of dirs that Ginatra
|
23
23
|
looks in for repositories.
|
24
24
|
remove - Removes the <globs> from the aforementioned array.
|
25
25
|
list - Lists the globs Ginatra looks in for repositories
|
data/bin/ginatra-server
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
rescue LoadError
|
6
|
-
end
|
7
|
-
require "vegas"
|
8
|
-
|
9
|
-
$:.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib")
|
10
|
-
|
3
|
+
require "bundler"
|
4
|
+
Bundler.setup(:default)
|
11
5
|
require "ginatra"
|
6
|
+
require "vegas"
|
12
7
|
|
13
8
|
Vegas::Runner.new(Ginatra::App, 'ginatra-server', {:port => Ginatra::Config.port, :host => Ginatra::Config.host}) do |runner, opts, app|
|
14
|
-
|
9
|
+
|
15
10
|
opts.banner = "Usage: ginatra-server [[options] start | stop | status]"
|
16
11
|
|
17
12
|
opts.separator " start - Start the Ginatra HTTP Server"
|
@@ -29,6 +24,6 @@ Vegas::Runner.new(Ginatra::App, 'ginatra-server', {:port => Ginatra::Config.port
|
|
29
24
|
runner.options[:start] = false
|
30
25
|
at_exit { puts opts }
|
31
26
|
end
|
32
|
-
|
27
|
+
|
33
28
|
end
|
34
29
|
|
data/config.ru
CHANGED
data/features/pages.feature
CHANGED
@@ -2,32 +2,34 @@ Feature: Page
|
|
2
2
|
In order to use multiple repositories
|
3
3
|
As a browser
|
4
4
|
I want to see the home page
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I am on the homepage
|
5
8
|
|
6
|
-
Scenario:
|
7
|
-
When I open '/'
|
9
|
+
Scenario: Viewing all the repositories
|
8
10
|
Then I should see "Ginatra"
|
9
11
|
And I should see "View My Git Repositories"
|
10
12
|
And I should see "test"
|
11
13
|
And I should see "description file for this repository and set the description for it."
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
And I should see "test"
|
14
|
+
|
15
|
+
Scenario: Viewing a single repository
|
16
|
+
When I follow "test"
|
16
17
|
And I should see "description file for this repository and set the description for it."
|
17
18
|
And I should see "Commits"
|
19
|
+
# Perhaps "And I should see xxxxxx as the latest commit"
|
18
20
|
And I should see "(author)"
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
And I should see "test"
|
21
|
+
|
22
|
+
Scenario: Viewing a commit
|
23
|
+
When I follow "test"
|
23
24
|
And I should see "description file for this repository and set the description for it."
|
24
|
-
|
25
|
-
And I should see "
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
When I follow "095955b6402c30ef24520bafdb8a8687df0a98d3"
|
26
|
+
And I should see "Commit: 095955b"
|
27
|
+
And I should see "first pass at having the hancock client"
|
28
|
+
|
29
|
+
Scenario: Viewing a file on a commit
|
30
|
+
When I open '/test/tree/6f27ba2f'
|
29
31
|
And I should see "test"
|
30
32
|
And I should see "description file for this repository and set the description for it."
|
31
|
-
And I should see "Tree:
|
33
|
+
And I should see "Tree: 6f27ba2f"
|
32
34
|
And I should see "README.md"
|
33
35
|
And I should see ".gitignore"
|
data/ginatra.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "ginatra"
|
3
|
+
s.version = "2.2.3"
|
4
|
+
s.summary = "A Gitweb Clone in Sinatra and Grit"
|
5
|
+
s.description = "Host your own git repository browser through the power of Sinatra and Grit"
|
6
|
+
s.email = "sam@lenary.co.uk"
|
7
|
+
s.homepage = "http://lenary.co.uk/ginatra"
|
8
|
+
s.authors = ["Sam Elliott", "Ryan Bigg"]
|
9
|
+
s.add_dependency('bundler', '~> 1.0.15')
|
10
|
+
s.add_dependency('sinatra', '~> 1.2.6')
|
11
|
+
s.add_dependency('grit', '~> 2.4.1')
|
12
|
+
s.add_dependency('vegas', '~> 0.1.8')
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- spec`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin`.split("\n").map {|f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
end
|
data/lib/ginatra.rb
CHANGED
@@ -1,28 +1,19 @@
|
|
1
|
-
# We only want Rubygems if it exists. Else, we assume they know what they're doing.
|
2
|
-
begin
|
3
|
-
require 'rubygems'
|
4
|
-
rescue LoadError
|
5
|
-
end
|
6
|
-
require 'sinatra/base'
|
7
|
-
require 'grit'
|
8
|
-
|
9
|
-
# The Ginatra Namespace Module
|
10
|
-
module Ginatra; end
|
11
1
|
|
12
|
-
|
13
|
-
|
2
|
+
require "bundler"
|
3
|
+
Bundler.setup(:default)
|
4
|
+
require 'sinatra/base'
|
14
5
|
|
15
|
-
# Loading in whichever order
|
16
|
-
require "ginatra/repo"
|
17
|
-
require "ginatra/repo_list"
|
18
|
-
require "ginatra/config"
|
19
|
-
require "ginatra/helpers"
|
20
6
|
|
21
7
|
require "sinatra/partials"
|
22
8
|
|
23
9
|
# Written myself. i know, what the hell?!
|
24
10
|
module Ginatra
|
25
11
|
|
12
|
+
autoload :Config, "ginatra/config"
|
13
|
+
autoload :Helpers, "ginatra/helpers"
|
14
|
+
autoload :Repo, "ginatra/repo"
|
15
|
+
autoload :RepoList, "ginatra/repo_list"
|
16
|
+
|
26
17
|
# A standard error class for inheritance.
|
27
18
|
class Error < StandardError; end
|
28
19
|
|
@@ -41,8 +32,6 @@ module Ginatra
|
|
41
32
|
end
|
42
33
|
end
|
43
34
|
|
44
|
-
VERSION = "2.2.1"
|
45
|
-
|
46
35
|
# The main application class.
|
47
36
|
#
|
48
37
|
# This class contains all the core application logic
|
@@ -68,17 +57,7 @@ module Ginatra
|
|
68
57
|
set :views, "#{current_path}/../views"
|
69
58
|
end
|
70
59
|
|
71
|
-
helpers
|
72
|
-
|
73
|
-
# Ginatra::Helpers module full of goodness
|
74
|
-
include Helpers
|
75
|
-
|
76
|
-
# My Sinatra Partials implementation.
|
77
|
-
#
|
78
|
-
# check out http://gist.github.com/119874
|
79
|
-
# for more details
|
80
|
-
include ::Sinatra::Partials
|
81
|
-
end
|
60
|
+
helpers Helpers, Sinatra::Partials
|
82
61
|
|
83
62
|
# Let's handle a CommitsError.
|
84
63
|
#
|
@@ -102,7 +81,7 @@ module Ginatra
|
|
102
81
|
@repo = RepoList.find(params[:repo])
|
103
82
|
@commits = @repo.commits
|
104
83
|
return "" if @commits.empty?
|
105
|
-
etag(@commits.first.id)
|
84
|
+
etag(@commits.first.id) if Ginatra::App.environment?(:production)
|
106
85
|
builder :atom, :layout => nil
|
107
86
|
end
|
108
87
|
|
@@ -114,7 +93,7 @@ module Ginatra
|
|
114
93
|
get '/:repo' do
|
115
94
|
@repo = RepoList.find(params[:repo])
|
116
95
|
@commits = @repo.commits
|
117
|
-
etag(@commits.first.id)
|
96
|
+
etag(@commits.first.id) if Ginatra::App.environment?(:production)
|
118
97
|
erb :log
|
119
98
|
end
|
120
99
|
|
@@ -126,7 +105,7 @@ module Ginatra
|
|
126
105
|
@repo = RepoList.find(params[:repo])
|
127
106
|
@commits = @repo.commits(params[:ref])
|
128
107
|
return "" if @commits.empty?
|
129
|
-
etag(@commits.first.id)
|
108
|
+
etag(@commits.first.id) if Ginatra::App.environment?(:production)
|
130
109
|
builder :atom, :layout => nil
|
131
110
|
end
|
132
111
|
|
@@ -140,7 +119,7 @@ module Ginatra
|
|
140
119
|
params[:page] = 1
|
141
120
|
@repo = RepoList.find(params[:repo])
|
142
121
|
@commits = @repo.commits(params[:ref])
|
143
|
-
etag(@commits.first.id)
|
122
|
+
etag(@commits.first.id) if Ginatra::App.environment?(:production)
|
144
123
|
erb :log
|
145
124
|
end
|
146
125
|
|
@@ -161,7 +140,7 @@ module Ginatra
|
|
161
140
|
get '/:repo/commit/:commit' do
|
162
141
|
@repo = RepoList.find(params[:repo])
|
163
142
|
@commit = @repo.commit(params[:commit]) # can also be a ref
|
164
|
-
etag(@commit.id)
|
143
|
+
etag(@commit.id) if Ginatra::App.environment?(:production)
|
165
144
|
erb(:commit)
|
166
145
|
end
|
167
146
|
|
@@ -183,12 +162,11 @@ module Ginatra
|
|
183
162
|
get '/:repo/tree/:tree' do
|
184
163
|
@repo = RepoList.find(params[:repo])
|
185
164
|
|
186
|
-
|
187
|
-
if (tag = @repo.git.method_missing('rev_parse', {}, '--verify', "#{params[:tree]}^{tree}")).empty?
|
165
|
+
if (tag = @repo.git.rev_parse({'--verify' => ''}, "#{params[:tree]}^{tree}")).empty?
|
188
166
|
# we don't have a tree.
|
189
167
|
not_found
|
190
168
|
else
|
191
|
-
etag(tag)
|
169
|
+
etag(tag) if Ginatra::App.environment?(:production)
|
192
170
|
end
|
193
171
|
|
194
172
|
@tree = @repo.tree(params[:tree]) # can also be a ref (i think)
|
@@ -213,7 +191,7 @@ module Ginatra
|
|
213
191
|
# this allows people to put in the remaining part of the path to the file, rather than endless clicks like you need in github
|
214
192
|
redirect "#{params[:repo]}/blob/#{params[:tree]}/#{params[:splat].first}"
|
215
193
|
else
|
216
|
-
etag(@tree.id)
|
194
|
+
etag(@tree.id) if Ginatra::App.environment?(:production)
|
217
195
|
@path = {}
|
218
196
|
@path[:tree] = "#{params[:repo]}/tree/#{params[:tree]}/#{params[:splat].first}"
|
219
197
|
@path[:blob] = "#{params[:repo]}/blob/#{params[:tree]}/#{params[:splat].first}"
|
@@ -228,7 +206,7 @@ module Ginatra
|
|
228
206
|
get '/:repo/blob/:blob' do
|
229
207
|
@repo = RepoList.find(params[:repo])
|
230
208
|
@blob = @repo.blob(params[:blob])
|
231
|
-
etag(@blob.id)
|
209
|
+
etag(@blob.id) if Ginatra::App.environment?(:production)
|
232
210
|
erb(:blob)
|
233
211
|
end
|
234
212
|
|
@@ -247,7 +225,7 @@ module Ginatra
|
|
247
225
|
# this allows people to put in the remaining part of the path to the folder, rather than endless clicks like you need in github
|
248
226
|
redirect "/#{params[:repo]}/tree/#{params[:tree]}/#{params[:splat].first}"
|
249
227
|
else
|
250
|
-
etag(@blob.id)
|
228
|
+
etag(@blob.id) if Ginatra::App.environment?(:production)
|
251
229
|
erb(:blob)
|
252
230
|
end
|
253
231
|
end
|
data/lib/ginatra/config.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require 'fileutils'
|
3
|
+
|
1
4
|
module Ginatra
|
2
5
|
|
3
6
|
# A Wrapper for the ginatra configuration variables,
|
@@ -27,7 +30,7 @@ module Ginatra
|
|
27
30
|
|
28
31
|
# create log_file location
|
29
32
|
# The log_file config option should be an absolute file system path
|
30
|
-
# It doesn't have to exist, but ginatra should have the proper file system privileges to create the directories
|
33
|
+
# It doesn't have to exist, but ginatra should have the proper file system privileges to create the directories
|
31
34
|
# and files along the specified path
|
32
35
|
unless log_file == STDOUT
|
33
36
|
parent_dir, separator, file_component = log_file.rpartition("/")
|
@@ -53,33 +56,27 @@ module Ginatra
|
|
53
56
|
@logger
|
54
57
|
end
|
55
58
|
|
56
|
-
|
57
|
-
|
58
|
-
#
|
59
|
-
# Very Destructive Method. Use with care!
|
60
|
-
def self.setup!
|
59
|
+
unless File.exist?(CONFIG_PATH)
|
60
|
+
FileUtils.mkdir_p(File.dirname(CONFIG_PATH))
|
61
61
|
File.open(CONFIG_PATH, 'w') do |f|
|
62
62
|
YAML.dump(DEFAULT_CONFIG, f)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
unless File.exist?(CONFIG_PATH)
|
67
|
-
require 'fileutils'
|
68
|
-
FileUtils.mkdir_p(File.dirname(CONFIG_PATH))
|
69
|
-
setup!
|
70
|
-
end
|
71
|
-
|
72
66
|
# Loads the configuration and merges it with
|
73
67
|
# the default configuration.
|
74
68
|
#
|
75
69
|
# @return [Hash] config a hash of the configuration options
|
76
70
|
def self.load!
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
71
|
+
loaded_config = {}
|
72
|
+
@config = DEFAULT_CONFIG.dup
|
73
|
+
if File.size(CONFIG_PATH) == 0
|
74
|
+
dump!
|
75
|
+
else
|
76
|
+
loaded_config = YAML.load_file(CONFIG_PATH)
|
77
|
+
@config.merge!(loaded_config)
|
81
78
|
end
|
82
|
-
@config
|
79
|
+
@config
|
83
80
|
end
|
84
81
|
|
85
82
|
# Dumps the _current_ configuration to +CONFIG_PATH+
|
data/lib/ginatra/helpers.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "digest/md5"
|
2
|
-
require "open4"
|
3
2
|
|
4
3
|
module Ginatra
|
5
4
|
# Helpers used in the views usually,
|
@@ -231,30 +230,5 @@ module Ginatra
|
|
231
230
|
def atom_feed_link(repo_param, ref=nil)
|
232
231
|
"<a href=\"" + prefix_url("#{repo_param}#{"/#{ref}" if !ref.nil?}.atom") + "\" title=\"Atom Feed\" class=\"atom\">Feed</a>"
|
233
232
|
end
|
234
|
-
|
235
|
-
def pygmentize(content, filename=nil)
|
236
|
-
type = !filename ? "diff" : pygmentize_type(filename)
|
237
|
-
html_output = ''
|
238
|
-
Open4.popen4("pygmentize -l #{type} -f html") do |pid, stdin, stdout, stderr|
|
239
|
-
stdin.puts content
|
240
|
-
stdin.close
|
241
|
-
html_output = stdout.read.strip
|
242
|
-
[stdout, stderr].each {|io| io.close }
|
243
|
-
end
|
244
|
-
html_output
|
245
|
-
rescue Errno::ENOENT
|
246
|
-
return "<div class=\"highlight\"><pre>#{content}</pre></div>"
|
247
|
-
end
|
248
|
-
|
249
|
-
def pygmentize_type(filename)
|
250
|
-
type =''
|
251
|
-
Open4.popen4("pygmentize -N #{filename}") do |pid, stdin, stdout, stderr|
|
252
|
-
type = stdout.read.strip
|
253
|
-
[stdin, stdout, stderr].each {|io| io.close }
|
254
|
-
end
|
255
|
-
type
|
256
|
-
rescue Errno::ENOENT
|
257
|
-
return "text"
|
258
|
-
end
|
259
233
|
end
|
260
234
|
end
|
data/lib/ginatra/repo.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "grit"
|
2
|
+
|
1
3
|
module Grit
|
2
4
|
class Commit
|
3
5
|
# this lets us add a link between commits and refs directly
|
@@ -30,7 +32,7 @@ module Ginatra
|
|
30
32
|
|
31
33
|
# Return a commit corresponding to the commit to the repo,
|
32
34
|
# but with the refs already attached.
|
33
|
-
#
|
35
|
+
#
|
34
36
|
# @see Ginatra::Repo#add_refs
|
35
37
|
#
|
36
38
|
# @raise [Ginatra::InvalidCommit] if the commit doesn't exist.
|
@@ -56,10 +58,10 @@ module Ginatra
|
|
56
58
|
def commits(start = 'master', max_count = 10, skip = 0)
|
57
59
|
raise(Ginatra::Error.new("max_count cannot be less than 0")) if max_count < 0
|
58
60
|
@repo.commits(start, max_count, skip).each do |commit|
|
59
|
-
add_refs(commit)
|
61
|
+
add_refs(commit)
|
60
62
|
end
|
61
63
|
end
|
62
|
-
|
64
|
+
|
63
65
|
# Adds the refs corresponding to Grit::Commit objects to the respective Commit objects.
|
64
66
|
#
|
65
67
|
# @todo Perhaps move into commit class.
|
@@ -67,10 +69,7 @@ module Ginatra
|
|
67
69
|
# @param [Grit::Commit] commit the commit you want refs added to
|
68
70
|
# @return [Array] the array of refs added to the commit. they are also on the commit object.
|
69
71
|
def add_refs(commit)
|
70
|
-
commit.refs =
|
71
|
-
refs = @repo.refs.select { |ref| ref.commit.id == commit.id }
|
72
|
-
commit.refs << refs
|
73
|
-
commit.refs.flatten!
|
72
|
+
commit.refs = @repo.refs.select {|ref| ref.commit.id == commit.id }
|
74
73
|
end
|
75
74
|
|
76
75
|
# Catch all
|
data/rackup.ru
CHANGED
data/spec/repo_list_spec.rb
CHANGED
data/spec/repo_spec.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
2
1
|
require "spec_helper"
|
3
2
|
|
4
3
|
describe "Ginatra" do
|
@@ -12,7 +11,7 @@ describe "Ginatra" do
|
|
12
11
|
@repo_list = Ginatra::RepoList
|
13
12
|
@ginatra_repo = @repo_list.find("test")
|
14
13
|
@grit_repo = Grit::Repo.new(File.join(current_path, "..", "repos", "test"), {})
|
15
|
-
@commit = @ginatra_repo.commit("
|
14
|
+
@commit = @ginatra_repo.commit("095955b6402c30ef24520bafdb8a8687df0a98d3")
|
16
15
|
end
|
17
16
|
|
18
17
|
it "should have a name" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,27 +1,13 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
$:.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib")
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.setup(:default, :test)
|
4
|
+
require 'rspec'
|
7
5
|
require "ginatra"
|
8
|
-
|
9
|
-
#gem 'webrat', '>=0.4.4'
|
10
|
-
begin
|
11
|
-
# When using webrat 0.6.0, there is no webrat/sinatra.rb file.
|
12
|
-
# Looking at the gem's code, it looks like it autoloads the sinatra adapter at webrat/adapters/sinatra.rb.
|
13
|
-
# So requiring just 'webrat' will also load the sinatra adapater, which is done in the rescue clause.
|
14
|
-
require 'webrat/sinatra'
|
15
|
-
rescue LoadError
|
16
|
-
STDERR.puts "WARNING: could not load webrat/sinatra: #{__FILE__}:#{__LINE__}"
|
17
|
-
require 'webrat'
|
18
|
-
end
|
19
|
-
|
20
|
-
#gem 'rack-test', '>=0.3.0'
|
6
|
+
require 'webrat'
|
21
7
|
require 'rack/test'
|
22
8
|
|
23
9
|
Webrat.configure do |config|
|
24
|
-
config.mode = :
|
10
|
+
config.mode = :rack
|
25
11
|
end
|
26
12
|
|
27
13
|
current_path = File.expand_path(File.dirname(__FILE__))
|
@@ -29,7 +15,7 @@ current_path = File.expand_path(File.dirname(__FILE__))
|
|
29
15
|
Ginatra::App.set :environment, :test
|
30
16
|
Ginatra::Config[:git_dirs] = ["#{current_path}/../repos/*"]
|
31
17
|
|
32
|
-
|
18
|
+
RSpec.configure do |config|
|
33
19
|
def app
|
34
20
|
Ginatra::App
|
35
21
|
end
|
data/views/blob.erb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
<div class="active">
|
4
4
|
<div class="blob">
|
5
5
|
<h4><img src="<%= prefix_url("img/doc.png") %>" /><%= @blob.name %></h4>
|
6
|
-
|
6
|
+
<pre><code><%= @blob.data %></code></pre>
|
7
7
|
</div>
|
8
8
|
<div class="clearfix"> </div>
|
9
|
-
</div>
|
9
|
+
</div>
|
data/views/commit.erb
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
<% @commit.diffs.select { |d| !d.deleted_file && !d.new_file }.each do |diff| %>
|
14
14
|
<% count += 1 %>
|
15
15
|
<h4><img src="<%= prefix_url("img/doc.png") %>" /><a name='file_<%= count %>'><code><%= diff.b_path %></code></a></h4>
|
16
|
-
<
|
16
|
+
<pre><code class="diff"><%= diff.diff %></code></pre>
|
17
17
|
<% end %>
|
18
18
|
</div>
|
19
19
|
</div>
|
data/views/layout.erb
CHANGED
@@ -1,36 +1,28 @@
|
|
1
1
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
2
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
<htm
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>Ginatra</title>
|
7
|
+
<link rel="stylesheet" href="<%= prefix_url("src/index.css") %>" type="text/css" media="screen" />
|
8
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
|
9
|
+
<script src="<%= prefix_url("src/ginatra.js") %>" type="text/javascript"></script>
|
10
|
+
<script type="text/javascript" src="<%= prefix_url("src/highlight.pack.js") %>"></script>
|
11
11
|
<script type="text/javascript">
|
12
12
|
hljs.initHighlightingOnLoad();
|
13
13
|
</script>
|
14
|
-
<
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
<
|
19
|
-
|
20
|
-
|
21
|
-
</
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
<%= yield %>
|
29
|
-
</div>
|
30
|
-
<div id="footer-spacer"> </div>
|
31
|
-
</div>
|
32
|
-
<div id="footer">
|
33
|
-
Ginatra — © 2009 Samuel Elliott — <a href="http://www.opensource.org/licenses/mit-license.php">MIT Licence</a>
|
34
|
-
</div>
|
35
|
-
</body>
|
14
|
+
<link rel="stylesheet" href="<%= prefix_url("src/github.css") %>" type="text/css" media="screen" />
|
15
|
+
</head>
|
16
|
+
<body>
|
17
|
+
<div id="content">
|
18
|
+
<div id="inner">
|
19
|
+
<h1><a href="<%= prefix_url %>">Ginatra</a></h1>
|
20
|
+
<%= yield %>
|
21
|
+
</div>
|
22
|
+
<div id="footer-spacer"> </div>
|
23
|
+
</div>
|
24
|
+
<div id="footer">
|
25
|
+
Ginatra — © 2009 Samuel Elliott — <a href="http://www.opensource.org/licenses/mit-license.php">MIT Licence</a>
|
26
|
+
</div>
|
27
|
+
</body>
|
36
28
|
</html>
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ginatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 1
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 2
|
9
|
+
- 3
|
10
|
+
version: 2.2.3
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Sam Elliott
|
@@ -10,49 +16,73 @@ autorequire:
|
|
10
16
|
bindir: bin
|
11
17
|
cert_chain: []
|
12
18
|
|
13
|
-
date:
|
19
|
+
date: 2011-07-01 00:00:00 +01:00
|
14
20
|
default_executable:
|
15
21
|
dependencies:
|
16
22
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
23
|
+
name: bundler
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 9
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 0
|
34
|
+
- 15
|
35
|
+
version: 1.0.15
|
18
36
|
type: :runtime
|
19
|
-
|
20
|
-
|
37
|
+
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: sinatra
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
21
43
|
requirements:
|
22
|
-
- -
|
44
|
+
- - ~>
|
23
45
|
- !ruby/object:Gem::Version
|
24
|
-
|
25
|
-
|
46
|
+
hash: 19
|
47
|
+
segments:
|
48
|
+
- 1
|
49
|
+
- 2
|
50
|
+
- 6
|
51
|
+
version: 1.2.6
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
26
54
|
- !ruby/object:Gem::Dependency
|
27
55
|
name: grit
|
28
|
-
|
29
|
-
|
30
|
-
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
31
59
|
requirements:
|
32
|
-
- -
|
60
|
+
- - ~>
|
33
61
|
- !ruby/object:Gem::Version
|
34
|
-
|
35
|
-
|
62
|
+
hash: 29
|
63
|
+
segments:
|
64
|
+
- 2
|
65
|
+
- 4
|
66
|
+
- 1
|
67
|
+
version: 2.4.1
|
68
|
+
type: :runtime
|
69
|
+
version_requirements: *id003
|
36
70
|
- !ruby/object:Gem::Dependency
|
37
71
|
name: vegas
|
38
|
-
|
39
|
-
|
40
|
-
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
41
75
|
requirements:
|
42
|
-
- -
|
76
|
+
- - ~>
|
43
77
|
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
-
|
47
|
-
|
78
|
+
hash: 11
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
- 1
|
82
|
+
- 8
|
83
|
+
version: 0.1.8
|
48
84
|
type: :runtime
|
49
|
-
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.9.6
|
55
|
-
version:
|
85
|
+
version_requirements: *id004
|
56
86
|
description: Host your own git repository browser through the power of Sinatra and Grit
|
57
87
|
email: sam@lenary.co.uk
|
58
88
|
executables:
|
@@ -62,11 +92,11 @@ executables:
|
|
62
92
|
- ginatra-server
|
63
93
|
extensions: []
|
64
94
|
|
65
|
-
extra_rdoc_files:
|
66
|
-
|
95
|
+
extra_rdoc_files: []
|
96
|
+
|
67
97
|
files:
|
68
|
-
- .gitattributes
|
69
98
|
- .gitignore
|
99
|
+
- Gemfile
|
70
100
|
- README.md
|
71
101
|
- Rakefile
|
72
102
|
- bin/ginatra
|
@@ -75,8 +105,10 @@ files:
|
|
75
105
|
- bin/ginatra-server
|
76
106
|
- config.ru
|
77
107
|
- features/pages.feature
|
108
|
+
- features/step_definitions/app_steps.rb
|
78
109
|
- features/step_definitions/page_steps.rb
|
79
110
|
- features/support/env.rb
|
111
|
+
- ginatra.gemspec
|
80
112
|
- lib/ginatra.rb
|
81
113
|
- lib/ginatra/config.rb
|
82
114
|
- lib/ginatra/helpers.rb
|
@@ -89,13 +121,10 @@ files:
|
|
89
121
|
- public/img/doc.png
|
90
122
|
- public/img/rm.png
|
91
123
|
- public/img/tree.png
|
92
|
-
- public/src/blank.gif
|
93
124
|
- public/src/colour.css
|
94
125
|
- public/src/commit.css
|
95
126
|
- public/src/ginatra.js
|
96
|
-
- public/src/iepngfix.htc
|
97
127
|
- public/src/index.css
|
98
|
-
- public/src/jquery-1.3.2.min.js
|
99
128
|
- public/src/lists.css
|
100
129
|
- public/src/reset.css
|
101
130
|
- public/src/table.css
|
@@ -117,30 +146,36 @@ files:
|
|
117
146
|
- views/log.erb
|
118
147
|
- views/tree.erb
|
119
148
|
has_rdoc: true
|
120
|
-
homepage: http://lenary.
|
149
|
+
homepage: http://lenary.co.uk/ginatra
|
121
150
|
licenses: []
|
122
151
|
|
123
152
|
post_install_message:
|
124
|
-
rdoc_options:
|
125
|
-
|
153
|
+
rdoc_options: []
|
154
|
+
|
126
155
|
require_paths:
|
127
156
|
- lib
|
128
157
|
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
none: false
|
129
159
|
requirements:
|
130
160
|
- - ">="
|
131
161
|
- !ruby/object:Gem::Version
|
162
|
+
hash: 3
|
163
|
+
segments:
|
164
|
+
- 0
|
132
165
|
version: "0"
|
133
|
-
version:
|
134
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
135
168
|
requirements:
|
136
169
|
- - ">="
|
137
170
|
- !ruby/object:Gem::Version
|
171
|
+
hash: 3
|
172
|
+
segments:
|
173
|
+
- 0
|
138
174
|
version: "0"
|
139
|
-
version:
|
140
175
|
requirements: []
|
141
176
|
|
142
177
|
rubyforge_project:
|
143
|
-
rubygems_version: 1.3.
|
178
|
+
rubygems_version: 1.3.7
|
144
179
|
signing_key:
|
145
180
|
specification_version: 3
|
146
181
|
summary: A Gitweb Clone in Sinatra and Grit
|
data/.gitattributes
DELETED