diff --git a/Gemfile b/Gemfile
index 3fb29ec..db27190 100644
--- a/Gemfile
+++ b/Gemfile
@@ -8,6 +8,7 @@ gem 'mime-types', :require => 'mime/types'
gem 'carrierwave', '0.6.2'
gem 'dynamic_form'
gem 'princely'
+gem 'russian', :git => 'git://github.com/yaroslav/russian.git'
# -- Heroku
#gem 'heroku'
diff --git a/Gemfile.lock b/Gemfile.lock
index 1701b11..094c9d0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,3 +1,10 @@
+GIT
+ remote: git://github.com/yaroslav/russian.git
+ revision: e2dde13672bcee176f8b0be364a55ac256913231
+ specs:
+ russian (0.6.0)
+ i18n (>= 0.5.0)
+
GEM
remote: http://rubygems.org/
specs:
@@ -123,4 +130,5 @@ DEPENDENCIES
mini_magick
princely
rails (= 3.2.6)
+ russian!
sqlite3-ruby
diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb
index 9c1ac16..f429525 100644
--- a/app/uploaders/file_uploader.rb
+++ b/app/uploaders/file_uploader.rb
@@ -5,11 +5,11 @@ class FileUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support
# include CarrierWave::RMagick
# include CarrierWave::ImageScience
- include CarrierWave::MiniMagick
+ include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader
if ENV['S3_KEY']
storage :fog
-
+
def cache_dir
"#{Rails.root.to_s}/tmp/uploads" if ENV['HEROKU'] == 'true'
end
@@ -37,36 +37,40 @@ class FileUploader < CarrierWave::Uploader::Base
# end
# Create different versions of your uploaded files
- version :collection do
- process :resize_to_fill => [200, 200]
- def store_dir
- ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
- end
- end
- version :album do
- process :resize_to_fill => [100, 100]
- def store_dir
- ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
- end
- end
- version :preview do
- process :resize_to_fit => [210, 210]
- def store_dir
- ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
- end
- end
- version :single do
- process :resize_to_limit => [950, 950]
- def store_dir
- ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
- end
- end
+ version :collection do
+ process :resize_to_fill => [200, 200]
+
+ def store_dir
+ ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
+ end
+ end
+ version :album do
+ process :resize_to_fill => [100, 100]
+
+ def store_dir
+ ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
+ end
+ end
+ version :preview do
+ process :resize_to_fit => [210, 210]
+
+ def store_dir
+ ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
+ end
+ end
+ version :single do
+ process :resize_to_limit => [950, 950]
+
+ def store_dir
+ ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
+ end
+ end
# Add a white list of extensions which are allowed to be uploaded,
# for images you might use something like this:
- def extension_white_list
- %w(jpg jpeg gif png bmp tiff)
- end
+ def extension_white_list
+ %w(jpg jpeg gif png bmp tiff)
+ end
# Override the filename of the uploaded files
# def filename
diff --git a/app/views/photos/upload.html.erb b/app/views/photos/upload.html.erb
index 25413ae..407d84b 100644
--- a/app/views/photos/upload.html.erb
+++ b/app/views/photos/upload.html.erb
@@ -1,86 +1,83 @@
<%= content_for :javascript do %>
-
-<%= 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/plupload.full.js" -%>
+ <%= javascript_include_tag "plupload/js/jquery.plupload.queue/jquery.plupload.queue.js" -%>
-
+ // Validate number of uploaded files
+ if (uploader.total.uploaded == 0) {
+ // Files in queue upload them first
+ if (uploader.files.length > 0) {
+ // 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();
+ }
+ });
+ })
+
<% end %>
-
<%= link_to "Edit uploaded photos", untouched_album_photos_path( @album ) %>
+
<%= link_to "Edit uploaded photos", untouched_album_photos_path(@album) %>
<%= link_to "Back to #{@album.title}", @album %>
\ No newline at end of file
diff --git a/config/application.rb b/config/application.rb
index 158f20e..61f1ca1 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -14,6 +14,8 @@ module Balder
config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/middleware/)
config.encoding = "utf-8"
+ config.i18n.default_locale = :ru
+ config.time_zone = 'Moscow'
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password, :password_confirmation]
diff --git a/config/initializers/to_url.rb b/config/initializers/to_url.rb
new file mode 100644
index 0000000..5db9279
--- /dev/null
+++ b/config/initializers/to_url.rb
@@ -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
\ No newline at end of file
diff --git a/db/schema.rb b/db/schema.rb
index 3bca3ad..f95ca4f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -16,8 +16,8 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
create_table "albums", :force => true do |t|
t.string "title", :null => false
t.text "description"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
t.text "path"
t.string "address"
t.float "longitude"
@@ -30,8 +30,8 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
create_table "collection_albums", :force => true do |t|
t.integer "collection_id"
t.integer "album_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
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|
t.string "title", :null => false
t.string "description"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
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 "action"
t.boolean "granted"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
create_table "photo_tags", :force => true do |t|
t.integer "tag_id"
t.integer "photo_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
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.text "description"
t.integer "album_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
t.text "path"
t.float "longitude"
t.float "latitude"
@@ -84,20 +84,20 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
t.integer "roleable_id"
t.string "roleable_type"
t.integer "role_id"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
create_table "roles", :force => true do |t|
t.string "name"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
create_table "tags", :force => true do |t|
t.string "title", :null => false
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
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.string "current_login_ip"
t.string "last_login_ip"
- t.datetime "created_at"
- t.datetime "updated_at"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
t.string "name"
end