f2h 0.9.0 → 0.9.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a64482627b170ed10b576eb0ffaf51b9f1584b7
4
- data.tar.gz: 3f0e18d4508f97f88e7bbd7e872d37e8eae364fc
3
+ metadata.gz: 94cce1e9d62e393c259daf5d66fb15292d9b1116
4
+ data.tar.gz: c19bb0243c002f9911ebe8a4b48b8e2bc16c4614
5
5
  SHA512:
6
- metadata.gz: b6c533ea3ad794ffa3fbd69145a3ec3b43810a6462256edd4c8d68288be30dfc4d5262f99b2d4b52929ff1c11dace9a0f08494bd1d124906877b9a539a44a2a3
7
- data.tar.gz: 5294be14f4144fb97937b29705bfbb75d705319ba84fd06c42406dd1fe62294001f13422e25244810eebe26b0b031054b3367662ff583a36fe3a9dce47cf0a50
6
+ metadata.gz: 44299ad1e43b341817a800e0796a4fd5e6800734bc230564368e675b8837fde589c538dff374cb5972f94024f005fa45300209c63e0842efd3078c3260e21424
7
+ data.tar.gz: 3b35a618c6ca5ccebd6b9959abe55d9591ca8c2454ab18476ca73ddedda1d70631f7db5615133909a07be1d6a394ac9f37d361bf0869395ebd51fc6288315900
data/.DS_Store CHANGED
Binary file
data/f2h.gemspec CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["ismailkalimi@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Generates boilerplate code for HTML5 creatives from Flash files}
13
- spec.description = %q{This just generates and downloads sane defaults for html5 animations from Flash}
14
- spec.homepage = "https://ikalimi.com/flash2html"
13
+ spec.description = %q{Boilerplate code that provides sane default settings when making html5 assets using html,css and js from Flash creatives}
14
+ spec.homepage = "https://github.com/ismk/Flash2HTML"
15
15
  spec.license = "MIT"
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,355 @@
1
+ module F2h
2
+ class Boilerplate
3
+
4
+
5
+ #===================== BOX BOILERPLATE ==============================
6
+
7
+ def html_boilerplate(foldername, type)
8
+ <<-eos
9
+ <!DOCTYPE html>
10
+ <html lang="en">
11
+ <head>
12
+ <meta charset="UTF-8">
13
+ <title></title>
14
+ <link rel="stylesheet" href="css/#{foldername}_#{type}.css">
15
+ <script src="js/jquery.min.js"></script>
16
+ <script src="js/TweenMax.min.js"></script>
17
+ <script src="js/#{foldername}_#{type}.js"></script>
18
+ </head>
19
+ <body>
20
+
21
+ <div id="overall_mask"></div>
22
+
23
+ <!-- Start-of-the-Image-Tags -->
24
+ <!-- End-of-the-Image-Tags -->
25
+
26
+ <!-- Start-of-the-ISI -->
27
+ <div id="isi"></div>
28
+ <!-- End-of-the-ISI -->
29
+
30
+ </body>
31
+ </html>
32
+ eos
33
+ end
34
+
35
+ def box_css_boilerplate
36
+ <<-eos
37
+ body{
38
+ position: fixed;
39
+ padding: 0;
40
+ margin: 0;
41
+ top: 0;
42
+ left: 0;
43
+ }
44
+
45
+ #overall_mask{
46
+ position: absolute;
47
+ height: 250px;
48
+ width: 300px;
49
+ }
50
+
51
+
52
+
53
+
54
+
55
+
56
+ /* Start-of-the-ISI */
57
+ #isi{
58
+ position: absolute;
59
+ background-color: white;
60
+ top: 250px;
61
+ width: 300px;
62
+ height: 76px;
63
+ font-size: 12px;
64
+ overflow-y: scroll;
65
+ overflow-x: hidden;
66
+ font-family: "Arial-Narrow";
67
+ padding-left: 5px;
68
+ }
69
+
70
+ #isi::-webkit-scrollbar {
71
+ width: 20px;
72
+ }
73
+
74
+ #isi::-webkit-scrollbar-button:vertical:start:increment{
75
+ display: block;
76
+ background-image: url();
77
+ background-repeat: no-repeat;
78
+ background-position: center;
79
+ }
80
+
81
+ #isi::-webkit-scrollbar-button:vertical:end:increment{
82
+ display: block;
83
+ background-image: url();
84
+ background-repeat: no-repeat;
85
+ background-position: center;
86
+ }
87
+
88
+ #isi::-webkit-scrollbar-track {
89
+ background-image: url();
90
+ background-position: center;
91
+ background-repeat: no-repeat;
92
+ background-size: 4px 97%;
93
+ }
94
+
95
+ #isi::-webkit-scrollbar-thumb {
96
+ height: 25px;
97
+ background-image: url();
98
+ background-position: center;
99
+ background-repeat: no-repeat;
100
+ }
101
+ /* End-of-the-ISI */
102
+
103
+ eos
104
+ end
105
+
106
+ def box_js_boilerplate
107
+ <<-eos
108
+ $(function(){
109
+ // WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.flashAdImpressionTrack('box-ad')");
110
+
111
+ //Start-of-the-animation-code
112
+ //End-of-the-animation-code
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ function autoScroll(){
124
+ ascroll = setInterval(function(){
125
+ elem = $("#isi")[0];
126
+ if (elem.scrollTop != 1075){
127
+ elem.scrollTop += 2;
128
+ }
129
+ }, 200);
130
+ }
131
+
132
+ $(document).on("touchstart", "#isi", function(){
133
+ clearInterval(ascroll);
134
+ });
135
+
136
+
137
+ $("#overall_mask").on("click", function(){
138
+ console.log("overall mask was clicked");
139
+ WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('', '<div data-advtype=box-mainClickThrough/>')");
140
+ });
141
+
142
+ $("#fdaBtn").on("click", function(){
143
+ console.log("fda btn open button clicked");
144
+ WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://www.fda.gov/medwatch/', '<div data-advtype=box-fda-medwatch/>')");
145
+ });
146
+
147
+ $("#pi").on("click", function(){
148
+ console.log("pi button clicked");
149
+ WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=box-pres-info/>')");
150
+ });
151
+
152
+ $("#medguide").on("click", function(){
153
+ console.log("medguide button clicked");
154
+ WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=box-med-guide/>')");
155
+ });
156
+
157
+
158
+ });
159
+
160
+ eos
161
+ end
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+ ######################## BANNER BOILERPLATE ##########################
174
+
175
+ def banner_css_boilerplate
176
+ <<-eos
177
+ body{
178
+ position: fixed;
179
+ padding: 0;
180
+ margin: 0;
181
+ top: 0;
182
+ left: 0;
183
+ }
184
+
185
+ #overall_mask{
186
+ position: absolute;
187
+ height: 90px;
188
+ width: 728px;
189
+ }
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+ /* Start-of-the-ISI */
198
+ #isi{
199
+ position: absolute;
200
+ background-color: white;
201
+ border-left: 1px solid gray;
202
+ top: 18px;
203
+ left: 428px;
204
+ width: 300px;
205
+ height: 72px;
206
+ font-size: 11px;
207
+ overflow-y: scroll;
208
+ overflow-x: hidden;
209
+ font-family: "Arial-Narrow";
210
+ padding-left: 5px;
211
+ }
212
+
213
+ #isi::-webkit-scrollbar {
214
+ width: 30px;
215
+ margin-top: 10px
216
+ }
217
+
218
+ #isi::-webkit-scrollbar-button:vertical:start:increment{
219
+ display: block;
220
+ background-image: url();
221
+ background-repeat: no-repeat;
222
+ background-position: center;
223
+ }
224
+
225
+ #isi::-webkit-scrollbar-button:vertical:end:increment{
226
+ display: block;
227
+ background-image: url();
228
+ background-repeat: no-repeat;
229
+ background-position: center;
230
+ }
231
+
232
+ #isi::-webkit-scrollbar-track {
233
+ background-image: url();
234
+ background-position: center;
235
+ background-repeat: no-repeat;
236
+ background-size: 4px 90%;
237
+ }
238
+
239
+ #isi::-webkit-scrollbar-thumb {
240
+ height: 25px;
241
+ background-image: url();
242
+ background-position: center;
243
+ background-repeat: no-repeat;
244
+ }
245
+ /* End-of-the-ISI */
246
+
247
+ eos
248
+ end
249
+
250
+ def banner_js_boilerplate
251
+ <<-eos
252
+ $(function(){
253
+ // WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.flashAdImpressionTrack('banner-ad')");
254
+
255
+ //Start-of-the-animation-code
256
+ //End-of-the-animation-code
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+ function autoScroll(){
265
+ ascroll = setInterval(function(){
266
+ elem = $("#isi")[0];
267
+ if (elem.scrollTop != 1075){
268
+ elem.scrollTop += 2;
269
+ }
270
+ }, 200);
271
+ }
272
+
273
+ $(document).on("touchstart", "#isi", function(){
274
+ clearInterval(ascroll);
275
+ });
276
+
277
+
278
+ $("#overall_mask").on("click", function(){
279
+ console.log("overall mask was clicked");
280
+ WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('', '<div data-advtype=banner-mainClickThrough/>')");
281
+ });
282
+
283
+ $("#fdaBtn").on("click", function(){
284
+ console.log("fda btn open button clicked");
285
+ WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://www.fda.gov/medwatch/', '<div data-advtype=banner-fda-medwatch/>')");
286
+ });
287
+
288
+ $("#pi").on("click", function(){
289
+ console.log("pi button clicked");
290
+ WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=banner-pres-info/>')");
291
+ });
292
+
293
+ $("#medguide").on("click", function(){
294
+ console.log("medguide button clicked");
295
+ WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=banner-med-guide/>')");
296
+ });
297
+
298
+
299
+ });
300
+
301
+ eos
302
+ end
303
+
304
+ def pdf_html
305
+ <<-eos
306
+ <!doctype html>
307
+ <html>
308
+ <head>
309
+ <meta charset="utf-8">
310
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
311
+ <title></title>
312
+ <style>
313
+ img{
314
+ display: block;
315
+ width:100%;
316
+ }
317
+ </style>
318
+ </head>
319
+
320
+ <body>
321
+ </body>
322
+ </html>
323
+ eos
324
+ end
325
+
326
+
327
+
328
+ #==================================================
329
+
330
+ def img_html(filename, loc)
331
+ <<-eos
332
+ <img id="#{filename}" src="#{loc}_images/#{filename}.png" alt="">
333
+ eos
334
+ end
335
+
336
+ def img_css(filename)
337
+ <<-eos
338
+
339
+ ##{filename}{
340
+ position: absolute;
341
+ top: 0;
342
+ left: 0;
343
+ }
344
+
345
+ eos
346
+ end
347
+
348
+ def img_js(filename)
349
+ <<-eos
350
+ TweenMax.to(#{filename}, 0.0, {});
351
+ eos
352
+ end
353
+
354
+ end
355
+ end
data/lib/f2h/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module F2h
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.2"
3
3
  end
data/lib/f2h.rb CHANGED
@@ -1,468 +1,29 @@
1
+ require_relative 'boilerplate'
2
+ require_relative 'initial_files'
3
+ require_relative 'pdf2img'
4
+ require_relative 'insert_tags'
5
+
1
6
  require "f2h/version"
2
7
  require 'rmagick'
3
8
 
4
9
  module F2h
5
10
  class Flash2HTML
6
11
 
7
- #===================== BOX BOILERPLATE ==============================
8
-
9
- def html_boilerplate(foldername, type)
10
- <<eos
11
- <!DOCTYPE html>
12
- <html lang="en">
13
- <head>
14
- <meta charset="UTF-8">
15
- <title></title>
16
- <link rel="stylesheet" href="css/#{foldername}_#{type}.css">
17
- <script src="js/jquery.min.js"></script>
18
- <script src="js/TweenMax.min.js"></script>
19
- <script src="js/#{foldername}_#{type}.js"></script>
20
- </head>
21
- <body>
22
-
23
-
24
- <!-- Start-of-the-Image-Tags -->
25
- <!-- End-of-the-Image-Tags -->
26
-
27
- <!-- Start-of-the-ISI -->
28
- <div id="isi"></div>
29
- <!-- End-of-the-ISI -->
30
-
31
- </body>
32
- </html>
33
- eos
34
- end
35
-
36
- def box_css_boilerplate
37
- <<eos
38
- body{
39
- position: fixed;
40
- padding: 0;
41
- margin: 0;
42
- top: 0;
43
- left: 0;
44
- }
45
-
46
- #overall_mask{
47
- position: absolute;
48
- height: 250px;
49
- width: 300px;
50
- }
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
- /* Start-of-the-ISI */
59
- #isi{
60
- position: absolute;
61
- background-color: white;
62
- top: 250px;
63
- width: 300px;
64
- height: 76px;
65
- font-size: 12px;
66
- overflow-y: scroll;
67
- overflow-x: hidden;
68
- font-family: "Arial-Narrow";
69
- padding-left: 5px;
70
- }
71
-
72
- #isi::-webkit-scrollbar {
73
- width: 20px;
74
- }
75
-
76
- #isi::-webkit-scrollbar-track {
77
- background-image: url();
78
- background-position: center;
79
- background-repeat: no-repeat;
80
- background-size: 4px 97%;
81
- }
82
-
83
- #isi::-webkit-scrollbar-thumb {
84
- height: 25px;
85
- background-image: url();
86
- background-position: center;
87
- background-repeat: no-repeat;
88
- }
89
- /* End-of-the-ISI */
90
-
91
- eos
92
- end
93
-
94
- def box_js_boilerplate
95
- <<eos
96
- $(function(){
97
- // WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.flashAdImpressionTrack('box-ad')");
98
-
99
- //Start-of-the-animation-code
100
- //End-of-the-animation-code
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
- function autoScroll(){
117
- ascroll = setInterval(function(){
118
- elem = $("#isi")[0];
119
- if (elem.scrollTop != 1075){
120
- elem.scrollTop += 2;
121
- }
122
- }, 200);
123
- }
124
-
125
- $(document).on("touchstart", "#isi", function(){
126
- clearInterval(ascroll);
127
- });
128
-
129
-
130
- $("#overall_mask").on("click", function(){
131
- console.log("overall mask was clicked");
132
- WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('', '<div data-advtype=box-mainClickThrough/>')");
133
- });
134
-
135
- $("#fdaBtn").on("click", function(){
136
- console.log("fda btn open button clicked");
137
- WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://www.fda.gov/medwatch/', '<div data-advtype=box-fda-medwatch/>')");
138
- });
139
-
140
- $("#pi").on("click", function(){
141
- console.log("pi button clicked");
142
- WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=box-pres-info/>')");
143
- });
144
-
145
- $("#medguide").on("click", function(){
146
- console.log("medguide button clicked");
147
- WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=box-med-guide/>')");
148
- });
149
-
150
-
151
- });
152
-
153
- eos
154
- end
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
- ######################## BANNER BOILERPLATE ##########################
167
-
168
- def banner_css_boilerplate
169
- <<eos
170
- body{
171
- position: fixed;
172
- padding: 0;
173
- margin: 0;
174
- top: 0;
175
- left: 0;
176
- }
177
-
178
- #overall_mask{
179
- position: absolute;
180
- height: 90px;
181
- width: 728px;
182
- }
183
-
184
- /* Start-of-the-ISI */
185
- #isi{
186
- position: absolute;
187
- background-color: white;
188
- border-left: 1px solid gray;
189
- top: 18px;
190
- left: 428px;
191
- width: 300px;
192
- height: 72px;
193
- font-size: 11px;
194
- overflow-y: scroll;
195
- overflow-x: hidden;
196
- font-family: "Arial-Narrow";
197
- padding-left: 5px;
198
- }
199
-
200
- #isi::-webkit-scrollbar {
201
- width: 30px;
202
- margin-top: 10px
203
- }
204
-
205
- #isi::-webkit-scrollbar-track {
206
- background-image: url();
207
- background-position: center;
208
- background-repeat: no-repeat;
209
- background-size: 4px 90%;
210
- }
211
-
212
- #isi::-webkit-scrollbar-thumb {
213
- height: 25px;
214
- background-image: url();
215
- background-position: center;
216
- background-repeat: no-repeat;
217
- }
218
- /* End-of-the-ISI */
219
-
220
- eos
221
- end
222
-
223
- def banner_js_boilerplate
224
- <<eos
225
- $(function(){
226
- // WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.flashAdImpressionTrack('banner-ad')");
227
-
228
- //Start-of-the-animation-code
229
- //End-of-the-animation-code
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
-
242
-
243
-
244
-
245
- function autoScroll(){
246
- ascroll = setInterval(function(){
247
- elem = $("#isi")[0];
248
- if (elem.scrollTop != 1075){
249
- elem.scrollTop += 2;
250
- }
251
- }, 200);
252
- }
253
-
254
- $(document).on("touchstart", "#isi", function(){
255
- clearInterval(ascroll);
256
- });
257
-
258
-
259
- $("#overall_mask").on("click", function(){
260
- console.log("overall mask was clicked");
261
- WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('', '<div data-advtype=banner-mainClickThrough/>')");
262
- });
263
-
264
- $("#fdaBtn").on("click", function(){
265
- console.log("fda btn open button clicked");
266
- WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://www.fda.gov/medwatch/', '<div data-advtype=banner-fda-medwatch/>')");
267
- });
268
-
269
- $("#pi").on("click", function(){
270
- console.log("pi button clicked");
271
- WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=banner-pres-info/>')");
272
- });
273
-
274
- $("#medguide").on("click", function(){
275
- console.log("medguide button clicked");
276
- WebViewCommunicator.sendJavascriptTo("main", "javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=banner-med-guide/>')");
277
- });
278
-
279
-
280
- });
281
-
282
- eos
283
- end
284
-
285
- def pdf_html
286
- <<eos
287
- <!doctype html>
288
- <html>
289
- <head>
290
- <meta charset="utf-8">
291
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
292
- <title></title>
293
- <style>
294
- img{
295
- display: block;
296
- width:100%;
297
- }
298
- </style>
299
- </head>
300
-
301
- <body>
302
- </body>
303
- </html>
304
- eos
305
- end
306
-
307
-
308
-
309
- #==================================================
310
-
311
- def img_html(filename, loc)
312
- <<eos
313
- <img id="#{filename}" src="#{loc}_images/#{filename}.png" alt="">
314
- eos
315
- end
316
-
317
- def img_css(filename)
318
- <<eos
319
-
320
- ##{filename}{
321
- position: absolute;
322
- top: 0;
323
- left: 0;
324
- }
325
-
326
- eos
327
- end
328
-
329
- def img_js(filename)
330
- <<eos
331
- TweenMax.to(#{filename}, 0.0, {});
332
- eos
333
- end
334
-
335
-
336
-
337
-
338
-
339
-
340
-
341
-
342
-
343
-
344
-
345
-
346
-
347
-
348
-
349
-
350
-
351
-
352
-
353
-
354
-
355
- def make_files
356
- make_dirs
357
- @types.each do |t|
358
- @ext.each do |k,value|
359
- if value
360
- File.open("#{k}/"+@get_current_foldername+"_#{t}.#{k}", 'w+') do |file|
361
- file.write(send("#{t}_#{k}_boilerplate"))
362
- end
363
- else
364
- File.open(@get_current_foldername+"_#{t}.#{k}", 'w+') do |file|
365
- to_write = html_boilerplate(@get_current_foldername, t)
366
- file.write(to_write)
367
- end
368
- end
369
- end
370
- end
371
- exec('curl -o js/TweenMax.min.js http://cdnjs.cloudflare.com/ajax/libs/gsap/1.17.0/TweenMax.min.js;curl -o js/jquery.min.js https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js')
372
- end
373
-
374
- def make_dirs
375
- Dir.mkdir("js") unless Dir.exist?("js")
376
- Dir.mkdir("css") unless Dir.exist?("css")
377
- Dir.mkdir("box_images") unless Dir.exist?("box_images")
378
- Dir.mkdir("banner_images") unless Dir.exist?("banner_images")
379
- end
380
-
381
- def insert_img_html(filenames,location)
382
- text_to_be_inserted = ""
383
- filenames.each do |f|
384
- text_to_be_inserted << img_html(f,location)
385
- end
386
- read = File.read(@get_current_foldername+"_#{location}.html")
387
- first_part, second_part, third_part = read.split(/(<!-- End-of-the-Image-Tags -->)/)
388
- first_part << text_to_be_inserted
389
- everything = first_part + second_part + third_part
390
- File.open(@get_current_foldername+"_#{location}.html", "w+") do |f|
391
- f.write(everything)
392
- end
393
- end
394
-
395
- def insert_img_css(filenames,location)
396
- text_to_be_inserted = ""
397
- filenames.each do |f|
398
- text_to_be_inserted << img_css(f)
399
- end
400
- read = File.read("css/"+@get_current_foldername+"_#{location}.css")
401
- first_part, second_part, third_part = read.split(/(\/\* Start-of-the-ISI \*\/)/)
402
- first_part << text_to_be_inserted
403
- everything = first_part + second_part + third_part
404
- File.open("css/" + @get_current_foldername+"_#{location}.css", "w+") do |f|
405
- f.write(everything)
406
- end
407
- end
408
-
409
- def insert_img_js(filenames,location)
410
- text_to_be_inserted = ""
411
- filenames.each do |f|
412
- text_to_be_inserted << img_js(f)
413
- end
414
- read = File.read("js/"+@get_current_foldername+"_#{location}.js")
415
- first_part, second_part, third_part = read.split(/(\/\/End-of-the-animation-code)/)
416
- first_part << text_to_be_inserted
417
- everything = first_part + second_part + third_part
418
- File.open("js/" + @get_current_foldername+"_#{location}.js", "w+") do |f|
419
- f.write(everything)
420
- end
421
- end
422
-
423
- def do_the_pdf(pdfs_to_html)
424
- p pdfs_to_html
425
- html_pdf_imgs = []
426
- pdfs_to_html.each do |file|
427
- if file.include? " "
428
- File.rename(file, file.gsub(" ","_"))
429
- file = file.gsub(" ","_")
430
- end
431
- pdf_folder_name = File.basename(file, ".*")
432
- Dir.mkdir(pdf_folder_name)
433
- p file
434
- imgs_from_pdf = Magick::Image.read(file) { self.density = 300 }
435
- imgs_from_pdf.each_with_index do |img,idx|
436
- img_tag = ['<img src="', '" alt="">']
437
- img_tag.insert(1,"#{pdf_folder_name}/#{pdf_folder_name}_#{idx}.png")
438
- html_pdf_imgs << img_tag.join
439
- img.write(pdf_folder_name+"/#{pdf_folder_name}_#{idx}.png") { self.quality = 100}
440
- end
441
- temp = pdf_html
442
- temp = temp.split(/(<body>)/)
443
- temp.insert(2,html_pdf_imgs.join("\n"))
444
- temp = temp.join
445
- puts temp
446
- File.open(pdf_folder_name+".html", "w+") do |f|
447
- f.write(temp)
448
- end
449
- end
12
+ # Initializing the instance variables
13
+ def initialize
14
+ @get_current_dir = Dir.getwd
15
+ @get_current_foldername = File.basename(@get_current_dir)
16
+ @init = InitialFiles.new
17
+ @bp = Boilerplate.new
18
+ @pdf2img = Img2Pdf.new
19
+ @it = InsertTags.new
450
20
  end
451
21
 
452
22
  def main
453
-
454
- @get_current_dir = Dir.getwd
455
- @get_current_foldername = File.basename(@get_current_dir)
456
- @box_name = ""
457
- @banner_name = ""
458
-
459
- @types = ["box", "banner"]
460
- @ext = { "html" => false,"css" => true,"js" => true }
461
-
462
23
  opts = ARGV
463
24
  case opts[0]
464
25
  when "new"
465
- make_files
26
+ @init.make_files
466
27
  when "g", "generate"
467
28
  case opts[1]
468
29
  when "img"
@@ -471,39 +32,58 @@ eos
471
32
  puts "Couldnt Find the box html,css,js files" unless File.exists? (@get_current_foldername+"_box.html")
472
33
  puts "Generating IMG tags for box in HTML, relative code for CSS and JS"
473
34
  files_to_be_written = opts[3..-1]
474
- insert_img_html(files_to_be_written,"box")
475
- insert_img_css(files_to_be_written,"box")
476
- insert_img_js(files_to_be_written,"box")
35
+ @it.insert_img_html(files_to_be_written,"box")
36
+ @it.insert_img_css(files_to_be_written,"box")
37
+ @it.insert_img_js(files_to_be_written,"box")
477
38
  when "banner"
478
39
  puts "Couldnt Find the banner html,css,js files" unless File.exists? (@get_current_foldername+"_banner.html")
479
40
  puts "Generating IMG tags for banner in HTML, relative code for CSS and JS"
480
41
  files_to_be_written = opts[3..-1]
481
- insert_img_html(files_to_be_written,"banner")
482
- insert_img_css(files_to_be_written,"banner")
483
- insert_img_js(files_to_be_written,"banner")
42
+ @it.insert_img_html(files_to_be_written,"banner")
43
+ @it.insert_img_css(files_to_be_written,"banner")
44
+ @it.insert_img_js(files_to_be_written,"banner")
484
45
  when "both"
485
46
  puts "Generating tags for both box and banner"
486
47
  files_to_be_written = opts[3..-1]
487
48
  ["box","banner"].each do |type|
488
- insert_img_html(files_to_be_written,type)
489
- insert_img_css(files_to_be_written,type)
490
- insert_img_js(files_to_be_written,type)
49
+ @it.insert_img_html(files_to_be_written,type)
50
+ @it.insert_img_css(files_to_be_written,type)
51
+ @it.insert_img_js(files_to_be_written,type)
491
52
  end
492
53
  else
493
54
  puts "either pass 'box','banner' or 'both' as flags after generate"
494
55
  end
495
56
  when "pdf"
496
- puts "this is the pdf"
57
+ puts "This is the pdf"
497
58
  pdf_files = opts[2..-1]
498
- do_the_pdf(pdf_files)
59
+ @pdf2img.do_the_pdf(pdf_files)
499
60
  else
500
61
  puts "either pass img or pdf"
501
62
  end
502
63
  when "-help"
503
- puts "Flags are:\nnew\ng or generate"
64
+ puts help
504
65
  else
505
66
  puts "Please use a proper flag\nUse -help flag to see all the options"
506
67
  end
507
68
  end
69
+
70
+ def help
71
+ <<-eos
72
+ Flags are:
73
+ -new
74
+ : Which Generates html,css and js files for Box and Banners
75
+ : Also downloads the current verison of jQuery and TweenMax
76
+
77
+ -g or genrate
78
+ : The Generate Flag is to be used in conjunction with either
79
+ -img
80
+ :Generates tags in html, css and js
81
+
82
+ -pdf
83
+ :Extracts imgages from the source PDF passed in as args
84
+ Creates a Folder and html file with all the images as tags
85
+ eos
86
+ end
87
+
508
88
  end
509
89
  end
@@ -0,0 +1,41 @@
1
+ module F2h
2
+ class InitialFiles
3
+ def initialize
4
+ @get_current_dir = Dir.getwd
5
+ @get_current_foldername = File.basename(@get_current_dir)
6
+ @box_name = ""
7
+ @banner_name = ""
8
+ @types = ["box", "banner"]
9
+ @ext = { "html" => false,"css" => true,"js" => true }
10
+ @bp = Boilerplate.new
11
+ end
12
+
13
+ def make_files
14
+ make_dirs
15
+ @types.each do |t|
16
+ @ext.each do |k,value|
17
+ if value
18
+ File.open("#{k}/"+@get_current_foldername+"_#{t}.#{k}", 'w+') do |file|
19
+ k.eql?("js") ? t.eql?("box") ? to_write = @bp.box_js_boilerplate : to_write = @bp.banner_js_boilerplate : t.eql?("box") ? to_write = @bp.box_css_boilerplate : to_write = @bp.banner_css_boilerplate
20
+ # file.write(send("#{@bp}.#{t}_#{k}_boilerplate"))
21
+ file.write(to_write)
22
+ end
23
+ else
24
+ File.open(@get_current_foldername+"_#{t}.#{k}", 'w+') do |file|
25
+ to_write = @bp.html_boilerplate(@get_current_foldername, t)
26
+ file.write(to_write)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ exec('curl -o js/TweenMax.min.js http://cdnjs.cloudflare.com/ajax/libs/gsap/1.17.0/TweenMax.min.js;curl -o js/jquery.min.js https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js')
32
+ end
33
+
34
+ def make_dirs
35
+ Dir.mkdir("js") unless Dir.exist?("js")
36
+ Dir.mkdir("css") unless Dir.exist?("css")
37
+ Dir.mkdir("box_images") unless Dir.exist?("box_images")
38
+ Dir.mkdir("banner_images") unless Dir.exist?("banner_images")
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,52 @@
1
+ module F2h
2
+ class InsertTags
3
+
4
+ def initialize
5
+ @get_current_dir = Dir.getwd
6
+ @get_current_foldername = File.basename(@get_current_dir)
7
+ @bp = Boilerplate.new
8
+ end
9
+
10
+ def insert_img_html(filenames,location)
11
+ text_to_be_inserted = ""
12
+ filenames.each do |f|
13
+ text_to_be_inserted << @bp.img_html(f,location)
14
+ end
15
+ read = File.read(@get_current_foldername+"_#{location}.html")
16
+ first_part, second_part, third_part = read.split(/(<!-- End-of-the-Image-Tags -->)/)
17
+ first_part << text_to_be_inserted
18
+ everything = first_part + second_part + third_part
19
+ File.open(@get_current_foldername+"_#{location}.html", "w+") do |f|
20
+ f.write(everything)
21
+ end
22
+ end
23
+
24
+ def insert_img_css(filenames,location)
25
+ text_to_be_inserted = ""
26
+ filenames.each do |f|
27
+ text_to_be_inserted << @bp.img_css(f)
28
+ end
29
+ read = File.read("css/"+@get_current_foldername+"_#{location}.css")
30
+ first_part, second_part, third_part = read.split(/(\/\* Start-of-the-ISI \*\/)/)
31
+ first_part << text_to_be_inserted
32
+ everything = first_part + second_part + third_part
33
+ File.open("css/" + @get_current_foldername+"_#{location}.css", "w+") do |f|
34
+ f.write(everything)
35
+ end
36
+ end
37
+
38
+ def insert_img_js(filenames,location)
39
+ text_to_be_inserted = ""
40
+ filenames.each do |f|
41
+ text_to_be_inserted << @bp.img_js(f)
42
+ end
43
+ read = File.read("js/"+@get_current_foldername+"_#{location}.js")
44
+ first_part, second_part, third_part = read.split(/(\/\/End-of-the-animation-code)/)
45
+ first_part << text_to_be_inserted
46
+ everything = first_part + second_part + third_part
47
+ File.open("js/" + @get_current_foldername+"_#{location}.js", "w+") do |f|
48
+ f.write(everything)
49
+ end
50
+ end
51
+ end
52
+ end
data/lib/pdf2img.rb ADDED
@@ -0,0 +1,36 @@
1
+ module F2h
2
+ class Img2Pdf
3
+ def initialize
4
+ @bp = Boilerplate.new
5
+ end
6
+
7
+ def do_the_pdf(pdfs_to_html)
8
+ p pdfs_to_html
9
+ html_pdf_imgs = []
10
+ pdfs_to_html.each do |file|
11
+ if file.include? " "
12
+ File.rename(file, file.gsub(" ","_"))
13
+ file = file.gsub(" ","_")
14
+ end
15
+ pdf_folder_name = File.basename(file, ".*")
16
+ Dir.mkdir(pdf_folder_name)
17
+ p file
18
+ imgs_from_pdf = Magick::Image.read(file) { self.density = 300 }
19
+ imgs_from_pdf.each_with_index do |img,idx|
20
+ img_tag = ['<img src="', '" alt="">']
21
+ img_tag.insert(1,"#{pdf_folder_name}/#{pdf_folder_name}_#{idx}.png")
22
+ html_pdf_imgs << img_tag.join
23
+ img.write(pdf_folder_name+"/#{pdf_folder_name}_#{idx}.png") { self.quality = 100}
24
+ end
25
+ temp = @bp.pdf_html
26
+ temp = temp.split(/(<body>)/)
27
+ temp.insert(2,html_pdf_imgs.join("\n"))
28
+ temp = temp.join
29
+ puts temp
30
+ File.open(pdf_folder_name+".html", "w+") do |f|
31
+ f.write(temp)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: f2h
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismail Kalimi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-03 00:00:00.000000000 Z
11
+ date: 2015-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick
@@ -66,8 +66,8 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: This just generates and downloads sane defaults for html5 animations
70
- from Flash
69
+ description: Boilerplate code that provides sane default settings when making html5
70
+ assets using html,css and js from Flash creatives
71
71
  email:
72
72
  - ismailkalimi@gmail.com
73
73
  executables:
@@ -89,9 +89,14 @@ files:
89
89
  - bin/f2h
90
90
  - bin/setup
91
91
  - f2h.gemspec
92
+ - lib/.DS_Store
93
+ - lib/boilerplate.rb
92
94
  - lib/f2h.rb
93
95
  - lib/f2h/version.rb
94
- homepage: https://ikalimi.com/flash2html
96
+ - lib/initial_files.rb
97
+ - lib/insert_tags.rb
98
+ - lib/pdf2img.rb
99
+ homepage: https://github.com/ismk/Flash2HTML
95
100
  licenses:
96
101
  - MIT
97
102
  metadata: