loyal_core 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +3 -0
- data/Rakefile +27 -0
- data/app/assets/images/loyal_core/down_rating.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/loyal_core/skin/recipe/avatar/ico_missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/loyal_core/skin/recipe/avatar/medium_missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/loyal_core/skin/recipe/avatar/mini_missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/loyal_core/skin/recipe/avatar/missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/loyal_core/skin/recipe/avatar/small_missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/loyal_core/skin/recipe/avatar/thumb_missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/loyal_core/skin/recipe/avatar/tiny_missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/user/avatar/ico_missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/user/avatar/medium_missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/user/avatar/mini_missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/user/avatar/missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/user/avatar/small_missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/user/avatar/thumb_missing.gif +0 -0
- data/app/assets/images/loyal_core/fallbacks/user/avatar/tiny_missing.gif +0 -0
- data/app/assets/images/loyal_core/liked.gif +0 -0
- data/app/assets/images/loyal_core/unlike.gif +0 -0
- data/app/assets/images/loyal_core/up_rating.gif +0 -0
- data/app/assets/javascripts/jquery.cookie.js +95 -0
- data/app/assets/javascripts/loyal_core/admin/skin/folders.js +2 -0
- data/app/assets/javascripts/loyal_core/admin/skin/recipes.js +2 -0
- data/app/assets/javascripts/loyal_core/ajax/captchas.js +2 -0
- data/app/assets/javascripts/loyal_core/ajax/like_tracks.js +2 -0
- data/app/assets/javascripts/loyal_core/ajax/rating_tracks.js +3 -0
- data/app/assets/javascripts/loyal_core/ajax/users/sessions.js +2 -0
- data/app/assets/javascripts/loyal_core/ajax.js +124 -0
- data/app/assets/javascripts/loyal_core/application.js +6 -0
- data/app/assets/javascripts/loyal_core/jumps.js +2 -0
- data/app/assets/javascripts/loyal_core/tools/append_params_return_to.js +21 -0
- data/app/assets/javascripts/loyal_core/tools/editor_content_mode_selector.js +8 -0
- data/app/assets/javascripts/loyal_core/tools/font_selector.js +83 -0
- data/app/assets/stylesheets/loyal_core/admin/skin/folders.css +4 -0
- data/app/assets/stylesheets/loyal_core/admin/skin/recipes.css +4 -0
- data/app/assets/stylesheets/loyal_core/ajax/captchas.css +4 -0
- data/app/assets/stylesheets/loyal_core/ajax/like_tracks.css +4 -0
- data/app/assets/stylesheets/loyal_core/ajax/rating_tracks.css +4 -0
- data/app/assets/stylesheets/loyal_core/ajax/users/sessions.css +4 -0
- data/app/assets/stylesheets/loyal_core/application.css.scss +18 -0
- data/app/assets/stylesheets/loyal_core/jumps.css +4 -0
- data/app/controllers/loyal_core/admin/skin/folders_controller.rb +54 -0
- data/app/controllers/loyal_core/admin/skin/recipes_controller.rb +52 -0
- data/app/controllers/loyal_core/ajax/captchas_controller.rb +26 -0
- data/app/controllers/loyal_core/ajax/like_tracks_controller.rb +33 -0
- data/app/controllers/loyal_core/ajax/rating_tracks_controller.rb +41 -0
- data/app/controllers/loyal_core/ajax/users/sessions_controller.rb +8 -0
- data/app/controllers/loyal_core/ajax_controller.rb +14 -0
- data/app/controllers/loyal_core/application_controller.rb +6 -0
- data/app/controllers/loyal_core/jumps_controller.rb +10 -0
- data/app/helpers/loyal_core/admin/skin/folders_helper.rb +5 -0
- data/app/helpers/loyal_core/admin/skin/recipes_helper.rb +5 -0
- data/app/helpers/loyal_core/ajax/captchas_helper.rb +6 -0
- data/app/helpers/loyal_core/ajax/like_tracks_helper.rb +6 -0
- data/app/helpers/loyal_core/ajax/rating_tracks_helper.rb +6 -0
- data/app/helpers/loyal_core/ajax/users/sessions_helper.rb +5 -0
- data/app/helpers/loyal_core/application_helper.rb +6 -0
- data/app/helpers/loyal_core/jumps_helper.rb +5 -0
- data/app/models/kindeditor/asset.rb +14 -0
- data/app/models/kindeditor/file.rb +4 -0
- data/app/models/kindeditor/flash.rb +4 -0
- data/app/models/kindeditor/image.rb +4 -0
- data/app/models/kindeditor/media.rb +4 -0
- data/app/models/loyal_core/like_track.rb +15 -0
- data/app/models/loyal_core/rating_track.rb +32 -0
- data/app/models/loyal_core/skin/dish.rb +10 -0
- data/app/models/loyal_core/skin/folder.rb +26 -0
- data/app/models/loyal_core/skin/recipe.rb +31 -0
- data/app/models/loyal_core/skin.rb +8 -0
- data/app/uploaders/loyal_core/asset_uploader.rb +128 -0
- data/app/uploaders/loyal_core/avatar_uploader.rb +37 -0
- data/app/views/layouts/loyal_core/application.html.erb +14 -0
- data/app/views/loyal_core/admin/skin/folders/_form.html.erb +9 -0
- data/app/views/loyal_core/admin/skin/folders/edit.html.erb +11 -0
- data/app/views/loyal_core/admin/skin/folders/index.html.erb +25 -0
- data/app/views/loyal_core/admin/skin/folders/new.html.erb +11 -0
- data/app/views/loyal_core/admin/skin/folders/show.html.erb +32 -0
- data/app/views/loyal_core/admin/skin/recipes/_form.html.erb +25 -0
- data/app/views/loyal_core/admin/skin/recipes/edit.html.erb +11 -0
- data/app/views/loyal_core/admin/skin/recipes/index.html.erb +37 -0
- data/app/views/loyal_core/admin/skin/recipes/new.html.erb +11 -0
- data/app/views/loyal_core/admin/skin/recipes/show.html.erb +16 -0
- data/app/views/loyal_core/ajax/captchas/_new.html.erb +1 -0
- data/app/views/loyal_core/ajax/captchas/new.html.erb +1 -0
- data/app/views/loyal_core/jumps/show.html.erb +12 -0
- data/app/views/simple_captcha/_simple_captcha.erb +16 -0
- data/config/locales/en/default.en.yml +139 -0
- data/config/locales/en/loyal_simple_captcha.en.yml +8 -0
- data/config/locales/zh-CN/action_view.zh-CN.yml +8 -0
- data/config/locales/zh-CN/default.zh-CN.yml +199 -0
- data/config/locales/zh-CN/loyal_simple_captcha.zh-CN.yml +8 -0
- data/config/locales/zh-CN/paginate.zh-CN.yml +8 -0
- data/config/routes.rb +24 -0
- data/db/migrate/20130331104216_create_loyal_core_rating_tracks.rb +19 -0
- data/db/migrate/20130331104822_create_loyal_core_like_tracks.rb +19 -0
- data/db/migrate/20130413061851_create_kindeditor_assets.rb +17 -0
- data/db/migrate/20130610091558_create_loyal_core_skin_folders.rb +48 -0
- data/db/migrate/20130610095635_create_loyal_core_skin_recipes.rb +28 -0
- data/db/migrate/20130610095938_create_loyal_core_skin_dishes.rb +13 -0
- data/lib/loyal_core/action_controller/request_init.rb +33 -0
- data/lib/loyal_core/action_controller/seo_methods.rb +47 -0
- data/lib/loyal_core/action_controller.rb +4 -0
- data/lib/loyal_core/action_helper/ajax/like_tracks_helper.rb +26 -0
- data/lib/loyal_core/action_helper/ajax/rating_tracks_helper.rb +35 -0
- data/lib/loyal_core/action_helper/font_selector_helper.rb +25 -0
- data/lib/loyal_core/action_helper.rb +27 -0
- data/lib/loyal_core/action_view/labeled_builder.rb +127 -0
- data/lib/loyal_core/action_view.rb +7 -0
- data/lib/loyal_core/active_model/fix_counter_cache.rb +39 -0
- data/lib/loyal_core/active_model/human_display_able.rb +26 -0
- data/lib/loyal_core/active_model/strip_whitespace.rb +27 -0
- data/lib/loyal_core/active_model.rb +16 -0
- data/lib/loyal_core/acts/bit_able.rb +139 -0
- data/lib/loyal_core/acts/content_depart_able.rb +102 -0
- data/lib/loyal_core/acts/content_mode_able.rb +88 -0
- data/lib/loyal_core/acts/has_avatar.rb +31 -0
- data/lib/loyal_core/acts/has_permalink.rb +43 -0
- data/lib/loyal_core/acts/like_track_able.rb +90 -0
- data/lib/loyal_core/acts/named_filter_able.rb +40 -0
- data/lib/loyal_core/acts/rating_track_able.rb +76 -0
- data/lib/loyal_core/acts/skin_dish_able.rb +56 -0
- data/lib/loyal_core/acts/tree.rb +104 -0
- data/lib/loyal_core/acts/uuid_ful.rb +39 -0
- data/lib/loyal_core/acts/views_count_able.rb +33 -0
- data/lib/loyal_core/acts.rb +35 -0
- data/lib/loyal_core/config.rb +116 -0
- data/lib/loyal_core/core_ext/singleton_class.rb +9 -0
- data/lib/loyal_core/engine.rb +11 -0
- data/lib/loyal_core/memoist.rb +204 -0
- data/lib/loyal_core/utils/array_util.rb +16 -0
- data/lib/loyal_core/utils/config_util.rb +186 -0
- data/lib/loyal_core/utils/data_util.rb +181 -0
- data/lib/loyal_core/utils/text_util.rb +49 -0
- data/lib/loyal_core/utils.rb +8 -0
- data/lib/loyal_core/version.rb +4 -0
- data/lib/loyal_core.rb +17 -0
- data/lib/tasks/loyal_core_tasks.rake +11 -0
- metadata +231 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'LoyalCore'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,95 @@
|
|
1
|
+
/*!
|
2
|
+
* jQuery Cookie Plugin v1.3.1
|
3
|
+
* https://github.com/carhartl/jquery-cookie
|
4
|
+
*
|
5
|
+
* Copyright 2013 Klaus Hartl
|
6
|
+
* Released under the MIT license
|
7
|
+
*/
|
8
|
+
(function (factory) {
|
9
|
+
if (typeof define === 'function' && define.amd) {
|
10
|
+
// AMD. Register as anonymous module.
|
11
|
+
define(['jquery'], factory);
|
12
|
+
} else {
|
13
|
+
// Browser globals.
|
14
|
+
factory(jQuery);
|
15
|
+
}
|
16
|
+
}(function ($) {
|
17
|
+
|
18
|
+
var pluses = /\+/g;
|
19
|
+
|
20
|
+
function raw(s) {
|
21
|
+
return s;
|
22
|
+
}
|
23
|
+
|
24
|
+
function decoded(s) {
|
25
|
+
return decodeURIComponent(s.replace(pluses, ' '));
|
26
|
+
}
|
27
|
+
|
28
|
+
function converted(s) {
|
29
|
+
if (s.indexOf('"') === 0) {
|
30
|
+
// This is a quoted cookie as according to RFC2068, unescape
|
31
|
+
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
32
|
+
}
|
33
|
+
try {
|
34
|
+
return config.json ? JSON.parse(s) : s;
|
35
|
+
} catch(er) {}
|
36
|
+
}
|
37
|
+
|
38
|
+
var config = $.cookie = function (key, value, options) {
|
39
|
+
|
40
|
+
// write
|
41
|
+
if (value !== undefined) {
|
42
|
+
options = $.extend({}, config.defaults, options);
|
43
|
+
|
44
|
+
if (typeof options.expires === 'number') {
|
45
|
+
var days = options.expires, t = options.expires = new Date();
|
46
|
+
t.setDate(t.getDate() + days);
|
47
|
+
}
|
48
|
+
|
49
|
+
value = config.json ? JSON.stringify(value) : String(value);
|
50
|
+
|
51
|
+
return (document.cookie = [
|
52
|
+
config.raw ? key : encodeURIComponent(key),
|
53
|
+
'=',
|
54
|
+
config.raw ? value : encodeURIComponent(value),
|
55
|
+
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
56
|
+
options.path ? '; path=' + options.path : '',
|
57
|
+
options.domain ? '; domain=' + options.domain : '',
|
58
|
+
options.secure ? '; secure' : ''
|
59
|
+
].join(''));
|
60
|
+
}
|
61
|
+
|
62
|
+
// read
|
63
|
+
var decode = config.raw ? raw : decoded;
|
64
|
+
var cookies = document.cookie.split('; ');
|
65
|
+
var result = key ? undefined : {};
|
66
|
+
for (var i = 0, l = cookies.length; i < l; i++) {
|
67
|
+
var parts = cookies[i].split('=');
|
68
|
+
var name = decode(parts.shift());
|
69
|
+
var cookie = decode(parts.join('='));
|
70
|
+
|
71
|
+
if (key && key === name) {
|
72
|
+
result = converted(cookie);
|
73
|
+
break;
|
74
|
+
}
|
75
|
+
|
76
|
+
if (!key) {
|
77
|
+
result[name] = converted(cookie);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
return result;
|
82
|
+
};
|
83
|
+
|
84
|
+
config.defaults = {};
|
85
|
+
|
86
|
+
$.removeCookie = function (key, options) {
|
87
|
+
if ($.cookie(key) !== undefined) {
|
88
|
+
// Must not alter options, thus extending a fresh object...
|
89
|
+
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
|
90
|
+
return true;
|
91
|
+
}
|
92
|
+
return false;
|
93
|
+
};
|
94
|
+
|
95
|
+
}));
|
@@ -0,0 +1,124 @@
|
|
1
|
+
|
2
|
+
var marchBackstage = (function(mod){
|
3
|
+
var _getMarchData = function(obj){
|
4
|
+
return {
|
5
|
+
type: obj.attr('march-type') || null,
|
6
|
+
id: obj.attr('march-id') || null,
|
7
|
+
action: obj.attr('march-action') || null,
|
8
|
+
obj: obj
|
9
|
+
};
|
10
|
+
}
|
11
|
+
|
12
|
+
// 弹出 错误对话框
|
13
|
+
mod.tryAjaxErrorDialog = function(data){
|
14
|
+
if(mod.isUnauthorized(data)) {
|
15
|
+
alert(data.response.error);
|
16
|
+
return false;
|
17
|
+
} else {
|
18
|
+
return true;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
// 没有登录的
|
23
|
+
mod.isUnauthorized = function(data){
|
24
|
+
return data.response.code == 'unauthorized';
|
25
|
+
}
|
26
|
+
|
27
|
+
// 绑定喜欢操作
|
28
|
+
mod.bindLikeActions = function(){
|
29
|
+
$('[march-on="ajax"]').on('click', function(){
|
30
|
+
var _data = _getMarchData($(this));
|
31
|
+
|
32
|
+
if(_data.action == 'like'){
|
33
|
+
$.ajax(
|
34
|
+
{
|
35
|
+
url: "/ajax/core/like_tracks/" + _data.type + "/" + _data.id + '/touch.json',
|
36
|
+
type: 'GET',
|
37
|
+
dataType: 'json',
|
38
|
+
success: function(data) {
|
39
|
+
switch(data.result.code){
|
40
|
+
case 'undo':
|
41
|
+
_data.obj.find('img.liked').css('display', 'none');
|
42
|
+
_data.obj.find('img.unlike').css('display', 'inline');
|
43
|
+
_data.obj.find('.count').text(data.result['count']);
|
44
|
+
break;
|
45
|
+
case 'like':
|
46
|
+
_data.obj.find('img.unlike').css('display', 'none');
|
47
|
+
_data.obj.find('img.liked').css('display', 'inline');
|
48
|
+
_data.obj.find('.count').text(data.result['count']);
|
49
|
+
break;
|
50
|
+
}
|
51
|
+
},
|
52
|
+
error: function(xhr, status, error) {
|
53
|
+
var data = eval("(" + xhr.responseText + ")");
|
54
|
+
mod.tryAjaxErrorDialog(data);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
);
|
58
|
+
}
|
59
|
+
});
|
60
|
+
}
|
61
|
+
|
62
|
+
// 绑定评价操作
|
63
|
+
mod.bindRatingActions = function(){
|
64
|
+
$('[march-on="ajax"]').on('click', function(){
|
65
|
+
var _data = _getMarchData($(this));
|
66
|
+
|
67
|
+
switch(_data.action){
|
68
|
+
case 'up': // 顶
|
69
|
+
case 'down': // 踩
|
70
|
+
$.ajax(
|
71
|
+
{
|
72
|
+
url: "/ajax/core/rating_tracks/" + _data.type + "/" + _data.id + "/" + _data.action + '.json',
|
73
|
+
success: function(data) {
|
74
|
+
// data:
|
75
|
+
// {
|
76
|
+
// response: {
|
77
|
+
// status: 200,
|
78
|
+
// code: 'success'
|
79
|
+
// }
|
80
|
+
// }
|
81
|
+
switch(data.result.code){
|
82
|
+
case 'already':
|
83
|
+
alert('您已经评价过了');
|
84
|
+
case 'up':
|
85
|
+
case 'down':
|
86
|
+
_data.obj.find('.count').text(data.result[_data.action + '_rating']);
|
87
|
+
break;
|
88
|
+
}
|
89
|
+
},
|
90
|
+
error: function(xhr, status, error) {
|
91
|
+
var data = eval("(" + xhr.responseText + ")");
|
92
|
+
mod.tryAjaxErrorDialog(data);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
);
|
96
|
+
break;
|
97
|
+
default:
|
98
|
+
break;
|
99
|
+
};
|
100
|
+
});
|
101
|
+
}
|
102
|
+
|
103
|
+
// marchBackstage.retrySimpleCaptcha(this);
|
104
|
+
mod.retrySimpleCaptcha = function(obj, url){
|
105
|
+
var currentRetryLink = $(obj);
|
106
|
+
$.get(url, {time: (new Date()).valueOf(), format: 'json'}, function(data){
|
107
|
+
if(data.response.code == 'success'){
|
108
|
+
var currentCaptchaZone = currentRetryLink.parents(".simple_captcha:first");
|
109
|
+
currentCaptchaZone.find('img.captcha-image').attr('src', data.simple_captcha_options.image_url);
|
110
|
+
currentCaptchaZone.find('input.captcha-key').val(data.simple_captcha_options.captcha_key);
|
111
|
+
}
|
112
|
+
});
|
113
|
+
|
114
|
+
return false;
|
115
|
+
}
|
116
|
+
|
117
|
+
return mod;
|
118
|
+
})(window.marchBackstage || {});
|
119
|
+
|
120
|
+
$(function(){
|
121
|
+
marchBackstage.bindLikeActions();
|
122
|
+
marchBackstage.bindRatingActions();
|
123
|
+
});
|
124
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
var loyalAppendParamsReturnTo = (function(mod){
|
2
|
+
// public
|
3
|
+
mod.onload = function(){
|
4
|
+
var currentUrl = window.location.href;
|
5
|
+
|
6
|
+
$('a[loayl-append-params-return-to=true]').each(function(){
|
7
|
+
if($(this).attr('href').indexOf('?') < 0){
|
8
|
+
$(this).attr('href', (
|
9
|
+
$(this).attr('href') + "?return_to=" + encodeURIComponent(currentUrl)
|
10
|
+
));
|
11
|
+
}
|
12
|
+
});
|
13
|
+
}
|
14
|
+
|
15
|
+
return mod;
|
16
|
+
})(window.loyalAppendParamsReturnTo || {});
|
17
|
+
|
18
|
+
$(function(){
|
19
|
+
loyalAppendParamsReturnTo.onload();
|
20
|
+
});
|
21
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
$(function(){
|
2
|
+
$('select.loyal-editor-content-mode-selector').on('change', function(){
|
3
|
+
var currentForm = $(this).parents('form:first');
|
4
|
+
// currentForm.appendHTML("<input type='hidden' name='content_mode_changed' value='true'/>");
|
5
|
+
currentForm.submit();
|
6
|
+
});
|
7
|
+
});
|
8
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
var loyalCoreFontSelect = (function(mod){
|
2
|
+
mod._config = {
|
3
|
+
selectors: {
|
4
|
+
fontSize: '.loyal-core-font-size-selector a'
|
5
|
+
},
|
6
|
+
cookies: {
|
7
|
+
fontSize: 'loyal-core-font-size'
|
8
|
+
},
|
9
|
+
fontSizeMap: {
|
10
|
+
small: '100%',
|
11
|
+
medium: '130%',
|
12
|
+
large: '160%'
|
13
|
+
},
|
14
|
+
defaultFontSize: 'small'
|
15
|
+
}
|
16
|
+
|
17
|
+
mod._getCookieName = function(name){
|
18
|
+
return mod._config.cookies[name];
|
19
|
+
}
|
20
|
+
|
21
|
+
mod._getActionLinks = function(name){
|
22
|
+
return $(mod._config.selectors[name]);
|
23
|
+
}
|
24
|
+
|
25
|
+
mod._getFontSizeMap = function(){
|
26
|
+
return mod._config.fontSizeMap;
|
27
|
+
}
|
28
|
+
|
29
|
+
mod._getFontSize = function(name){
|
30
|
+
var fontSizeMap = mod._getFontSizeMap();
|
31
|
+
return fontSizeMap[name] || fontSizeMap[mod._config.defaultFontSize];
|
32
|
+
}
|
33
|
+
|
34
|
+
// private
|
35
|
+
mod._bindFontSizeLinksActions = function(){
|
36
|
+
mod._getActionLinks('fontSize').on('click', function(){
|
37
|
+
var fontSizeName = $(this).attr('loyal-data-type-size');
|
38
|
+
var selector = $(this).parent().find("[name=font-selector-size]").val();
|
39
|
+
|
40
|
+
var fontSize = mod._getFontSize(fontSizeName);
|
41
|
+
|
42
|
+
$.cookie(mod._getCookieName('fontSize'), fontSizeName, { expires: 2, path: '/' });
|
43
|
+
|
44
|
+
mod._setFontSizeCss($(selector), fontSize);
|
45
|
+
});
|
46
|
+
}
|
47
|
+
|
48
|
+
// 设置正文的字体大小
|
49
|
+
mod._setFontSizeCss = function(worker, fontSize){
|
50
|
+
worker.css('font-size', fontSize);
|
51
|
+
}
|
52
|
+
|
53
|
+
mod._loadFontSizeFromStore = function(){
|
54
|
+
var actionLinks = mod._getActionLinks('fontSize');
|
55
|
+
|
56
|
+
var selector = actionLinks.parent().find("[name=font-selector-size]").val();
|
57
|
+
var fontSizeName = $.cookie(mod._getCookieName('fontSize'));
|
58
|
+
var fontSize = mod._getFontSize(fontSizeName);
|
59
|
+
|
60
|
+
// 设置控制链接的字体
|
61
|
+
actionLinks.each(function(){
|
62
|
+
var current = $(this);
|
63
|
+
var currentFontSizeName = current.attr('loyal-data-type-size');
|
64
|
+
current.css('font-size', mod._getFontSize(currentFontSizeName));
|
65
|
+
});
|
66
|
+
|
67
|
+
mod._setFontSizeCss($(selector), fontSize);
|
68
|
+
}
|
69
|
+
|
70
|
+
// public
|
71
|
+
mod.onload = function(){
|
72
|
+
// 首先绑定按钮 事件
|
73
|
+
mod._bindFontSizeLinksActions();
|
74
|
+
mod._loadFontSizeFromStore();
|
75
|
+
}
|
76
|
+
|
77
|
+
return mod;
|
78
|
+
})(window.loyalCoreFontSelect || {});
|
79
|
+
|
80
|
+
$(function(){
|
81
|
+
loyalCoreFontSelect.onload();
|
82
|
+
});
|
83
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/*
|
2
|
+
*= require_self
|
3
|
+
*/
|
4
|
+
|
5
|
+
.simple_captcha {
|
6
|
+
padding: 15px;
|
7
|
+
font-size: 12px;
|
8
|
+
}
|
9
|
+
|
10
|
+
|
11
|
+
.simple_captcha .simple_captcha_field input{
|
12
|
+
width: 150px !important;
|
13
|
+
font-size: 14px;
|
14
|
+
background-color: #efefef;
|
15
|
+
padding: 5px;
|
16
|
+
}
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module LoyalCore
|
3
|
+
class Admin::Skin::FoldersController < ::LoyalAdmin::ApplicationController
|
4
|
+
def index
|
5
|
+
|
6
|
+
end
|
7
|
+
|
8
|
+
def show
|
9
|
+
@loyal_core_skin_folder = ::LoyalCore::Skin::Folder.find params[:id]
|
10
|
+
|
11
|
+
@loyal_core_skin_recipes = @loyal_core_skin_folder.recipes.page(params[:page])
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@loyal_core_skin_folder = ::LoyalCore::Skin::Folder.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
@loyal_core_skin_folder = ::LoyalCore::Skin::Folder.new(params[:loyal_core_skin_folder])
|
20
|
+
|
21
|
+
@loyal_core_skin_folder.created_by = current_user.id
|
22
|
+
@loyal_core_skin_folder.created_ip = request.remote_ip
|
23
|
+
|
24
|
+
if @loyal_core_skin_folder.save
|
25
|
+
redirect_to loyal_core_app.admin_skin_folder_url(:id => @loyal_core_skin_folder.id)
|
26
|
+
else
|
27
|
+
render :new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def edit
|
32
|
+
@loyal_core_skin_folder = ::LoyalCore::Skin::Folder.find params[:id]
|
33
|
+
end
|
34
|
+
|
35
|
+
def update
|
36
|
+
@loyal_core_skin_folder = ::LoyalCore::Skin::Folder.find params[:id]
|
37
|
+
|
38
|
+
if @loyal_core_skin_folder.update_attributes(params[:loyal_core_skin_folder])
|
39
|
+
redirect_to loyal_core_app.admin_skin_folder_url(:id => @loyal_core_skin_folder.id)
|
40
|
+
else
|
41
|
+
render :edit
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def destroy
|
46
|
+
@loyal_core_skin_folder = ::LoyalCore::Skin::Folder.find params[:id]
|
47
|
+
|
48
|
+
@loyal_core_skin_folder.destroy
|
49
|
+
|
50
|
+
redirect_to params[:return_to] || loyal_core_app.admin_skin_folders_url
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module LoyalCore
|
3
|
+
class Admin::Skin::RecipesController < ::LoyalAdmin::ApplicationController
|
4
|
+
def index
|
5
|
+
@loyal_core_skin_recipes = ::LoyalCore::Skin::Recipe.page(params[:page])
|
6
|
+
end
|
7
|
+
|
8
|
+
def show
|
9
|
+
@loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.find params[:id]
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
@loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.new(params[:loyal_core_skin_recipe])
|
18
|
+
|
19
|
+
@loyal_core_skin_recipe.created_by = current_user.id
|
20
|
+
@loyal_core_skin_recipe.created_ip = request.remote_ip
|
21
|
+
|
22
|
+
if @loyal_core_skin_recipe.save
|
23
|
+
redirect_to loyal_core_app.admin_skin_recipe_url(:id => @loyal_core_skin_recipe.id)
|
24
|
+
else
|
25
|
+
render :new
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def edit
|
30
|
+
@loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.find params[:id]
|
31
|
+
end
|
32
|
+
|
33
|
+
def update
|
34
|
+
@loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.find params[:id]
|
35
|
+
|
36
|
+
if @loyal_core_skin_recipe.update_attributes(params[:loyal_core_skin_recipe])
|
37
|
+
redirect_to loyal_core_app.admin_skin_recipe_url(:id => @loyal_core_skin_recipe.id)
|
38
|
+
else
|
39
|
+
render :edit
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy
|
44
|
+
@loyal_core_skin_recipe = ::LoyalCore::Skin::Recipe.find params[:id]
|
45
|
+
|
46
|
+
@loyal_core_skin_recipe.destroy
|
47
|
+
|
48
|
+
redirect_to params[:return_to] || loyal_core_app.admin_skin_recipes_url
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module LoyalCore
|
3
|
+
class Ajax::CaptchasController < ::LoyalCore::AjaxController
|
4
|
+
def new
|
5
|
+
|
6
|
+
@simple_captcha_options = generate_simple_captcha_options(:object => params[:object])
|
7
|
+
|
8
|
+
respond_to do |format|
|
9
|
+
format.html { render :new, :layout => nil }
|
10
|
+
|
11
|
+
format.json {
|
12
|
+
render :json => {
|
13
|
+
:response => {
|
14
|
+
:status => 200,
|
15
|
+
:code => :success
|
16
|
+
},
|
17
|
+
:simple_captcha_options => @simple_captcha_options
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
format.js { render :js => "var simpleCaptchaOptions = #{@simple_captcha_options.to_json};" }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|