smithycms 0.7.3 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/smithy/editor.coffee +4 -3
- data/app/assets/javascripts/smithy/nested_forms.js +1 -1
- data/app/assets/javascripts/smithy/page_contents.coffee +11 -0
- data/app/assets/stylesheets/smithy/forms.scss +23 -0
- data/app/assets/stylesheets/smithy/pages.scss +5 -0
- data/app/assets/stylesheets/smithy/templates.scss +1 -6
- data/app/controllers/smithy/pages_controller.rb +1 -1
- data/app/helpers/smithy/application_helper.rb +3 -6
- data/app/inputs/markdown_input.rb +6 -3
- data/app/models/smithy/asset.rb +1 -1
- data/app/models/smithy/content_block_template.rb +1 -1
- data/app/models/smithy/image.rb +1 -1
- data/app/models/smithy/page.rb +3 -2
- data/app/models/smithy/page_content.rb +8 -4
- data/app/models/smithy/permitted_params.rb +43 -6
- data/app/models/smithy/template_container.rb +1 -1
- data/app/views/smithy/pages/_container.html.erb +2 -20
- data/app/views/smithy/pages/_page_content.html.erb +27 -0
- data/db/migrate/20160819164547_add_css_classes_to_smithy_page_contents.rb +5 -0
- data/lib/smithy.rb +1 -0
- data/lib/smithy/content_blocks/model.rb +1 -1
- data/lib/smithy/content_blocks/registry.rb +1 -2
- data/lib/smithy/dependencies.rb +1 -0
- data/lib/smithy/engine.rb +4 -3
- data/lib/smithy/liquid/tags/html.rb +6 -2
- data/lib/smithy/page_content_wrapper.rb +15 -0
- data/lib/smithy/version.rb +1 -1
- metadata +25 -178
- data/app/assets/javascripts/smithy/page_contents.js +0 -4
- data/vendor/cache/CFPropertyList-2.3.2.gem +0 -0
- data/vendor/cache/actionmailer-4.1.10.gem +0 -0
- data/vendor/cache/actionpack-4.1.10.gem +0 -0
- data/vendor/cache/actionview-4.1.10.gem +0 -0
- data/vendor/cache/activemodel-4.1.10.gem +0 -0
- data/vendor/cache/activerecord-4.1.10.gem +0 -0
- data/vendor/cache/activesupport-4.1.10.gem +0 -0
- data/vendor/cache/addressable-2.3.8.gem +0 -0
- data/vendor/cache/amoeba-3.0.0.gem +0 -0
- data/vendor/cache/arel-5.0.1.20140414130214.gem +0 -0
- data/vendor/cache/autoprefixer-rails-6.3.6.1.gem +0 -0
- data/vendor/cache/awesome_nested_set-3.0.3.gem +0 -0
- data/vendor/cache/aws-sdk-2.3.4.gem +0 -0
- data/vendor/cache/aws-sdk-core-2.3.4.gem +0 -0
- data/vendor/cache/aws-sdk-resources-2.3.4.gem +0 -0
- data/vendor/cache/bcrypt-3.1.10.gem +0 -0
- data/vendor/cache/bootstrap-sass-3.2.0.2.gem +0 -0
- data/vendor/cache/builder-3.2.2.gem +0 -0
- data/vendor/cache/byebug-4.0.5.gem +0 -0
- data/vendor/cache/capybara-2.4.4.gem +0 -0
- data/vendor/cache/celluloid-0.16.0.gem +0 -0
- data/vendor/cache/coderay-1.1.0.gem +0 -0
- data/vendor/cache/coffee-rails-4.1.1.gem +0 -0
- data/vendor/cache/coffee-script-2.4.1.gem +0 -0
- data/vendor/cache/coffee-script-source-1.10.0.gem +0 -0
- data/vendor/cache/columnize-0.9.0.gem +0 -0
- data/vendor/cache/concurrent-ruby-1.0.2.gem +0 -0
- data/vendor/cache/coveralls-0.7.12.gem +0 -0
- data/vendor/cache/crass-1.0.2.gem +0 -0
- data/vendor/cache/database_cleaner-1.4.1.gem +0 -0
- data/vendor/cache/diff-lcs-1.2.5.gem +0 -0
- data/vendor/cache/docile-1.1.5.gem +0 -0
- data/vendor/cache/domain_name-0.5.23.gem +0 -0
- data/vendor/cache/dotenv-2.0.1.gem +0 -0
- data/vendor/cache/dotenv-rails-2.0.1.gem +0 -0
- data/vendor/cache/em-websocket-0.5.1.gem +0 -0
- data/vendor/cache/erubis-2.7.0.gem +0 -0
- data/vendor/cache/eventmachine-1.0.7.gem +0 -0
- data/vendor/cache/excon-0.49.0.gem +0 -0
- data/vendor/cache/execjs-2.6.0.gem +0 -0
- data/vendor/cache/factory_girl-4.5.0.gem +0 -0
- data/vendor/cache/factory_girl_rails-4.5.0.gem +0 -0
- data/vendor/cache/fakeweb-1.3.0.gem +0 -0
- data/vendor/cache/ffaker-2.0.0.gem +0 -0
- data/vendor/cache/ffi-1.9.8.gem +0 -0
- data/vendor/cache/fission-0.5.0.gem +0 -0
- data/vendor/cache/fog-1.38.0.gem +0 -0
- data/vendor/cache/fog-aliyun-0.1.0.gem +0 -0
- data/vendor/cache/fog-atmos-0.1.0.gem +0 -0
- data/vendor/cache/fog-aws-0.9.2.gem +0 -0
- data/vendor/cache/fog-brightbox-0.10.1.gem +0 -0
- data/vendor/cache/fog-cloudatcost-0.1.2.gem +0 -0
- data/vendor/cache/fog-core-1.39.0.gem +0 -0
- data/vendor/cache/fog-dynect-0.0.3.gem +0 -0
- data/vendor/cache/fog-ecloud-0.3.0.gem +0 -0
- data/vendor/cache/fog-google-0.1.0.gem +0 -0
- data/vendor/cache/fog-json-1.0.2.gem +0 -0
- data/vendor/cache/fog-local-0.3.0.gem +0 -0
- data/vendor/cache/fog-openstack-0.1.5.gem +0 -0
- data/vendor/cache/fog-powerdns-0.1.1.gem +0 -0
- data/vendor/cache/fog-profitbricks-0.0.5.gem +0 -0
- data/vendor/cache/fog-rackspace-0.1.1.gem +0 -0
- data/vendor/cache/fog-radosgw-0.0.5.gem +0 -0
- data/vendor/cache/fog-riakcs-0.1.0.gem +0 -0
- data/vendor/cache/fog-sakuracloud-1.7.5.gem +0 -0
- data/vendor/cache/fog-serverlove-0.1.2.gem +0 -0
- data/vendor/cache/fog-softlayer-1.1.1.gem +0 -0
- data/vendor/cache/fog-storm_on_demand-0.1.1.gem +0 -0
- data/vendor/cache/fog-terremark-0.1.0.gem +0 -0
- data/vendor/cache/fog-vmfusion-0.1.0.gem +0 -0
- data/vendor/cache/fog-voxel-0.1.0.gem +0 -0
- data/vendor/cache/fog-vsphere-0.7.0.gem +0 -0
- data/vendor/cache/fog-xenserver-0.2.3.gem +0 -0
- data/vendor/cache/fog-xml-0.1.2.gem +0 -0
- data/vendor/cache/font-awesome-sass-4.6.2.gem +0 -0
- data/vendor/cache/formatador-0.2.5.gem +0 -0
- data/vendor/cache/formtastic-3.1.4.gem +0 -0
- data/vendor/cache/formtastic-bootstrap-3.1.1.gem +0 -0
- data/vendor/cache/friendly_id-5.0.5.gem +0 -0
- data/vendor/cache/fuubar-2.0.0.gem +0 -0
- data/vendor/cache/guard-2.12.5.gem +0 -0
- data/vendor/cache/guard-compat-1.2.1.gem +0 -0
- data/vendor/cache/guard-livereload-2.4.0.gem +0 -0
- data/vendor/cache/guard-rspec-4.5.0.gem +0 -0
- data/vendor/cache/hitimes-1.2.2.gem +0 -0
- data/vendor/cache/http-cookie-1.0.2.gem +0 -0
- data/vendor/cache/http_parser.rb-0.6.0.gem +0 -0
- data/vendor/cache/httparty-0.13.7.gem +0 -0
- data/vendor/cache/i18n-0.7.0.gem +0 -0
- data/vendor/cache/inflecto-0.0.2.gem +0 -0
- data/vendor/cache/ipaddress-0.8.3.gem +0 -0
- data/vendor/cache/jmespath-1.2.4.gem +0 -0
- data/vendor/cache/jquery-rails-3.1.4.gem +0 -0
- data/vendor/cache/json-1.8.2.gem +0 -0
- data/vendor/cache/json_pure-1.8.3.gem +0 -0
- data/vendor/cache/kaminari-0.16.3.gem +0 -0
- data/vendor/cache/kramdown-1.11.1.gem +0 -0
- data/vendor/cache/launchy-2.4.3.gem +0 -0
- data/vendor/cache/letter_opener-1.3.0.gem +0 -0
- data/vendor/cache/liquid-2.6.3.gem +0 -0
- data/vendor/cache/listen-2.10.0.gem +0 -0
- data/vendor/cache/lumberjack-1.0.9.gem +0 -0
- data/vendor/cache/mail-2.6.4.gem +0 -0
- data/vendor/cache/method_source-0.8.2.gem +0 -0
- data/vendor/cache/mime-types-2.4.3.gem +0 -0
- data/vendor/cache/mini_magick-4.5.1.gem +0 -0
- data/vendor/cache/mini_portile-0.6.2.gem +0 -0
- data/vendor/cache/minitest-5.5.1.gem +0 -0
- data/vendor/cache/multi_json-1.11.0.gem +0 -0
- data/vendor/cache/multi_xml-0.5.5.gem +0 -0
- data/vendor/cache/mysql2-0.3.18.gem +0 -0
- data/vendor/cache/nenv-0.2.0.gem +0 -0
- data/vendor/cache/netrc-0.10.3.gem +0 -0
- data/vendor/cache/nokogiri-1.6.6.2.gem +0 -0
- data/vendor/cache/nokogumbo-1.4.7.gem +0 -0
- data/vendor/cache/notiffany-0.0.6.gem +0 -0
- data/vendor/cache/pg-0.18.1.gem +0 -0
- data/vendor/cache/pry-0.10.1.gem +0 -0
- data/vendor/cache/rack-1.5.2.gem +0 -0
- data/vendor/cache/rack-cache-1.6.1.gem +0 -0
- data/vendor/cache/rack-livereload-0.3.15.gem +0 -0
- data/vendor/cache/rack-protection-1.5.3.gem +0 -0
- data/vendor/cache/rack-test-0.6.3.gem +0 -0
- data/vendor/cache/rails-4.1.10.gem +0 -0
- data/vendor/cache/railties-4.1.10.gem +0 -0
- data/vendor/cache/rake-10.4.2.gem +0 -0
- data/vendor/cache/rb-fsevent-0.9.4.gem +0 -0
- data/vendor/cache/rb-inotify-0.9.5.gem +0 -0
- data/vendor/cache/rbvmomi-1.8.2.gem +0 -0
- data/vendor/cache/refile-0.6.2.gem +0 -0
- data/vendor/cache/refile-mini_magick-0.2.0.gem +0 -0
- data/vendor/cache/refile-s3-0.2.0.gem +0 -0
- data/vendor/cache/remotipart-1.2.1.gem +0 -0
- data/vendor/cache/rest-client-1.8.0.gem +0 -0
- data/vendor/cache/rinku-1.7.3.gem +0 -0
- data/vendor/cache/rspec-3.2.0.gem +0 -0
- data/vendor/cache/rspec-core-3.2.2.gem +0 -0
- data/vendor/cache/rspec-expectations-3.2.0.gem +0 -0
- data/vendor/cache/rspec-mocks-3.2.1.gem +0 -0
- data/vendor/cache/rspec-rails-3.2.1.gem +0 -0
- data/vendor/cache/rspec-support-3.2.2.gem +0 -0
- data/vendor/cache/ruby-oembed-0.8.14.gem +0 -0
- data/vendor/cache/ruby-progressbar-1.7.5.gem +0 -0
- data/vendor/cache/sanitize-4.0.1.gem +0 -0
- data/vendor/cache/sass-3.4.22.gem +0 -0
- data/vendor/cache/sass-rails-5.0.4.gem +0 -0
- data/vendor/cache/shellany-0.0.1.gem +0 -0
- data/vendor/cache/shoulda-matchers-2.8.0.gem +0 -0
- data/vendor/cache/simplecov-0.9.2.gem +0 -0
- data/vendor/cache/simplecov-html-0.9.0.gem +0 -0
- data/vendor/cache/sinatra-1.4.7.gem +0 -0
- data/vendor/cache/slodown-0.1.3.gem +0 -0
- data/vendor/cache/slop-3.6.0.gem +0 -0
- data/vendor/cache/smithycms-auth-0.4.2.gem +0 -0
- data/vendor/cache/sprockets-3.6.0.gem +0 -0
- data/vendor/cache/sprockets-rails-2.3.3.gem +0 -0
- data/vendor/cache/sqlite3-1.3.10.gem +0 -0
- data/vendor/cache/term-ansicolor-1.3.0.gem +0 -0
- data/vendor/cache/terminal-notifier-guard-1.6.4.gem +0 -0
- data/vendor/cache/thor-0.19.1.gem +0 -0
- data/vendor/cache/thread_safe-0.3.5.gem +0 -0
- data/vendor/cache/tilt-2.0.4.gem +0 -0
- data/vendor/cache/timers-4.0.1.gem +0 -0
- data/vendor/cache/tins-1.3.5.gem +0 -0
- data/vendor/cache/trollop-2.1.2.gem +0 -0
- data/vendor/cache/tzinfo-1.2.2.gem +0 -0
- data/vendor/cache/unf-0.1.4.gem +0 -0
- data/vendor/cache/unf_ext-0.0.6.gem +0 -0
- data/vendor/cache/xml-simple-1.1.5.gem +0 -0
- data/vendor/cache/xpath-2.0.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b8a748c87e90088c1ecde907900b0f65cd9e995
|
4
|
+
data.tar.gz: 74176f6fed35d9fc36e809a67885048d1e58dae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8b890ff799dc1439f26133149ea290e1c711e46faa1f53b4d426d70400e0672fa20aad5eb881b731989720b4a67ec243d93e2e975d2309fbb3602c8fdf3aa3f
|
7
|
+
data.tar.gz: 6991e5a9ee4b806b5baaebdb5a9bb5cc7169ba33f366d531ab48e965171c0bf3d0f648e610e60d91758f584f8fa4433046a824678fa1e94c39d66eb40a90b2a5
|
@@ -26,10 +26,11 @@ window.ace_edit = (id, template_type, name) ->
|
|
26
26
|
,
|
27
27
|
readOnly: false
|
28
28
|
})
|
29
|
-
editor.setOptions
|
30
|
-
enableBasicAutocompletion: true
|
29
|
+
editor.setOptions
|
30
|
+
enableBasicAutocompletion: true
|
31
31
|
enableSnippets: true
|
32
|
-
|
32
|
+
maxLines: 40
|
33
|
+
minLines: 2
|
33
34
|
return editor
|
34
35
|
|
35
36
|
create_ace_toolbar = (editor, assets_modal_url, pages_modal_url) ->
|
@@ -5,7 +5,7 @@ $(function() {
|
|
5
5
|
$('form').on('click', 'a.add_nested_fields', function() {
|
6
6
|
// Setup
|
7
7
|
var assoc = $(this).attr('data-association'); // Name of child
|
8
|
-
var content = $(
|
8
|
+
var content = $(this).attr('data-fields-blueprint'); // Fields template
|
9
9
|
|
10
10
|
// Make the context correct by replacing new_<parents> with the generated ID
|
11
11
|
// of each of the parent objects
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$("form#new_page_content .page_content_block").click ->
|
2
|
+
$('#page_content_content_block_type').val($(this).attr('data-content_block'))
|
3
|
+
$('form#new_page_content').submit()
|
4
|
+
|
5
|
+
$('.page_content .page_content-heading a[data-toggle="collapse"]').click (e) ->
|
6
|
+
e.preventDefault()
|
7
|
+
e.stopPropagation()
|
8
|
+
$(this).parent().siblings('.page_content-fields').collapse('toggle')
|
9
|
+
|
10
|
+
# $ ->
|
11
|
+
# $('.page_content-fields').collapse('hide')
|
@@ -1,3 +1,26 @@
|
|
1
1
|
#template_content,
|
2
2
|
#content_content,
|
3
3
|
#content_block_content { height:100%; width:97%; }
|
4
|
+
|
5
|
+
|
6
|
+
.page_content {
|
7
|
+
@extend .panel;
|
8
|
+
@extend .panel-default;
|
9
|
+
margin-bottom:8px;
|
10
|
+
|
11
|
+
.page_content-heading { @extend .panel-heading; }
|
12
|
+
.page_content-fields {
|
13
|
+
@extend .panel-collapse;
|
14
|
+
> div { @extend .panel-body; }
|
15
|
+
}
|
16
|
+
.page_content-toggle {
|
17
|
+
color:$text-color; display:inline-block; width:100%;
|
18
|
+
&:hover,
|
19
|
+
&:active,
|
20
|
+
&:focus { text-decoration: none; }
|
21
|
+
.name { font-weight: bold; }
|
22
|
+
.type,
|
23
|
+
.lastupdated { color:#BBB; font-size:$font-size-small; padding-left:1em; }
|
24
|
+
.lastupdated { float:right; font-style:italic; padding-top:$font-size-base - $font-size-small; }
|
25
|
+
}
|
26
|
+
}
|
@@ -2,6 +2,11 @@
|
|
2
2
|
.handle { color:#999; cursor:move; padding-right:6px; }
|
3
3
|
}
|
4
4
|
|
5
|
+
.page-container {
|
6
|
+
border-top: 1px solid #AAA; margin: 1.5em 0; padding: 1.5em 0 1em;
|
7
|
+
&:first-child { margin-top: 3em }
|
8
|
+
}
|
9
|
+
|
5
10
|
#side .page-list {
|
6
11
|
position:relative; overflow:hidden;
|
7
12
|
.back { background:#444; }
|
@@ -8,14 +8,9 @@ textarea[name="content[content]"],
|
|
8
8
|
.template_content_editor,
|
9
9
|
.ace_editor {
|
10
10
|
display:none;
|
11
|
-
|
12
|
-
width:97%;
|
11
|
+
width:100%;
|
13
12
|
position:relative;
|
14
|
-
&.short {
|
15
|
-
min-height:10em;
|
16
|
-
}
|
17
13
|
}
|
18
|
-
|
19
14
|
.ace-editor-toolbar {
|
20
15
|
background:#f9f9f9; border:1px solid darken(#f9f9f9,10%); border-radius:$border-radius-base $border-radius-base 0 0; line-height:40px; width:97%; margin:0; padding:0;
|
21
16
|
li {
|
@@ -112,7 +112,7 @@ module Smithy
|
|
112
112
|
|
113
113
|
def page_path
|
114
114
|
params[:path] = '' if params[:id].nil? && params[:path].nil? # sets the root path when nothing else is passed
|
115
|
-
params[:path].nil? ? params[:id] : "/#{params[:path]}"
|
115
|
+
params[:path].nil? ? params[:id] : "/#{params[:path]}".downcase
|
116
116
|
end
|
117
117
|
|
118
118
|
def render_page
|
@@ -1,13 +1,10 @@
|
|
1
1
|
module Smithy
|
2
2
|
module ApplicationHelper
|
3
3
|
def smithy_link_to_add_fields(name, association, form_builder)
|
4
|
-
|
5
|
-
|
6
|
-
form_builder.template.concat(raw render("#{form_builder.object.class.to_s.tableize}/#{association.to_s.singularize}_fields", :f => builder))
|
7
|
-
end
|
4
|
+
blueprint = form_builder.semantic_fields_for(association, model_object(form_builder, association), :child_index => "new_#{association}") do |builder|
|
5
|
+
raw render("#{form_builder.object.class.to_s.tableize}/#{association.to_s.singularize}_fields", :f => builder)
|
8
6
|
end
|
9
|
-
form_builder.template.
|
10
|
-
form_builder.template.link_to(name, "javascript:void(0)", :class => "add_nested_fields", "data-association" => association)
|
7
|
+
form_builder.template.link_to(name, "javascript:void(0)", :class => "add_nested_fields", "data-association" => association, 'data-fields-blueprint' => CGI.escapeHTML(blueprint).html_safe)
|
11
8
|
end
|
12
9
|
|
13
10
|
def smithy_link_to_remove_fields(name, form_builder)
|
@@ -3,9 +3,12 @@ class MarkdownInput < FormtasticBootstrap::Inputs::TextInput
|
|
3
3
|
def to_html
|
4
4
|
self.options[:hint] = markdown_hint if self.options[:hint].blank?
|
5
5
|
bootstrap_wrapping do
|
6
|
-
builder.text_area(method, form_control_input_html_options)
|
7
|
-
|
8
|
-
|
6
|
+
text_area = builder.text_area(method, form_control_input_html_options)
|
7
|
+
editor = builder.template.content_tag :div do
|
8
|
+
builder.template.content_tag(:div, nil, id: editor_id, class: 'ace_editor', data: { id: id, type: :markdown, name: dom_id, init: "$('##{editor_id}').smithy_editor()".html_safe, assets_url: builder.template.selector_modal_assets_path, pages_url: builder.template.selector_modal_pages_path }) +
|
9
|
+
builder.template.content_tag(:div, nil, id: 'content-guide')
|
10
|
+
end
|
11
|
+
text_area + editor
|
9
12
|
end
|
10
13
|
end
|
11
14
|
|
data/app/models/smithy/asset.rb
CHANGED
data/app/models/smithy/image.rb
CHANGED
data/app/models/smithy/page.rb
CHANGED
@@ -5,7 +5,7 @@ module Smithy
|
|
5
5
|
validate :validate_exclusion_of_reserved_words
|
6
6
|
validate :validate_page_to_copy_exists
|
7
7
|
|
8
|
-
belongs_to :template
|
8
|
+
belongs_to :template, inverse_of: :pages
|
9
9
|
has_many :containers, :through => :template
|
10
10
|
has_many :contents, :class_name => "PageContent"
|
11
11
|
|
@@ -44,6 +44,7 @@ module Smithy
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def duplicate_content_from(page_id)
|
47
|
+
page_id = page_id.id if page_id.is_a?(Smithy::Page)
|
47
48
|
page = Page.find(page_id)
|
48
49
|
self.contents = page.contents.map(&:amoeba_dup)
|
49
50
|
self.contents.each do |content|
|
@@ -55,7 +56,7 @@ module Smithy
|
|
55
56
|
def normalize_friendly_id(value) # normalize_friendly_id overrides the default creator for friendly_id
|
56
57
|
return "/" if self.parent.blank?
|
57
58
|
value = self.permalink? ? self.permalink.parameterize : value.to_s.parameterize
|
58
|
-
[(self.parent.present? && !self.parent.root? ? self.parent.path : nil), value].join('/')
|
59
|
+
[(self.parent.present? && !self.parent.root? ? self.parent.path : nil), value].join('/').downcase
|
59
60
|
end
|
60
61
|
|
61
62
|
def should_generate_new_friendly_id?
|
@@ -4,13 +4,14 @@ module Smithy
|
|
4
4
|
validates_presence_of :content_block_type, :on => :create
|
5
5
|
validates_presence_of :label, :container, :page
|
6
6
|
|
7
|
-
belongs_to :page, :touch => true
|
8
|
-
belongs_to :content_block, :polymorphic => true
|
9
|
-
belongs_to :content_block_template
|
7
|
+
belongs_to :page, :touch => true, inverse_of: :contents
|
8
|
+
belongs_to :content_block, :polymorphic => true, inverse_of: :page_contents
|
9
|
+
belongs_to :content_block_template, inverse_of: :page_contents
|
10
10
|
|
11
11
|
before_update :set_publishable
|
12
12
|
|
13
13
|
accepts_nested_attributes_for :content_block, :allow_destroy => true
|
14
|
+
|
14
15
|
amoeba do
|
15
16
|
enable
|
16
17
|
include_association :content_block
|
@@ -41,7 +42,10 @@ module Smithy
|
|
41
42
|
# scopes as the original values as well, but this ensures they don't get clobbered
|
42
43
|
liquid_context.merge('smithy' => liquid_context.scopes.last)
|
43
44
|
liquid_context.merge(self.to_liquid)
|
44
|
-
content_block_template.liquid_template.render(liquid_context)
|
45
|
+
output = content_block_template.liquid_template.render(liquid_context)
|
46
|
+
# auto-wrap every page content in a div with the page_content-#id and the page_content#css_classes
|
47
|
+
wrapper = Smithy::PageContentWrapper.new(self)
|
48
|
+
wrapper.wrap(output)
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
@@ -25,12 +25,11 @@ module Smithy
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def content_block_attributes
|
28
|
-
|
29
|
-
:all
|
28
|
+
[ :name, templates_attributes: [ :id, :name, :content, :_destroy ] ]
|
30
29
|
end
|
31
30
|
|
32
31
|
def content_block_template_attributes
|
33
|
-
[ :
|
32
|
+
[ :name, :content ]
|
34
33
|
end
|
35
34
|
|
36
35
|
def image_attributes
|
@@ -38,12 +37,19 @@ module Smithy
|
|
38
37
|
end
|
39
38
|
|
40
39
|
def page_attributes
|
41
|
-
[
|
40
|
+
[
|
41
|
+
:browser_title, :cache_length, :description, :external_link, :keywords, :permalink, :publish, :published_at, :show_in_navigation, :title, :parent_id, :template_id, :copy_content_from,
|
42
|
+
contents_attributes: page_content_attributes + [:id, :_destroy]
|
43
|
+
]
|
42
44
|
end
|
43
45
|
|
44
46
|
def page_content_attributes
|
45
|
-
|
46
|
-
|
47
|
+
attributes = [ :label, :css_classes, :container, :content_block_type, :content_block_template_id, :position ]
|
48
|
+
content_block_attributes = ::Smithy::ContentBlocks::Registry.content_blocks.inject([]) do |association_attributes, content_block_type|
|
49
|
+
association_attributes += nested_content_block_attributes_for(content_block_type)
|
50
|
+
end
|
51
|
+
attributes << { content_block_attributes: content_block_attributes + [:id, :_destroy] } if content_block_attributes.present?
|
52
|
+
attributes
|
47
53
|
end
|
48
54
|
|
49
55
|
def page_list_attributes
|
@@ -61,5 +67,36 @@ module Smithy
|
|
61
67
|
def template_container_attributes
|
62
68
|
[ :name, :position ]
|
63
69
|
end
|
70
|
+
|
71
|
+
private
|
72
|
+
def content_block_attributes_for(content_block_type)
|
73
|
+
attributes_method = "#{content_block_type.underscore}_attributes".to_sym
|
74
|
+
if self.respond_to?(attributes_method)
|
75
|
+
public_send(attributes_method)
|
76
|
+
else
|
77
|
+
klass = "Smithy::#{content_block_type.camelize}".safe_constantize || content_block_type.camelize.safe_constantize
|
78
|
+
klass.present? ? klass.column_names.delete_if { |n| n.to_s.presence_in %w(id updated_at created_at) }.map(&:to_sym) : []
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def nested_content_block_attributes_for(content_block_type)
|
83
|
+
content_block_attributes = content_block_attributes_for(content_block_type)
|
84
|
+
association_attributes = []
|
85
|
+
reflected_content_block_associations(content_block_type).each do |reflection|
|
86
|
+
name, association = reflection
|
87
|
+
next if association.active_record.nested_attributes_options[name.to_sym].blank?
|
88
|
+
allowed_attributes = content_block_attributes_for(content_block_type) + [:id]
|
89
|
+
allowed_attributes += [:_destroy] if association.active_record.nested_attributes_options[name.to_sym][:allow_destroy] == true
|
90
|
+
association_attributes << {"#{name}_attributes".to_sym => allowed_attributes }
|
91
|
+
end
|
92
|
+
content_block_attributes += association_attributes
|
93
|
+
content_block_attributes.uniq
|
94
|
+
end
|
95
|
+
|
96
|
+
def reflected_content_block_associations(content_block_type)
|
97
|
+
klass = "Smithy::#{content_block_type}".safe_constantize || content_block_type.safe_constantize
|
98
|
+
reflections = klass.reflections.delete_if{|k,v| k.to_s.presence_in %w(id page_contents pages) }
|
99
|
+
end
|
100
|
+
|
64
101
|
end
|
65
102
|
end
|
@@ -1,24 +1,6 @@
|
|
1
|
-
<div class="
|
1
|
+
<div class="page-container">
|
2
2
|
<%= f.inputs container.display_name do %>
|
3
|
-
|
4
|
-
<% @page.contents.for_container(container.name).each do |page_content| %>
|
5
|
-
<%= content_tag_for :tr, page_content do %>
|
6
|
-
<td>
|
7
|
-
<i class="fa fa-reorder handle"></i>
|
8
|
-
<%= link_to "edit", edit_page_content_path(@page.id, page_content), class: "btn btn-primary btn-sm" %>
|
9
|
-
</td>
|
10
|
-
<td><strong><%= page_content.label %></strong></td>
|
11
|
-
<td><%= page_content.content_block_type.demodulize %></td>
|
12
|
-
<td><%= page_content.updated_at.strftime('%b %e, %Y %H:%M:%S') %></td>
|
13
|
-
<td>
|
14
|
-
<div class="pull-right">
|
15
|
-
<%= link_to "preview", preview_page_content_path(@page.id, page_content), class: "btn btn-default btn-sm", data: { previewtoggle: "modal" } %>
|
16
|
-
<%= link_to "<i class=\"fa fa-trash\"></i> delete".html_safe, page_content_path(@page.id, page_content), method: :delete, data: { confirm: "Do you really want to delete this content?" }, class: "btn btn-danger btn-sm" %>
|
17
|
-
</div>
|
18
|
-
</td>
|
19
|
-
<% end %>
|
20
|
-
<% end %>
|
21
|
-
</table>
|
3
|
+
<%= render :partial => "page_content", :collection => @page.contents.for_container(container.name), :locals => { :f => f } %>
|
22
4
|
<div><%= link_to "Add to #{container.display_name}", new_page_content_path(@page.id, page_content: { container: container.name }), class: "btn btn-primary btn-sm" %></div>
|
23
5
|
<% end %>
|
24
6
|
</div>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<div class="page_content">
|
2
|
+
<%= f.semantic_fields_for :contents, page_content do |f| %>
|
3
|
+
<div class="page_content-heading">
|
4
|
+
<a href="#page_content-<%= page_content.id %>" class="page_content-toggle" id="page_content-<%= page_content.id %>" data-toggle="collapse">
|
5
|
+
<span class="name"><%= page_content.label %></span>
|
6
|
+
<span class="type"><%= page_content.content_block_type.demodulize.underscore.humanize %></span>
|
7
|
+
<span class="lastupdated">Last Updated: <%= page_content.updated_at.strftime('%b %e, %Y %H:%M') %></span>
|
8
|
+
</a>
|
9
|
+
</div>
|
10
|
+
<div class="page_content-fields collapse" role="tabpanel">
|
11
|
+
<div>
|
12
|
+
<%= f.inputs do %>
|
13
|
+
<%= f.input :label, hint: "Internal CMS usage only - so you can identify it later" %>
|
14
|
+
<%= f.input :css_classes, label: 'CSS Classes', hint: 'If you need a hook to apply special styles' %>
|
15
|
+
<%= f.input :container, as: :hidden %>
|
16
|
+
<%= f.input :content_block_type, as: :hidden %>
|
17
|
+
<% end %>
|
18
|
+
<div class="well">
|
19
|
+
<%= f.input :content_block_template, collection: page_content.templates, include_blank: false %>
|
20
|
+
<%= f.semantic_fields_for(:content_block) do |builder| %>
|
21
|
+
<%= render partial: "#{page_content.content_block_type.underscore.pluralize}/form_fields", locals: { f: builder } %>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
data/lib/smithy.rb
CHANGED
@@ -3,7 +3,7 @@ module Smithy
|
|
3
3
|
module Model
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
included do
|
6
|
-
has_many :page_contents, :
|
6
|
+
has_many :page_contents, as: :content_block, class_name: '::Smithy::PageContent', dependent: :destroy
|
7
7
|
has_many :pages, through: :page_contents, class_name: '::Smithy::Page'
|
8
8
|
Smithy::ContentBlocks::Registry.register self
|
9
9
|
amoeba do
|
@@ -20,8 +20,7 @@ module Smithy
|
|
20
20
|
return unless ActiveRecord::Base.connection.table_exists?(content_block.table_name)
|
21
21
|
content_block_name = content_block.to_s.demodulize
|
22
22
|
@@content_blocks << content_block_name unless @@content_blocks.include?(content_block_name)
|
23
|
-
|
24
|
-
cb.save
|
23
|
+
Smithy::ContentBlock.find_or_create_by(name: content_block_name)
|
25
24
|
@@content_blocks
|
26
25
|
end
|
27
26
|
end
|
data/lib/smithy/dependencies.rb
CHANGED
data/lib/smithy/engine.rb
CHANGED
@@ -26,7 +26,8 @@ module Smithy
|
|
26
26
|
end
|
27
27
|
|
28
28
|
initializer :assets do |config|
|
29
|
-
|
29
|
+
icons = %w(_blank _page doc pdf ppt txt xls xlsx)
|
30
|
+
Rails.application.config.assets.precompile += %w( ZeroClipboard.swf smithy/logo-sm.png) + icons.map{|icon| "smithy/icons/#{icon}.png" }
|
30
31
|
end
|
31
32
|
|
32
33
|
config.after_initialize do
|
@@ -40,8 +41,8 @@ module Smithy
|
|
40
41
|
# we need to require all our model files so that ContentBlocks
|
41
42
|
# are registered with the engine
|
42
43
|
Dir[Smithy::Engine.root.join('app', 'models', 'smithy', '*.rb')].each do |file|
|
43
|
-
table_name = File.basename(file, '.rb').pluralize
|
44
|
-
|
44
|
+
table_name = "smithy_#{File.basename(file, '.rb').pluralize}"
|
45
|
+
require file if ActiveRecord::Base.connection.table_exists?(table_name)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
@@ -47,14 +47,18 @@ module Smithy
|
|
47
47
|
def render(context)
|
48
48
|
controller = context.registers[:controller]
|
49
49
|
javascript = Smithy::Template.javascripts.find_by(name: tag_without_ext('js'))
|
50
|
-
|
50
|
+
path = "/templates/javascripts/#{tag_with_ext('js')}"
|
51
|
+
path += "?#{javascript.updated_at.to_s(:number)}" if javascript.present?
|
52
|
+
controller.view_context.send(:javascript_include_tag, path)
|
51
53
|
end
|
52
54
|
end
|
53
55
|
class SmithyStylesheetLinkTag < Base
|
54
56
|
def render(context)
|
55
57
|
controller = context.registers[:controller]
|
56
58
|
stylesheet = Smithy::Template.stylesheets.find_by(name: tag_without_ext('css'))
|
57
|
-
|
59
|
+
path = "/templates/stylesheets/#{tag_with_ext('css')}"
|
60
|
+
path += "?#{stylesheet.updated_at.to_s(:number)}" if stylesheet.present?
|
61
|
+
controller.view_context.send(:stylesheet_link_tag, path)
|
58
62
|
end
|
59
63
|
end
|
60
64
|
end
|