Class: F2h::Flash2HTML
- Inherits:
-
Object
- Object
- F2h::Flash2HTML
- Defined in:
- lib/f2h.rb
Instance Method Summary collapse
-
#banner_css_boilerplate ⇒ Object
BANNER BOILERPLATE ##########################.
- #banner_js_boilerplate ⇒ Object
- #box_css_boilerplate ⇒ Object
- #box_js_boilerplate ⇒ Object
- #do_the_pdf(pdfs_to_html) ⇒ Object
-
#html_boilerplate(foldername, type) ⇒ Object
BOX BOILERPLATE ==============================.
- #img_css(filename) ⇒ Object
-
#img_html(filename, loc) ⇒ Object
.
- #img_js(filename) ⇒ Object
- #insert_img_css(filenames, location) ⇒ Object
- #insert_img_html(filenames, location) ⇒ Object
- #insert_img_js(filenames, location) ⇒ Object
- #main ⇒ Object
- #make_dirs ⇒ Object
- #make_files ⇒ Object
- #pdf_html ⇒ Object
Instance Method Details
#banner_css_boilerplate ⇒ Object
BANNER BOILERPLATE ##########################
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/f2h.rb', line 168 def "body{\n position: fixed;\n padding: 0;\n margin: 0;\n top: 0;\n left: 0;\n}\n\n#overall_mask{\n position: absolute;\n height: 90px;\n width: 728px;\n}\n\n /* Start-of-the-ISI */\n#isi{\n position: absolute;\n background-color: white;\n border-left: 1px solid gray;\n top: 18px;\n left: 428px;\n width: 300px;\n height: 72px;\n font-size: 11px;\n overflow-y: scroll;\n overflow-x: hidden;\n font-family: \"Arial-Narrow\";\n padding-left: 5px;\n}\n\n#isi::-webkit-scrollbar {\n width: 30px;\n margin-top: 10px\n}\n\n#isi::-webkit-scrollbar-track {\n background-image: url();\n background-position: center;\n background-repeat: no-repeat;\n background-size: 4px 90%;\n}\n\n#isi::-webkit-scrollbar-thumb {\n height: 25px;\n background-image: url();\n background-position: center;\n background-repeat: no-repeat;\n}\n /* End-of-the-ISI */\n\n" end |
#banner_js_boilerplate ⇒ Object
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/f2h.rb', line 223 def "$(function(){\n// WebViewCommunicator.sendJavascriptTo(\"main\", \"javascript:appRouter.homeView.flashAdImpressionTrack('banner-ad')\");\n\n //Start-of-the-animation-code\n //End-of-the-animation-code\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction autoScroll(){\nascroll = setInterval(function(){\n elem = $(\"#isi\")[0];\n if (elem.scrollTop != 1075){\n elem.scrollTop += 2;\n }\n}, 200);\n }\n\n $(document).on(\"touchstart\", \"#isi\", function(){\n clearInterval(ascroll);\n });\n\n\n $(\"#overall_mask\").on(\"click\", function(){\nconsole.log(\"overall mask was clicked\");\nWebViewCommunicator.sendJavascriptTo(\"main\", \"javascript:appRouter.homeView.openChildBrowser('', '<div data-advtype=banner-mainClickThrough/>')\");\n });\n\n $(\"#fdaBtn\").on(\"click\", function(){\nconsole.log(\"fda btn open button clicked\");\nWebViewCommunicator.sendJavascriptTo(\"main\", \"javascript:appRouter.homeView.openChildBrowser('http://www.fda.gov/medwatch/', '<div data-advtype=banner-fda-medwatch/>')\");\n });\n\n $(\"#pi\").on(\"click\", function(){\nconsole.log(\"pi button clicked\");\nWebViewCommunicator.sendJavascriptTo(\"main\", \"javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=banner-pres-info/>')\");\n });\n\n $(\"#medguide\").on(\"click\", function(){\nconsole.log(\"medguide button clicked\");\nWebViewCommunicator.sendJavascriptTo(\"main\", \"javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=banner-med-guide/>')\");\n });\n\n\n});\n\n" end |
#box_css_boilerplate ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/f2h.rb', line 36 def box_css_boilerplate "body{\n position: fixed;\n padding: 0;\n margin: 0;\n top: 0;\n left: 0;\n}\n\n#overall_mask{\n position: absolute;\n height: 250px;\n width: 300px;\n}\n\n\n\n\n\n\n\n /* Start-of-the-ISI */\n#isi{\n position: absolute;\n background-color: white;\n top: 250px;\n width: 300px;\n height: 76px;\n font-size: 12px;\n overflow-y: scroll;\n overflow-x: hidden;\n font-family: \"Arial-Narrow\";\n padding-left: 5px;\n}\n\n#isi::-webkit-scrollbar {\n width: 20px;\n}\n\n#isi::-webkit-scrollbar-track {\n background-image: url();\n background-position: center;\n background-repeat: no-repeat;\n background-size: 4px 97%;\n}\n\n#isi::-webkit-scrollbar-thumb {\n height: 25px;\n background-image: url();\n background-position: center;\n background-repeat: no-repeat;\n}\n /* End-of-the-ISI */\n\n" end |
#box_js_boilerplate ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/f2h.rb', line 94 def box_js_boilerplate "$(function(){\n// WebViewCommunicator.sendJavascriptTo(\"main\", \"javascript:appRouter.homeView.flashAdImpressionTrack('box-ad')\");\n\n //Start-of-the-animation-code\n //End-of-the-animation-code\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfunction autoScroll(){\nascroll = setInterval(function(){\n elem = $(\"#isi\")[0];\n if (elem.scrollTop != 1075){\n elem.scrollTop += 2;\n }\n}, 200);\n }\n\n $(document).on(\"touchstart\", \"#isi\", function(){\n clearInterval(ascroll);\n });\n\n\n $(\"#overall_mask\").on(\"click\", function(){\nconsole.log(\"overall mask was clicked\");\nWebViewCommunicator.sendJavascriptTo(\"main\", \"javascript:appRouter.homeView.openChildBrowser('', '<div data-advtype=box-mainClickThrough/>')\");\n });\n\n $(\"#fdaBtn\").on(\"click\", function(){\nconsole.log(\"fda btn open button clicked\");\nWebViewCommunicator.sendJavascriptTo(\"main\", \"javascript:appRouter.homeView.openChildBrowser('http://www.fda.gov/medwatch/', '<div data-advtype=box-fda-medwatch/>')\");\n });\n\n $(\"#pi\").on(\"click\", function(){\nconsole.log(\"pi button clicked\");\nWebViewCommunicator.sendJavascriptTo(\"main\", \"javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=box-pres-info/>')\");\n });\n\n $(\"#medguide\").on(\"click\", function(){\nconsole.log(\"medguide button clicked\");\nWebViewCommunicator.sendJavascriptTo(\"main\", \"javascript:appRouter.homeView.openChildBrowser('http://127.0.0.1:8081/', '<div data-advtype=box-med-guide/>')\");\n });\n\n\n});\n\n" end |
#do_the_pdf(pdfs_to_html) ⇒ Object
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/f2h.rb', line 423 def do_the_pdf(pdfs_to_html) p pdfs_to_html html_pdf_imgs = [] pdfs_to_html.each do |file| if file.include? " " File.rename(file, file.gsub(" ","_")) file = file.gsub(" ","_") end pdf_folder_name = File.basename(file, ".*") Dir.mkdir(pdf_folder_name) p file imgs_from_pdf = Magick::Image.read(file) { self.density = 300 } imgs_from_pdf.each_with_index do |img,idx| img_tag = ['<img src="', '" alt="">'] img_tag.insert(1,"#{pdf_folder_name}/#{pdf_folder_name}_#{idx}.png") html_pdf_imgs << img_tag.join img.write(pdf_folder_name+"/#{pdf_folder_name}_#{idx}.png") { self.quality = 100} end temp = pdf_html temp = temp.split(/(<body>)/) temp.insert(2,html_pdf_imgs.join("\n")) temp = temp.join puts temp File.open(pdf_folder_name+".html", "w+") do |f| f.write(temp) end end end |
#html_boilerplate(foldername, type) ⇒ Object
BOX BOILERPLATE ==============================
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/f2h.rb', line 9 def html_boilerplate(foldername, type) "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <title></title>\n <link rel=\"stylesheet\" href=\"css/\#{foldername}_\#{type}.css\">\n <script src=\"js/jquery.min.js\"></script>\n <script src=\"js/TweenMax.min.js\"></script>\n <script src=\"js/\#{foldername}_\#{type}.js\"></script>\n</head>\n<body>\n\n\n <!-- Start-of-the-Image-Tags -->\n <!-- End-of-the-Image-Tags -->\n\n <!-- Start-of-the-ISI -->\n <div id=\"isi\"></div>\n <!-- End-of-the-ISI -->\n\n</body>\n</html>\n" end |
#img_css(filename) ⇒ Object
317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/f2h.rb', line 317 def img_css(filename) "\n#\#{filename}{\n position: absolute;\n top: 0;\n left: 0;\n}\n\n" end |
#img_html(filename, loc) ⇒ Object
311 312 313 314 315 |
# File 'lib/f2h.rb', line 311 def img_html(filename, loc) " <img id=\"\#{filename}\" src=\"\#{loc}_images/\#{filename}.png\" alt=\"\">\n" end |
#img_js(filename) ⇒ Object
329 330 331 332 333 |
# File 'lib/f2h.rb', line 329 def img_js(filename) "TweenMax.to(\#{filename}, 0.0, {});\n" end |
#insert_img_css(filenames, location) ⇒ Object
395 396 397 398 399 400 401 402 403 404 405 406 407 |
# File 'lib/f2h.rb', line 395 def insert_img_css(filenames,location) text_to_be_inserted = "" filenames.each do |f| text_to_be_inserted << img_css(f) end read = File.read("css/"+@get_current_foldername+"_#{location}.css") first_part, second_part, third_part = read.split(/(\/\* Start-of-the-ISI \*\/)/) first_part << text_to_be_inserted everything = first_part + second_part + third_part File.open("css/" + @get_current_foldername+"_#{location}.css", "w+") do |f| f.write(everything) end end |
#insert_img_html(filenames, location) ⇒ Object
381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File 'lib/f2h.rb', line 381 def insert_img_html(filenames,location) text_to_be_inserted = "" filenames.each do |f| text_to_be_inserted << img_html(f,location) end read = File.read(@get_current_foldername+"_#{location}.html") first_part, second_part, third_part = read.split(/(<!-- End-of-the-Image-Tags -->)/) first_part << text_to_be_inserted everything = first_part + second_part + third_part File.open(@get_current_foldername+"_#{location}.html", "w+") do |f| f.write(everything) end end |
#insert_img_js(filenames, location) ⇒ Object
409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/f2h.rb', line 409 def insert_img_js(filenames,location) text_to_be_inserted = "" filenames.each do |f| text_to_be_inserted << img_js(f) end read = File.read("js/"+@get_current_foldername+"_#{location}.js") first_part, second_part, third_part = read.split(/(\/\/End-of-the-animation-code)/) first_part << text_to_be_inserted everything = first_part + second_part + third_part File.open("js/" + @get_current_foldername+"_#{location}.js", "w+") do |f| f.write(everything) end end |
#main ⇒ Object
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/f2h.rb', line 452 def main @get_current_dir = Dir.getwd @get_current_foldername = File.basename(@get_current_dir) @box_name = "" = "" @types = ["box", "banner"] @ext = { "html" => false,"css" => true,"js" => true } opts = ARGV case opts[0] when "new" make_files when "g", "generate" case opts[1] when "img" case opts[2] when "box" puts "Couldnt Find the box html,css,js files" unless File.exists? (@get_current_foldername+"_box.html") puts "Generating IMG tags for box in HTML, relative code for CSS and JS" files_to_be_written = opts[3..-1] insert_img_html(files_to_be_written,"box") insert_img_css(files_to_be_written,"box") insert_img_js(files_to_be_written,"box") when "banner" puts "Couldnt Find the banner html,css,js files" unless File.exists? (@get_current_foldername+"_banner.html") puts "Generating IMG tags for banner in HTML, relative code for CSS and JS" files_to_be_written = opts[3..-1] insert_img_html(files_to_be_written,"banner") insert_img_css(files_to_be_written,"banner") insert_img_js(files_to_be_written,"banner") when "both" puts "Generating tags for both box and banner" files_to_be_written = opts[3..-1] ["box","banner"].each do |type| insert_img_html(files_to_be_written,type) insert_img_css(files_to_be_written,type) insert_img_js(files_to_be_written,type) end else puts "either pass 'box','banner' or 'both' as flags after generate" end when "pdf" puts "this is the pdf" pdf_files = opts[2..-1] do_the_pdf(pdf_files) else puts "either pass img or pdf" end when "-help" puts "Flags are:\nnew\ng or generate" else puts "Please use a proper flag\nUse -help flag to see all the options" end end |
#make_dirs ⇒ Object
374 375 376 377 378 379 |
# File 'lib/f2h.rb', line 374 def make_dirs Dir.mkdir("js") unless Dir.exist?("js") Dir.mkdir("css") unless Dir.exist?("css") Dir.mkdir("box_images") unless Dir.exist?("box_images") Dir.mkdir("banner_images") unless Dir.exist?("banner_images") end |
#make_files ⇒ Object
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/f2h.rb', line 355 def make_files make_dirs @types.each do |t| @ext.each do |k,value| if value File.open("#{k}/"+@get_current_foldername+"_#{t}.#{k}", 'w+') do |file| file.write(send("#{t}_#{k}_boilerplate")) end else File.open(@get_current_foldername+"_#{t}.#{k}", 'w+') do |file| to_write = html_boilerplate(@get_current_foldername, t) file.write(to_write) end end end end 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') end |
#pdf_html ⇒ Object
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/f2h.rb', line 285 def pdf_html "<!doctype html>\n<html>\n <head>\n<meta charset=\"utf-8\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n<title></title>\n<style>\nimg{\n display: block;\n width:100%;\n}\n</style>\n </head>\n\n <body>\n </body>\n</html>\n" end |