ghpreview-instant_markdown_d 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +42 -0
- data/Rakefile +6 -0
- data/bin/ghpreview-instant_markdown_d +5 -0
- data/ghpreview-instant_markdown_d.gemspec +29 -0
- data/lib/ghpreview/instant_markdown_d.rb +2 -0
- data/lib/ghpreview/instant_markdown_d/extension/ghpreview/template.erb +41 -0
- data/lib/ghpreview/instant_markdown_d/extension/ghpreview/wrapper.rb +9 -0
- data/lib/ghpreview/instant_markdown_d/previewer.rb +24 -0
- data/lib/ghpreview/instant_markdown_d/sender.rb +25 -0
- data/lib/ghpreview/instant_markdown_d/server.rb +54 -0
- data/lib/ghpreview/instant_markdown_d/version.rb +5 -0
- data/lib/ghpreview/instant_markdown_d/viewer.rb +14 -0
- data/spec/ghpreview/instant_markdown_d_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 347040a9ee2ee3ff65fc0e34a214b5c2c4fa2270
|
4
|
+
data.tar.gz: 6fe7ddc9a1b6b93249ee420549286675dd220e26
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 87080b216e6730fbba0601ebe8b3b8d3e9d1b2b16d0dc3dc21bfead446af03f8418908545c1c77bc981850834fb076f93c7b0a5a2bc0ba6f8c0ce17aa90b0035
|
7
|
+
data.tar.gz: 6ef39275e745806aaa10459c386d53c5e8aeb9c70b39580d8e24d19d35847cec792c5382b66086de05451d1eeee9e5a3781c59927dea95d59c7fa9dfd7ed5261
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Yuichi TANIKAWA
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# GHPreview::InstantMarkdownD
|
2
|
+
|
3
|
+
GHPreview::InstantMarkdownD is a small server that is compatible with [instant-markdown-d](https://github.com/suan/instant-markdown-d).
|
4
|
+
It uses `ghpreview` for previewing Markdown files.
|
5
|
+
|
6
|
+
See also
|
7
|
+
* [ghpreview](https://github.com/neo/ghpreview )
|
8
|
+
* [instant-markdown-d](https://github.com/suan/instant-markdown-d )
|
9
|
+
|
10
|
+
## Prerequisites
|
11
|
+
|
12
|
+
You'll need the icu library.
|
13
|
+
|
14
|
+
If you're on a Mac
|
15
|
+
|
16
|
+
```bash
|
17
|
+
$ brew install icu4c
|
18
|
+
```
|
19
|
+
|
20
|
+
or on Ubuntu
|
21
|
+
|
22
|
+
```bash
|
23
|
+
$ sudo apt-get install libicu-dev
|
24
|
+
```
|
25
|
+
|
26
|
+
## Installation
|
27
|
+
|
28
|
+
```bash
|
29
|
+
$ gem install ghpreview-instant_markdown_d
|
30
|
+
```
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
See [instant-markdown-d](https://github.com/suan/instant-markdown-d ).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ghpreview/instant_markdown_d/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ghpreview-instant_markdown_d"
|
8
|
+
spec.version = GHPreview::InstantMarkdownD::VERSION
|
9
|
+
spec.authors = ["Yuichi TANIKAWA"]
|
10
|
+
spec.email = ["t.yuichi111@gmail.com"]
|
11
|
+
spec.summary = %q{Small server running ghpreview compatible with instant-markdown-d}
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'ghpreview', '~> 0.1'
|
22
|
+
spec.add_dependency 'rack', '~> 1.5'
|
23
|
+
spec.add_dependency 'thin', '~> 1.6'
|
24
|
+
spec.add_dependency 'faye-websocket', '~> 0.7'
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "rspec"
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<%= stylesheet_links %>
|
6
|
+
<style>
|
7
|
+
body { padding: 30px 0; }
|
8
|
+
#readme { width: 914px; margin: 0 auto; }
|
9
|
+
</style>
|
10
|
+
<script>
|
11
|
+
var socket = new EventSource('/');
|
12
|
+
|
13
|
+
socket.onopen = function() {
|
14
|
+
console.log('OPEN');
|
15
|
+
};
|
16
|
+
|
17
|
+
socket.onmessage = function(event) {
|
18
|
+
console.log('MESSAGE: ' + event.data);
|
19
|
+
};
|
20
|
+
|
21
|
+
socket.onerror = function(event) {
|
22
|
+
console.log('ERROR: ' + event.message);
|
23
|
+
};
|
24
|
+
|
25
|
+
socket.addEventListener('preview', function(event) {
|
26
|
+
document.getElementsByClassName('markdown-body')[0].innerHTML = event.data;
|
27
|
+
});
|
28
|
+
|
29
|
+
socket.addEventListener('die', function(event) {
|
30
|
+
socket.close();
|
31
|
+
console.log('DIE');
|
32
|
+
});
|
33
|
+
</script>
|
34
|
+
</head>
|
35
|
+
<body>
|
36
|
+
<div id="readme">
|
37
|
+
<article class="markdown-body">
|
38
|
+
</article>
|
39
|
+
</div>
|
40
|
+
</body>
|
41
|
+
</html>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'ghpreview/wrapper'
|
2
|
+
|
3
|
+
GHPreview::Wrapper.class_eval do
|
4
|
+
remove_const :STYLED_TEMPLATE_FILEPATH
|
5
|
+
const_set :STYLED_TEMPLATE_FILEPATH, '/tmp/ghpreview-instant_makrdown_d-template.erb'
|
6
|
+
|
7
|
+
remove_const :RAW_TEMPLATE_FILEPATH
|
8
|
+
const_set :RAW_TEMPLATE_FILEPATH, "#{File.dirname(__FILE__)}/template.erb"
|
9
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'eventmachine'
|
2
|
+
|
3
|
+
require_relative 'server'
|
4
|
+
require_relative 'viewer'
|
5
|
+
require_relative 'extension/ghpreview/wrapper'
|
6
|
+
|
7
|
+
module GHPreview
|
8
|
+
module InstantMarkdownD
|
9
|
+
class Previewer
|
10
|
+
HOST = 'localhost'
|
11
|
+
PORT = 8090
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
Wrapper.generate_template_with_fingerprinted_stylesheet_links
|
15
|
+
|
16
|
+
EM.defer do
|
17
|
+
Viewer.open_url HOST, PORT
|
18
|
+
end
|
19
|
+
|
20
|
+
Server.run HOST, PORT
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'faye/websocket'
|
2
|
+
|
3
|
+
module GHPreview
|
4
|
+
module InstantMarkdownD
|
5
|
+
class Sender
|
6
|
+
def self.setup
|
7
|
+
Faye::WebSocket.load_adapter('thin')
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.request?(env)
|
11
|
+
Faye::EventSource.eventsource?(env)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.response(env)
|
15
|
+
@es ||= Faye::EventSource.new(env)
|
16
|
+
@es.onclose = ->(event) { @es = nil }
|
17
|
+
@es.rack_response
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.send(content, event)
|
21
|
+
@es.send(content, event: event.to_s) if @es
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rack/request'
|
2
|
+
require 'rack/response'
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'ghpreview/converter'
|
5
|
+
|
6
|
+
require_relative 'sender'
|
7
|
+
|
8
|
+
module GHPreview
|
9
|
+
module InstantMarkdownD
|
10
|
+
class Server
|
11
|
+
|
12
|
+
def self.run(host, port)
|
13
|
+
Sender.setup
|
14
|
+
Rack::Handler::Thin.run new, Host: host, Port: port
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
if Sender.request? env
|
19
|
+
puts 'connetion establish!'
|
20
|
+
|
21
|
+
Sender.response env
|
22
|
+
|
23
|
+
else
|
24
|
+
req = Rack::Request.new(env)
|
25
|
+
|
26
|
+
case req.request_method
|
27
|
+
when 'GET'
|
28
|
+
Rack::Response.new(Wrapper.wrap_html nil).finish
|
29
|
+
|
30
|
+
when 'PUT'
|
31
|
+
EM.defer do
|
32
|
+
md = req.body.read
|
33
|
+
html = Converter.to_html md
|
34
|
+
Sender.send html, :preview
|
35
|
+
end
|
36
|
+
|
37
|
+
[200, {}, []]
|
38
|
+
|
39
|
+
when 'DELETE'
|
40
|
+
EM.add_timer(1) do
|
41
|
+
Sender.send 'die', :die
|
42
|
+
Process.kill('TERM', Process.pid)
|
43
|
+
end
|
44
|
+
|
45
|
+
[200, {}, []]
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ghpreview-instant_markdown_d
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuichi TANIKAWA
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ghpreview
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thin
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faye-websocket
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
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: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Small server running ghpreview compatible with instant-markdown-d
|
112
|
+
email:
|
113
|
+
- t.yuichi111@gmail.com
|
114
|
+
executables:
|
115
|
+
- ghpreview-instant_markdown_d
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".travis.yml"
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/ghpreview-instant_markdown_d
|
127
|
+
- ghpreview-instant_markdown_d.gemspec
|
128
|
+
- lib/ghpreview/instant_markdown_d.rb
|
129
|
+
- lib/ghpreview/instant_markdown_d/extension/ghpreview/template.erb
|
130
|
+
- lib/ghpreview/instant_markdown_d/extension/ghpreview/wrapper.rb
|
131
|
+
- lib/ghpreview/instant_markdown_d/previewer.rb
|
132
|
+
- lib/ghpreview/instant_markdown_d/sender.rb
|
133
|
+
- lib/ghpreview/instant_markdown_d/server.rb
|
134
|
+
- lib/ghpreview/instant_markdown_d/version.rb
|
135
|
+
- lib/ghpreview/instant_markdown_d/viewer.rb
|
136
|
+
- spec/ghpreview/instant_markdown_d_spec.rb
|
137
|
+
- spec/spec_helper.rb
|
138
|
+
homepage: ''
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 2.2.2
|
159
|
+
signing_key:
|
160
|
+
specification_version: 4
|
161
|
+
summary: Small server running ghpreview compatible with instant-markdown-d
|
162
|
+
test_files:
|
163
|
+
- spec/ghpreview/instant_markdown_d_spec.rb
|
164
|
+
- spec/spec_helper.rb
|