commit
1b6ecbf520
@ -1,96 +1,90 @@
|
||||
source 'http://ruby.taobao.org'
|
||||
#source 'http://ruby.sdutlinux.org/'
|
||||
|
||||
unless RUBY_PLATFORM =~ /w32/
|
||||
# unix-like only
|
||||
gem 'iconv'
|
||||
end
|
||||
|
||||
gem "mysql2", "= 0.3.18"
|
||||
gem 'redis-rails'
|
||||
gem 'rubyzip'
|
||||
gem 'delayed_job_active_record'#, :group => :production
|
||||
gem 'daemons'
|
||||
gem 'grape', '~> 0.9.0'
|
||||
gem 'grape-entity'
|
||||
gem 'seems_rateable', '~> 1.0.13'
|
||||
gem "rails", "3.2.13"
|
||||
gem "jquery-rails", "~> 2.0.2"
|
||||
gem "i18n", "~> 0.6.0"
|
||||
gem 'coderay', '~> 1.1.0'
|
||||
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
|
||||
gem "builder", "3.0.0"
|
||||
gem 'acts-as-taggable-on', '2.4.1'
|
||||
gem 'spreadsheet'
|
||||
gem 'ruby-ole'
|
||||
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
|
||||
group :development do
|
||||
gem 'grape-swagger'
|
||||
#gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git'
|
||||
gem 'puma' if RbConfig::CONFIG['host_os'] =~ /linux/
|
||||
gem 'pry-rails'
|
||||
if RUBY_VERSION >= '2.0.0'
|
||||
gem 'pry-byebug'
|
||||
else
|
||||
# gem 'pry-debugger'
|
||||
end
|
||||
gem 'pry-stack_explorer'
|
||||
gem 'better_errors', '~> 1.1.0'
|
||||
gem 'rack-mini-profiler', '~> 0.9.3'
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem "shoulda", "~> 3.5.0"
|
||||
gem "mocha", "~> 1.1.0"
|
||||
gem 'capybara', '~> 2.4.1'
|
||||
gem 'nokogiri', '~> 1.6.3'
|
||||
gem 'factory_girl', '~> 4.4.0'
|
||||
gem 'selenium-webdriver', '~> 2.42.0'
|
||||
|
||||
gem "faker"
|
||||
# platforms :mri, :mingw do
|
||||
# group :rmagick do
|
||||
# # RMagick 2 supports ruby 1.9
|
||||
# # RMagick 1 would be fine for ruby 1.8 but Bundler does not support
|
||||
# # different requirements for the same gem on different platforms
|
||||
# gem "rmagick", ">= 2.0.0"
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
||||
# Gems used only for assets and not required
|
||||
# in production environments by default.
|
||||
group :assets do
|
||||
gem 'sass-rails', '~> 3.2.3'
|
||||
gem 'coffee-rails', '~> 3.2.1'
|
||||
|
||||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
||||
gem 'therubyracer', :platforms => :ruby
|
||||
|
||||
gem 'uglifier', '>= 1.0.3'
|
||||
end
|
||||
|
||||
# Optional gem for LDAP authentication
|
||||
group :ldap do
|
||||
gem "net-ldap", "~> 0.3.1"
|
||||
end
|
||||
|
||||
|
||||
# Optional gem for OpenID authentication
|
||||
group :openid do
|
||||
gem "ruby-openid", "~> 2.1.4", :require => "openid"
|
||||
gem "rack-openid"
|
||||
end
|
||||
|
||||
|
||||
database_file = File.join(File.dirname(__FILE__), "config/database.yml")
|
||||
if File.exist?(database_file)
|
||||
else
|
||||
warn("Please configure your config/database.yml first")
|
||||
end
|
||||
|
||||
# Load plugins' Gemfiles
|
||||
Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
|
||||
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
|
||||
instance_eval File.read(file)
|
||||
end
|
||||
source 'http://ruby.taobao.org'
|
||||
#source 'http://ruby.sdutlinux.org/'
|
||||
|
||||
unless RUBY_PLATFORM =~ /w32/
|
||||
# unix-like only
|
||||
gem 'iconv'
|
||||
end
|
||||
|
||||
gem "mysql2", "= 0.3.18"
|
||||
gem 'redis-rails'
|
||||
gem 'rubyzip'
|
||||
gem 'delayed_job_active_record'#, :group => :production
|
||||
gem 'daemons'
|
||||
gem 'grape', '~> 0.9.0'
|
||||
gem 'grape-entity'
|
||||
gem 'seems_rateable', '~> 1.0.13'
|
||||
gem "rails", "3.2.13"
|
||||
gem "jquery-rails", "~> 2.0.2"
|
||||
gem "i18n", "~> 0.6.0"
|
||||
gem 'coderay', '~> 1.1.0'
|
||||
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
|
||||
gem "builder", "3.0.0"
|
||||
gem 'acts-as-taggable-on', '2.4.1'
|
||||
gem 'spreadsheet'
|
||||
gem 'ruby-ole'
|
||||
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
|
||||
gem "rmagick", ">= 2.0.0"
|
||||
|
||||
group :development do
|
||||
gem 'grape-swagger'
|
||||
#gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git'
|
||||
gem 'puma' if RbConfig::CONFIG['host_os'] =~ /linux/
|
||||
gem 'pry-rails'
|
||||
if RUBY_VERSION >= '2.0.0'
|
||||
gem 'pry-byebug'
|
||||
else
|
||||
# gem 'pry-debugger'
|
||||
end
|
||||
gem 'pry-stack_explorer'
|
||||
gem 'better_errors', '~> 1.1.0'
|
||||
gem 'rack-mini-profiler', '~> 0.9.3'
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem "shoulda", "~> 3.5.0"
|
||||
gem "mocha", "~> 1.1.0"
|
||||
gem 'capybara', '~> 2.4.1'
|
||||
gem 'nokogiri', '~> 1.6.3'
|
||||
gem 'factory_girl', '~> 4.4.0'
|
||||
gem 'selenium-webdriver', '~> 2.42.0'
|
||||
|
||||
gem "faker"
|
||||
end
|
||||
|
||||
# Gems used only for assets and not required
|
||||
# in production environments by default.
|
||||
group :assets do
|
||||
gem 'sass-rails', '~> 3.2.3'
|
||||
gem 'coffee-rails', '~> 3.2.1'
|
||||
|
||||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
||||
gem 'therubyracer', :platforms => :ruby
|
||||
|
||||
gem 'uglifier', '>= 1.0.3'
|
||||
end
|
||||
|
||||
# Optional gem for LDAP authentication
|
||||
group :ldap do
|
||||
gem "net-ldap", "~> 0.3.1"
|
||||
end
|
||||
|
||||
|
||||
# Optional gem for OpenID authentication
|
||||
group :openid do
|
||||
gem "ruby-openid", "~> 2.1.4", :require => "openid"
|
||||
gem "rack-openid"
|
||||
end
|
||||
|
||||
|
||||
database_file = File.join(File.dirname(__FILE__), "config/database.yml")
|
||||
if File.exist?(database_file)
|
||||
else
|
||||
warn("Please configure your config/database.yml first")
|
||||
end
|
||||
|
||||
# Load plugins' Gemfiles
|
||||
Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
|
||||
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
|
||||
instance_eval File.read(file)
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
var imgSpan = $('#avatar_image');
|
||||
|
||||
imgSpan.attr({"src":'<%= @urlfile.to_s << "?" << Time.now.to_s%>'});
|
||||
imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'});
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 20.minutes, :key => '_trustie_session', :domain => :all
|
||||
Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 90.minutes, :key => '_trustie_session', :domain => :all
|
||||
|
@ -0,0 +1,11 @@
|
||||
desc "compress and backup avatar"
|
||||
task :compress_avatar => :environment do
|
||||
path = File.join(Rails.root, "public/images/avatars/User")
|
||||
Dir.foreach(path) do |f|
|
||||
if f.to_s =~ /^\d+$/
|
||||
puts f
|
||||
image = Trustie::Utils::Image.new(File.join(path,f), true)
|
||||
image.compress(300)
|
||||
end
|
||||
end
|
||||
end
|
@ -1 +1,2 @@
|
||||
require 'trustie/utils'
|
||||
require 'trustie/utils'
|
||||
require 'trustie/utils/image'
|
||||
|
@ -0,0 +1,35 @@
|
||||
#coding=utf-8
|
||||
|
||||
module Trustie
|
||||
module Utils
|
||||
class Image
|
||||
def initialize(file, bak)
|
||||
@file = file
|
||||
@bak = bak
|
||||
end
|
||||
|
||||
def compress(size=300)
|
||||
backup if @bak
|
||||
begin
|
||||
f = Magick::ImageList.new(@file)
|
||||
if f.format != 'GIF'
|
||||
width = size
|
||||
if f[0].columns > width
|
||||
proportion = (width/f[0].columns.to_f)
|
||||
height = (f[0].rows*proportion)
|
||||
f.resize_to_fill!(width,height.to_i)
|
||||
f.write(@file)
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
logger.error "[Error] compress : ===> #{e}"
|
||||
end
|
||||
end
|
||||
|
||||
def backup
|
||||
FileUtils.cp @file, "#{@file}.bak"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,37 @@
|
||||
KindEditor.plugin('paste', function(K) {
|
||||
var editor = this,
|
||||
name = 'paste';
|
||||
var contentWindow = document.getElementsByTagName('iframe')[0].contentWindow;
|
||||
contentWindow.document.getElementsByTagName('body')[0].onpaste = function(event) {
|
||||
// use event.originalEvent.clipboard for newer chrome versions
|
||||
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
||||
console.log(JSON.stringify(items)); // will give you the mime types
|
||||
// find pasted image among pasted items
|
||||
var blob = null;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].type.indexOf("image") === 0) {
|
||||
blob = items[i].getAsFile();
|
||||
}
|
||||
}
|
||||
// load image if there is a pasted image
|
||||
if (blob !== null) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(event) {
|
||||
console.log(event.target.result); // data url!
|
||||
var data = new FormData();
|
||||
data.append("imgFile", blob, "imageFilename.png");
|
||||
$.ajax({
|
||||
url: '/kindeditor/upload?dir=image',
|
||||
contentType: false,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
editor.exec('insertimage', JSON.parse(data).url);
|
||||
}
|
||||
});
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
}
|
||||
}
|
||||
});
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue