gitdocs 0.4.8 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/lib/gitdocs.rb +5 -3
- data/lib/gitdocs/cli.rb +3 -2
- data/lib/gitdocs/configuration.rb +1 -1
- data/lib/gitdocs/manager.rb +5 -4
- data/lib/gitdocs/migration/006_add_web_port_to_config.rb +9 -0
- data/lib/gitdocs/public/js/app.js +8 -19
- data/lib/gitdocs/public/js/settings.js +25 -0
- data/lib/gitdocs/runner.rb +3 -2
- data/lib/gitdocs/server.rb +19 -3
- data/lib/gitdocs/version.rb +1 -1
- data/lib/gitdocs/views/dir.haml +6 -6
- data/lib/gitdocs/views/settings.haml +12 -6
- data/test/test_helper.rb +1 -1
- metadata +3 -1
data/CHANGELOG
CHANGED
data/lib/gitdocs.rb
CHANGED
@@ -18,10 +18,12 @@ module Gitdocs
|
|
18
18
|
|
19
19
|
DEBUG = ENV['DEBUG']
|
20
20
|
|
21
|
-
|
21
|
+
# Gitdocs.start(:config_root => "...", :debug => true)
|
22
|
+
def self.start(options={}, &blk)
|
23
|
+
options = { :debug => DEBUG, :config_root => nil }.merge(options)
|
22
24
|
@manager.stop if @manager
|
23
|
-
@manager = Manager.new(config_root, debug, &blk)
|
24
|
-
@manager.start
|
25
|
+
@manager = Manager.new(options[:config_root], options[:debug], &blk)
|
26
|
+
@manager.start(options[:port])
|
25
27
|
end
|
26
28
|
|
27
29
|
def self.restart
|
data/lib/gitdocs/cli.rb
CHANGED
@@ -8,13 +8,14 @@ module Gitdocs
|
|
8
8
|
|
9
9
|
desc "start", "Starts a daemonized gitdocs process"
|
10
10
|
method_option :debug, :type => :boolean, :aliases => "-D"
|
11
|
+
method_option :port, :type => :string, :aliases => "-p"
|
11
12
|
def start
|
12
13
|
if self.stopped? && !options[:debug]
|
13
|
-
self.runner.execute { Gitdocs.start }
|
14
|
+
self.runner.execute { Gitdocs.start(:port => options[:port]) }
|
14
15
|
self.running? ? say("Started gitdocs", :green) : say("Failed to start gitdocs", :red)
|
15
16
|
elsif self.stopped? && options[:debug]
|
16
17
|
say "Starting in debug mode", :yellow
|
17
|
-
Gitdocs.start(
|
18
|
+
Gitdocs.start(:debug => true, :port => options[:port])
|
18
19
|
else # already running
|
19
20
|
say "Gitdocs is already running, please use restart", :red
|
20
21
|
end
|
data/lib/gitdocs/manager.rb
CHANGED
@@ -23,7 +23,7 @@ module Gitdocs
|
|
23
23
|
results
|
24
24
|
end
|
25
25
|
|
26
|
-
def start
|
26
|
+
def start(web_port=nil)
|
27
27
|
self.log "Starting Gitdocs v#{VERSION}..."
|
28
28
|
self.log "Using configuration root: '#{self.config.config_root}'"
|
29
29
|
self.log "Shares: #{config.shares.map(&:inspect).join(", ")}"
|
@@ -41,12 +41,13 @@ module Gitdocs
|
|
41
41
|
@runners.each(&:run)
|
42
42
|
# Start the web front-end
|
43
43
|
if self.config.global.start_web_frontend
|
44
|
-
|
44
|
+
web_port ||= self.config.global.web_frontend_port
|
45
|
+
Server.new(self, *@runners).start(web_port.to_i)
|
45
46
|
EM.defer( proc {
|
46
47
|
i = 0
|
47
48
|
web_started = false
|
48
49
|
begin
|
49
|
-
TCPSocket.open('127.0.0.1',
|
50
|
+
TCPSocket.open('127.0.0.1', web_port.to_i).close
|
50
51
|
web_started = true
|
51
52
|
rescue Errno::ECONNREFUSED
|
52
53
|
self.log "Retrying server loop..."
|
@@ -54,7 +55,7 @@ module Gitdocs
|
|
54
55
|
i += 1
|
55
56
|
retry if i <= 20
|
56
57
|
end
|
57
|
-
system("open http://localhost
|
58
|
+
system("open http://localhost:#{web_port}/") if !retrying && self.config.global.load_browser_on_startup && web_started
|
58
59
|
}, proc {
|
59
60
|
self.log "Web server running!"
|
60
61
|
})
|
@@ -34,24 +34,14 @@ GitDocs = {
|
|
34
34
|
var extractor = function(e) { return $(e).data('val') || $(e).text() }
|
35
35
|
$("table#fileListing").tablesorter({ textExtraction : extractor, sortList: [[0,0]] });
|
36
36
|
},
|
37
|
-
//
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
success: function() {
|
46
|
-
$('.content div.alert-message').remove();
|
47
|
-
var el = $('.content').prepend('<div class="alert-message success"><a class="close" href="#">×</a>' +
|
48
|
-
'<p><strong>Settings saved!</strong> Gitdocs has been restarted with your new settings.</p>' +
|
49
|
-
'</div>');
|
50
|
-
$('div.alert-message').alert();
|
51
|
-
}
|
52
|
-
});
|
53
|
-
return false;
|
54
|
-
});
|
37
|
+
// Displays a closeable alert within the content pane
|
38
|
+
// Gitdocs.showAlert('This is the message', 'success')
|
39
|
+
showAlert : function(body, result) {
|
40
|
+
if (result == null) result = 'info';
|
41
|
+
$('.content div.alert-message').remove();
|
42
|
+
var el = $('.content').prepend('<div class="alert-message ' + result +
|
43
|
+
'"><a class="close" href="#">×</a>' + body + '</div>');
|
44
|
+
$('div.alert-message').alert();
|
55
45
|
}
|
56
46
|
};
|
57
47
|
|
@@ -59,7 +49,6 @@ $(document).ready(function() {
|
|
59
49
|
GitDocs.linkBreadcrumbs();
|
60
50
|
GitDocs.fillDirMeta();
|
61
51
|
StringFormatter.autoLink();
|
62
|
-
GitDocs.observeSettingsForm();
|
63
52
|
});
|
64
53
|
|
65
54
|
// Redirect to edit page for new file when new file form is submitted
|
@@ -0,0 +1,25 @@
|
|
1
|
+
GitDocs.settings = {
|
2
|
+
// To make the settings form ajax-y
|
3
|
+
observeSettingsForm : function() {
|
4
|
+
$('#settings').submit(function(e) {
|
5
|
+
e.preventDefault();
|
6
|
+
$.ajax({
|
7
|
+
type: 'POST', url: this.action, data: $(this).serialize(),
|
8
|
+
success: function() {
|
9
|
+
GitDocs.showAlert('<p><strong>Settings saved!</strong> Gitdocs has been restarted with your new settings.</p>', 'success')
|
10
|
+
}
|
11
|
+
});
|
12
|
+
return false;
|
13
|
+
});
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
$(document).ready(function() {
|
18
|
+
GitDocs.settings.observeSettingsForm();
|
19
|
+
});
|
20
|
+
|
21
|
+
// Handle delete for settings form
|
22
|
+
$('input.remove_share').live('click', function(e){
|
23
|
+
$(this).siblings("input[type=hidden]").val("true")
|
24
|
+
$(this).parents("form").submit()
|
25
|
+
});
|
data/lib/gitdocs/runner.rb
CHANGED
@@ -21,7 +21,8 @@ module Gitdocs
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def run
|
24
|
-
return false unless self.valid?
|
24
|
+
return false unless self.valid?
|
25
|
+
|
25
26
|
@show_notifications = @share.notification
|
26
27
|
@current_remote = @share.remote_name
|
27
28
|
@current_branch = @share.branch_name
|
@@ -159,7 +160,7 @@ module Gitdocs
|
|
159
160
|
|
160
161
|
def valid?
|
161
162
|
out, status = sh_with_code "git status"
|
162
|
-
status.success?
|
163
|
+
@root.present? && status.success?
|
163
164
|
end
|
164
165
|
|
165
166
|
def warn(title, msg)
|
data/lib/gitdocs/server.rb
CHANGED
@@ -18,6 +18,7 @@ module Gitdocs
|
|
18
18
|
Thin::Logging.debug = @manager.debug
|
19
19
|
Thin::Server.start('127.0.0.1', port) do
|
20
20
|
use Rack::Static, :urls => ['/css', '/js', '/img', '/doc'], :root => File.expand_path("../public", __FILE__)
|
21
|
+
use Rack::MethodOverride
|
21
22
|
run Renee {
|
22
23
|
if request.path_info == '/'
|
23
24
|
render! "home", :layout => 'app', :locals => {:conf => manager.config, :nav_state => "home" }
|
@@ -31,7 +32,10 @@ module Gitdocs
|
|
31
32
|
if remote_branch = share.delete('remote_branch')
|
32
33
|
share['remote_name'], share['branch_name'] = remote_branch.split('/', 2)
|
33
34
|
end
|
34
|
-
|
35
|
+
# Update paths
|
36
|
+
if share['path'] && !share['path'].empty?
|
37
|
+
shares[Integer(idx)].update_attributes(share)
|
38
|
+
end
|
35
39
|
end
|
36
40
|
EM.add_timer(0.1) { manager.restart }
|
37
41
|
redirect! '/settings'
|
@@ -42,8 +46,20 @@ module Gitdocs
|
|
42
46
|
render! "search", :layout => 'app', :locals => {:conf => manager.config, :results => manager.search(request.GET['q']), :nav_state => nil}
|
43
47
|
end
|
44
48
|
|
45
|
-
path('shares')
|
46
|
-
|
49
|
+
path('shares') do
|
50
|
+
post do
|
51
|
+
Configuration::Share.create
|
52
|
+
redirect! '/settings'
|
53
|
+
end
|
54
|
+
|
55
|
+
var(:int) do |id|
|
56
|
+
delete do
|
57
|
+
share = manager.config.shares.find { |s| s.id == id }
|
58
|
+
halt 404 if share.nil?
|
59
|
+
share.destroy
|
60
|
+
redirect! '/settings'
|
61
|
+
end
|
62
|
+
end
|
47
63
|
end
|
48
64
|
|
49
65
|
var :int do |idx|
|
data/lib/gitdocs/version.rb
CHANGED
data/lib/gitdocs/views/dir.haml
CHANGED
@@ -26,13 +26,13 @@
|
|
26
26
|
%p No files were found in this directory.
|
27
27
|
|
28
28
|
.row
|
29
|
-
.span6
|
30
|
-
%form.add
|
31
|
-
%p Add a file in this directory
|
32
|
-
%input{:type => 'text', :name => "path", :class => "edit" }
|
33
|
-
%input{:type => 'submit', :value => "New file", :class => "btn secondary" }
|
34
29
|
.span6
|
35
30
|
%form.upload{ :method => "post", :enctype => "multipart/form-data", :action => "/#{idx}#{request.path_info}?mode=upload" }
|
36
|
-
%p Upload
|
31
|
+
%p Upload file to this directory
|
37
32
|
%input{:type => 'file', :value => "Select a file", :name => "file", :class => "uploader" }
|
38
33
|
%input{:type => 'submit', :value => "Upload file", :class => "btn secondary" }
|
34
|
+
.span6
|
35
|
+
%form.add
|
36
|
+
%p Add new file in this directory
|
37
|
+
%input{:type => 'text', :name => "path", :class => "edit", :placeholder => "somefile.md" }
|
38
|
+
%input{:type => 'submit', :value => "New file", :class => "btn secondary" }
|
@@ -1,11 +1,17 @@
|
|
1
1
|
- @title = "Settings"
|
2
|
+
%script{ :src => "/js/settings.js", :type => "text/javascript", :charset => "utf-8" }
|
2
3
|
|
3
4
|
%form#settings{:method => 'POST', :action => '/settings'}
|
4
5
|
%h2 Gitdocs
|
5
6
|
#config.field.config
|
6
|
-
%
|
7
|
-
|
8
|
-
|
7
|
+
%dl
|
8
|
+
%dt Web Frontend Port
|
9
|
+
%dd
|
10
|
+
%input{:type =>'input', :name=>"config[web_frontend_port]", :value => conf.global.web_frontend_port }
|
11
|
+
%p
|
12
|
+
%input{:type =>'hidden', :value => '0', :name=>"config[load_browser_on_startup]"}
|
13
|
+
%input{:type =>'checkbox', :value => '1', :name=>"config[load_browser_on_startup]", :checked => conf.global.load_browser_on_startup ? 'checked' : nil}
|
14
|
+
%span Open browser on startup?
|
9
15
|
|
10
16
|
%h2 Shares
|
11
17
|
- conf.shares.each_with_index do |share, idx|
|
@@ -41,9 +47,9 @@
|
|
41
47
|
%input{:type =>'hidden', :value => '0', :name=>"share[#{idx}][notification]"}
|
42
48
|
%input{:type =>'checkbox', :value => '1', :name=>"share[#{idx}][notification]", :checked => share.notification ? 'checked' : nil}
|
43
49
|
%span Notifications?
|
44
|
-
.delete
|
45
|
-
%
|
46
|
-
|
50
|
+
.delete
|
51
|
+
%a{ :href => "/shares/#{share.id}", :class => "btn remove_share danger", :"data-method" => "delete"}
|
52
|
+
Delete
|
47
53
|
|
48
54
|
%input{:value => 'Save', :type => 'submit', :class => "btn primary" }
|
49
55
|
%a{ :class => "btn secondary new-share", :href => "/shares", :"data-method" => "post" } Add Share
|
data/test/test_helper.rb
CHANGED
@@ -31,7 +31,7 @@ class MiniTest::Spec
|
|
31
31
|
end
|
32
32
|
begin
|
33
33
|
puts "RUNNING!"
|
34
|
-
Gitdocs.start(conf_path) do |conf|
|
34
|
+
Gitdocs.start(:config_path => conf_path) do |conf|
|
35
35
|
conf.global.update_attributes(:load_browser_on_startup => false, :start_web_frontend => false)
|
36
36
|
conf.add_path(path, :polling_interval => 0.1, :notification => false)
|
37
37
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gitdocs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.9
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Josh Hull
|
@@ -262,6 +262,7 @@ files:
|
|
262
262
|
- lib/gitdocs/migration/003_create_configs.rb
|
263
263
|
- lib/gitdocs/migration/004_add_index_for_path.rb
|
264
264
|
- lib/gitdocs/migration/005_add_start_web_frontend.rb
|
265
|
+
- lib/gitdocs/migration/006_add_web_port_to_config.rb
|
265
266
|
- lib/gitdocs/public/css/app.css
|
266
267
|
- lib/gitdocs/public/css/bootstrap.css
|
267
268
|
- lib/gitdocs/public/css/coderay.css
|
@@ -308,6 +309,7 @@ files:
|
|
308
309
|
- lib/gitdocs/public/js/jquery.js
|
309
310
|
- lib/gitdocs/public/js/jquery.tablesorter.js
|
310
311
|
- lib/gitdocs/public/js/search.js
|
312
|
+
- lib/gitdocs/public/js/settings.js
|
311
313
|
- lib/gitdocs/public/js/util.js
|
312
314
|
- lib/gitdocs/rendering.rb
|
313
315
|
- lib/gitdocs/runner.rb
|