gitdocs 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/README.md +1 -0
  2. data/gitdocs.gemspec +3 -0
  3. data/lib/gitdocs/cli.rb +2 -2
  4. data/lib/gitdocs/configuration.rb +25 -29
  5. data/lib/gitdocs/migration/001_create_shares.rb +13 -0
  6. data/lib/gitdocs/migration/002_add_remote_branch.rb +10 -0
  7. data/lib/gitdocs/public/css/app.css +48 -16
  8. data/lib/gitdocs/public/css/coderay.css +41 -0
  9. data/lib/gitdocs/public/css/tilt.css +81 -0
  10. data/lib/gitdocs/public/img/git_logo.png +0 -0
  11. data/lib/gitdocs/public/js/ace/ace-compat.js +1 -0
  12. data/lib/gitdocs/public/js/ace/ace-uncompressed.js +14202 -0
  13. data/lib/gitdocs/public/js/ace/ace.js +1 -0
  14. data/lib/gitdocs/public/js/ace/keybinding-emacs.js +1 -0
  15. data/lib/gitdocs/public/js/ace/keybinding-vim.js +1 -0
  16. data/lib/gitdocs/public/js/ace/mode-coffee.js +1 -0
  17. data/lib/gitdocs/public/js/ace/mode-css.js +1 -0
  18. data/lib/gitdocs/public/js/ace/mode-html.js +1 -0
  19. data/lib/gitdocs/public/js/ace/mode-javascript.js +1 -0
  20. data/lib/gitdocs/public/js/ace/mode-json.js +1 -0
  21. data/lib/gitdocs/public/js/ace/mode-lua.js +1 -0
  22. data/lib/gitdocs/public/js/ace/mode-markdown.js +1 -0
  23. data/lib/gitdocs/public/js/ace/mode-php.js +1 -0
  24. data/lib/gitdocs/public/js/ace/mode-python.js +1 -0
  25. data/lib/gitdocs/public/js/ace/mode-ruby.js +1 -0
  26. data/lib/gitdocs/public/js/ace/mode-scala.js +1 -0
  27. data/lib/gitdocs/public/js/ace/mode-scss.js +1 -0
  28. data/lib/gitdocs/public/js/ace/mode-sql.js +1 -0
  29. data/lib/gitdocs/public/js/ace/mode-svg.js +1 -0
  30. data/lib/gitdocs/public/js/ace/mode-textile.js +1 -0
  31. data/lib/gitdocs/public/js/ace/mode-xml.js +1 -0
  32. data/lib/gitdocs/public/js/ace/theme-tomorrow.js +1 -0
  33. data/lib/gitdocs/public/js/ace/theme-tomorrow_night.js +1 -0
  34. data/lib/gitdocs/public/js/ace/theme-tomorrow_night_blue.js +1 -0
  35. data/lib/gitdocs/public/js/ace/theme-twilight.js +1 -0
  36. data/lib/gitdocs/public/js/ace/theme-vibrant_ink.js +1 -0
  37. data/lib/gitdocs/public/js/ace/worker-coffee.js +7041 -0
  38. data/lib/gitdocs/public/js/ace/worker-css.js +9525 -0
  39. data/lib/gitdocs/public/js/ace/worker-javascript.js +9739 -0
  40. data/lib/gitdocs/public/js/app.js +26 -0
  41. data/lib/gitdocs/public/js/edit.js +30 -0
  42. data/lib/gitdocs/public/js/jquery.js +4 -0
  43. data/lib/gitdocs/public/js/util.js +17 -0
  44. data/lib/gitdocs/runner.rb +16 -9
  45. data/lib/gitdocs/server.rb +46 -8
  46. data/lib/gitdocs/version.rb +1 -1
  47. data/lib/gitdocs/views/app.haml +14 -0
  48. data/lib/gitdocs/views/dir.haml +14 -5
  49. data/lib/gitdocs/views/edit.haml +32 -0
  50. data/lib/gitdocs/views/file.haml +7 -7
  51. data/lib/gitdocs/views/home.haml +1 -1
  52. data/lib/gitdocs/views/settings.haml +34 -0
  53. data/lib/gitdocs.rb +5 -5
  54. data/test/configuration_test.rb +6 -6
  55. data/test/test_helper.rb +13 -6
  56. metadata +193 -122
data/README.md CHANGED
@@ -128,6 +128,7 @@ Gitdocs is a young project but we have big plans for it including:
128
128
  - Local-area peer-to-peer syncing, avoid 'polling' in cases where we can using a messaging protocol.
129
129
  - Click-to-share instant access granting file access to users using a local tunnel or other means.
130
130
  - Support for linux and windows platforms (coming soon), and maybe android and iOS as well?
131
+ - Indexing and full-text search for all documents in a repo
131
132
 
