Module: Zen

Defined in:
lib/zen.rb,
lib/zen/event.rb,
lib/zen/theme.rb,
lib/zen/error.rb,
lib/zen/markup.rb,
lib/zen/version.rb,
lib/zen/package.rb,
lib/zen/language.rb,
lib/zen/validation.rb,
lib/zen/bin/create.rb,
lib/zen/bin/default.rb,
lib/zen/package/menu.rb,
lib/zen/model/helper.rb,
lib/zen/controller/preview.rb,
lib/zen/language/translation.rb,
lib/zen/controller/translations.rb,
lib/zen/controller/main_controller.rb,
lib/zen/controller/base_controller.rb,
lib/zen/controller/admin_controller.rb,
lib/zen/controller/frontend_controller.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Bin, Controller, Event, Markup, Model, Validation Classes: Language, LanguageError, Package, PackageError, PluginError, Theme, ThemeError, ValidationError

Constant Summary

VERSION =

:nodoc:

'0.3'

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Class Attribute Details

+ (Object) asset

Instance of Ramaze::Asset::Environment to use for all backend assets.

Since:

  • 0.1



26
27
28
# File 'lib/zen.rb', line 26

def asset
  @asset
end

+ (Object) database

The database connection to use for Sequel.

Since:

  • 0.1



23
24
25
# File 'lib/zen.rb', line 23

def database
  @database
end

+ (Object) root

The root directory of the application.

Since:

  • 0.1



29
30
31
# File 'lib/zen.rb', line 29

def root
  @root
end

Class Method Details

+ (Object) load_global_assets (private)

Loads a global CSS and JS file.

Since:

  • 0.3



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/zen.rb', line 138

def load_global_assets
  publics    = Ramaze.options.publics
  css_loaded = false
  js_loaded  = false

  publics.each do |p|
    p   = File.join(Zen.root, p)
    css = File.join(p, 'admin', 'css', 'global.css')
    js  = File.join(p, 'admin', 'js', 'global.js')

    if File.exist?(css) and css_loaded == false
      Zen.asset.serve(:css, ['admin/css/global'])
      css_loaded = true
    end

    if File.exist?(js) and js_loaded == false
      Zen.asset.serve(:javascript, ['admin/js/global'])
      js_loaded = true
    end
  end
end

+ (Object) setup_assets (private)

Configures Ramaze::Asset and loads all the global assets.

Since:

  • 0.3



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/zen.rb', line 92

def setup_assets
  cache_path = File.join(root, 'public', 'minified')

  if !File.directory?(cache_path)
    Dir.mkdir(cache_path)
  end

  Zen.asset = Ramaze::Asset::Environment.new(
    :cache_path => cache_path,
    :minify     => Ramaze.options.mode == :live
  )

  Zen.asset.serve(
    :css,
    [
      'admin/css/zen/reset',
      'admin/css/zen/grid',
      'admin/css/zen/layout',
      'admin/css/zen/general',
      'admin/css/zen/forms',
      'admin/css/zen/tables',
      'admin/css/zen/buttons',
      'admin/css/zen/messages'
    ],
    :name => 'zen_core'
  )

  Zen.asset.serve(
    :javascript,
    [
      'admin/js/vendor/mootools/core',
      'admin/js/vendor/mootools/more',
      'admin/js/zen/lib/html_table',
      'admin/js/zen/index'
    ],
    :name => 'zen_core'
  )

  require 'zen/asset_groups'
end

+ (Object) start

Prepares Zen for the party of it's life.

Since:

  • 0.3



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/zen.rb', line 49

def start
  if root.nil?
    raise('You need to specify a valid root directory in Zen.root')
  end

  # Set up Ramaze::Cache manually. This makes it possible for the langauge
  # files to cache their data in the custom cache without having to wait for
  # Ramaze to set it up.
  Ramaze::Cache.setup
  Ramaze.options.setup.delete(Ramaze::Cache)

  require 'zen/model/init'
  require 'zen/model/methods'

  setup_assets

  require 'zen/package/all'

  # Load the global stylesheet and Javascript file if they're located in
  # ROOT/public/css/admin/global.css and ROOT/public/js/admin/global.js
  load_global_assets

  # Migrate all settings
  begin
    Settings::Setting.migrate
  rescue => e
    Ramaze::Log.warn(
      'Failed to migrate the settings, make sure the database ' \
        'table is up to date and that you executed rake db:migrate.'
    )
  end

  Zen.asset.build(:javascript)
  Zen.asset.build(:css)
end