Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
393 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'carrierwave' | ||
require 'carrierwave/validations/active_model' | ||
|
||
require 'mongo_mapper_ext/mongo_mapper' | ||
|
||
%w( | ||
fixes | ||
micelaneous | ||
mongo_mapper/plugins/carrier_wave | ||
).each{|f| require "mongo_mapper_ext/carrier_wave/#{f}"} | ||
|
||
MongoMapper::Document.send :include, MongoMapper::Plugins::CarrierWave |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CarrierWave::SanitizedFile.class_eval do | ||
def sanitize_regexp | ||
/[^[:word:]\.\-\+\s_]/i | ||
end | ||
end | ||
|
||
CarrierWave::Uploader::Cache.class_eval do | ||
def original_filename=(filename) | ||
raise CarrierWave::InvalidParameter, "invalid filename" unless filename =~ /\A[[:word:]\.\-\+\s_]+\z/i | ||
@original_filename = filename | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Changing filename format from <version>_<filename_with_extension> to <name>.<version>.<extension> | ||
# | ||
CarrierWave::Uploader::Versions.class_eval do | ||
def full_filename(for_file) | ||
name = super | ||
if version_name | ||
ext = File.extname name | ||
base = File.basename name, ext | ||
"#{base}.#{version_name}#{ext}" | ||
else | ||
name | ||
end | ||
end | ||
|
||
def full_original_filename | ||
name = super | ||
if version_name | ||
ext = File.extname name | ||
base = File.basename name, ext | ||
"#{base}.#{version_name}#{ext}" | ||
else | ||
name | ||
end | ||
end | ||
end |
19 changes: 0 additions & 19 deletions
19
lib/mongo_mapper_ext/plugins/carrierwave.rb → ...wave/mongo_mapper/plugins/carrier_wave.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'mongo_mapper_ext/mongo_db/upsert' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'mongo_mapper_ext/gems' | ||
require 'mongo_mapper' | ||
|
||
require 'mongo_mapper_ext/mongo_db' | ||
|
||
%w( | ||
fixes | ||
hacks | ||
support | ||
|
||
migration | ||
view_helpers | ||
logging | ||
|
||
plugins/attribute_cache | ||
plugins/attribute_convertors | ||
plugins/belongs_to_with_counter_cache | ||
plugins/custom_scope | ||
plugins/db_config | ||
plugins/micelaneous | ||
).each{|file| require "mongo_mapper_ext/mongo_mapper/#{file}"} | ||
|
||
|
||
# | ||
# Default plugins | ||
# | ||
module MongoMapper::Plugins | ||
[CustomScope, AttributeCache, AttributeConvertors, BelongsToWithCounterCache, Micelaneous, DbConfig].each do |plugin| | ||
::MongoMapper::Document.send :include, plugin | ||
end | ||
end | ||
|
||
|
||
# | ||
# Attribute protection | ||
# | ||
MongoMapper::Document.included do | ||
attr_protected :id, :_id, :_type, :created_at, :updated_at | ||
end | ||
|
||
|
||
# | ||
# Locales | ||
# | ||
dir = __FILE__.dirname | ||
I18n.load_path += Dir["#{dir}/mongo_mapper/locales/**/*.{rb,yml}"] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.