freeberry 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/README.rdoc +12 -5
  2. data/app/controllers/manage/assets_controller.rb +13 -3
  3. data/config/locales/manage/en.yml +13 -0
  4. data/config/locales/manage/ru.yml +13 -0
  5. data/config/locales/manage/uk.yml +14 -1
  6. data/config/routes.rb +4 -2
  7. data/lib/freeberry.rb +3 -0
  8. data/lib/freeberry/controllers/authorized_system.rb +1 -23
  9. data/lib/freeberry/header_tools.rb +8 -14
  10. data/lib/freeberry/models/asset.rb +16 -14
  11. data/lib/freeberry/models/comment.rb +11 -14
  12. data/lib/freeberry/models/header.rb +0 -2
  13. data/lib/freeberry/railtie.rb +10 -10
  14. data/lib/freeberry/utils.rb +7 -0
  15. data/lib/freeberry/version.rb +1 -1
  16. data/lib/generators/freeberry/base/templates/helpers/manage/assets_helper.rb +2 -4
  17. data/lib/generators/freeberry/base/templates/javascripts/rails.js +40 -32
  18. data/lib/generators/freeberry/base/templates/views/layouts/application.html.erb +1 -1
  19. data/lib/generators/freeberry/base/templates/views/layouts/manage.html.erb +1 -1
  20. data/lib/generators/freeberry/base/templates/views/manage/assets/_collection.html.erb +18 -5
  21. data/lib/generators/freeberry/base/templates/views/manage/assets/_picture.html.erb +2 -2
  22. data/lib/generators/freeberry/base/templates/views/manage/assets/_swfscript.html.erb +1 -1
  23. data/lib/generators/freeberry/base/templates/views/manage/posts/_form.html.erb +6 -6
  24. data/lib/generators/freeberry/base/templates/views/manage/structures/_form.html.erb +1 -1
  25. data/lib/generators/freeberry/manage_scaffold/templates/multiplay/views/model_filter.html.erb +3 -3
  26. data/lib/generators/freeberry/manage_scaffold/templates/single/views/model_filter.html.erb +4 -4
  27. data/lib/generators/freeberry/models/templates/create_assets.rb +1 -0
  28. data/lib/generators/freeberry/models/templates/models/avatar.rb +2 -2
  29. data/lib/generators/freeberry/models/templates/models/comment.rb +31 -0
  30. data/lib/generators/freeberry/models/templates/models/picture.rb +4 -1
  31. data/lib/generators/freeberry/models/templates/models/structure.rb +3 -1
  32. metadata +4 -4