132
133
  ## Prior Projects
133
134
 
data/gitdocs.gemspec CHANGED
@@ -23,10 +23,13 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency 'renee', '~> 0.3.6'
24
24
  s.add_dependency 'redcarpet'
25
25
  s.add_dependency 'thor'
26
+ s.add_dependency 'coderay'
26
27
  s.add_dependency 'dante', '~> 0.0.4'
27
28
  s.add_dependency 'growl', '~> 1.0.3'
28
29
  s.add_dependency 'yajl-ruby'
29
30
  s.add_dependency 'haml'
31
+ s.add_dependency 'sqlite3', "~> 1.3.4"
32
+ s.add_dependency 'activerecord', "~> 3.1.0"
30
33
 
31
34
  s.add_development_dependency 'minitest', "~> 2.6.1"
32
35
  s.add_development_dependency 'rake'
data/lib/gitdocs/cli.rb CHANGED
@@ -64,7 +64,7 @@ module Gitdocs
64
64
  FileUtils.mkdir_p(File.dirname(path))
65
65
  system("git clone -q #{remote} #{path}") or raise "Unable to clone into #{path}"
66
66
  self.add(path)
67
- say "Created & added path #{path} to doc list"
67
+ say "Created #{path} path for gitdoc"
68
68
  end
69
69
 
70
70
  desc "status", "Retrieve gitdocs status"
@@ -72,7 +72,7 @@ module Gitdocs
72
72
  say "GitDoc v#{VERSION}"
73
73
  say "Running: #{self.running?}"
74
74
  say "Watching paths:"
75
- say self.config.paths.map { |p| " - #{p}" }.join("\n")
75
+ say self.config.shares.map { |s| " - #{s.path}" }.join("\n")
76
76
  end
77
77
 
78
78
  desc "config", "Configuration options for gitdocs"
@@ -1,3 +1,5 @@
1
+ require 'active_record'
2
+
1
3
  module Gitdocs
2
4
  class Configuration
3
5
  attr_reader :config_root
@@ -5,48 +7,42 @@ module Gitdocs
5
7
  def initialize(config_root = nil)
6
8
  @config_root = config_root || File.expand_path(".gitdocs", ENV["HOME"])
7
9
  FileUtils.mkdir_p(@config_root)
10
+ ActiveRecord::Base.establish_connection(
11
+ :adapter => 'sqlite3',
12
+ :database => ENV["TEST"] ? ':memory:' : File.join(@config_root, 'config.db')
13
+ )
14
+ ActiveRecord::Migrator.migrate(File.expand_path("../migration", __FILE__))
15
+ import_old_shares unless ENV["TEST"]
8
16
  end
9
17
 
10
- # @config.paths => ['my/path/1', 'my/path/2']
11
- def paths
12
- self.read_file('paths').split("\n")
18
+ class Share < ActiveRecord::Base
19
+ attr_accessible :polling_interval, :path, :notification, :branch_name, :remote_name
13
20
  end
14
21
 
15
- def paths=(paths)
16
- self.write_file('paths', paths.uniq.join("\n"))
22
+ def add_path(path, opts = nil)
23
+ path_opts = {:path => path}
24
+ path_opts.merge!(opts) if opts
25
+ Share.new(path_opts).save!
17
26
  end
18
27
 
19
- # @config.add_path('my/path/1')
20
- def add_path(path)
21
- path = normalize_path(path)
22
- self.paths += [path]
23
- path
28
+ def remove_path(path)
29
+ Share.where(:path => path).destroy_all
24
30
  end
25
31
 
26
- # @config.remove_path('my/path/1')
27
- def remove_path(path)
28
- path = normalize_path(path)
29
- self.paths -= [path]
30
- path
32
+ def shares
33
+ Share.all
31
34
  end
32
35
 
33
36
  def normalize_path(path)
34
37
  File.expand_path(path, Dir.pwd)
35
38
  end
36
39
 
37
- protected
38
-
39
- # Read file from gitdocs repo
40
- # @config.read_file('paths')
41
- def read_file(name)
42
- full_path = File.expand_path(name, @config_root)
43
- File.exist?(full_path) ? File.read(full_path) : ''
44
- end
45
-
46
- # Writes configuration file
47
- # @config.write_file('paths', '...')
48
- def write_file(name, content)
49
- File.open(File.expand_path(name, @config_root), 'w') { |f| f.puts content }
40
+ private
41
+ def import_old_shares
42
+ full_path = File.expand_path('paths', config_root)
43
+ if File.exist?(full_path)
44
+ File.read(full_path).split("\n").each { |path| Share.find_or_create_by_path(path) }
45
+ end
50
46
  end
51
47
  end
