Class: Layout
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Layout
- Defined in:
- app/models/layout.rb
Class Method Summary collapse
- .create_default(sid, user_id) ⇒ Object
- .default(sid) ⇒ Object
- .name_exists?(sid, name) ⇒ Boolean
- .preference(sid, name) ⇒ Object
Instance Method Summary collapse
- #display_name ⇒ Object
- #handler_enum ⇒ Object
- #history ⇒ Object
- #javascripts ⇒ Object
- #locale_enum ⇒ Object
- #make_path ⇒ Object
- #old_javascripts ⇒ Object
- #old_stylesheets ⇒ Object
- #record_history ⇒ Object
- #set_format ⇒ Object
- #stylesheets ⇒ Object
Class Method Details
.create_default(sid, user_id) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/models/layout.rb', line 61 def self.create_default(sid, user_id) layout = Layout.new(:path=>"layouts/#{sid}/application", :handler=>"haml", :format=>"html", :locale=>"en", :system_id=>sid, :user_id=>user_id, :name=>"application", :body=><<eos !!! %html / Layout: application [#{sid}] %head = render :partial=>"layouts/kit_header" %style(type="text/css") div#edit_link { top:30px; } %body = yield eos ) layout.save! end |
.default(sid) ⇒ Object
57 58 59 |
# File 'app/models/layout.rb', line 57 def self.default(sid) Layout.sys(sid).order(:id).first end |
.name_exists?(sid, name) ⇒ Boolean
53 54 55 |
# File 'app/models/layout.rb', line 53 def self.name_exists?(sid, name) Layout.sys(sid).where("name = '#{name}'").count > 0 end |
.preference(sid, name) ⇒ Object
94 95 96 97 98 |
# File 'app/models/layout.rb', line 94 def self.preference(sid, name) l = Layout.sys(sid).where(:id=>Preference.get_cached(sid, name)).first rescue nil return l if l Layout.sys(sid).order("created_at").first end |
Instance Method Details
#display_name ⇒ Object
23 24 25 |
# File 'app/models/layout.rb', line 23 def display_name "Layout" end |
#handler_enum ⇒ Object
49 50 51 |
# File 'app/models/layout.rb', line 49 def handler_enum ['haml', 'erb', 'builder'] end |
#history ⇒ Object
33 34 35 |
# File 'app/models/layout.rb', line 33 def history DesignHistory.sys(self.system_id).where(:model=>"Layout").where(:model_id=>self.id).order("id desc") end |
#javascripts ⇒ Object
78 79 80 |
# File 'app/models/layout.rb', line 78 def javascripts self.html_assets.where(:file_type=>"js").all end |
#locale_enum ⇒ Object
45 46 47 |
# File 'app/models/layout.rb', line 45 def locale_enum ['en'] end |
#make_path ⇒ Object
37 38 39 |
# File 'app/models/layout.rb', line 37 def make_path self.path = "layouts/#{self.system_id}/#{self.name.urlise}" end |
#old_javascripts ⇒ Object
90 91 92 |
# File 'app/models/layout.rb', line 90 def old_javascripts self.read_attribute(:javascripts) end |
#old_stylesheets ⇒ Object
86 87 88 |
# File 'app/models/layout.rb', line 86 def old_stylesheets self.read_attribute(:stylesheets) end |
#record_history ⇒ Object
27 28 29 30 31 |
# File 'app/models/layout.rb', line 27 def record_history if self.changed.include?('body') DesignHistory.record(self) end end |
#set_format ⇒ Object
41 42 43 |
# File 'app/models/layout.rb', line 41 def set_format self.format = 'html' end |
#stylesheets ⇒ Object
82 83 84 |
# File 'app/models/layout.rb', line 82 def stylesheets self.html_assets.where(:file_type=>"css").all end |