freeberry 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,8 +9,8 @@ For more instruction see {Wiki}[http://wiki.github.com/galetahub/freeberry].
9
9
 
10
10
  In your Gemfile:
11
11
 
12
- gem 'devise', '1.1.3'
13
- gem 'paperclip', '2.3.6'
12
+ gem 'devise', '1.1.5'
13
+ gem 'paperclip', '2.3.7'
14
14
  gem 'nokogiri', '1.4.4'
15
15
  gem 'declarative_authorization', '0.5.1'
16
16
  gem 'responders', '0.6.2'
data/Rakefile CHANGED
@@ -36,15 +36,6 @@ begin
36
36
  gemspec.authors = ["Igor Galeta", "Pavlo Galeta"]
37
37
  gemspec.files = FileList["[A-Z]*", "{app,config,lib}/**/*"]
38
38
  gemspec.rubyforge_project = "freeberry"
39
-
40
- #gemspec.add_dependency('devise', '>= 1.1.3')
41
- #gemspec.add_dependency('paperclip', '>= 2.3.3')
42
- #gemspec.add_dependency('nokogiri', '>= 1.4.3.1')
43
- #gemspec.add_dependency('declarative_authorization', '>= 0.5.1')
44
- #gemspec.add_dependency('responders', '>= 0.6.2')
45
- #gemspec.add_dependency('inherited_resources', '>= 1.1.2')
46
- #gemspec.add_dependency('haddock', '>= 0.2.2')
47
- #gemspec.add_dependency('will_paginate', '>= 2.3.15')
48
39
  end
49
40
 
50
41
  Jeweler::GemcutterTasks.new
File without changes
@@ -5,7 +5,7 @@ module Freeberry
5
5
  autoload :SystemSettings, 'freeberry/system_settings'
6
6
  autoload :MysqlUtils, 'freeberry/mysql_utils'
7
7
  autoload :Settingslogic, 'freeberry/settingslogic'
8
- autoload :HeaderTools, 'freeberry/header_tools'
8
+ autoload :HeaderUtils, 'freeberry/header_utils'
9
9
  autoload :ModelFilter, 'freeberry/model_filter'
10
10
  autoload :Transliteration, 'freeberry/transliteration'
11
11
  autoload :AccessibleAttributes, 'freeberry/accessible_attributes'
@@ -15,7 +15,7 @@ module Freeberry
15
15
  module Controllers
16
16
  autoload :AuthorizedSystem, 'freeberry/controllers/authorized_system'
17
17
  autoload :HeadOptions, 'freeberry/controllers/head_options'
18
- autoload :HelperTools, 'freeberry/controllers/helper_tools'
18
+ autoload :HelperUtils, 'freeberry/controllers/helper_utils'
19
19
  end
20
20
 
21
21
  # Models
@@ -4,14 +4,19 @@ module Freeberry
4
4
  def self.included(base)
5
5
  base.send(:extend, ClassMethods)
6
6
  base.send(:include, InstanceMethods)
7
-
8
- # Send current_user to Declarative authorization module
9
- base.before_filter :set_current_user
10
-
11
- base.helper_method :content_manager?
12
7
  end
13
8
 
14
9
  module ClassMethods
10
+ def self.extended(base)
11
+ base.class_eval do
12
+ skip_before_filter :set_current_user
13
+
14
+ # Send current_user to Declarative authorization module
15
+ before_filter :set_current_user
16
+
17
+ helper_method :content_manager?
18
+ end
19
+ end
15
20
  end
16
21
 
17
22
  module InstanceMethods
@@ -7,25 +7,26 @@ module Freeberry
7
7
  base.send :helper_method, :head_options if base.respond_to? :helper_method
8
8
  end
9
9
 
10
- def head_options(record, options={})
10
+ def head_options(record, options = {})
11
11
  return if record.nil?
12
12
 
13
- header = nil
14
- header = record.header if record.respond_to?(:header)
13
+ options = { :spliter => " | " }.merge(options)
14
+
15
+ header = record.respond_to?(:header) ? record.header : nil
15
16
 
16
17
  @view_title = record.title if record.respond_to?(:title)
17
- @view_title ||= t('page.title')
18
+ @view_title ||= I18n.t('page.title')
18
19
 
19
20
  # title
20
21
  page_title = []
21
22
  page_title << options[:title] if options.key?(:title)
22
23
  page_title << ((header.nil? || header.title.blank?) ? record.title : header.title)
23
- page_title << t('page.title') if options[:append_title]
24
+ page_title << I18n.t('page.title') if options[:append_title]
24
25
  page_title.flatten!
25
26
  page_title.compact!
26
27
  page_title.uniq!
27
28
 
28
- @page_title = page_title.join(" | ")
29
+ @page_title = page_title.join(options[:spliter])
29
30
 
30
31
  # keywords
31
32
  keywords = record.keywords.join(', ') if record.respond_to?(:keywords)
@@ -1,6 +1,6 @@
1
1
  module Freeberry
2
2
  module Controllers
3
- module HelperTools
3
+ module HelperUtils
4
4
 
5
5
  def title(content)
6
6
  content_for(:title) { content } unless content.blank?
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Freeberry
3
- module HeaderTools
3
+ module HeaderUtils
4
4
  def self.included(base)
5
5
  base.send(:extend, ClassMethods)
6
6
  base.send(:include, InstanceMethods)
@@ -10,6 +10,9 @@ module Freeberry
10
10
  def self.extended(base)
11
11
  base.class_eval do
12
12
  has_one :header, :as => :headerable, :dependent => :delete
13
+
14
+ attr_accessible :header_attributes
15
+
13
16
  accepts_nested_attributes_for :header, :reject_if => :all_blank
14
17
  end
15
18
  end
@@ -9,7 +9,7 @@ module Freeberry
9
9
 
10
10
  module ClassMethods
11
11
  def self.extended(base)
12
- base.send(:include, HeaderTools)
12
+ base.send(:include, HeaderUtils)
13
13
  base.class_eval do
14
14
  belongs_to :structure
15
15
  has_many :comments, :as => :commentable, :dependent => :delete_all
@@ -9,7 +9,7 @@ module Freeberry
9
9
 
10
10
  module ClassMethods
11
11
  def self.extended(base)
12
- base.send(:include, HeaderTools)
12
+ base.send(:include, HeaderUtils)
13
13
  base.class_eval do
14
14
  enumerated_attribute :structure_type, :id_attribute => :kind
15
15
  enumerated_attribute :position_type, :id_attribute => :position
@@ -17,6 +17,8 @@ module Freeberry
17
17
 
18
18
  scope :admins, joins(:roles).where(["`roles`.role_type = ?", ::RoleType.admin.id])
19
19
  scope :with_role, proc {|role| joins(:roles).where(["`roles`.role_type = ?", role.id]) }
20
+
21
+ before_create :set_default_role, :if => :roles_empty?
20
22
  end
21
23
  end
22
24
  end
@@ -33,16 +35,15 @@ module Freeberry
33
35
  def has_role?(role_name)
34
36
  role_symbols.include?(role_name.to_sym)
35
37
  end
38
+
39
+ def roles_empty?
40
+ self.roles.empty?
41
+ end
36
42
 
37
43
  def roles_attributes=(value)
38
44
  options = value || {}
39
45
  options.each do |k, v|
40
- r = self.roles.detect { |r| r.role_type.id == k.to_i }
41
- if v.to_i == 0
42
- self.roles.delete(r) unless r.nil?
43
- else
44
- r ||= self.roles.build(:role_type => ::RoleType.find(k.to_i))
45
- end
46
+ create_or_destroy_role(k.to_i, v.to_i == 1)
46
47
  end
47
48
  end
48
49
 
@@ -64,7 +65,22 @@ module Freeberry
64
65
  end
65
66
 
66
67
  protected
67
-
68
+
69
+ def set_default_role
70
+ unless has_role?(:default)
71
+ self.roles.build(:role_type => ::RoleType.default)
72
+ end
73
+ end
74
+
75
+ def create_or_destroy_role(role_id, need_create = true)
76
+ role = self.roles.detect { |r| r.role_type.id == role_id }
77
+ if need_create
78
+ role ||= self.roles.build(:role_type => ::RoleType.find(role_id))
79
+ elsif !role.nil?
80
+ self.roles.delete(role)
81
+ end
82
+ end
83
+
68
84
  def make_login
69
85
  return if self.email.blank?
70
86
 
@@ -24,7 +24,7 @@ module Freeberry
24
24
  ::ActionController::Base.send :include, Freeberry::Controllers::AuthorizedSystem
25
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::HelperUtils
28
28
  end
29
29
 
30
30
  rake_tasks do
@@ -18,7 +18,7 @@ module Freeberry
18
18
  when :datetime, :date, :timestamp, :time then
19
19
  options[:extra_html] ||= "<script type='text/javascript'>
20
20
  $(function() {
21
- $('#_#{field_name}').datepicker({
21
+ $('\##{form_name}_#{field_name}').datepicker({
22
22
  numberOfMonths: 1,
23
23
  dateFormat: 'dd.mm.yy'
24
24
  });
@@ -1,8 +1,9 @@
1
+ # encoding: utf-8
1
2
  module Freeberry
2
3
  module Version
3
4
  MAJOR = 0
4
5
  MINOR = 2
5
- RELEASE = 6
6
+ RELEASE = 7
6
7
 
7
8
  def self.dup
8
9
  "#{MAJOR}.#{MINOR}.#{RELEASE}"
@@ -13,7 +13,7 @@
13
13
  <div class="dinamic-inner">
14
14
  <div class="r-block">
15
15
  <div class="r-block-cont">
16
- <%%= link_to <%= singular_name %>.name, edit_manage_<%= parent_singular_name %>_<%= singular_name %>_path(@<%= parent_singular_name %>.id, <%= singular_name %>.id), :class=>"title" %>
16
+ <%%= link_to <%= singular_name %>.title, edit_manage_<%= parent_singular_name %>_<%= singular_name %>_path(@<%= parent_singular_name %>.id, <%= singular_name %>.id), :class=>"title" %>
17
17
  </div>
18
18
  </div>
19
19
  </div>
@@ -13,7 +13,7 @@
13
13
  <div class="dinamic-inner">
14
14
  <div class="r-block">
15
15
  <div class="r-block-cont">
16
- <%%= link_to <%= singular_name %>.name, edit_manage_<%= singular_name %>_path(:id=><%= singular_name %>.id), :class=>"title" %>
16
+ <%%= link_to <%= singular_name %>.title, edit_manage_<%= singular_name %>_path(:id=><%= singular_name %>.id), :class=>"title" %>
17
17
  </div>
18
18
  </div>
19
19
  </div>
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 6
10
- version: 0.2.6
9
+ - 7
10
+ version: 0.2.7
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-12-01 00:00:00 +02:00
19
+ date: 2011-02-07 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -54,12 +54,12 @@ files:
54
54
  - lib/freeberry/accessible_attributes.rb
55
55
  - lib/freeberry/controllers/authorized_system.rb
56
56
  - lib/freeberry/controllers/head_options.rb
57
- - lib/freeberry/controllers/helper_tools.rb
57
+ - lib/freeberry/controllers/helper_utils.rb
58
58
  - lib/freeberry/core_ext.rb
59
59
  - lib/freeberry/core_ext/array.rb
60
60
  - lib/freeberry/core_ext/i18n.rb
61
61
  - lib/freeberry/core_ext/string.rb
62
- - lib/freeberry/header_tools.rb
62
+ - lib/freeberry/header_utils.rb
63
63
  - lib/freeberry/model_filter.rb
64
64
  - lib/freeberry/models/asset.rb
65
65
  - lib/freeberry/models/comment.rb
@@ -331,8 +331,8 @@ homepage: https://github.com/galetahub/freeberry
331
331
  licenses: []
332
332
 
333
333
  post_install_message:
334
- rdoc_options:
335
- - --charset=UTF-8
334
+ rdoc_options: []
335
+
336
336
  require_paths:
337
337
  - lib
338
338
  required_ruby_version: !ruby/object:Gem::Requirement