pangrid 0.5.2 → 0.6.0
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.
- checksums.yaml +4 -4
- data/README +28 -9
- data/lib/pangrid/clues.rb +80 -0
- data/lib/pangrid/plugin.rb +7 -2
- data/lib/pangrid/plugins/acrosslite.rb +53 -19
- data/lib/pangrid/plugins/csv.rb +18 -13
- data/lib/pangrid/plugins/excel.rb +1 -1
- data/lib/pangrid/plugins/exolve.rb +15 -3
- data/lib/pangrid/plugins/json.rb +19 -3
- data/lib/pangrid/plugins/png.rb +5 -5
- data/lib/pangrid/plugins/qxw.rb +36 -14
- data/lib/pangrid/plugins/reddit.rb +11 -19
- data/lib/pangrid/plugins/text.rb +0 -8
- data/lib/pangrid/utils.rb +17 -0
- data/lib/pangrid/version.rb +1 -1
- data/lib/pangrid/xw.rb +62 -36
- data/lib/pangrid.rb +78 -31
- metadata +21 -9
- data/lib/deps/trollop.rb +0 -838
- data/lib/pangrid/data/webform.html +0 -24
- data/lib/pangrid/frontend/webrick.rb +0 -74
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
<option value="reddit-blank">Reddit (grid + clues)</option>
|
|
9
|
-
</select>
|
|
10
|
-
→
|
|
11
|
-
<select name="to">
|
|
12
|
-
<option value="reddit-blank">Reddit (blank)</option>
|
|
13
|
-
<option value="reddit-filled">Reddit (filled)</option>
|
|
14
|
-
<option value="text">Text</option>
|
|
15
|
-
<option value="across-lite-text">AcrossLite text</option>
|
|
16
|
-
</select>
|
|
17
|
-
<input type="submit" value="Convert" />
|
|
18
|
-
</form>
|
|
19
|
-
<hr>
|
|
20
|
-
<div>
|
|
21
|
-
<textarea rows=40 cols=80 readonly>%s</textarea>
|
|
22
|
-
</div>
|
|
23
|
-
</body>
|
|
24
|
-
</html>
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
require "webrick"
|
|
2
|
-
|
|
3
|
-
module Pangrid
|
|
4
|
-
|
|
5
|
-
TEMPLATE_DIR = File.dirname(File.expand_path(__FILE__)) + '/../data'
|
|
6
|
-
TEMPLATE = TEMPLATE_DIR + '/webform.html'
|
|
7
|
-
|
|
8
|
-
class Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|
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
|
|
22
|
-
out = nil
|
|
23
|
-
|
|
24
|
-
begin
|
|
25
|
-
out = writer.write(reader.read(input))
|
|
26
|
-
rescue Exception => e
|
|
27
|
-
out = e.inspect
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
response.header['Access-Control-Allow-Origin'] = '*'
|
|
31
|
-
|
|
32
|
-
case request.path
|
|
33
|
-
when "/"
|
|
34
|
-
template = IO.read(TEMPLATE)
|
|
35
|
-
response.status = 200
|
|
36
|
-
response.content_type = "text/html"
|
|
37
|
-
response.body = template % out
|
|
38
|
-
when "/blob"
|
|
39
|
-
response.status = 200
|
|
40
|
-
response.content_type = "application/octet-stream"
|
|
41
|
-
response.body = out
|
|
42
|
-
when "/json"
|
|
43
|
-
if request.query["to"] == "json"
|
|
44
|
-
response.status = 200
|
|
45
|
-
response.content_type = "text/json"
|
|
46
|
-
response.body = out
|
|
47
|
-
else
|
|
48
|
-
response.status = 200
|
|
49
|
-
response.content_type = "text/json"
|
|
50
|
-
response.body = '{ "error" : "non-json format requested" }'
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def self.run_webserver(port)
|
|
57
|
-
puts "-------------------------------------------"
|
|
58
|
-
puts "Open your web browser and load"
|
|
59
|
-
puts " http://localhost:#{port}"
|
|
60
|
-
puts "-------------------------------------------"
|
|
61
|
-
|
|
62
|
-
Plugin.load_all
|
|
63
|
-
|
|
64
|
-
logfile = File.open('pangrid-webrick-access.log', 'a')
|
|
65
|
-
logfile.sync = true
|
|
66
|
-
log = [ [logfile, WEBrick::AccessLog::COMMON_LOG_FORMAT] ]
|
|
67
|
-
|
|
68
|
-
server = WEBrick::HTTPServer.new(:Port => port, :AccessLog => log)
|
|
69
|
-
server.mount "/", Servlet
|
|
70
|
-
trap("INT") { server.shutdown }
|
|
71
|
-
server.start
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
end # module Pangrid
|