52
- end
48
+ end
@@ -0,0 +1,13 @@
1
+ class CreateShares < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :shares do |t|
4
+ t.column :path, :string
5
+ t.column :polling_interval, :double, :default => 15
6
+ t.column :notification, :boolean, :default => true
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ raise
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ class AddRemoteBranch < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :shares, :remote_name, :string, :default => 'origin'
4
+ add_column :shares, :branch_name, :string, :default => 'master'
5
+ end
6
+
7
+ def self.down
8
+ raise
9
+ end
10
+ end
@@ -1,7 +1,7 @@
1
1
  body {
2
2
  margin-left: 20%;
3
3
  margin-right: 20%;
4
- font-family: Arial, Verdana;
4
+ font-family: Helvetica, Arial, Verdana;
5
5
  }
6
6
 
7
7
  body h1, h2 {
@@ -9,11 +9,46 @@ body h1, h2 {
9
9
  padding-bottom: 0.8em;
10
10
  font-weight: bold;
11
11
  }
12
- body h1 { font-size: 2em; }
12
+
13
+ body h1 { font-size: 1.8em; }
13
14
  body h2 { font-size: 1.5em; margin-top: 0.2em; }
14
15
 
16
+ .nav h1 {
17
+ text-align: center;
18
+ }
19
+
20
+ .nav h1 a {
21
+ text-decoration: none;
22
+ color: black;
23
+ }
24
+
25
+ .nav h1 a:hover {
26
+ text-decoration: none;
27
+ }
28
+
29
+ .menu {
30
+ margin-top :10px;
31
+ display: absolute;
32
+ float:right;
33
+ }
34
+
35
+ div.share {
36
+ border-color: #000000;
37
+ border-radius: 7px;
38
+ padding: 2em;
39
+ margin-top: 1.2em;
40
+ }
41
+
42
+ div.share.even {
43
+ background: #FEFBAA;
44
+ }
45
+
46
+ div.share input {
47
+ width :100%;
48
+ }
49
+
15
50
  body .container {
16
- min-width: 500px;
51
+ min-width: 700px;
17
52
  background: #FCEA97;
18
53
  border-style: solid;
19
54
  border-width: 5px;
@@ -23,24 +58,21 @@ body .container {
23
58
  margin-top: 1.2em;
24
59
  }
25
60
 
26
- body a { text-decoration: none; color: blue; }
61
+ body a { text-decoration: none; color: #33e; }
27
62
  body a:hover { text-decoration: underline; }
28
63
 
29
- body .contents {
30
- overflow: auto;
31
- background-color: #F8F8F8;
32
- border: 3px solid #EFEFEF;
33
- padding: 1.2em;
34
- margin: 0;
35
- font-family: ;
64
+ body #editor {
65
+ position: relative;
66
+ width: 700px;
67
+ height: 600px;
68
+ margin-bottom: 1em;
36
69
  }
37
70
 
38
- body .contents h1 {
39
- font-size: 2em;
40
- padding-bottom: 0.8em;
71
+ body form.upload, form.add {
72
+ padding-top: 1.4em;
41
73
  }
42
74
 
43
- body .contents h2 {
44
- font-size: 1.4em;
75
+ body form.upload p, form.add p {
45
76
  padding-bottom: 0.6em;
77
+ font-weight: bold;
46
78
  }
@@ -0,0 +1,41 @@
1
+ pre.CodeRay {
2
+ border: 1px black solid;
3
+ background-color: #1d1f21;
4
+ color: #c5c8c6;
5
+ padding: 5px;
6
+ -webkit-border-radius: 4px;
7
+ -moz-border-radius: 4px;
8
+ overflow: auto;
9
+ font-size: 12px;
10
+ font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Courier New', monospace;
11
+ }
12
+
13
+ pre.CodeRay .string {
14
+ color: #b5bd68;
15
+ }
16
+
17
+ pre.CodeRay .constant, .predefined-constant {
18
+ color: #cc6666;
19
+ }
20
+
21
+ pre.CodeRay .instance-variable, pre.CodeRay .class {
22
+ color: #cc6666;
23
+
24
+ }
25
+
26
+ pre.CodeRay .keyword {
27
+ color: #b294bb;
28
+ }
29
+
30
+ pre.CodeRay .symbol {
31
+ color: #b5bd68;
32
+ }
33
+
34
+ pre.CodeRay .integer {
35
+ color: #f77;
36
+
37
+ }
38
+
39
+ pre.CodeRay .comment {
40
+ color: #969896;
41
+ }
@@ -0,0 +1,81 @@
1
+ body .contents .tilt {
2
+ overflow: auto;
3
+ background-color: #F8F8F8;
4
+ padding: 1.2em;
5
+ border: 3px solid #EFEFEF;
6
+ margin: 0;
7
+ font-family: helvetica, arial, freesans, clean, sans-serif;
8
+ }
9
+
10
+ .tilt strong { font-weight: bold; }
11
+ .tilt em { font-style: italic; }
12
+
13
+ .tilt pre {
14
+ background-color: #eee;
15
+ padding: 10px;
16
+ -webkit-border-radius: 5px;
17
+ -moz-border-radius: 5px;
18
+ border-radius: 5px;
19
+ overflow: auto;
20
+ }
21
+
22
+ .tilt code {
23
+ background-color: #eee;
24
+ padding: 1px 3px;
25
+ -webkit-border-radius: 4px;
26
+ -moz-border-radius: 4px;
27
+ border-radius: 4px;
28
+ font-family: monospace;
29
+ }
30
+
31
+ .tilt p { padding-bottom: 0.5em; }
32
+
33
+ .tilt ul {
34
+ margin: 1em 2em 1em 0;
35
+ margin-left: 2em;
36
+ }
37
+
38
+ .tilt li p {
39
+ margin: 0.3em;
40
+ }
41
+
42
+ .tilt li {
43
+ list-style-type: square;
44
+ }
45
+
46
+ .tilt a:link, .tilt a:visited{
47
+ color: #33e;
48
+ text-decoration: none;
49
+ }
50
+
51
+ .tilt a:hover{
52
+ color: #00f;
53
+ text-shadow:1px 1px 2px #ccf;
54
+ text-decoration:underline;
55
+ }
56
+
57
+ .tilt h1 {
58
+ font-size: 1.8em;
59
+ padding-bottom: 0.6em;
60
+ margin-bottom: 0;
61
+ font-weight: bold;
62
+ }
63
+
64
+ .tilt h2 {
65
+ font-size: 1.4em;
66
+ border-bottom: 1px dotted #aaa;
67
+ margin-bottom: 1em;
68
+ padding-bottom: 0;
69
+ color: #333;
70
+ }
71
+
72
+ .tilt h3 {
73
+ color: #666;
74
+ padding-bottom: 0.4em;
75
+ }
76
+
77
+ .tilt .shadow {
78
+ -webkit-box-shadow:0 5px 15px #000;
79
+ -moz-box-shadow:0 5px 15px #000;
80
+ box-shadow:0 5px 15px #000;
81
+ }
Binary file
@@ -0,0 +1 @@
1
+ define(function(a,b,c){a("pilot/browser_focus"),a("pilot/dom"),a("pilot/event"),a("pilot/event_emitter"),a("pilot/fixoldbrowsers"),a("pilot/keys"),a("pilot/lang"),a("pilot/oop"),a("pilot/useragent"),a("pilot/canon")}),define(function(a,b,c){console.warn("DEPRECATED: 'pilot/browser_focus' is deprecated. Use 'ace/lib/browser_focus' instead"),c.exports=a("ace/lib/browser_focus")}),define(function(a,b,c){console.warn("DEPRECATED: 'pilot/dom' is deprecated. Use 'ace/lib/dom' instead"),c.exports=a("ace/lib/dom")}),define(function(a,b,c){console.warn("DEPRECATED: 'pilot/event' is deprecated. Use 'ace/lib/event' instead"),c.exports=a("ace/lib/event")}),define(function(a,b,c){console.warn("DEPRECATED: 'pilot/event_emitter' is deprecated. Use 'ace/lib/event_emitter' instead"),c.exports=a("ace/lib/event_emitter")}),define(function(a,b,c){console.warn("DEPRECATED: 'pilot/fixoldbrowsers' is deprecated. Use 'ace/lib/fixoldbrowsers' instead"),c.exports=a("ace/lib/fixoldbrowsers")}),define(function(a,b,c){console.warn("DEPRECATED: 'pilot/keys' is deprecated. Use 'ace/lib/keys' instead"),c.exports=a("ace/lib/keys")}),define(function(a,b,c){console.warn("DEPRECATED: 'pilot/lang' is deprecated. Use 'ace/lib/lang' instead"),c.exports=a("ace/lib/lang")}),define(function(a,b,c){console.warn("DEPRECATED: 'pilot/oop' is deprecated. Use 'ace/lib/oop' instead"),c.exports=a("ace/lib/oop")}),define(function(a,b,c){console.warn("DEPRECATED: 'pilot/useragent' is deprecated. Use 'ace/lib/useragent' instead"),c.exports=a("ace/lib/useragent")}),define(function(a,b,c){console.warn("DEPRECATED: 'pilot/canon' is deprecated."),b.addCommand=function(){console.warn("DEPRECATED: 'canon.addCommand()' is deprecated. Use 'editor.commands.addCommand(command)' instead."),console.trace()},b.removeCommand=function(){console.warn("DEPRECATED: 'canon.removeCommand()' is deprecated. Use 'editor.commands.removeCommand(command)' instead."),console.trace()}})