bananajour 2.2.2 → 2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.md +34 -5
- data/bin/bananajour +15 -4
- data/lib/bananajour/bonjour/advertiser.rb +2 -2
- data/lib/bananajour/bonjour/browser.rb +18 -22
- data/lib/bananajour/commands.rb +4 -3
- data/lib/bananajour/gem_dependencies.rb +0 -2
- data/lib/bananajour/version.rb +1 -1
- data/lib/bananajour.rb +5 -0
- data/sinatra/app.rb +7 -7
- data/sinatra/views/home.haml +1 -1
- metadata +2 -23
- data/sinatra/lib/browsers.rb +0 -2
data/Readme.md
CHANGED
@@ -28,7 +28,7 @@ Install it from [gemcutter](http://gemcutter.org/) via gems:
|
|
28
28
|
Start it up:
|
29
29
|
|
30
30
|
bananajour
|
31
|
-
|
31
|
+
|
32
32
|
Go into an existing project and add it to bananajour:
|
33
33
|
|
34
34
|
cd ~/code/myproj
|
@@ -47,14 +47,43 @@ For a list of all the commands:
|
|
47
47
|
|
48
48
|
bananajour help
|
49
49
|
|
50
|
+
Optional configuration: you can override the hostname by setting a global git config option like so:
|
51
|
+
|
52
|
+
git config --global bananajour.hostname foobar
|
53
|
+
|
54
|
+
If you set this setting, then bananajour will assume that you know precisely what you're doing, it will not append .local, it will not check this hostname is valid, or do anything to it. If you set this, then you're on your own.
|
55
|
+
|
56
|
+
Make sure you have these ports open on your firewall:
|
57
|
+
9417 - git - bigbananajour
|
58
|
+
9418 - git - bananajour
|
59
|
+
9331 - bananajour
|
60
|
+
9332 - bigbananajour
|
61
|
+
|
62
|
+
|
50
63
|
Linux support
|
51
64
|
-------------
|
52
65
|
|
53
|
-
To install the dnssd gem on
|
66
|
+
To install the dnssd gem on Linux you'll need [avahi](http://avahi.org/). For Ubunutu peeps this means:
|
67
|
+
|
68
|
+
sudo apt-get install libavahi-compat-libdnssd-dev libavahi-discover
|
69
|
+
|
70
|
+
You can debug whether or not Avahi can see Bananajour and git-daemon Bonjour statuses using the command 'avahi-browse'. This command can be found in the package 'avahi-utils'.
|
71
|
+
|
72
|
+
The following command will show you all of the Bonjour services running on your local network:
|
73
|
+
|
74
|
+
avahi-browse --all
|
75
|
+
|
76
|
+
If you kill bananajour with kill -9 it doesn't get a chance to unregister the Bonjour services, and when it is restarted it will die with DNSSD::AlreadyRegisteredError. Although not ideal, you can work around this my restarting avahi-daemon first.
|
77
|
+
|
78
|
+
You will also need to uncomment the following line in your /etc/avahi/avahi-daemon.conf.
|
79
|
+
|
80
|
+
domain-name=local
|
81
|
+
|
82
|
+
And then restart the Avahi service:
|
54
83
|
|
55
|
-
|
84
|
+
sudo service avahi-daemon restart
|
56
85
|
|
57
|
-
|
86
|
+
Note: You might have to restart the avahi-daemon sometimes if you are having problems seeing other bananajours.
|
58
87
|
|
59
88
|
Using with Ginatra
|
60
89
|
------------------
|
@@ -107,4 +136,4 @@ All directories and files are MIT Licensed.
|
|
107
136
|
|
108
137
|
Warning to all those who still believe secrecy will save their revenue stream
|
109
138
|
-----------------------------------------------------------------------------
|
110
|
-
Bananas were meant to be shared. There are no secret bananas.
|
139
|
+
Bananas were meant to be shared. There are no secret bananas.
|
data/bin/bananajour
CHANGED
@@ -9,13 +9,24 @@ Bananajour.setup! if !Bananajour.setup?
|
|
9
9
|
Bananajour.check_git!
|
10
10
|
Bananajour.check_git_config!
|
11
11
|
|
12
|
+
parent_process_pid = Process.pid
|
13
|
+
pids = []
|
14
|
+
at_exit do
|
15
|
+
if Process.pid == parent_process_pid
|
16
|
+
pids.each do |pid|
|
17
|
+
Process.kill("TERM", pid) rescue nil
|
18
|
+
sleep 0.2
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
12
23
|
case ARGV.first
|
13
24
|
|
14
25
|
when nil
|
15
|
-
Bananajour.serve_web!
|
16
|
-
Bananajour.serve_git!
|
17
|
-
Bananajour.advertise!
|
18
|
-
Process.
|
26
|
+
pids << Bananajour.serve_web!
|
27
|
+
pids << Bananajour.serve_git!
|
28
|
+
pids << Bananajour.advertise!
|
29
|
+
Process.waitall
|
19
30
|
|
20
31
|
when "add", "init"
|
21
32
|
repo = Bananajour.add!(ARGV[1] || File.expand_path("."))
|
@@ -15,7 +15,7 @@ class Bananajour::Bonjour::Advertiser
|
|
15
15
|
tr["uri"] = Bananajour.web_uri
|
16
16
|
tr["gravatar"] = Bananajour.gravatar
|
17
17
|
tr["version"] = Bananajour::VERSION
|
18
|
-
DNSSD.register("#{Bananajour.config.name}'s bananajour", "_http._tcp,_bananajour", nil, Bananajour.web_port, tr)
|
18
|
+
DNSSD.register("#{Bananajour.config.name}'s bananajour", "_http._tcp,_bananajour", nil, Bananajour.web_port, tr)
|
19
19
|
end
|
20
20
|
def register_repos
|
21
21
|
loop do
|
@@ -45,7 +45,7 @@ class Bananajour::Bonjour::Advertiser
|
|
45
45
|
tr["bjour-uri"] = Bananajour.web_uri
|
46
46
|
tr["bjour-gravatar"] = Bananajour.gravatar
|
47
47
|
tr["bjour-version"] = Bananajour::VERSION
|
48
|
-
service = DNSSD.register(new_repo.name, "_git._tcp,_bananajour", nil, 9418, tr)
|
48
|
+
service = DNSSD.register(new_repo.name, "_git._tcp,_bananajour", nil, 9418, tr)
|
49
49
|
service.class.instance_eval { attr_accessor(:repository) }
|
50
50
|
service.repository = new_repo
|
51
51
|
@services << service
|
@@ -20,41 +20,37 @@ class Bananajour::Bonjour::Browser
|
|
20
20
|
def initialize(service)
|
21
21
|
@service = service
|
22
22
|
@mutex = Mutex.new
|
23
|
-
@replies =
|
23
|
+
@replies = {}
|
24
24
|
watch!
|
25
25
|
end
|
26
26
|
def replies
|
27
|
-
@mutex.synchronize
|
28
|
-
@replies.clone
|
29
|
-
end
|
27
|
+
@mutex.synchronize { @replies.values }
|
30
28
|
end
|
31
29
|
private
|
32
30
|
def watch!
|
33
|
-
|
31
|
+
Thread.new(@service, @mutex, @replies) do |service, mutex, replies|
|
34
32
|
begin
|
35
|
-
|
36
|
-
|
33
|
+
DNSSD.browse!(service) do |reply|
|
34
|
+
Thread.new(reply, replies, mutex) do |reply, replies, mutex|
|
37
35
|
begin
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
DNSSD.resolve!(reply.name, reply.type, reply.domain) do |resolve_reply|
|
37
|
+
mutex.synchronize do
|
38
|
+
if reply.flags.add?
|
39
|
+
replies[reply.fullname] = resolve_reply
|
40
|
+
else
|
41
|
+
replies.delete(reply.fullname)
|
42
|
+
end
|
44
43
|
end
|
44
|
+
resolve_reply.service.stop unless resolve_reply.service.stopped?
|
45
45
|
end
|
46
|
-
rescue DNSSD::
|
47
|
-
|
48
|
-
ensure
|
49
|
-
rr.service.stop unless rr.service.stopped?
|
46
|
+
rescue DNSSD::BadParamError
|
47
|
+
# Ignore em
|
50
48
|
end
|
51
49
|
end
|
52
50
|
end
|
53
|
-
rescue DNSSD::
|
54
|
-
|
55
|
-
rescue Timeout::Error
|
56
|
-
# Do nothing
|
51
|
+
rescue DNSSD::BadParamError
|
52
|
+
# Ignore em
|
57
53
|
end
|
58
54
|
end
|
59
55
|
end
|
60
|
-
end
|
56
|
+
end
|
data/lib/bananajour/commands.rb
CHANGED
@@ -11,15 +11,16 @@ module Bananajour::Commands
|
|
11
11
|
abort(config_message["user.name", "My Name"]) if config.name.empty?
|
12
12
|
abort(config_message["user.email", "name@domain.com"]) if config.email.empty?
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
|
+
# Start sinatra app.
|
15
16
|
def serve_web!
|
17
|
+
puts "* Starting " + web_uri.foreground(:yellow)
|
16
18
|
fork { exec "/usr/bin/env ruby #{File.dirname(__FILE__)}/../../sinatra/app.rb -p #{web_port} -e production" }
|
17
|
-
puts "* Started " + web_uri.foreground(:yellow)
|
18
19
|
end
|
19
20
|
|
20
21
|
def serve_git!
|
22
|
+
puts "* Starting " + "#{git_uri}".foreground(:yellow)
|
21
23
|
fork { exec "git daemon --base-path=#{repositories_path} --export-all" }
|
22
|
-
puts "* Started " + "#{git_uri}".foreground(:yellow)
|
23
24
|
end
|
24
25
|
|
25
26
|
def advertise!
|
data/lib/bananajour/version.rb
CHANGED
data/lib/bananajour.rb
CHANGED
@@ -65,6 +65,11 @@ module Bananajour
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def host_name
|
68
|
+
hn = get_git_global_config("bananajour.hostname")
|
69
|
+
unless hn.nil? or hn.empty?
|
70
|
+
return hn
|
71
|
+
end
|
72
|
+
|
68
73
|
hn = Socket.gethostname
|
69
74
|
|
70
75
|
# if there is more than one period in the hostname then assume it's a FQDN
|
data/sinatra/app.rb
CHANGED
@@ -20,12 +20,10 @@ set :server, 'thin' # Things go weird with anything else - let's lock it down to
|
|
20
20
|
set :haml, {:format => :html5, :attr_wrapper => '"'}
|
21
21
|
set :logging, false
|
22
22
|
|
23
|
-
require "#{__DIR__}/lib/browsers" # to prevent reloading
|
24
23
|
require "#{__DIR__}/lib/mock_browsers" if Sinatra::Application.development?
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
24
|
+
|
25
|
+
set :bananajour_browser, Bananajour::Bonjour::BananajourBrowser.new
|
26
|
+
set :repository_browser, Bananajour::Bonjour::RepositoryBrowser.new
|
29
27
|
|
30
28
|
load "#{__DIR__}/lib/diff_helpers.rb"
|
31
29
|
helpers DiffHelpers
|
@@ -34,6 +32,8 @@ require "bananajour/helpers"
|
|
34
32
|
helpers Bananajour::GravatarHelpers, Bananajour::DateHelpers
|
35
33
|
|
36
34
|
helpers do
|
35
|
+
def bananajour_browser() options.bananajour_browser end
|
36
|
+
def repository_browser() options.repository_browser end
|
37
37
|
def json(body)
|
38
38
|
content_type "application/json"
|
39
39
|
params[:callback] ? "#{params[:callback]}(#{body});" : body
|
@@ -52,8 +52,8 @@ end
|
|
52
52
|
|
53
53
|
get "/" do
|
54
54
|
@my_repositories = Bananajour.repositories
|
55
|
-
@other_repos_by_name =
|
56
|
-
@people =
|
55
|
+
@other_repos_by_name = repository_browser.other_repositories.group_by {|r| r.name}
|
56
|
+
@people = bananajour_browser.other_bananajours
|
57
57
|
haml :home
|
58
58
|
end
|
59
59
|
|
data/sinatra/views/home.haml
CHANGED
@@ -237,7 +237,7 @@
|
|
237
237
|
&= commit.author
|
238
238
|
- else
|
239
239
|
%ul.network
|
240
|
-
- for repo in
|
240
|
+
- for repo in repository_browser.repositories_similar_to(repository)
|
241
241
|
%li.loading{'data-json-uri' => repo.json_uri}
|
242
242
|
%a.name{:href => "#{repo.person.uri}##{repo.html_id}"}= repo.person.name
|
243
243
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bananajour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: "2.6"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Lucas
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-23 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -72,26 +72,6 @@ dependencies:
|
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: 1.3.1
|
74
74
|
version:
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: rack
|
77
|
-
type: :runtime
|
78
|
-
version_requirement:
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - "="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: 1.0.0
|
84
|
-
version:
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
name: thin
|
87
|
-
type: :runtime
|
88
|
-
version_requirement:
|
89
|
-
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
requirements:
|
91
|
-
- - "="
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 1.0.0
|
94
|
-
version:
|
95
75
|
- !ruby/object:Gem::Dependency
|
96
76
|
name: haml
|
97
77
|
type: :runtime
|
@@ -139,7 +119,6 @@ files:
|
|
139
119
|
- lib/bananajour/version.rb
|
140
120
|
- lib/bananajour.rb
|
141
121
|
- sinatra/app.rb
|
142
|
-
- sinatra/lib/browsers.rb
|
143
122
|
- sinatra/lib/diff_helpers.rb
|
144
123
|
- sinatra/lib/mock_browsers.rb
|
145
124
|
- sinatra/public/jquery-1.3.2.min.js
|
data/sinatra/lib/browsers.rb
DELETED