lenary-ginatra 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +2 -0
- data/.gitignore +13 -0
- data/.gitmodules +3 -0
- data/README.md +127 -0
- data/Rakefile +86 -0
- data/TODO.md +10 -0
- data/VERSION +1 -0
- data/bin/ginatra +60 -0
- data/bin/ginatra-daemon +81 -0
- data/bin/ginatra-directory +60 -0
- data/bin/ginatra-server +28 -0
- data/config.ru +7 -0
- data/features/pages.feature +33 -0
- data/features/step_definitions/page_steps.rb +36 -0
- data/features/support/env.rb +12 -0
- data/ginatra.gemspec +120 -0
- data/lib/ginatra.rb +185 -0
- data/lib/ginatra/config.rb +55 -0
- data/lib/ginatra/helpers.rb +112 -0
- data/lib/ginatra/repo.rb +50 -0
- data/lib/ginatra/repo_list.rb +53 -0
- data/lib/sinatra/partials.rb +17 -0
- data/public/favicon.ico +0 -0
- data/rackup.ru +7 -0
- data/repos/README.md +8 -0
- data/spec/repo_list_spec.rb +22 -0
- data/spec/repo_spec.rb +58 -0
- data/spec/spec_helper.rb +30 -0
- data/vendor/vegas/History.txt +18 -0
- data/vendor/vegas/LICENSE +22 -0
- data/vendor/vegas/Manifest.txt +5 -0
- data/vendor/vegas/README.rdoc +45 -0
- data/vendor/vegas/Rakefile +32 -0
- data/vendor/vegas/lib/vegas.rb +16 -0
- data/vendor/vegas/lib/vegas/runner.rb +270 -0
- data/vendor/vegas/test/test_app/bin/test_app +9 -0
- data/vendor/vegas/test/test_app/test_app.rb +10 -0
- data/vendor/vegas/test/test_apps.rb +22 -0
- data/vendor/vegas/test/test_helper.rb +59 -0
- data/vendor/vegas/test/test_vegas_runner.rb +8 -0
- data/vendor/vegas/vegas.gemspec +45 -0
- data/views/_actor_box.erb +13 -0
- data/views/_commit_info_box.erb +27 -0
- data/views/_header.erb +6 -0
- data/views/_tree_part.erb +11 -0
- data/views/atom.builder +32 -0
- data/views/blob.erb +9 -0
- data/views/commit.erb +20 -0
- data/views/index.erb +12 -0
- data/views/layout.erb +35 -0
- data/views/log.erb +64 -0
- data/views/tree.erb +24 -0
- metadata +158 -0
data/.gitattributes
ADDED
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/README.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
Ginatra
|
2
|
+
=======
|
3
|
+
|
4
|
+
This project is to make a clone of gitweb in Ruby and Sinatra. It serves git
|
5
|
+
repositories out of a set of specified directories using an array of glob-based
|
6
|
+
paths. I have plans to make it function just as gitweb does, including leeching
|
7
|
+
config files and suchlike.
|
8
|
+
|
9
|
+
Updating to Multiple directory repositories:
|
10
|
+
============================================
|
11
|
+
|
12
|
+
- Remove any bare cloned repositories from `./repos/`
|
13
|
+
- Execute the following: `rake setup:repo` which creates a non-bare test repo in
|
14
|
+
`./repos/`
|
15
|
+
|
16
|
+
Simple eh?
|
17
|
+
|
18
|
+
Installation
|
19
|
+
------------
|
20
|
+
|
21
|
+
You should be using Git 1.6.3 or later just to be sure that it all works:
|
22
|
+
|
23
|
+
$ git --version
|
24
|
+
git version 1.6.3
|
25
|
+
|
26
|
+
You'll need a few gems just to serve git repositories, for page caching, syntax highlighting & a sinatra daemon runner:
|
27
|
+
|
28
|
+
$ (sudo) gem install grit kematzy-sinatra-cache coderay vegas
|
29
|
+
|
30
|
+
To run the test suite, you also need:
|
31
|
+
|
32
|
+
$ (sudo) gem install rspec webrat rack-test cucumber
|
33
|
+
|
34
|
+
To do both these steps more quickly, run the following rake tasks:
|
35
|
+
|
36
|
+
$ rake setup:gems
|
37
|
+
$ rake setup:test
|
38
|
+
|
39
|
+
Then clone this repository:
|
40
|
+
|
41
|
+
$ git clone git://github.com/lenary/ginatra.git
|
42
|
+
|
43
|
+
You'll also need to (`--bare`) clone `atmos/hancock-client` into the repos
|
44
|
+
directory and call it test: (don't ask, it was just a repo i chose at random)
|
45
|
+
|
46
|
+
$ cd repos && git clone --bare git://github.com/atmos/hancock-client.git test.git
|
47
|
+
|
48
|
+
This can be done much quicker by doing the following rake task
|
49
|
+
|
50
|
+
$ rake setup:repo
|
51
|
+
|
52
|
+
Usage
|
53
|
+
-----
|
54
|
+
|
55
|
+
If you're just using it in development, use the following to run Ginatra:
|
56
|
+
|
57
|
+
$ ruby ginatra.rb
|
58
|
+
|
59
|
+
Ginatra also runs on thin. **BEWARE:** There are issues running Ginatra on
|
60
|
+
Passenger. We discourage Ginatra's use on Passenger until we can make it stable.
|
61
|
+
|
62
|
+
I have made a rake task so that you can easily add repositories to Ginatra. Use
|
63
|
+
the following to add repositories to Ginatra, without fear of getting it wrong:
|
64
|
+
|
65
|
+
$ rake add repo='git://github.com/lenary/ginatra.git'
|
66
|
+
$ rake add repo='git://github.com/mojombo/grit.git' name='fun'
|
67
|
+
|
68
|
+
Authors & Thanks
|
69
|
+
----------------
|
70
|
+
|
71
|
+
**Authors:**
|
72
|
+
|
73
|
+
- Samuel Elliott (lenary)
|
74
|
+
- Ryan Bigg (radar)
|
75
|
+
|
76
|
+
**Thanks**
|
77
|
+
|
78
|
+
- tekkub - For help with Grit
|
79
|
+
- schacon - For help with Grit
|
80
|
+
- cirwin - For moral support and design help
|
81
|
+
- irc://irc.freenode.net/git - for any other problems I had
|
82
|
+
- Picol Project (http://picol.org) - for the icons
|
83
|
+
- sr - For help with a large sinatra error
|
84
|
+
- raggi - For a refactor and several feature suggestions
|
85
|
+
|
86
|
+
Screenshots
|
87
|
+
-----------
|
88
|
+
|
89
|
+
**Index**
|
90
|
+
|
91
|
+
![Ginatra Index](http://lenary-uploads.appspot.com/img/i?id=ag5sZW5hcnktdXBsb2Fkc3IMCxIFSW1hZ2UYox8M&w=500&h=500 "Ginatra Index")
|
92
|
+
|
93
|
+
**Log**
|
94
|
+
|
95
|
+
![Ginatra Log](http://lenary-uploads.appspot.com/img/i?id=ag5sZW5hcnktdXBsb2Fkc3IMCxIFSW1hZ2UYvRcM&w=500&h=500 "Ginatra Log")
|
96
|
+
|
97
|
+
**Commit**
|
98
|
+
|
99
|
+
![Ginatra Commit](http://lenary-uploads.appspot.com/img/i?id=ag5sZW5hcnktdXBsb2Fkc3IMCxIFSW1hZ2UYvBcM&w=500&h=500 "Ginatra Commit")
|
100
|
+
|
101
|
+
**Tree**
|
102
|
+
|
103
|
+
![Ginatra Tree](http://lenary-uploads.appspot.com/img/i?id=ag5sZW5hcnktdXBsb2Fkc3IMCxIFSW1hZ2UYpB8M&w=500&h=500 "Ginatra Tree")
|
104
|
+
|
105
|
+
Licence
|
106
|
+
-------
|
107
|
+
|
108
|
+
The MIT License
|
109
|
+
|
110
|
+
Copyright (c) 2009 Samuel Elliott
|
111
|
+
|
112
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
113
|
+
this software and associated documentation files (the "Software"), to deal in
|
114
|
+
the Software without restriction, including without limitation the rights to
|
115
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
116
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
117
|
+
subject to the following conditions:
|
118
|
+
|
119
|
+
The above copyright notice and this permission notice shall be included in all
|
120
|
+
copies or substantial portions of the Software.
|
121
|
+
|
122
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
123
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
124
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
125
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
126
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
127
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'cucumber/rake/task'
|
3
|
+
require 'spec/rake/spectask'
|
4
|
+
|
5
|
+
current_path = File.expand_path(File.dirname(__FILE__))
|
6
|
+
require "#{current_path}/lib/ginatra"
|
7
|
+
|
8
|
+
task :default => ['rake:spec', 'rake:features']
|
9
|
+
|
10
|
+
desc "Runs the Cucumber Feature Suite"
|
11
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
12
|
+
t.cucumber_opts = "--format pretty"
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :features do
|
16
|
+
|
17
|
+
desc "Runs the `@current` feature(s) or scenario(s)"
|
18
|
+
Cucumber::Rake::Task.new(:current) do |c|
|
19
|
+
c.cucumber_opts = "--format pretty -t current"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Runs the RSpec Test Suite"
|
25
|
+
Spec::Rake::SpecTask.new(:spec) do |r|
|
26
|
+
r.spec_files = FileList['spec/*_spec.rb']
|
27
|
+
r.spec_opts = ['--color']
|
28
|
+
end
|
29
|
+
|
30
|
+
namespace :spec do
|
31
|
+
|
32
|
+
desc "RSpec Test Suite with pretty output"
|
33
|
+
Spec::Rake::SpecTask.new(:long) do |r|
|
34
|
+
r.spec_files = FileList['spec/*_spec.rb']
|
35
|
+
r.spec_opts = ['--color', '--format specdoc']
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "RSpec Test Suite with html output"
|
39
|
+
Spec::Rake::SpecTask.new(:html) do |r|
|
40
|
+
r.spec_files = FileList['spec/*_spec.rb']
|
41
|
+
r.spec_opts = ['--color', '--format html:spec/html_spec.html']
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
namespace :setup do
|
47
|
+
|
48
|
+
desc "Clones the Test Repository"
|
49
|
+
task :repo do |t|
|
50
|
+
FileUtils.cd(File.join(current_path, "repos")) do
|
51
|
+
puts `git clone git://github.com/atmos/hancock-client.git test`
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Installs the Required Gems"
|
56
|
+
task :gems do |t|
|
57
|
+
gems = %w(grit kematzy-sinatra-cache vegas)
|
58
|
+
puts %x(gem install #{gems.join(" ")})
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Installs the Test Gems"
|
62
|
+
task :test do |t|
|
63
|
+
gems = %w(rspec webrat rack-test cucumber)
|
64
|
+
puts %x(gem install #{gems.join(" ")})
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
begin
|
70
|
+
require 'jeweler'
|
71
|
+
Jeweler::Tasks.new do |gemspec|
|
72
|
+
gemspec.name = "ginatra"
|
73
|
+
gemspec.summary = "A Gitweb Clone in Sinatra and Grit"
|
74
|
+
gemspec.description = "Host your own git repository browser through the power of Sinatra and Grit"
|
75
|
+
gemspec.email = "sam@lenary.co.uk"
|
76
|
+
gemspec.homepage = "http://lenary.github.com/ginatra"
|
77
|
+
gemspec.authors = ["Sam Elliott", "Ryan Bigg"]
|
78
|
+
gemspec.add_dependency('sinatra', '>=0.9.4')
|
79
|
+
gemspec.add_dependency('grit', '>=1.1.1')
|
80
|
+
gemspec.add_dependency('coderay', '>=0.8.0')
|
81
|
+
gemspec.files.include 'vendor/**/*'
|
82
|
+
end
|
83
|
+
rescue LoadError
|
84
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
85
|
+
end
|
86
|
+
|
data/TODO.md
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.2
|
data/bin/ginatra
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
current_path = File.expand_path(File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require "#{current_path}/../lib/ginatra"
|
6
|
+
|
7
|
+
module Ginatra::Executable
|
8
|
+
HELP = <<HELP
|
9
|
+
Usage: ginatra [ version | server <options> <command> |
|
10
|
+
daemon <command> | directory <command> <args> ]
|
11
|
+
|
12
|
+
Ginatra Commands:
|
13
|
+
version - Pretty Self explanatory. Print version number and exit
|
14
|
+
|
15
|
+
Ginatra Server Commands:
|
16
|
+
start - Start the Ginatra HTTP Server.
|
17
|
+
stop - Stop the Ginatra Server.
|
18
|
+
status - How's your Ginatra Server holding up?
|
19
|
+
|
20
|
+
Ginatra Daemon Commands:
|
21
|
+
start - Starts the Git Daemon servimg Ginatra's Repositories
|
22
|
+
stop - Stops the Git Daemon
|
23
|
+
restart - Restarts the Git Daemon
|
24
|
+
status - Is the Git Daemon on or off?
|
25
|
+
|
26
|
+
|
27
|
+
Ginatra Directory Commands:
|
28
|
+
add - Adds the <globs> to the array of dirs that Ginatra
|
29
|
+
looks in for repositories.
|
30
|
+
remove - Removes the <globs> from the aforementioned array.
|
31
|
+
list - Lists the globs Ginatra looks in for repositories
|
32
|
+
|
33
|
+
HELP
|
34
|
+
|
35
|
+
@current_path = File.expand_path(File.dirname(__FILE__))
|
36
|
+
|
37
|
+
def self.daemon(*args)
|
38
|
+
system("#{@current_path}/ginatra-daemon #{args.join(" ")}")
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.directory(*args)
|
42
|
+
system("#{@current_path}/ginatra-directory #{args.join(" ")}")
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.server(*args)
|
46
|
+
system("#{@current_path}/ginatra-server #{args.join(" ")}")
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.version(*args)
|
50
|
+
puts Ginatra::VERSION
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
command, *args = ARGV[0], ARGV[1..-1]
|
55
|
+
if command !~ /^(version|daemon|directory|server)$/
|
56
|
+
puts Ginatra::Executable::HELP
|
57
|
+
exit
|
58
|
+
end
|
59
|
+
Ginatra::Executable.send(command, *args)
|
60
|
+
|
data/bin/ginatra-daemon
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
current_path = File.expand_path(File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require "#{current_path}/../lib/ginatra"
|
6
|
+
require "logger"
|
7
|
+
|
8
|
+
def logger
|
9
|
+
return @logger if @logger
|
10
|
+
@logger = Logger.new(STDOUT)
|
11
|
+
@logger.level = Logger::INFO
|
12
|
+
@logger.formatter = Proc.new {|s, t, n, msg| "[#{t}] #{msg}\n"}
|
13
|
+
@logger
|
14
|
+
end
|
15
|
+
|
16
|
+
module Ginatra::Daemon
|
17
|
+
|
18
|
+
SYMLINK_DIR = File.expand_path('~/.ginatra/symlinks')
|
19
|
+
PID_FILE = File.expand_path('~/.ginatra/daemon.pid')
|
20
|
+
HELP = <<HELP
|
21
|
+
Usage: ginatra-daemon [ start | stop | restart | status ]
|
22
|
+
|
23
|
+
Commands:
|
24
|
+
start - Starts the Git Daemon servimg Ginatra's Repositories
|
25
|
+
stop - Stops the Git Daemon
|
26
|
+
restart - Restarts the Git Daemon
|
27
|
+
status - Is the Git Daemon on or off?
|
28
|
+
|
29
|
+
HELP
|
30
|
+
|
31
|
+
def self.start
|
32
|
+
# Create Symlinks
|
33
|
+
FileUtils.mkdir_p(SYMLINK_DIR)
|
34
|
+
logger.info "Creating Symlinks"
|
35
|
+
dirs = Ginatra::Config.git_dirs.map{|path| Dir.glob(path)}.flatten
|
36
|
+
FileUtils.ln_sf(dirs, SYMLINK_DIR)
|
37
|
+
# Start Process
|
38
|
+
if File.exists?(PID_FILE)
|
39
|
+
logger.warn "Ginatra Daemon running at pid:#{File.new(PID_FILE).read}"
|
40
|
+
else
|
41
|
+
logger.info "Starting ginatra-daemon"
|
42
|
+
Kernel.fork do
|
43
|
+
system "git daemon --reuseaddr --base-path=#{SYMLINK_DIR} --pid-file=#{PID_FILE} #{SYMLINK_DIR}/*"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.stop
|
49
|
+
# Stop Process
|
50
|
+
pid = File.new(PID_FILE).read.to_i
|
51
|
+
logger.warn "Sending INT to #{pid}"
|
52
|
+
FileUtils.rm(PID_FILE)
|
53
|
+
Process.kill(:INT, pid)
|
54
|
+
# Remove Symlinks
|
55
|
+
links = Dir.glob("#{SYMLINK_DIR}/*")
|
56
|
+
logger.warn "Removing Symlinks"
|
57
|
+
FileUtils.rm(links)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.restart
|
61
|
+
self.stop
|
62
|
+
self.start
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.status
|
66
|
+
if File.exists?(PID_FILE)
|
67
|
+
logger.info "Ginatra Daemon running at pid:#{File.new(PID_FILE).read}"
|
68
|
+
else
|
69
|
+
logger.info "Ginatra Daemon not running"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
command = ARGV[0]
|
76
|
+
if command !~ /^(stop|status|start|restart)$/
|
77
|
+
puts Ginatra::Daemon::HELP
|
78
|
+
exit
|
79
|
+
end
|
80
|
+
Ginatra::Daemon.send(command)
|
81
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
current_path = File.expand_path(File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require "#{current_path}/../lib/ginatra"
|
6
|
+
require "logger"
|
7
|
+
|
8
|
+
def logger
|
9
|
+
return @logger if @logger
|
10
|
+
@logger = Logger.new(STDOUT)
|
11
|
+
@logger.level = Logger::INFO
|
12
|
+
@logger.formatter = Proc.new {|s, t, n, msg| "[#{t}] #{msg}\n"}
|
13
|
+
@logger
|
14
|
+
end
|
15
|
+
|
16
|
+
module Ginatra::Directory
|
17
|
+
|
18
|
+
HELP = <<HELP
|
19
|
+
Usage: ginatra-directory [ list | add <globs> | remove <globs> ]
|
20
|
+
|
21
|
+
Commands:
|
22
|
+
add - Adds the <globs> to the array of dirs that Ginatra
|
23
|
+
looks in for repositories.
|
24
|
+
remove - Removes the <globs> from the aforementioned array.
|
25
|
+
list - Lists the globs Ginatra looks in for repositories
|
26
|
+
|
27
|
+
HELP
|
28
|
+
|
29
|
+
def self.add(globs)
|
30
|
+
Ginatra::Config.load!
|
31
|
+
Ginatra::Config[:git_dirs] << globs
|
32
|
+
Ginatra::Config[:git_dirs].flatten
|
33
|
+
logger.info "Added #{globs.join(" ")} to your config"
|
34
|
+
Ginatra::Config.dump!
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.remove(globs)
|
38
|
+
Ginatra::Config.load!
|
39
|
+
globs.each do |glob|
|
40
|
+
Ginatra::Config[:git_dirs].delete(glob)
|
41
|
+
end
|
42
|
+
logger.info "Removed #{globs.join(" ")} from your config"
|
43
|
+
Ginatra::Config.dump!
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.list(*args)
|
47
|
+
Ginatra::Config.load!
|
48
|
+
puts "Directories Ginatra will look for repos in:"
|
49
|
+
puts Ginatra::Config[:git_dirs].map{|r| " - #{r}"}.join("\n")
|
50
|
+
puts ""
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
command, *args = ARGV[0], ARGV[1..-1]
|
55
|
+
if command !~ /^(add|remove|list)$/
|
56
|
+
puts Ginatra::Directory::HELP
|
57
|
+
exit
|
58
|
+
end
|
59
|
+
Ginatra::Directory.send(command, *args)
|
60
|
+
|