Class: Inkling::Theme

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
FileUtils
Defined in:
app/models/inkling/theme.rb

Overview

maintain one record which will theme the entire site for now

Constant Summary collapse

@@default_content =
<<-DEFAULT
  <html>
  <head>
    <title>Your Inkling CMS</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
  </head>
  <body>

  This is the default theme for public users to view content on your site. <br/>
  
  An administrator should log into Inkling Administration and configure the 'content' theme. <br/>

  <div class="notice"><%= notice %></div>
  <div class="alert"><%= alert %></div>

  <div id="page">
    <div id="main">
  <%= yield %> 
    </div>
  </div>

  <div id="footer">
    <span id="version" align='center'>Inkling version <%= Inkling::VERSION %></span>
  </div>


  </body>
  </html>
DEFAULT

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.contentObject



45
46
47
48
49
50
51
# File 'app/models/inkling/theme.rb', line 45

def self.content
  if Inkling::Theme.find_by_name("content").nil?
    self.create!(:name => "content", :body =>  @@default_content)
  end
  
  Inkling::Theme.find_by_name("content")
end

.install_from_dir(dirname) ⇒ Object

takes a directory and recursively interns all structures there as a theme structure (just like any sub directory in app/views)



59
60
61
# File 'app/models/inkling/theme.rb', line 59

def self.install_from_dir(dirname)
  
end

.site_theme_fileObject



53
54
55
# File 'app/models/inkling/theme.rb', line 53

def self.site_theme_file
  "#{Inkling::THEME_LAYOUTS_DIR}#{self.site.file_name}"
end

Instance Method Details

#check_initObject



67
68
69
70
71
# File 'app/models/inkling/theme.rb', line 67

def check_init
  mkdir(Inkling::TMP_DIR) unless File.exist?(Inkling::TMP_DIR)
  mkdir("#{Inkling::THEMES_DIR}") unless File.exist?("#{Inkling::THEMES_DIR}") 
  mkdir("#{Inkling::THEME_LAYOUTS_DIR}") unless File.exist?("#{Inkling::THEME_LAYOUTS_DIR}") 
end

#delete_fileObject



73
74
75
# File 'app/models/inkling/theme.rb', line 73

def delete_file
  rm("#{Inkling::THEME_LAYOUTS_DIR}#{self.file_name}")
end

#file_nameObject



77
78
79
# File 'app/models/inkling/theme.rb', line 77

def file_name
  "#{self.name}#{self.extension}"
end

#write_fileObject



63
64
65
# File 'app/models/inkling/theme.rb', line 63

def write_file
  File.open("#{Inkling::THEME_LAYOUTS_DIR}#{self.file_name}", "w") {|f| f.write(self.body)}
end