From 3c2b4d3fd27dd40966e04070153c9dc5d57ef27a Mon Sep 17 00:00:00 2001 From: JiangRu Date: Tue, 25 Nov 2014 18:34:14 +0800 Subject: [PATCH] first commit for ad banner pro --- Gemfile | 14 + Gemfile.lock | 104 +++++ MIT-LICENSE | 20 + README.rdoc | 3 + Rakefile | 32 ++ ad_banner.gemspec | 19 + app/assets/images/ad_banner/.keep | 0 app/assets/images/slideshow_preview_A.png | Bin 0 -> 3433 bytes app/assets/images/slideshow_preview_B.png | Bin 0 -> 3077 bytes .../javascripts/ad_banner/banner_preview.js | 82 ++++ app/assets/javascripts/admin/ad_banners.js | 21 + app/assets/javascripts/cycle2.js | 4 + .../javascripts/cycle2/jquery.cycle2.min.js | 17 + .../transition/jquery.cycle2.flip.min.js | 2 + .../transition/jquery.cycle2.ie-fade.min.js | 2 + .../jquery.cycle2.scrollVert.min.js | 2 + .../transition/jquery.cycle2.tile.min.js | 2 + app/assets/stylesheets/ad_banner/.keep | 0 app/assets/stylesheets/ad_banners.css | 4 + app/assets/stylesheets/admin/ad_banners.css | 4 + app/assets/stylesheets/admin/ad_images.css | 4 + app/controllers/.keep | 0 app/controllers/ad_banners_controller.rb | 30 ++ .../admin/ad_banners_controller.rb | 56 +++ app/controllers/admin/ad_images_controller.rb | 71 ++++ app/helpers/.keep | 0 app/helpers/ad_banners_helper.rb | 2 + app/helpers/admin/ad_banners_helper.rb | 2 + app/helpers/admin/ad_images_helper.rb | 2 + app/mailers/.keep | 0 app/models/.keep | 0 app/models/ad_image.rb | 40 ++ app/models/banner.rb | 36 ++ app/views/.keep | 0 app/views/ad_banners/widget.html.erb | 1 + app/views/admin/ad_banners/_form.html.erb | 12 + app/views/admin/ad_banners/_index.html.erb | 387 ++++++++++++++++++ app/views/admin/ad_banners/index.html.erb | 46 +++ app/views/admin/ad_banners/index.js.erb | 5 + app/views/admin/ad_images/_form.html.erb | 199 +++++++++ app/views/admin/ad_images/edit.html.erb | 5 + app/views/admin/ad_images/index.html.erb | 35 ++ app/views/admin/ad_images/new.html.erb | 5 + bin/rails | 16 + config/locales/en.yml | 36 ++ config/locales/zh_tw.yml | 33 ++ config/routes.rb | 14 + lib/ad_banner.rb | 4 + lib/ad_banner/engine.rb | 28 ++ lib/ad_banner/version.rb | 3 + lib/tasks/ad_banner_tasks.rake | 4 + test/ad_banner_test.rb | 7 + .../controllers/ad_banners_controller_test.rb | 9 + .../admin/ad_banners_controller_test.rb | 9 + .../admin/ad_images_controller_test.rb | 19 + test/dummy/README.rdoc | 28 ++ test/dummy/Rakefile | 6 + test/dummy/app/assets/images/.keep | 0 .../app/assets/javascripts/application.js | 13 + .../app/assets/stylesheets/application.css | 15 + .../app/controllers/application_controller.rb | 5 + test/dummy/app/controllers/concerns/.keep | 0 test/dummy/app/helpers/application_helper.rb | 2 + test/dummy/app/mailers/.keep | 0 test/dummy/app/models/.keep | 0 test/dummy/app/models/concerns/.keep | 0 .../app/views/layouts/application.html.erb | 14 + test/dummy/bin/bundle | 3 + test/dummy/bin/rails | 4 + test/dummy/bin/rake | 4 + test/dummy/config.ru | 4 + test/dummy/config/application.rb | 29 ++ test/dummy/config/boot.rb | 5 + test/dummy/config/environment.rb | 5 + test/dummy/config/environments/development.rb | 34 ++ test/dummy/config/environments/production.rb | 80 ++++ test/dummy/config/environments/test.rb | 39 ++ .../initializers/backtrace_silencers.rb | 7 + .../config/initializers/cookies_serializer.rb | 3 + .../initializers/filter_parameter_logging.rb | 4 + test/dummy/config/initializers/inflections.rb | 16 + test/dummy/config/initializers/mime_types.rb | 4 + .../config/initializers/session_store.rb | 3 + .../config/initializers/wrap_parameters.rb | 9 + test/dummy/config/locales/en.yml | 23 ++ test/dummy/config/routes.rb | 56 +++ test/dummy/config/secrets.yml | 22 + test/dummy/lib/assets/.keep | 0 test/dummy/log/.keep | 0 test/dummy/public/404.html | 67 +++ test/dummy/public/422.html | 67 +++ test/dummy/public/500.html | 66 +++ test/dummy/public/favicon.ico | 0 test/fixtures/ad_images.yml | 15 + test/fixtures/banners.yml | 17 + test/helpers/ad_banners_helper_test.rb | 4 + test/helpers/admin/ad_banners_helper_test.rb | 4 + test/helpers/admin/ad_images_helper_test.rb | 4 + test/integration/navigation_test.rb | 9 + test/models/ad_image_test.rb | 7 + test/models/banner_test.rb | 7 + test/test_helper.rb | 15 + 102 files changed, 2171 insertions(+) create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 MIT-LICENSE create mode 100644 README.rdoc create mode 100644 Rakefile create mode 100644 ad_banner.gemspec create mode 100644 app/assets/images/ad_banner/.keep create mode 100644 app/assets/images/slideshow_preview_A.png create mode 100644 app/assets/images/slideshow_preview_B.png create mode 100644 app/assets/javascripts/ad_banner/banner_preview.js create mode 100644 app/assets/javascripts/admin/ad_banners.js create mode 100644 app/assets/javascripts/cycle2.js create mode 100644 app/assets/javascripts/cycle2/jquery.cycle2.min.js create mode 100644 app/assets/javascripts/cycle2/transition/jquery.cycle2.flip.min.js create mode 100644 app/assets/javascripts/cycle2/transition/jquery.cycle2.ie-fade.min.js create mode 100644 app/assets/javascripts/cycle2/transition/jquery.cycle2.scrollVert.min.js create mode 100644 app/assets/javascripts/cycle2/transition/jquery.cycle2.tile.min.js create mode 100644 app/assets/stylesheets/ad_banner/.keep create mode 100644 app/assets/stylesheets/ad_banners.css create mode 100644 app/assets/stylesheets/admin/ad_banners.css create mode 100644 app/assets/stylesheets/admin/ad_images.css create mode 100644 app/controllers/.keep create mode 100644 app/controllers/ad_banners_controller.rb create mode 100644 app/controllers/admin/ad_banners_controller.rb create mode 100644 app/controllers/admin/ad_images_controller.rb create mode 100644 app/helpers/.keep create mode 100644 app/helpers/ad_banners_helper.rb create mode 100644 app/helpers/admin/ad_banners_helper.rb create mode 100644 app/helpers/admin/ad_images_helper.rb create mode 100644 app/mailers/.keep create mode 100644 app/models/.keep create mode 100644 app/models/ad_image.rb create mode 100644 app/models/banner.rb create mode 100644 app/views/.keep create mode 100644 app/views/ad_banners/widget.html.erb create mode 100644 app/views/admin/ad_banners/_form.html.erb create mode 100644 app/views/admin/ad_banners/_index.html.erb create mode 100644 app/views/admin/ad_banners/index.html.erb create mode 100644 app/views/admin/ad_banners/index.js.erb create mode 100644 app/views/admin/ad_images/_form.html.erb create mode 100644 app/views/admin/ad_images/edit.html.erb create mode 100644 app/views/admin/ad_images/index.html.erb create mode 100644 app/views/admin/ad_images/new.html.erb create mode 100755 bin/rails create mode 100644 config/locales/en.yml create mode 100644 config/locales/zh_tw.yml create mode 100644 config/routes.rb create mode 100644 lib/ad_banner.rb create mode 100644 lib/ad_banner/engine.rb create mode 100644 lib/ad_banner/version.rb create mode 100644 lib/tasks/ad_banner_tasks.rake create mode 100644 test/ad_banner_test.rb create mode 100644 test/controllers/ad_banners_controller_test.rb create mode 100644 test/controllers/admin/ad_banners_controller_test.rb create mode 100644 test/controllers/admin/ad_images_controller_test.rb create mode 100644 test/dummy/README.rdoc create mode 100644 test/dummy/Rakefile create mode 100644 test/dummy/app/assets/images/.keep create mode 100644 test/dummy/app/assets/javascripts/application.js create mode 100644 test/dummy/app/assets/stylesheets/application.css create mode 100644 test/dummy/app/controllers/application_controller.rb create mode 100644 test/dummy/app/controllers/concerns/.keep create mode 100644 test/dummy/app/helpers/application_helper.rb create mode 100644 test/dummy/app/mailers/.keep create mode 100644 test/dummy/app/models/.keep create mode 100644 test/dummy/app/models/concerns/.keep create mode 100644 test/dummy/app/views/layouts/application.html.erb create mode 100755 test/dummy/bin/bundle create mode 100755 test/dummy/bin/rails create mode 100755 test/dummy/bin/rake create mode 100644 test/dummy/config.ru create mode 100644 test/dummy/config/application.rb create mode 100644 test/dummy/config/boot.rb create mode 100644 test/dummy/config/environment.rb create mode 100644 test/dummy/config/environments/development.rb create mode 100644 test/dummy/config/environments/production.rb create mode 100644 test/dummy/config/environments/test.rb create mode 100644 test/dummy/config/initializers/backtrace_silencers.rb create mode 100644 test/dummy/config/initializers/cookies_serializer.rb create mode 100644 test/dummy/config/initializers/filter_parameter_logging.rb create mode 100644 test/dummy/config/initializers/inflections.rb create mode 100644 test/dummy/config/initializers/mime_types.rb create mode 100644 test/dummy/config/initializers/session_store.rb create mode 100644 test/dummy/config/initializers/wrap_parameters.rb create mode 100644 test/dummy/config/locales/en.yml create mode 100644 test/dummy/config/routes.rb create mode 100644 test/dummy/config/secrets.yml create mode 100644 test/dummy/lib/assets/.keep create mode 100644 test/dummy/log/.keep create mode 100644 test/dummy/public/404.html create mode 100644 test/dummy/public/422.html create mode 100644 test/dummy/public/500.html create mode 100644 test/dummy/public/favicon.ico create mode 100644 test/fixtures/ad_images.yml create mode 100644 test/fixtures/banners.yml create mode 100644 test/helpers/ad_banners_helper_test.rb create mode 100644 test/helpers/admin/ad_banners_helper_test.rb create mode 100644 test/helpers/admin/ad_images_helper_test.rb create mode 100644 test/integration/navigation_test.rb create mode 100644 test/models/ad_image_test.rb create mode 100644 test/models/banner_test.rb create mode 100644 test/test_helper.rb diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..ab99bc2 --- /dev/null +++ b/Gemfile @@ -0,0 +1,14 @@ +source "https://rubygems.org" + +# Declare your gem's dependencies in ad_banner.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use debugger +# gem 'debugger' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..7494fe6 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,104 @@ +PATH + remote: . + specs: + ad_banner (0.0.1) + mongoid (= 4.0.0.beta1) + rails (~> 4.1.0.rc2) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.1.0) + actionpack (= 4.1.0) + actionview (= 4.1.0) + mail (~> 2.5.4) + actionpack (4.1.0) + actionview (= 4.1.0) + activesupport (= 4.1.0) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.0) + activesupport (= 4.1.0) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.0) + activesupport (= 4.1.0) + builder (~> 3.1) + activerecord (4.1.0) + activemodel (= 4.1.0) + activesupport (= 4.1.0) + arel (~> 5.0.0) + activesupport (4.1.0) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + arel (5.0.0) + bson (2.2.2) + builder (3.2.2) + connection_pool (2.0.0) + erubis (2.7.0) + hike (1.2.3) + i18n (0.6.9) + json (1.8.1) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.25.1) + minitest (5.3.2) + mongoid (4.0.0.beta1) + activemodel (>= 4.0.0) + moped (~> 2.0.beta6) + origin (~> 2.1) + tzinfo (>= 0.3.37) + moped (2.0.0.rc1) + bson (~> 2.2) + connection_pool (~> 2.0) + optionable (~> 0.2.0) + multi_json (1.9.2) + optionable (0.2.0) + origin (2.1.1) + polyglot (0.3.4) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rails (4.1.0) + actionmailer (= 4.1.0) + actionpack (= 4.1.0) + actionview (= 4.1.0) + activemodel (= 4.1.0) + activerecord (= 4.1.0) + activesupport (= 4.1.0) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.0) + sprockets-rails (~> 2.0) + railties (4.1.0) + actionpack (= 4.1.0) + activesupport (= 4.1.0) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.2.2) + sprockets (2.12.0) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.1.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + thor (0.19.1) + thread_safe (0.3.3) + tilt (1.4.1) + treetop (1.4.15) + polyglot + polyglot (>= 0.3.1) + tzinfo (1.1.0) + thread_safe (~> 0.1) + +PLATFORMS + ruby + +DEPENDENCIES + ad_banner! diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..ea966ec --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2014 YOURNAME + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..3c8d89b --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += AdBanner + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..ed781dc --- /dev/null +++ b/Rakefile @@ -0,0 +1,32 @@ +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end + +require 'rdoc/task' + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'AdBanner' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + + + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task default: :test diff --git a/ad_banner.gemspec b/ad_banner.gemspec new file mode 100644 index 0000000..ea883fc --- /dev/null +++ b/ad_banner.gemspec @@ -0,0 +1,19 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "ad_banner/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "ad_banner" + s.version = AdBanner::VERSION + s.authors = ["Ruling Digital"] + s.email = ["orbit@rulingcom.com"] + s.homepage = "http://www.rulingcom.com" + s.summary = "Ad Banner management" + s.description = "Create Banners for Orbit" + s.license = "MIT" + + s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] + s.test_files = Dir["test/**/*"] +end diff --git a/app/assets/images/ad_banner/.keep b/app/assets/images/ad_banner/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/images/slideshow_preview_A.png b/app/assets/images/slideshow_preview_A.png new file mode 100644 index 0000000000000000000000000000000000000000..25a42a3497ad9d3fbb2bdef54936861a7436ba26 GIT binary patch literal 3433 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 500) { + var resize = 500/bannerW + bannerW = Math.floor(bannerW*resize); + bannerH = Math.floor(bannerH*resize); + console.log(bannerW) + }; + if(bannerH > 300) { + var resize = 300/bannerH + bannerW = Math.floor(bannerW*resize); + bannerH = Math.floor(bannerH*resize); + } + slideshow($(this).find('.preview'), bannerEffect, bannerTime, bannerSpeed); + $(this).find('.preview').css({ + 'width': bannerW, + 'height': bannerH + }); + $(this).find('.preview img').css({ + 'width': '100%', + 'height': '100%' + }); + }); + $('#preview').on('hidden', function() { + $(this).attr('aria-labelledby', '').find('h3').text('') + $(this).find('.preview').cycle('destroy'); + $(this).find('.preview img').removeAttr('style'); + }); +}; + +$(function() { + var bannerName = null, + bannerEffect = null, + bannerTime = null, + bannerSpeed = null, + bannerW = null, + bannerH = null, + $preview = $('#pageslide .preview'); + + $(".ad_banner_ad_fx").change(function () { + var suckIE = false; + // bannerTime = $("#pageslide #timeout").val()*1000; + // bannerSpeed = $("#pageslide #speed").val()*1000; + + bannerTime = parseInt(bannerTime) || 300; + bannerSpeed = parseInt(bannerSpeed) || 300; + $(this).children('option:selected').each(function(index, el) { + $(this).val() == 'flipHorz' || $(this).val() == 'flipVert' ? $('.suckIE').show() : $('.suckIE').hide(); + }); + slideshow($preview, $(this).val(), 2000, 1000); + }); + preview(); +}); + diff --git a/app/assets/javascripts/admin/ad_banners.js b/app/assets/javascripts/admin/ad_banners.js new file mode 100644 index 0000000..d059265 --- /dev/null +++ b/app/assets/javascripts/admin/ad_banners.js @@ -0,0 +1,21 @@ +$(function() { + $.pageslide.closeCallback(function(pageslide, item) { + $("tr").removeClass("active"); + pageslide.find('.preview').cycle('destroy'); + }); + $.pageslide.loadComplete(function(pageslide, item) { + $("tr").removeClass("active"); + item.closest('tr').addClass('active'); + if(item.data('id') == 'new') { + resetForm(); + pageslide.find('form').attr('action', '/admin/ad_banners/'); + pageslide.find('form').attr('method', 'post'); + } + else { + setForm(item.data('form')); + pageslide.find('form').attr('action', '/admin/ad_banners/' + item.data('id')); + pageslide.find('form').attr('method', 'put'); + } + setSlideshow(pageslide.find('.preview'), item.data()); + }); +}) \ No newline at end of file diff --git a/app/assets/javascripts/cycle2.js b/app/assets/javascripts/cycle2.js new file mode 100644 index 0000000..60bea42 --- /dev/null +++ b/app/assets/javascripts/cycle2.js @@ -0,0 +1,4 @@ +//= require cycle2/jquery.cycle2.min.js +//= require cycle2/transition/jquery.cycle2.flip.min.js +//= require cycle2/transition/jquery.cycle2.scrollVert.min.js +//= require cycle2/transition/jquery.cycle2.tile.min.js \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/jquery.cycle2.min.js b/app/assets/javascripts/cycle2/jquery.cycle2.min.js new file mode 100644 index 0000000..9f9ec0f --- /dev/null +++ b/app/assets/javascripts/cycle2/jquery.cycle2.min.js @@ -0,0 +1,17 @@ +/*! +* jQuery Cycle2; build: v20131005 +* http://jquery.malsup.com/cycle2/ +* Copyright (c) 2013 M. Alsup; Dual licensed: MIT/GPL +*/ +/*! core engine; version: 20131003 */ +(function(e){"use strict";function t(e){return(e||"").toLowerCase()}var i="20131003";e.fn.cycle=function(i){var n;return 0!==this.length||e.isReady?this.each(function(){var n,s,o,c,r=e(this),l=e.fn.cycle.log;if(!r.data("cycle.opts")){(r.data("cycle-log")===!1||i&&i.log===!1||s&&s.log===!1)&&(l=e.noop),l("--c2 init--"),n=r.data();for(var a in n)n.hasOwnProperty(a)&&/^cycle[A-Z]+/.test(a)&&(c=n[a],o=a.match(/^cycle(.*)/)[1].replace(/^[A-Z]/,t),l(o+":",c,"("+typeof c+")"),n[o]=c);s=e.extend({},e.fn.cycle.defaults,n,i||{}),s.timeoutId=0,s.paused=s.paused||!1,s.container=r,s._maxZ=s.maxZ,s.API=e.extend({_container:r},e.fn.cycle.API),s.API.log=l,s.API.trigger=function(e,t){return s.container.trigger(e,t),s.API},r.data("cycle.opts",s),r.data("cycle.API",s.API),s.API.trigger("cycle-bootstrap",[s,s.API]),s.API.addInitialSlides(),s.API.preInitSlideshow(),s.slides.length&&s.API.initSlideshow()}}):(n={s:this.selector,c:this.context},e.fn.cycle.log("requeuing slideshow (dom not ready)"),e(function(){e(n.s,n.c).cycle(i)}),this)},e.fn.cycle.API={opts:function(){return this._container.data("cycle.opts")},addInitialSlides:function(){var t=this.opts(),i=t.slides;t.slideCount=0,t.slides=e(),i=i.jquery?i:t.container.find(i),t.random&&i.sort(function(){return Math.random()-.5}),t.API.add(i)},preInitSlideshow:function(){var t=this.opts();t.API.trigger("cycle-pre-initialize",[t]);var i=e.fn.cycle.transitions[t.fx];i&&e.isFunction(i.preInit)&&i.preInit(t),t._preInitialized=!0},postInitSlideshow:function(){var t=this.opts();t.API.trigger("cycle-post-initialize",[t]);var i=e.fn.cycle.transitions[t.fx];i&&e.isFunction(i.postInit)&&i.postInit(t)},initSlideshow:function(){var t,i=this.opts(),n=i.container;i.API.calcFirstSlide(),"static"==i.container.css("position")&&i.container.css("position","relative"),e(i.slides[i.currSlide]).css("opacity",1).show(),i.API.stackSlides(i.slides[i.currSlide],i.slides[i.nextSlide],!i.reverse),i.pauseOnHover&&(i.pauseOnHover!==!0&&(n=e(i.pauseOnHover)),n.hover(function(){i.API.pause(!0)},function(){i.API.resume(!0)})),i.timeout&&(t=i.API.getSlideOpts(i.currSlide),i.API.queueTransition(t,t.timeout+i.delay)),i._initialized=!0,i.API.updateView(!0),i.API.trigger("cycle-initialized",[i]),i.API.postInitSlideshow()},pause:function(t){var i=this.opts(),n=i.API.getSlideOpts(),s=i.hoverPaused||i.paused;t?i.hoverPaused=!0:i.paused=!0,s||(i.container.addClass("cycle-paused"),i.API.trigger("cycle-paused",[i]).log("cycle-paused"),n.timeout&&(clearTimeout(i.timeoutId),i.timeoutId=0,i._remainingTimeout-=e.now()-i._lastQueue,(0>i._remainingTimeout||isNaN(i._remainingTimeout))&&(i._remainingTimeout=void 0)))},resume:function(e){var t=this.opts(),i=!t.hoverPaused&&!t.paused;e?t.hoverPaused=!1:t.paused=!1,i||(t.container.removeClass("cycle-paused"),0===t.slides.filter(":animated").length&&t.API.queueTransition(t.API.getSlideOpts(),t._remainingTimeout),t.API.trigger("cycle-resumed",[t,t._remainingTimeout]).log("cycle-resumed"))},add:function(t,i){var n,s=this.opts(),o=s.slideCount,c=!1;"string"==e.type(t)&&(t=e.trim(t)),e(t).each(function(){var t,n=e(this);i?s.container.prepend(n):s.container.append(n),s.slideCount++,t=s.API.buildSlideOpts(n),s.slides=i?e(n).add(s.slides):s.slides.add(n),s.API.initSlide(t,n,--s._maxZ),n.data("cycle.opts",t),s.API.trigger("cycle-slide-added",[s,t,n])}),s.API.updateView(!0),c=s._preInitialized&&2>o&&s.slideCount>=1,c&&(s._initialized?s.timeout&&(n=s.slides.length,s.nextSlide=s.reverse?n-1:1,s.timeoutId||s.API.queueTransition(s)):s.API.initSlideshow())},calcFirstSlide:function(){var e,t=this.opts();e=parseInt(t.startingSlide||0,10),(e>=t.slides.length||0>e)&&(e=0),t.currSlide=e,t.reverse?(t.nextSlide=e-1,0>t.nextSlide&&(t.nextSlide=t.slides.length-1)):(t.nextSlide=e+1,t.nextSlide==t.slides.length&&(t.nextSlide=0))},calcNextSlide:function(){var e,t=this.opts();t.reverse?(e=0>t.nextSlide-1,t.nextSlide=e?t.slideCount-1:t.nextSlide-1,t.currSlide=e?0:t.nextSlide+1):(e=t.nextSlide+1==t.slides.length,t.nextSlide=e?0:t.nextSlide+1,t.currSlide=e?t.slides.length-1:t.nextSlide-1)},calcTx:function(t,i){var n,s=t;return i&&s.manualFx&&(n=e.fn.cycle.transitions[s.manualFx]),n||(n=e.fn.cycle.transitions[s.fx]),n||(n=e.fn.cycle.transitions.fade,s.API.log('Transition "'+s.fx+'" not found. Using fade.')),n},prepareTx:function(e,t){var i,n,s,o,c,r=this.opts();return 2>r.slideCount?(r.timeoutId=0,void 0):(!e||r.busy&&!r.manualTrump||(r.API.stopTransition(),r.busy=!1,clearTimeout(r.timeoutId),r.timeoutId=0),r.busy||(0!==r.timeoutId||e)&&(n=r.slides[r.currSlide],s=r.slides[r.nextSlide],o=r.API.getSlideOpts(r.nextSlide),c=r.API.calcTx(o,e),r._tx=c,e&&void 0!==o.manualSpeed&&(o.speed=o.manualSpeed),r.nextSlide!=r.currSlide&&(e||!r.paused&&!r.hoverPaused&&r.timeout)?(r.API.trigger("cycle-before",[o,n,s,t]),c.before&&c.before(o,n,s,t),i=function(){r.busy=!1,r.container.data("cycle.opts")&&(c.after&&c.after(o,n,s,t),r.API.trigger("cycle-after",[o,n,s,t]),r.API.queueTransition(o),r.API.updateView(!0))},r.busy=!0,c.transition?c.transition(o,n,s,t,i):r.API.doTransition(o,n,s,t,i),r.API.calcNextSlide(),r.API.updateView()):r.API.queueTransition(o)),void 0)},doTransition:function(t,i,n,s,o){var c=t,r=e(i),l=e(n),a=function(){l.animate(c.animIn||{opacity:1},c.speed,c.easeIn||c.easing,o)};l.css(c.cssBefore||{}),r.animate(c.animOut||{},c.speed,c.easeOut||c.easing,function(){r.css(c.cssAfter||{}),c.sync||a()}),c.sync&&a()},queueTransition:function(t,i){var n=this.opts(),s=void 0!==i?i:t.timeout;return 0===n.nextSlide&&0===--n.loop?(n.API.log("terminating; loop=0"),n.timeout=0,s?setTimeout(function(){n.API.trigger("cycle-finished",[n])},s):n.API.trigger("cycle-finished",[n]),n.nextSlide=n.currSlide,void 0):(s&&(n._lastQueue=e.now(),void 0===i&&(n._remainingTimeout=t.timeout),n.paused||n.hoverPaused||(n.timeoutId=setTimeout(function(){n.API.prepareTx(!1,!n.reverse)},s))),void 0)},stopTransition:function(){var e=this.opts();e.slides.filter(":animated").length&&(e.slides.stop(!1,!0),e.API.trigger("cycle-transition-stopped",[e])),e._tx&&e._tx.stopTransition&&e._tx.stopTransition(e)},advanceSlide:function(e){var t=this.opts();return clearTimeout(t.timeoutId),t.timeoutId=0,t.nextSlide=t.currSlide+e,0>t.nextSlide?t.nextSlide=t.slides.length-1:t.nextSlide>=t.slides.length&&(t.nextSlide=0),t.API.prepareTx(!0,e>=0),!1},buildSlideOpts:function(i){var n,s,o=this.opts(),c=i.data()||{};for(var r in c)c.hasOwnProperty(r)&&/^cycle[A-Z]+/.test(r)&&(n=c[r],s=r.match(/^cycle(.*)/)[1].replace(/^[A-Z]/,t),o.API.log("["+(o.slideCount-1)+"]",s+":",n,"("+typeof n+")"),c[s]=n);c=e.extend({},e.fn.cycle.defaults,o,c),c.slideNum=o.slideCount;try{delete c.API,delete c.slideCount,delete c.currSlide,delete c.nextSlide,delete c.slides}catch(l){}return c},getSlideOpts:function(t){var i=this.opts();void 0===t&&(t=i.currSlide);var n=i.slides[t],s=e(n).data("cycle.opts");return e.extend({},i,s)},initSlide:function(t,i,n){var s=this.opts();i.css(t.slideCss||{}),n>0&&i.css("zIndex",n),isNaN(t.speed)&&(t.speed=e.fx.speeds[t.speed]||e.fx.speeds._default),t.sync||(t.speed=t.speed/2),i.addClass(s.slideClass)},updateView:function(e,t){var i=this.opts();if(i._initialized){var n=i.API.getSlideOpts(),s=i.slides[i.currSlide];!e&&t!==!0&&(i.API.trigger("cycle-update-view-before",[i,n,s]),0>i.updateView)||(i.slideActiveClass&&i.slides.removeClass(i.slideActiveClass).eq(i.currSlide).addClass(i.slideActiveClass),e&&i.hideNonActive&&i.slides.filter(":not(."+i.slideActiveClass+")").hide(),i.API.trigger("cycle-update-view",[i,n,s,e]),e&&i.API.trigger("cycle-update-view-after",[i,n,s]))}},getComponent:function(t){var i=this.opts(),n=i[t];return"string"==typeof n?/^\s*[\>|\+|~]/.test(n)?i.container.find(n):e(n):n.jquery?n:e(n)},stackSlides:function(t,i,n){var s=this.opts();t||(t=s.slides[s.currSlide],i=s.slides[s.nextSlide],n=!s.reverse),e(t).css("zIndex",s.maxZ);var o,c=s.maxZ-2,r=s.slideCount;if(n){for(o=s.currSlide+1;r>o;o++)e(s.slides[o]).css("zIndex",c--);for(o=0;s.currSlide>o;o++)e(s.slides[o]).css("zIndex",c--)}else{for(o=s.currSlide-1;o>=0;o--)e(s.slides[o]).css("zIndex",c--);for(o=r-1;o>s.currSlide;o--)e(s.slides[o]).css("zIndex",c--)}e(i).css("zIndex",s.maxZ-1)},getSlideIndex:function(e){return this.opts().slides.index(e)}},e.fn.cycle.log=function(){window.console&&console.log&&console.log("[cycle2] "+Array.prototype.join.call(arguments," "))},e.fn.cycle.version=function(){return"Cycle2: "+i},e.fn.cycle.transitions={custom:{},none:{before:function(e,t,i,n){e.API.stackSlides(i,t,n),e.cssBefore={opacity:1,display:"block"}}},fade:{before:function(t,i,n,s){var o=t.API.getSlideOpts(t.nextSlide).slideCss||{};t.API.stackSlides(i,n,s),t.cssBefore=e.extend(o,{opacity:0,display:"block"}),t.animIn={opacity:1},t.animOut={opacity:0}}},fadeout:{before:function(t,i,n,s){var o=t.API.getSlideOpts(t.nextSlide).slideCss||{};t.API.stackSlides(i,n,s),t.cssBefore=e.extend(o,{opacity:1,display:"block"}),t.animOut={opacity:0}}},scrollHorz:{before:function(e,t,i,n){e.API.stackSlides(t,i,n);var s=e.container.css("overflow","hidden").width();e.cssBefore={left:n?s:-s,top:0,opacity:1,display:"block"},e.cssAfter={zIndex:e._maxZ-2,left:0},e.animIn={left:0},e.animOut={left:n?-s:s}}}},e.fn.cycle.defaults={allowWrap:!0,autoSelector:".cycle-slideshow[data-cycle-auto-init!=false]",delay:0,easing:null,fx:"fade",hideNonActive:!0,loop:0,manualFx:void 0,manualSpeed:void 0,manualTrump:!0,maxZ:100,pauseOnHover:!1,reverse:!1,slideActiveClass:"cycle-slide-active",slideClass:"cycle-slide",slideCss:{position:"absolute",top:0,left:0},slides:"> img",speed:500,startingSlide:0,sync:!0,timeout:4e3,updateView:-1},e(document).ready(function(){e(e.fn.cycle.defaults.autoSelector).cycle()})})(jQuery),/*! Cycle2 autoheight plugin; Copyright (c) M.Alsup, 2012; version: 20130304 */ +function(e){"use strict";function t(t,n){var s,o,c,r=n.autoHeight;if("container"==r)o=e(n.slides[n.currSlide]).outerHeight(),n.container.height(o);else if(n._autoHeightRatio)n.container.height(n.container.width()/n._autoHeightRatio);else if("calc"===r||"number"==e.type(r)&&r>=0){if(c="calc"===r?i(t,n):r>=n.slides.length?0:r,c==n._sentinelIndex)return;n._sentinelIndex=c,n._sentinel&&n._sentinel.remove(),s=e(n.slides[c].cloneNode(!0)),s.removeAttr("id name rel").find("[id],[name],[rel]").removeAttr("id name rel"),s.css({position:"static",visibility:"hidden",display:"block"}).prependTo(n.container).addClass("cycle-sentinel cycle-slide").removeClass("cycle-slide-active"),s.find("*").css("visibility","hidden"),n._sentinel=s}}function i(t,i){var n=0,s=-1;return i.slides.each(function(t){var i=e(this).height();i>s&&(s=i,n=t)}),n}function n(t,i,n,s){var o=e(s).outerHeight(),c=i.sync?i.speed/2:i.speed;i.container.animate({height:o},c)}function s(i,o){o._autoHeightOnResize&&(e(window).off("resize orientationchange",o._autoHeightOnResize),o._autoHeightOnResize=null),o.container.off("cycle-slide-added cycle-slide-removed",t),o.container.off("cycle-destroyed",s),o.container.off("cycle-before",n),o._sentinel&&(o._sentinel.remove(),o._sentinel=null)}e.extend(e.fn.cycle.defaults,{autoHeight:0}),e(document).on("cycle-initialized",function(i,o){function c(){t(i,o)}var r,l=o.autoHeight,a=e.type(l),d=null;("string"===a||"number"===a)&&(o.container.on("cycle-slide-added cycle-slide-removed",t),o.container.on("cycle-destroyed",s),"container"==l?o.container.on("cycle-before",n):"string"===a&&/\d+\:\d+/.test(l)&&(r=l.match(/(\d+)\:(\d+)/),r=r[1]/r[2],o._autoHeightRatio=r),"number"!==a&&(o._autoHeightOnResize=function(){clearTimeout(d),d=setTimeout(c,50)},e(window).on("resize orientationchange",o._autoHeightOnResize)),setTimeout(c,30))})}(jQuery),/*! caption plugin for Cycle2; version: 20130306 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{caption:"> .cycle-caption",captionTemplate:"{{slideNum}} / {{slideCount}}",overlay:"> .cycle-overlay",overlayTemplate:"
{{title}}
{{desc}}
",captionModule:"caption"}),e(document).on("cycle-update-view",function(t,i,n,s){"caption"===i.captionModule&&e.each(["caption","overlay"],function(){var e=this,t=n[e+"Template"],o=i.API.getComponent(e);o.length&&t?(o.html(i.API.tmpl(t,n,i,s)),o.show()):o.hide()})}),e(document).on("cycle-destroyed",function(t,i){var n;e.each(["caption","overlay"],function(){var e=this,t=i[e+"Template"];i[e]&&t&&(n=i.API.getComponent("caption"),n.empty())})})}(jQuery),/*! command plugin for Cycle2; version: 20130707 */ +function(e){"use strict";var t=e.fn.cycle;e.fn.cycle=function(i){var n,s,o,c=e.makeArray(arguments);return"number"==e.type(i)?this.cycle("goto",i):"string"==e.type(i)?this.each(function(){var r;return n=i,o=e(this).data("cycle.opts"),void 0===o?(t.log('slideshow must be initialized before sending commands; "'+n+'" ignored'),void 0):(n="goto"==n?"jump":n,s=o.API[n],e.isFunction(s)?(r=e.makeArray(c),r.shift(),s.apply(o.API,r)):(t.log("unknown command: ",n),void 0))}):t.apply(this,arguments)},e.extend(e.fn.cycle,t),e.extend(t.API,{next:function(){var e=this.opts();if(!e.busy||e.manualTrump){var t=e.reverse?-1:1;e.allowWrap===!1&&e.currSlide+t>=e.slideCount||(e.API.advanceSlide(t),e.API.trigger("cycle-next",[e]).log("cycle-next"))}},prev:function(){var e=this.opts();if(!e.busy||e.manualTrump){var t=e.reverse?1:-1;e.allowWrap===!1&&0>e.currSlide+t||(e.API.advanceSlide(t),e.API.trigger("cycle-prev",[e]).log("cycle-prev"))}},destroy:function(){this.stop();var t=this.opts(),i=e.isFunction(e._data)?e._data:e.noop;clearTimeout(t.timeoutId),t.timeoutId=0,t.API.stop(),t.API.trigger("cycle-destroyed",[t]).log("cycle-destroyed"),t.container.removeData(),i(t.container[0],"parsedAttrs",!1),t.retainStylesOnDestroy||(t.container.removeAttr("style"),t.slides.removeAttr("style"),t.slides.removeClass(t.slideActiveClass)),t.slides.each(function(){e(this).removeData(),i(this,"parsedAttrs",!1)})},jump:function(e){var t,i=this.opts();if(!i.busy||i.manualTrump){var n=parseInt(e,10);if(isNaN(n)||0>n||n>=i.slides.length)return i.API.log("goto: invalid slide index: "+n),void 0;if(n==i.currSlide)return i.API.log("goto: skipping, already on slide",n),void 0;i.nextSlide=n,clearTimeout(i.timeoutId),i.timeoutId=0,i.API.log("goto: ",n," (zero-index)"),t=i.currSlider;r++)i=s.slides[r],r==t?n=i:(o.push(i),e(i).data("cycle.opts").slideNum=c,c++);n&&(s.slides=e(o),s.slideCount--,e(n).remove(),t==s.currSlide?s.API.advanceSlide(1):s.currSlide>t?s.currSlide--:s.currSlide++,s.API.trigger("cycle-slide-removed",[s,t,n]).log("cycle-slide-removed"),s.API.updateView())}}),e(document).on("click.cycle","[data-cycle-cmd]",function(t){t.preventDefault();var i=e(this),n=i.data("cycle-cmd"),s=i.data("cycle-context")||".cycle-slideshow";e(s).cycle(n,i.data("cycle-arg"))})}(jQuery),/*! hash plugin for Cycle2; version: 20130905 */ +function(e){"use strict";function t(t,i){var n;return t._hashFence?(t._hashFence=!1,void 0):(n=window.location.hash.substring(1),t.slides.each(function(s){if(e(this).data("cycle-hash")==n){if(i===!0)t.startingSlide=s;else{var o=s>t.currSlide;t.nextSlide=s,t.API.prepareTx(!0,o)}return!1}}),void 0)}e(document).on("cycle-pre-initialize",function(i,n){t(n,!0),n._onHashChange=function(){t(n,!1)},e(window).on("hashchange",n._onHashChange)}),e(document).on("cycle-update-view",function(e,t,i){i.hash&&"#"+i.hash!=window.location.hash&&(t._hashFence=!0,window.location.hash=i.hash)}),e(document).on("cycle-destroyed",function(t,i){i._onHashChange&&e(window).off("hashchange",i._onHashChange)})}(jQuery),/*! loader plugin for Cycle2; version: 20130307 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{loader:!1}),e(document).on("cycle-bootstrap",function(t,i){function n(t,n){function o(t){var o;"wait"==i.loader?(r.push(t),0===a&&(r.sort(c),s.apply(i.API,[r,n]),i.container.removeClass("cycle-loading"))):(o=e(i.slides[i.currSlide]),s.apply(i.API,[t,n]),o.show(),i.container.removeClass("cycle-loading"))}function c(e,t){return e.data("index")-t.data("index")}var r=[];if("string"==e.type(t))t=e.trim(t);else if("array"===e.type(t))for(var l=0;t.length>l;l++)t[l]=e(t[l])[0];t=e(t);var a=t.length;a&&(t.hide().appendTo("body").each(function(t){function c(){0===--l&&(--a,o(d))}var l=0,d=e(this),u=d.is("img")?d:d.find("img");return d.data("index",t),u=u.filter(":not(.cycle-loader-ignore)").filter(':not([src=""])'),u.length?(l=u.length,u.each(function(){this.complete?c():e(this).load(function(){c()}).error(function(){0===--l&&(i.API.log("slide skipped; img not loaded:",this.src),0===--a&&"wait"==i.loader&&s.apply(i.API,[r,n]))})}),void 0):(--a,r.push(d),void 0)}),a&&i.container.addClass("cycle-loading"))}var s;i.loader&&(s=i.API.add,i.API.add=n)})}(jQuery),/*! pager plugin for Cycle2; version: 20130525 */ +function(e){"use strict";function t(t,i,n){var s,o=t.API.getComponent("pager");o.each(function(){var o=e(this);if(i.pagerTemplate){var c=t.API.tmpl(i.pagerTemplate,i,t,n[0]);s=e(c).appendTo(o)}else s=o.children().eq(t.slideCount-1);s.on(t.pagerEvent,function(e){e.preventDefault(),t.API.page(o,e.currentTarget)})})}function i(e,t){var i=this.opts();if(!i.busy||i.manualTrump){var n=e.children().index(t),s=n,o=s>i.currSlide;i.currSlide!=s&&(i.nextSlide=s,i.API.prepareTx(!0,o),i.API.trigger("cycle-pager-activated",[i,e,t]))}}e.extend(e.fn.cycle.defaults,{pager:"> .cycle-pager",pagerActiveClass:"cycle-pager-active",pagerEvent:"click.cycle",pagerTemplate:""}),e(document).on("cycle-bootstrap",function(e,i,n){n.buildPagerLink=t}),e(document).on("cycle-slide-added",function(e,t,n,s){t.pager&&(t.API.buildPagerLink(t,n,s),t.API.page=i)}),e(document).on("cycle-slide-removed",function(t,i,n){if(i.pager){var s=i.API.getComponent("pager");s.each(function(){var t=e(this);e(t.children()[n]).remove()})}}),e(document).on("cycle-update-view",function(t,i){var n;i.pager&&(n=i.API.getComponent("pager"),n.each(function(){e(this).children().removeClass(i.pagerActiveClass).eq(i.currSlide).addClass(i.pagerActiveClass)}))}),e(document).on("cycle-destroyed",function(e,t){var i=t.API.getComponent("pager");i&&(i.children().off(t.pagerEvent),t.pagerTemplate&&i.empty())})}(jQuery),/*! prevnext plugin for Cycle2; version: 20130709 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{next:"> .cycle-next",nextEvent:"click.cycle",disabledClass:"disabled",prev:"> .cycle-prev",prevEvent:"click.cycle",swipe:!1}),e(document).on("cycle-initialized",function(e,t){if(t.API.getComponent("next").on(t.nextEvent,function(e){e.preventDefault(),t.API.next()}),t.API.getComponent("prev").on(t.prevEvent,function(e){e.preventDefault(),t.API.prev()}),t.swipe){var i=t.swipeVert?"swipeUp.cycle":"swipeLeft.cycle swipeleft.cycle",n=t.swipeVert?"swipeDown.cycle":"swipeRight.cycle swiperight.cycle";t.container.on(i,function(){t.API.next()}),t.container.on(n,function(){t.API.prev()})}}),e(document).on("cycle-update-view",function(e,t){if(!t.allowWrap){var i=t.disabledClass,n=t.API.getComponent("next"),s=t.API.getComponent("prev"),o=t._prevBoundry||0,c=void 0!==t._nextBoundry?t._nextBoundry:t.slideCount-1;t.currSlide==c?n.addClass(i).prop("disabled",!0):n.removeClass(i).prop("disabled",!1),t.currSlide===o?s.addClass(i).prop("disabled",!0):s.removeClass(i).prop("disabled",!1)}}),e(document).on("cycle-destroyed",function(e,t){t.API.getComponent("prev").off(t.nextEvent),t.API.getComponent("next").off(t.prevEvent),t.container.off("swipeleft.cycle swiperight.cycle swipeLeft.cycle swipeRight.cycle swipeUp.cycle swipeDown.cycle")})}(jQuery),/*! progressive loader plugin for Cycle2; version: 20130315 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{progressive:!1}),e(document).on("cycle-pre-initialize",function(t,i){if(i.progressive){var n,s,o=i.API,c=o.next,r=o.prev,l=o.prepareTx,a=e.type(i.progressive);if("array"==a)n=i.progressive;else if(e.isFunction(i.progressive))n=i.progressive(i);else if("string"==a){if(s=e(i.progressive),n=e.trim(s.html()),!n)return;if(/^(\[)/.test(n))try{n=e.parseJSON(n)}catch(d){return o.log("error parsing progressive slides",d),void 0}else n=n.split(RegExp(s.data("cycle-split")||"\n")),n[n.length-1]||n.pop()}l&&(o.prepareTx=function(e,t){var s,o;return e||0===n.length?(l.apply(i.API,[e,t]),void 0):(t&&i.currSlide==i.slideCount-1?(o=n[0],n=n.slice(1),i.container.one("cycle-slide-added",function(e,t){setTimeout(function(){t.API.advanceSlide(1)},50)}),i.API.add(o)):t||0!==i.currSlide?l.apply(i.API,[e,t]):(s=n.length-1,o=n[s],n=n.slice(0,s),i.container.one("cycle-slide-added",function(e,t){setTimeout(function(){t.currSlide=1,t.API.advanceSlide(-1)},50)}),i.API.add(o,!0)),void 0)}),c&&(o.next=function(){var e=this.opts();if(n.length&&e.currSlide==e.slideCount-1){var t=n[0];n=n.slice(1),e.container.one("cycle-slide-added",function(e,t){c.apply(t.API),t.container.removeClass("cycle-loading")}),e.container.addClass("cycle-loading"),e.API.add(t)}else c.apply(e.API)}),r&&(o.prev=function(){var e=this.opts();if(n.length&&0===e.currSlide){var t=n.length-1,i=n[t];n=n.slice(0,t),e.container.one("cycle-slide-added",function(e,t){t.currSlide=1,t.API.advanceSlide(-1),t.container.removeClass("cycle-loading")}),e.container.addClass("cycle-loading"),e.API.add(i,!0)}else r.apply(e.API)})}})}(jQuery),/*! tmpl plugin for Cycle2; version: 20121227 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{tmplRegex:"{{((.)?.*?)}}"}),e.extend(e.fn.cycle.API,{tmpl:function(t,i){var n=RegExp(i.tmplRegex||e.fn.cycle.defaults.tmplRegex,"g"),s=e.makeArray(arguments);return s.shift(),t.replace(n,function(t,i){var n,o,c,r,l=i.split(".");for(n=0;s.length>n;n++)if(c=s[n]){if(l.length>1)for(r=c,o=0;l.length>o;o++)c=r,r=r[l[o]]||i;else r=c[i];if(e.isFunction(r))return r.apply(c,s);if(void 0!==r&&null!==r&&r!=i)return r}return i})}})}(jQuery); +//@ sourceMappingURL=jquery.cycle2.js.map \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.flip.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.flip.min.js new file mode 100644 index 0000000..5b71b2c --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.flip.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20130909 */ +(function(e){"use strict";function t(t){return{preInit:function(e){e.slides.css(n)},transition:function(i,n,s,o,r){var l=i,c=e(n),a=e(s),d=l.speed/2;t.call(a,-90),a.css({display:"block","background-position":"-90px",opacity:1}),c.css("background-position","0px"),c.animate({backgroundPosition:90},{step:t,duration:d,easing:l.easeOut||l.easing,complete:function(){i.API.updateView(!1,!0),a.animate({backgroundPosition:0},{step:t,duration:d,easing:l.easeIn||l.easing,complete:r})}})}}}function i(t){return function(i){var n=e(this);n.css({"-webkit-transform":"rotate"+t+"("+i+"deg)","-moz-transform":"rotate"+t+"("+i+"deg)","-ms-transform":"rotate"+t+"("+i+"deg)","-o-transform":"rotate"+t+"("+i+"deg)",transform:"rotate"+t+"("+i+"deg)"})}}var n,s=document.createElement("div").style,o=e.fn.cycle.transitions,r=void 0!==s.transform||void 0!==s.MozTransform||void 0!==s.webkitTransform||void 0!==s.oTransform||void 0!==s.msTransform;r&&void 0!==s.msTransform&&(s.msTransform="rotateY(0deg)",s.msTransform||(r=!1)),r?(o.flipHorz=t(i("Y")),o.flipVert=t(i("X")),n={"-webkit-backface-visibility":"hidden","-moz-backface-visibility":"hidden","-o-backface-visibility":"hidden","backface-visibility":"hidden"}):(o.flipHorz=o.scrollHorz,o.flipVert=o.scrollVert||o.scrollHorz)})(jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.ie-fade.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.ie-fade.min.js new file mode 100644 index 0000000..89b50d2 --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.ie-fade.min.js @@ -0,0 +1,2 @@ +/*! Plugin for Cycle2; Copyright (c) 2012 M. Alsup; ver: 20121120 */ +(function(a){function b(a,b,c){if(a&&c.style.filter){b._filter=c.style.filter;try{c.style.removeAttribute("filter")}catch(d){}}else!a&&b._filter&&(c.style.filter=b._filter)}"use strict",a.extend(a.fn.cycle.transitions,{fade:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssBefore=a.extend(g,{opacity:0,display:"block"}),c.animIn={opacity:1},c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}},fadeout:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssBefore=a.extend(g,{opacity:1,display:"block"}),c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}}})})(jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.scrollVert.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.scrollVert.min.js new file mode 100644 index 0000000..c5ebe28 --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.scrollVert.min.js @@ -0,0 +1,2 @@ +/*! Plugin for Cycle2; Copyright (c) 2012 M. Alsup; ver: 20121120 */ +(function(a){"use strict",a.fn.cycle.transitions.scrollVert={before:function(a,b,c,d){a.API.stackSlides(a,b,c,d);var e=a.container.css("overflow","hidden").height();a.cssBefore={top:d?-e:e,left:0,opacity:1,display:"block"},a.animIn={top:0},a.animOut={top:d?e:-e}}}})(jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.tile.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.tile.min.js new file mode 100644 index 0000000..f64379f --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.tile.min.js @@ -0,0 +1,2 @@ +/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20130721 */ +(function(e){"use strict";e.fn.cycle.transitions.tileSlide=e.fn.cycle.transitions.tileBlind={before:function(t,i,n,s){t.API.stackSlides(i,n,s),e(i).show(),t.container.css("overflow","hidden"),t.tileDelay=t.tileDelay||"tileSlide"==t.fx?100:125,t.tileCount=t.tileCount||7,t.tileVertical=t.tileVertical!==!1,t.container.data("cycleTileInitialized")||(t.container.on("cycle-destroyed",e.proxy(this.onDestroy,t.API)),t.container.data("cycleTileInitialized",!0))},transition:function(t,i,n,s,o){function r(e){p.eq(e).animate(I,{duration:t.speed,easing:t.easing,complete:function(){(s?v-1===e:0===e)&&t._tileAniCallback()}}),setTimeout(function(){(s?v-1!==e:0!==e)&&r(s?e+1:e-1)},t.tileDelay)}t.slides.not(i).not(n).hide();var c,l,a,d,u,p=e(),f=e(i),y=e(n),v=t.tileCount,h=t.tileVertical,g=t.container.height(),m=t.container.width();h?(l=Math.floor(m/v),d=m-l*(v-1),a=u=g):(l=d=m,a=Math.floor(g/v),u=g-a*(v-1)),t.container.find(".cycle-tiles-container").remove();var I,A={left:0,top:0,overflow:"hidden",position:"absolute",margin:0,padding:0};I=h?"tileSlide"==t.fx?{top:g}:{width:0}:"tileSlide"==t.fx?{left:m}:{height:0};var S=e('
');S.css({zIndex:f.css("z-index"),overflow:"visible",position:"absolute",top:0,left:0,direction:"ltr"}),S.insertBefore(n);for(var x=0;v>x;x++)c=e("
").css(A).css({width:v-1===x?d:l,height:v-1===x?u:a,marginLeft:h?x*l:0,marginTop:h?0:x*a}).append(f.clone().css({position:"relative",maxWidth:"none",width:f.width(),margin:0,padding:0,marginLeft:h?-(x*l):0,marginTop:h?0:-(x*a)})),p=p.add(c);S.append(p),f.hide(),y.show().css("opacity",1),r(s?0:v-1),t._tileAniCallback=function(){y.show(),f.hide(),S.remove(),o()}},stopTransition:function(e){e.container.find("*").stop(!0,!0),e._tileAniCallback&&e._tileAniCallback()},onDestroy:function(){var e=this.opts();e.container.find(".cycle-tiles-container").remove()}}})(jQuery); \ No newline at end of file diff --git a/app/assets/stylesheets/ad_banner/.keep b/app/assets/stylesheets/ad_banner/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/ad_banners.css b/app/assets/stylesheets/ad_banners.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/ad_banners.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/assets/stylesheets/admin/ad_banners.css b/app/assets/stylesheets/admin/ad_banners.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/admin/ad_banners.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/assets/stylesheets/admin/ad_images.css b/app/assets/stylesheets/admin/ad_images.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/admin/ad_images.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/.keep b/app/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb new file mode 100644 index 0000000..1f89adc --- /dev/null +++ b/app/controllers/ad_banners_controller.rb @@ -0,0 +1,30 @@ +class AdBannersController < ApplicationController + def widget + adbanner = Banner.find(OrbitHelper.widget_custom_value) + images = adbanner.ad_images.can_display.collect.with_index do |b,i| + image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url + klass = i == 0 ? "active" : "" + caption = i == 0 ? '
' : "" + { + "image_link" => image_link, + "title" => b.title, + "class" => klass, + "height" => adbanner.height, + "width" => adbanner.width, + "caption" => caption, + "context" => b.context, + "link" => b.out_link || "#" + } + end + { + "extras" => { + "ad_fx" => adbanner.ad_fx, + "speed" => adbanner.speed, + "title" => adbanner.title, + "timeout" => adbanner.timeout, + "more" => "More" + }, + "images" => images + } + end +end diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb new file mode 100644 index 0000000..8652ff6 --- /dev/null +++ b/app/controllers/admin/ad_banners_controller.rb @@ -0,0 +1,56 @@ +class Admin::AdBannersController < OrbitAdminController + before_action ->(module_app = @app_title) { set_variables module_app } + + def index + @banners = Banner.all + end + + def show + @ad_banners = Banner.all + @active = Banner.find(params[:id]) + render :action => 'index' + end + + def new + @ad_banner = Banner.new + render layout: false + end + + def create + @ad_banner = Banner.new(banner_params) + if @ad_banner.save + redirect_to admin_ad_banners_url + else + @ad_banner = Banner.new(params[:ad_banner]) + render :new + end + end + + def edit + @ad_banner = Banner.find(params[:id]) + render layout: false + end + + def update + @ad_banner = Banner.find(params[:id]) + if @ad_banner.update_attributes(banner_params) + redirect_to admin_ad_banners_url, :status => 303 + else + render :edit + end + end + + def destroy + @ad_banner = Banner.find(params[:id]) + @ad_banner.destroy + redirect_to admin_ad_banners_url + end + + private + + # Never trust parameters from the scary internet, only allow the white list through. + def banner_params + params.require(:ad_banner).permit! + end +end + diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb new file mode 100644 index 0000000..58687e7 --- /dev/null +++ b/app/controllers/admin/ad_images_controller.rb @@ -0,0 +1,71 @@ +class Admin::AdImagesController < Admin::AdBannersController + def initialize + super + @app_title = "ad_banner" + end + + def index + @ad_images = AdImage.order_by(sort).page(params[:page]).per(10) + @table_fields = ["preview","ad_banner.banner","title","start_date","end_date", "link"] + end + + def edit + @ad_image = AdImage.find(params[:id]) + @item = [[t('image'),"1"],[t('video'),"2"]] + @item_choose = @ad_image.exchange_item + if can_edit_or_delete?(@ad_image) + @ad_banner = @ad_image.banner + else + render_401 + end + end + + def update + @ad_image = AdImage.find(params[:id]) + if @ad_image.update_attributes(ad_image_params) + redirect_to params['referer_url'] + else + @ad_banners = Banner.all + @tags = @module_app.tags || [] + render action: :edit + end + end + + def new + @ad_image = AdImage.new + @item = [[t('image'),"1"],[t('video'),"2"]] + @ad_banner = Banner.find(params[:banner]) + @tags = @module_app.tags || [] + + @ad_image.postdate = Date.today + end + + def create + @ad_image = AdImage.new(ad_image_params) + if @ad_image.save + redirect_to params['referer_url'] + else + @ad_banners = Banner.all + @tags = @module_app.tags || [] + @ad_image = AdImage.new(ad_image_params) + render action: :new + end + end + + def destroy + @ad_image = AdImage.find params[:id] + if @ad_image.destroy + redirect_to admin_ad_banners_url + end + end + + private + + def ad_image_params + params.require(:ad_image).permit! + end + + def setup_vars + @module_app = ModuleApp.where(:key => "ad_banner").first + end +end \ No newline at end of file diff --git a/app/helpers/.keep b/app/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/helpers/ad_banners_helper.rb b/app/helpers/ad_banners_helper.rb new file mode 100644 index 0000000..1b9a594 --- /dev/null +++ b/app/helpers/ad_banners_helper.rb @@ -0,0 +1,2 @@ +module AdBannersHelper +end diff --git a/app/helpers/admin/ad_banners_helper.rb b/app/helpers/admin/ad_banners_helper.rb new file mode 100644 index 0000000..8f9cd4d --- /dev/null +++ b/app/helpers/admin/ad_banners_helper.rb @@ -0,0 +1,2 @@ +module Admin::AdBannersHelper +end diff --git a/app/helpers/admin/ad_images_helper.rb b/app/helpers/admin/ad_images_helper.rb new file mode 100644 index 0000000..eaadef7 --- /dev/null +++ b/app/helpers/admin/ad_images_helper.rb @@ -0,0 +1,2 @@ +module Admin::AdImagesHelper +end diff --git a/app/mailers/.keep b/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/.keep b/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb new file mode 100644 index 0000000..0e17a16 --- /dev/null +++ b/app/models/ad_image.rb @@ -0,0 +1,40 @@ +require 'uri' + +class AdImage + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :file, ImageUploader + + field :title, type: String, localize: true + field :context, type: String, localize: true + field :weight, type: Integer, default: 1 + field :out_link, type: String + field :link_open, type: String + field :postdate , :type => DateTime, :default => Time.now + field :deadline , :type => DateTime + field :youtube , :type => String + field :exchange_item + LINK_OPEN_TYPES = ["local", "new_window"] + + belongs_to :banner + + before_validation :add_http + # validates :file, presence: true + validates :out_link, format: { with: URI::regexp(%w(http https)) }, allow_blank: true + # validates :title, presence: true + + scope :can_display, ->{self.and(AdImage.or({:postdate.lte=>Time.now},{:postdate=>nil}).selector,AdImage.or({:deadline.gte=>Time.now},{:deadline=>nil}).selector)} + + def expired? + self.deadline { :minimum => 2 } + validates :height, :width, :presence => true + + FX_TYPES = %w(fade fadeout flipHorz flipVert scrollHorz scrollVert tileSlide tileBlind) + + def size + "#{self.width} x #{self.height}" + end + + def timeout_millisecond + self.timeout*1000 rescue 0 + end + + def preview_link + "
Preview".html_safe + end + + def data_attribute_hash + {'width'=> self.width,'height'=> self.height,'ad_fx'=> self.ad_fx,'name'=>self.title,'timeout'=>self.timeout,'speed'=>self.speed}.to_json + end +end diff --git a/app/views/.keep b/app/views/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/ad_banners/widget.html.erb b/app/views/ad_banners/widget.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/ad_banners/widget.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/app/views/admin/ad_banners/_form.html.erb b/app/views/admin/ad_banners/_form.html.erb new file mode 100644 index 0000000..7ed6e75 --- /dev/null +++ b/app/views/admin/ad_banners/_form.html.erb @@ -0,0 +1,12 @@ +<%#= flash_messages %> +<%#= f.error_messages %> + +<%= f.label :title, t('ad_banner.banner_name') %> +<%= f.text_field :title, class: 'input-large', placeholder: t('ad_banner.banner_name'), id: 'name' %> +<%= t('ad_banner.name_only_english') %> + +<%= f.label :size, t('ad_banner.size') %> + +<%= f.number_field :width, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'width' %> + +<%= f.number_field :height, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'height' %> diff --git a/app/views/admin/ad_banners/_index.html.erb b/app/views/admin/ad_banners/_index.html.erb new file mode 100644 index 0000000..70a75d6 --- /dev/null +++ b/app/views/admin/ad_banners/_index.html.erb @@ -0,0 +1,387 @@ +<% + height = 140 +%> + +
+<% @banners.each_with_index do |banner,i| %> + <% if (i+1)%3==1 %>
<% end %> +
+
<%= banner.title %>
+
+ <% if !banner.ad_images.can_display.blank? %> + <% banner.ad_images.can_display.each do |image| %> + <% if image.exchange_item == '1' %> +
+ <% elsif image.exchange_item == '2' %> +
+ <% end %> + <% end %> + <% else %> +
+
+ <% end %> + +
+ + <% if can_edit_or_delete?(banner) %> + + <% end %> + +
+ + + + + +
<%= t("ad_banner.size") %> : <%= banner.size %>
+
+ + <% if can_edit_or_delete?(banner) %> +
+
+
+ + <%= t("new_image") %> + + <% banner.ad_images.each_with_index do |image,idx| %> +
+ <% if image.exchange_item == '1' %> +
" style="background: url('<%= image.file.thumb.url %>'); background-size: cover; background-position: center;"> + <% if image.expired? %> +
<%= t("ad_banner.expired") %>
+ <% end %> + <% if (image.postdate > Time.now rescue false) %> +
<%= t("start_date")+': '+(format_value image.postdate) %>
+ <% end %> + <%= t('image') %> + <%= t(:edit) %> + <%= t(:delete_) %> +
+ <% else %> +
" style="background: url('http://img.youtube.com/vi/<%= image.youtube.to_s[-11,11] %>/hqdefault.jpg'); background-size: cover; background-position: center;"> + <% if image.expired? %> +
<%= t("ad_banner.expired") %>
+ <% end %> + <% if (image.postdate > Time.now rescue false) %> +
<%= t("start_date")+': '+(format_value image.postdate) %>
+ <% end %> + <%= t('video') %> + <%= t(:edit) %> + <%= t(:delete_) %> +
+ <% end %> +
+ + + + + + + + + + + + + + + + + +
<%= t("title") %> : <%= image.title %>
<%= t("start_date") %> : <%= format_value image.postdate %>
<%= t("end_date") %> : <%= format_value image.deadline %>
<%= t("link") %> : <%= image.out_link rescue " " %>
+
+
+ <% end %> +
+
+ <% end %> + +
+ <% if ((i+1)%3==0) or (i+1 == @banners.count) %>