data/README.rdoc CHANGED
@@ -10,16 +10,17 @@ For more instruction see {Wiki}[http://wiki.github.com/galetahub/freeberry].
10
10
  In your Gemfile:
11
11
 
12
12
  gem 'devise', '1.1.3'
13
- gem 'paperclip', '2.3.3'
14
- gem 'nokogiri', '1.4.3.1'
13
+ gem 'paperclip', '2.3.6'
14
+ gem 'nokogiri', '1.4.4'
15
15
  gem 'declarative_authorization', '0.5.1'
16
16
  gem 'responders', '0.6.2'
17
17
  gem 'inherited_resources', '1.1.2'
18
18
  gem 'haddock', '0.2.2'
19
- gem 'will_paginate', '2.3.15'
20
19
  gem "mime-types", '1.16', :require => 'mime/types'
20
+ gem "ckeditor", '3.4.3.pre'
21
21
 
22
- gem "ckeditor", :git => 'git://github.com/galetahub/rails-ckeditor.git', :branch => 'rails3'
22
+ gem 'awesome_nested_set', :git => 'git://github.com/galetahub/awesome_nested_set.git'
23
+ gem 'will_paginate', :git => 'git://github.com/galetahub/will_paginate.git', :branch => 'rails3'
23
24
  gem "freeberry", :git => "git://github.com/galetahub/freeberry.git"
24
25
 
25
26
  Bundler
@@ -29,7 +30,6 @@ Bundler
29
30
  Plugins:
30
31
 
31
32
  rails plugin install git://github.com/galetahub/enum_field.git
32
- rails plugin install git://github.com/galetahub/awesome_nested_set.git
33
33
  rails plugin install git://github.com/galetahub/salty_slugs.git
34
34
  rails plugin install git://github.com/galetahub/auto_html.git
35
35
  rails plugin install git://github.com/galetahub/attach_file_field.git
@@ -37,31 +37,38 @@ Plugins:
37
37
  === Generators
38
38
 
39
39
  Plugin attach_file_field wants generate assets:
40
+
40
41
  rails generate attach_file_field
41
42
 
42
43
  Devise (http://github.com/plataformatec/devise)
44
+
43
45
  rails generate devise:install
44
46
 
45
47
  Ckeditor (http://github.com/galetahub/rails-ckeditor)
48
+
46
49
  rails generate ckeditor:base
47
50
  rails generate ckeditor:migration
48
51
 
49
52
  Freeberry
53
+
50
54
  rails generate freeberry:base
51
55
  rails generate freeberry:models
52
56
 
53
57
  === Configuration
54
58
 
55
59
  Create yml files:
60
+
56
61
  cp config/application.yml.sample config/application.yml
57
62
  cp config/database.yml.sample config/database.yml
58
63
 
59
64
  Create database and load seed data:
65
+
60
66
  rake db:create
61
67
  rake db:migrate
62
68
  rake db:seed
63
69
 
64
70
  In config/application.rb:
71
+
65
72
  config.autoload_paths += %W( #{config.root}/app/models/defaults )
66
73
 
67
74
  == Usage
@@ -1,10 +1,11 @@
1
1
  class Manage::AssetsController < Manage::BaseController
2
- before_filter :find_klass, :only => [:create]
2
+ before_filter :find_klass, :only => [:create, :sort]
3
3
  before_filter :find_asset, :only => [:destroy]
4
4
 
5
+ filter_access_to :sort, :require => :update
6
+
5
7
  respond_to :html, :xml
6
8
 
7
- # POST /manage/assets
8
9
  def create
9
10
  @asset ||= @klass.new(params[:asset])
10
11
 
@@ -21,7 +22,6 @@ class Manage::AssetsController < Manage::BaseController
21
22
  end
22
23
  end
23
24
 
24
- # DELETE /manage/assets/1
25
25
  def destroy
26
26
  @asset.destroy
27
27
 
@@ -30,6 +30,16 @@ class Manage::AssetsController < Manage::BaseController
30
30
  end
31
31
  end
32
32
 
33
+ def sort
34
+ params[:picture].each_with_index do |id, index|
35
+ @klass.move_to(index, id)
36
+ end
37
+
38
+ respond_with(@klass) do |format|
39
+ format.html { head :ok }
40
+ end
41
+ end
42
+
33
43
  protected
34
44
 
35
45
  def find_asset
@@ -200,6 +200,19 @@ en:
200
200
  created_at_asc: "date ascending"
201
201
  title_desc: "by title descending"
202
202
  title_asc: "by title ascending"
203
+
204
+ sort_columns:
205
+ _: "-"
206
+ created_at_desc: "by date descending"
207
+ created_at_asc: "date ascending"
208
+ title_desc: "by title descending"
209
+ title_asc: "by title ascending"
210
+ name_desc: "by name descending"
211
+ name_asc: "by name ascending"
212
+ position_desc: "the attitude of descending"
213
+ position_asc: "for the position of the ascending"
214
+ sort_order_desc: "to sort in descending order"
215
+ sort_order_asc: "to sort in ascending order"
203
216
 
204
217
  flash:
205
218
  manage:
@@ -200,6 +200,19 @@ ru:
200
200
  created_at_asc: "по дате по возрастанию"
201
201
  title_desc: "по названию по убыванию"
202
202
  title_asc: "по названию по возрастанию"
203
+
204
+ sort_columns:
205
+ _: "-"
206
+ created_at_desc: "по дате по убыванию"
207
+ created_at_asc: "по дате по возрастанию"
208
+ title_desc: "по названию по убыванию"
209
+ title_asc: "по названию по возрастанию"
210
+ name_desc: "по названию по убыванию"
211
+ name_asc: "по названию по возрастанию"
212
+ position_desc: "за позицией по убыванию"
213
+ position_asc: "за позицией по возрастанию"
214
+ sort_order_desc: "по сортировке по убыванию"
215
+ sort_order_asc: "по сортировке по возрастанию"
203
216
 
204
217
  flash:
205
218
  manage:
@@ -200,12 +200,25 @@ uk:
200
200
  created_at_asc: "за датою за зростанням"
201
201
  title_desc: "за назвою за спаданням"
202
202
  title_asc: "за назвою за зростанням"
203
+
204
+ sort_columns:
205
+ _: "-"
206
+ created_at_desc: "за датою за спаданням"
207
+ created_at_asc: "за датою за зростанням"
208
+ title_desc: "за назвою за спаданням"
209
+ title_asc: "за назвою за зростанням"
210
+ name_desc: "за назвою за спаданням"
211
+ name_asc: "за назвою за зростанням"
212
+ position_desc: "за позицією за спаданням"
213
+ position_asc: "за позицією за зростанням"
214
+ sort_order_desc: "по сортуванню за спаданням"
215
+ sort_order_asc: "по сортуванню за зростанням"
203
216
 
204
217
  flash:
205
218
  manage:
206
219
  actions:
207
220
  create:
208
- success: "Запис успішно створена"
221
+ success: "Запис успішно створено"
209
222
  failure: "Виникли помилки при збереженні даних"
210
223
  update:
211
224
  success: "Запис успішно оновлено"
data/config/routes.rb CHANGED
@@ -16,8 +16,10 @@ Rails.application.routes.draw do
16
16
  resources :posts
17
17
  end
18
18
 
19
+ resources :assets, :only => [:create, :destroy] do
20
+ post :sort, :on => :collection
21
+ end
22
+
19
23
  resources :settings
20
- resources :pictures
21
- resources :assets, :only => [:create, :destroy]
22
24
  end
23
25
  end
data/lib/freeberry.rb CHANGED
@@ -9,6 +9,7 @@ module Freeberry
9
9
  autoload :ModelFilter, 'freeberry/model_filter'
10
10
  autoload :Transliteration, 'freeberry/transliteration'
11
11
  autoload :AccessibleAttributes, 'freeberry/accessible_attributes'
12
+ autoload :Utils, 'freeberry/utils'
12
13
 
13
14
  # Controllers
14
15
  module Controllers
@@ -31,6 +32,8 @@ module Freeberry
31
32
  autoload :Asset, 'freeberry/models/asset'
32
33
  autoload :Header, 'freeberry/models/header'
33
34
  end
35
+
36
+ IMAGE_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/jpg', 'image/pjpeg', 'image/tiff', 'image/x-png']
34
37
  end
35
38
 
36
39
  require 'freeberry/railtie'
@@ -8,7 +8,7 @@ module Freeberry
8
8
  # Send current_user to Declarative authorization module
9
9
  base.before_filter :set_current_user
10
10
 
11
- base.helper_method :content_manager?, :current_client, :client_logged_in?, :account_signed_in?
11
+ base.helper_method :content_manager?
12
12
  end
13
13
 
14
14
  module ClassMethods
@@ -49,28 +49,6 @@ module Freeberry
49
49
  def content_manager?
50
50
  user_signed_in? && current_user.admin?
51
51
  end
52
-
53
- # For RPXNow
54
- def client_logged_in?
55
- !!current_client
56
- end
57
-
58
- def current_client=(new_client)
59
- session[:client_id] = new_client ? new_client.id : nil
60
- @current_client = new_client || false
61
- end
62
-
63
- def current_client
64
- @current_client ||= client_login_from_session unless @current_client == false
65
- end
66
-
67
- def client_login_from_session
68
- self.current_client = RpxClient.find_by_id(session[:client_id]) if session[:client_id]
69
- end
70
-
71
- def account_signed_in?
72
- user_signed_in? || client_logged_in?
73
- end
74
52
  end
75
53
  end
76
54
  end
@@ -2,29 +2,23 @@
2
2
  module Freeberry
3
3
  module HeaderTools
4
4
  def self.included(base)
5
- base.extend(ClassMethods)
5
+ base.send(:extend, ClassMethods)
6
+ base.send(:include, InstanceMethods)
6
7
  end
7
8
 
8
9
  module ClassMethods
9
10
  def self.extended(base)
10
- base.has_one :header, :as=>:headerable, :dependent=>:destroy
11
- base.after_update :save_header
12
-
13
- base.send :include, InstanceMethods
11
+ base.class_eval do
12
+ has_one :header, :as => :headerable, :dependent => :delete
13
+ accepts_nested_attributes_for :header, :reject_if => :all_blank
14
+ end
14
15
  end
15
16
  end
16
17
 
17
18
  module InstanceMethods
18
- def page_header=(value)
19
- h = self.header || self.build_header
20
- h.attributes = value
19
+ def default_header
20
+ header || build_header
21
21
  end
22
-
23
- private
24
-
25
- def save_header
26
- self.header.save(:validate => false) unless self.header.nil?
27
- end
28
22
  end
29
23
  end
30
24
  end
@@ -14,9 +14,13 @@ module Freeberry
14
14
  belongs_to :assetable, :polymorphic => true
15
15
 
16
16
  before_validation :make_content_type
17
- before_create :read_dimensions, :parameterize_file_name
17
+ before_create :read_dimensions, :parameterize_filename
18
18
  end
19
19
  end
20
+
21
+ def move_to(index, id)
22
+ update_all(["sort_order = ?", index], ["id = ?", id.to_i])
23
+ end
20
24
  end
21
25
 
22
26
  module InstanceMethods
@@ -45,7 +49,7 @@ module Freeberry
45
49
  end
46
50
 
47
51
  def format_created_at
48
- I18n.l(self.created_at, :format=>"%d.%m.%Y %H:%M")
52
+ I18n.l(created_at, :format => "%d.%m.%Y %H:%M")
49
53
  end
50
54
 
51
55
  def to_xml(options = {})
@@ -68,11 +72,11 @@ module Freeberry
68
72
  end
69
73
 
70
74
  def has_dimensions?
71
- self.respond_to?(:width) && self.respond_to?(:height)
75
+ respond_to?(:width) && respond_to?(:height)
72
76
  end
73
77
 
74
78
  def image?
75
- ["image/jpeg", "image/tiff", "image/png", "image/gif", "image/bmp"].include?(self.data_content_type)
79
+ Freeberry::IMAGE_TYPES.include?(data_content_type)
76
80
  end
77
81
 
78
82
  def geometry
@@ -82,6 +86,13 @@ module Freeberry
82
86
 
83
87
  protected
84
88
 
89
+ def parameterize_filename
90
+ unless data_file_name.blank?
91
+ filename = Freeberry::Utils.parameterize_filename(data_file_name)
92
+ self.data.instance_write(:file_name, filename)
93
+ end
94
+ end
95
+
85
96
  def read_dimensions
86
97
  if image? && has_dimensions?
87
98
  self.width = geometry.width
@@ -89,17 +100,8 @@ module Freeberry
89
100
  end
90
101
  end
91
102
 
92
- def parameterize_file_name
93
- unless data_file_name.blank?
94
- extension = File.extname(data_file_name).downcase
95
- filename = File.basename(data_file_name, extension).downcase.parameterize
96
-
97
- self.data.instance_write(:file_name, [filename, extension].join)
98
- end
99
- end
100
-
101
103
  def make_content_type
102
- if data_content_type == "application/octet-stream"
104
+ if data_content_type.blank? || data_content_type == "application/octet-stream"
103
105
  content_types = MIME::Types.type_for(filename)
104
106
  self.data_content_type = content_types.first.to_s unless content_types.empty?
105
107
  end
@@ -10,20 +10,13 @@ module Freeberry
10
10
  module ClassMethods
11
11
  def self.extended(base)
12
12
  base.class_eval do
13
- belongs_to :commentable, :polymorphic => true, :counter_cache => :comments_count
13
+ belongs_to :commentable, :polymorphic => true, :counter_cache => true
14
14
  belongs_to :author, :polymorphic => true
15
15
 
16
- validates :user_name, :presence => true, :length => { :maximum => 100 },
17
- :format => { :with => /\A[^[:cntrl:]\\<>\/&]*\z/ }
18
- validates :user_email, :presence => true, :length => { :within => 6..100 },
19
- :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
20
- validates :content, :presence => true, :length => { :maximum => 500 }
21
- validates :commentable_type, :presence => true, :inclusion => { :in => %w( Post Broadcast ) }
22
-
23
- validates :author_type, :inclusion => { :in => %w( User Client ) }, :allow_blank => true
24
-
25
16
  before_validation :make_author
26
17
 
18
+ scope :recently, order("#{quoted_table_name}.created_at DESC")
19
+ scope :siblings_for, lambda { |item| where(["commentable_type = ? AND commentable_id = ?", item.commentable_type, item.commentable_id]) }
27
20
  scope :follows, where(:is_follow => true)
28
21
  end
29
22
  end
@@ -31,16 +24,20 @@ module Freeberry
31
24
 
32
25
  module InstanceMethods
33
26
  def comments_count
34
- @comments_count ||= self.class.count(:conditions=>["commentable_id = ? AND commentable_type = ?", self.commentable_id, self.commentable_type])
27
+ @comments_count ||= siblings.count
35
28
  @comments_count
36
29
  end
30
+
31
+ def siblings
32
+ self.class.siblings_for(self)
33
+ end
37
34
 
38
35
  protected
39
36
 
40
37
  def make_author
41
- unless self.author.nil?
42
- self.user_email = self.author.email
43
- self.user_name = self.author.name
38
+ unless author.nil?
39
+ self.user_email = author.email if author.respond_to?(:email)
40
+ self.user_name = author.name if author.respond_to?(:name)
44
41
  end
45
42
  end
46
43
  end
@@ -10,8 +10,6 @@ module Freeberry
10
10
  module ClassMethods
11
11
  def self.extended(base)
12
12
  base.class_eval do
13
- validates_presence_of :headerable_type, :headerable_id
14
-
15
13
  belongs_to :headerable, :polymorphic => true
16
14
  end
17
15
  end
@@ -5,26 +5,26 @@ require 'freeberry'
5
5
  module Freeberry
6
6
  class Engine < ::Rails::Engine
7
7
  config.before_initialize do
8
- ActiveSupport::XmlMini.backend = 'Nokogiri'
8
+ ::ActiveSupport::XmlMini.backend = 'Nokogiri'
9
9
 
10
- Responders::FlashResponder.flash_keys = [ :success, :failure ]
11
- InheritedResources.flash_keys = [ :success, :failure ]
10
+ ::Responders::FlashResponder.flash_keys = [ :success, :failure ]
11
+ ::InheritedResources.flash_keys = [ :success, :failure ]
12
12
 
13
13
  config.i18n.load_path += Dir[File.join(File.dirname(__FILE__), "../../config", 'locales', '**', '*.{rb,yml}').to_s]
14
14
 
15
- I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
15
+ ::I18n::Backend::Simple.send(:include, ::I18n::Backend::Pluralization)
16
16
 
17
- ActiveSupport.on_load :active_record do
18
- ActiveRecord::Base.send :include, Freeberry::MysqlUtils
19
- ActiveRecord::Base.send :include, Freeberry::AccessibleAttributes
17
+ ::ActiveSupport.on_load :active_record do
18
+ ::ActiveRecord::Base.send :include, Freeberry::MysqlUtils
19
+ ::ActiveRecord::Base.send :include, Freeberry::AccessibleAttributes
20
20
  end
21
21
  end
22
22
 
23
23
  config.after_initialize do
24
- ActionController::Base.send :include, Freeberry::Controllers::AuthorizedSystem
25
- ActionController::Base.send :include, Freeberry::Controllers::HeadOptions
24
+ ::ActionController::Base.send :include, Freeberry::Controllers::AuthorizedSystem
25
+ ::ActionController::Base.send :include, Freeberry::Controllers::HeadOptions
26
26
 
27
- ActionView::Base.send :include, Freeberry::Controllers::HelperTools
27
+ ::ActionView::Base.send :include, Freeberry::Controllers::HelperTools
28
28
  end
29
29
 
30
30
  rake_tasks do
@@ -2,6 +2,13 @@
2
2
  module Freeberry
3
3
  class Utils
4
4
  class << self
5
+ def parameterize_filename(filename)
6
+ extension = File.extname(filename)
7
+ basename = filename.gsub(/#{extension}$/, "")
8
+
9
+ [basename.parameterize('_'), extension].join.downcase
10
+ end
11
+
5
12
  def form_field(form_name, field_name, column, options={})
6
13
  field = case column.type
7
14
  when :string, :binary, :integer, :float, :decimal then
@@ -2,7 +2,7 @@ module Freeberry
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- RELEASE = 5
5
+ RELEASE = 6
6
6
 
7
7
  def self.dup
8
8
  "#{MAJOR}.#{MINOR}.#{RELEASE}"
@@ -1,12 +1,10 @@
1
1
  module Manage::AssetsHelper
2
2
 
3
- def manage_assets_path_with_session_information(klass='Asset', options = {})
4
- options.symbolize_keys!
3
+ def manage_assets_path_with_session_information(klass = 'Asset', options = {})
4
+ options = { :format => :xml, :protocol => "http://" }.merge(options)
5
5
  session_key = Rails.application.config.send(:session_options)[:key]
6
6
 
7
7
  options[session_key] = Rack::Utils.escape(cookies[session_key])
8
- options[:format] = :xml
9
- options[:protocol] = "http://"
10
8
  options[:klass] = klass
11
9
 
12
10
  if protect_against_forgery?
@@ -1,3 +1,12 @@
1
+ /*
2
+ * jquery-ujs
3
+ *
4
+ * http://github.com/rails/jquery-ujs/blob/master/src/rails.js
5
+ *
6
+ * This rails.js file supports jQuery 1.4.3 and 1.4.4 .
7
+ *
8
+ */
9
+
1
10
  jQuery(function ($) {
2
11
  var csrf_token = $('meta[name=csrf-token]').attr('content'),
3
12
  csrf_param = $('meta[name=csrf-param]').attr('content');
@@ -19,16 +28,22 @@ jQuery(function ($) {
19
28
  },
20
29
 
21
30
  /**
22
- * Handles execution of remote calls firing overridable events along the way
31
+ * Handles execution of remote calls. Provides following callbacks:
32
+ *
33
+ * - ajax:before - is execute before the whole thing begings
34
+ * - ajax:beforeSend - is executed before firing ajax call
35
+ * - ajax:success - is executed when status is success
36
+ * - ajax:complete - is executed when the request finishes, whether in failure or success.
37
+ * - ajax:error - is execute in case of error
23
38
  */
24
39
  callRemote: function () {
25
40
  var el = this,
26
41
  method = el.attr('method') || el.attr('data-method') || 'GET',
27
42
  url = el.attr('action') || el.attr('href'),
28
- dataType = el.attr('data-type') || 'script';
43
+ dataType = el.attr('data-type') || ($.ajaxSettings && $.ajaxSettings.dataType);
29
44
 
30
45
  if (url === undefined) {
31
- throw "No URL specified for remote call (action or href must be present).";
46
+ throw "No URL specified for remote call (action or href must be present).";
32
47
  } else {
33
48
  if (el.triggerAndReturn('ajax:before')) {
34
49
  var data = el.is('form') ? el.serializeArray() : [];
@@ -38,7 +53,8 @@ jQuery(function ($) {
38
53
  dataType: dataType,
39
54
  type: method.toUpperCase(),
40
55
  beforeSend: function (xhr) {
41
- el.trigger('ajax:loading', xhr);
56
+ xhr.setRequestHeader("Accept", "text/javascript");
57
+ el.trigger('ajax:beforeSend', xhr);
42
58
  },
43
59
  success: function (data, status, xhr) {
44
60
  el.trigger('ajax:success', [data, status, xhr]);
@@ -47,12 +63,10 @@ jQuery(function ($) {
47
63
  el.trigger('ajax:complete', xhr);
48
64
  },
49
65
  error: function (xhr, status, error) {
50
- el.trigger('ajax:failure', [xhr, status, error]);
66
+ el.trigger('ajax:error', [xhr, status, error]);
51
67
  }
52
68
  });
53
69
  }
54
-
55
- el.trigger('ajax:after');
56
70
  }
57
71
  }
58
72
  });
@@ -60,28 +74,16 @@ jQuery(function ($) {
60
74
  /**
61
75
  * confirmation handler
62
76
  */
63
- var jqueryVersion = $().jquery;
64
77
 
65
- if ( (jqueryVersion === '1.4') || (jqueryVersion === '1.4.1') || (jqueryVersion === '1.4.2')){
66
- $('a[data-confirm],input[data-confirm]').live('click.rails', function () {
67
- var el = $(this);
68
- if (el.triggerAndReturn('confirm')) {
69
- if (!confirm(el.attr('data-confirm'))) {
70
- return false;
71
- }
72
- }
73
- });
74
- } else {
75
- $('body').delegate('a[data-confirm],input[data-confirm]', 'click.rails', function () {
76
- var el = $(this);
77
- if (el.triggerAndReturn('confirm')) {
78
- if (!confirm(el.attr('data-confirm'))) {
79
- return false;
80
- }
81
- }
82
- });
83
- }
84
-
78
+ $('body').delegate('a[data-confirm], button[data-confirm], input[data-confirm]', 'click.rails', function () {
79
+ var el = $(this);
80
+ if (el.triggerAndReturn('confirm')) {
81
+ if (!confirm(el.attr('data-confirm'))) {
82
+ return false;
83
+ }
84
+ }
85
+ });
86
+
85
87
 
86
88
 
87
89
  /**
@@ -104,8 +106,8 @@ jQuery(function ($) {
104
106
  form = $('<form method="post" action="'+href+'"></form>'),
105
107
  metadata_input = '<input name="_method" value="'+method+'" type="hidden" />';
106
108
 
107
- if (csrf_param != null && csrf_token != null) {
108
- metadata_input += '<input name="'+csrf_param+'" value="'+csrf_token+'" type="hidden" />';
109
+ if (csrf_param !== undefined && csrf_token !== undefined) {
110
+ metadata_input += '<input name="'+csrf_param+'" value="'+csrf_token+'" type="hidden" />';
109
111
  }
110
112
 
111
113
  form.hide()
@@ -132,10 +134,10 @@ jQuery(function ($) {
132
134
  });
133
135
  };
134
136
 
135
- $(disable_with_form_remote_selector).live('ajax:before', disable_with_input_function);
137
+ $(disable_with_form_remote_selector).live('ajax:before.rails', disable_with_input_function);
136
138
  $(disable_with_form_not_remote_selector).live('submit.rails', disable_with_input_function);
137
139
 
138
- $(disable_with_form_remote_selector).live('ajax:complete', function () {
140
+ $(disable_with_form_remote_selector).live('ajax:complete.rails', function () {
139
141
  $(this).find(disable_with_input_selector).each(function () {
140
142
  var input = $(this);
141
143
  input.removeAttr('disabled')
@@ -143,4 +145,10 @@ jQuery(function ($) {
143
145
  });
144
146
  });
145
147
 
148
+ var jqueryVersion = $().jquery;
149
+
150
+ if ( (jqueryVersion === '1.4') || (jqueryVersion === '1.4.1') || (jqueryVersion === '1.4.2') ){
151
+ alert('This rails.js does not support the jQuery version you are using. Please read documentation.');
152
+ }
153
+
146
154
  });
@@ -14,7 +14,7 @@
14
14
  <script src="https://www.google.com/jsapi?key=" type="text/javascript"></script>
15
15
  <script language="Javascript" type="text/javascript">
16
16
  //<![CDATA[
17
- google.load("jquery", "1.4.3");
17
+ google.load("jquery", "1.4.4");
18
18
  google.load("swfobject", "2.2");
19
19
  //]]>
20
20
  </script>
@@ -11,7 +11,7 @@
11
11
  <script src="https://www.google.com/jsapi?key=" type="text/javascript"></script>
12
12
  <script language="Javascript" type="text/javascript">
13
13
  //<![CDATA[
14
- google.load("jquery", "1.4.3");
14
+ google.load("jquery", "1.4.4");
15
15
  google.load("jqueryui", "1.8.6");
16
16
  google.load("swfobject", "2.2");
17
17
  //]]>
@@ -1,6 +1,6 @@
1
1
  <% unless model.new_record? %>
2
- <% javascript "jquery.fancybox-1.3.1.pack.js" %>
3
- <% stylesheet "jquery.fancybox-1.3.1.css" %>
2
+ <% javascript "jquery.fancybox-1.3.2.pack.js" %>
3
+ <% stylesheet "fancybox/jquery.fancybox-1.3.2.css" %>
4
4
 
5
5
  <div class="gray-blocks">
6
6
  <div style="padding: 20px;" class="bg-bl">
@@ -21,16 +21,29 @@
21
21
 
22
22
  <script type='text/javascript'>
23
23
  $(document).ready(function(){
24
- $("div.galery a.fancybox").fancybox({
24
+ /*$("div.galery a.fancybox").fancybox({
25
25
  'titleShow' : true,
26
26
  'transitionIn' : 'none',
27
27
  'transitionOut' : 'none'
28
- });
29
-
28
+ });*/
29
+
30
30
  $('div.galery a.del').bind("ajax:complete", function(){
31
31
  var pid = $(this).attr('href').replace('/manage/assets/', '');
32
32
  $('#picture_' + pid).fadeOut(1);
33
33
  });
34
+
35
+ $("div.galery").sortable({
36
+ revert: true,
37
+ update: function(event, ui){
38
+ var data = $('div.galery').sortable('serialize');
39
+ $.ajax({
40
+ url: "<%= sort_manage_assets_path(:klass => model.pictures.name) %>",
41
+ data: data,
42
+ dataType: 'script',
43
+ type: 'POST'
44
+ });
45
+ }
46
+ });
34
47
  });
35
48
  </script>
36
49
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= content_tag(:div, :class=>"ill", :id=>"picture_#{picture.id}") do %>
1
+ <%= content_tag(:div, :class=>"ill", :id => dom_id(picture)) do %>
2
2
  <%= link_to image_tag("manage/empty.gif", :alt=>t('manage.delete'), :title=>t('manage.delete')),
3
3
  manage_asset_path(picture),
4
4
  :remote => true,
@@ -6,5 +6,5 @@
6
6
  :confirm => t('manage.confirm_delete'),
7
7
  :class => "del" %>
8
8
 
9
- <%= link_to image_tag(picture.url(:thumb), :alt=>picture.filename, :title=>picture.filename), picture.url(:content), :class => "fancybox" %>
9
+ <%= link_to image_tag(picture.url(:thumb), :title => picture.filename), picture.url(:content), :class => "fancybox" %>
10
10
  <% end %>
@@ -17,7 +17,7 @@
17
17
  file_size_limit : "10 MB",
18
18
  file_types : "*.jpg;*.jpeg;*.png;*.gif", // or you could use something like: "*.doc;*.wpd;*.pdf",
19
19
  file_types_description : "All Images",
20
- file_upload_limit : 10,
20
+ file_upload_limit : 20,
21
21
  file_queue_limit : 0,
22
22
 
23
23
  // The event handler functions are defined in handlers.js
@@ -1,13 +1,10 @@
1
- <% javascript "calendar/ui.datepicker-#{I18n.locale}" %>
1
+ <% javascript "datepicker/jquery.ui.datepicker-#{I18n.locale}" %>
2
2
 
3
3
  <div class="edit-cont">
4
4
  <div class="inputs-bl">
5
5
  <%= form.label "title" %>
6
6
  <%= form.text_field "title", :class=>"text name" %>
7
-
8
- <%= form.label "content" %>
9
- <%= form.cktext_area "content", options_for_ckeditor %>
10
-
7
+
11
8
  <%= form.label :published_at %>
12
9
  <%= form.text_field :published_at %>
13
10
 
@@ -19,6 +16,9 @@
19
16
  dateFormat: 'dd.mm.yy'
20
17
  });
21
18
  });
22
- </script>
19
+ </script>
20
+
21
+ <%= form.label "content" %>
22
+ <%= form.cktext_area "content", options_for_ckeditor(:width => 860) %>
23
23
  </div>
24
24
  </div>
@@ -11,7 +11,7 @@
11
11
  <div class="bot-bg">
12
12
  <div class="wh-title"><%= t('manage.keywords') %></div>
13
13
  <div class="elem-bl">
14
- <%= fields_for "structure[page_header]", @structure.header || Header.new do |h| %>
14
+ <%= form.fields_for :header, @structure.header || Header.new do |h| %>
15
15
  <%= h.label "title" %><br/>
16
16
  <%= h.text_field "title", :class=>"text" %><br/>
17
17
 
@@ -19,11 +19,11 @@
19
19
  </div>
20
20
  <div class="sort">
21
21
  <label><%%= t('manage.sort') %></label>
22
- <div class="select"><%%= link_to_function t("manage.<%= plural_name %>.sort.#{@search.order_column}_#{@search.order_type}"), "SelectList.toggle(event)", :class=>"corn", :id=>'sort_select' %></div>
22
+ <div class="select"><%%= link_to_function t("<%= plural_name %>.#{@search.order_column}_#{@search.order_type}", :scope => [:manage, :sort_columns], :default => :"#{@search.order_column}_#{@search.order_type}"), "SelectList.toggle(event)", :class=>"corn", :id=>'sort_select' %></div>
23
23
  <div id='sort_select_list' class="select-list" style='display:none;'>
24
24
  <% model.attributes.each do |attribute, value| -%>
25
- <%%= link_to_sort(t('manage.<%= plural_name %>.sort.<%= attribute %>_desc'), :name=><%= attribute.inspect %>, :order_type=>'desc') %>
26
- <%%= link_to_sort(t('manage.<%= plural_name %>.sort.<%= attribute %>_asc'), :name=><%= attribute.inspect %>, :order_type=>'asc') %>
25
+ <%%= link_to_sort(t('<%= plural_name %>.<%= attribute %>_desc', :scope => [:manage, :sort_columns], :default => :<%= attribute %>_desc), :name => <%= attribute.inspect %>, :order_type => 'desc') %>
26
+ <%%= link_to_sort(t('<%= plural_name %>.<%= attribute %>_asc', :scope => [:manage, :sort_columns], :default => :<%= attribute %>_asc), :name => <%= attribute.inspect %>, :order_type => 'asc') %>
27
27
  <% end %>
28
28
  </div>
29
29
  </div>
@@ -5,7 +5,7 @@
5
5
  <%%= cookie_content_tag(:div, :id=>"block_filter", :class=>"filt") do %>
6
6
  <%%= form_for @search, :as => :search, :url=>manage_<%= plural_name %>_path, :html=>{:method=>:get, :id=>"form_filter"} do |f| %>
7
7
  <% model.attributes.each do |attribute, value| -%>
8
- <%%= f.label :<%= attribute %>, t('activerecord.attributes.<%= singular_name %>.<%= attribute %>') %>
8
+ <%%= f.label :<%= attribute %>, t('<%= singular_name %>.<%= attribute %>', :scope => [:activerecord, :attributes]) %>
9
9
  <%%= f.text_field :<%= attribute %>, :class=>"text" %>
10
10
  <% end -%>
11
11
 
@@ -19,11 +19,11 @@
19
19
  </div>
20
20
  <div class="sort">
21
21
  <label><%%= t('manage.sort') %></label>
22
- <div class="select"><%%= link_to_function t("manage.<%= plural_name %>.sort.#{@search.order_column}_#{@search.order_type}"), "SelectList.toggle(event)", :class=>"corn", :id=>'sort_select' %></div>
22
+ <div class="select"><%%= link_to_function t("<%= plural_name %>.#{@search.order_column}_#{@search.order_type}", :scope => [:manage, :sort_columns], :default => :"#{@search.order_column}_#{@search.order_type}"), "SelectList.toggle(event)", :class=>"corn", :id=>'sort_select' %></div>
23
23
  <div id='sort_select_list' class="select-list" style='display:none;'>
24
24
  <% model.attributes.each do |attribute, value| %>
25
- <%%= link_to_sort(t('manage.<%= plural_name %>.sort.<%= attribute %>_desc'),:name => <%= attribute.inspect %>, :order_type => 'desc') %>
26
- <%%= link_to_sort(t('manage.<%= plural_name %>.sort.<%= attribute %>_asc'), :name => <%= attribute.inspect %>, :order_type => 'asc') %>
25
+ <%%= link_to_sort(t('<%= plural_name %>.<%= attribute %>_desc', :scope => [:manage, :sort_columns], :default => :<%= attribute %>_desc), :name => <%= attribute.inspect %>, :order_type => 'desc') %>
26
+ <%%= link_to_sort(t('<%= plural_name %>.<%= attribute %>_asc', :scope => [:manage, :sort_columns], :default => :<%= attribute %>_asc), :name => <%= attribute.inspect %>, :order_type => 'asc') %>
27
27
  <% end %>
28
28
  </div>
29
29
  </div>
@@ -12,6 +12,7 @@ class FreeberryCreateAssets < ActiveRecord::Migration
12
12
 
13
13
  t.integer :locale, :limit => 1, :default => 0
14
14
  t.integer :user_id
15
+ t.integer :sort_order, :default => 0
15
16
 
16
17
  t.timestamps
17
18
  end
@@ -29,10 +29,10 @@ class Avatar < Asset
29
29
  :url => "/assets/avatars/:id/:style_:basename.:extension",
30
30
  :path => ":rails_root/public/assets/avatars/:id/:style_:basename.:extension",
31
31
  :convert_options => { :all => "-strip" },
32
- :styles => { :thumb => "50x50#", :small=>"32x32#" }
32
+ :styles => { :thumb => "50x50#", :small => "32x32#" }
33
33
 
34
34
  validates_attachment_size :data, :less_than => 1.megabyte
35
- validates_attachment_content_type :data, :content_type => ['image/gif', 'image/jpeg', 'image/png', 'image/tiff', 'image/x-png']
35
+ validates_attachment_content_type :data, :content_type => Freeberry::IMAGE_TYPES
36
36
 
37
37
  attr_accessible :data
38
38
  end
@@ -3,10 +3,24 @@ class Comment < ActiveRecord::Base
3
3
 
4
4
  using_access_control
5
5
 
6
+ validates :content, :presence => true, :length => { :maximum => 500 }
7
+ validates :commentable_type, :presence => true, :inclusion => { :in => %w( Post Article ) }
8
+ validates :author_type, :inclusion => { :in => %w( User FreeberryAuth::Account ) }, :allow_blank => true
9
+
10
+ with_options :if => :anonymous? do |anonymous|
11
+ anonymous.validates :user_name, :length => { :maximum => 100 }, :presence => true,
12
+ :format => { :with => /\A[^[:cntrl:]\\<>\/&]*\z/ }
13
+ anonymous.validates :user_email, :length => { :within => 6..100 }, :presence => true,
14
+ :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
15
+ end
16
+
6
17
  attr_accessible :user_name, :user_email, :content, :is_follow
7
18
 
19
+ #after_create :send_notifiers
20
+
8
21
  auto_html_for :content do
9
22
  html_escape
23
+ big_words :length => 80, :tag => "span"
10
24
  image
11
25
  youtube :width => 500, :height => 300
12
26
  vimeo :width => 500, :height => 300
@@ -14,4 +28,21 @@ class Comment < ActiveRecord::Base
14
28
  simple_format
15
29
  sanitize
16
30
  end
31
+
32
+ def anonymous?
33
+ author.nil?
34
+ end
35
+
36
+ def siblings
37
+ self.class.siblings_for(self)
38
+ end
39
+
40
+ protected
41
+
42
+ def send_notifiers
43
+ emails = [ commentable.user.try(:email) ]
44
+ emails.concat(siblings.follows.select("user_email").map(&:user_email).uniq)
45
+ emails.delete_if{ |email| email.blank? || email == user_email }
46
+ emails.each { |email| Notifier.comment(email, self).deliver }
47
+ end
17
48
  end
@@ -27,9 +27,12 @@ class Picture < Asset
27
27
  :url => "/assets/pictures/:id/:style_:basename.:extension",
28
28
  :path => ":rails_root/public/assets/pictures/:id/:style_:basename.:extension",
29
29
  :convert_options => { :all => "-strip" },
30
- :styles => { :content => '575>', :thumb => '80x80#', :cover => '400x250#' }
30
+ :styles => { :content => '575>', :thumb => '80x80#' }
31
31
 
32
32
  validates_attachment_size :data, :less_than => 2.megabytes
33
+ validates_attachment_content_type :data, :content_type => Freeberry::IMAGE_TYPES
33
34
 
34
35
  attr_accessible :data
36
+
37
+ default_scope order("#{quoted_table_name}.sort_order")
35
38
  end
@@ -5,5 +5,7 @@ class Structure < ActiveRecord::Base
5
5
 
6
6
  has_slug :prepend_id => false
7
7
 
8
- attr_accessible :title, :kind, :position, :parent_id, :redirect_url
8
+ attr_accessible :title, :kind, :position, :parent_id, :redirect_url,
9
+ :position_type, :slug, :parent, :structure_type,
10
+ :header_attributes, :is_visible
9
11
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freeberry
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Igor Galeta
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-23 00:00:00 +02:00
19
+ date: 2010-12-01 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies: []
22
22