pangrid 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pangrid/data/webform.html +23 -0
- data/lib/pangrid/frontend/webrick.rb +33 -52
- data/lib/pangrid/version.rb +1 -1
- 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: f9a62fd092cf1da1873a8785956e255402f9af4e
|
4
|
+
data.tar.gz: 535b5a21f16d48fead93813873f41d41c1c6e18d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dec53c4e07f22ae3a78168b8896d582a541bf5448aa681c2dbbd9f378596d867104c10909878b830108d4bea0229333c8472ef50fb2f2113664e84ea6b5e5e4d
|
7
|
+
data.tar.gz: 521111576dbdffd31db91ce84f43522383bc2034dbf41607a51d0879fa2e7c42db9923375fee91f1db588dde132be154b05244d4b1f9d413423ca111e3dcbfbd
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<html>
|
2
|
+
<body>
|
3
|
+
<form method="POST" action="convert" enctype="multipart/form-data">
|
4
|
+
<input type="file" name="filedata" />
|
5
|
+
<select name="from">
|
6
|
+
<option value="across-lite-binary">AcrossLite binary (.puz)</option>
|
7
|
+
<option value="across-lite-text">AcrossLite text</option>
|
8
|
+
</select>
|
9
|
+
→
|
10
|
+
<select name="to">
|
11
|
+
<option value="reddit-blank">Reddit (blank)</option>
|
12
|
+
<option value="reddit-filled">Reddit (filled)</option>
|
13
|
+
<option value="text">Text</option>
|
14
|
+
<option value="across-lite-text">AcrossLite text</option>
|
15
|
+
</select>
|
16
|
+
<input type="submit" value="Convert" />
|
17
|
+
</form>
|
18
|
+
<hr>
|
19
|
+
<div>
|
20
|
+
<textarea rows=40 cols=80 readonly>%s</textarea>
|
21
|
+
</div>
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -2,56 +2,36 @@ require "webrick"
|
|
2
2
|
|
3
3
|
module Pangrid
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
<body>
|
8
|
-
<form method="POST" enctype="multipart/form-data">
|
9
|
-
<input type="file" name="filedata" />
|
10
|
-
<select name="from">
|
11
|
-
<option value="across-lite-binary">AcrossLite binary (.puz)</option>
|
12
|
-
<option value="across-lite-text">AcrossLite text</option>
|
13
|
-
</select>
|
14
|
-
→
|
15
|
-
<select name="to">
|
16
|
-
<option value="reddit-blank">Reddit (blank)</option>
|
17
|
-
<option value="reddit-filled">Reddit (filled)</option>
|
18
|
-
<option value="text">Text</option>
|
19
|
-
</select>
|
20
|
-
<input type="submit" />
|
21
|
-
</form>
|
22
|
-
<hr>
|
23
|
-
<div>
|
24
|
-
<pre>%s</pre>
|
25
|
-
</div>
|
26
|
-
</body>
|
27
|
-
</html>
|
28
|
-
HERE
|
5
|
+
TEMPLATE_DIR = File.dirname(File.expand_path(__FILE__)) + '/../data'
|
6
|
+
TEMPLATE = TEMPLATE_DIR + '/webform.html'
|
29
7
|
|
30
8
|
class Servlet < WEBrick::HTTPServlet::AbstractServlet
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
9
|
+
def do_GET (request, response)
|
10
|
+
template = IO.read(TEMPLATE)
|
11
|
+
response.status = 200
|
12
|
+
response.content_type = "text/html"
|
13
|
+
response.body = template % ""
|
14
|
+
end
|
15
|
+
|
16
|
+
def do_POST(request, response)
|
17
|
+
input = request.query["filedata"]
|
18
|
+
from = Plugin.get(request.query["from"])
|
19
|
+
to = Plugin.get(request.query["to"])
|
20
|
+
reader = from.new
|
21
|
+
writer = to.new
|
43
22
|
out = nil
|
44
23
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
24
|
+
begin
|
25
|
+
out = writer.write(reader.read(input))
|
26
|
+
rescue Exception => e
|
27
|
+
out = e.inspect
|
28
|
+
end
|
50
29
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
30
|
+
template = IO.read(TEMPLATE)
|
31
|
+
response.status = 200
|
32
|
+
response.content_type = "text/html"
|
33
|
+
response.body = template % out
|
34
|
+
end
|
55
35
|
end
|
56
36
|
|
57
37
|
def self.run_webserver(port)
|
@@ -60,15 +40,16 @@ def self.run_webserver(port)
|
|
60
40
|
puts " http://localhost:#{port}"
|
61
41
|
puts "-------------------------------------------"
|
62
42
|
|
63
|
-
|
43
|
+
Plugin.load_all
|
64
44
|
|
65
|
-
|
66
|
-
|
45
|
+
logfile = File.open('pangrid-webrick-access.log', 'a')
|
46
|
+
logfile.sync = true
|
47
|
+
log = [ [logfile, WEBrick::AccessLog::COMMON_LOG_FORMAT] ]
|
67
48
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
49
|
+
server = WEBrick::HTTPServer.new(:Port => port, :AccessLog => log)
|
50
|
+
server.mount "/", Servlet
|
51
|
+
trap("INT") { server.shutdown }
|
52
|
+
server.start
|
72
53
|
end
|
73
54
|
|
74
55
|
end # module Pangrid
|
data/lib/pangrid/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pangrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin DeMello
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: martindemello@gmail.com
|
@@ -23,6 +23,7 @@ files:
|
|
23
23
|
- bin/pangrid
|
24
24
|
- lib/deps/trollop.rb
|
25
25
|
- lib/pangrid.rb
|
26
|
+
- lib/pangrid/data/webform.html
|
26
27
|
- lib/pangrid/frontend/webrick.rb
|
27
28
|
- lib/pangrid/plugin.rb
|
28
29
|
- lib/pangrid/plugins/acrosslite.rb
|