<% end %> +<% end %> +
+ + \ No newline at end of file diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb new file mode 100644 index 0000000..5b79e3f --- /dev/null +++ b/app/views/admin/ad_banners/index.html.erb @@ -0,0 +1,46 @@ + +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "cycle2" %> + <%= javascript_include_tag "ad_banner/banner_preview" %> +<% end %> + + + +<% if current_user.is_admin? or current_user.is_manager?(@module_app) %> + + +
+
+ + + + +
+
+
+
+ <%= form_for :ad_banner, url: nil, remote: true do |f| %> +
+ <%= render :partial => "form", :locals => { :f => f } %> +
+ <%= t(:cancel) %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small' %> +
+
+ <% end %> +
+
+
+
+ + <%= render 'layouts/delete_modal', delete_options: @delete_options %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/ad_banners/index.js.erb b/app/views/admin/ad_banners/index.js.erb new file mode 100644 index 0000000..b6d94bc --- /dev/null +++ b/app/views/admin/ad_banners/index.js.erb @@ -0,0 +1,5 @@ +$.pageslide.close(); +$("#banner_index").html("<%= j render 'index' %>"); +$(".cycle-slideshow").cycle(); +openSlide(); +preview(); \ No newline at end of file diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb new file mode 100644 index 0000000..67a38d8 --- /dev/null +++ b/app/views/admin/ad_images/_form.html.erb @@ -0,0 +1,199 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + +<%#= f.error_messages %> + + +
+ + +
+ + +
+ +
+ +
+
<%= t("choose_type") %>
+ <%= + select_tag "ad_image[exchange_item]", options_for_select(@item,@item_choose), prompt: t('select'),:onchange => "chg(this.options[this.options.selectedIndex].value)" + %> +
+
+ + + + + + + + +
+ +
+
+
+ <% @site_in_use_locales.each_with_index do |locale, i| %> +
" id="title_<%= locale %>"> + <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, :value => (@ad_image.title_translations[locale] rescue nil), :placeholder=>"#{t(locale.to_s)+t("title")}" %> + <% end %> +
+ <% end %> +
+
+ <% @site_in_use_locales.each_with_index do |locale, i| %> + " href="#title_<%= locale %>" data-toggle="tab"><%= t(locale.to_s) %> + <% end %> +
+
+
+
+ + +
+ +
+ <%= f.datetime_picker :postdate, :no_label => true %> +
+
+ + +
+ +
+ <%= f.datetime_picker :deadline, :no_label => true %> +
+
+ + +
+ +
+ <%= f.text_field :out_link, placeholder: t('ad_banner.enter_url') %> +
+
+ +
+ +
+ <%= f.select :link_open, AdImage::LINK_OPEN_TYPES.map{|a| [t("ad_banner.#{a}"), a]} %> +
+
+ +
+ +
+ + + + + +
+ + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+
+ <%= f.fields_for :context_translations do |f| %> + <%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@ad_image.context_translations[locale] rescue nil) %> + <% end %> +
+
+
+ +
+ + <% end %> + +
+ +
+ + +
+ + <%= f.submit t('submit'), class: 'btn btn-primary' %> +
+ + diff --git a/app/views/admin/ad_images/edit.html.erb b/app/views/admin/ad_images/edit.html.erb new file mode 100644 index 0000000..721e40e --- /dev/null +++ b/app/views/admin/ad_images/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @ad_image, url: admin_ad_image_path(@ad_image), html: {class: "form-horizontal main-forms", onSubmit: "return checkSelect();"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/ad_images/index.html.erb b/app/views/admin/ad_images/index.html.erb new file mode 100644 index 0000000..c36888f --- /dev/null +++ b/app/views/admin/ad_images/index.html.erb @@ -0,0 +1,35 @@ + + + + <% @table_fields.each do |f| %> + <%= thead(f) %> + <% end %> + + + + <% @ad_images.each do |image| %> + + + + + + + + + <% end %> + +
<%= image.banner.title %> + <%= image.title %> +
+ <% if can_edit_or_delete?(image) %> + + <% end %> +
+
<%= format_value image.postdate %><%= format_value image.deadline %><%= image.out_link rescue " " %>
diff --git a/app/views/admin/ad_images/new.html.erb b/app/views/admin/ad_images/new.html.erb new file mode 100644 index 0000000..aac016f --- /dev/null +++ b/app/views/admin/ad_images/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @ad_image, url: admin_ad_images_path, html: {class: "form-horizontal main-forms", onSubmit: "return checkSelect();"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000..cf3cc5f --- /dev/null +++ b/bin/rails @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. + +ENGINE_ROOT = File.expand_path('../..', __FILE__) +ENGINE_PATH = File.expand_path('../../lib/ad_banner/engine', __FILE__) + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) + +require "action_controller/railtie" +require "action_mailer/railtie" +require "sprockets/railtie" +require "rails/test_unit/railtie" +require "mongoid" +require 'rails/engine/commands' diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..a2984d8 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,36 @@ +en: + + ad_banner: + ad_banner: Ad Banner + banner: Banner + banner_name: Banner Name + edit_banner: Edit Banner + effect: Effect + enter_number: Please enter a number + enter_url: Please enter the URL + local: Open In Current page + name_only_english: Banner Name can only in English + new_banner: New Banner + new_window: Open In New window + no_ie_10_effect_support: IE10 earlier do not support this effect + number_milliseconds: Please enter the number of milliseconds + number_seconds: Please enter the number of seconds + size: Size + transition_interval: Interval + transition_speed: Speed + type: Link Open Type + banner_name_note: Banner Name only english + ste: Transition Interval + ste_note: Please enter the number of seconds + best_size: Best Size + all: All + categories: Categories + add: Add + setting: Settings + expired: Expired + video: Video + new_image: New Image or Video + youtube: youtube embed URL + type: Image or Video + choose_type: Please Select One Type First + select: Please Select One \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml new file mode 100644 index 0000000..5205868 --- /dev/null +++ b/config/locales/zh_tw.yml @@ -0,0 +1,33 @@ +zh_tw: + + ad_banner: + ad_banner: 廣告輪播 + banner: 橫幅 + banner_name: 橫幅名稱 + name_only_english: 橫幅名稱只能為英文 + edit_banner: 編輯橫幅 + enter_number: 請輸入數字 + enter_url: 請輸入網址 + local: 當前視窗開啟 + new_banner: 新增橫幅 + new_window: 新視窗開啟 + ste: 轉換間隔時間 + number_seconds: 請輸入秒數 + number_milliseconds: 請輸入毫秒數 + best_size: 最佳尺寸 + effect: 效果 + all: 全部 + categories: 類別 + add: 新增 + size: 大小 + setting: Settings + transition_interval: 轉換間隔 + transition_speed: 轉換速度 + type: 開啟方式 + expired: 已下架 + video: 影片 + new_image: 新增圖片 或 影片 + youtube: youtube網址嵌入 + type: 圖片 或 影片 + choose_type: 請先選擇類型 + select: 請選擇 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..edb5ca5 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,14 @@ +Rails.application.routes.draw do + +get 'ad_banners/widget' + +locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales + + scope "(:locale)", locale: Regexp.new(locales.join("|")) do + namespace :admin do + resources :ad_banners + resources :ad_images + end + end + +end diff --git a/lib/ad_banner.rb b/lib/ad_banner.rb new file mode 100644 index 0000000..1629af0 --- /dev/null +++ b/lib/ad_banner.rb @@ -0,0 +1,4 @@ +require "ad_banner/engine" + +module AdBanner +end diff --git a/lib/ad_banner/engine.rb b/lib/ad_banner/engine.rb new file mode 100644 index 0000000..6f9b098 --- /dev/null +++ b/lib/ad_banner/engine.rb @@ -0,0 +1,28 @@ +module AdBanner + class Engine < ::Rails::Engine + initializer "ad_banner" do + OrbitApp.registration "AdBanner", :type => "ModuleApp" do + module_label "ad_banner.ad_banner" + base_url File.expand_path File.dirname(__FILE__) + widget_methods ["widget"] + widget_settings [{"override_category_with"=>"banner","multiselect"=>false,"display_field"=>"title"}] + taggable "Banner" + categorizable + authorizable + + side_bar do + head_label_i18n 'ad_banner.ad_banner', icon_class: "icons-landscape" + available_for "users" + active_for_controllers (['admin/ad_banners','admin/ad_images']) + head_link_path "admin_ad_banners_path" + + context_link 'ad_banner.all', + :link_path=>"admin_ad_banners_path" , + :priority=>1, + :active_for_action=>{'admin/ad_banners'=>"index"}, + :available_for => 'users' + end + end + end + end +end diff --git a/lib/ad_banner/version.rb b/lib/ad_banner/version.rb new file mode 100644 index 0000000..c610fcf --- /dev/null +++ b/lib/ad_banner/version.rb @@ -0,0 +1,3 @@ +module AdBanner + VERSION = "0.0.1" +end diff --git a/lib/tasks/ad_banner_tasks.rake b/lib/tasks/ad_banner_tasks.rake new file mode 100644 index 0000000..ad4405f --- /dev/null +++ b/lib/tasks/ad_banner_tasks.rake @@ -0,0 +1,4 @@ +# desc "Explaining what the task does" +# task :ad_banner do +# # Task goes here +# end diff --git a/test/ad_banner_test.rb b/test/ad_banner_test.rb new file mode 100644 index 0000000..0339192 --- /dev/null +++ b/test/ad_banner_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class AdBannerTest < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, AdBanner + end +end diff --git a/test/controllers/ad_banners_controller_test.rb b/test/controllers/ad_banners_controller_test.rb new file mode 100644 index 0000000..1acfc75 --- /dev/null +++ b/test/controllers/ad_banners_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class AdBannersControllerTest < ActionController::TestCase + test "should get widget" do + get :widget + assert_response :success + end + +end diff --git a/test/controllers/admin/ad_banners_controller_test.rb b/test/controllers/admin/ad_banners_controller_test.rb new file mode 100644 index 0000000..5ef05ee --- /dev/null +++ b/test/controllers/admin/ad_banners_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class Admin::AdBannersControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + +end diff --git a/test/controllers/admin/ad_images_controller_test.rb b/test/controllers/admin/ad_images_controller_test.rb new file mode 100644 index 0000000..7ee0cc7 --- /dev/null +++ b/test/controllers/admin/ad_images_controller_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class Admin::AdImagesControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + + test "should get new" do + get :new + assert_response :success + end + + test "should get create" do + get :create + assert_response :success + end + +end diff --git a/test/dummy/README.rdoc b/test/dummy/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/test/dummy/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile new file mode 100644 index 0000000..ba6b733 --- /dev/null +++ b/test/dummy/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/test/dummy/app/assets/images/.keep b/test/dummy/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js new file mode 100644 index 0000000..5bc2e1c --- /dev/null +++ b/test/dummy/app/assets/javascripts/application.js @@ -0,0 +1,13 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/test/dummy/app/assets/stylesheets/application.css b/test/dummy/app/assets/stylesheets/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/test/dummy/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/test/dummy/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/test/dummy/app/controllers/concerns/.keep b/test/dummy/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/test/dummy/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test/dummy/app/mailers/.keep b/test/dummy/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/models/.keep b/test/dummy/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/models/concerns/.keep b/test/dummy/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb new file mode 100644 index 0000000..593a778 --- /dev/null +++ b/test/dummy/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Dummy + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test/dummy/bin/bundle b/test/dummy/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/test/dummy/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails new file mode 100755 index 0000000..728cd85 --- /dev/null +++ b/test/dummy/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/test/dummy/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test/dummy/config.ru b/test/dummy/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/test/dummy/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb new file mode 100644 index 0000000..42833cd --- /dev/null +++ b/test/dummy/config/application.rb @@ -0,0 +1,29 @@ +require File.expand_path('../boot', __FILE__) + +# Pick the frameworks you want: +# require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "sprockets/railtie" +require "rails/test_unit/railtie" + +Bundler.require(*Rails.groups) +require "ad_banner" + +module Dummy + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end + diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb new file mode 100644 index 0000000..6266cfc --- /dev/null +++ b/test/dummy/config/boot.rb @@ -0,0 +1,5 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb new file mode 100644 index 0000000..ee8d90d --- /dev/null +++ b/test/dummy/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb new file mode 100644 index 0000000..a384d95 --- /dev/null +++ b/test/dummy/config/environments/development.rb @@ -0,0 +1,34 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb new file mode 100644 index 0000000..4f67ce3 --- /dev/null +++ b/test/dummy/config/environments/production.rb @@ -0,0 +1,80 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # Version of your assets, change this if you want to expire all your assets. + config.assets.version = '1.0' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. + # config.assets.precompile += %w( search.js ) + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new +end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb new file mode 100644 index 0000000..053f5b6 --- /dev/null +++ b/test/dummy/config/environments/test.rb @@ -0,0 +1,39 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/dummy/config/initializers/backtrace_silencers.rb b/test/dummy/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/test/dummy/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test/dummy/config/initializers/cookies_serializer.rb b/test/dummy/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7a06a89 --- /dev/null +++ b/test/dummy/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/test/dummy/config/initializers/inflections.rb b/test/dummy/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/test/dummy/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/test/dummy/config/initializers/mime_types.rb b/test/dummy/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/test/dummy/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/test/dummy/config/initializers/session_store.rb b/test/dummy/config/initializers/session_store.rb new file mode 100644 index 0000000..e766b67 --- /dev/null +++ b/test/dummy/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_dummy_session' diff --git a/test/dummy/config/initializers/wrap_parameters.rb b/test/dummy/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..b81ea74 --- /dev/null +++ b/test/dummy/config/initializers/wrap_parameters.rb @@ -0,0 +1,9 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end diff --git a/test/dummy/config/locales/en.yml b/test/dummy/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/test/dummy/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb new file mode 100644 index 0000000..3f66539 --- /dev/null +++ b/test/dummy/config/routes.rb @@ -0,0 +1,56 @@ +Rails.application.routes.draw do + # The priority is based upon order of creation: first created -> highest priority. + # See how all your routes lay out with "rake routes". + + # You can have the root of your site routed with "root" + # root 'welcome#index' + + # Example of regular route: + # get 'products/:id' => 'catalog#view' + + # Example of named route that can be invoked with purchase_url(id: product.id) + # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase + + # Example resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Example resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Example resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Example resource route with more complex sub-resources: + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', on: :collection + # end + # end + + # Example resource route with concerns: + # concern :toggleable do + # post 'toggle' + # end + # resources :posts, concerns: :toggleable + # resources :photos, concerns: :toggleable + + # Example resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end +end diff --git a/test/dummy/config/secrets.yml b/test/dummy/config/secrets.yml new file mode 100644 index 0000000..1674bae --- /dev/null +++ b/test/dummy/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: da32ed1abd0044ae97c6bc18b67b5e554c9c979970b02f1fa2d9353c61a23152e56466b35630d44c29b32fbe775341f6307aafb9a5758a92eef1e737bcde42f0 + +test: + secret_key_base: 939dbbde912d62e38c32f29a4d1603ed7ca30583cfd73aea8da11bdd812b49dced94b30e7dc1cb89844fb90bbf501db092a52b9dc896343d0c058d7d0b9f822c + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/test/dummy/lib/assets/.keep b/test/dummy/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/log/.keep b/test/dummy/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/public/404.html b/test/dummy/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/test/dummy/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test/dummy/public/422.html b/test/dummy/public/422.html new file mode 100644 index 0000000..a21f82b --- /dev/null +++ b/test/dummy/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test/dummy/public/500.html b/test/dummy/public/500.html new file mode 100644 index 0000000..061abc5 --- /dev/null +++ b/test/dummy/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test/dummy/public/favicon.ico b/test/dummy/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/ad_images.yml b/test/fixtures/ad_images.yml new file mode 100644 index 0000000..490f8f7 --- /dev/null +++ b/test/fixtures/ad_images.yml @@ -0,0 +1,15 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + context: MyString + weight: 1 + out_link: MyString + link_open: MyString + +two: + title: MyString + context: MyString + weight: 1 + out_link: MyString + link_open: MyString diff --git a/test/fixtures/banners.yml b/test/fixtures/banners.yml new file mode 100644 index 0000000..9de01cd --- /dev/null +++ b/test/fixtures/banners.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + ad_fx: MyString + height: 1 + speed: 1 + title: MyString + timeout: 1 + width: 1 + +two: + ad_fx: MyString + height: 1 + speed: 1 + title: MyString + timeout: 1 + width: 1 diff --git a/test/helpers/ad_banners_helper_test.rb b/test/helpers/ad_banners_helper_test.rb new file mode 100644 index 0000000..3015e47 --- /dev/null +++ b/test/helpers/ad_banners_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class AdBannersHelperTest < ActionView::TestCase +end diff --git a/test/helpers/admin/ad_banners_helper_test.rb b/test/helpers/admin/ad_banners_helper_test.rb new file mode 100644 index 0000000..1e41b76 --- /dev/null +++ b/test/helpers/admin/ad_banners_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Admin::AdBannersHelperTest < ActionView::TestCase +end diff --git a/test/helpers/admin/ad_images_helper_test.rb b/test/helpers/admin/ad_images_helper_test.rb new file mode 100644 index 0000000..aaf4604 --- /dev/null +++ b/test/helpers/admin/ad_images_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Admin::AdImagesHelperTest < ActionView::TestCase +end diff --git a/test/integration/navigation_test.rb b/test/integration/navigation_test.rb new file mode 100644 index 0000000..eec8c0e --- /dev/null +++ b/test/integration/navigation_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class NavigationTest < ActionDispatch::IntegrationTest + + # test "the truth" do + # assert true + # end +end + diff --git a/test/models/ad_image_test.rb b/test/models/ad_image_test.rb new file mode 100644 index 0000000..11a35c4 --- /dev/null +++ b/test/models/ad_image_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class AdImageTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/banner_test.rb b/test/models/banner_test.rb new file mode 100644 index 0000000..df0805a --- /dev/null +++ b/test/models/banner_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class BannerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..1e26a31 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,15 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require File.expand_path("../dummy/config/environment.rb", __FILE__) +require "rails/test_help" + +Rails.backtrace_cleaner.remove_silencers! + +# Load support files +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } + +# Load fixtures from the engine +if ActiveSupport::TestCase.method_defined?(:fixture_path=) + ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__) +end