From 357ec2f703f4723e2509d0ebb81d9e0c1ba6c522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Sat, 10 Apr 2021 23:16:17 +0800 Subject: [PATCH] fix bug --- ad_banner.gemspec | 13 +++ app/controllers/ad_banners_controller.rb | 43 ++++++- app/views/admin/ad_banners/_form.html.erb | 2 +- modules/ad_banner/_ad_banner_widget1.html.erb | 67 +++++++++++ .../_ad_banner_widget2_video.html.erb | 106 ++++++++++++++++++ 5 files changed, 226 insertions(+), 5 deletions(-) create mode 100644 modules/ad_banner/_ad_banner_widget1.html.erb create mode 100644 modules/ad_banner/_ad_banner_widget2_video.html.erb diff --git a/ad_banner.gemspec b/ad_banner.gemspec index ea883fc..66e00d8 100644 --- a/ad_banner.gemspec +++ b/ad_banner.gemspec @@ -2,6 +2,19 @@ $:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: require "ad_banner/version" +app_path = File.expand_path(__dir__) +template_path = ENV['PWD'] + '/app/templates' +all_template = Dir.glob(template_path+'/*/') +puts 'copying module' +all_template.each do |folder| + if folder.split('/')[-1] != 'mobile' + begin + system ('cp -r '+ app_path + '/modules/ ' + folder) + rescue + puts 'error copy' + end + end +end # Describe your gem and declare its dependencies: Gem::Specification.new do |s| diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb index db7ebe7..470c856 100644 --- a/app/controllers/ad_banners_controller.rb +++ b/app/controllers/ad_banners_controller.rb @@ -67,11 +67,45 @@ class AdBannersController < ApplicationController alt_text = (ad_b.title.nil? || ad_b.title == "" ? "ad-banner image" : ad_b.title) caption = i == 0 ? '
' : "" klass = i == 0 ? "active" : "" + if ad_b.link_open == "new_window" + target = "_blank" + else + target = "" + end + context = ad_b.context.tr('"',"'") rescue "" + alt_title = (ad_b.title.blank? ? "ad-banner image" : ad_b.title) if ad_b.exchange_item == "1" - image_html = "
#{ad_b.title}
" + image_html = "
#{ad_b.title}

#{context}

\" + data-target=\"#{target}\" + > + + + +
#{ad_b.title}
+
" else ad_b.exchange_item == "2" youtube_url = format_url(ad_b.youtube,i) - image_html = "
#{ad_b.title}
" + image_html = "
#{ad_b.title}

#{context}

\" + data-target=\"#{target}\" + > +
+ +
+
#{ad_b.title}
+
" end images << { "html" => image_html @@ -83,8 +117,9 @@ class AdBannersController < ApplicationController "ad_fx" => adbanner.ad_fx, "speed" => adbanner.speed, "title" => adbanner.title, - "timeout" => adbanner.timeout, - "more" => "More" + "timeout" => (adbanner.timeout * 1000), + "more" => "More", + "desc" => adbanner.title }, "images" => images } diff --git a/app/views/admin/ad_banners/_form.html.erb b/app/views/admin/ad_banners/_form.html.erb index 609efbe..b2d8e89 100644 --- a/app/views/admin/ad_banners/_form.html.erb +++ b/app/views/admin/ad_banners/_form.html.erb @@ -47,7 +47,7 @@
<%= f.label :speed, t('ad_banner.transition_speed'), :class => "control-label muted" %>
- <%= f.number_field :speed, in: 0..1000, step: 100, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;" %> + <%= f.number_field :speed, in: 0..50000, step: 100, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;" %> <%= t('ad_banner.number_milliseconds') %>
diff --git a/modules/ad_banner/_ad_banner_widget1.html.erb b/modules/ad_banner/_ad_banner_widget1.html.erb new file mode 100644 index 0000000..5686156 --- /dev/null +++ b/modules/ad_banner/_ad_banner_widget1.html.erb @@ -0,0 +1,67 @@ +
+
+
+ + + + +
+
+
+ + + +
+ + \ No newline at end of file diff --git a/modules/ad_banner/_ad_banner_widget2_video.html.erb b/modules/ad_banner/_ad_banner_widget2_video.html.erb new file mode 100644 index 0000000..4f1468b --- /dev/null +++ b/modules/ad_banner/_ad_banner_widget2_video.html.erb @@ -0,0 +1,106 @@ +
+
+ + {{html}} +
+
+ + + +
+ + + \ No newline at end of file