fix validation for photo title if russian locale
This commit is contained in:
parent
aedc18f834
commit
d996de1514
1
Gemfile
1
Gemfile
|
@ -8,6 +8,7 @@ gem 'mime-types', :require => 'mime/types'
|
||||||
gem 'carrierwave', '0.6.2'
|
gem 'carrierwave', '0.6.2'
|
||||||
gem 'dynamic_form'
|
gem 'dynamic_form'
|
||||||
gem 'princely'
|
gem 'princely'
|
||||||
|
gem 'russian', :git => 'git://github.com/yaroslav/russian.git'
|
||||||
|
|
||||||
# -- Heroku
|
# -- Heroku
|
||||||
#gem 'heroku'
|
#gem 'heroku'
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
GIT
|
||||||
|
remote: git://github.com/yaroslav/russian.git
|
||||||
|
revision: e2dde13672bcee176f8b0be364a55ac256913231
|
||||||
|
specs:
|
||||||
|
russian (0.6.0)
|
||||||
|
i18n (>= 0.5.0)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
@ -123,4 +130,5 @@ DEPENDENCIES
|
||||||
mini_magick
|
mini_magick
|
||||||
princely
|
princely
|
||||||
rails (= 3.2.6)
|
rails (= 3.2.6)
|
||||||
|
russian!
|
||||||
sqlite3-ruby
|
sqlite3-ruby
|
||||||
|
|
|
@ -5,11 +5,11 @@ class FileUploader < CarrierWave::Uploader::Base
|
||||||
# Include RMagick or ImageScience support
|
# Include RMagick or ImageScience support
|
||||||
# include CarrierWave::RMagick
|
# include CarrierWave::RMagick
|
||||||
# include CarrierWave::ImageScience
|
# include CarrierWave::ImageScience
|
||||||
include CarrierWave::MiniMagick
|
include CarrierWave::MiniMagick
|
||||||
# Choose what kind of storage to use for this uploader
|
# Choose what kind of storage to use for this uploader
|
||||||
if ENV['S3_KEY']
|
if ENV['S3_KEY']
|
||||||
storage :fog
|
storage :fog
|
||||||
|
|
||||||
def cache_dir
|
def cache_dir
|
||||||
"#{Rails.root.to_s}/tmp/uploads" if ENV['HEROKU'] == 'true'
|
"#{Rails.root.to_s}/tmp/uploads" if ENV['HEROKU'] == 'true'
|
||||||
end
|
end
|
||||||
|
@ -37,36 +37,40 @@ class FileUploader < CarrierWave::Uploader::Base
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# Create different versions of your uploaded files
|
# Create different versions of your uploaded files
|
||||||
version :collection do
|
version :collection do
|
||||||
process :resize_to_fill => [200, 200]
|
process :resize_to_fill => [200, 200]
|
||||||
def store_dir
|
|
||||||
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
def store_dir
|
||||||
end
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
version :album do
|
end
|
||||||
process :resize_to_fill => [100, 100]
|
version :album do
|
||||||
def store_dir
|
process :resize_to_fill => [100, 100]
|
||||||
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
|
||||||
end
|
def store_dir
|
||||||
end
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
version :preview do
|
end
|
||||||
process :resize_to_fit => [210, 210]
|
end
|
||||||
def store_dir
|
version :preview do
|
||||||
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
process :resize_to_fit => [210, 210]
|
||||||
end
|
|
||||||
end
|
def store_dir
|
||||||
version :single do
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
process :resize_to_limit => [950, 950]
|
end
|
||||||
def store_dir
|
end
|
||||||
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
version :single do
|
||||||
end
|
process :resize_to_limit => [950, 950]
|
||||||
end
|
|
||||||
|
def store_dir
|
||||||
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Add a white list of extensions which are allowed to be uploaded,
|
# Add a white list of extensions which are allowed to be uploaded,
|
||||||
# for images you might use something like this:
|
# for images you might use something like this:
|
||||||
def extension_white_list
|
def extension_white_list
|
||||||
%w(jpg jpeg gif png bmp tiff)
|
%w(jpg jpeg gif png bmp tiff)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Override the filename of the uploaded files
|
# Override the filename of the uploaded files
|
||||||
# def filename
|
# def filename
|
||||||
|
|
|
@ -1,86 +1,83 @@
|
||||||
<%= content_for :javascript do %>
|
<%= content_for :javascript do %>
|
||||||
<style type="text/css">@import url(/javascripts/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css);</style>
|
<style type="text/css">@import url(/javascripts/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css);</style>
|
||||||
<%= javascript_include_tag "plupload/js/plupload.full.js" -%>
|
<%= javascript_include_tag "plupload/js/plupload.full.js" -%>
|
||||||
<%= javascript_include_tag "plupload/js/jquery.plupload.queue/jquery.plupload.queue.js" -%>
|
<%= javascript_include_tag "plupload/js/jquery.plupload.queue/jquery.plupload.queue.js" -%>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
|
|
||||||
$("#uploader").pluploadQueue({
|
|
||||||
// General settings
|
|
||||||
runtimes : 'flash,html5,browserplus,silverlight,gears',
|
|
||||||
url : '<%= photos_path %>',
|
|
||||||
max_file_size : '10mb',
|
|
||||||
multipart: true,
|
|
||||||
multipart_params: {
|
|
||||||
'<%= get_session_key %>' : encodeURIComponent('<%= cookies[get_session_key] %>'),
|
|
||||||
'authenticity_token' : '<%= form_authenticity_token %>',
|
|
||||||
'photo[album_id]' : "<%= @album.id %>"
|
|
||||||
},
|
|
||||||
|
|
||||||
// Resize images on clientside if we can
|
$("#uploader").pluploadQueue({
|
||||||
//resize : {width : 320, height : 240, quality : 90},
|
// General settings
|
||||||
|
runtimes:'flash,html5,browserplus,silverlight,gears',
|
||||||
|
url:'<%= photos_path %>',
|
||||||
|
max_file_size:'10mb',
|
||||||
|
multipart:true,
|
||||||
|
multipart_params:{
|
||||||
|
'<%= get_session_key %>':encodeURIComponent('<%= cookies[get_session_key] %>'),
|
||||||
|
'authenticity_token':'<%= form_authenticity_token %>',
|
||||||
|
'photo[album_id]':"<%= @album.id %>"
|
||||||
|
},
|
||||||
|
|
||||||
// Specify what files to browse for
|
// Resize images on clientside if we can
|
||||||
filters : [
|
//resize : {width : 320, height : 240, quality : 90},
|
||||||
{title : "Image files", extensions : "jpg,gif,png,bmp,jpeg,tif,tiff"}
|
|
||||||
],
|
|
||||||
|
|
||||||
// Flash settings
|
// Specify what files to browse for
|
||||||
flash_swf_url : '/javascripts/plupload/js/plupload.flash.swf',
|
filters:[
|
||||||
|
{title:"Image files", extensions:"jpg,gif,png,bmp,jpeg,tif,tiff,JPG,GIF,PNG,BMP,JPEG,TIF,TIFF"}
|
||||||
|
],
|
||||||
|
|
||||||
// Silverlight settings
|
// Flash settings
|
||||||
silverlight_xap_url : '/javascripts/plupload/js/plupload.silverlight.xap',
|
flash_swf_url:'/javascripts/plupload/js/plupload.flash.swf',
|
||||||
|
|
||||||
// Post init events, bound after the internal events
|
|
||||||
init : {
|
|
||||||
|
|
||||||
FileUploaded: function(up, file, info) {
|
// Silverlight settings
|
||||||
// Called when a file has finished uploading
|
silverlight_xap_url:'/javascripts/plupload/js/plupload.silverlight.xap',
|
||||||
res = info.response;
|
|
||||||
if (res.substring(0, 7) === "FILEID:") {
|
|
||||||
var image = $('<img>').appendTo('#thumbs')
|
|
||||||
image.css('display','none')
|
|
||||||
image.attr('src', res.substring(7) )
|
|
||||||
image.fadeIn('slow')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Client side form validation
|
// Post init events, bound after the internal events
|
||||||
$('form').submit(function(e) {
|
init:{
|
||||||
var uploader = $('#uploader').pluploadQueue();
|
|
||||||
|
|
||||||
// Validate number of uploaded files
|
FileUploaded:function (up, file, info) {
|
||||||
if (uploader.total.uploaded == 0) {
|
// Called when a file has finished uploading
|
||||||
// Files in queue upload them first
|
res = info.response;
|
||||||
if (uploader.files.length > 0) {
|
if (res.substring(0, 7) === "FILEID:") {
|
||||||
// When all files are uploaded submit form
|
var image = $('<img>').appendTo('#thumbs')
|
||||||
uploader.bind('UploadProgress', function() {
|
image.css('display', 'none')
|
||||||
if (uploader.total.uploaded == uploader.files.length)
|
image.attr('src', res.substring(7))
|
||||||
$('form').submit();
|
image.fadeIn('slow')
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
uploader.start();
|
// Client side form validation
|
||||||
} else
|
$('form').submit(function (e) {
|
||||||
alert('You must at least upload one file.');
|
var uploader = $('#uploader').pluploadQueue();
|
||||||
|
|
||||||
e.preventDefault();
|
// Validate number of uploaded files
|
||||||
}
|
if (uploader.total.uploaded == 0) {
|
||||||
});
|
// Files in queue upload them first
|
||||||
})
|
if (uploader.files.length > 0) {
|
||||||
</script>
|
// When all files are uploaded submit form
|
||||||
|
uploader.bind('UploadProgress', function () {
|
||||||
|
if (uploader.total.uploaded == uploader.files.length)
|
||||||
|
$('form').submit();
|
||||||
|
});
|
||||||
|
uploader.start();
|
||||||
|
} else
|
||||||
|
alert('You must at least upload one file.');
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
</script>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<form>
|
<form>
|
||||||
<div id="uploader">
|
<div id="uploader">
|
||||||
<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
|
<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<br>
|
||||||
<br>
|
<div id="thumbs"></div>
|
||||||
<div id="thumbs"></div>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<br><%= link_to "Edit uploaded photos", untouched_album_photos_path( @album ) %>
|
<br><%= link_to "Edit uploaded photos", untouched_album_photos_path(@album) %>
|
||||||
<br><%= link_to "Back to #{@album.title}", @album %>
|
<br><%= link_to "Back to #{@album.title}", @album %>
|
|
@ -14,6 +14,8 @@ module Balder
|
||||||
config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/middleware/)
|
config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/middleware/)
|
||||||
|
|
||||||
config.encoding = "utf-8"
|
config.encoding = "utf-8"
|
||||||
|
config.i18n.default_locale = :ru
|
||||||
|
config.time_zone = 'Moscow'
|
||||||
|
|
||||||
# Configure sensitive parameters which will be filtered from the log file.
|
# Configure sensitive parameters which will be filtered from the log file.
|
||||||
config.filter_parameters += [:password, :password_confirmation]
|
config.filter_parameters += [:password, :password_confirmation]
|
||||||
|
|
22
config/initializers/to_url.rb
Normal file
22
config/initializers/to_url.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
String.class_eval do
|
||||||
|
def to_url
|
||||||
|
self.parameterize
|
||||||
|
end
|
||||||
|
|
||||||
|
def linkify
|
||||||
|
result = self.downcase
|
||||||
|
result.gsub!(/&(\d)+;/, '') # Ditch Entities
|
||||||
|
result.gsub!('&', 'and') # Replace & with 'and'
|
||||||
|
result.gsub!(/['"]/, '') # replace quotes by nothing
|
||||||
|
result.gsub!(/\W/, ' ') # strip all non word chars
|
||||||
|
result.gsub!(/\ +/, '-') # replace all white space sections with a dash
|
||||||
|
result.gsub!(/(-)$/, '') # trim dashes
|
||||||
|
result.gsub!(/^(-)/, '') # trim dashes
|
||||||
|
result.gsub!(/[^a-zA-Z0-9\-]/, '-') # Get rid of anything we don't like
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def linkify!
|
||||||
|
self.replace(self.linkify)
|
||||||
|
end
|
||||||
|
end
|
40
db/schema.rb
40
db/schema.rb
|
@ -16,8 +16,8 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
|
||||||
create_table "albums", :force => true do |t|
|
create_table "albums", :force => true do |t|
|
||||||
t.string "title", :null => false
|
t.string "title", :null => false
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
t.text "path"
|
t.text "path"
|
||||||
t.string "address"
|
t.string "address"
|
||||||
t.float "longitude"
|
t.float "longitude"
|
||||||
|
@ -30,8 +30,8 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
|
||||||
create_table "collection_albums", :force => true do |t|
|
create_table "collection_albums", :force => true do |t|
|
||||||
t.integer "collection_id"
|
t.integer "collection_id"
|
||||||
t.integer "album_id"
|
t.integer "album_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "collection_albums", ["album_id"], :name => "index_collection_albums_on_album_id"
|
add_index "collection_albums", ["album_id"], :name => "index_collection_albums_on_album_id"
|
||||||
|
@ -40,8 +40,8 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
|
||||||
create_table "collections", :force => true do |t|
|
create_table "collections", :force => true do |t|
|
||||||
t.string "title", :null => false
|
t.string "title", :null => false
|
||||||
t.string "description"
|
t.string "description"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "collections", ["id"], :name => "index_collections_on_id", :unique => true
|
add_index "collections", ["id"], :name => "index_collections_on_id", :unique => true
|
||||||
|
@ -51,15 +51,15 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
|
||||||
t.string "permissible_type"
|
t.string "permissible_type"
|
||||||
t.string "action"
|
t.string "action"
|
||||||
t.boolean "granted"
|
t.boolean "granted"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "photo_tags", :force => true do |t|
|
create_table "photo_tags", :force => true do |t|
|
||||||
t.integer "tag_id"
|
t.integer "tag_id"
|
||||||
t.integer "photo_id"
|
t.integer "photo_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "photo_tags", ["photo_id"], :name => "index_photo_tags_on_photo_id"
|
add_index "photo_tags", ["photo_id"], :name => "index_photo_tags_on_photo_id"
|
||||||
|
@ -69,8 +69,8 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
|
||||||
t.string "title", :null => false
|
t.string "title", :null => false
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.integer "album_id"
|
t.integer "album_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
t.text "path"
|
t.text "path"
|
||||||
t.float "longitude"
|
t.float "longitude"
|
||||||
t.float "latitude"
|
t.float "latitude"
|
||||||
|
@ -84,20 +84,20 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
|
||||||
t.integer "roleable_id"
|
t.integer "roleable_id"
|
||||||
t.string "roleable_type"
|
t.string "roleable_type"
|
||||||
t.integer "role_id"
|
t.integer "role_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "roles", :force => true do |t|
|
create_table "roles", :force => true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "tags", :force => true do |t|
|
create_table "tags", :force => true do |t|
|
||||||
t.string "title", :null => false
|
t.string "title", :null => false
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "tags", ["id"], :name => "index_tags_on_id", :unique => true
|
add_index "tags", ["id"], :name => "index_tags_on_id", :unique => true
|
||||||
|
@ -116,8 +116,8 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
|
||||||
t.datetime "last_login_at"
|
t.datetime "last_login_at"
|
||||||
t.string "current_login_ip"
|
t.string "current_login_ip"
|
||||||
t.string "last_login_ip"
|
t.string "last_login_ip"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
t.string "name"
|
t.string "name"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue