nwiki 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.org +2 -0
- data/Gemfile.lock +19 -17
- data/lib/nwiki/frontend/app/html.rb +4 -4
- data/lib/nwiki/frontend/app/top.rb +4 -4
- data/lib/nwiki/frontend/app.rb +37 -35
- data/lib/nwiki/utils.rb +15 -0
- data/lib/nwiki/version.rb +1 -1
- data/lib/nwiki.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 609576afeda6cc82444c04db2af2e13365de24f0
|
4
|
+
data.tar.gz: d129328ecf29465291517a2a1ee0696d0d849ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a581ca3dd2f278ead5a5c48a1872d0139d2131446e92e01fed1599c1cead0cb8ebc142d88eb2130e5642d22487266d884144e56e113edbefc46bd5adccaaa75
|
7
|
+
data.tar.gz: f24750c7c0da3439456b6e88e584f5900bc47cf5bf656416253c3a2aced34ad8fd48feac51701ef15a259aaf5ce0424b0c0f799f58d4eb55b4d2ee5d98a91ead
|
data/CHANGELOG.org
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/libgit2/rugged.git
|
3
|
-
revision:
|
3
|
+
revision: 12b8de15ec588d84f89e2527ef1e935e36879ddf
|
4
4
|
branch: development
|
5
5
|
submodules: true
|
6
6
|
specs:
|
@@ -17,7 +17,7 @@ GIT
|
|
17
17
|
PATH
|
18
18
|
remote: .
|
19
19
|
specs:
|
20
|
-
nwiki (0.2.
|
20
|
+
nwiki (0.2.1)
|
21
21
|
org-ruby
|
22
22
|
rack
|
23
23
|
rack-git
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
term-ansicolor
|
37
37
|
thor
|
38
38
|
diff-lcs (1.2.5)
|
39
|
-
docile (1.1.
|
39
|
+
docile (1.1.5)
|
40
40
|
ffi (1.9.3)
|
41
41
|
formatador (0.2.5)
|
42
42
|
guard (2.6.1)
|
@@ -45,22 +45,23 @@ GEM
|
|
45
45
|
lumberjack (~> 1.0)
|
46
46
|
pry (>= 0.9.12)
|
47
47
|
thor (>= 0.18.1)
|
48
|
-
guard-rspec (4.2.
|
48
|
+
guard-rspec (4.2.10)
|
49
49
|
guard (~> 2.1)
|
50
50
|
rspec (>= 2.14, < 4.0)
|
51
|
-
listen (2.7.
|
51
|
+
listen (2.7.9)
|
52
52
|
celluloid (>= 0.15.2)
|
53
53
|
rb-fsevent (>= 0.9.3)
|
54
54
|
rb-inotify (>= 0.9)
|
55
|
-
lumberjack (1.0.
|
55
|
+
lumberjack (1.0.9)
|
56
56
|
method_source (0.8.2)
|
57
57
|
mime-types (2.3)
|
58
58
|
multi_json (1.10.1)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
netrc (0.7.7)
|
60
|
+
org-ruby (0.9.7)
|
61
|
+
rubypants (~> 0.2)
|
62
|
+
pry (0.10.0)
|
63
|
+
coderay (~> 1.1.0)
|
64
|
+
method_source (~> 0.8.1)
|
64
65
|
slop (~> 3.4)
|
65
66
|
rack (1.5.2)
|
66
67
|
rack-rewrite (1.5.0)
|
@@ -70,20 +71,21 @@ GEM
|
|
70
71
|
rb-fsevent (0.9.4)
|
71
72
|
rb-inotify (0.9.5)
|
72
73
|
ffi (>= 0.5.0)
|
73
|
-
rest-client (1.
|
74
|
-
mime-types (>= 1.16)
|
74
|
+
rest-client (1.7.1)
|
75
|
+
mime-types (>= 1.16, < 3.0)
|
76
|
+
netrc (~> 0.7)
|
75
77
|
rspec (3.0.0)
|
76
78
|
rspec-core (~> 3.0.0)
|
77
79
|
rspec-expectations (~> 3.0.0)
|
78
80
|
rspec-mocks (~> 3.0.0)
|
79
|
-
rspec-core (3.0.
|
81
|
+
rspec-core (3.0.2)
|
80
82
|
rspec-support (~> 3.0.0)
|
81
|
-
rspec-expectations (3.0.
|
83
|
+
rspec-expectations (3.0.2)
|
82
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
83
85
|
rspec-support (~> 3.0.0)
|
84
|
-
rspec-mocks (3.0.
|
86
|
+
rspec-mocks (3.0.2)
|
85
87
|
rspec-support (~> 3.0.0)
|
86
|
-
rspec-support (3.0.
|
88
|
+
rspec-support (3.0.2)
|
87
89
|
ruby_gntp (0.3.4)
|
88
90
|
rubypants (0.2.0)
|
89
91
|
simplecov (0.8.2)
|
@@ -29,8 +29,8 @@ module Nwiki
|
|
29
29
|
<title><%= page_title %><%= @wiki.title %></title>
|
30
30
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
31
31
|
<link rel="alternate" type="application/atom+xml" title="ATOM Feed" href="/articles.xml">
|
32
|
-
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0
|
33
|
-
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0
|
32
|
+
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
|
33
|
+
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
|
34
34
|
</head>
|
35
35
|
<body>
|
36
36
|
<a href="https://github.com/niku/nikulog">
|
@@ -49,8 +49,8 @@ module Nwiki
|
|
49
49
|
</div>
|
50
50
|
</div>
|
51
51
|
</div>
|
52
|
-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
|
53
|
-
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0
|
52
|
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
53
|
+
<script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
54
54
|
</body>
|
55
55
|
</html>
|
56
56
|
EOS
|
@@ -25,8 +25,8 @@ module Nwiki
|
|
25
25
|
<title><%= @wiki.title %></title>
|
26
26
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
27
27
|
<link rel="alternate" type="application/atom+xml" title="ATOM Feed" href="/articles.xml">
|
28
|
-
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0
|
29
|
-
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0
|
28
|
+
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
|
29
|
+
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
|
30
30
|
</head>
|
31
31
|
<body>
|
32
32
|
<a href="https://github.com/niku/nikulog">
|
@@ -45,8 +45,8 @@ module Nwiki
|
|
45
45
|
</div>
|
46
46
|
</div>
|
47
47
|
</div>
|
48
|
-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
|
49
|
-
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0
|
48
|
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
49
|
+
<script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
50
50
|
</body>
|
51
51
|
</html>
|
52
52
|
EOS
|
data/lib/nwiki/frontend/app.rb
CHANGED
@@ -10,7 +10,9 @@ require_relative 'app/html'
|
|
10
10
|
module Nwiki
|
11
11
|
module Frontend
|
12
12
|
class App
|
13
|
-
|
13
|
+
Rack::Mime::MIME_TYPES.merge!({ ".org" => "text/html" })
|
14
|
+
|
15
|
+
TEMPLATE = -> (wiki, page_title, html) {
|
14
16
|
erb = ERB.new <<EOS
|
15
17
|
<!DOCTYPE HTML>
|
16
18
|
<html>
|
@@ -18,8 +20,8 @@ module Nwiki
|
|
18
20
|
<title><%= page_title %><%= wiki.title %></title>
|
19
21
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
20
22
|
<link rel="alternate" type="application/atom+xml" title="ATOM Feed" href="/articles.xml">
|
21
|
-
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0
|
22
|
-
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0
|
23
|
+
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
|
24
|
+
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
|
23
25
|
</head>
|
24
26
|
<body>
|
25
27
|
<a href="https://github.com/niku/nikulog">
|
@@ -38,44 +40,42 @@ module Nwiki
|
|
38
40
|
</div>
|
39
41
|
</div>
|
40
42
|
</div>
|
41
|
-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
|
42
|
-
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0
|
43
|
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
44
|
+
<script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
43
45
|
</body>
|
44
46
|
</html>
|
45
47
|
EOS
|
46
48
|
erb.result(binding).force_encoding("UTF-8")
|
47
|
-
|
49
|
+
}
|
48
50
|
|
49
|
-
|
50
|
-
Rack::
|
51
|
+
FILE_CONVERTER = -> (wiki, template, file, env) {
|
52
|
+
path = Rack::Utils.unescape(env["PATH_INFO"])
|
53
|
+
return file unless Nwiki::Utils.orgfile?(path)
|
54
|
+
page_title = Nwiki::Utils.page_title(path)
|
55
|
+
file.force_encoding("UTF-8")
|
56
|
+
html = Orgmode::Parser.new(file, offset: 1).to_html
|
57
|
+
template.call(wiki, page_title, html)
|
58
|
+
}.curry
|
59
|
+
|
60
|
+
DIRECTORY_CONVERTER = -> (wiki, template, file, env) {
|
61
|
+
path = Rack::Utils.unescape(env["PATH_INFO"])
|
62
|
+
if path == '/'
|
63
|
+
page_title = Nwiki::Utils.page_title(path)
|
64
|
+
html = wiki.find_directory("/").to_html
|
65
|
+
template.call(wiki, page_title, html)
|
66
|
+
else
|
67
|
+
page_title = Nwiki::Utils.page_title(path)
|
68
|
+
list = dirs.
|
69
|
+
each { |d| d.force_encoding("UTF-8") }.
|
70
|
+
map { |e| Nwiki::Utils.strip_org(e) }.
|
71
|
+
map { |e| %Q!<li><a href="#{e}">#{e}</a></li>! }
|
72
|
+
html = "<ul><li><a href=\"../\">../</a></li>#{list.join}</ul>"
|
73
|
+
template.call(wiki, page_title, html)
|
74
|
+
end
|
75
|
+
}.curry
|
51
76
|
|
77
|
+
def initialize git_repo_path
|
52
78
|
wiki = Core::Wiki.new git_repo_path
|
53
|
-
file_converter = -> (file, env) {
|
54
|
-
path = Rack::Utils.unescape(env["PATH_INFO"])
|
55
|
-
return file if ::File.extname(path) != ".org"
|
56
|
-
file.force_encoding("UTF-8")
|
57
|
-
page_title = path.empty? ? '' : "#{path.gsub(/\.org$/, '').gsub(/^\//, '')} - "
|
58
|
-
html = if ::File.extname(path) == ".org"
|
59
|
-
Orgmode::Parser.new(file, offset: 1).to_html
|
60
|
-
else
|
61
|
-
file
|
62
|
-
end
|
63
|
-
template(wiki, page_title, html)
|
64
|
-
}
|
65
|
-
directory_converter = -> (dirs, env) {
|
66
|
-
path = Rack::Utils.unescape(env["PATH_INFO"])
|
67
|
-
if path == '/'
|
68
|
-
page_title = path.empty? ? '' : "#{path.gsub(/\.org$/, '').gsub(/^\//, '')} - "
|
69
|
-
html = wiki.find_directory("/").to_html
|
70
|
-
template(wiki, page_title, html)
|
71
|
-
else
|
72
|
-
dirs.each { |d| d.force_encoding("UTF-8") }
|
73
|
-
page_title = path.empty? ? '' : "#{path.gsub(/\.org$/, '').gsub(/^\//, '')} - "
|
74
|
-
list = dirs.map { |e| %Q!<li><a href="#{e.gsub(/\.org/, '')}">#{e.gsub(/\.org/, '')}</a></li>! }
|
75
|
-
html = "<ul><li><a href=\"../\">../</a></li>#{list.join}</ul>"
|
76
|
-
template(wiki, page_title, html)
|
77
|
-
end
|
78
|
-
}
|
79
79
|
|
80
80
|
@builder = Rack::Builder.new {
|
81
81
|
map '/' do
|
@@ -91,7 +91,9 @@ EOS
|
|
91
91
|
path !~ /\/$/ && File.extname(path) !~ /(png|jpg|gif)/
|
92
92
|
}
|
93
93
|
end
|
94
|
-
run Rack::Git::File.new git_repo_path,
|
94
|
+
run Rack::Git::File.new git_repo_path,
|
95
|
+
file_converter: FILE_CONVERTER.call(wiki, TEMPLATE),
|
96
|
+
directory_converter: DIRECTORY_CONVERTER.call(wiki, TEMPLATE)
|
95
97
|
end
|
96
98
|
}
|
97
99
|
end
|
data/lib/nwiki/utils.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Nwiki
|
2
|
+
module Utils
|
3
|
+
def self.page_title path
|
4
|
+
path.empty? ? '' : "#{path.gsub(/\.org$/, '').gsub(/^\//, '')} - "
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.orgfile? path
|
8
|
+
::File.extname(path) == ".org"
|
9
|
+
end
|
10
|
+
|
11
|
+
def strip_org path
|
12
|
+
path.gsub(/\.org$/) { '' }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/nwiki/version.rb
CHANGED
data/lib/nwiki.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nwiki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- niku
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- lib/nwiki/frontend/app/feed.rb
|
186
186
|
- lib/nwiki/frontend/app/html.rb
|
187
187
|
- lib/nwiki/frontend/app/top.rb
|
188
|
+
- lib/nwiki/utils.rb
|
188
189
|
- lib/nwiki/version.rb
|
189
190
|
- nwiki.gemspec
|
190
191
|
- public/.gitkeep
|