smithycms 0.0.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +4 -1
  3. data/Rakefile +6 -12
  4. data/app/controllers/smithy/assets_controller.rb +3 -3
  5. data/app/controllers/smithy/base_controller.rb +9 -0
  6. data/app/controllers/smithy/content_blocks_controller.rb +3 -3
  7. data/app/controllers/smithy/content_pieces_controller.rb +6 -6
  8. data/app/controllers/smithy/contents_controller.rb +3 -3
  9. data/app/controllers/smithy/images_controller.rb +3 -3
  10. data/app/controllers/smithy/page_contents_controller.rb +4 -4
  11. data/app/controllers/smithy/pages_controller.rb +3 -3
  12. data/app/controllers/smithy/settings_controller.rb +3 -3
  13. data/app/controllers/smithy/templates_controller.rb +5 -5
  14. data/app/models/smithy/asset.rb +4 -5
  15. data/app/models/smithy/content.rb +0 -2
  16. data/app/models/smithy/content_block.rb +1 -3
  17. data/app/models/smithy/content_block_template.rb +1 -3
  18. data/app/models/smithy/image.rb +0 -2
  19. data/app/models/smithy/page.rb +5 -3
  20. data/app/models/smithy/page_content.rb +3 -5
  21. data/app/models/smithy/page_list.rb +0 -2
  22. data/app/models/smithy/permitted_params.rb +57 -0
  23. data/app/models/smithy/setting.rb +0 -1
  24. data/app/models/smithy/template.rb +6 -9
  25. data/app/models/smithy/template_container.rb +1 -3
  26. data/app/views/smithy/assets/edit.html.erb +1 -1
  27. data/app/views/smithy/assets/new.html.erb +4 -10
  28. data/config/initializers/dragonfly.rb +18 -38
  29. data/config/routes.rb +8 -8
  30. data/lib/smithy/content_blocks/registry.rb +1 -1
  31. data/lib/smithy/dependencies.rb +0 -1
  32. data/lib/smithy/dragonfly/asset_helper.rb +11 -11
  33. data/lib/smithy/dragonfly/remote_data_store.rb +3 -9
  34. data/lib/smithy/dragonfly.rb +1 -1
  35. data/lib/smithy/engine.rb +2 -1
  36. data/lib/smithy/formatter.rb +4 -5
  37. data/lib/smithy/version.rb +1 -1
  38. metadata +120 -220
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c8d0a9c785b4f6f88d4852f538d4af020eca85df
4
+ data.tar.gz: c8b09872f45049bd4853bd521c945c920cb459f3
5
+ SHA512:
6
+ metadata.gz: 2f24d3f4efbb2ccd2c8cba5f87d4d85c3de907fa585aa07dcec4df803edd098fdc9ddc314d80513626180b9405b39bb1dd4a611aea5ff30827e7f11d80089f08
7
+ data.tar.gz: c1cd515a71a1826b34fd54501fbefc8b11b465b83ba0064312342900d6b5e02e7344e297cf9743b633eb57e912d4eb3ecd6d5e46a309f4068790373aea3980fc
data/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/smithycms.png)](http://badge.fury.io/rb/smithycms)
4
4
  [![Code Climate](https://codeclimate.com/github/sterrym/smithy.png)](https://codeclimate.com/github/sterrym/smithy)
5
+ [![Build Status](https://travis-ci.org/sterrym/smithycms.png?branch=master)](https://travis-ci.org/sterrym/smithycms)
6
+ [![Coverage Status](https://coveralls.io/repos/sterrym/smithycms/badge.png)](https://coveralls.io/r/sterrym/smithycms)
7
+ [![Dependency Status](https://gemnasium.com/sterrym/smithycms.png)](https://gemnasium.com/sterrym/smithycms)
5
8
 
6
9
  ## Templates & Includes
7
10
  These are the building blocks of a page. All the markup is written using the Liquid templating engine. This allows anyone to be able to write templates without the dangers of exposing the whole stack to the template editor.
@@ -41,7 +44,7 @@ Now start up your server and go to http://localhost:nnnn/smithy
41
44
 
42
45
  ## Integrating with third-party authentication
43
46
 
44
- Add this to your routes file (below the `mount Smithy::Engine` line). It will redirect smithy/login|logout (the built-in paths) to your existing authentication paths.
47
+ Add this to your routes file (before the `mount Smithy::Engine` line). It will redirect smithy/login|logout (the built-in paths) to your existing authentication paths.
45
48
 
46
49
  ```ruby
47
50
  scope "/smithy" do
data/Rakefile CHANGED
@@ -1,27 +1,21 @@
1
- #!/usr/bin/env rake
2
1
  begin
3
2
  require 'bundler/setup'
4
3
  rescue LoadError
5
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
5
  end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
6
+
7
+ require 'rdoc/task'
14
8
 
15
9
  RDoc::Task.new(:rdoc) do |rdoc|
16
10
  rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'Smithy'
11
+ rdoc.title = 'SampleEngine'
18
12
  rdoc.options << '--line-numbers'
19
13
  rdoc.rdoc_files.include('README.rdoc')
20
14
  rdoc.rdoc_files.include('lib/**/*.rb')
21
15
  end
22
16
 
23
-
24
-
25
-
26
17
  Bundler::GemHelper.install_tasks
27
18
 
19
+ require 'rspec/core/rake_task'
20
+ RSpec::Core::RakeTask.new(:spec)
21
+ task :default => :spec
@@ -10,12 +10,12 @@ module Smithy
10
10
  end
11
11
 
12
12
  def new
13
- @asset = Asset.new(params[:asset])
13
+ @asset = Asset.new(filtered_params)
14
14
  respond_with @asset
15
15
  end
16
16
 
17
17
  def create
18
- @asset = Asset.new(params[:asset])
18
+ @asset = Asset.new(filtered_params)
19
19
  @asset.save
20
20
  flash.notice = "Your asset was created" if @asset.persisted?
21
21
  respond_with @asset do |format|
@@ -30,7 +30,7 @@ module Smithy
30
30
 
31
31
  def update
32
32
  @asset = Asset.find(params[:id])
33
- flash.notice = "Your asset was saved" if @asset.update_attributes(params[:asset])
33
+ flash.notice = "Your asset was saved" if @asset.update_attributes(filtered_params)
34
34
  respond_with @asset do |format|
35
35
  format.html { redirect_to assets_path }
36
36
  end
@@ -11,4 +11,13 @@ class Smithy::BaseController < ApplicationController
11
11
  redirect_to smithy_login_path
12
12
  end
13
13
  end
14
+
15
+ def filtered_params
16
+ permitted_params.params_for controller_name.singularize
17
+ end
18
+
19
+ def permitted_params
20
+ permitted_params ||= PermittedParams.new(params, smithy_current_user)
21
+ end
22
+ helper_method :permitted_params
14
23
  end
@@ -10,12 +10,12 @@ module Smithy
10
10
  end
11
11
 
12
12
  def new
13
- @content_block = ContentBlock.new(params[:content_block])
13
+ @content_block = ContentBlock.new(filtered_params)
14
14
  respond_with @content_block
15
15
  end
16
16
 
17
17
  def create
18
- @content_block = ContentBlock.new(params[:content_block])
18
+ @content_block = ContentBlock.new(filtered_params)
19
19
  @content_block.save
20
20
  flash.notice = "Your content_block was created" if @content_block.persisted?
21
21
  respond_with @content_block do |format|
@@ -30,7 +30,7 @@ module Smithy
30
30
 
31
31
  def update
32
32
  @content_block = ContentBlock.find(params[:id])
33
- flash.notice = "Your content_block was saved" if @content_block.update_attributes(params[:content_block])
33
+ flash.notice = "Your content_block was saved" if @content_block.update_attributes(filtered_params)
34
34
  respond_with @content_block do |format|
35
35
  format.html { redirect_to [:edit, @content_block] }
36
36
  end
@@ -54,6 +54,10 @@ class Smithy::ContentPiecesController < Smithy::BaseController
54
54
  end
55
55
 
56
56
  private
57
+ def filtered_params
58
+ permitted_params.params_for klass.name.sub(/^Smithy::/, '').underscore
59
+ end
60
+
57
61
  def klass
58
62
  # override to provide an object for each class
59
63
  raise "You must inherit from this Smithy::ContentPiecesController and provide a private #klass method"
@@ -63,12 +67,8 @@ class Smithy::ContentPiecesController < Smithy::BaseController
63
67
  @klass_name ||= klass.name.sub(/^Smithy::/, '').titleize
64
68
  end
65
69
 
66
- def klass_params
67
- params[klass.name.sub(/^Smithy::/, '').underscore]
68
- end
69
-
70
70
  def new_record
71
- klass.new(klass_params)
71
+ klass.new(filtered_params)
72
72
  end
73
73
 
74
74
  def find_record
@@ -84,7 +84,7 @@ class Smithy::ContentPiecesController < Smithy::BaseController
84
84
  end
85
85
 
86
86
  def update_record(record)
87
- record.update_attributes(klass_params)
87
+ record.update_attributes(filtered_params)
88
88
  end
89
89
 
90
90
  def readable_attributes
@@ -10,12 +10,12 @@ module Smithy
10
10
  end
11
11
 
12
12
  def new
13
- @content = Smithy::Content.new(params[:content])
13
+ @content = Smithy::Content.new(filtered_params)
14
14
  respond_with @content
15
15
  end
16
16
 
17
17
  def create
18
- @content = Smithy::Content.new(params[:content])
18
+ @content = Smithy::Content.new(filtered_params)
19
19
  @content.save
20
20
  flash.notice = "Your content was created" if @content.persisted?
21
21
  respond_with @content
@@ -28,7 +28,7 @@ module Smithy
28
28
 
29
29
  def update
30
30
  @content = Smithy::Content.find(params[:id])
31
- flash.notice = "Your content was saved" if @content.update_attributes(params[:content])
31
+ flash.notice = "Your content was saved" if @content.update_attributes(filtered_params)
32
32
  respond_with @content
33
33
  end
34
34
 
@@ -10,12 +10,12 @@ module Smithy
10
10
  end
11
11
 
12
12
  def new
13
- @image = Smithy::Image.new(params[:image])
13
+ @image = Smithy::Image.new(filtered_params)
14
14
  respond_with @image
15
15
  end
16
16
 
17
17
  def create
18
- @image = Smithy::Image.new(params[:image])
18
+ @image = Smithy::Image.new(filtered_params)
19
19
  @image.save
20
20
  flash.notice = "Your image was created" if @image.persisted?
21
21
  respond_with @image
@@ -28,7 +28,7 @@ module Smithy
28
28
 
29
29
  def update
30
30
  @image = Smithy::Image.find(params[:id])
31
- flash.notice = "Your image was saved" if @image.update_attributes(params[:image])
31
+ flash.notice = "Your image was saved" if @image.update_attributes(filtered_params)
32
32
  respond_with @image
33
33
  end
34
34
 
@@ -9,7 +9,7 @@ module Smithy
9
9
  respond_to :html, :json
10
10
 
11
11
  def new
12
- @page_content = Smithy::PageContent.new(params[:page_content])
12
+ @page_content = Smithy::PageContent.new(filtered_params)
13
13
  @page_content.label = [@page.title, @page_content.container.titleize].join(' - ') unless @page_content.label?
14
14
  end
15
15
 
@@ -17,8 +17,8 @@ module Smithy
17
17
  @page_content = Smithy::PageContent.new
18
18
  # we have to ensure that the content_block_type gets added before the content_block_attributes
19
19
  # see PageContent#content_block_attributes=
20
- @page_content.content_block_type = params[:page_content][:content_block_type]
21
- @page_content.attributes = params[:page_content]
20
+ @page_content.content_block_type = filtered_params[:content_block_type]
21
+ @page_content.attributes = filtered_params
22
22
  @page_content.page = @page
23
23
  @page_content.save
24
24
  respond_with @page_content do |format|
@@ -32,7 +32,7 @@ module Smithy
32
32
 
33
33
  def update
34
34
  @page_content = Smithy::PageContent.find(params[:id])
35
- @saved = @page_content.update_attributes(params[:page_content])
35
+ @saved = @page_content.update_attributes(filtered_params)
36
36
  flash.notice = "Your content was saved" if @saved
37
37
  respond_with @page_content do |format|
38
38
  format.html { @saved ? redirect_to(edit_page_path(@page.id)) : render(:action => "edit") }
@@ -39,7 +39,7 @@ module Smithy
39
39
  end
40
40
 
41
41
  def update
42
- flash.notice = "Your page was saved #{@page.published? ? 'and published' : 'as a draft'}" if @page.update_attributes(params[:page])
42
+ flash.notice = "Your page was saved #{@page.published? ? 'and published' : 'as a draft'}" if @page.update_attributes(filtered_params)
43
43
  respond_with @page do |format|
44
44
  format.html { redirect_to edit_page_path(@page.id) }
45
45
  end
@@ -67,7 +67,7 @@ module Smithy
67
67
 
68
68
  private
69
69
  def initialize_page
70
- @page = Page.new(params[:page])
70
+ @page = Page.new(filtered_params)
71
71
  set_publish
72
72
  end
73
73
 
@@ -78,7 +78,7 @@ module Smithy
78
78
  end
79
79
 
80
80
  def load_page_from_path
81
- @page = Page.find(page_path)
81
+ @page = Page.friendlfind(page_path)
82
82
  redirect_to @page.external_link and return false if @page.external_link?
83
83
  end
84
84
 
@@ -15,12 +15,12 @@ module Smithy
15
15
  end
16
16
 
17
17
  def new
18
- @setting = Setting.new(params[:setting])
18
+ @setting = Setting.new(filtered_params)
19
19
  respond_with @setting
20
20
  end
21
21
 
22
22
  def create
23
- @setting = Setting.new(params[:setting])
23
+ @setting = Setting.new(filtered_params)
24
24
  @setting.save
25
25
  flash.notice = "Your setting was created" if @setting.persisted?
26
26
  respond_with @setting
@@ -33,7 +33,7 @@ module Smithy
33
33
 
34
34
  def update
35
35
  @setting = Setting.find(params[:id])
36
- flash.notice = "Your setting was saved" if @setting.update_attributes(params[:setting])
36
+ flash.notice = "Your setting was saved" if @setting.update_attributes(filtered_params)
37
37
  respond_with @setting
38
38
  end
39
39
 
@@ -11,12 +11,12 @@ module Smithy
11
11
  end
12
12
 
13
13
  def new
14
- @template = Template.new(params[:template])
14
+ @template = Template.new(filtered_params)
15
15
  respond_with @template
16
16
  end
17
17
 
18
18
  def create
19
- @template = Template.new(params[:template])
19
+ @template = Template.new(filtered_params)
20
20
  @template.save
21
21
  flash.notice = "Your template was created" if @template.persisted?
22
22
  respond_with @template do |format|
@@ -39,7 +39,7 @@ module Smithy
39
39
 
40
40
  def update
41
41
  @template = Template.find(params[:id])
42
- flash.notice = "Your template was saved" if @template.update_attributes(params[:template])
42
+ flash.notice = "Your template was saved" if @template.update_attributes(filtered_params)
43
43
  respond_with @template do |format|
44
44
  format.html { redirect_to [:edit, @template] }
45
45
  end
@@ -52,12 +52,12 @@ module Smithy
52
52
  end
53
53
 
54
54
  def javascript
55
- @javascript = Template.javascripts.find_by_name(params[:javascript].sub(/\.js$/, ''))
55
+ @javascript = Template.javascripts.find_by(name: params[:javascript].sub(/\.js$/, ''))
56
56
  render_asset_template(@javascript, params[:javascript], 'text/javascript')
57
57
  end
58
58
 
59
59
  def stylesheet
60
- @stylesheet = Template.stylesheets.find_by_name(params[:stylesheet].sub(/\.css$/, ''))
60
+ @stylesheet = Template.stylesheets.find_by(name: params[:stylesheet].sub(/\.css$/, ''))
61
61
  render_asset_template(@stylesheet, params[:stylesheet], 'text/css')
62
62
  end
63
63
 
@@ -1,18 +1,17 @@
1
1
  module Smithy
2
2
  class Asset < ActiveRecord::Base
3
- attr_accessible :name, :file, :file_name, :file_url, :retained_file, :uploaded_file_url
4
-
5
3
  validates_presence_of :file, :name
6
4
 
7
5
  has_many :images, :dependent => :destroy
8
6
 
9
- file_accessor :file
10
- include Smithy::Dragonfly::AssetHelper
7
+ extend ::Dragonfly::Model
8
+ dragonfly_accessor :file
9
+ include ::Smithy::Dragonfly::AssetHelper
11
10
 
12
11
  before_validation :set_name
13
12
  before_save :set_file_uid_manually
14
13
 
15
- default_scope order(:name)
14
+ default_scope -> { order(:name) }
16
15
 
17
16
  def file
18
17
  # check for the jquery uploaded file first, just in case one got past the manual check. Also keeps backwards-compatibility
@@ -2,8 +2,6 @@ module Smithy
2
2
  class Content < ActiveRecord::Base
3
3
  include Smithy::ContentBlocks::Model
4
4
 
5
- attr_accessible :content
6
-
7
5
  validates_presence_of :content
8
6
 
9
7
  before_save :render_markdown_content
@@ -1,7 +1,5 @@
1
1
  module Smithy
2
2
  class ContentBlock < ActiveRecord::Base
3
- attr_accessible :name, :templates_attributes
4
-
5
3
  validates_presence_of :name
6
4
 
7
5
  has_many :templates, :class_name => "ContentBlockTemplate"
@@ -11,7 +9,7 @@ module Smithy
11
9
 
12
10
  accepts_nested_attributes_for :templates, :reject_if => lambda {|a| a['name'].blank? || a['content'].blank? }, :allow_destroy => true
13
11
 
14
- default_scope order(:name)
12
+ default_scope -> { order(:name) }
15
13
 
16
14
  def description
17
15
  klass.content_block_description if klass
@@ -1,7 +1,5 @@
1
1
  module Smithy
2
2
  class ContentBlockTemplate < ActiveRecord::Base
3
- attr_accessible :content, :name
4
-
5
3
  belongs_to :content_block, :touch => true
6
4
  has_many :page_contents
7
5
 
@@ -11,7 +9,7 @@ module Smithy
11
9
 
12
10
  after_save :touch_page_contents
13
11
 
14
- default_scope order(:name)
12
+ default_scope -> { order(:name) }
15
13
 
16
14
  def liquid_template
17
15
  @liquid_template ||= ::Liquid::Template.parse(self.content)
@@ -2,8 +2,6 @@ module Smithy
2
2
  class Image < ActiveRecord::Base
3
3
  include Smithy::ContentBlocks::Model
4
4
 
5
- attr_accessible :alternate_text, :asset_id, :height, :html_attributes, :image_scaling, :link_url, :width, :content
6
-
7
5
  validates_presence_of :asset
8
6
 
9
7
  belongs_to :asset
@@ -1,7 +1,5 @@
1
1
  module Smithy
2
2
  class Page < ActiveRecord::Base
3
- attr_accessible :browser_title, :cache_length, :description, :external_link, :keywords, :permalink, :publish, :published_at, :show_in_navigation, :title, :parent_id, :template_id
4
-
5
3
  validates_presence_of :template, :title
6
4
  validate :validate_one_root
7
5
  validate :validate_exclusion_of_reserved_words
@@ -19,7 +17,7 @@ module Smithy
19
17
 
20
18
  accepts_nested_attributes_for :contents, :reject_if => lambda {|a| a['label'].blank? || a['container'].blank? || a['content_block'].blank? }, :allow_destroy => true
21
19
 
22
- scope :included_in_navigation, lambda{ where("show_in_navigation=? AND published_at <= ?", true, Time.now) }
20
+ scope :included_in_navigation, -> { where("show_in_navigation=? AND published_at <= ?", true, Time.now) }
23
21
 
24
22
  attr_accessor :publish
25
23
 
@@ -37,6 +35,10 @@ module Smithy
37
35
  [(self.parent.present? && !self.parent.root? ? self.parent.path : nil), value].join('/')
38
36
  end
39
37
 
38
+ def should_generate_new_friendly_id?
39
+ title_changed? || permalink_changed?
40
+ end
41
+
40
42
  def published?
41
43
  self.published_at?
42
44
  end
@@ -1,7 +1,5 @@
1
1
  module Smithy
2
2
  class PageContent < ActiveRecord::Base
3
- attr_accessible :label, :container, :content_block_type, :content_block_attributes, :content_block_template_id, :position
4
-
5
3
  validates_presence_of :content_block, :content_block_template, :on => :update
6
4
  validates_presence_of :content_block_type, :on => :create
7
5
  validates_presence_of :label, :container, :page
@@ -14,9 +12,9 @@ module Smithy
14
12
 
15
13
  accepts_nested_attributes_for :content_block, :allow_destroy => true
16
14
 
17
- default_scope order(:position).order(:id)
18
- scope :for_container, lambda {|container| where(:container => container) }
19
- scope :publishable, lambda { where(:publishable => true) }
15
+ default_scope -> { order(:position).order(:id) }
16
+ scope :for_container, ->(container) { where(:container => container) }
17
+ scope :publishable, -> { where(:publishable => true) }
20
18
 
21
19
  def attributes=(attributes = {})
22
20
  self.content_block_type = attributes[:content_block_type]
@@ -2,8 +2,6 @@ module Smithy
2
2
  class PageList < ActiveRecord::Base
3
3
  include Smithy::ContentBlocks::Model
4
4
 
5
- attr_accessible :count, :page_template_id, :parent_id, :include_children, :sort
6
-
7
5
  validates_presence_of :parent_id
8
6
 
9
7
  belongs_to :parent, :class_name => "Page"
@@ -0,0 +1,57 @@
1
+ module Smithy
2
+ class PermittedParams < Struct.new(:params, :user)
3
+ def params_for(param)
4
+ param = param.to_sym
5
+ attributes = send("#{param.to_s}_attributes".to_sym)
6
+ if attributes == :all
7
+ params.fetch(param, {}).permit!
8
+ else
9
+ params.fetch(param, {}).permit( *attributes )
10
+ end
11
+ end
12
+
13
+ def asset_attributes
14
+ [ :name, :file, :file_name, :file_url, :retained_file, :uploaded_file_url ]
15
+ end
16
+
17
+ def content_attributes
18
+ [ :content ]
19
+ end
20
+
21
+ def content_block_attributes
22
+ [ :name, :templates_attributes ]
23
+ end
24
+
25
+ def content_block_template_attributes
26
+ [ :content, :name ]
27
+ end
28
+
29
+ def image_attributes
30
+ [ :alternate_text, :asset_id, :height, :html_attributes, :image_scaling, :link_url, :width, :content ]
31
+ end
32
+
33
+ def page_attributes
34
+ [ :browser_title, :cache_length, :description, :external_link, :keywords, :permalink, :publish, :published_at, :show_in_navigation, :title, :parent_id, :template_id ]
35
+ end
36
+
37
+ def page_content_attributes
38
+ [ :label, :container, :content_block_type, :content_block_attributes, :content_block_template_id, :position ]
39
+ end
40
+
41
+ def page_list_attributes
42
+ [ :count, :page_template_id, :parent_id, :include_children, :sort ]
43
+ end
44
+
45
+ def setting_attributes
46
+ [ :name, :value ]
47
+ end
48
+
49
+ def template_attributes
50
+ [ :name, :content, :template_type ]
51
+ end
52
+
53
+ def template_container_attributes
54
+ [ :name, :position ]
55
+ end
56
+ end
57
+ end
@@ -1,6 +1,5 @@
1
1
  module Smithy
2
2
  class Setting < ActiveRecord::Base
3
- attr_accessible :name, :value
4
3
  validates_presence_of :name, :value
5
4
  end
6
5
  end
@@ -1,23 +1,21 @@
1
1
  module Smithy
2
2
  class Template < ActiveRecord::Base
3
- attr_accessible :name, :content, :template_type
4
-
5
3
  validates_presence_of :name
6
4
  validates_uniqueness_of :name, :scope => :template_type
7
5
  validates_presence_of :content, :on => :update
8
6
 
9
7
  has_many :pages
10
- has_many :containers, :class_name => "TemplateContainer"
8
+ has_many :containers, :class_name => "Smithy::TemplateContainer"
11
9
 
12
10
  before_save :uncache_liquid_template_if_content_changed
13
11
  after_save :load_containers
14
12
  after_save :touch_pages
15
13
 
16
- default_scope order(:name)
17
- scope :javascripts, where(:template_type => "javascript")
18
- scope :partials, where(:template_type => "include")
19
- scope :stylesheets, where(:template_type => "stylesheet")
20
- scope :templates, where(:template_type => "template")
14
+ default_scope -> { order(:name) }
15
+ scope :javascripts, -> { where(:template_type => "javascript") }
16
+ scope :partials, -> { where(:template_type => "include") }
17
+ scope :stylesheets, -> { where(:template_type => "stylesheet") }
18
+ scope :templates, -> { where(:template_type => "template") }
21
19
 
22
20
  class << self
23
21
  def types
@@ -36,7 +34,6 @@ module Smithy
36
34
  def load_containers
37
35
  return unless self.template_type == 'template'
38
36
  container_names = liquid_template.root.nodelist.select{|n| n.is_a?(::Liquid::Variable) && n.name.match(/^page\.container\.(.*)/) }.map{|n| n.name.match(/^page\.container\.(.*)/)[1] }
39
- # self.containers = container_names.map{|container_name| Smithy::TemplateContainer.new(:name => container_name) }
40
37
  self.containers = container_names.inject([]) do |containers, container_name|
41
38
  containers.push Smithy::TemplateContainer.new(:name => container_name, :position => containers.size)
42
39
  end
@@ -5,9 +5,7 @@ module Smithy
5
5
  belongs_to :template
6
6
  has_many :pages, :through => :template
7
7
 
8
- attr_accessible :name, :position
9
-
10
- default_scope :order => [:position, :name]
8
+ default_scope -> { order([:position, :name]) }
11
9
 
12
10
  def display_name
13
11
  name.titleize
@@ -1,4 +1,4 @@
1
- <% content_for :title, "Assets" %>
1
+ <% content_for :title, "Images &amp; Files".html_safe %>
2
2
 
3
3
  <div class="well">
4
4
  <%= render :partial => "form" %>
@@ -1,13 +1,7 @@
1
- <% content_for :title, "Images &amp; Files" %>
1
+ <% content_for :title, "Images &amp; Files".html_safe %>
2
2
 
3
- <%= semantic_form_for @template, :html => { :class => 'form-horizontal' } do |f| %>
4
- <%= f.inputs "New #{@template.template_type.capitalize}" do %>
5
- <%= f.input :name %>
6
- <%= f.input :template_type, :as => :hidden %>
7
- <% end %>
8
- <%= f.actions :submit %>
9
- <% end %>
10
-
11
- <%= render :partial => "secondary_nav" %>
3
+ <div class="well">
4
+ <%= render :partial => "form" %>
5
+ </div>
12
6
 
13
7
  <% content_for :related, nil %>