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
|
||||||
|
|
|
@ -39,24 +39,28 @@ class FileUploader < CarrierWave::Uploader::Base
|
||||||
# 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
|
def store_dir
|
||||||
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
version :album do
|
version :album do
|
||||||
process :resize_to_fill => [100, 100]
|
process :resize_to_fill => [100, 100]
|
||||||
|
|
||||||
def store_dir
|
def store_dir
|
||||||
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
version :preview do
|
version :preview do
|
||||||
process :resize_to_fit => [210, 210]
|
process :resize_to_fit => [210, 210]
|
||||||
|
|
||||||
def store_dir
|
def store_dir
|
||||||
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
version :single do
|
version :single do
|
||||||
process :resize_to_limit => [950, 950]
|
process :resize_to_limit => [950, 950]
|
||||||
|
|
||||||
def store_dir
|
def store_dir
|
||||||
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
<%= 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({
|
$("#uploader").pluploadQueue({
|
||||||
// General settings
|
// General settings
|
||||||
runtimes : 'flash,html5,browserplus,silverlight,gears',
|
runtimes:'flash,html5,browserplus,silverlight,gears',
|
||||||
url : '<%= photos_path %>',
|
url:'<%= photos_path %>',
|
||||||
max_file_size : '10mb',
|
max_file_size:'10mb',
|
||||||
multipart: true,
|
multipart:true,
|
||||||
multipart_params: {
|
multipart_params:{
|
||||||
'<%= get_session_key %>' : encodeURIComponent('<%= cookies[get_session_key] %>'),
|
'<%= get_session_key %>':encodeURIComponent('<%= cookies[get_session_key] %>'),
|
||||||
'authenticity_token' : '<%= form_authenticity_token %>',
|
'authenticity_token':'<%= form_authenticity_token %>',
|
||||||
'photo[album_id]' : "<%= @album.id %>"
|
'photo[album_id]':"<%= @album.id %>"
|
||||||
},
|
},
|
||||||
|
|
||||||
// Resize images on clientside if we can
|
// Resize images on clientside if we can
|
||||||
//resize : {width : 320, height : 240, quality : 90},
|
//resize : {width : 320, height : 240, quality : 90},
|
||||||
|
|
||||||
// Specify what files to browse for
|
// Specify what files to browse for
|
||||||
filters : [
|
filters:[
|
||||||
{title : "Image files", extensions : "jpg,gif,png,bmp,jpeg,tif,tiff"}
|
{title:"Image files", extensions:"jpg,gif,png,bmp,jpeg,tif,tiff,JPG,GIF,PNG,BMP,JPEG,TIF,TIFF"}
|
||||||
],
|
],
|
||||||
|
|
||||||
// Flash settings
|
// Flash settings
|
||||||
flash_swf_url : '/javascripts/plupload/js/plupload.flash.swf',
|
flash_swf_url:'/javascripts/plupload/js/plupload.flash.swf',
|
||||||
|
|
||||||
// Silverlight settings
|
// Silverlight settings
|
||||||
silverlight_xap_url : '/javascripts/plupload/js/plupload.silverlight.xap',
|
silverlight_xap_url:'/javascripts/plupload/js/plupload.silverlight.xap',
|
||||||
|
|
||||||
// Post init events, bound after the internal events
|
// Post init events, bound after the internal events
|
||||||
init : {
|
init:{
|
||||||
|
|
||||||
FileUploaded: function(up, file, info) {
|
FileUploaded:function (up, file, info) {
|
||||||
// Called when a file has finished uploading
|
// Called when a file has finished uploading
|
||||||
res = info.response;
|
res = info.response;
|
||||||
if (res.substring(0, 7) === "FILEID:") {
|
if (res.substring(0, 7) === "FILEID:") {
|
||||||
var image = $('<img>').appendTo('#thumbs')
|
var image = $('<img>').appendTo('#thumbs')
|
||||||
image.css('display','none')
|
image.css('display', 'none')
|
||||||
image.attr('src', res.substring(7) )
|
image.attr('src', res.substring(7))
|
||||||
image.fadeIn('slow')
|
image.fadeIn('slow')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Client side form validation
|
// Client side form validation
|
||||||
$('form').submit(function(e) {
|
$('form').submit(function (e) {
|
||||||
var uploader = $('#uploader').pluploadQueue();
|
var uploader = $('#uploader').pluploadQueue();
|
||||||
|
|
||||||
// Validate number of uploaded files
|
// Validate number of uploaded files
|
||||||
|
@ -57,30 +57,27 @@ $(document).ready(function() {
|
||||||
// Files in queue upload them first
|
// Files in queue upload them first
|
||||||
if (uploader.files.length > 0) {
|
if (uploader.files.length > 0) {
|
||||||
// When all files are uploaded submit form
|
// When all files are uploaded submit form
|
||||||
uploader.bind('UploadProgress', function() {
|
uploader.bind('UploadProgress', function () {
|
||||||
if (uploader.total.uploaded == uploader.files.length)
|
if (uploader.total.uploaded == uploader.files.length)
|
||||||
$('form').submit();
|
$('form').submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
uploader.start();
|
uploader.start();
|
||||||
} else
|
} else
|
||||||
alert('You must at least upload one file.');
|
alert('You must at least upload one file.');
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
</script>
|
</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