veda 0.0.1.pre
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.
- checksums.yaml +7 -0
- data/README.md +89 -0
- data/bin/veda +3 -0
- data/config.ru +6 -0
- data/lib/veda.rb +7 -0
- data/lib/veda/cli.rb +80 -0
- data/lib/veda/documentation.rb +38 -0
- data/lib/veda/public/css/coderay.css +124 -0
- data/lib/veda/public/css/style.css +134 -0
- data/lib/veda/scm.rb +26 -0
- data/lib/veda/server.rb +87 -0
- data/lib/veda/version.rb +3 -0
- data/lib/veda/views/index.slim +3 -0
- data/lib/veda/views/layout.slim +9 -0
- data/lib/veda/views/library.slim +5 -0
- data/lib/veda/views/show.slim +33 -0
- metadata +228 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e04be53378e0b8539793c26e62127201dd51bb4f
|
4
|
+
data.tar.gz: 289a7989e1a727b1aaae77374c0991e2f0a6c123
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5572792b0220c831e9ab008f7734cd83a5b0bcadb1bca3fe0175c2587e41f2835e48da95788efca4b928ae147879698818605792283de0ad86a25eff694548b7
|
7
|
+
data.tar.gz: d631f6aa80433988b016a5675c85ab2b9f03030b73677087e7154dffd7d0158c27dfde1a3547f745a10b3d6b6f8fc72996acbc6f4698995bba1768818c9dee16
|
data/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# Veda
|
2
|
+
|
3
|
+
Collaborate documentation and WIKI
|
4
|
+
|
5
|
+
## What is Veda?
|
6
|
+
|
7
|
+
Veda is Git based documentation system, it aims to simplify writing documentation and text using
|
8
|
+
the same methodologies as writing code. Everyone can fork and contribute documentation.
|
9
|
+
|
10
|
+
## Getting Veda
|
11
|
+
|
12
|
+
Veda is still in prerelease. But you can get a sneak peek by running:
|
13
|
+
|
14
|
+
``` ruby
|
15
|
+
gem install veda --pre
|
16
|
+
```
|
17
|
+
|
18
|
+
In case you use RBENV type ``rbenv rehash`` to make the ``veda`` command available.
|
19
|
+
Then go in to a directory with markdown and type:
|
20
|
+
|
21
|
+
``` shell
|
22
|
+
veda
|
23
|
+
```
|
24
|
+
|
25
|
+
to start the veda server. You can then browse to ``http://localhost:4567`` to read the
|
26
|
+
documentation.
|
27
|
+
|
28
|
+
## Installing Veda documentation
|
29
|
+
|
30
|
+
Veda makes it easy to download and view documentation written on github.
|
31
|
+
|
32
|
+
```
|
33
|
+
veda install emilebosch/guides
|
34
|
+
```
|
35
|
+
|
36
|
+
It will clone the repo from github, install it in ``~/.veda/library/emilebosch/guides``.
|
37
|
+
|
38
|
+
To view a list of locally installed documentation type:
|
39
|
+
|
40
|
+
```
|
41
|
+
veda list
|
42
|
+
```
|
43
|
+
|
44
|
+
## Mounting Veda in Rails apps
|
45
|
+
|
46
|
+
You can mount Veda also in your rails app like any other rack app. This allows you
|
47
|
+
to expose your documentation fast and easy. Just put this baby in your ``routes.rb``
|
48
|
+
|
49
|
+
``` ruby
|
50
|
+
mount Veda::Server.new("my-haikus", Rails.root) => "/haiku"
|
51
|
+
```
|
52
|
+
|
53
|
+
## Extending Veda
|
54
|
+
|
55
|
+
You can extend veda by placing a ``Vedafile`` in a directory. This will be loaded runtime.
|
56
|
+
|
57
|
+
You can then freedompatch Veda into awesomeness.
|
58
|
+
|
59
|
+
### Providing your own views
|
60
|
+
|
61
|
+
For instance, u can provide your own views, u can just patch the ``Veda::Server``.
|
62
|
+
|
63
|
+
``` ruby
|
64
|
+
class Veda::Server
|
65
|
+
set :root, File.dirname(__FILE__)
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
## Hacking on Veda
|
70
|
+
|
71
|
+
Yes, please help out and make Veda awesome! I need your mad skills to take this further.
|
72
|
+
|
73
|
+
Fork, clone and cd this repo:
|
74
|
+
|
75
|
+
```
|
76
|
+
git@github.com:emilebosch/veda.git
|
77
|
+
cd veda
|
78
|
+
```
|
79
|
+
|
80
|
+
Now, because Veda, relies on git, there is a git repo in a git repo. (GITCEPTION! OMG!) Anyway,
|
81
|
+
since, i haven't found an elegant way to do this yet (Please PR one!) You need
|
82
|
+
to run ``rake unzip`` to unzip the test repo.
|
83
|
+
|
84
|
+
So in short, to test:
|
85
|
+
|
86
|
+
```
|
87
|
+
rake unzip
|
88
|
+
rake
|
89
|
+
```
|
data/bin/veda
ADDED
data/config.ru
ADDED
data/lib/veda.rb
ADDED
data/lib/veda/cli.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Veda
|
4
|
+
class Cli < Thor
|
5
|
+
default_task :start
|
6
|
+
|
7
|
+
desc "start", "Start the veda webserver"
|
8
|
+
def start
|
9
|
+
start_server
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "install [REPO]", "Install and view documentation from github, i.e. `veda install emilebosch/guides`"
|
13
|
+
def install(repo)
|
14
|
+
path = library_path(repo)
|
15
|
+
unless File.exist? path
|
16
|
+
`mkdir -p #{path}`
|
17
|
+
`git clone git@github.com:#{repo}.git #{path}`
|
18
|
+
end
|
19
|
+
Dir.chdir(path)
|
20
|
+
start_server
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "list","List locally installed vedas"
|
24
|
+
def list
|
25
|
+
puts "Installed vedas in #{library_path}"
|
26
|
+
for path in Dir.glob "#{library_path}*/*"
|
27
|
+
base, name = path.split(library_path)
|
28
|
+
puts "- #{name}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "version", "Shows version information"
|
33
|
+
def version
|
34
|
+
puts Veda::VERSION
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "update [REPO]", "Update a locally installed veda"
|
38
|
+
def update(repo)
|
39
|
+
puts `cd #{library_path(repo)} && git pull`
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "library", "Run in veda library mode"
|
43
|
+
def library
|
44
|
+
start_library
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "powify [NAME]", "Installs veda under Pow (defaults to veda.dev)"
|
48
|
+
def powify(domain='veda', force=false)
|
49
|
+
abort("Hmm.. pow doesn't seem to be installed. Can't find the directory #{pow_dir}") unless File.exists? pow_dir
|
50
|
+
|
51
|
+
dir = File.join(pow_dir, domain)
|
52
|
+
abort("Link already exists #{dir} -> #{File.readlink(dir)}, use -force=true to relink!") if File.exists? dir unless force
|
53
|
+
|
54
|
+
FileUtils.rm_f(dir) if force
|
55
|
+
FileUtils.ln_s(gem_dir, dir)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def gem_dir
|
61
|
+
File.dirname(File.dirname(File.dirname(__FILE__)))
|
62
|
+
end
|
63
|
+
|
64
|
+
def pow_dir
|
65
|
+
File.join(Dir.home, ".pow")
|
66
|
+
end
|
67
|
+
|
68
|
+
def start_library
|
69
|
+
Veda::Library.run!
|
70
|
+
end
|
71
|
+
|
72
|
+
def start_server
|
73
|
+
Veda::Server.run!
|
74
|
+
end
|
75
|
+
|
76
|
+
def library_path(guide=nil)
|
77
|
+
path = "#{Dir.home}/.veda/library/#{guide}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'hashie'
|
3
|
+
|
4
|
+
module Veda
|
5
|
+
class Documentation
|
6
|
+
|
7
|
+
def initialize(directory = nil, repo = nil)
|
8
|
+
@directory = directory
|
9
|
+
@repo = repo
|
10
|
+
end
|
11
|
+
|
12
|
+
def fetch(file)
|
13
|
+
path = make_path("#{file}.md")
|
14
|
+
|
15
|
+
data = { title: file }
|
16
|
+
contents = File.read path
|
17
|
+
match = contents.match /---(.*?)---(.*)/m
|
18
|
+
if match
|
19
|
+
data = YAML::load(match[1])
|
20
|
+
contents = match[2]
|
21
|
+
end
|
22
|
+
|
23
|
+
pages = contents.split '<!-- break -->'
|
24
|
+
scm_file = ScmFile.new @repo, path
|
25
|
+
|
26
|
+
Hashie::Mash.new(data.merge!(pages: pages, scm_file: scm_file, contents: contents, id: File.basename(file, '.md')))
|
27
|
+
end
|
28
|
+
|
29
|
+
def make_path(file)
|
30
|
+
@directory ? "#{@directory}/#{file}" : file
|
31
|
+
end
|
32
|
+
|
33
|
+
def collection
|
34
|
+
files = Dir.glob make_path("*.md")
|
35
|
+
files.collect { |file| fetch(File.basename(file,'.md')) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
.CodeRay pre {
|
2
|
+
margin: 0px;
|
3
|
+
}
|
4
|
+
|
5
|
+
span.CodeRay { white-space: pre; border: 0px; padding: 2px; }
|
6
|
+
table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px; }
|
7
|
+
table.CodeRay td { padding: 2px 4px; vertical-align: top; }
|
8
|
+
|
9
|
+
.CodeRay .line-numbers {
|
10
|
+
background-color: hsl(180,65%,90%);
|
11
|
+
color: gray;
|
12
|
+
text-align: right;
|
13
|
+
-webkit-user-select: none;
|
14
|
+
-moz-user-select: none;
|
15
|
+
user-select: none;
|
16
|
+
}
|
17
|
+
.CodeRay .line-numbers a {
|
18
|
+
background-color: hsl(180,65%,90%) !important;
|
19
|
+
color: gray !important;
|
20
|
+
text-decoration: none !important;
|
21
|
+
}
|
22
|
+
.CodeRay .line-numbers pre {
|
23
|
+
word-break: normal;
|
24
|
+
}
|
25
|
+
.CodeRay .line-numbers a:target { color: blue !important; }
|
26
|
+
.CodeRay .line-numbers .highlighted { color: red !important; }
|
27
|
+
.CodeRay .line-numbers .highlighted a { color: red !important; }
|
28
|
+
.CodeRay span.line-numbers { padding: 0px 4px; }
|
29
|
+
.CodeRay .line { display: block; float: left; width: 100%; }
|
30
|
+
.CodeRay .code { width: 100%; }
|
31
|
+
|
32
|
+
.CodeRay .debug { color: white !important; background: blue !important; }
|
33
|
+
|
34
|
+
.CodeRay .annotation { color:#007 }
|
35
|
+
.CodeRay .attribute-name { color:#b48 }
|
36
|
+
.CodeRay .attribute-value { color:#700 }
|
37
|
+
.CodeRay .binary { color:#549 }
|
38
|
+
.CodeRay .binary .char { color:#325 }
|
39
|
+
.CodeRay .binary .delimiter { color:#325 }
|
40
|
+
.CodeRay .char { color:#D20 }
|
41
|
+
.CodeRay .char .content { color:#D20 }
|
42
|
+
.CodeRay .char .delimiter { color:#710 }
|
43
|
+
.CodeRay .class { color:#B06; }
|
44
|
+
.CodeRay .class-variable { color:#369 }
|
45
|
+
.CodeRay .color { color:#0A0 }
|
46
|
+
.CodeRay .comment { color:#777 }
|
47
|
+
.CodeRay .comment .char { color:#444 }
|
48
|
+
.CodeRay .comment .delimiter { color:#444 }
|
49
|
+
.CodeRay .constant { color:#036; }
|
50
|
+
.CodeRay .decorator { color:#B0B }
|
51
|
+
.CodeRay .definition { color:#099; }
|
52
|
+
.CodeRay .delimiter { color:black }
|
53
|
+
.CodeRay .directive { color:#088; }
|
54
|
+
.CodeRay .docstring { color:#D42; }
|
55
|
+
.CodeRay .doctype { color:#34b }
|
56
|
+
.CodeRay .done { text-decoration: line-through; color: gray }
|
57
|
+
.CodeRay .entity { color:#800; }
|
58
|
+
.CodeRay .error { color:#F00; background-color:#FAA }
|
59
|
+
.CodeRay .escape { color:#666 }
|
60
|
+
.CodeRay .exception { color:#C00; }
|
61
|
+
.CodeRay .float { color:#60E }
|
62
|
+
.CodeRay .function { color:#06B; }
|
63
|
+
.CodeRay .function .delimiter { color:#024; }
|
64
|
+
.CodeRay .global-variable { color:#d70 }
|
65
|
+
.CodeRay .hex { color:#02b }
|
66
|
+
.CodeRay .id { color:#33D; }
|
67
|
+
.CodeRay .include { color:#B44; }
|
68
|
+
.CodeRay .inline { background-color: hsla(0,0%,0%,0.07); color: black }
|
69
|
+
.CodeRay .inline-delimiter { font-weight: bold; color: #666 }
|
70
|
+
.CodeRay .instance-variable { color:#33B }
|
71
|
+
.CodeRay .integer { color:#00D }
|
72
|
+
.CodeRay .imaginary { color:#f00 }
|
73
|
+
.CodeRay .important { color:#D00 }
|
74
|
+
.CodeRay .key { color: #606 }
|
75
|
+
.CodeRay .key .char { color: #60f }
|
76
|
+
.CodeRay .key .delimiter { color: #404 }
|
77
|
+
.CodeRay .keyword { color:#080; }
|
78
|
+
.CodeRay .label { color:#970; }
|
79
|
+
.CodeRay .local-variable { color:#950 }
|
80
|
+
.CodeRay .map .content { color:#808 }
|
81
|
+
.CodeRay .map .delimiter { color:#40A}
|
82
|
+
.CodeRay .map { background-color:hsla(200,100%,50%,0.06); }
|
83
|
+
.CodeRay .namespace { color:#707; }
|
84
|
+
.CodeRay .octal { color:#40E }
|
85
|
+
.CodeRay .operator { }
|
86
|
+
.CodeRay .predefined { color:#369; }
|
87
|
+
.CodeRay .predefined-constant { color:#069 }
|
88
|
+
.CodeRay .predefined-type { color:#0a8; }
|
89
|
+
.CodeRay .preprocessor { color:#579 }
|
90
|
+
.CodeRay .pseudo-class { color:#00C; }
|
91
|
+
.CodeRay .regexp { background-color:hsla(300,100%,50%,0.06); }
|
92
|
+
.CodeRay .regexp .content { color:#808 }
|
93
|
+
.CodeRay .regexp .delimiter { color:#404 }
|
94
|
+
.CodeRay .regexp .modifier { color:#C2C }
|
95
|
+
.CodeRay .reserved { color:#080; }
|
96
|
+
.CodeRay .shell { background-color:hsla(120,100%,50%,0.06); }
|
97
|
+
.CodeRay .shell .content { color:#2B2 }
|
98
|
+
.CodeRay .shell .delimiter { color:#161 }
|
99
|
+
.CodeRay .string { background-color:hsla(0,100%,50%,0.05); }
|
100
|
+
.CodeRay .string .char { color: #b0b }
|
101
|
+
.CodeRay .string .content { color: #D20 }
|
102
|
+
.CodeRay .string .delimiter { color: #710 }
|
103
|
+
.CodeRay .string .modifier { color: #E40 }
|
104
|
+
.CodeRay .symbol { color:#A60 }
|
105
|
+
.CodeRay .symbol .content { color:#A60 }
|
106
|
+
.CodeRay .symbol .delimiter { color:#740 }
|
107
|
+
.CodeRay .tag { color:#070; }
|
108
|
+
.CodeRay .type { color:#339; }
|
109
|
+
.CodeRay .value { color: #088 }
|
110
|
+
.CodeRay .variable { color:#037 }
|
111
|
+
|
112
|
+
.CodeRay .insert { background: hsla(120,100%,50%,0.12) }
|
113
|
+
.CodeRay .delete { background: hsla(0,100%,50%,0.12) }
|
114
|
+
.CodeRay .change { color: #bbf; background: #007 }
|
115
|
+
.CodeRay .head { color: #f8f; background: #505 }
|
116
|
+
.CodeRay .head .filename { color: white; }
|
117
|
+
|
118
|
+
.CodeRay .delete .eyecatcher { background-color: hsla(0,100%,50%,0.2); border: 1px solid hsla(0,100%,45%,0.5); margin: -1px; border-bottom: none; border-top-left-radius: 5px; border-top-right-radius: 5px; }
|
119
|
+
.CodeRay .insert .eyecatcher { background-color: hsla(120,100%,50%,0.2); border: 1px solid hsla(120,100%,25%,0.5); margin: -1px; border-top: none; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }
|
120
|
+
|
121
|
+
.CodeRay .insert .insert { color: #0c0; background:transparent; }
|
122
|
+
.CodeRay .delete .delete { color: #c00; background:transparent; }
|
123
|
+
.CodeRay .change .change { color: #88f }
|
124
|
+
.CodeRay .head .head { color: #f4f }
|
@@ -0,0 +1,134 @@
|
|
1
|
+
.last-commit {
|
2
|
+
background-color:#efefef;
|
3
|
+
padding:10px;
|
4
|
+
border-radius:3px;
|
5
|
+
margin:10px 0px;
|
6
|
+
}
|
7
|
+
|
8
|
+
body {
|
9
|
+
padding:20px;
|
10
|
+
font-family:helvetica;
|
11
|
+
font-size:13px;
|
12
|
+
background-color:#f9f8f6;
|
13
|
+
line-height: 1.6
|
14
|
+
}
|
15
|
+
|
16
|
+
.nav {
|
17
|
+
border-bottom:1px solid #efefef;
|
18
|
+
padding-bottom:15px;
|
19
|
+
margin-bottom:10px;
|
20
|
+
}
|
21
|
+
|
22
|
+
a {
|
23
|
+
color:#a0a0a0;
|
24
|
+
}
|
25
|
+
|
26
|
+
.authors {
|
27
|
+
margin:0px;
|
28
|
+
padding:0px;
|
29
|
+
margin-top:-10px;
|
30
|
+
list-style:none;
|
31
|
+
margin-bottom:5px;
|
32
|
+
}
|
33
|
+
|
34
|
+
.authors li {
|
35
|
+
display:inline-block;
|
36
|
+
margin-left:5px;
|
37
|
+
}
|
38
|
+
|
39
|
+
.authors img {
|
40
|
+
border-radius:3px;
|
41
|
+
height:30px;
|
42
|
+
width:30px;
|
43
|
+
}
|
44
|
+
|
45
|
+
.page {
|
46
|
+
width:900px; margin:0 auto;
|
47
|
+
border:1px solid #efefef;
|
48
|
+
padding:20px;
|
49
|
+
background-color:white;
|
50
|
+
border-radius:3px;
|
51
|
+
}
|
52
|
+
|
53
|
+
h1 {
|
54
|
+
margin-top:0px;
|
55
|
+
}
|
56
|
+
|
57
|
+
pre>code {
|
58
|
+
padding:10px;
|
59
|
+
display:block;
|
60
|
+
border:1px solid rgb(255,233,186);
|
61
|
+
border-radius:3px;
|
62
|
+
background-color:#fef9ec;
|
63
|
+
}
|
64
|
+
|
65
|
+
code {
|
66
|
+
color:orange;
|
67
|
+
border: 1px solid #ebe8e0;
|
68
|
+
background: #f9f8f6;
|
69
|
+
color:#454545;
|
70
|
+
padding:1px 3px;
|
71
|
+
border-radius:2px;
|
72
|
+
}
|
73
|
+
|
74
|
+
.email, .comment, .rev, .date {
|
75
|
+
display:inline-block;
|
76
|
+
}
|
77
|
+
|
78
|
+
.date {
|
79
|
+
width:90px;
|
80
|
+
}
|
81
|
+
|
82
|
+
.rev {
|
83
|
+
width: 60px;
|
84
|
+
background-color: #efefef;
|
85
|
+
border-radius: 3px;
|
86
|
+
text-align: center;
|
87
|
+
color: #404040;
|
88
|
+
background-color:#fef9ec;
|
89
|
+
margin-right: 10px;
|
90
|
+
}
|
91
|
+
|
92
|
+
.commits {
|
93
|
+
border-top:1px solid #efefef;
|
94
|
+
margin:0px;
|
95
|
+
margin-top:20px;
|
96
|
+
padding:0px;
|
97
|
+
list-style:none;
|
98
|
+
padding:20px;
|
99
|
+
padding-bottom:0px;
|
100
|
+
}
|
101
|
+
|
102
|
+
.commits li {
|
103
|
+
margin:0px;
|
104
|
+
padding:0px;
|
105
|
+
margin-bottom: 2px;
|
106
|
+
}
|
107
|
+
|
108
|
+
.commits img {
|
109
|
+
margin-right: 5px;
|
110
|
+
width: 19px;
|
111
|
+
height: 19px;
|
112
|
+
border-radius: 2px;
|
113
|
+
vertical-align: top;
|
114
|
+
}
|
115
|
+
|
116
|
+
.warn {
|
117
|
+
background-color:#FFF5D1;
|
118
|
+
padding:10px;
|
119
|
+
border-radius:3px;
|
120
|
+
}
|
121
|
+
|
122
|
+
pre {
|
123
|
+
margin:0px;
|
124
|
+
padding:0px;
|
125
|
+
}
|
126
|
+
|
127
|
+
.CodeRay {
|
128
|
+
padding:10px;
|
129
|
+
display:block;
|
130
|
+
border:1px solid rgb(255,233,186);
|
131
|
+
border-radius:3px;
|
132
|
+
background-color:#fef9ec;
|
133
|
+
color:#454545;
|
134
|
+
}
|
data/lib/veda/scm.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'git'
|
2
|
+
|
3
|
+
module Veda
|
4
|
+
class ScmFile
|
5
|
+
|
6
|
+
def initialize(repo, file)
|
7
|
+
@git = Git.open(repo || '.')
|
8
|
+
@log = @git.log(20).object(file)
|
9
|
+
@status = @git.status[file]
|
10
|
+
end
|
11
|
+
|
12
|
+
def log
|
13
|
+
@log.collect { | c | Hashie::Mash.new({ rev: c.sha[0,7], author: c.author.name, email: c.author.email, comment: c.message, date: c.date }) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def status
|
17
|
+
@status
|
18
|
+
end
|
19
|
+
|
20
|
+
def authors
|
21
|
+
log.sort_by { |x| x[:date] }
|
22
|
+
.reverse
|
23
|
+
.group_by { |x| x[:author] }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/veda/server.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require "sinatra/reloader"
|
3
|
+
require 'slim'
|
4
|
+
require 'coderay'
|
5
|
+
require 'redcarpet'
|
6
|
+
|
7
|
+
module Veda
|
8
|
+
class MarkdownRenderer < Redcarpet::Render::HTML
|
9
|
+
def block_code(code, language)
|
10
|
+
CodeRay.highlight(code, language || 'none')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Helpers
|
15
|
+
def date(date)
|
16
|
+
date.strftime('%b %e, %Y')
|
17
|
+
end
|
18
|
+
|
19
|
+
def markdown(text)
|
20
|
+
rndr = MarkdownRenderer.new(:filter_html => true)
|
21
|
+
options = {
|
22
|
+
:fenced_code_blocks => true,
|
23
|
+
:no_intra_emphasis => true,
|
24
|
+
:autolink => true,
|
25
|
+
:strikethrough => true,
|
26
|
+
:lax_html_blocks => true,
|
27
|
+
:superscript => true
|
28
|
+
}
|
29
|
+
markdown_to_html = Redcarpet::Markdown.new(rndr, options)
|
30
|
+
markdown_to_html.render(text)
|
31
|
+
end
|
32
|
+
|
33
|
+
def gravatar(email)
|
34
|
+
gravatar_id = Digest::MD5.hexdigest(email.downcase)
|
35
|
+
"http://gravatar.com/avatar/#{gravatar_id}.png"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Server < Sinatra::Base
|
40
|
+
helpers Veda::Helpers
|
41
|
+
register Sinatra::Reloader if development?
|
42
|
+
|
43
|
+
def initialize(path=nil, repo=nil)
|
44
|
+
@documentation = Veda::Documentation.new(path, repo)
|
45
|
+
super()
|
46
|
+
end
|
47
|
+
|
48
|
+
get '/' do
|
49
|
+
slim :index
|
50
|
+
end
|
51
|
+
|
52
|
+
get '/:file' do
|
53
|
+
@page = @documentation.fetch params[:file]
|
54
|
+
slim :show
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class Library < Sinatra::Base
|
59
|
+
register Sinatra::Reloader if development?
|
60
|
+
|
61
|
+
get '/' do
|
62
|
+
@files = Dir.glob("#{home}/*/*").collect { |f| f.gsub home, '' }
|
63
|
+
slim :library
|
64
|
+
end
|
65
|
+
|
66
|
+
get '/*' do
|
67
|
+
parts = env['PATH_INFO'].split('/').reject(&:empty?)
|
68
|
+
return unless parts.length >= 2
|
69
|
+
|
70
|
+
dir = "#{parts[0]}/#{parts[1]}"
|
71
|
+
|
72
|
+
env['PATH_INFO'] = env['PATH_INFO'].gsub(dir,'')
|
73
|
+
env['SCRIPT_NAME'] = dir
|
74
|
+
|
75
|
+
path = File.join(home, dir)
|
76
|
+
|
77
|
+
Dir.chdir(path)
|
78
|
+
Server.new.call(env)
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def home
|
84
|
+
"#{Dir.home}/.veda/Library"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/veda/version.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
- @title = @page.title
|
2
|
+
|
3
|
+
.nav
|
4
|
+
a(href=url('/')) Go to index
|
5
|
+
|
6
|
+
h1=@page.title
|
7
|
+
|
8
|
+
- if @page.scm_file.status.sha_repo=="0000000000000000000000000000000000000000"
|
9
|
+
.warn Heya, this file is staged but not commited! You can commit this via `git commit`
|
10
|
+
|
11
|
+
- if @page.scm_file.status.untracked
|
12
|
+
.warn Heya, this file is untracked! You can add it to the git repository via `git add`
|
13
|
+
|
14
|
+
- unless @page.scm_file.status.untracked
|
15
|
+
ul.authors
|
16
|
+
- for name, y in @page.scm_file.authors
|
17
|
+
li: img width=40 height=40 src=gravatar(y[0].email) title="#{name} (#{y[0].email})"
|
18
|
+
|
19
|
+
- unless @page.scm_file.log.length == 0
|
20
|
+
span Created by #{@page.scm_file.log.last.author} on #{date(@page.scm_file.log.last.date)}, latest edit #{@page.scm_file.log.first.date.strftime('%b %e, %Y')} by #{@page.scm_file.log.first.author}.
|
21
|
+
|
22
|
+
.last-commit #{@page.scm_file.log.first.comment} - #{date(@page.scm_file.log.first.date)}
|
23
|
+
|
24
|
+
==markdown(@page.contents)
|
25
|
+
|
26
|
+
- unless @page.scm_file.log.length == 0
|
27
|
+
ul.commits
|
28
|
+
- for log in @page.scm_file.log
|
29
|
+
li
|
30
|
+
.email: img src=gravatar(log.email)
|
31
|
+
.rev=log.rev
|
32
|
+
.date=date(log.date)
|
33
|
+
.comment=log.comment
|
metadata
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: veda
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emile Bosch
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sinatra
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: slim
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hashie
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: git
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sinatra-contrib
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coderay
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: redcarpet
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: guard
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: guard-shell
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description: Collaborative git based documentation
|
182
|
+
email: emilebosch@me.com
|
183
|
+
executables:
|
184
|
+
- veda
|
185
|
+
extensions: []
|
186
|
+
extra_rdoc_files: []
|
187
|
+
files:
|
188
|
+
- lib/veda/cli.rb
|
189
|
+
- lib/veda/documentation.rb
|
190
|
+
- lib/veda/public/css/coderay.css
|
191
|
+
- lib/veda/public/css/style.css
|
192
|
+
- lib/veda/scm.rb
|
193
|
+
- lib/veda/server.rb
|
194
|
+
- lib/veda/version.rb
|
195
|
+
- lib/veda/views/index.slim
|
196
|
+
- lib/veda/views/layout.slim
|
197
|
+
- lib/veda/views/library.slim
|
198
|
+
- lib/veda/views/show.slim
|
199
|
+
- lib/veda.rb
|
200
|
+
- README.md
|
201
|
+
- config.ru
|
202
|
+
- bin/veda
|
203
|
+
homepage: https://github.com/emilebosch/veda
|
204
|
+
licenses:
|
205
|
+
- MIT
|
206
|
+
metadata: {}
|
207
|
+
post_install_message:
|
208
|
+
rdoc_options: []
|
209
|
+
require_paths:
|
210
|
+
- lib
|
211
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - '>='
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - '>'
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: 1.3.1
|
221
|
+
requirements: []
|
222
|
+
rubyforge_project:
|
223
|
+
rubygems_version: 2.0.2
|
224
|
+
signing_key:
|
225
|
+
specification_version: 4
|
226
|
+
summary: Veda
|
227
|
+
test_files: []
|
228
|
+
has_rdoc:
|