siuying-gitdocs 0.4.14.md
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 +5 -0
- data/CHANGELOG +79 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +192 -0
- data/Rakefile +8 -0
- data/bin/gitdocs +5 -0
- data/gitdocs.gemspec +41 -0
- data/lib/gitdocs/cli.rb +111 -0
- data/lib/gitdocs/configuration.rb +79 -0
- data/lib/gitdocs/docfile.rb +23 -0
- data/lib/gitdocs/manager.rb +96 -0
- data/lib/gitdocs/markdown_converter.rb +44 -0
- data/lib/gitdocs/markdown_template.rb +20 -0
- data/lib/gitdocs/migration/001_create_shares.rb +13 -0
- data/lib/gitdocs/migration/002_add_remote_branch.rb +10 -0
- data/lib/gitdocs/migration/003_create_configs.rb +11 -0
- data/lib/gitdocs/migration/004_add_index_for_path.rb +10 -0
- data/lib/gitdocs/migration/005_add_start_web_frontend.rb +9 -0
- data/lib/gitdocs/migration/006_add_web_port_to_config.rb +9 -0
- data/lib/gitdocs/public/css/app.css +51 -0
- data/lib/gitdocs/public/css/bootstrap.css +356 -0
- data/lib/gitdocs/public/css/coderay.css +41 -0
- data/lib/gitdocs/public/css/tilt.css +82 -0
- data/lib/gitdocs/public/img/error.png +0 -0
- data/lib/gitdocs/public/img/file.png +0 -0
- data/lib/gitdocs/public/img/folder.png +0 -0
- data/lib/gitdocs/public/img/git_logo.png +0 -0
- data/lib/gitdocs/public/img/info.png +0 -0
- data/lib/gitdocs/public/img/ok.png +0 -0
- data/lib/gitdocs/public/img/warning.png +0 -0
- data/lib/gitdocs/public/js/ace/ace-compat.js +1 -0
- data/lib/gitdocs/public/js/ace/ace-uncompressed.js +14202 -0
- data/lib/gitdocs/public/js/ace/ace.js +1 -0
- data/lib/gitdocs/public/js/ace/keybinding-emacs.js +1 -0
- data/lib/gitdocs/public/js/ace/keybinding-vim.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-coffee.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-css.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-html.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-javascript.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-json.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-lua.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-markdown.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-php.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-python.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-ruby.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-scala.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-scss.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-sql.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-svg.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-textile.js +1 -0
- data/lib/gitdocs/public/js/ace/mode-xml.js +1 -0
- data/lib/gitdocs/public/js/ace/theme-tomorrow.js +1 -0
- data/lib/gitdocs/public/js/ace/theme-tomorrow_night.js +1 -0
- data/lib/gitdocs/public/js/ace/theme-tomorrow_night_blue.js +1 -0
- data/lib/gitdocs/public/js/ace/theme-twilight.js +1 -0
- data/lib/gitdocs/public/js/ace/theme-vibrant_ink.js +1 -0
- data/lib/gitdocs/public/js/ace/worker-coffee.js +7041 -0
- data/lib/gitdocs/public/js/ace/worker-css.js +9525 -0
- data/lib/gitdocs/public/js/ace/worker-javascript.js +9739 -0
- data/lib/gitdocs/public/js/app.js +107 -0
- data/lib/gitdocs/public/js/bootstrap-alerts.js +113 -0
- data/lib/gitdocs/public/js/edit.js +30 -0
- data/lib/gitdocs/public/js/jquery.js +4 -0
- data/lib/gitdocs/public/js/jquery.tablesorter.js +4 -0
- data/lib/gitdocs/public/js/search.js +13 -0
- data/lib/gitdocs/public/js/settings.js +25 -0
- data/lib/gitdocs/public/js/util.js +145 -0
- data/lib/gitdocs/runner.rb +259 -0
- data/lib/gitdocs/server.rb +154 -0
- data/lib/gitdocs/version.rb +3 -0
- data/lib/gitdocs/views/_ace_scripts.erb +8 -0
- data/lib/gitdocs/views/_header.haml +14 -0
- data/lib/gitdocs/views/app.haml +40 -0
- data/lib/gitdocs/views/dir.haml +43 -0
- data/lib/gitdocs/views/edit.haml +15 -0
- data/lib/gitdocs/views/file.haml +8 -0
- data/lib/gitdocs/views/home.haml +10 -0
- data/lib/gitdocs/views/revisions.haml +28 -0
- data/lib/gitdocs/views/search.haml +16 -0
- data/lib/gitdocs/views/settings.haml +55 -0
- data/lib/gitdocs.rb +37 -0
- data/lib/img/icon.png +0 -0
- data/test/configuration_test.rb +39 -0
- data/test/runner_test.rb +25 -0
- data/test/test_helper.rb +54 -0
- metadata +370 -0
data/.gitignore
ADDED
data/CHANGELOG
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
0.4.15 (Unreleased)
|
|
2
|
+
|
|
3
|
+
* Adds a 'new directory' function to front-end [thanks Kale Worsley]
|
|
4
|
+
* Change 'New file' function to actually create a blank file [thanks Kale Worsley]
|
|
5
|
+
|
|
6
|
+
0.4.14 (1/14/2012)
|
|
7
|
+
|
|
8
|
+
* Change file modes into tab style [thanks Kale Worsley]
|
|
9
|
+
* Add ability to revert a file to a previous revision [thanks Kale Worsley]
|
|
10
|
+
* Add optional git commit message field to edit form [thanks Kale Worsley]
|
|
11
|
+
|
|
12
|
+
0.4.13 (1/11/2012)
|
|
13
|
+
|
|
14
|
+
* Redirect to first share if there's only one
|
|
15
|
+
* Render inline README for a directory
|
|
16
|
+
* Front-end now lists folder sizes in directory listing [Thanks evan tatarka]
|
|
17
|
+
|
|
18
|
+
0.4.12 (1/05/2012)
|
|
19
|
+
|
|
20
|
+
* Fixes incorrect padding style on rendered code blocks (thanks chris kempson)
|
|
21
|
+
* Fixes encoding issues in markdown files
|
|
22
|
+
* Tag documents as utf-8 in meta for web frontend (thanks chris kempson)
|
|
23
|
+
|
|
24
|
+
0.4.11 (1/04/2012)
|
|
25
|
+
|
|
26
|
+
* Add line-height to code blocks in file displays
|
|
27
|
+
* Fixes various browser inconsistencies (thanks evan tatarka)
|
|
28
|
+
|
|
29
|
+
0.4.10 (12/30/2011)
|
|
30
|
+
|
|
31
|
+
* View revision history on the web front-end!
|
|
32
|
+
|
|
33
|
+
0.4.9 (12/30/2011)
|
|
34
|
+
|
|
35
|
+
* Adds configuration for web port in settings
|
|
36
|
+
* Adds support for 'add' and 'remove' shares in settings
|
|
37
|
+
|
|
38
|
+
0.4.8 (12/29/2011)
|
|
39
|
+
|
|
40
|
+
* Only encode to utf-8 on ruby 1.9.x
|
|
41
|
+
* Fixes so that settings form on the web front-end saves
|
|
42
|
+
* Cleanup the front-end directory listing significantly
|
|
43
|
+
* More robust EM reactor loop handling
|
|
44
|
+
|
|
45
|
+
0.4.7 (12/15/2011)
|
|
46
|
+
|
|
47
|
+
* Re-throw exceptions from reactor loop
|
|
48
|
+
* Socket testing moved to defer block
|
|
49
|
+
|
|
50
|
+
0.4.5, 0.4.6 (12/14/2011)
|
|
51
|
+
|
|
52
|
+
* Enables logs in ~/.gitdocs/log for easier debugging
|
|
53
|
+
* Fix issue with default sort order on web interface
|
|
54
|
+
* Fixes major mime type detection issues
|
|
55
|
+
* Fixes rendering issues
|
|
56
|
+
|
|
57
|
+
0.4.4 (12/14/2011)
|
|
58
|
+
|
|
59
|
+
* Lock to eventmachine 1.0
|
|
60
|
+
* Use mime-types over file for better platform support
|
|
61
|
+
* Remove signal handling and just leverage EM start/stop
|
|
62
|
+
* Adds table sorting and file+folder icons in web front-end
|
|
63
|
+
|
|
64
|
+
0.4.3 (12/13/2011)
|
|
65
|
+
|
|
66
|
+
* Javascript fixes for front-end
|
|
67
|
+
|
|
68
|
+
0.4.2 (12/13/2011)
|
|
69
|
+
|
|
70
|
+
* Fixes search on blank results case
|
|
71
|
+
|
|
72
|
+
0.4.1 (12/13/2011)
|
|
73
|
+
|
|
74
|
+
* Adds a basic search to web front-end
|
|
75
|
+
* Beginning of the work towards cross-platform notifications
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011 GoMiso, Inc
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Gitdocs
|
|
2
|
+
|
|
3
|
+
Open-source dropbox alternative powered by git. Collaborate on files and tasks without any extra hassle.
|
|
4
|
+
gitdocs will automatically keep everyone's repos in sync by pushing and pulling changes.
|
|
5
|
+
This allows any git repo to be used as a collaborative task list, file share, or wiki for a team.
|
|
6
|
+
Supports a web front-end allowing each repo to be accessed through your browser.
|
|
7
|
+
|
|
8
|
+
**Note:** Gitdocs has been tested on multiple unix systems including Mac OS X and Ubuntu.
|
|
9
|
+
Windows support is [half-baked](https://github.com/bazaarlabs/gitdocs/issues/7)
|
|
10
|
+
but we plan to tackle that shortly in an upcoming release.
|
|
11
|
+
|
|
12
|
+
## Why?
|
|
13
|
+
|
|
14
|
+
Why use gitdocs for your file and doc sharing needs?
|
|
15
|
+
|
|
16
|
+
* **Open** - gitdocs is entirely open-source under the MIT license
|
|
17
|
+
* **Simple** - gitdocs is the simplest thing that works in both setup and usage
|
|
18
|
+
* **Secure** - gitdocs leverages git (and existing providers like github) to store your data safely.
|
|
19
|
+
* **Versatile** - share task lists, code snippets, images, files or just use it as a wiki (with our web front-end).
|
|
20
|
+
* **Portable** - access your files on any client that can use git.
|
|
21
|
+
|
|
22
|
+
The best part is that getting started using this project is quick and simple.
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
Gitdocs monitors any number of directories for changes and keeps them automatically synced. You can either add
|
|
27
|
+
existing git directories to be watched or have gitdocs pull down a repository for you.
|
|
28
|
+
|
|
29
|
+
There are plenty of great git hosting providers to safely store your data and you can trust the data is stored securely.
|
|
30
|
+
If you want a private repo to use with gitdocs, we recommend you check out [BitBucket](https://bitbucket.org/) which
|
|
31
|
+
provides free private git repos after registration.
|
|
32
|
+
|
|
33
|
+
To get started with gitdocs and a secure private bitbucket repo:
|
|
34
|
+
|
|
35
|
+
- `gem install gitdocs`
|
|
36
|
+
- `gitdocs start`
|
|
37
|
+
- Login to [BitBucket](https://bitbucket.org/) and add a new private repo named 'docs'
|
|
38
|
+
- Setup your SSH Key under [Account](https://bitbucket.org/account/) for ssh access
|
|
39
|
+
- `gitdocs create ~/Documents/gitdocs git@bitbucket.org:username/docs.git`
|
|
40
|
+
|
|
41
|
+
There you go! Now just start adding and editing files within the directory and they will be automatically
|
|
42
|
+
synchronized across all gitdocs-enabled clients.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
Requires ruby and rubygems. Install as a gem:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
gem install gitdocs
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you have Growl installed on Max OSX, you'll probably want to run:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
brew install growlnotify
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
to enable Growl notification support.
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
### Starting Gitdocs
|
|
63
|
+
|
|
64
|
+
You need to start gitdocs in order for the monitoring to work:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
gitdocs start
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
If the start command fails, you can check the logs in `~/.gitdocs/log` or run again with the debug flag:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
gitdocs start -D
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Once gitdocs has been started and is monitoring the correct directories, simply start editing or adding files to your
|
|
77
|
+
designated git repos and changes will be automatically pushed. Gitdocs can be easily stopped or restarted:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
gitdocs stop
|
|
81
|
+
gitdocs restart
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
For an overview of gitdocs current status, run:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
gitdocs status
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Monitoring Shares
|
|
91
|
+
|
|
92
|
+
You can add existing folders to watch:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
gitdocs add my/path/to/watch
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
or instruct gitdocs to fetch a remote share and keep it synced with:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
gitdocs create local/path/for/repo git@github.com:user/some/remote/repo.git
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
This will clone the remote repo and begin monitoring the local path. You can remove and clear monitored paths as well:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
gitdocs rm my/path/to/watch
|
|
108
|
+
gitdocs clear
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Web Front-end
|
|
112
|
+
|
|
113
|
+
Gitdocs come with a handy web front-end that is available.
|
|
114
|
+
|
|
115
|
+
<a href="http://i.imgur.com/IMwqN.png">
|
|
116
|
+
<img src="http://i.imgur.com/IMwqN.png" width="250" />
|
|
117
|
+
</a>
|
|
118
|
+
<a href="http://i.imgur.com/0wVyB.png">
|
|
119
|
+
<img src="http://i.imgur.com/0wVyB.png" width="250" />
|
|
120
|
+
</a>
|
|
121
|
+
<a href="http://i.imgur.com/Ijyo9.png">
|
|
122
|
+
<img src="http://i.imgur.com/Ijyo9.png" width="250" />
|
|
123
|
+
</a>
|
|
124
|
+
|
|
125
|
+
This browser front-end supports the following features:
|
|
126
|
+
|
|
127
|
+
* Explore the files within all your shares
|
|
128
|
+
* View revision history for every file in your share
|
|
129
|
+
* Revert a file to any previous state in the file's history
|
|
130
|
+
* View source files in your shares with code syntax highlighting
|
|
131
|
+
* View text files in your shares with smart formatting (markdown, textile)
|
|
132
|
+
* View any file in your shares that can be rendered inline (pdf, images, et al)
|
|
133
|
+
* Edit and update text files using a text editor
|
|
134
|
+
* Upload and create new files within your shares
|
|
135
|
+
* Manage share settings and other configuration options
|
|
136
|
+
|
|
137
|
+
To check out the front-end, simply visit `http://localhost:8888` whenever gitdocs is running.
|
|
138
|
+
|
|
139
|
+
### Conflict Resolution
|
|
140
|
+
|
|
141
|
+
Proper conflict resolution is an important part of any good doc and file collaboration tool.
|
|
142
|
+
In most cases, git does a good job of handling file merges for you. Still, what about cases where the conflict cannot be
|
|
143
|
+
resolved automatically?
|
|
144
|
+
|
|
145
|
+
Don't worry, gitdocs makes handling this simple. In the event of a conflict,
|
|
146
|
+
**all the different versions of a document are stored** in the repo tagged with the **git sha** for each
|
|
147
|
+
committed version. The members of the repo can then compare all versions and resolve the conflict.
|
|
148
|
+
|
|
149
|
+
## Gitdocs in Practice
|
|
150
|
+
|
|
151
|
+
At Miso, our team actually uses gitdocs in conjunction with Dropbox. We find Dropbox is ideal for galleries, videos,
|
|
152
|
+
and large binary files of all sorts. We use gitdocs for storing our actual "docs":
|
|
153
|
+
Task lists, wiki pages, planning docs, collaborative designs, notes, guides, code snippets, etc.
|
|
154
|
+
|
|
155
|
+
You will find that the gitdocs browser front-end is well suited for this usage scenario
|
|
156
|
+
since you can browse formatted wiki pages, view files with smart syntax highlighting,
|
|
157
|
+
edit files with a rich text editor, search all your files, as well as view individual file revision histories.
|
|
158
|
+
|
|
159
|
+
## Planned Features
|
|
160
|
+
|
|
161
|
+
Gitdocs is a young project but we have many plans for it including:
|
|
162
|
+
|
|
163
|
+
- Better handling of large binary files circumventing known git limitations
|
|
164
|
+
- Click-to-share instant access granting file access to users using a local tunnel or other means.
|
|
165
|
+
- Tagging and organizing of files within the web front-end
|
|
166
|
+
- Better access to the versions for a particular file within the web front-end
|
|
167
|
+
|
|
168
|
+
## Contributors
|
|
169
|
+
|
|
170
|
+
Gitdocs was created at [Miso](http://engineering.gomiso.com) by [Joshua Hull](https://github.com/joshbuddy) and [Nathan Esquenazi](https://github.com/nesquena).
|
|
171
|
+
We also have had several contributors:
|
|
172
|
+
|
|
173
|
+
* [Chris Kempson](https://github.com/ChrisKempson) - Encoding issues
|
|
174
|
+
* [Evan Tatarka](https://github.com/evant) - Front-end style fixes
|
|
175
|
+
* [Kale Worsley](https://github.com/kaleworsley) - Custom commit msgs, revert revisions, front-end cleanup
|
|
176
|
+
|
|
177
|
+
Gitdocs is still a young project with a lot of opportunity for contributions. Patches welcome!
|
|
178
|
+
|
|
179
|
+
## Prior Projects
|
|
180
|
+
|
|
181
|
+
Gitdocs is a fresh project that we originally spiked on in a few days time. Our primary goals are to keep the code as simple as possible,
|
|
182
|
+
but provide the features that makes Dropbox great. If you are interested in other Dropbox alternatives, be sure to checkout our notes below:
|
|
183
|
+
|
|
184
|
+
* [SparkleShare](http://sparkleshare.org/) is an open source, self-hosted Dropbox alternative written using C# and the [Mono Project](http://www.mono-project.com/Main_Page).
|
|
185
|
+
More mature but has a lot of dependencies, and lacks some of the features planned in Gitdocs.
|
|
186
|
+
* [DVCS-Autosync](http://mayrhofer.eu.org/dvcs-autosync) is a project to create an open source replacement for Dropbox based on distributed version control systems.
|
|
187
|
+
Very similar project but again we have features planned that are out of scope (local tunnel file sharing, complete web ui for browsing, uploading and editing).
|
|
188
|
+
* [Lipsync](https://github.com/philcryer/lipsync) is another similar project. We haven't looked at this too closely, but thought we would mention it in this list.
|
|
189
|
+
* [bitpocket](https://github.com/sickill/bitpocket) is a project that uses rsync to synchronize data. Interesting concept, but
|
|
190
|
+
lacks revision history, author tracking, etc and we have features planned that are out of scope for this project
|
|
191
|
+
|
|
192
|
+
If any other open-source dropbox alternatives are available, we would love to hear about them so let us know!
|
data/Rakefile
ADDED
data/bin/gitdocs
ADDED
data/gitdocs.gemspec
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "gitdocs/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "siuying-gitdocs"
|
|
7
|
+
s.version = Gitdocs::VERSION
|
|
8
|
+
s.authors = ["Josh Hull", "Nathan Esquenazi"]
|
|
9
|
+
s.email = ["joshbuddy@gmail.com", "nesquena@gmail.com"]
|
|
10
|
+
s.homepage = "https://github.com/siuying/gitdocs"
|
|
11
|
+
s.summary = %q{Open-source Dropbox using Ruby and Git (my fork with github favoured markdown support)}
|
|
12
|
+
s.description = %q{Open-source Dropbox using Ruby and Git (my fork with github favoured markdown support).}
|
|
13
|
+
|
|
14
|
+
s.files = `git ls-files`.split("\n")
|
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
17
|
+
s.require_paths = ["lib"]
|
|
18
|
+
|
|
19
|
+
s.add_dependency 'joshbuddy-guard', '~> 0.10.0'
|
|
20
|
+
s.add_dependency 'thin', '~> 1.3.1'
|
|
21
|
+
s.add_dependency 'renee', '~> 0.3.7'
|
|
22
|
+
s.add_dependency 'redcarpet', '~> 2.0.0'
|
|
23
|
+
s.add_dependency 'thor', '~> 0.14.6'
|
|
24
|
+
s.add_dependency 'coderay', '~> 1.0.4'
|
|
25
|
+
s.add_dependency 'dante', '~> 0.1.2'
|
|
26
|
+
s.add_dependency 'growl', '~> 1.0.3'
|
|
27
|
+
s.add_dependency 'yajl-ruby', '~> 1.1.0'
|
|
28
|
+
s.add_dependency 'haml', '~> 3.1.4'
|
|
29
|
+
s.add_dependency 'sqlite3', "~> 1.3.4"
|
|
30
|
+
s.add_dependency 'activerecord', "~> 3.1.0"
|
|
31
|
+
s.add_dependency 'grit', "~> 2.4.1"
|
|
32
|
+
s.add_dependency 'shell_tools', "~> 0.1.0"
|
|
33
|
+
s.add_dependency 'mimetype-fu', "~> 0.1.2"
|
|
34
|
+
s.add_dependency 'eventmachine', '>= 1.0.0.beta.3'
|
|
35
|
+
s.add_dependency 'pygments.rb'
|
|
36
|
+
|
|
37
|
+
s.add_development_dependency 'minitest', "~> 2.6.1"
|
|
38
|
+
s.add_development_dependency 'rake'
|
|
39
|
+
s.add_development_dependency 'mocha'
|
|
40
|
+
s.add_development_dependency 'fakeweb'
|
|
41
|
+
end
|
data/lib/gitdocs/cli.rb
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
module Gitdocs
|
|
2
|
+
require 'thor'
|
|
3
|
+
|
|
4
|
+
class Cli < Thor
|
|
5
|
+
include Thor::Actions
|
|
6
|
+
|
|
7
|
+
def self.source_root; File.expand_path('../../', __FILE__); end
|
|
8
|
+
|
|
9
|
+
desc "start", "Starts a daemonized gitdocs process"
|
|
10
|
+
method_option :debug, :type => :boolean, :aliases => "-D"
|
|
11
|
+
method_option :port, :type => :string, :aliases => "-p"
|
|
12
|
+
def start
|
|
13
|
+
if self.stopped? && !options[:debug]
|
|
14
|
+
self.runner.execute { Gitdocs.start(:port => options[:port]) }
|
|
15
|
+
self.running? ? say("Started gitdocs", :green) : say("Failed to start gitdocs", :red)
|
|
16
|
+
elsif self.stopped? && options[:debug]
|
|
17
|
+
say "Starting in debug mode", :yellow
|
|
18
|
+
Gitdocs.start(:debug => true, :port => options[:port])
|
|
19
|
+
else # already running
|
|
20
|
+
say "Gitdocs is already running, please use restart", :red
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc "stop", "Stops the gitdocs process"
|
|
25
|
+
def stop
|
|
26
|
+
if self.running?
|
|
27
|
+
self.runner.execute(:kill => true)
|
|
28
|
+
say "Stopped gitdocs", :red
|
|
29
|
+
else # not running
|
|
30
|
+
say "Gitdocs is not running", :red
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
desc "restart", "Restarts the gitdocs process"
|
|
35
|
+
def restart
|
|
36
|
+
self.stop
|
|
37
|
+
self.start
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
desc "add PATH", "Adds a path to gitdocs"
|
|
41
|
+
def add(path)
|
|
42
|
+
self.config.add_path(path)
|
|
43
|
+
say "Added path #{path} to doc list"
|
|
44
|
+
self.restart if self.running?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
desc "rm PATH", "Removes a path from gitdocs"
|
|
48
|
+
def rm(path)
|
|
49
|
+
self.config.remove_path(path)
|
|
50
|
+
say "Removed path #{path} from doc list"
|
|
51
|
+
self.restart if self.running?
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
desc "clear", "Clears all paths from gitdocs"
|
|
55
|
+
def clear
|
|
56
|
+
self.config.clear
|
|
57
|
+
say "Cleared paths from gitdocs"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
desc "create PATH REMOTE", "Creates a new gitdoc root based on an existing remote"
|
|
61
|
+
def create(path, remote)
|
|
62
|
+
FileUtils.mkdir_p(File.dirname(path))
|
|
63
|
+
system("git clone -q #{remote} #{ShellTools.escape(path)}") or raise "Unable to clone into #{path}"
|
|
64
|
+
self.add(path)
|
|
65
|
+
say "Created #{path} path for gitdoc"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
desc "status", "Retrieve gitdocs status"
|
|
69
|
+
def status
|
|
70
|
+
say "GitDoc v#{VERSION}"
|
|
71
|
+
say "Running: #{self.running?}"
|
|
72
|
+
say "Watching paths:"
|
|
73
|
+
say self.config.shares.map { |s| " - #{s.path}" }.join("\n")
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
desc "config", "Configuration options for gitdocs"
|
|
77
|
+
def config
|
|
78
|
+
# TODO make this work
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
desc "help", "Prints out the help"
|
|
82
|
+
def help(task = nil, subcommand = false)
|
|
83
|
+
say "\nGitdocs: Collaborate with ease.\n\n"
|
|
84
|
+
task ? self.class.task_help(shell, task) : self.class.help(shell, subcommand)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Helpers for thor
|
|
88
|
+
no_tasks do
|
|
89
|
+
def runner(options={})
|
|
90
|
+
Dante::Runner.new('gitdocs', options.merge(:debug => false, :daemonize => true, :pid_path => self.pid_path))
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def config
|
|
94
|
+
@config ||= Configuration.new
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def running?
|
|
98
|
+
self.runner.daemon_running?
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def stopped?
|
|
102
|
+
self.runner.daemon_stopped?
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def pid_path
|
|
106
|
+
"/tmp/gitdocs.pid"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require 'active_record'
|
|
2
|
+
require 'grit'
|
|
3
|
+
|
|
4
|
+
module Gitdocs
|
|
5
|
+
class Configuration
|
|
6
|
+
attr_reader :config_root
|
|
7
|
+
|
|
8
|
+
def initialize(config_root = nil)
|
|
9
|
+
@config_root = config_root || File.expand_path(".gitdocs", ENV["HOME"])
|
|
10
|
+
FileUtils.mkdir_p(@config_root)
|
|
11
|
+
ActiveRecord::Base.establish_connection(
|
|
12
|
+
:adapter => 'sqlite3',
|
|
13
|
+
:database => ENV["TEST"] ? ':memory:' : File.join(@config_root, 'config.db')
|
|
14
|
+
)
|
|
15
|
+
ActiveRecord::Migrator.migrate(File.expand_path("../migration", __FILE__))
|
|
16
|
+
import_old_shares unless ENV["TEST"]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class Share < ActiveRecord::Base
|
|
20
|
+
attr_accessible :polling_interval, :path, :notification, :branch_name, :remote_name
|
|
21
|
+
|
|
22
|
+
def available_remotes
|
|
23
|
+
repo = Grit::Repo.new(path)
|
|
24
|
+
repo.remotes.map{|r| r.name}
|
|
25
|
+
rescue
|
|
26
|
+
nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def available_branches
|
|
30
|
+
repo = Grit::Repo.new(path)
|
|
31
|
+
repo.heads.map{|r| r.name}
|
|
32
|
+
rescue
|
|
33
|
+
nil
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class Config < ActiveRecord::Base
|
|
38
|
+
attr_accessible :load_browser_on_startup, :start_web_frontend, :web_frontend_port
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def add_path(path, opts = nil)
|
|
42
|
+
path = self.normalize_path(path)
|
|
43
|
+
path_opts = {:path => path}
|
|
44
|
+
path_opts.merge!(opts) if opts
|
|
45
|
+
Share.new(path_opts).save!
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def remove_path(path)
|
|
49
|
+
path = self.normalize_path(path)
|
|
50
|
+
Share.where(:path => path).destroy_all
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def clear
|
|
54
|
+
Share.destroy_all
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def shares
|
|
58
|
+
Share.all
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def global
|
|
62
|
+
raise if Config.all.size > 1
|
|
63
|
+
Config.create! if Config.all.empty?
|
|
64
|
+
Config.all.first
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def normalize_path(path)
|
|
68
|
+
File.expand_path(path, Dir.pwd)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
def import_old_shares
|
|
73
|
+
full_path = File.expand_path('paths', config_root)
|
|
74
|
+
if File.exist?(full_path)
|
|
75
|
+
File.read(full_path).split("\n").each { |path| Share.find_or_create_by_path(path) }
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Gitdocs
|
|
2
|
+
class Docfile
|
|
3
|
+
attr_accessor :parent
|
|
4
|
+
attr_reader :path, :name
|
|
5
|
+
|
|
6
|
+
def initialize(path)
|
|
7
|
+
@path = path
|
|
8
|
+
@parent = File.dirname(path)
|
|
9
|
+
@name = File.basename(path)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# within?("parent", "/root/path") => "/root/path/parent"
|
|
13
|
+
def within?(dir, root)
|
|
14
|
+
expanded_root = File.expand_path(dir, root)
|
|
15
|
+
File.expand_path(@parent, root) == expanded_root ||
|
|
16
|
+
File.expand_path(@path, root).include?(expanded_root)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def dir?
|
|
20
|
+
File.directory?(@path)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module Gitdocs
|
|
2
|
+
Restart = Class.new(RuntimeError)
|
|
3
|
+
|
|
4
|
+
class Manager
|
|
5
|
+
attr_reader :config, :debug
|
|
6
|
+
|
|
7
|
+
def initialize(config_root, debug)
|
|
8
|
+
@config = Configuration.new(config_root)
|
|
9
|
+
@logger = Logger.new(File.expand_path('log', @config.config_root))
|
|
10
|
+
@debug = debug
|
|
11
|
+
yield @config if block_given?
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
RepoDescriptor = Struct.new(:name, :index)
|
|
15
|
+
|
|
16
|
+
def search(term)
|
|
17
|
+
results = {}
|
|
18
|
+
@runners.each_with_index do |runner, index|
|
|
19
|
+
descriptor = RepoDescriptor.new(runner.root, index)
|
|
20
|
+
repo_results = runner.search(term)
|
|
21
|
+
results[descriptor] = repo_results unless repo_results.empty?
|
|
22
|
+
end
|
|
23
|
+
results
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def start(web_port=nil)
|
|
27
|
+
self.log "Starting Gitdocs v#{VERSION}..."
|
|
28
|
+
self.log "Using configuration root: '#{self.config.config_root}'"
|
|
29
|
+
self.log "Shares: #{config.shares.map(&:inspect).join(", ")}"
|
|
30
|
+
# Start the repo watchers
|
|
31
|
+
runners = nil
|
|
32
|
+
retrying = false
|
|
33
|
+
begin
|
|
34
|
+
EM.run do
|
|
35
|
+
self.log "Starting EM loop..."
|
|
36
|
+
@runners = config.shares.map { |share|
|
|
37
|
+
self.log "Starting #{share}"
|
|
38
|
+
Runner.new(share)
|
|
39
|
+
}
|
|
40
|
+
self.log "Running runners... #{@runners.size}"
|
|
41
|
+
@runners.each(&:run)
|
|
42
|
+
# Start the web front-end
|
|
43
|
+
if self.config.global.start_web_frontend
|
|
44
|
+
web_port ||= self.config.global.web_frontend_port
|
|
45
|
+
Server.new(self, *@runners).start(web_port.to_i)
|
|
46
|
+
EM.defer( proc {
|
|
47
|
+
i = 0
|
|
48
|
+
web_started = false
|
|
49
|
+
begin
|
|
50
|
+
TCPSocket.open('127.0.0.1', web_port.to_i).close
|
|
51
|
+
web_started = true
|
|
52
|
+
rescue Errno::ECONNREFUSED
|
|
53
|
+
self.log "Retrying server loop..."
|
|
54
|
+
sleep 0.2
|
|
55
|
+
i += 1
|
|
56
|
+
retry if i <= 20
|
|
57
|
+
end
|
|
58
|
+
system("open http://localhost:#{web_port}/") if !retrying && self.config.global.load_browser_on_startup && web_started
|
|
59
|
+
}, proc {
|
|
60
|
+
self.log "Web server running!"
|
|
61
|
+
})
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
rescue Restart
|
|
65
|
+
retrying = true
|
|
66
|
+
retry
|
|
67
|
+
end
|
|
68
|
+
rescue Exception => e # Report all errors in log
|
|
69
|
+
self.log(e.class.inspect + " - " + e.inspect + " - " + e.message.inspect, :error)
|
|
70
|
+
self.log(e.backtrace.join("\n"), :error)
|
|
71
|
+
raise
|
|
72
|
+
ensure
|
|
73
|
+
self.log("Gitdocs is terminating...goodbye\n\n")
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def restart
|
|
77
|
+
Thread.new do
|
|
78
|
+
Thread.main.raise Restart, "restarting ... "
|
|
79
|
+
sleep 0.1 while EM.reactor_running?
|
|
80
|
+
start
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def stop
|
|
85
|
+
EM.stop
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
protected
|
|
89
|
+
|
|
90
|
+
# Logs and outputs to file or stdout based on debugging state
|
|
91
|
+
# log("message")
|
|
92
|
+
def log(msg, level=:info)
|
|
93
|
+
@debug ? puts(msg) : @logger.send(level, msg)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|