skylinecms 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -1
- data/CHANGELOG +50 -0
- data/README.md +11 -3
- data/app/controllers/skyline/application_controller.rb +6 -5
- data/app/controllers/skyline/articles_controller.rb +4 -4
- data/app/controllers/skyline/content_controller.rb +2 -4
- data/app/controllers/skyline/media/data_controller.rb +1 -0
- data/app/controllers/skyline/site/media_files_data_controller.rb +1 -0
- data/app/controllers/skyline/user_preferences_controller.rb +1 -1
- data/app/controllers/skyline/users_controller.rb +5 -1
- data/app/controllers/skyline/variant_current_editor_controller.rb +6 -1
- data/app/controllers/skyline/variants_controller.rb +2 -2
- data/app/helpers/skyline/content_helper.rb +1 -1
- data/app/helpers/skyline/editors/editor.rb +6 -6
- data/app/helpers/skyline/editors/joinable_list.rb +1 -1
- data/app/helpers/skyline/form_helper.rb +1 -0
- data/app/helpers/skyline/menu_helper.rb +0 -8
- data/app/helpers/skyline/presenters/presenter.rb +2 -2
- data/app/middleware/skyline/sprockets_middleware.rb +3 -8
- data/app/models/skyline/article.rb +29 -25
- data/app/models/skyline/article_version.rb +20 -20
- data/app/models/skyline/associated_tag.rb +1 -1
- data/app/models/skyline/grant.rb +1 -1
- data/app/models/skyline/link_section_link.rb +1 -1
- data/app/models/skyline/media_cache.rb +1 -1
- data/app/models/skyline/media_dir.rb +0 -2
- data/app/models/skyline/media_node.rb +1 -1
- data/app/models/skyline/object_ref.rb +3 -3
- data/app/models/skyline/page.rb +1 -3
- data/app/models/skyline/publication.rb +3 -1
- data/app/models/skyline/ref_object.rb +1 -1
- data/app/models/skyline/referable_uri.rb +1 -1
- data/app/models/skyline/right.rb +1 -1
- data/app/models/skyline/role.rb +1 -1
- data/app/models/skyline/section.rb +9 -9
- data/app/models/skyline/sections/content_collection_section.rb +3 -3
- data/app/models/skyline/sections/link_section.rb +3 -3
- data/app/models/skyline/sections/media_section.rb +2 -0
- data/app/models/skyline/sections/rss_section.rb +11 -12
- data/app/models/skyline/tag.rb +1 -1
- data/app/models/skyline/user.rb +213 -202
- data/app/models/skyline/user_preference.rb +2 -2
- data/app/models/skyline/variant.rb +18 -14
- data/app/observers/skyline/version_stamper.rb +1 -1
- data/app/templates/skyline/page/default/index.html.erb +1 -1
- data/app/views/skyline/articles/_security.html.erb +1 -1
- data/app/views/skyline/articles/edit.html.erb +1 -1
- data/app/views/skyline/content/{_add.rhtml → _add.html.erb} +0 -0
- data/app/views/skyline/content/{_filter.rhtml → _filter.html.erb} +0 -0
- data/app/views/skyline/content/{create.rhtml → create.html.erb} +0 -0
- data/app/views/skyline/content/{edit.rhtml → edit.html.erb} +0 -0
- data/app/views/skyline/content/{error.rhtml → error.html.erb} +0 -0
- data/app/views/skyline/content/{list.rhtml → list.html.erb} +3 -3
- data/app/views/skyline/content/{show.rhtml → show.html.erb} +0 -0
- data/app/views/skyline/content_sections/_tags.html.erb +1 -1
- data/app/views/skyline/shared/_header_area.html.erb +1 -1
- data/app/views/skyline/users/_new.html.erb +1 -1
- data/config/initializers/middlewares.rb +5 -1
- data/config/initializers/mime_types.rb +0 -6
- data/config/initializers/observers.rb +1 -1
- data/config/locales/en-US.yml +1 -1
- data/db/fixtures/roles_and_rights.rb +5 -5
- data/db/fixtures/roots.rb +1 -1
- data/doc/concepts.md +37 -0
- data/lib/skyline/belongs_to_referable.rb +5 -5
- data/lib/skyline/content/class_meta_data.rb +4 -3
- data/lib/skyline/content/content.rb +28 -18
- data/lib/skyline/content/exportable.rb +3 -3
- data/lib/skyline/content/field_meta_data.rb +12 -11
- data/lib/skyline/content/implementation.rb +7 -6
- data/lib/skyline/content/meta_data/field.rb +1 -1
- data/lib/skyline/content/stack.rb +1 -1
- data/lib/skyline/content/versioning/version.rb +1 -1
- data/lib/skyline/engine.rb +1 -1
- data/lib/skyline/has_many_referables_in.rb +4 -4
- data/lib/skyline/plugins/manager.rb +4 -3
- data/lib/skyline/plugins/plugin.rb +9 -1
- data/lib/skyline/rendering/renderer.rb +12 -2
- data/lib/skyline/sections/interface.rb +1 -1
- data/lib/skyline/taggable.rb +4 -4
- data/lib/skyline/version.rb +2 -2
- data/public/skyline/javascripts/src/application.js +1 -1
- data/public/skyline/javascripts/src/application_preinit.js +1 -0
- data/public/skyline/javascripts/src/library_uploader.js +1 -1
- data/public/skyline/javascripts/src/skyline.editor/src/skyline.editor.js +18 -18
- data/public/skyline/javascripts/src/skyline.editor/src/tinymce_preinit.js +4 -0
- data/public/skyline/javascripts/src/skyline.js +20 -18
- data/public/skyline/javascripts/src/skyline/src/skyline.js +2 -2
- data/public/skyline/javascripts/src/skyline/src/uploader.js +1 -1
- data/skylinecms.gemspec +7 -5
- data/test/factories.rb +2 -0
- data/test/integration/media_browser_super_access_test.rb +3 -3
- data/test/integration/media_browser_user_access_test.rb +2 -2
- data/test/integration/user_preferences_test.rb +5 -5
- data/test/test_helper.rb +1 -0
- data/test/unit/article_test.rb +1 -1
- data/test/unit/locales_test.rb +13 -3
- data/test/unit/test_content_object_test.rb +1 -1
- data/test/unit/test_section_test.rb +3 -2
- data/test/unit/user_preference_test.rb +2 -2
- data/vendor/digitpaint/nested_attributes_positioning.rb +5 -5
- metadata +66 -40
@@ -1,5 +1,5 @@
|
|
1
1
|
class Skyline::UserPreference < ActiveRecord::Base
|
2
|
-
|
2
|
+
self.table_name = "skyline_user_preferences"
|
3
3
|
|
4
4
|
belongs_to :user, :class_name => "::#{Skyline::Configuration.user_class.name}"
|
5
5
|
|
@@ -26,7 +26,7 @@ class Skyline::UserPreference < ActiveRecord::Base
|
|
26
26
|
self.exists?(["`#{self.table_name}`.`key` LIKE ?", "#{key}.%"])
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def remove_key(key)
|
30
30
|
self.delete_all("`#{self.table_name}`.`key` LIKE '#{key}.%'")
|
31
31
|
end
|
32
32
|
|
@@ -53,24 +53,28 @@ class Skyline::Variant < Skyline::ArticleVersion
|
|
53
53
|
raise StandardError, "can't be published if its dirty" if self.changed? || self.data.changed?
|
54
54
|
|
55
55
|
if self.valid?
|
56
|
-
self.
|
56
|
+
self.article.run_callbacks :publication do
|
57
|
+
self.prepare_data_to_be_published!(false)
|
57
58
|
|
58
|
-
|
59
|
-
|
59
|
+
published_publication = self.dup_to_class(self.article.publications)
|
60
|
+
published_publication.created_at = Time.now
|
61
|
+
published_publication.updated_at = Time.now
|
62
|
+
published_publication.save
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
self.article.published_publication = published_publication
|
65
|
+
self.article.url_part = published_publication.data.url_part if published_publication.data.respond_to?(:url_part)
|
66
|
+
self.article.published_publication_data = published_publication.data
|
67
|
+
self.article.set_default_variant(self)
|
68
|
+
self.article.save!
|
66
69
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
+
unless self.article.keep_history?
|
71
|
+
self.article.publications.each do |publication|
|
72
|
+
publication.destroy if publication != published_publication
|
73
|
+
end
|
70
74
|
end
|
71
|
-
end
|
72
75
|
|
73
|
-
|
76
|
+
published_publication
|
77
|
+
end
|
74
78
|
else
|
75
79
|
self.prepare_data_to_be_published!(false)
|
76
80
|
false
|
@@ -158,7 +162,7 @@ class Skyline::Variant < Skyline::ArticleVersion
|
|
158
162
|
|
159
163
|
def create_data
|
160
164
|
if self.data.new_record?
|
161
|
-
self.data.save(false)
|
165
|
+
self.data.save(:validate => false)
|
162
166
|
self.data_id = self.data.id
|
163
167
|
end
|
164
168
|
end
|
@@ -13,7 +13,7 @@
|
|
13
13
|
</tbody>
|
14
14
|
</table>
|
15
15
|
<% if @variant.editable_by?(current_user) && current_user.allow?(@article, :lock) %>
|
16
|
-
<%= skyline_form_for(
|
16
|
+
<%= skyline_form_for(@article, {:as => :article, :url => skyline_article_path(@article, :variant_id => @variant), :html => {:method => "put"}, :remote => true}) do |f| %>
|
17
17
|
<div class="button" style="margin-top: 5px">
|
18
18
|
<% if @article.locked? %>
|
19
19
|
<%= f.hidden_field :locked, :value => "0" %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= skyline_form_for @article, :as => :article, :url => skyline_article_path(@article), :html => {:method => :put, :id => "page_form"} do |a| %>
|
1
|
+
<%= skyline_form_for @article, {:as => :article, :url => skyline_article_path(@article), :html => {:method => :put, :id => "page_form"}} do |a| %>
|
2
2
|
<dl id="contentPanel" class="panel">
|
3
3
|
<%= a.fields_for :variants_attributes, @variant, :index => 1 do |v| %>
|
4
4
|
<%= v.fields_for :data_attributes, v.object.data do |vd| %>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,15 +1,15 @@
|
|
1
1
|
<% content_for :header do %>
|
2
2
|
<% if @stack.size > 1 %>
|
3
|
-
<%= @title = t(:title_sublisting, :scope => [:content, :list], :group => @stack.klass.plural_name, :title => @stack[-2].class.singular_name + " " + @stack[-2].human_id.to_s) %>
|
3
|
+
<%= @title = t(:title_sublisting, :scope => [:content, :list], :group => @stack.klass.plural_name, :title => @stack[-2].class.singular_name + " " + @stack[-2].human_id.to_s).html_safe %>
|
4
4
|
<% else %>
|
5
|
-
<%= @title = t(:title, :scope => [:content, :list], :class => @stack.klass.plural_name) %>
|
5
|
+
<%= @title = t(:title, :scope => [:content, :list], :class => @stack.klass.plural_name).html_safe %>
|
6
6
|
<% end %>
|
7
7
|
<% end %>
|
8
8
|
|
9
9
|
<%= Skyline::Presenters::Table.new(@elements,stack.klass,self).output %>
|
10
10
|
|
11
11
|
<% content_for :meta do %>
|
12
|
-
<%= render :partial => "add", :locals => {:klass => stack.klass, :record => stack.current, :return_to => url_for(
|
12
|
+
<%= render :partial => "add", :locals => {:klass => stack.klass, :record => stack.current, :return_to => url_for(:types => stack.klass.to_s.underscore.pluralize)} %>
|
13
13
|
<%= render :partial => "filter" if stack.klass.filterable? %>
|
14
14
|
<% end %>
|
15
15
|
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= skyline_fields_for "article[variants_attributes][1][sections_attributes][#{guid}][sectionable_attributes]"
|
1
|
+
<%= skyline_fields_for sectionable, :as => "article[variants_attributes][1][sections_attributes][#{guid}][sectionable_attributes]" do |s| %>
|
2
2
|
<table class="fields" id="section-<%=guid%>-tags">
|
3
3
|
<tbody>
|
4
4
|
<tr>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
<div id="usernavigation">
|
6
6
|
<%= t(:logged_in_as, :user => h(current_user.display_name), :scope => [:authentication]).html_safe %>
|
7
|
-
(<%= link_to t(:logout, :scope => [:authentication]),
|
7
|
+
(<%= link_to t(:logout, :scope => [:authentication]), skyline_authentication_path, :method => :delete, :remote => true %>)
|
8
8
|
</div>
|
9
9
|
</div>
|
10
10
|
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= skyline_form_for
|
1
|
+
<%= skyline_form_for @user, {:as => :user, :url => skyline_users_path(), :remote => true, :method => :post} do |f|%>
|
2
2
|
<%= render :partial => "form", :locals => {:f => f, :password_attribute => :password, :password_confirmation_attribute => :password_confirmation} %>
|
3
3
|
<% end %>
|
@@ -8,11 +8,15 @@ Rails.application.config.middleware.insert_before(
|
|
8
8
|
# Only needed for development, the files will be cached in Production.
|
9
9
|
# --
|
10
10
|
Rails.application.config.middleware.use(Skyline::SprocketsMiddleware, Rails.public_path, "skyline/javascripts/src", :cache => (Rails.env == "production") ) do |env|
|
11
|
+
env.register_load_location("")
|
11
12
|
env.register_load_location("skyline/src")
|
12
13
|
env.register_load_location("skyline/vendor/*")
|
14
|
+
env.register_load_location("skyline/vendor/fancyupload/")
|
15
|
+
env.register_load_location("skyline/vendor/mootools/")
|
16
|
+
|
13
17
|
env.register_load_location("skyline.editor/src")
|
14
18
|
env.register_load_location("skyline.editor/vendor/*")
|
15
|
-
env.register_load_location("skyline.editor/vendor/tinymce/jscripts/*")
|
19
|
+
env.register_load_location("skyline.editor/vendor/tinymce/jscripts/*")
|
16
20
|
|
17
21
|
env.map "skyline/javascripts/application.js", "skyline/javascripts/src/application.js"
|
18
22
|
env.map "skyline/javascripts/skyline.js", "skyline/javascripts/src/skyline.js"
|
@@ -103,12 +103,6 @@ mime_types = {
|
|
103
103
|
audio/x-midi
|
104
104
|
application/x-midi
|
105
105
|
audio/ac3},
|
106
|
-
:pdf => %w{application/pdf
|
107
|
-
application/x-pdf
|
108
|
-
application/acrobat
|
109
|
-
applications/vnd.pdf
|
110
|
-
text/pdf
|
111
|
-
text/x-pdf},
|
112
106
|
:excel => %w{application/vnd.ms-excel
|
113
107
|
application/msexcel
|
114
108
|
application/x-msexcel
|
data/config/locales/en-US.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
if !Object.const_defined?(:Rails)
|
2
|
-
require File.dirname(__FILE__) + "
|
2
|
+
require File.dirname(__FILE__) + "/../../../../config/environment"
|
3
3
|
end
|
4
4
|
|
5
5
|
def log(str)
|
@@ -38,15 +38,15 @@ Skyline::Right.connection.execute("DELETE FROM skyline_rights_skyline_roles WHER
|
|
38
38
|
log "\n== Creating roles"
|
39
39
|
|
40
40
|
stfu do
|
41
|
-
Skyline::Role.
|
41
|
+
Skyline::Role.seed(:name,
|
42
42
|
{:name => "super", :system => true}
|
43
|
-
|
43
|
+
)
|
44
44
|
end
|
45
45
|
|
46
46
|
log "\n== Creating rights"
|
47
47
|
|
48
48
|
stfu do
|
49
|
-
Skyline::Right.
|
49
|
+
Skyline::Right.seed(:name,
|
50
50
|
{:name => "media_dir_create"},
|
51
51
|
{:name => "media_dir_update"},
|
52
52
|
{:name => "media_dir_delete"},
|
@@ -91,7 +91,7 @@ stfu do
|
|
91
91
|
{:name => "user_delete"},
|
92
92
|
|
93
93
|
{:name => "tinymce_edit_html"} # Defines wether or not to show the "edit html" button in the toolbar
|
94
|
-
|
94
|
+
)
|
95
95
|
end
|
96
96
|
|
97
97
|
log "\n== Mapping Rights to Roles"
|
data/db/fixtures/roots.rb
CHANGED
data/doc/concepts.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
Skyline concepts
|
2
|
+
================
|
3
|
+
|
4
|
+
To get a better understanding of Skyline here's a quick overview of the main building blocks.
|
5
|
+
|
6
|
+
Pages
|
7
|
+
-----
|
8
|
+
|
9
|
+
Skyline is primarily built around pages. Pages are ordered into a tree which represents the structure of the
|
10
|
+
website. Pages consist of two parts: static data and sections and they inherit their properties from articles.
|
11
|
+
|
12
|
+
Articles
|
13
|
+
--------
|
14
|
+
|
15
|
+
Article is a container class that adds the functionality needed to add sections, versioning, publication
|
16
|
+
and other cool stuff. Pages are articles too. You can subclass the `Article` class to create your
|
17
|
+
own custom editable object (A news item for instance)
|
18
|
+
|
19
|
+
Sections
|
20
|
+
--------
|
21
|
+
|
22
|
+
Sections are elements that are predefined and are used as building blocks for content. Skyline has a number of
|
23
|
+
sections built in but you can also add new sections.
|
24
|
+
|
25
|
+
|
26
|
+
Rendering
|
27
|
+
---------
|
28
|
+
|
29
|
+
Skyline articles are rendered by the show action of the Skyline::Site::PagesController this controller can be overwritten if
|
30
|
+
for instance you need to render a specific page template for an element that is not directly linked to a page.
|
31
|
+
Like articles.
|
32
|
+
|
33
|
+
Settings
|
34
|
+
--------
|
35
|
+
|
36
|
+
Settings can be used to link articles to pages but also to set defaults like templates or colors which
|
37
|
+
then can be used in the templates.
|
@@ -43,7 +43,7 @@ module Skyline::BelongsToReferable
|
|
43
43
|
|
44
44
|
base.send(:cattr_accessor, :referable_contents)
|
45
45
|
base.send(:attr_accessor, :previous_referables)
|
46
|
-
base.send(:alias_method_chain, :
|
46
|
+
base.send(:alias_method_chain, :dup, :referable_content)
|
47
47
|
|
48
48
|
|
49
49
|
base.send("referable_contents=", [])
|
@@ -112,13 +112,13 @@ module Skyline::BelongsToReferable
|
|
112
112
|
end
|
113
113
|
|
114
114
|
# @private
|
115
|
-
def
|
116
|
-
|
115
|
+
def dup_with_referable_content
|
116
|
+
dup_without_referable_content.tap do |dup|
|
117
117
|
if self.referable_contents.any?
|
118
118
|
self.referable_contents.each do |field|
|
119
119
|
if self.send(field).present?
|
120
|
-
|
121
|
-
|
120
|
+
dup.send("#{field}_id=", nil)
|
121
|
+
dup.send("#{field}=", self.send(field).dup)
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Skyline::Content
|
2
2
|
module ClassMetaData
|
3
|
-
|
3
|
+
|
4
4
|
# Returns singular name of this class, falls back on standard Rails humanization
|
5
5
|
def singular_name
|
6
6
|
self.settings.singular_label
|
@@ -72,7 +72,7 @@ module Skyline::Content
|
|
72
72
|
return get_settings if settings.nil? && !block_given?
|
73
73
|
s = MetaData::ClassSettings.new(settings.update(:owner => self))
|
74
74
|
yield s if block_given?
|
75
|
-
|
75
|
+
self.cmd_settings = s
|
76
76
|
after_set_settings!
|
77
77
|
s
|
78
78
|
end
|
@@ -99,7 +99,8 @@ module Skyline::Content
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def get_settings
|
102
|
-
|
102
|
+
self.cmd_settings = MetaData::ClassSettings.new(:owner => self) unless self.cmd_settings.present?
|
103
|
+
self.cmd_settings
|
103
104
|
end
|
104
105
|
end
|
105
106
|
end
|
@@ -3,25 +3,35 @@ module Skyline::Content
|
|
3
3
|
module Content
|
4
4
|
def self.included(obj)
|
5
5
|
obj.extend(KlassMethods)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
|
7
|
+
if obj.ancestors.include?( ::ActiveRecord::Base)
|
8
|
+
obj.class_eval do
|
9
|
+
after_save :process_after_save
|
10
|
+
|
11
|
+
# Attributes for module settings (replacement for read/write_inheritable*)
|
12
|
+
# Values for FieldMetaData
|
13
|
+
class_attribute :fmd_field_hash
|
14
|
+
class_attribute :fmd_ungrouped_field_list
|
15
|
+
class_attribute :fmd_field_order_value
|
16
|
+
# Settings for ClassMetaData
|
17
|
+
class_attribute :cmd_settings
|
18
|
+
# List of possible export formats for Exportable
|
19
|
+
class_attribute :exportable_formats
|
10
20
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
21
|
+
scope :published, lambda {
|
22
|
+
if obj.publishable?
|
23
|
+
{:conditions => {:published => true}}
|
24
|
+
else
|
25
|
+
{}
|
26
|
+
end
|
27
|
+
}
|
18
28
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
29
|
+
scope :with_site, {}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
23
33
|
|
24
|
-
|
34
|
+
module KlassMethods #:nodoc:
|
25
35
|
|
26
36
|
def content?
|
27
37
|
true
|
@@ -174,7 +184,7 @@ module Skyline::Content
|
|
174
184
|
return nil if self_referential_associations.empty?
|
175
185
|
|
176
186
|
self_referential_associations.collect do |assoc|
|
177
|
-
(assoc.options[:foreign_key] || assoc.
|
187
|
+
(assoc.options[:foreign_key] || assoc.foreign_key).to_s + " is null"
|
178
188
|
end.join(" AND ")
|
179
189
|
end
|
180
190
|
|
@@ -272,7 +282,7 @@ module Skyline::Content
|
|
272
282
|
params = {}
|
273
283
|
if tempid = k.to_s[/^n__?(n?\d+)/,1]
|
274
284
|
# new
|
275
|
-
params.update(assoc.source_reflection.
|
285
|
+
params.update(assoc.source_reflection.foreign_key => target_id)
|
276
286
|
params.update(position_column => order_map[tempid]) if position_column
|
277
287
|
self.send(assoc.through_reflection.name).build(v.update(params))
|
278
288
|
else
|
@@ -4,8 +4,8 @@ module Skyline::Content
|
|
4
4
|
|
5
5
|
# List of possible export formats for this class
|
6
6
|
def export_formats
|
7
|
-
|
8
|
-
end
|
7
|
+
self.exportable_formats || []
|
8
|
+
end
|
9
9
|
|
10
10
|
# Set a list of possible export format for this class
|
11
11
|
# [DOC]
|
@@ -17,7 +17,7 @@ module Skyline::Content
|
|
17
17
|
class << self; self; end.send(:define_method, "export_#{format}"){}
|
18
18
|
end
|
19
19
|
if formats.any?
|
20
|
-
|
20
|
+
self.exportable_formats = formats
|
21
21
|
class << self; self; end.send(:define_method,:exportable?) do
|
22
22
|
true
|
23
23
|
end
|
@@ -153,15 +153,15 @@ module Skyline::Content
|
|
153
153
|
options = options_from_params_with_default fields
|
154
154
|
fields = fields.first if fields.any? && fields.first.kind_of?(Array)
|
155
155
|
options.reverse_merge! field_create_defaults(options)
|
156
|
-
|
156
|
+
|
157
157
|
fields.each do |field_name|
|
158
158
|
options.update(:name => field_name, :owner => self)
|
159
159
|
if self.fields.has_key?(field_name)
|
160
|
-
|
160
|
+
self.fmd_field_hash = self.fields.merge(field_name => MetaData::Field.from(self.fields[field_name],options))
|
161
161
|
else
|
162
|
-
|
162
|
+
self.fmd_field_hash = self.fields.merge(field_name => MetaData::Field.new(options))
|
163
163
|
end
|
164
|
-
self.ungrouped_fields << field_name
|
164
|
+
self.fmd_ungrouped_field_list = self.ungrouped_fields << field_name
|
165
165
|
yield self.fields[field_name] if block_given?
|
166
166
|
after_field_create!(self.fields[field_name])
|
167
167
|
end
|
@@ -184,8 +184,8 @@ module Skyline::Content
|
|
184
184
|
field_group = MetaData::FieldGroup.new(options.update(:owner => self, :name => name))
|
185
185
|
yield field_group if block_given?
|
186
186
|
|
187
|
-
|
188
|
-
|
187
|
+
self.fmd_ungrouped_field_list = self.ungrouped_fields.dup << name
|
188
|
+
self.fmd_field_hash = self.fields.merge(name => field_group)
|
189
189
|
|
190
190
|
field_group
|
191
191
|
end
|
@@ -194,9 +194,10 @@ module Skyline::Content
|
|
194
194
|
# field_order :name,:naw,:body
|
195
195
|
def field_order(*order)
|
196
196
|
if order.empty?
|
197
|
-
|
197
|
+
self.fmd_field_order_value = order unless self.fmd_field_order_value.present?
|
198
|
+
self.fmd_field_order_value
|
198
199
|
else
|
199
|
-
|
200
|
+
self.fmd_field_order_value = order
|
200
201
|
end
|
201
202
|
end
|
202
203
|
|
@@ -209,7 +210,7 @@ module Skyline::Content
|
|
209
210
|
# <tt>Array[Symbol]</tt>:: Field names of fields which are writable.
|
210
211
|
#--
|
211
212
|
def writable_fields #:nodoc:
|
212
|
-
self.fields.select do |k,v|
|
213
|
+
self.fields.select do |k,v|
|
213
214
|
if v.kind_of?(MetaData::Field) && v.editor == :file && !v.hidden_in(:edit)
|
214
215
|
true
|
215
216
|
else
|
@@ -231,11 +232,11 @@ module Skyline::Content
|
|
231
232
|
end
|
232
233
|
|
233
234
|
def fields #:nodoc:
|
234
|
-
|
235
|
+
self.fmd_field_hash || {}
|
235
236
|
end
|
236
237
|
|
237
238
|
def ungrouped_fields #:nodoc:
|
238
|
-
|
239
|
+
self.fmd_ungrouped_field_list || []
|
239
240
|
end
|
240
241
|
|
241
242
|
# @deprecated
|