maglove 0.8.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +157 -0
- data/Gemfile.lock +59 -49
- data/bin/maglove +13 -13
- data/data/maglove/export.haml +11 -0
- data/data/maglove/index.haml +17 -0
- data/data/maglove/maglove.css +62 -0
- data/data/maglove/maglove.haml +18 -0
- data/data/maglove/maglove.js +68 -0
- data/lib/block_resolver.rb +6 -0
- data/lib/ext/thor/option.rb +43 -0
- data/lib/magloft/api.rb +39 -0
- data/lib/magloft/api_caller.rb +67 -0
- data/lib/magloft/remote_collection.rb +50 -0
- data/lib/magloft/remote_resource.rb +124 -0
- data/lib/magloft/transformable.rb +11 -0
- data/lib/magloft/typeloft_block.rb +18 -0
- data/lib/magloft/typeloft_image.rb +18 -0
- data/lib/magloft/typeloft_template.rb +18 -0
- data/lib/magloft/typeloft_theme.rb +41 -0
- data/lib/magloft.rb +3 -0
- data/lib/maglove/application.rb +10 -12
- data/lib/maglove/asset/theme.rb +37 -32
- data/lib/maglove/commands/assets.rb +85 -0
- data/lib/maglove/commands/base.rb +55 -0
- data/lib/maglove/commands/fonts.rb +69 -0
- data/lib/maglove/commands/main.rb +24 -0
- data/lib/maglove/commands/theme.rb +197 -0
- data/lib/maglove/helper/log_helper.rb +3 -18
- data/lib/maglove/middleware/live_reload.rb +97 -0
- data/lib/maglove/phantom_script.rb +9 -10
- data/lib/maglove/server.rb +46 -78
- data/lib/maglove/tilt/coffee_template.rb +7 -6
- data/lib/maglove/tilt/haml_template.rb +4 -4
- data/lib/maglove/tilt/js_template.rb +8 -8
- data/lib/maglove/tilt/less_template.rb +5 -4
- data/lib/maglove/tilt/scss_template.rb +17 -11
- data/lib/maglove/tilt/yaml_template.rb +3 -2
- data/lib/maglove/version.rb +1 -1
- data/lib/maglove/workspace.rb +41 -0
- data/lib/maglove.rb +38 -49
- data/lib/powersnap.rb +24 -0
- data/lib/workspace/workspace_dir/archive.rb +18 -0
- data/lib/workspace/workspace_dir.rb +98 -0
- data/lib/workspace/workspace_file/archive.rb +45 -0
- data/lib/workspace/workspace_file/media.rb +19 -0
- data/lib/workspace/workspace_file/net.rb +18 -0
- data/lib/workspace/workspace_file/parse.rb +21 -0
- data/lib/workspace/workspace_file.rb +99 -0
- data/lib/workspace.rb +11 -0
- data/maglove.gemspec +12 -12
- metadata +100 -86
- data/data/maglove/dump.haml +0 -58
- data/data/maglove/sdk.haml +0 -27
- data/lib/ext/commander/command.rb +0 -32
- data/lib/ext/commander/methods.rb +0 -8
- data/lib/maglove/asset/base_theme.rb +0 -17
- data/lib/maglove/command/compile.rb +0 -44
- data/lib/maglove/command/compress.rb +0 -28
- data/lib/maglove/command/copy.rb +0 -35
- data/lib/maglove/command/core.rb +0 -23
- data/lib/maglove/command/font.rb +0 -80
- data/lib/maglove/command/server.rb +0 -16
- data/lib/maglove/command/sync.rb +0 -17
- data/lib/maglove/command/theme.rb +0 -175
- data/lib/maglove/command/util.rb +0 -45
- data/lib/maglove/helper/asset_helper.rb +0 -24
- data/lib/maglove/helper/command_helper.rb +0 -67
- data/lib/maglove/helper/theme_helper.rb +0 -105
- data/lib/maglove/server/hpub.rb +0 -185
- data/lib/maglove/template/tumblr.rb +0 -81
- data/lib/maglove/tilt/twig_template.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dccb23a8c8be90fb803c245920d9fdb69a2daf3
|
4
|
+
data.tar.gz: c52c4361e99d42bc6b54c8d7d01f5863e27c0c7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c689282df29d5158e65d1820202d6f69ef0036ee8f3a4feb44df581778539ec6c97202d9dc0f8e0cf1478ace624c726ff013d8a473c78b444e7204e5085aa582
|
7
|
+
data.tar.gz: 7707828d8db40facb164f6b6a0a4ce0035775e2aaeb0b50efbe32ec333867d1ae50e91220f9d2f3741ae69b4c0b4e706d2a534ca21f6033b2c638f19870fe753
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
# kind_of? is a good way to check a type
|
2
|
+
Style/ClassCheck:
|
3
|
+
EnforcedStyle: kind_of?
|
4
|
+
|
5
|
+
# It's better to be more explicit about the type
|
6
|
+
Style/BracesAroundHashParameters:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
# specs sometimes have useless assignments, which is fine
|
10
|
+
Lint/UselessAssignment:
|
11
|
+
Exclude:
|
12
|
+
- '**/spec/**/*'
|
13
|
+
|
14
|
+
# We could potentially enable the 2 below:
|
15
|
+
Style/IndentHash:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/AlignHash:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
# HoundCI doesn't like this rule
|
22
|
+
Style/DotPosition:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
# We allow !! as it's an easy way to convert ot boolean
|
26
|
+
Style/DoubleNegation:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
# Sometimes we allow a rescue block that doesn't contain code
|
30
|
+
Lint/HandleExceptions:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
# Cop supports --auto-correct.
|
34
|
+
Lint/UnusedBlockArgument:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
# Needed for $verbose
|
38
|
+
Style/GlobalVars:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
# We want to allow class Fastlane::Class
|
42
|
+
Style/ClassAndModuleChildren:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
# $? Exit
|
46
|
+
Style/SpecialGlobalVars:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Metrics/AbcSize:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
Metrics/MethodLength:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
Metrics/CyclomaticComplexity:
|
56
|
+
Enabled: false
|
57
|
+
|
58
|
+
# The %w might be confusing for new users
|
59
|
+
Style/WordArray:
|
60
|
+
MinSize: 19
|
61
|
+
|
62
|
+
# raise and fail are both okay
|
63
|
+
Style/SignalException:
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
# Better too much 'return' than one missing
|
67
|
+
Style/RedundantReturn:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
# Having if in the same line might not always be good
|
71
|
+
Style/IfUnlessModifier:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
# and and or is okay
|
75
|
+
Style/AndOr:
|
76
|
+
Enabled: false
|
77
|
+
|
78
|
+
# Configuration parameters: CountComments.
|
79
|
+
Metrics/ClassLength:
|
80
|
+
Max: 320
|
81
|
+
|
82
|
+
|
83
|
+
# Configuration parameters: AllowURI, URISchemes.
|
84
|
+
Metrics/LineLength:
|
85
|
+
Max: 370
|
86
|
+
|
87
|
+
# Configuration parameters: CountKeywordArgs.
|
88
|
+
Metrics/ParameterLists:
|
89
|
+
Max: 17
|
90
|
+
|
91
|
+
Metrics/PerceivedComplexity:
|
92
|
+
Max: 20
|
93
|
+
|
94
|
+
# Sometimes it's easier to read without guards
|
95
|
+
Style/GuardClause:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
# We allow both " and '
|
99
|
+
Style/StringLiterals:
|
100
|
+
Enabled: false
|
101
|
+
|
102
|
+
# something = if something_else
|
103
|
+
# that's confusing
|
104
|
+
Style/ConditionalAssignment:
|
105
|
+
Enabled: false
|
106
|
+
|
107
|
+
# Better to have too much self than missing a self
|
108
|
+
Style/RedundantSelf:
|
109
|
+
Enabled: false
|
110
|
+
|
111
|
+
# e.g.
|
112
|
+
# def self.is_supported?(platform)
|
113
|
+
# we may never use `platform`
|
114
|
+
Lint/UnusedMethodArgument:
|
115
|
+
Enabled: false
|
116
|
+
|
117
|
+
# the let(:key) { ... }
|
118
|
+
Lint/ParenthesesAsGroupedExpression:
|
119
|
+
Exclude:
|
120
|
+
- '**/spec/**/*'
|
121
|
+
|
122
|
+
# This would reject is_ in front of methods
|
123
|
+
# We use `is_supported?` everywhere already
|
124
|
+
Style/PredicateName:
|
125
|
+
Enabled: false
|
126
|
+
|
127
|
+
# We allow the $
|
128
|
+
Style/PerlBackrefs:
|
129
|
+
Enabled: false
|
130
|
+
|
131
|
+
# Disable '+ should be surrounded with a single space' for xcodebuild_spec.rb
|
132
|
+
Style/SpaceAroundOperators:
|
133
|
+
Exclude:
|
134
|
+
- '**/spec/actions_specs/xcodebuild_spec.rb'
|
135
|
+
|
136
|
+
AllCops:
|
137
|
+
Include:
|
138
|
+
- '**/fastlane/Fastfile'
|
139
|
+
Exclude:
|
140
|
+
- './vendor/**/*'
|
141
|
+
- db/schema.rb
|
142
|
+
|
143
|
+
# We're not there yet
|
144
|
+
Style/Documentation:
|
145
|
+
Enabled: false
|
146
|
+
|
147
|
+
# Added after upgrade to 0.38.0
|
148
|
+
Style/MutableConstant:
|
149
|
+
Enabled: false
|
150
|
+
|
151
|
+
# length > 0 is good
|
152
|
+
Style/ZeroLengthPredicate:
|
153
|
+
Enabled: false
|
154
|
+
|
155
|
+
# Adds complexity
|
156
|
+
Style/IfInsideElse:
|
157
|
+
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -1,26 +1,28 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
maglove (0.
|
5
|
-
actionpack (
|
6
|
-
activesupport (
|
4
|
+
maglove (1.0.2)
|
5
|
+
actionpack (>= 4.0)
|
6
|
+
activesupport (>= 4.0)
|
7
7
|
bundler (~> 1.10)
|
8
8
|
coffee-script (~> 2.4)
|
9
|
-
|
10
|
-
|
9
|
+
dialers (~> 0.2)
|
10
|
+
faraday (~> 0.9)
|
11
|
+
faye (~> 1.2)
|
11
12
|
filewatcher (~> 0.5)
|
12
13
|
haml (~> 4.0)
|
13
|
-
hamloft (~> 0.2.
|
14
|
+
hamloft (~> 0.2.4)
|
14
15
|
image_optim (~> 0.21)
|
15
16
|
image_optim_pack (~> 0.2)
|
16
17
|
less (~> 2.6)
|
17
18
|
logging (~> 2.0)
|
18
|
-
|
19
|
+
maglove-widgets (~> 1.0)
|
20
|
+
open_uri_redirections (~> 0.2)
|
21
|
+
puma (~> 3.6)
|
19
22
|
rubyzip (~> 1.1)
|
20
23
|
sass (~> 3.4)
|
21
|
-
|
24
|
+
thor (~> 0.19)
|
22
25
|
tilt (~> 1.4)
|
23
|
-
webrick (~> 1.3)
|
24
26
|
|
25
27
|
GEM
|
26
28
|
remote: https://rubygems.org/
|
@@ -43,31 +45,58 @@ GEM
|
|
43
45
|
i18n (~> 0.7)
|
44
46
|
minitest (~> 5.1)
|
45
47
|
tzinfo (~> 1.1)
|
48
|
+
addressable (2.4.0)
|
46
49
|
ast (2.3.0)
|
47
50
|
builder (3.2.2)
|
48
|
-
coderay (1.1.1)
|
49
51
|
coffee-script (2.4.1)
|
50
52
|
coffee-script-source
|
51
53
|
execjs
|
52
54
|
coffee-script-source (1.10.0)
|
53
|
-
commander (4.4.0)
|
54
|
-
highline (~> 1.7.2)
|
55
55
|
commonjs (0.2.7)
|
56
56
|
concurrent-ruby (1.0.2)
|
57
|
-
|
58
|
-
|
57
|
+
cookiejar (0.3.3)
|
58
|
+
dialers (0.2.2)
|
59
|
+
faraday (~> 0.9)
|
60
|
+
faraday-conductivity (~> 0.3)
|
61
|
+
faraday_middleware (~> 0.9)
|
62
|
+
em-http-request (1.1.5)
|
63
|
+
addressable (>= 2.3.4)
|
64
|
+
cookiejar (!= 0.3.1)
|
65
|
+
em-socksify (>= 0.3)
|
66
|
+
eventmachine (>= 1.0.3)
|
67
|
+
http_parser.rb (>= 0.6.0)
|
68
|
+
em-socksify (0.3.1)
|
69
|
+
eventmachine (>= 1.0.0.beta.4)
|
59
70
|
erubis (2.7.0)
|
71
|
+
eventmachine (1.2.0.1)
|
60
72
|
execjs (2.7.0)
|
61
73
|
exifr (1.2.5)
|
74
|
+
faraday (0.9.2)
|
75
|
+
multipart-post (>= 1.2, < 3)
|
76
|
+
faraday-conductivity (0.3.1)
|
77
|
+
faraday (~> 0.8)
|
78
|
+
faraday_middleware (0.10.0)
|
79
|
+
faraday (>= 0.7.4, < 0.10)
|
80
|
+
faye (1.2.3)
|
81
|
+
cookiejar (>= 0.3.0)
|
82
|
+
em-http-request (>= 0.3.0)
|
83
|
+
eventmachine (>= 0.12.0)
|
84
|
+
faye-websocket (>= 0.9.1)
|
85
|
+
multi_json (>= 1.0.0)
|
86
|
+
rack (>= 1.0.0)
|
87
|
+
websocket-driver (>= 0.5.1)
|
88
|
+
faye-websocket (0.10.4)
|
89
|
+
eventmachine (>= 0.12.0)
|
90
|
+
websocket-driver (>= 0.5.1)
|
62
91
|
filewatcher (0.5.3)
|
63
92
|
trollop (~> 2.0)
|
64
93
|
fspath (3.0.1)
|
65
94
|
haml (4.0.7)
|
66
95
|
tilt
|
67
|
-
hamloft (0.2.
|
96
|
+
hamloft (0.2.4)
|
68
97
|
haml (~> 4.0)
|
69
98
|
nokogiri (~> 1.6)
|
70
|
-
|
99
|
+
http_parser.rb (0.6.0)
|
71
100
|
i18n (0.7.0)
|
72
101
|
image_optim (0.24.0)
|
73
102
|
exifr (~> 1.2, >= 1.2.2)
|
@@ -75,37 +104,35 @@ GEM
|
|
75
104
|
image_size (~> 1.3)
|
76
105
|
in_threads (~> 1.3)
|
77
106
|
progress (~> 3.0, >= 3.0.1)
|
78
|
-
image_optim_pack (0.3.0.
|
107
|
+
image_optim_pack (0.3.0.20161021)
|
79
108
|
fspath (>= 2.1, < 4)
|
80
109
|
image_optim (~> 0.19)
|
81
110
|
image_size (1.4.2)
|
82
111
|
in_threads (1.3.1)
|
83
112
|
less (2.6.0)
|
84
113
|
commonjs (~> 0.2.7)
|
85
|
-
libv8 (3.16.14.15)
|
86
114
|
little-plugger (1.1.4)
|
87
115
|
logging (2.1.0)
|
88
116
|
little-plugger (~> 1.1)
|
89
117
|
multi_json (~> 1.10)
|
90
118
|
loofah (2.0.3)
|
91
119
|
nokogiri (>= 1.5.9)
|
92
|
-
|
120
|
+
maglove-widgets (1.0.0)
|
121
|
+
bundler (~> 1.10)
|
122
|
+
haml (~> 4.0)
|
123
|
+
hamloft (~> 0.2.4)
|
93
124
|
mini_portile2 (2.1.0)
|
94
|
-
|
95
|
-
minitest (5.9.0)
|
125
|
+
minitest (5.9.1)
|
96
126
|
multi_json (1.12.1)
|
97
|
-
|
127
|
+
multipart-post (2.0.0)
|
128
|
+
nokogiri (1.6.8.1)
|
98
129
|
mini_portile2 (~> 2.1.0)
|
99
|
-
|
130
|
+
open_uri_redirections (0.2.1)
|
100
131
|
parser (2.3.1.2)
|
101
132
|
ast (~> 2.2)
|
102
|
-
pkg-config (1.1.7)
|
103
133
|
powerpack (0.1.1)
|
104
134
|
progress (3.2.2)
|
105
|
-
|
106
|
-
coderay (~> 1.1.0)
|
107
|
-
method_source (~> 0.8.1)
|
108
|
-
slop (~> 3.4)
|
135
|
+
puma (3.6.0)
|
109
136
|
rack (2.0.1)
|
110
137
|
rack-test (0.6.3)
|
111
138
|
rack (>= 1.0)
|
@@ -115,20 +142,6 @@ GEM
|
|
115
142
|
rails-html-sanitizer (1.0.3)
|
116
143
|
loofah (~> 2.0)
|
117
144
|
rainbow (2.1.0)
|
118
|
-
ref (2.0.0)
|
119
|
-
rspec (3.5.0)
|
120
|
-
rspec-core (~> 3.5.0)
|
121
|
-
rspec-expectations (~> 3.5.0)
|
122
|
-
rspec-mocks (~> 3.5.0)
|
123
|
-
rspec-core (3.5.2)
|
124
|
-
rspec-support (~> 3.5.0)
|
125
|
-
rspec-expectations (3.5.0)
|
126
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
127
|
-
rspec-support (~> 3.5.0)
|
128
|
-
rspec-mocks (3.5.0)
|
129
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
130
|
-
rspec-support (~> 3.5.0)
|
131
|
-
rspec-support (3.5.0)
|
132
145
|
rubocop (0.42.0)
|
133
146
|
parser (>= 2.3.1.1, < 3.0)
|
134
147
|
powerpack (~> 0.1)
|
@@ -138,25 +151,22 @@ GEM
|
|
138
151
|
ruby-progressbar (1.8.1)
|
139
152
|
rubyzip (1.2.0)
|
140
153
|
sass (3.4.22)
|
141
|
-
|
142
|
-
therubyracer (0.12.2)
|
143
|
-
libv8 (~> 3.16.14.0)
|
144
|
-
ref
|
154
|
+
thor (0.19.1)
|
145
155
|
thread_safe (0.3.5)
|
146
156
|
tilt (1.4.1)
|
147
157
|
trollop (2.1.2)
|
148
158
|
tzinfo (1.2.2)
|
149
159
|
thread_safe (~> 0.1)
|
150
160
|
unicode-display_width (1.1.0)
|
151
|
-
|
161
|
+
websocket-driver (0.6.4)
|
162
|
+
websocket-extensions (>= 0.1.0)
|
163
|
+
websocket-extensions (0.1.2)
|
152
164
|
|
153
165
|
PLATFORMS
|
154
166
|
ruby
|
155
167
|
|
156
168
|
DEPENDENCIES
|
157
169
|
maglove!
|
158
|
-
pry (~> 0.10)
|
159
|
-
rspec (~> 3.3)
|
160
170
|
rubocop (~> 0.32)
|
161
171
|
|
162
172
|
BUNDLED WITH
|
data/bin/maglove
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
$:.push
|
3
|
-
|
2
|
+
$:.push("lib/")
|
3
|
+
require "thor"
|
4
|
+
require "ext/thor/option"
|
5
|
+
require 'coffee_script'
|
6
|
+
require "active_support/all"
|
7
|
+
require "hamloft"
|
8
|
+
require "workspace"
|
4
9
|
require "maglove"
|
10
|
+
require "action_dispatch/http/mime_type"
|
5
11
|
|
6
|
-
|
12
|
+
# require local widgets
|
13
|
+
Dir["widgets/*.rb"].each { |path| require File.join(Dir.pwd, path) }
|
7
14
|
|
8
|
-
#
|
9
|
-
|
10
|
-
Tilt.mappings["haml"] = [MagLove::Tilt::HamlTemplate]
|
11
|
-
Tilt.mappings["scss"] = [MagLove::Tilt::ScssTemplate]
|
12
|
-
Tilt.mappings["less"] = [MagLove::Tilt::LessTemplate]
|
13
|
-
Tilt.mappings["yml"] = [MagLove::Tilt::YamlTemplate]
|
14
|
-
Tilt.mappings["coffee"] = [MagLove::Tilt::CoffeeTemplate]
|
15
|
-
Tilt.mappings["js"] = [MagLove::Tilt::JsTemplate]
|
16
|
-
Tilt.mappings["twig"] = [MagLove::Tilt::TwigTemplate]
|
15
|
+
# allow colons
|
16
|
+
ARGV.unshift(*ARGV.shift.split(":")) if ARGV.count > 0 and ARGV[0].include?(":")
|
17
17
|
|
18
|
-
MagLove::
|
18
|
+
MagLove::Commands::Main.start
|
@@ -0,0 +1,11 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%meta{ charset: "UTF-8" }
|
5
|
+
%title= "#{theme} - EXPORT"
|
6
|
+
%meta{ name: "viewport", content: "width=device-width, initial-scale=1.0" }
|
7
|
+
%link{ href: asset("theme.css"), media: "screen", rel: "stylesheet" }
|
8
|
+
%link{ href: root_asset("fonts/fonts.css"), media: "screen", rel: "stylesheet" }
|
9
|
+
%script{ src: asset("theme.js"), type: "text/javascript" }
|
10
|
+
%body
|
11
|
+
= contents
|
@@ -0,0 +1,17 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%meta{ charset: "UTF-8" }
|
5
|
+
%title= "#{theme} - INDEX"
|
6
|
+
%meta{ name: "viewport", content: "width=device-width, initial-scale=1.0" }
|
7
|
+
%meta{ name: "pageid", content: "0" }
|
8
|
+
%link{ href: "/fonts/fonts.css", media: "screen", rel: "stylesheet" }
|
9
|
+
%link{ href: "/maglove.css", media: "screen", rel: "stylesheet" }
|
10
|
+
%body#index
|
11
|
+
#templates-container
|
12
|
+
- templates.each do |template|
|
13
|
+
%div.template-item
|
14
|
+
%a.template{href: "/#{template}", style: "background-image: url(#{MagLoft::ApiCaller::MAGLOFT_CDN_URL}/themes/#{theme}/thumbnails/#{template}.png);"}
|
15
|
+
%div.template-label
|
16
|
+
%span
|
17
|
+
#{template}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
body#index {
|
2
|
+
padding: 0;
|
3
|
+
margin: 0;
|
4
|
+
font-family: "Helvetica Neue", Helvetica;
|
5
|
+
background: #F5F5F5;
|
6
|
+
}
|
7
|
+
|
8
|
+
div#templates-container {
|
9
|
+
display: flex;
|
10
|
+
position: relative;
|
11
|
+
flex-wrap: wrap;
|
12
|
+
padding: 10px;
|
13
|
+
margin: 0px auto;
|
14
|
+
max-width: 1024px;
|
15
|
+
}
|
16
|
+
|
17
|
+
div#templates-container .template-item {
|
18
|
+
flex: 1;
|
19
|
+
min-width: 300px;
|
20
|
+
margin: 10px;
|
21
|
+
position: relative;
|
22
|
+
border: 4px solid #FFFFFF;
|
23
|
+
}
|
24
|
+
|
25
|
+
div#templates-container .template-item a.template {
|
26
|
+
position: relative;
|
27
|
+
padding-top: 133.333%;
|
28
|
+
background-size: cover;
|
29
|
+
background-repeat: no-repeat;
|
30
|
+
background-position: center center;
|
31
|
+
background-color: #EEEEEE;
|
32
|
+
display: flex;
|
33
|
+
color: #FFFFFF;
|
34
|
+
text-shadow: 0px 1px 4px #000;
|
35
|
+
}
|
36
|
+
|
37
|
+
div#templates-container .template-item a.template:hover .template-label {
|
38
|
+
background-color: rgba(0,0,0,0.5);
|
39
|
+
color: #FFFFFF;
|
40
|
+
}
|
41
|
+
|
42
|
+
div#templates-container .template-item a.template .template-label {
|
43
|
+
position: absolute;
|
44
|
+
top: 0;
|
45
|
+
left: 0;
|
46
|
+
right: 0;
|
47
|
+
bottom: 0;
|
48
|
+
transition: background-color 250ms, color 250ms;
|
49
|
+
display: flex;
|
50
|
+
align-items: center;
|
51
|
+
justify-content: center;
|
52
|
+
text-decoration: none;
|
53
|
+
}
|
54
|
+
|
55
|
+
div#templates-container .template-item a.template .template-label span {
|
56
|
+
font-weight: bold;
|
57
|
+
text-align: center;
|
58
|
+
font-size: 20px;
|
59
|
+
text-transform: uppercase;
|
60
|
+
padding: 20px;
|
61
|
+
border-radius: 4px;
|
62
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%meta{ charset: "UTF-8" }
|
5
|
+
%title= "#{theme} - #{template}"
|
6
|
+
%meta{ name: "viewport", content: "width=device-width, initial-scale=1.0" }
|
7
|
+
%meta{ name: "pageid", content: "0" }
|
8
|
+
%style{ type: "text/css", id: "theme-css" }
|
9
|
+
= css_contents
|
10
|
+
%link{ href: "/fonts/fonts.css", media: "screen", rel: "stylesheet" }
|
11
|
+
%script{ type: "text/javascript", id: "theme-js" }
|
12
|
+
= js_contents
|
13
|
+
%script{ src: "/maglove.js", type: "text/javascript" }
|
14
|
+
%link{ href: "/maglove.css", media: "screen", rel: "stylesheet" }
|
15
|
+
:javascript
|
16
|
+
const maglove = new MagLove("#{template}", "127.0.0.1", "#{port}")
|
17
|
+
%body
|
18
|
+
= contents
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class MagLove {
|
2
|
+
|
3
|
+
constructor(template, host="127.0.0.1", port="3000", endpoint="maglove") {
|
4
|
+
this.template = template
|
5
|
+
this.templates = []
|
6
|
+
this.host = host
|
7
|
+
this.port = port
|
8
|
+
this.endpoint = endpoint
|
9
|
+
this.socket = null
|
10
|
+
|
11
|
+
// Connect to WebSocket
|
12
|
+
this.socket = new WebSocket(`ws://${this.host}:${this.port}/${this.endpoint}`)
|
13
|
+
this.socket.onopen = this.onSocketOpen.bind(this)
|
14
|
+
this.socket.onmessage = this.onSocketMessage.bind(this)
|
15
|
+
this.socket.onclose = this.onSocketClose.bind(this)
|
16
|
+
}
|
17
|
+
|
18
|
+
onSocketOpen(event) {
|
19
|
+
console.log("MagLove Opened")
|
20
|
+
this.send("init")
|
21
|
+
}
|
22
|
+
|
23
|
+
onSocketMessage(event) {
|
24
|
+
const message = JSON.parse(event.data)
|
25
|
+
this[message.command](message)
|
26
|
+
}
|
27
|
+
|
28
|
+
onSocketClose(event) {
|
29
|
+
console.log("MagLove Closed")
|
30
|
+
}
|
31
|
+
|
32
|
+
send(command, data={}) {
|
33
|
+
data.command = command
|
34
|
+
this.socket.send(JSON.stringify(data))
|
35
|
+
}
|
36
|
+
|
37
|
+
init(message) {
|
38
|
+
console.log("MagLove Initialized")
|
39
|
+
this.templates = message.templates
|
40
|
+
this.send("watch")
|
41
|
+
if(window.ThemeApi) {
|
42
|
+
window.ThemeApi.init({deviceId: 'AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE', appId: 'com.magloft.maglove', apiHost: 'www.magloft.com'})
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
html(message) {
|
47
|
+
if(message.template === this.template) {
|
48
|
+
document.body.innerHTML = message.contents
|
49
|
+
}
|
50
|
+
$(window.document).trigger("typeloftWidgetChanged")
|
51
|
+
}
|
52
|
+
|
53
|
+
css(message) {
|
54
|
+
document.getElementById("theme-css").textContent = message.contents
|
55
|
+
}
|
56
|
+
|
57
|
+
js(message) {
|
58
|
+
document.getElementById("theme-js").remove()
|
59
|
+
let script = document.createElement('script')
|
60
|
+
script.id = "theme-js"
|
61
|
+
script.textContent = message.contents
|
62
|
+
document.getElementsByTagName('head')[0].appendChild(script)
|
63
|
+
|
64
|
+
if(window.ThemeApi) {
|
65
|
+
window.ThemeApi.init({deviceId: 'AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE', appId: 'com.magloft.maglove', apiHost: 'www.magloft.com'})
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Thor
|
2
|
+
class Option
|
3
|
+
attr_reader :validator
|
4
|
+
|
5
|
+
def initialize(name, options = {})
|
6
|
+
options[:required] = false unless options.key?(:required)
|
7
|
+
super
|
8
|
+
@lazy_default = options[:lazy_default]
|
9
|
+
@group = options[:group].to_s.capitalize if options[:group]
|
10
|
+
@aliases = Array(options[:aliases])
|
11
|
+
@hide = options[:hide]
|
12
|
+
@validator = options[:validator]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Options
|
17
|
+
# Parse the value at the peek analyzing if it requires an input or not.
|
18
|
+
#
|
19
|
+
def parse_peek(switch, option)
|
20
|
+
if parsing_options? && (current_is_switch_formatted? || last?)
|
21
|
+
if option.boolean?
|
22
|
+
# No problem for boolean types
|
23
|
+
elsif no_or_skip?(switch)
|
24
|
+
return nil # User set value to nil
|
25
|
+
elsif option.string? && !option.required?
|
26
|
+
# Return the default if there is one, else the human name
|
27
|
+
return option.lazy_default || option.default || option.human_name
|
28
|
+
elsif option.lazy_default
|
29
|
+
return option.lazy_default
|
30
|
+
else
|
31
|
+
fail MalformattedArgumentError, "No value provided for option '#{switch}'"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
@non_assigned_required.delete(option)
|
36
|
+
if option.validator and !option.validator.validate(switch, peek)
|
37
|
+
fail MalformattedArgumentError, option.validator.message(switch, peek)
|
38
|
+
end
|
39
|
+
|
40
|
+
send(:"parse_#{option.type}", switch)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/magloft/api.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "dialers"
|
2
|
+
require "magloft/api_caller"
|
3
|
+
require "magloft/remote_collection"
|
4
|
+
require "magloft/remote_resource"
|
5
|
+
require "magloft/transformable"
|
6
|
+
require "magloft/typeloft_block"
|
7
|
+
require "magloft/typeloft_image"
|
8
|
+
require "magloft/typeloft_template"
|
9
|
+
require "magloft/typeloft_theme"
|
10
|
+
|
11
|
+
module MagLoft
|
12
|
+
class Api < Dialers::Wrapper
|
13
|
+
attr_accessor :token
|
14
|
+
|
15
|
+
def self.client(token = nil)
|
16
|
+
@client ||= self.new(token)
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(token)
|
20
|
+
@token = token
|
21
|
+
end
|
22
|
+
|
23
|
+
def api_caller
|
24
|
+
@api_caller ||= ApiCaller.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def typeloft_themes
|
28
|
+
TypeloftTheme
|
29
|
+
end
|
30
|
+
|
31
|
+
def typeloft_templates
|
32
|
+
TypeloftTemplate
|
33
|
+
end
|
34
|
+
|
35
|
+
def typeloft_blocks
|
36
|
+
TypeloftBlock
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|