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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20cf602a0fad5c8e2664c6e6530b2729d92085d8
4
- data.tar.gz: f7a28ac4266f26ff28eeefd8e981f9686558aca7
3
+ metadata.gz: f9a62fd092cf1da1873a8785956e255402f9af4e
4
+ data.tar.gz: 535b5a21f16d48fead93813873f41d41c1c6e18d
5
5
  SHA512:
6
- metadata.gz: addb1a4d2a2c9ad3ffb128d3e9f8ce0c41d4c34872018a1ff8fb6236bd4ee3661367a4b7559bb409b30e7661c3d5da9a49b56dd1f9bd18c2e1f8dd1178043a1c
7
- data.tar.gz: da6e7e07721a387021f55d6d58b7ace1e49c7e434ce8ad4adf046800905a384bfdee45945f38d8c181881b41c3d3a52adfc0d80a0f801d54217f44b066da06e2
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
+ &rarr;
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
- FORM = <<HERE
6
- <html>
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
- &rarr;
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
- def do_GET (request, response)
32
- response.status = 200
33
- response.content_type = "text/html"
34
- response.body = FORM % ""
35
- end
36
-
37
- def do_POST(request, response)
38
- input = request.query["filedata"]
39
- from = Plugin.get(request.query["from"])
40
- to = Plugin.get(request.query["to"])
41
- reader = from.new
42
- writer = to.new
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
- begin
46
- out = writer.write(reader.read(input))
47
- rescue Exception => e
48
- out = e.inspect
49
- end
24
+ begin
25
+ out = writer.write(reader.read(input))
26
+ rescue Exception => e
27
+ out = e.inspect
28
+ end
50
29
 
51
- response.status = 200
52
- response.content_type = "text/html"
53
- response.body = FORM % WEBrick::HTMLUtils.escape(out)
54
- end
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
- Plugin.load_all
43
+ Plugin.load_all
64
44
 
65
- log_stream = File.open('pangrid-webrick-access.log', 'w+')
66
- log = [ [log_stream, WEBrick::AccessLog::COMMON_LOG_FORMAT] ]
45
+ logfile = File.open('pangrid-webrick-access.log', 'a')
46
+ logfile.sync = true
47
+ log = [ [logfile, WEBrick::AccessLog::COMMON_LOG_FORMAT] ]
67
48
 
68
- server = WEBrick::HTTPServer.new(:Port => port, :AccessLog => log)
69
- server.mount "/", Servlet
70
- trap("INT") { server.shutdown }
71
- server.start
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
@@ -1,3 +1,3 @@
1
1
  module Pangrid
2
- VERSION='0.2.1'
2
+ VERSION='0.2.2'
3
3
  end
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.1
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-09 00:00:00.000000000 Z
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