first commit for template store

This commit is contained in:
Harry Bomrah 2017-08-02 17:07:55 +08:00
commit 05508cafb8
107 changed files with 2780 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@ -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

15
Gemfile Normal file
View File

@ -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]

20
MIT-LICENSE Normal file
View File

@ -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.

3
README.rdoc Normal file
View File

@ -0,0 +1,3 @@
= RulingTemplate
This project rocks and uses MIT-LICENSE.

37
Rakefile Normal file
View File

@ -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

View File

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@ -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 .

View File

@ -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 = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
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<len; i++) {
o.push('0');
}
o.push(hex);
hex = o.join('');
}
return hex;
},
HexToRGB = function (hex) {
var hex = parseInt(((hex.indexOf('#') > -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)

View File

@ -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
*/

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -0,0 +1,4 @@
class RulingTemplatesController < ApplicationController
def index
end
end

View File

@ -0,0 +1,4 @@
module RulingTemplate
module ApplicationHelper
end
end

27
app/models/r_template.rb Normal file
View File

@ -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

View File

@ -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

View File

@ -0,0 +1,8 @@
class TemplatePsdFile
include Mongoid::Document
include Mongoid::Timestamps
mount_uploader :psd_zip, AssetUploader
belongs_to :r_template
end

View File

@ -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 %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
<li><a href="#status" data-toggle="tab"><%= t(:status) %></a></li>
<li><a href="#tag" data-toggle="tab"><%= t(:tags) %></a></li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= select_category(f, @module_app) %>
</div>
</div>
<div class="control-group">
<%= f.label :price, t("ruling_template.price"), :class => "control-label muted" %>
<div class="controls">
<%= f.number_field :price, :min => 0, :step => 1000 %>
</div>
</div>
<div class="control-group">
<%= f.label :colors, t("ruling_template.colors"), :class => "control-label muted" %>
<div class="controls">
<a href="" id="add-color" class="btn btn-info"><%= t("ruling_template.add_color") %></a>
</div>
<div class="controls">
<div id="color-box-area">
<% if !@template.new_record? && !@template.colors.empty? %>
<% @template.colors.each do |color| %>
<div class='customWidget'>
<div class='color-holder' style='background-color: #<%= color %>'></div>
<input type='hidden' value='<%= color %>' name='r_template[colors][]'>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
</div>
<!-- Status -->
<div class="tab-pane fade" id="status">
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @template.is_top? %>">
<%= f.check_box :is_top %> <%= t(:top) %>
</label>
<label class="checkbox inline btn <%= 'active' if @template.is_hot? %>">
<%= f.check_box :is_hot %> <%= t(:hot) %>
</label>
<label class="checkbox inline btn <%= 'active' if @template.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
<!-- Tag -->
<div class="tab-pane fade" id="tag">
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<%= select_tags(f, @module_app) %>
</div>
</div>
</div>
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:title) %></label>
<div class="controls">
<%= 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 %>
</div>
</div>
<!-- Description -->
<div class="control-group input-subtitle">
<label class="control-label muted"><%= t(:description) %></label>
<div class="controls">
<div class="textarea">
<%= 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 %>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.hidden_field :user_id, :value => current_user.id.to_s %>
<%= f.submit t('ruling_template.upload_files'), class: 'btn btn-primary' %>
<a href="" onclick="window.history.back();return false;" class="btn" ><%= t("cancel") %></a>
</div>
<script type="text/javascript">
$("form#template-form").on("submit",function(){
if($("input[name='r_template[tags][]']:checked").length == 0){
alert("Please select at least one tag.");
return false;
}
})
$("#add-color").on("click",function(){
var input = $("<div class='customWidget'><div class='color-holder' style='background-color: #0000ff'></div><input type='hidden' value='0000ff' name='r_template[colors][]'></div>");
$("#color-box-area").append(input);
input.ColorPicker({
color: '#0000ff',
onShow: function (colpkr) {
$(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
$(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
input.find("div.color-holder").css('background-color', '#' + hex);
input.find("input").val(hex);
},
onSubmit: function(hsb, hex, rgb){
input.find("div.color-holder").css('background-color', '#' + hex);
input.find("input").val(hex);
}
});
return false;
})
<% if !@template.new_record? && !@template.colors.empty? %>
$(".customWidget").each(function(){
var el = $(this);
el.ColorPicker({
color: "#" + el.find("input").val(),
onShow: function (colpkr) {
$(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
$(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
el.find("div.color-holder").css('background-color', '#' + hex);
el.find("input").val(hex);
},
onSubmit: function(hsb, hex, rgb){
el.find("div.color-holder").css('background-color', '#' + hex);
el.find("input").val(hex);
}
})
})
<% end %>
</script>

View File

@ -0,0 +1,12 @@
<li class="template">
<a data-title="<%= template.title %>" class="template-display-btn" href="<%= admin_ruling_template_path(template.id) %>">
<% if template.template_image_files.empty? %>
<img src="/assets/ruling_template/npa.png" />
<% else %>
<img src="<%= template.template_image_files.first.image_file.url %>" />
<% end %>
</a>
<div class="template-title">
<a data-title="<%= template.title %>" class="template-display-btn" href="<%= admin_ruling_template_path(template.id) %>"><%= template.title %></a>
</div>
</li>

View File

@ -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| %>
<fieldset>
<%= render :partial => 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,39 @@
<%= csrf_meta_tags %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "ruling_template/template" %>
<% end %>
<ul id="template-holder">
<%= render :partial => "template", :collection => @templates %>
</ul>
<div id="templateDisplay" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="templateTitle">Modal header</h3>
</div>
<div class="modal-body" id="template-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<a id="edit-button" class="btn btn-primary" href="">Edit</a>
<a data-method="delete" data-confirm="Are you sure?" id="delete-button" class="btn btn-danger" href="">Delete</a>
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
<script type="text/javascript">
$(".template-display-btn").on("click",function(){
var el = $(this);
$.ajax({
url : el.attr("href"),
type : "get",
dataType : "html"
}).done(function(html){
$("#templateTitle").text(el.data("title"));
$("#template-body").html(html);
$("#edit-button").attr("href", el.attr("href") + "/edit");
$("#delete-button").attr("href", el.attr("href"));
$("#templateDisplay").modal("show");
})
return false;
})
</script>

View File

@ -0,0 +1,5 @@
<%= form_for @template, url: admin_ruling_templates_path, html: {class: "form-horizontal main-forms", :id => "template-form"} do |f| %>
<fieldset>
<%= render :partial => 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,144 @@
<style type="text/css">
.color-bar {
margin: 0px;
padding: 0px;
}
.color-bar .color{
display: inline-block;
width: 30px;
height: 10px;
margin: 0px;
padding: 0px;
}
.tag-bar {
margin: 0px;
padding: 0px;
}
.tag-bar .tag{
display: inline-block;
}
.template-info{
width: 100%;
font-size: 15px;
line-height: 25px;
}
.template-info th{
width: 30%;
text-align: left;
}
.template-info tr {
padding : 10px 0;
}
.template-preview{
margin-left: 0;
margin-top: 5px;
}
.template-preview li{
display: inline-block;
}
.template-preview img{
width: 100px;
}
</style>
<table class="template-info">
<tbody>
<tr>
<th>Template Number</th>
<td><%= @template.uid %></td>
</tr>
<tr>
<th>Created On</th>
<td><%= @template.created_at.strftime("%Y-%m-%d") %></td>
</tr>
<tr>
<th>Author</th>
<td><%= User.find(@template.user_id).name rescue "Deleted User" %></td>
</tr>
<tr>
<th>Category</th>
<td><%= @template.category.title rescue "" %></td>
</tr>
<tr>
<th>Description</th>
<td><%= @template.description %></td>
</tr>
<tr>
<th>Price</th>
<td><%= @template.price %> NTD.</td>
</tr>
<tr>
<th>Published</th>
<td>
<% if @template.allowed %>
<span class="label label-success">Published</span>
<% else %>
<span class="label label-important">Not Published</span>
<% end %>
</td>
</tr>
<tr>
<th>Sold</th>
<td>
<% if @template.sold %>
<span class="label label-warning">Sold</span>
<% else %>
<span class="label label-info">Not Sold</span>
<% end %>
</td>
</tr>
<tr>
<th>Colors</th>
<td>
<ul class="color-bar clearfix">
<% @template.colors.each do |color| %>
<li class="color" style="background-color: #<%= color %>"></li>
<% end %>
</ul>
</td>
</tr>
<tr>
<th>Colors</th>
<td>
<ul class="tag-bar clearfix">
<% @template.tags.each do |tag| %>
<li class="tag"><span class="label label-default"><%= tag.name %></span></li>
<% end %>
</ul>
</td>
</tr>
<tr>
<th>Preview</th>
<td>
<% if @template.template_image_files.empty? %>
No preview available.
<% else %>
<ul class="template-preview">
<% @template.template_image_files.each do |image| %>
<li><a href="<%= image.image_file.url %>" target="_blank"><img src="<%= image.image_file.url %>" alt=""></a></li>
<% end %>
</ul>
<% end %>
</td>
</tr>
<tr>
<th>PSD</th>
<td>
<% if @template.template_psd_file.nil? %>
No PSD available.
<% else %>
<a href="<%= @template.template_psd_file.psd_zip.url %>">Download PSD</a>
<% end %>
</td>
</tr>
<tr>
<th>Template Zip</th>
<td>
<% if @template.template_zip.nil? || @template.template_zip.url.nil? %>
No template available.
<% else %>
<a href="<%= @template.template_zip.url %>">Download Template</a>
<% end %>
</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,369 @@
<%= csrf_meta_tags %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "ruling_template/template" %>
<style type="text/css">
.fileinput-button {
position: relative;
overflow: hidden;
display: inline-block;
}
.fileinput-button input {
position: absolute;
top: 0;
right: 0;
margin: 0;
opacity: 0;
-ms-filter: 'alpha(opacity=0)';
font-size: 200px !important;
direction: ltr;
cursor: pointer;
}
/* Fixes for IE < 8 */
@media screen\9 {
.fileinput-button input {
filter: alpha(opacity=0);
font-size: 100%;
height: 100%;
}
}
#progress {
margin-top: 10px;
height: 5px;
text-align: center;
margin-bottom: 5px;
}
.progress-text{
text-align: center;
font-size: 18px;
}
.area {
margin-bottom: 40px;
border-bottom: 1px solid #c8c8c8;
}
</style>
<% end %>
<div class="file-upload-area">
<h3><%= @template.title %></h3>
<% if !@template.template_image_files.empty? %>
<label class="control-label muted">Uploaded Images (Drag to change order)</label>
<ul class="preview-image-area">
<% @template.template_image_files.asc(:order).each do |image| %>
<li class="uploaded-image" data-id="<%= image.id.to_s %>">
<img src="<%= image.image_file.thumb.url %>" alt="">
<a href="<%= delete_image_admin_ruling_template_path(image.id) %>" class="preview-image-delete btn btn-small btn-danger">Delete</a>
</li>
<% end %>
</ul>
<% end %>
<div class="preview-upload-area area">
<label class="control-label muted">Preview Images</label>
<form action="<%= upload_image_admin_ruling_template_path(@template.id) %>" id="fileupload">
<!-- Redirect browsers with JavaScript disabled to the origin page -->
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="fileupload-buttonbar">
<div class="navbar">
<div class="navbar-inner">
<ul class="nav">
<li>
<div class="fileinput-button add-photo">
<i class="icon-plus icon-white"></i>
<span>Add files...</span>
<input type="file" name="template_image_file[image_file]" multiple>
</div>
</li>
<li>
<button type="submit" class="start add-photo">
<i class="icon-upload icon-white"></i>
<span>Start upload</span>
</button>
</li>
<li>
<button type="reset" class="cancel add-photo">
<i class="icon-ban-circle icon-white"></i>
<span>Cancel upload</span>
</button>
</li>
<!-- <li>
<button type="button" class="delete">
<i class="icons-trash icon-white"></i>
<span>Delete</span>
</button>
</li> -->
</ul>
</div>
</div>
<!-- The global progress information -->
<div class="fileupload-progress">
<!-- The global progress bar -->
<div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
<div class="bar" style="width:0%;"></div>
</div>
<!-- The extended global progress information -->
<div class="progress-extended"></div>
</div>
</div>
<!-- Drop Zone -->
<div id="dropzone" class="drop">
<div data-icons="&#xe0a3;"></div>
Drop files here
</div>
<!-- The loading indicator is shown during file processing -->
<div class="fileupload-loading"></div>
<!-- The table listing the files available for upload/download -->
<div id="file-list" class="nano">
<div class="content">
<ul role="presentation" class="files clearfix">
</ul>
</div>
</div>
</form>
</div>
<div class="zip-upload-area area">
<% if !@template.template_psd_file.nil? && !@template.template_psd_file.psd_zip.url.nil? %>
<a href="<%= @template.template_psd_file.psd_zip.url %>">Click here to download PSD</a>
<% end %>
<label class="control-label muted">Upload PSD</label>
<form id="psdfileupload" method="POST" enctype="multipart/form-data" action="<%= upload_temp_file_admin_ruling_templates_path %>">
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Select PSD File</span>
<!-- The file input field used as target for the file upload widget -->
<input type="file" name="psdfile" >
<input type="hidden" name="path" >
<input name="authenticity_token" value="<%= form_authenticity_token %>" type="hidden">
</span>
<input id="psd-upload-submit" type="submit" class="btn btn-primary" value="Upload" style="display: none;" />
</form>
<div class="psd-notification-area"></div>
<div id="progress" class="progress">
<div class="bar bar-success"></div>
</div>
<div class="progress-text"></div>
</div>
<div class="template-upload-area area">
<% if !@template.template_zip.url.nil? %>
<a href="<%= @template.template_zip.url %>">Click here to download Template</a>
<% end %>
<label class="control-label muted">Upload Template</label>
<%= form_for @template, url: admin_ruling_template_path(@template.id) do |f| %>
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Select Template File</span>
<%= f.file_field :template_zip %>
</span>
<input id="template-upload-submit" type="submit" class="btn btn-primary" value="Upload" style="display: none;" />
<% end %>
<div class="template-notification-area"></div>
</div>
<a href="<%= edit_admin_ruling_template_path(@template.id) %>" class="btn btn-info">Edit Template</a>
<a href="<%= admin_ruling_templates_path %>" class="btn btn-warning">Templates</a>
</div>
<% 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" %>
<script type="text/javascript">
!function ($) {
$.fn.checkListLength = function (param){
_defaultSettings = {
onlyOne: null,
};
_set = $.extend(_defaultSettings, param);
$this = this;
$li = this.children('li');
$dropzone = $('#dropzone');
if(($li.length - _set.onlyOne) == 0) {
$('#dropzone').fadeIn(300);
} else {
$('#dropzone').fadeOut(300);
};
$('#file-list').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
}
}(window.jQuery);
$(function () {
'use strict';
// Initialize the jQuery File Upload widget:
if($('#fileupload').length){
$('#fileupload').fileupload({
maxFileSize: 5000000,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
dropZone: $('#dropzone'),
headers:{
'X-CSRF-Token': $('meta[name="csrf-token"]').attr("content")
}
}).on('fileuploaddone', function (e, data) {
alert("Please refresh the page.");
});
}
var psdfilename = null,
psdFileForm = null;
$("#psdfileupload").fileupload({
maxChunkSize : 8 * 1024 * 1024,
acceptFileTypes: /(\.|\/)(zip)$/i,
add : function(e, data){
var file = data.originalFiles[0].name.split(".");
psdfilename = data.originalFiles[0].name;
psdFileForm = data;
if(file[file.length - 1] == "zip"){
$("div.psd-notification-area").removeClass("error").text("");
$("#psd-upload-submit").show();
}else{
$("div.psd-notification-area").addClass("error").text("Only zip file allowed.");
$("#psd-upload-submit").hide();
return false;
}
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .bar').css(
'width',
progress + '%'
);
if(progress < 100){
$('.progress-text').text("Uploading " + progress + "%");
}else{
$('.progress-text').text("Uploaded successfully.");
}
}
})
$("#psd-upload-submit").on("click",function(){
$.ajax({
url : "<%= get_temp_dir_name_admin_ruling_template_path(@template.id) %>",
dataType : "json",
type : "get",
data : {"filename" : psdfilename}
}).done(function(data){
$('.progress-text').show();
$("#psdfileupload input[type=hidden]").val(data.path);
psdFileForm.submit();
})
return false;
})
$("#r_template_template_zip").on("change",function(){
var file = this.files[0].name.split(".");
if(file[file.length - 1] == "zip"){
$("div.template-notification-area").removeClass("error").text("");
$("#template-upload-submit").show();
}else{
$("div.template-notification-area").addClass("error").text("Only zip file allowed.");
$("#template-upload-submit").hide();
return false;
}
})
});
</script>
<% end %>
<script type="text/javascript">
$(".preview-image-area").sortable({
update : function(event, ui){
var image_ids = [];
$(".preview-image-area li").each(function(){
image_ids.push($(this).data("id"));
})
$.ajax({
url : "<%= change_image_order_admin_ruling_templates_path %>",
data : {"images" : image_ids},
dataType : "json",
type : "post",
headers:{
'X-CSRF-Token' : $('meta[name="csrf-token"]').attr("content")
}
})
}
});
$(".preview-image-delete").on("click",function(){
var el = $(this);
if(confirm("Are you sure?")){
$.ajax({
url : el.attr("href"),
type : "delete",
dataType : "json",
headers:{
'X-CSRF-Token' : $('meta[name="csrf-token"]').attr("content")
}
}).done(function(){
el.parent().remove();
})
}
return false;
})
</script>
<!-- The template to display files available for upload -->
<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<li class="template-upload fade">
<ul class="clearfix">
<li class="action-bnt">
{% if (o.files.valid && !i) { %}
<div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
<div class="bar" style="width:0%;"></div>
</div>
{% if (!o.options.autoUpload) { %}
<button class="btn btn-primary start">
<i class="icon-upload icon-white"></i>
</button>
{% } %}
{% } %}
{% if (!i) { %}
<button class="btn btn-warning cancel">
<i class="icon-ban-circle icon-white"></i>
</button>
{% } %}
</li>
<li class="preview pull-left"><span class="fade"></span></li>
<li class="name-size">
<p>{%=file.name%}</p>
{% if (file.error) { %}
<p class="error"><span class="label label-important">Error</span> {%=file.error%}</p>
{% } else if (o.files.valid && !i) { %}
<p class="label label-info">{%=o.formatFileSize(file.size)%}</p>
{% } %}
</li>
</ul>
</li>
{% } %}
</script>
<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<li class="template-download fade">
<ul class="clearfix">
{% if (file.error) { %}
<li class="name-size">
<p>{%=file.name%}</p>
<p class="error"><span class="label label-important">Error</span> {%=file.error%}</p>
</li>
{% } else { %}
<li class="preview">
{% if (file.thumbnail_url) { %}
<a href="{%=file.url%}" title="{%=file.name%}" data-gallery="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
{% } %}
</li>
<li class="name-size">
<p><a href="{%=file.url%}" title="{%=file.name%}" data-gallery="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a></p>
<p ><span class="label label-success">Success</span> File uploaded successfully!</p>
<p class="label label-info">{%=o.formatFileSize(file.size)%}</p>
</li>
{% } %}
</ul>
</li>
{% } %}
</script>

12
bin/rails Executable file
View File

@ -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'

9
config/locales/en.yml Normal file
View File

@ -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

9
config/locales/zh_tw.yml Normal file
View File

@ -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

22
config/routes.rb Normal file
View File

@ -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

4
lib/ruling_template.rb Normal file
View File

@ -0,0 +1,4 @@
require "ruling_template/engine"
module RulingTemplate
end

View File

@ -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

View File

@ -0,0 +1,3 @@
module RulingTemplate
VERSION = "0.0.1"
end

View File

@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :ruling_template do
# # Task goes here
# end

20
ruling_template.gemspec Normal file
View File

@ -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

28
test/dummy/README.rdoc Normal file
View File

@ -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
<tt>rake doc:app</tt>.

6
test/dummy/Rakefile Normal file
View File

@ -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

View File

View File

@ -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 .

View File

@ -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
*/

View File

@ -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

View File

@ -0,0 +1,2 @@
module ApplicationHelper
end

View File

View File

View File

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>

3
test/dummy/bin/bundle Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

4
test/dummy/bin/rails Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

4
test/dummy/bin/rake Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run

29
test/dummy/bin/setup Executable file
View File

@ -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

4
test/dummy/config.ru Normal file
View File

@ -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

View File

@ -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

View File

@ -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__)

View File

@ -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

View File

@ -0,0 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 )

View File

@ -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!

View File

@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -0,0 +1,4 @@
Rails.application.routes.draw do
mount RulingTemplate::Engine => "/ruling_template"
end

View File

@ -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"] %>

View File

0
test/dummy/log/.keep Normal file
View File

Some files were not shown because too many files have changed in this diff Show More