nwiki 0.1.0 → 0.1.1

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/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 1.9.3-p327
1
+ 1.9.3-p362
data/CHANGELOG.org CHANGED
@@ -1,5 +1,11 @@
1
1
  * CHANGELOG
2
+ ** 0.1.1
3
+ - [fix] Complement '/' to url when title clicked.
2
4
  ** 0.1.0
5
+ - [feature] link to list of articles
6
+ ** 0.0.11
7
+ - [feature] change top-page from static to dynamic
8
+ ** 0.0.10
3
9
  - [feature] filter list of directory structure. return '.org' file only.
4
10
  ** 0.0.9
5
11
  - [fix] Fix url in the feed
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in nwiki.gemspec
4
4
  gemspec
5
+
6
+ gem 'coveralls', require: false
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Nwiki
2
2
 
3
+ [![Build Status](https://travis-ci.org/niku/nwiki.png?branch=master)](https://travis-ci.org/niku/nwiki)
4
+ [![Dependency Status](https://gemnasium.com/niku/nwiki.png)](https://gemnasium.com/niku/nwiki)
5
+ [![Code Climate](https://codeclimate.com/github/niku/nwiki.png)](https://codeclimate.com/github/niku/nwiki)
6
+ [![Coverage Status](https://coveralls.io/repos/niku/nwiki/badge.png?branch=master)](https://coveralls.io/r/niku/nwiki)
7
+
3
8
  TODO: Write a gem description
4
9
 
5
10
  ## Installation
@@ -0,0 +1,53 @@
1
+ require 'rss'
2
+
3
+ module Nwiki
4
+ module Frontend
5
+ class Feed
6
+ attr_reader :articles_path
7
+
8
+ def initialize git_repo_path, opts = {}
9
+ @wiki = Nwiki::Core::Wiki.new git_repo_path
10
+ raise unless @wiki.exist?
11
+ @articles_path = opts[:articles_path] || ''
12
+ end
13
+
14
+ def call env
15
+ [
16
+ 200,
17
+ { 'Content-Type' => "application/atom+xml; charset=#{Nwiki::Core::Wiki.repo_filename_encoding}" },
18
+ [
19
+ RSS::Maker.make('atom') { |maker|
20
+ maker.channel.title = @wiki.title
21
+ maker.channel.description = @wiki.subtitle
22
+ maker.channel.link = Rack::Request.new(env).url
23
+
24
+ maker.channel.author = @wiki.author
25
+ maker.channel.date = Time.parse('2014-02-06')
26
+ maker.channel.id = Rack::Request.new(env).url
27
+
28
+ maker.items.do_sort = true
29
+ maker.items.max_size = 50
30
+
31
+ log = @wiki.access.repo.log
32
+ log.each do |commit|
33
+ date = commit.date
34
+ commit.show.each do |diff|
35
+ next unless diff.new_file
36
+
37
+ path = Nwiki::Core::Wiki.canonicalize_path(diff.b_path)
38
+ path.gsub!(/\.org$/, '')
39
+
40
+ maker.items.new_item do |item|
41
+ item.link = Rack::Request.new(env).url.gsub(Regexp.new(Rack::Request.new(env).fullpath), "#{articles_path}/#{path}")
42
+ item.title = File.basename(path)
43
+ item.date = date
44
+ end
45
+ end
46
+ end
47
+ }.to_s
48
+ ]
49
+ ]
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,52 @@
1
+ require 'erb'
2
+
3
+ module Nwiki
4
+ module Frontend
5
+ class Html
6
+ def initialize git_repo_path
7
+ @wiki = Nwiki::Core::Wiki.new git_repo_path
8
+ raise unless @wiki.exist?
9
+ end
10
+
11
+ def call env
12
+ path_info = env["PATH_INFO"]
13
+ page = @wiki.find path_info
14
+ case page
15
+ when Core::Page, Core::Directory
16
+ [200, {"Content-Type" => "text/html; charset=#{page.encoding}"}, [html(page)]]
17
+ when Core::File
18
+ [200, {"Content-Type" => page.content_type}, [page.data]]
19
+ else
20
+ [404, {"Content-Type" => "text/plane"}, ["not found."]]
21
+ end
22
+ end
23
+
24
+ def html page
25
+ erb = ERB.new <<EOS
26
+ <!DOCTYPE HTML>
27
+ <html>
28
+ <head>
29
+ <title><%= page.title %> - <%= @wiki.title %></title>
30
+ <link rel="alternate" type="application/atom+xml" title="ATOM Feed" href="/articles.xml">
31
+ <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
32
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
33
+ <script src="/bootstrap/js/bootstrap.min.js"></script>
34
+ </head>
35
+ <body>
36
+ <div class="container">
37
+ <div class="row">
38
+ <div class="span12">
39
+ <h1><a href="/articles/"><%= @wiki.title %></a></h1>
40
+ <h2><%= @wiki.subtitle %></h2>
41
+ <%= page.to_html %>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ </body>
46
+ </html>
47
+ EOS
48
+ erb.result(binding).force_encoding(page.encoding)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,48 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'erb'
3
+
4
+ module Nwiki
5
+ module Frontend
6
+ class Top
7
+ def initialize git_repo_path, opts = {}
8
+ @wiki = Nwiki::Core::Wiki.new git_repo_path
9
+ end
10
+
11
+ def call env
12
+ [
13
+ 200,
14
+ { "Content-Type" => "text/html; charset=#{Nwiki::Core::Wiki.repo_filename_encoding}" },
15
+ [html]
16
+ ]
17
+ end
18
+
19
+ def html
20
+ erb = ERB.new <<EOS
21
+ <!DOCTYPE HTML>
22
+ <html>
23
+ <head>
24
+ <meta http-equiv="refresh" content="5;URL=http://niku.name/articles/">
25
+ <title><%= @wiki.title %></title>
26
+ <link rel="alternate" type="application/atom+xml" title="ATOM Feed" href="/articles.xml">
27
+ <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
28
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
29
+ <script src="/bootstrap/js/bootstrap.min.js"></script>
30
+ </head>
31
+ <body>
32
+ <div class="container">
33
+ <div class="row">
34
+ <div class="span12">
35
+ <h1><%= @wiki.title %></h1>
36
+ <h2><%= @wiki.subtitle %></h2>
37
+ <p>ここまだ何にも作ってないんす.<a href="./articles/">articles</a>以下が動いているのでそっちを見てね.5秒経つと自動で移動します.</p>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ </body>
42
+ </html>
43
+ EOS
44
+ erb.result(binding).force_encoding(Nwiki::Core::Wiki.repo_filename_encoding)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,11 +1,16 @@
1
- require 'erb'
2
- require 'rss'
1
+ # -*- coding: utf-8 -*-
2
+ require_relative 'app/top'
3
+ require_relative 'app/feed'
4
+ require_relative 'app/html'
3
5
 
4
6
  module Nwiki
5
7
  module Frontend
6
8
  class App
7
9
  def initialize git_repo_path
8
10
  @builder = Rack::Builder.new {
11
+ map '/' do
12
+ run Top.new git_repo_path
13
+ end
9
14
  map '/articles.xml' do
10
15
  run Feed.new git_repo_path, articles_path: '/articles'
11
16
  end
@@ -19,100 +24,5 @@ module Nwiki
19
24
  @builder.call env
20
25
  end
21
26
  end
22
-
23
- class Feed
24
- attr_reader :articles_path
25
-
26
- def initialize git_repo_path, opts = {}
27
- @wiki = Nwiki::Core::Wiki.new git_repo_path
28
- raise unless @wiki.exist?
29
- @articles_path = opts[:articles_path] || ''
30
- end
31
-
32
- def call env
33
- [
34
- 200,
35
- { 'Content-Type' => "application/atom+xml; charset=#{Nwiki::Core::Wiki.repo_filename_encoding}" },
36
- [
37
- RSS::Maker.make('atom') { |maker|
38
- maker.channel.title = @wiki.title
39
- maker.channel.description = @wiki.subtitle
40
- maker.channel.link = Rack::Request.new(env).url
41
-
42
- maker.channel.author = @wiki.author
43
- maker.channel.date = Time.parse('2014-02-06')
44
- maker.channel.id = Rack::Request.new(env).url
45
-
46
- maker.items.do_sort = true
47
- maker.items.max_size = 50
48
-
49
- log = @wiki.access.repo.log
50
- log.each do |commit|
51
- date = commit.date
52
- commit.show.each do |diff|
53
- next unless diff.new_file
54
-
55
- path = Nwiki::Core::Wiki.canonicalize_path(diff.b_path)
56
- path.gsub!(/\.org$/, '')
57
-
58
- maker.items.new_item do |item|
59
- item.link = Rack::Request.new(env).url.gsub(Regexp.new(Rack::Request.new(env).fullpath), "#{articles_path}/#{path}")
60
- item.title = File.basename(path)
61
- item.date = date
62
- end
63
- end
64
- end
65
- }.to_s
66
- ]
67
- ]
68
- end
69
- end
70
-
71
- class Html
72
- def initialize git_repo_path
73
- @wiki = Nwiki::Core::Wiki.new git_repo_path
74
- raise unless @wiki.exist?
75
- end
76
-
77
- def call env
78
- path_info = env["PATH_INFO"]
79
- page = @wiki.find path_info
80
- case page
81
- when Core::Page, Core::Directory
82
- [200, {"Content-Type" => "text/html; charset=#{page.encoding}"}, [html(page)]]
83
- when Core::File
84
- [200, {"Content-Type" => page.content_type}, [page.data]]
85
- else
86
- [404, {"Content-Type" => "text/plane"}, ["not found."]]
87
- end
88
- end
89
-
90
- def html page
91
- erb = ERB.new <<EOS
92
- <!DOCTYPE HTML>
93
- <html>
94
- <head>
95
- <title><%= page.title %> - <%= @wiki.title %></title>
96
- <link rel="alternate" type="application/atom+xml" title="ATOM Feed" href="/articles.xml">
97
- <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
98
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
99
- <script src="/bootstrap/js/bootstrap.min.js"></script>
100
- </head>
101
- <body>
102
- <div class="container">
103
- <div class="row">
104
- <div class="span12">
105
- <h1><%= @wiki.title %></h1>
106
- <h2><%= @wiki.subtitle %></h2>
107
- <%= page.to_html %>
108
- </div>
109
- </div>
110
- </div>
111
- </body>
112
- </html>
113
- EOS
114
- erb.result(binding).force_encoding(page.encoding)
115
- end
116
- end
117
27
  end
118
28
  end
data/lib/nwiki/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nwiki
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -14,6 +14,14 @@ module Nwiki
14
14
  get path
15
15
  end
16
16
 
17
+ context 'GET /' do
18
+ let(:path) { '/' }
19
+
20
+ it { subject.should be_ok }
21
+ it { subject.should match %r!\bヽ(´・肉・`)ノログ\b! }
22
+ it { subject.should match %r!\bHow do we fighting without fighting?\b! }
23
+ end
24
+
17
25
  context 'GET /articles' do
18
26
  let(:path) { '/articles/' }
19
27
 
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'nwiki'
2
2
  require 'rack/test'
3
+ require 'coveralls'
3
4
 
4
5
  RSpec.configure do |config|
5
6
  config.treat_symbols_as_metadata_keys_with_true_values = true
@@ -7,3 +8,5 @@ RSpec.configure do |config|
7
8
  config.filter_run :focus
8
9
  config.include Rack::Test::Methods
9
10
  end
11
+
12
+ Coveralls.wear!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nwiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-09 00:00:00.000000000 Z
12
+ date: 2013-07-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gollum-lib
@@ -162,6 +162,7 @@ executables: []
162
162
  extensions: []
163
163
  extra_rdoc_files: []
164
164
  files:
165
+ - .coveralls.yml
165
166
  - .gitignore
166
167
  - .rspec
167
168
  - .ruby-version
@@ -182,6 +183,9 @@ files:
182
183
  - lib/nwiki/core/wiki.rb
183
184
  - lib/nwiki/frontend.rb
184
185
  - lib/nwiki/frontend/app.rb
186
+ - lib/nwiki/frontend/app/feed.rb
187
+ - lib/nwiki/frontend/app/html.rb
188
+ - lib/nwiki/frontend/app/top.rb
185
189
  - lib/nwiki/version.rb
186
190
  - nwiki.gemspec
187
191
  - public/bootstrap/css/bootstrap-responsive.min.css
@@ -247,7 +251,6 @@ files:
247
251
  - spec/examples/sample.git/refs/heads/config
248
252
  - spec/examples/sample.git/refs/heads/master
249
253
  - spec/nwiki/core/git_access_spec.rb
250
- - spec/nwiki/core/page_spec.rb
251
254
  - spec/nwiki/core/wiki_spec.rb
252
255
  - spec/requests/articles_spec.rb
253
256
  - spec/spec_helper.rb
@@ -265,7 +268,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
268
  version: '0'
266
269
  segments:
267
270
  - 0
268
- hash: 3045566447973314358
271
+ hash: -789790350238631427
269
272
  required_rubygems_version: !ruby/object:Gem::Requirement
270
273
  none: false
271
274
  requirements:
@@ -274,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
277
  version: '0'
275
278
  segments:
276
279
  - 0
277
- hash: 3045566447973314358
280
+ hash: -789790350238631427
278
281
  requirements: []
279
282
  rubyforge_project:
280
283
  rubygems_version: 1.8.23
@@ -340,7 +343,6 @@ test_files:
340
343
  - spec/examples/sample.git/refs/heads/config
341
344
  - spec/examples/sample.git/refs/heads/master
342
345
  - spec/nwiki/core/git_access_spec.rb
343
- - spec/nwiki/core/page_spec.rb
344
346
  - spec/nwiki/core/wiki_spec.rb
345
347
  - spec/requests/articles_spec.rb
346
348
  - spec/spec_helper.rb
File without changes