commit 05508cafb88c5a45b7ef67eac7e650d53834e92c Author: Harry Bomrah Date: Wed Aug 2 17:07:55 2017 +0800 first commit for template store diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..de5d954 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.bundle/ +log/*.log +pkg/ +test/dummy/db/*.sqlite3 +test/dummy/db/*.sqlite3-journal +test/dummy/log/*.log +test/dummy/tmp/ +test/dummy/.sass-cache diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..698836d --- /dev/null +++ b/Gemfile @@ -0,0 +1,15 @@ +source 'https://rubygems.org' + +# Declare your gem's dependencies in ruling_template.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 a debugger +# gem 'byebug', group: [:development, :test] + diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..d33f7d5 --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2017 Harry Bomrah + +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..f337915 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += RulingTemplate + +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..933a343 --- /dev/null +++ b/Rakefile @@ -0,0 +1,37 @@ +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 = 'RulingTemplate' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +load 'rails/tasks/engine.rake' + + +load 'rails/tasks/statistics.rake' + + + +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/app/assets/images/ruling_template/.keep b/app/assets/images/ruling_template/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/images/ruling_template/colorpicker/Thumbs.db b/app/assets/images/ruling_template/colorpicker/Thumbs.db new file mode 100755 index 0000000..d396c36 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/Thumbs.db differ diff --git a/app/assets/images/ruling_template/colorpicker/blank.gif b/app/assets/images/ruling_template/colorpicker/blank.gif new file mode 100755 index 0000000..75b945d Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/blank.gif differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_background.png b/app/assets/images/ruling_template/colorpicker/colorpicker_background.png new file mode 100755 index 0000000..8401572 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_background.png differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_hex.png b/app/assets/images/ruling_template/colorpicker/colorpicker_hex.png new file mode 100755 index 0000000..4e532d7 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_hex.png differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_hsb_b.png b/app/assets/images/ruling_template/colorpicker/colorpicker_hsb_b.png new file mode 100755 index 0000000..dfac595 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_hsb_b.png differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_hsb_h.png b/app/assets/images/ruling_template/colorpicker/colorpicker_hsb_h.png new file mode 100755 index 0000000..3977ed9 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_hsb_h.png differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_hsb_s.png b/app/assets/images/ruling_template/colorpicker/colorpicker_hsb_s.png new file mode 100755 index 0000000..a2a6997 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_hsb_s.png differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_indic.gif b/app/assets/images/ruling_template/colorpicker/colorpicker_indic.gif new file mode 100755 index 0000000..f9fa95e Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_indic.gif differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_overlay.png b/app/assets/images/ruling_template/colorpicker/colorpicker_overlay.png new file mode 100755 index 0000000..561cdd9 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_overlay.png differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_rgb_b.png b/app/assets/images/ruling_template/colorpicker/colorpicker_rgb_b.png new file mode 100755 index 0000000..dfac595 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_rgb_b.png differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_rgb_g.png b/app/assets/images/ruling_template/colorpicker/colorpicker_rgb_g.png new file mode 100755 index 0000000..72b3276 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_rgb_g.png differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_rgb_r.png b/app/assets/images/ruling_template/colorpicker/colorpicker_rgb_r.png new file mode 100755 index 0000000..4855fe0 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_rgb_r.png differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_select.gif b/app/assets/images/ruling_template/colorpicker/colorpicker_select.gif new file mode 100755 index 0000000..599f7f1 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_select.gif differ diff --git a/app/assets/images/ruling_template/colorpicker/colorpicker_submit.png b/app/assets/images/ruling_template/colorpicker/colorpicker_submit.png new file mode 100755 index 0000000..7f4c082 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/colorpicker_submit.png differ diff --git a/app/assets/images/ruling_template/colorpicker/custom_background.png b/app/assets/images/ruling_template/colorpicker/custom_background.png new file mode 100755 index 0000000..cf55ffd Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/custom_background.png differ diff --git a/app/assets/images/ruling_template/colorpicker/custom_hex.png b/app/assets/images/ruling_template/colorpicker/custom_hex.png new file mode 100755 index 0000000..888f444 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/custom_hex.png differ diff --git a/app/assets/images/ruling_template/colorpicker/custom_hsb_b.png b/app/assets/images/ruling_template/colorpicker/custom_hsb_b.png new file mode 100755 index 0000000..2f99dae Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/custom_hsb_b.png differ diff --git a/app/assets/images/ruling_template/colorpicker/custom_hsb_h.png b/app/assets/images/ruling_template/colorpicker/custom_hsb_h.png new file mode 100755 index 0000000..a217e92 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/custom_hsb_h.png differ diff --git a/app/assets/images/ruling_template/colorpicker/custom_hsb_s.png b/app/assets/images/ruling_template/colorpicker/custom_hsb_s.png new file mode 100755 index 0000000..7826b41 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/custom_hsb_s.png differ diff --git a/app/assets/images/ruling_template/colorpicker/custom_indic.gif b/app/assets/images/ruling_template/colorpicker/custom_indic.gif new file mode 100755 index 0000000..222fb94 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/custom_indic.gif differ diff --git a/app/assets/images/ruling_template/colorpicker/custom_rgb_b.png b/app/assets/images/ruling_template/colorpicker/custom_rgb_b.png new file mode 100755 index 0000000..80764e5 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/custom_rgb_b.png differ diff --git a/app/assets/images/ruling_template/colorpicker/custom_rgb_g.png b/app/assets/images/ruling_template/colorpicker/custom_rgb_g.png new file mode 100755 index 0000000..fc9778b Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/custom_rgb_g.png differ diff --git a/app/assets/images/ruling_template/colorpicker/custom_rgb_r.png b/app/assets/images/ruling_template/colorpicker/custom_rgb_r.png new file mode 100755 index 0000000..91b0cd4 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/custom_rgb_r.png differ diff --git a/app/assets/images/ruling_template/colorpicker/custom_submit.png b/app/assets/images/ruling_template/colorpicker/custom_submit.png new file mode 100755 index 0000000..cd202cd Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/custom_submit.png differ diff --git a/app/assets/images/ruling_template/colorpicker/select.png b/app/assets/images/ruling_template/colorpicker/select.png new file mode 100755 index 0000000..21213bf Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/select.png differ diff --git a/app/assets/images/ruling_template/colorpicker/select2.png b/app/assets/images/ruling_template/colorpicker/select2.png new file mode 100755 index 0000000..2cd2cab Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/select2.png differ diff --git a/app/assets/images/ruling_template/colorpicker/slider.png b/app/assets/images/ruling_template/colorpicker/slider.png new file mode 100755 index 0000000..8b03da9 Binary files /dev/null and b/app/assets/images/ruling_template/colorpicker/slider.png differ diff --git a/app/assets/images/ruling_template/npa.png b/app/assets/images/ruling_template/npa.png new file mode 100644 index 0000000..58b8f77 Binary files /dev/null and b/app/assets/images/ruling_template/npa.png differ diff --git a/app/assets/javascripts/ruling_template/application.js b/app/assets/javascripts/ruling_template/application.js new file mode 100644 index 0000000..8913b40 --- /dev/null +++ b/app/assets/javascripts/ruling_template/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 any plugin's vendor/assets/javascripts directory 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/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/app/assets/javascripts/ruling_template/colorpicker.js b/app/assets/javascripts/ruling_template/colorpicker.js new file mode 100755 index 0000000..10a2b22 --- /dev/null +++ b/app/assets/javascripts/ruling_template/colorpicker.js @@ -0,0 +1,484 @@ +/** + * + * Color picker + * Author: Stefan Petre www.eyecon.ro + * + * Dual licensed under the MIT and GPL licenses + * + */ +(function ($) { + var ColorPicker = function () { + var + ids = {}, + inAction, + charMin = 65, + visible, + tpl = '
', + defaults = { + eventName: 'click', + onShow: function () {}, + onBeforeShow: function(){}, + onHide: function () {}, + onChange: function () {}, + onSubmit: function () {}, + color: 'ff0000', + livePreview: true, + flat: false + }, + fillRGBFields = function (hsb, cal) { + var rgb = HSBToRGB(hsb); + $(cal).data('colorpicker').fields + .eq(1).val(rgb.r).end() + .eq(2).val(rgb.g).end() + .eq(3).val(rgb.b).end(); + }, + fillHSBFields = function (hsb, cal) { + $(cal).data('colorpicker').fields + .eq(4).val(hsb.h).end() + .eq(5).val(hsb.s).end() + .eq(6).val(hsb.b).end(); + }, + fillHexFields = function (hsb, cal) { + $(cal).data('colorpicker').fields + .eq(0).val(HSBToHex(hsb)).end(); + }, + setSelector = function (hsb, cal) { + $(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100})); + $(cal).data('colorpicker').selectorIndic.css({ + left: parseInt(150 * hsb.s/100, 10), + top: parseInt(150 * (100-hsb.b)/100, 10) + }); + }, + setHue = function (hsb, cal) { + $(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h/360, 10)); + }, + setCurrentColor = function (hsb, cal) { + $(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb)); + }, + setNewColor = function (hsb, cal) { + $(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb)); + }, + keyDown = function (ev) { + var pressedKey = ev.charCode || ev.keyCode || -1; + if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) { + return false; + } + var cal = $(this).parent().parent(); + if (cal.data('colorpicker').livePreview === true) { + change.apply(this); + } + }, + change = function (ev) { + var cal = $(this).parent().parent(), col; + if (this.parentNode.className.indexOf('_hex') > 0) { + cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value)); + } else if (this.parentNode.className.indexOf('_hsb') > 0) { + cal.data('colorpicker').color = col = fixHSB({ + h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10), + s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10), + b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10) + }); + } else { + cal.data('colorpicker').color = col = RGBToHSB(fixRGB({ + r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10), + g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10), + b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10) + })); + } + if (ev) { + fillRGBFields(col, cal.get(0)); + fillHexFields(col, cal.get(0)); + fillHSBFields(col, cal.get(0)); + } + setSelector(col, cal.get(0)); + setHue(col, cal.get(0)); + setNewColor(col, cal.get(0)); + cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]); + }, + blur = function (ev) { + var cal = $(this).parent().parent(); + cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus'); + }, + focus = function () { + charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65; + $(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus'); + $(this).parent().addClass('colorpicker_focus'); + }, + downIncrement = function (ev) { + var field = $(this).parent().find('input').focus(); + var current = { + el: $(this).parent().addClass('colorpicker_slider'), + max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255), + y: ev.pageY, + field: field, + val: parseInt(field.val(), 10), + preview: $(this).parent().parent().data('colorpicker').livePreview + }; + $(document).bind('mouseup', current, upIncrement); + $(document).bind('mousemove', current, moveIncrement); + }, + moveIncrement = function (ev) { + ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10)))); + if (ev.data.preview) { + change.apply(ev.data.field.get(0), [true]); + } + return false; + }, + upIncrement = function (ev) { + change.apply(ev.data.field.get(0), [true]); + ev.data.el.removeClass('colorpicker_slider').find('input').focus(); + $(document).unbind('mouseup', upIncrement); + $(document).unbind('mousemove', moveIncrement); + return false; + }, + downHue = function (ev) { + var current = { + cal: $(this).parent(), + y: $(this).offset().top + }; + current.preview = current.cal.data('colorpicker').livePreview; + $(document).bind('mouseup', current, upHue); + $(document).bind('mousemove', current, moveHue); + }, + moveHue = function (ev) { + change.apply( + ev.data.cal.data('colorpicker') + .fields + .eq(4) + .val(parseInt(360*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.y))))/150, 10)) + .get(0), + [ev.data.preview] + ); + return false; + }, + upHue = function (ev) { + fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0)); + fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0)); + $(document).unbind('mouseup', upHue); + $(document).unbind('mousemove', moveHue); + return false; + }, + downSelector = function (ev) { + var current = { + cal: $(this).parent(), + pos: $(this).offset() + }; + current.preview = current.cal.data('colorpicker').livePreview; + $(document).bind('mouseup', current, upSelector); + $(document).bind('mousemove', current, moveSelector); + }, + moveSelector = function (ev) { + change.apply( + ev.data.cal.data('colorpicker') + .fields + .eq(6) + .val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.pos.top))))/150, 10)) + .end() + .eq(5) + .val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - ev.data.pos.left))))/150, 10)) + .get(0), + [ev.data.preview] + ); + return false; + }, + upSelector = function (ev) { + fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0)); + fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0)); + $(document).unbind('mouseup', upSelector); + $(document).unbind('mousemove', moveSelector); + return false; + }, + enterSubmit = function (ev) { + $(this).addClass('colorpicker_focus'); + }, + leaveSubmit = function (ev) { + $(this).removeClass('colorpicker_focus'); + }, + clickSubmit = function (ev) { + var cal = $(this).parent(); + var col = cal.data('colorpicker').color; + cal.data('colorpicker').origColor = col; + setCurrentColor(col, cal.get(0)); + cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col), cal.data('colorpicker').el); + }, + show = function (ev) { + var cal = $('#' + $(this).data('colorpickerId')); + cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]); + var pos = $(this).offset(); + var viewPort = getViewport(); + var top = pos.top + this.offsetHeight; + var left = pos.left; + if (top + 176 > viewPort.t + viewPort.h) { + top -= this.offsetHeight + 176; + } + if (left + 356 > viewPort.l + viewPort.w) { + left -= 356; + } + cal.css({left: left + 'px', top: top + 'px'}); + if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) { + cal.show(); + } + $(document).bind('mousedown', {cal: cal}, hide); + return false; + }, + hide = function (ev) { + if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) { + if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) { + ev.data.cal.hide(); + } + $(document).unbind('mousedown', hide); + } + }, + isChildOf = function(parentEl, el, container) { + if (parentEl == el) { + return true; + } + if (parentEl.contains) { + return parentEl.contains(el); + } + if ( parentEl.compareDocumentPosition ) { + return !!(parentEl.compareDocumentPosition(el) & 16); + } + var prEl = el.parentNode; + while(prEl && prEl != container) { + if (prEl == parentEl) + return true; + prEl = prEl.parentNode; + } + return false; + }, + getViewport = function () { + var m = document.compatMode == 'CSS1Compat'; + return { + l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft), + t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop), + w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth), + h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight) + }; + }, + fixHSB = function (hsb) { + return { + h: Math.min(360, Math.max(0, hsb.h)), + s: Math.min(100, Math.max(0, hsb.s)), + b: Math.min(100, Math.max(0, hsb.b)) + }; + }, + fixRGB = function (rgb) { + return { + r: Math.min(255, Math.max(0, rgb.r)), + g: Math.min(255, Math.max(0, rgb.g)), + b: Math.min(255, Math.max(0, rgb.b)) + }; + }, + fixHex = function (hex) { + var len = 6 - hex.length; + if (len > 0) { + var o = []; + for (var i=0; i -1) ? hex.substring(1) : hex), 16); + return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)}; + }, + HexToHSB = function (hex) { + return RGBToHSB(HexToRGB(hex)); + }, + RGBToHSB = function (rgb) { + var hsb = { + h: 0, + s: 0, + b: 0 + }; + var min = Math.min(rgb.r, rgb.g, rgb.b); + var max = Math.max(rgb.r, rgb.g, rgb.b); + var delta = max - min; + hsb.b = max; + if (max != 0) { + + } + hsb.s = max != 0 ? 255 * delta / max : 0; + if (hsb.s != 0) { + if (rgb.r == max) { + hsb.h = (rgb.g - rgb.b) / delta; + } else if (rgb.g == max) { + hsb.h = 2 + (rgb.b - rgb.r) / delta; + } else { + hsb.h = 4 + (rgb.r - rgb.g) / delta; + } + } else { + hsb.h = -1; + } + hsb.h *= 60; + if (hsb.h < 0) { + hsb.h += 360; + } + hsb.s *= 100/255; + hsb.b *= 100/255; + return hsb; + }, + HSBToRGB = function (hsb) { + var rgb = {}; + var h = Math.round(hsb.h); + var s = Math.round(hsb.s*255/100); + var v = Math.round(hsb.b*255/100); + if(s == 0) { + rgb.r = rgb.g = rgb.b = v; + } else { + var t1 = v; + var t2 = (255-s)*v/255; + var t3 = (t1-t2)*(h%60)/60; + if(h==360) h = 0; + if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3} + else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3} + else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3} + else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3} + else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3} + else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3} + else {rgb.r=0; rgb.g=0; rgb.b=0} + } + return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)}; + }, + RGBToHex = function (rgb) { + var hex = [ + rgb.r.toString(16), + rgb.g.toString(16), + rgb.b.toString(16) + ]; + $.each(hex, function (nr, val) { + if (val.length == 1) { + hex[nr] = '0' + val; + } + }); + return hex.join(''); + }, + HSBToHex = function (hsb) { + return RGBToHex(HSBToRGB(hsb)); + }, + restoreOriginal = function () { + var cal = $(this).parent(); + var col = cal.data('colorpicker').origColor; + cal.data('colorpicker').color = col; + fillRGBFields(col, cal.get(0)); + fillHexFields(col, cal.get(0)); + fillHSBFields(col, cal.get(0)); + setSelector(col, cal.get(0)); + setHue(col, cal.get(0)); + setNewColor(col, cal.get(0)); + }; + return { + init: function (opt) { + opt = $.extend({}, defaults, opt||{}); + if (typeof opt.color == 'string') { + opt.color = HexToHSB(opt.color); + } else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) { + opt.color = RGBToHSB(opt.color); + } else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) { + opt.color = fixHSB(opt.color); + } else { + return this; + } + return this.each(function () { + if (!$(this).data('colorpickerId')) { + var options = $.extend({}, opt); + options.origColor = opt.color; + var id = 'collorpicker_' + parseInt(Math.random() * 1000); + $(this).data('colorpickerId', id); + var cal = $(tpl).attr('id', id); + if (options.flat) { + cal.appendTo(this).show(); + } else { + cal.appendTo(document.body); + } + options.fields = cal + .find('input') + .bind('keyup', keyDown) + .bind('change', change) + .bind('blur', blur) + .bind('focus', focus); + cal + .find('span').bind('mousedown', downIncrement).end() + .find('>div.colorpicker_current_color').bind('click', restoreOriginal); + options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector); + options.selectorIndic = options.selector.find('div div'); + options.el = this; + options.hue = cal.find('div.colorpicker_hue div'); + cal.find('div.colorpicker_hue').bind('mousedown', downHue); + options.newColor = cal.find('div.colorpicker_new_color'); + options.currentColor = cal.find('div.colorpicker_current_color'); + cal.data('colorpicker', options); + cal.find('div.colorpicker_submit') + .bind('mouseenter', enterSubmit) + .bind('mouseleave', leaveSubmit) + .bind('click', clickSubmit); + fillRGBFields(options.color, cal.get(0)); + fillHSBFields(options.color, cal.get(0)); + fillHexFields(options.color, cal.get(0)); + setHue(options.color, cal.get(0)); + setSelector(options.color, cal.get(0)); + setCurrentColor(options.color, cal.get(0)); + setNewColor(options.color, cal.get(0)); + if (options.flat) { + cal.css({ + position: 'relative', + display: 'block' + }); + } else { + $(this).bind(options.eventName, show); + } + } + }); + }, + showPicker: function() { + return this.each( function () { + if ($(this).data('colorpickerId')) { + show.apply(this); + } + }); + }, + hidePicker: function() { + return this.each( function () { + if ($(this).data('colorpickerId')) { + $('#' + $(this).data('colorpickerId')).hide(); + } + }); + }, + setColor: function(col) { + if (typeof col == 'string') { + col = HexToHSB(col); + } else if (col.r != undefined && col.g != undefined && col.b != undefined) { + col = RGBToHSB(col); + } else if (col.h != undefined && col.s != undefined && col.b != undefined) { + col = fixHSB(col); + } else { + return this; + } + return this.each(function(){ + if ($(this).data('colorpickerId')) { + var cal = $('#' + $(this).data('colorpickerId')); + cal.data('colorpicker').color = col; + cal.data('colorpicker').origColor = col; + fillRGBFields(col, cal.get(0)); + fillHSBFields(col, cal.get(0)); + fillHexFields(col, cal.get(0)); + setHue(col, cal.get(0)); + setSelector(col, cal.get(0)); + setCurrentColor(col, cal.get(0)); + setNewColor(col, cal.get(0)); + } + }); + } + }; + }(); + $.fn.extend({ + ColorPicker: ColorPicker.init, + ColorPickerHide: ColorPicker.hidePicker, + ColorPickerShow: ColorPicker.showPicker, + ColorPickerSetColor: ColorPicker.setColor + }); +})(jQuery) \ No newline at end of file diff --git a/app/assets/stylesheets/ruling_template/application.css b/app/assets/stylesheets/ruling_template/application.css new file mode 100644 index 0000000..f9cd5b3 --- /dev/null +++ b/app/assets/stylesheets/ruling_template/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 any plugin's vendor/assets/stylesheets directory 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/app/assets/stylesheets/ruling_template/colorpicker.css b/app/assets/stylesheets/ruling_template/colorpicker.css new file mode 100755 index 0000000..11f0843 --- /dev/null +++ b/app/assets/stylesheets/ruling_template/colorpicker.css @@ -0,0 +1,161 @@ +.colorpicker { + width: 356px; + height: 176px; + overflow: hidden; + position: absolute; + background: url(/assets/ruling_template/colorpicker/colorpicker_background.png); + font-family: Arial, Helvetica, sans-serif; + display: none; +} +.colorpicker_color { + width: 150px; + height: 150px; + left: 14px; + top: 13px; + position: absolute; + background: #f00; + overflow: hidden; + cursor: crosshair; +} +.colorpicker_color div { + position: absolute; + top: 0; + left: 0; + width: 150px; + height: 150px; + background: url(/assets/ruling_template/colorpicker/colorpicker_overlay.png); +} +.colorpicker_color div div { + position: absolute; + top: 0; + left: 0; + width: 11px; + height: 11px; + overflow: hidden; + background: url(/assets/ruling_template/colorpicker/colorpicker_select.gif); + margin: -5px 0 0 -5px; +} +.colorpicker_hue { + position: absolute; + top: 13px; + left: 171px; + width: 35px; + height: 150px; + cursor: n-resize; +} +.colorpicker_hue div { + position: absolute; + width: 35px; + height: 9px; + overflow: hidden; + background: url(/assets/ruling_template/colorpicker/colorpicker_indic.gif) left top; + margin: -4px 0 0 0; + left: 0px; +} +.colorpicker_new_color { + position: absolute; + width: 60px; + height: 30px; + left: 213px; + top: 13px; + background: #f00; +} +.colorpicker_current_color { + position: absolute; + width: 60px; + height: 30px; + left: 283px; + top: 13px; + background: #f00; +} +.colorpicker input { + background-color: transparent; + border: 1px solid transparent; + position: absolute; + font-size: 10px; + font-family: Arial, Helvetica, sans-serif; + color: #898989; + top: 4px; + right: 11px; + text-align: right; + margin: 0; + padding: 0; + height: 11px; +} +.colorpicker_hex { + position: absolute; + width: 72px; + height: 22px; + background: url(/assets/ruling_template/colorpicker/colorpicker_hex.png) top; + left: 212px; + top: 142px; +} +.colorpicker_hex input { + right: 6px; +} +.colorpicker_field { + height: 22px; + width: 62px; + background-position: top; + position: absolute; +} +.colorpicker_field span { + position: absolute; + width: 12px; + height: 22px; + overflow: hidden; + top: 0; + right: 0; + cursor: n-resize; +} +.colorpicker_rgb_r { + background-image: url(/assets/ruling_template/colorpicker/colorpicker_rgb_r.png); + top: 52px; + left: 212px; +} +.colorpicker_rgb_g { + background-image: url(/assets/ruling_template/colorpicker/colorpicker_rgb_g.png); + top: 82px; + left: 212px; +} +.colorpicker_rgb_b { + background-image: url(/assets/ruling_template/colorpicker/colorpicker_rgb_b.png); + top: 112px; + left: 212px; +} +.colorpicker_hsb_h { + background-image: url(/assets/ruling_template/colorpicker/colorpicker_hsb_h.png); + top: 52px; + left: 282px; +} +.colorpicker_hsb_s { + background-image: url(/assets/ruling_template/colorpicker/colorpicker_hsb_s.png); + top: 82px; + left: 282px; +} +.colorpicker_hsb_b { + background-image: url(/assets/ruling_template/colorpicker/colorpicker_hsb_b.png); + top: 112px; + left: 282px; +} +.colorpicker_submit { + position: absolute; + width: 22px; + height: 22px; + background: url(/assets/ruling_template/colorpicker/colorpicker_submit.png) top; + left: 322px; + top: 142px; + overflow: hidden; +} +.colorpicker_focus { + background-position: center; +} +.colorpicker_hex.colorpicker_focus { + background-position: bottom; +} +.colorpicker_submit.colorpicker_focus { + background-position: bottom; +} +.colorpicker_slider { + background-position: bottom; +} diff --git a/app/assets/stylesheets/ruling_template/template.scss b/app/assets/stylesheets/ruling_template/template.scss new file mode 100644 index 0000000..2b122f4 --- /dev/null +++ b/app/assets/stylesheets/ruling_template/template.scss @@ -0,0 +1,286 @@ +ul#template-holder { + list-style: none; + li.template { + display: inline-block; + margin: 15px 5px; + width: 250px; + max-height: 400px; + background-color: #cecece; + + img { + padding: 10px; + width: 230px; + } + + div.template-title{ + font-size: 20px; + text-align: center; + background-color: rgba(0,0,0, 0.5); + padding: 5px; + + a{ + color: #fff; + text-decoration: none; + } + + &:hover{ + background-color: rgba(100,100,100,0.5); + a{ + color: #000; + } + } + + } + } +} + +.customWidget { + top: 0; + left: 0; + width: 36px; + height: 36px; + background: url(/assets/ruling_template/colorpicker/select2.png); + display: inline-block; + margin-right: 10px; + div.color-holder { + position: relative; + top: 4px; + left: 4px; + width: 28px; + height: 28px; + background: url(/assets/ruling_template/colorpicker/select2.png) center; + } +} +.colorpicker input { + color: #0000ff; + width: 50px; +} + +#fileupload { + position: relative; + clear: both; + overflow: hidden; + margin: 10px 0 15px; + height: 254px; + border: 1px solid #d4d4d4; + border-radius: 4px; + background-color: #FDFDFD; + /*-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, .15) inset; + box-shadow: 0px 0px 10px rgba(0, 0, 0, .15) inset;*/ + table { + margin: 0; + } + .fileupload-buttonbar { + .navbar { + margin-bottom: 0; + .add-photo { + border: none; + border-right: 1px solid #d4d4d4; + background-color: transparent; + padding: 10px 15px 10px; + color: #777777; + text-decoration: none; + text-shadow: 0 1px 0 #ffffff; + &:hover { + color: #333333; + text-decoration: none; + background-color: #EDEDED; + } + } + .fileinput-button { + position: relative; + overflow: hidden; + input { + position: absolute; + top: 0; + right: 0; + margin: 0; + font-size: 23px; + opacity: 0; + -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; + filter: alpha(opacity=0); + cursor: pointer; + -webkit-transform: translate(-300px, 0) scale(4); + -moz-transform: translate(-300px, 0) scale(4); + -ms-transform: translate(-300px, 0) scale(4); + -o-transform: translate(-300px, 0) scale(4); + transform: translate(-300px, 0) scale(4); + direction: ltr; + } + } + } + .navbar-inner { + border-width: 0 0 1px; + border-radius: 4px 4px 0 0; + padding: 0; + } + } + + + .fileupload-progress{ + position: relative; + z-index: 3; + .progress { + position: absolute; + right: 0; + left: 0; + margin-bottom: 0; + height: 5px; + border-radius: 0; + background-color: transparent; + background-image: none; + } + .progress-success.progress-striped{ + .bar { + background-color: #0088CC; + } + } + .progress-extended { + position: absolute; + top: 1px; + right: 0; + padding-right: 15px; + color: #0088CC; + text-align: right; + text-shadow: 0 1px 0 #ffffff; + letter-spacing: -0.1em; + font-size: 12px; + font-family: 'Varela Round', sans-serif; + line-height: 40px; + } + } + + #dropzone { + margin: 15px 10px 10px; + padding: 30px; + text-align: center; + font-size: 2em; + font-family: 'Raleway'; + line-height: 1.2em; + color: #e4e4e4; + div[data-icons] { + font-size: 4em; + height: 70px; + padding-top: 30px; + text-shadow: 0px -1px 0px #ececec; + color: #f5f5f5; + } + &.drop{ + position: absolute; + top: 37px; + left: 0; + right: 0; + bottom: 0; + border: 2px dashed #0088CC; + border-radius: 10px; + color: #0088CC; + background-color: #FFFFFF; + z-index: 0; + div[data-icons] { + text-shadow: 0px -1px 0px #0c5f80; + color: #0088CC; + } + } + &.fade{ + opacity: .3; + } + &.in { + opacity: .7; + z-index: 2; + border-color: #faa732; + color: #faa732; + div[data-icons] { + text-shadow: 0px -1px 0px #a28a10; + color: #faa732; + } + } + } + + #file-list { + position: relative; + z-index: 1; + height: 209px; + margin: 2px 0; + .pane { + margin-right: 2px; + } + .files { + margin: 0; + padding: 10px 14px 10px 10px; + list-style: none; + } + .files > li { + padding: 10px; + } + .files > li:nth-child(even) { + background-color: #e9e9e9; + border-radius: 3px; + } + .files ul { + position: relative; + margin: 0; + padding: 0; + list-style: none; + li { + float: left; + } + li.action-bnt { + float: right; + } + } + .preview { + width: 80px; + min-height: 1px; + margin-right: 10px; + text-align: center; + } + .name { + width: 150px; + max-width: 250px; + margin-left: 15px; + } + .progress { + position: absolute; + left: -5px; + right: -5px; + bottom: -5px; + margin-bottom: 0; + height: 5px; + box-shadow: none; + background-color: transparent; + background-image: none; + } + .size { + width: 80px; + } + .action-bnt { + text-align: right; + } + } +} + +.preview-image-area{ + border: 1px dashed #cecece; + border-radius: 10px; + width: auto; + min-height: 250px; + padding: 15px; + cursor: move; + .uploaded-image{ + display: inline-block; + margin-right: 10px; + max-width: 200px; + margin-bottom: 10px; + text-align: center; + img{ + width: 200px; + } + a{ + margin-top: 5px; + } + } +} + +#psdfileupload{ + margin: 0 0; +} diff --git a/app/controllers/admin/ruling_templates_controller.rb b/app/controllers/admin/ruling_templates_controller.rb new file mode 100644 index 0000000..0300b6c --- /dev/null +++ b/app/controllers/admin/ruling_templates_controller.rb @@ -0,0 +1,97 @@ +class Admin::RulingTemplatesController < OrbitAdminController + + def index + @templates = RTemplate.all.desc(:created_at).page(params[:page]).per(10) + end + + def new + @template = RTemplate.new + end + + def edit + @template = RTemplate.find(params[:id]) + end + + def create + template = RTemplate.new(template_params) + template.save + redirect_to upload_files_admin_ruling_template_path(template.id) + end + + def update + template = RTemplate.find(params[:id]) + template.update_attributes(template_params) + template.save + redirect_to upload_files_admin_ruling_template_path(template.id) + end + + def show + @template = RTemplate.find(params[:id]) + render :layout => false + end + + def upload_files + @template = RTemplate.find(params[:id]) + end + + def upload_image + template = RTemplate.find(params[:id]) + image = TemplateImageFile.new(template_image_params) + image.order = (template.template_image_files.max(:order) + 1 rescue 0) + image.r_template = template + image.save + render :json => {"files" => [{"thumbnail_url"=>image.image_file.thumb.url}]}.to_json + end + + def change_image_order + image_ids = params[:images] + image_ids.each_with_index do |img, idx| + image = TemplateImageFile.find(img) + image.order = idx + image.save + end + render :json => {"success" => true}.to_json + end + + def delete_image + image = TemplateImageFile.find(params[:id]) + image.destroy + render :json => {"success" => true}.to_json + end + + def upload_temp_file + filepath = params[:path] + file = params[:psdfile] + File.open(filepath,"ab"){ |f| f.write(file.read) } + render :json => {"success" => true}.to_json + end + + def get_temp_dir_name + dirname = Digest::MD5.hexdigest(Time.now.to_s) + directory = "public/ruling_template/#{dirname}" + FileUtils.mkdir_p(directory) unless File.exists?(directory) + path_to_file = "#{directory}/#{params[:filename]}" + File.open(path_to_file,"w") + template = RTemplate.find(params[:id]) + if !template.template_psd_file.nil? && !template.template_psd_file.psd_zip.url.nil? + template.template_psd_file.destroy + end + psd = TemplatePsdFile.new + psd.psd_zip = Rails.root.join(path_to_file).open + psd.r_template = template + psd.save + FileUtils.remove_dir(directory) + render :json => {"psd_id" => psd.id.to_s, "path" => psd.psd_zip.path}.to_json + end + + private + + def template_params + params.require(:r_template).permit! + end + + def template_image_params + params.require(:template_image_file).permit! + end + +end \ No newline at end of file diff --git a/app/controllers/ruling_templates_controller.rb b/app/controllers/ruling_templates_controller.rb new file mode 100644 index 0000000..d4b1774 --- /dev/null +++ b/app/controllers/ruling_templates_controller.rb @@ -0,0 +1,4 @@ +class RulingTemplatesController < ApplicationController + def index + end +end \ No newline at end of file diff --git a/app/helpers/ruling_template/application_helper.rb b/app/helpers/ruling_template/application_helper.rb new file mode 100644 index 0000000..0c048b0 --- /dev/null +++ b/app/helpers/ruling_template/application_helper.rb @@ -0,0 +1,4 @@ +module RulingTemplate + module ApplicationHelper + end +end diff --git a/app/models/r_template.rb b/app/models/r_template.rb new file mode 100644 index 0000000..dc7d340 --- /dev/null +++ b/app/models/r_template.rb @@ -0,0 +1,27 @@ +class RTemplate + include Mongoid::Document + include Mongoid::Timestamps + include OrbitModel::Status + include OrbitTag::Taggable + include OrbitCategory::Categorizable + include Slug + + + field :title, as: :slug_title, :localize => true + field :description, :localize => true + field :price, :type => Integer + field :allowed, :type => Boolean, :default => true + field :user_id + field :colors, :type => Array, :default => [] + field :sold, :type => Boolean, :default => false + + + mount_uploader :template_zip, AssetUploader + + has_many :template_image_files, :autosave => true, :dependent => :destroy + has_one :template_psd_file, :autosave => true, :dependent => :destroy + + accepts_nested_attributes_for :template_image_files, :allow_destroy => true + accepts_nested_attributes_for :template_psd_file, :allow_destroy => true + +end \ No newline at end of file diff --git a/app/models/template_image_file.rb b/app/models/template_image_file.rb new file mode 100644 index 0000000..72257e8 --- /dev/null +++ b/app/models/template_image_file.rb @@ -0,0 +1,10 @@ +class TemplateImageFile + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :image_file, GalleryUploader + + field :order, :type => Integer, :default => 0 + + belongs_to :r_template +end \ No newline at end of file diff --git a/app/models/template_psd_file.rb b/app/models/template_psd_file.rb new file mode 100644 index 0000000..ecd1b28 --- /dev/null +++ b/app/models/template_psd_file.rb @@ -0,0 +1,8 @@ +class TemplatePsdFile + include Mongoid::Document + include Mongoid::Timestamps + + mount_uploader :psd_zip, AssetUploader + + belongs_to :r_template +end \ No newline at end of file diff --git a/app/views/admin/ruling_templates/_form.html.erb b/app/views/admin/ruling_templates/_form.html.erb new file mode 100644 index 0000000..f722ceb --- /dev/null +++ b/app/views/admin/ruling_templates/_form.html.erb @@ -0,0 +1,190 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%#= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> + <%= stylesheet_link_tag "ruling_template/template" %> + <%= stylesheet_link_tag "ruling_template/colorpicker" %> +<% 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/file-type" %> + <%= javascript_include_tag "lib/module-area" %> + <%= javascript_include_tag "ruling_template/colorpicker" %> +<% end %> + +
+ + + + + +
+ +
+
+ +
+ <%= select_category(f, @module_app) %> +
+
+
+ <%= f.label :price, t("ruling_template.price"), :class => "control-label muted" %> +
+ <%= f.number_field :price, :min => 0, :step => 1000 %> +
+
+
+ <%= f.label :colors, t("ruling_template.colors"), :class => "control-label muted" %> + +
+
+ <% if !@template.new_record? && !@template.colors.empty? %> + <% @template.colors.each do |color| %> +
+
+ +
+ <% end %> + <% end %> +
+
+
+
+ +
+
+ +
+ + + +
+
+
+ +
+
+ + <%= select_tags(f, @module_app) %> +
+ +
+
+ + + + +
+ <% @site_in_use_locales.each_with_index do |locale, i| %> +
"> + +
+ +
+ <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@template.title_translations[locale] rescue nil) %> + <% end %> +
+
+ +
+ +
+
+ <%= f.fields_for :description_translations do |f| %> + <%= f.text_area locale, rows: 5, class: "input-block-level", value: (@template.description_translations[locale] rescue nil) %> + <% end %> +
+
+
+
+ <% end %> +
+
+ + +
+ <%= f.hidden_field :user_id, :value => current_user.id.to_s %> + <%= f.submit t('ruling_template.upload_files'), class: 'btn btn-primary' %> + <%= t("cancel") %> +
+ \ No newline at end of file diff --git a/app/views/admin/ruling_templates/_template.html.erb b/app/views/admin/ruling_templates/_template.html.erb new file mode 100644 index 0000000..5d132d3 --- /dev/null +++ b/app/views/admin/ruling_templates/_template.html.erb @@ -0,0 +1,12 @@ +
  • + + <% if template.template_image_files.empty? %> + + <% else %> + + <% end %> + + +
  • \ No newline at end of file diff --git a/app/views/admin/ruling_templates/edit.html.erb b/app/views/admin/ruling_templates/edit.html.erb new file mode 100644 index 0000000..27750f9 --- /dev/null +++ b/app/views/admin/ruling_templates/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @template, url: admin_ruling_template_path(@template.id), html: {class: "form-horizontal main-forms", :id => "template-form"} do |f| %> +
    + <%= render :partial => 'form', locals: {f: f} %> +
    +<% end %> \ No newline at end of file diff --git a/app/views/admin/ruling_templates/index.html.erb b/app/views/admin/ruling_templates/index.html.erb new file mode 100644 index 0000000..88b495b --- /dev/null +++ b/app/views/admin/ruling_templates/index.html.erb @@ -0,0 +1,39 @@ +<%= csrf_meta_tags %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "ruling_template/template" %> +<% end %> + + + + \ No newline at end of file diff --git a/app/views/admin/ruling_templates/new.html.erb b/app/views/admin/ruling_templates/new.html.erb new file mode 100644 index 0000000..b968f98 --- /dev/null +++ b/app/views/admin/ruling_templates/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @template, url: admin_ruling_templates_path, html: {class: "form-horizontal main-forms", :id => "template-form"} do |f| %> +
    + <%= render :partial => 'form', locals: {f: f} %> +
    +<% end %> \ No newline at end of file diff --git a/app/views/admin/ruling_templates/show.html.erb b/app/views/admin/ruling_templates/show.html.erb new file mode 100644 index 0000000..225731d --- /dev/null +++ b/app/views/admin/ruling_templates/show.html.erb @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Template Number<%= @template.uid %>
    Created On<%= @template.created_at.strftime("%Y-%m-%d") %>
    Author<%= User.find(@template.user_id).name rescue "Deleted User" %>
    Category<%= @template.category.title rescue "" %>
    Description<%= @template.description %>
    Price<%= @template.price %> NTD.
    Published + <% if @template.allowed %> + Published + <% else %> + Not Published + <% end %> +
    Sold + <% if @template.sold %> + Sold + <% else %> + Not Sold + <% end %> +
    Colors +
      + <% @template.colors.each do |color| %> +
    • + <% end %> +
    +
    Colors +
      + <% @template.tags.each do |tag| %> +
    • <%= tag.name %>
    • + <% end %> +
    +
    Preview + <% if @template.template_image_files.empty? %> + No preview available. + <% else %> +
      + <% @template.template_image_files.each do |image| %> +
    • + <% end %> +
    + <% end %> +
    PSD + <% if @template.template_psd_file.nil? %> + No PSD available. + <% else %> + Download PSD + <% end %> +
    Template Zip + <% if @template.template_zip.nil? || @template.template_zip.url.nil? %> + No template available. + <% else %> + Download Template + <% end %> +
    \ No newline at end of file diff --git a/app/views/admin/ruling_templates/upload_files.html.erb b/app/views/admin/ruling_templates/upload_files.html.erb new file mode 100644 index 0000000..17dc3e1 --- /dev/null +++ b/app/views/admin/ruling_templates/upload_files.html.erb @@ -0,0 +1,369 @@ +<%= csrf_meta_tags %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "ruling_template/template" %> + +<% end %> +
    +

    <%= @template.title %>

    + <% if !@template.template_image_files.empty? %> + +
      + <% @template.template_image_files.asc(:order).each do |image| %> +
    • + + Delete +
    • + <% end %> +
    + <% end %> +
    + +
    + + +
    + + +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    + Drop files here +
    + +
    + +
    +
    + +
    +
    +
    +
    + +
    + <% if !@template.template_psd_file.nil? && !@template.template_psd_file.psd_zip.url.nil? %> + Click here to download PSD + <% end %> + +
    + + + Select PSD File + + + + + + +
    +
    +
    +
    +
    +
    +
    + +
    + <% if !@template.template_zip.url.nil? %> + Click here to download Template + <% end %> + + <%= form_for @template, url: admin_ruling_template_path(@template.id) do |f| %> + + + Select Template File + <%= f.file_field :template_zip %> + + + <% end %> +
    +
    + Edit Template + Templates +
    +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/jquery-ui-sortable.min" %> + <%= javascript_include_tag "file-upload/vendor/jquery.ui.widget.js" %> + <%= javascript_include_tag "file-upload/tmpl.min.js" %> + <%= javascript_include_tag "file-upload/load-image.min.js" %> + <%= javascript_include_tag "file-upload/canvas-to-blob.min.js" %> + <%= javascript_include_tag "file-upload/jquery.iframe-transport.js" %> + <%= javascript_include_tag "file-upload/jquery.fileupload.js" %> + <%= javascript_include_tag "file-upload/jquery.fileupload-fp.js" %> + <%= javascript_include_tag "file-upload/jquery.fileupload-ui.js" %> + <%= javascript_include_tag "file-upload/drop-zone.js" %> + +<% end %> + + + + + \ No newline at end of file diff --git a/app/views/ruling_templates/index.html.erb b/app/views/ruling_templates/index.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000..86833a8 --- /dev/null +++ b/bin/rails @@ -0,0 +1,12 @@ +#!/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/ruling_template/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 'rails/all' +require 'rails/engine/commands' diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..835411c --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,9 @@ +en: + ruling_template: + ruling_template: Templates + all: All + new: New Template + price: Price + upload_files: Upload Files + colors: Colors + add_color: Add Color \ 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..b248714 --- /dev/null +++ b/config/locales/zh_tw.yml @@ -0,0 +1,9 @@ +zh_tw: + ruling_template: + ruling_template: Templates + all: All + new: New Template + price: Price + upload_files: Upload Files + colors: Colors + add_color: Add Color \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..cb6f67d --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,22 @@ +Rails.application.routes.draw do + + locales = Site.first.in_use_locales rescue I18n.available_locales + + scope "(:locale)", locale: Regexp.new(locales.join("|")) do + namespace :admin do + resources :ruling_templates do + member do + get "upload_files" + post "upload_image" + get "get_temp_dir_name" + delete "delete_image" + end + collection do + post "change_image_order" + post "upload_temp_file" + end + end + end + end + +end diff --git a/lib/ruling_template.rb b/lib/ruling_template.rb new file mode 100644 index 0000000..9b89497 --- /dev/null +++ b/lib/ruling_template.rb @@ -0,0 +1,4 @@ +require "ruling_template/engine" + +module RulingTemplate +end diff --git a/lib/ruling_template/engine.rb b/lib/ruling_template/engine.rb new file mode 100644 index 0000000..d39c651 --- /dev/null +++ b/lib/ruling_template/engine.rb @@ -0,0 +1,34 @@ +module RulingTemplate + class Engine < ::Rails::Engine + initializer "ruling_template" do + OrbitApp.registration "ruling_template", :type => "ModuleApp" do + module_label "ruling_template.ruling_template" + base_url File.expand_path File.dirname(__FILE__) + categorizable + authorizable + frontend_enabled + # data_count 1..30 + # set_keyword_contstraints ["/cpanel/"] + side_bar do + head_label_i18n 'ruling_template.ruling_template', icon_class: "icons-palette" + available_for "users" + active_for_controllers (['admin/ruling_templates']) + head_link_path "admin_ruling_templates_path" + + context_link 'ruling_template.all', + :link_path=>"admin_ruling_templates_path" , + :priority=>1, + :active_for_action=>{'admin/ruling_templates'=>"index"}, + :available_for => 'users' + + context_link 'ruling_template.new', + :link_path=>"new_admin_ruling_template_path" , + :priority=>1, + :active_for_action=>{'admin/ruling_templates'=>"new"}, + :available_for => 'users' + + end + end + end + end +end diff --git a/lib/ruling_template/version.rb b/lib/ruling_template/version.rb new file mode 100644 index 0000000..d3ce725 --- /dev/null +++ b/lib/ruling_template/version.rb @@ -0,0 +1,3 @@ +module RulingTemplate + VERSION = "0.0.1" +end diff --git a/lib/tasks/ruling_template_tasks.rake b/lib/tasks/ruling_template_tasks.rake new file mode 100644 index 0000000..7980724 --- /dev/null +++ b/lib/tasks/ruling_template_tasks.rake @@ -0,0 +1,4 @@ +# desc "Explaining what the task does" +# task :ruling_template do +# # Task goes here +# end diff --git a/ruling_template.gemspec b/ruling_template.gemspec new file mode 100644 index 0000000..817b989 --- /dev/null +++ b/ruling_template.gemspec @@ -0,0 +1,20 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "ruling_template/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "ruling_template" + s.version = RulingTemplate::VERSION + s.authors = ["Harry Bomrah"] + s.email = ["harry@rulingcom.com"] + s.homepage = "http://www.rulingcom.com" + s.summary = "Module for Templates" + s.description = "Module for Templates" + s.license = "MIT" + + s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] + s.test_files = Dir["test/**/*"] + +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..8913b40 --- /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 any plugin's vendor/assets/javascripts directory 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/rails/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..f9cd5b3 --- /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 any plugin's vendor/assets/stylesheets directory 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..5191e69 --- /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/bin/setup b/test/dummy/bin/setup new file mode 100755 index 0000000..acdb2c1 --- /dev/null +++ b/test/dummy/bin/setup @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +Dir.chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file: + + puts "== Installing dependencies ==" + system "gem install bundler --conservative" + system "bundle check || bundle install" + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # system "cp config/database.yml.sample config/database.yml" + # end + + puts "\n== Preparing database ==" + system "bin/rake db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system "rm -f log/*" + system "rm -rf tmp/cache" + + puts "\n== Restarting application server ==" + system "touch tmp/restart.txt" +end diff --git a/test/dummy/config.ru b/test/dummy/config.ru new file mode 100644 index 0000000..bd83b25 --- /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..21690aa --- /dev/null +++ b/test/dummy/config/application.rb @@ -0,0 +1,26 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +Bundler.require(*Rails.groups) +require "ruling_template" + +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 + + # Do not swallow errors in after_commit/after_rollback callbacks. + config.active_record.raise_in_transactional_callbacks = true + 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/database.yml b/test/dummy/config/database.yml new file mode 100644 index 0000000..1c1a37c --- /dev/null +++ b/test/dummy/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 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..b55e214 --- /dev/null +++ b/test/dummy/config/environments/development.rb @@ -0,0 +1,41 @@ +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 + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # 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 + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = 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..5c1b32e --- /dev/null +++ b/test/dummy/config/environments/production.rb @@ -0,0 +1,79 @@ +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 serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # 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 + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # 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 + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # 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' + + # 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 + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb new file mode 100644 index 0000000..1c19f08 --- /dev/null +++ b/test/dummy/config/environments/test.rb @@ -0,0 +1,42 @@ +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 file server for tests with Cache-Control for performance. + config.serve_static_files = 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 + + # Randomize the order test cases are executed. + config.active_support.test_order = :random + + # 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/assets.rb b/test/dummy/config/initializers/assets.rb new file mode 100644 index 0000000..01ef3e6 --- /dev/null +++ b/test/dummy/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) 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..7f70458 --- /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 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/to_time_preserves_timezone.rb b/test/dummy/config/initializers/to_time_preserves_timezone.rb new file mode 100644 index 0000000..8674be3 --- /dev/null +++ b/test/dummy/config/initializers/to_time_preserves_timezone.rb @@ -0,0 +1,10 @@ +# Be sure to restart your server when you modify this file. + +# Preserve the timezone of the receiver when calling to `to_time`. +# Ruby 2.4 will change the behavior of `to_time` to preserve the timezone +# when converting to an instance of `Time` instead of the previous behavior +# of converting to the local system timezone. +# +# Rails 5.0 introduced this config option so that apps made with earlier +# versions of Rails are not affected when upgrading. +ActiveSupport.to_time_preserves_timezone = true diff --git a/test/dummy/config/initializers/wrap_parameters.rb b/test/dummy/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/test/dummy/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# 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 + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# 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..9f86626 --- /dev/null +++ b/test/dummy/config/routes.rb @@ -0,0 +1,4 @@ +Rails.application.routes.draw do + + mount RulingTemplate::Engine => "/ruling_template" +end diff --git a/test/dummy/config/secrets.yml b/test/dummy/config/secrets.yml new file mode 100644 index 0000000..cb03ec7 --- /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: f229dd4974549a2d096402bd823f542d6e54df0f015422f7d7b954cb10e65c0256cff830c0972a9e736c007f69b4a0e972812f3a04bff16852ebd31e8089c27b + +test: + secret_key_base: 4fc4affd84263342fb1abb9eabbdab71ed9a5ca805f67c671e31b28f626e5a4aa808b169e6cac7ad02638ee862458836caeb0972694a912ddc66497affeb2638 + +# 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/integration/navigation_test.rb b/test/integration/navigation_test.rb new file mode 100644 index 0000000..f5d1ec2 --- /dev/null +++ b/test/integration/navigation_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class NavigationTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end + diff --git a/test/ruling_template_test.rb b/test/ruling_template_test.rb new file mode 100644 index 0000000..b34d52f --- /dev/null +++ b/test/ruling_template_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class RulingTemplateTest < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, RulingTemplate + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..763f88f --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,21 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require File.expand_path("../../test/dummy/config/environment.rb", __FILE__) +ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)] +ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__) +require "rails/test_help" + +# Filter out Minitest backtrace while allowing backtrace from other libraries +# to be shown. +Minitest.backtrace_filter = Minitest::BacktraceFilter.new + +# Load support files +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } + +# Load fixtures from the engine +if ActiveSupport::TestCase.respond_to?(:fixture_path=) + ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__) + ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path + ActiveSupport::TestCase.fixtures :all +end