igg 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/igg +10 -1
- data/lib/igg.rb +1 -0
- data/lib/igg/builder/templates/project/index.html +1 -1
- data/lib/igg/builder/templates/project/mobile.html +33 -0
- data/lib/igg/cli.rb +3 -112
- data/lib/igg/server.rb +107 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c4b02dc2158a0e842aea0bc8c0b9c608c620e52
|
4
|
+
data.tar.gz: d9ef9188cd181d13bb8170f174d5f4067f79ceab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9541872c8264cb14778287145e1f534aacdd5c03a02e16f69f8d41cf3c6cab74e4c8ec3ed03f64402d1dbaf6731540d85ec12253215e13ed57f6e7b889ea5ca4
|
7
|
+
data.tar.gz: ece28bc8c04e9a28b82b748c94c943f17b23b5ee2d32efe9c9d42832bdc43856e39628e00c10b46f49cebef43d65416e7232455f6fe27b8f01f2bffdb94c1a04
|
data/README.md
CHANGED
@@ -40,12 +40,12 @@ Several tools for fast developing an ImpactJS Game, include generators and built
|
|
40
40
|
open 'http://localhost:4567' in browser
|
41
41
|
|
42
42
|
![play impact game usage](https://raw.github.com/eiffelqiu/igg/master/doc/screen3.png)
|
43
|
+
![index usage](https://raw.github.com/eiffelqiu/igg/master/doc/screen5.png)
|
43
44
|
|
44
45
|
$ igg server ## DO NOT Run in an ImpactJS project folder will NOT start server
|
45
46
|
|
46
47
|
![run server error usage](https://raw.github.com/eiffelqiu/igg/master/doc/screen4.png)
|
47
48
|
|
48
|
-
|
49
49
|
### Run Server mode to run weltmeister level editor
|
50
50
|
|
51
51
|
$ igg server
|
data/bin/igg
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'igg/cli'
|
3
3
|
|
4
|
-
Igg::CLI.start
|
4
|
+
Igg::CLI.start
|
5
|
+
|
6
|
+
at_exit do
|
7
|
+
if $!.nil? || $!.is_a?(SystemExit) && $!.success?
|
8
|
+
puts 'igg server successfully shut down'
|
9
|
+
else
|
10
|
+
code = $!.is_a?(SystemExit) ? $!.status : 1
|
11
|
+
puts "igg server shut down failure with code #{code}"
|
12
|
+
end
|
13
|
+
end
|
data/lib/igg.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8"/>
|
5
|
+
<title>Impact Game</title>
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7
|
+
<meta name="apple-mobile-web-app-capable" content="yes" />
|
8
|
+
<style type="text/css">
|
9
|
+
html, body {
|
10
|
+
background-color: #333;
|
11
|
+
color: #fff;
|
12
|
+
font-family: helvetica, arial, sans-serif;
|
13
|
+
margin: 0;
|
14
|
+
padding: 0;
|
15
|
+
font-size: 12pt;
|
16
|
+
}
|
17
|
+
|
18
|
+
#canvas {
|
19
|
+
position: absolute;
|
20
|
+
left: 0;
|
21
|
+
right: 0;
|
22
|
+
top: 0;
|
23
|
+
bottom: 0;
|
24
|
+
margin: auto;
|
25
|
+
}
|
26
|
+
</style>
|
27
|
+
<script type="text/javascript" src="lib/impact/impact.js"></script>
|
28
|
+
<script type="text/javascript" src="lib/game/main.js"></script>
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<canvas id="canvas"></canvas>
|
32
|
+
</body>
|
33
|
+
</html>
|
data/lib/igg/cli.rb
CHANGED
@@ -3,116 +3,11 @@ require 'sinatra/base'
|
|
3
3
|
require 'pathname'
|
4
4
|
require 'json'
|
5
5
|
require 'thor'
|
6
|
+
require_relative 'server'
|
6
7
|
|
7
8
|
require_relative 'ext/string_extention'
|
8
9
|
%w[project entity level].each { |task| require_relative "builder/#{task}_builder" }
|
9
10
|
|
10
|
-
########################################################
|
11
|
-
##
|
12
|
-
## reference code from Chris Darroch's 'impactrb'
|
13
|
-
## code: https://github.com/chrisdarroch/impactrb
|
14
|
-
##
|
15
|
-
## I adpated it to run in current impact project folder
|
16
|
-
##
|
17
|
-
########################################################
|
18
|
-
class Server < Sinatra::Base
|
19
|
-
|
20
|
-
set :public_folder, Dir.pwd
|
21
|
-
|
22
|
-
# This is where you could serve different pages depending on the device accessing the page,
|
23
|
-
# such as for iPads and mobile devices.
|
24
|
-
|
25
|
-
# get '/', :agent => /iphone|android/i do
|
26
|
-
# File.read('mobile.html')
|
27
|
-
# end
|
28
|
-
|
29
|
-
get '/' do
|
30
|
-
File.read('./index.html')
|
31
|
-
end
|
32
|
-
|
33
|
-
get '/weltmeister' do
|
34
|
-
File.read('./weltmeister.html')
|
35
|
-
end
|
36
|
-
|
37
|
-
get /\/lib\/weltmeister\/api\/glob(.php)?/ do
|
38
|
-
@files = params[:glob].inject([]) do |memo, glob|
|
39
|
-
dir = from_impact_basedir(glob)
|
40
|
-
Pathname.glob(dir).each do |d|
|
41
|
-
memo << relative_pathname(d)
|
42
|
-
end
|
43
|
-
memo
|
44
|
-
end
|
45
|
-
|
46
|
-
content_type :json
|
47
|
-
@files.to_json
|
48
|
-
end
|
49
|
-
|
50
|
-
get /\/lib\/weltmeister\/api\/browse(.php)?/ do
|
51
|
-
@dir = from_impact_basedir(params[:dir])
|
52
|
-
@type = params[:type]
|
53
|
-
|
54
|
-
extensions = []
|
55
|
-
|
56
|
-
case @type
|
57
|
-
when 'images' then extensions += %w{png gif jpg jpeg bmp}
|
58
|
-
when 'scripts' then extensions += %w{js}
|
59
|
-
else extensions += "*".to_a
|
60
|
-
end
|
61
|
-
|
62
|
-
parent = @dir ? relative_pathname(Pathname.new(@dir).parent) : false
|
63
|
-
directories = Pathname.new(@dir).children.select { |c| c.directory? }.map { |d| relative_pathname d }
|
64
|
-
files = Pathname.glob(File.join(@dir, "*.{#{extensions.join(',')}}")).map { |f| relative_pathname f }
|
65
|
-
|
66
|
-
content_type :json
|
67
|
-
{
|
68
|
-
:parent => parent,
|
69
|
-
:dirs => directories,
|
70
|
-
:files => files
|
71
|
-
}.to_json
|
72
|
-
end
|
73
|
-
|
74
|
-
post /\/lib\/weltmeister\/api\/save(.php)?/ do
|
75
|
-
response = { :error => 0 }
|
76
|
-
|
77
|
-
if params[:path] && params[:data]
|
78
|
-
@dir = from_impact_basedir(params[:path])
|
79
|
-
|
80
|
-
if File.extname(@dir) == ".js"
|
81
|
-
begin
|
82
|
-
File.open(@dir, 'w') { |f| f.write(params[:data]) }
|
83
|
-
rescue => e
|
84
|
-
response[:error] = 2
|
85
|
-
response[:msg] = "Could not save the level file. " + e.message
|
86
|
-
end
|
87
|
-
else
|
88
|
-
response[:error] = 3
|
89
|
-
response[:msg] = "File must have a .js suffix"
|
90
|
-
end
|
91
|
-
else
|
92
|
-
response[:error] = 1
|
93
|
-
response[:msg] = "No Data or Path specified"
|
94
|
-
end
|
95
|
-
|
96
|
-
content_type :json
|
97
|
-
response.to_json
|
98
|
-
end
|
99
|
-
|
100
|
-
helpers do
|
101
|
-
def from_impact_basedir(dir)
|
102
|
-
@folder = dir.to_s.sub(%r{\.\./?},"")
|
103
|
-
# File.join(File.dirname(__FILE__), @folder)
|
104
|
-
File.join(Dir.pwd, @folder)
|
105
|
-
end
|
106
|
-
def relative_pathname(path)
|
107
|
-
# @asset_root ||= Pathname(File.dirname(__FILE__)).realpath
|
108
|
-
@asset_root ||= Pathname(Dir.pwd).realpath
|
109
|
-
path = Pathname(File.expand_path(path))
|
110
|
-
path.relative_path_from(@asset_root).cleanpath.to_s
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
11
|
class Igg::CLI < Thor
|
117
12
|
include Thor::Actions
|
118
13
|
Igg::Builder.constants.each { |b| include "Igg::Builder::#{b}".to_class }
|
@@ -148,24 +43,20 @@ class Igg::CLI < Thor
|
|
148
43
|
puts "*" * 80
|
149
44
|
puts "Server automatically modified lib/weltmeister/config.js file"
|
150
45
|
puts "and removed all '.php' suffix in API of this file"
|
151
|
-
puts "*" * 80
|
152
|
-
puts
|
153
|
-
|
154
46
|
puts
|
155
|
-
puts "*" * 80
|
156
47
|
puts "Play your game : http://localhost:4567/"
|
157
48
|
puts "Run weltmeister : http://localhost:4567/weltmeister"
|
158
49
|
puts "*" * 80
|
159
50
|
puts
|
160
51
|
Server.run!
|
161
52
|
else
|
162
|
-
puts "*" *
|
53
|
+
puts "*" * 80
|
163
54
|
puts "Can't start server without impact and weltmeister, you must do as follow"
|
164
55
|
puts
|
165
56
|
puts "1: Copy 'impact' folder to current 'lib' subdirectory. "
|
166
57
|
puts "2: Copy 'weltmeister' folder to current 'lib' subdirectory. "
|
167
58
|
puts "3: Copy 'weltmeister.html' folder to current directory. "
|
168
|
-
puts "*" *
|
59
|
+
puts "*" * 80
|
169
60
|
exit
|
170
61
|
end
|
171
62
|
elsif method == 'help'
|
data/lib/igg/server.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
########################################################
|
2
|
+
##
|
3
|
+
## reference code from Chris Darroch's 'impactrb'
|
4
|
+
## code: https://github.com/chrisdarroch/impactrb
|
5
|
+
##
|
6
|
+
## I adpated it to run in current impact project folder
|
7
|
+
##
|
8
|
+
########################################################
|
9
|
+
|
10
|
+
require 'sinatra'
|
11
|
+
|
12
|
+
class Server < Sinatra::Base
|
13
|
+
|
14
|
+
configure { set :server, :puma }
|
15
|
+
|
16
|
+
set :public_folder, Dir.pwd
|
17
|
+
|
18
|
+
get '/', :agent => /iphone|android/i do
|
19
|
+
File.read('mobile.html')
|
20
|
+
end
|
21
|
+
|
22
|
+
get '/' do
|
23
|
+
File.read('./index.html')
|
24
|
+
end
|
25
|
+
|
26
|
+
get '/weltmeister' do
|
27
|
+
File.read('./weltmeister.html')
|
28
|
+
end
|
29
|
+
|
30
|
+
get /\/lib\/weltmeister\/api\/glob(.php)?/ do
|
31
|
+
@files = params[:glob].inject([]) do |memo, glob|
|
32
|
+
dir = from_impact_basedir(glob)
|
33
|
+
Pathname.glob(dir).each do |d|
|
34
|
+
memo << relative_pathname(d)
|
35
|
+
end
|
36
|
+
memo
|
37
|
+
end
|
38
|
+
|
39
|
+
content_type :json
|
40
|
+
@files.to_json
|
41
|
+
end
|
42
|
+
|
43
|
+
get /\/lib\/weltmeister\/api\/browse(.php)?/ do
|
44
|
+
@dir = from_impact_basedir(params[:dir])
|
45
|
+
@type = params[:type]
|
46
|
+
|
47
|
+
extensions = []
|
48
|
+
|
49
|
+
case @type
|
50
|
+
when 'images' then extensions += %w{png gif jpg jpeg bmp}
|
51
|
+
when 'scripts' then extensions += %w{js}
|
52
|
+
else extensions += "*".to_a
|
53
|
+
end
|
54
|
+
|
55
|
+
parent = @dir ? relative_pathname(Pathname.new(@dir).parent) : false
|
56
|
+
directories = Pathname.new(@dir).children.select { |c| c.directory? }.map { |d| relative_pathname d }
|
57
|
+
files = Pathname.glob(File.join(@dir, "*.{#{extensions.join(',')}}")).map { |f| relative_pathname f }
|
58
|
+
|
59
|
+
content_type :json
|
60
|
+
{
|
61
|
+
:parent => parent,
|
62
|
+
:dirs => directories,
|
63
|
+
:files => files
|
64
|
+
}.to_json
|
65
|
+
end
|
66
|
+
|
67
|
+
post /\/lib\/weltmeister\/api\/save(.php)?/ do
|
68
|
+
response = { :error => 0 }
|
69
|
+
|
70
|
+
if params[:path] && params[:data]
|
71
|
+
@dir = from_impact_basedir(params[:path])
|
72
|
+
|
73
|
+
if File.extname(@dir) == ".js"
|
74
|
+
begin
|
75
|
+
File.open(@dir, 'w') { |f| f.write(params[:data]) }
|
76
|
+
rescue => e
|
77
|
+
response[:error] = 2
|
78
|
+
response[:msg] = "Could not save the level file. " + e.message
|
79
|
+
end
|
80
|
+
else
|
81
|
+
response[:error] = 3
|
82
|
+
response[:msg] = "File must have a .js suffix"
|
83
|
+
end
|
84
|
+
else
|
85
|
+
response[:error] = 1
|
86
|
+
response[:msg] = "No Data or Path specified"
|
87
|
+
end
|
88
|
+
|
89
|
+
content_type :json
|
90
|
+
response.to_json
|
91
|
+
end
|
92
|
+
|
93
|
+
helpers do
|
94
|
+
def from_impact_basedir(dir)
|
95
|
+
@folder = dir.to_s.sub(%r{\.\./?},"")
|
96
|
+
# File.join(File.dirname(__FILE__), @folder)
|
97
|
+
File.join(Dir.pwd, @folder)
|
98
|
+
end
|
99
|
+
def relative_pathname(path)
|
100
|
+
# @asset_root ||= Pathname(File.dirname(__FILE__)).realpath
|
101
|
+
@asset_root ||= Pathname(Dir.pwd).realpath
|
102
|
+
path = Pathname(File.expand_path(path))
|
103
|
+
path.relative_path_from(@asset_root).cleanpath.to_s
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: igg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- eiffel qiu
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: puma
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.10'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.10'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,6 +133,7 @@ files:
|
|
119
133
|
- lib/igg/builder/templates/project/index.html
|
120
134
|
- lib/igg/builder/templates/project/level.js
|
121
135
|
- lib/igg/builder/templates/project/main.tt
|
136
|
+
- lib/igg/builder/templates/project/mobile.html
|
122
137
|
- lib/igg/builder/templates/project/sounds/death.mp3
|
123
138
|
- lib/igg/builder/templates/project/sounds/death.ogg
|
124
139
|
- lib/igg/builder/templates/project/sounds/jump.mp3
|
@@ -130,6 +145,7 @@ files:
|
|
130
145
|
- lib/igg/cli.rb
|
131
146
|
- lib/igg/ext/method_hooker.rb
|
132
147
|
- lib/igg/ext/string_extention.rb
|
148
|
+
- lib/igg/server.rb
|
133
149
|
homepage: http://github.com/eiffelqiu/igg
|
134
150
|
licenses:
|
135
151
|
- GPL2
|