lib/caboodle/kit.rb in caboodle-0.1.4 vs lib/caboodle/kit.rb in caboodle-0.1.5
- old
+ new
@@ -57,11 +57,11 @@
unless name.blank?
kit_name = name.to_s.split("::").last || name
kit_name = kit_name.downcase
puts "Loading Kit: #{kit_name}"
orig = Caboodle.constants
- require "caboodle/kits/#{kit_name}/#{kit_name}" rescue puts "Problem loading Kit: #{kit_name}"
+ require "caboodle/kits/#{kit_name}/#{kit_name}" #rescue puts "Problem loading Kit: #{kit_name}"
added = Caboodle.constants - orig
added.each do |d|
c = Caboodle.const_get(d)
if c.respond_to?(:is_a_caboodle_kit)
c.register
@@ -75,11 +75,11 @@
unless name.blank?
kit_name = name.to_s.split("::").last || name
kit_name = kit_name.downcase
puts "Loading Kit: #{kit_name}"
orig = Caboodle.constants
- require "caboodle/kits/#{kit_name}/#{kit_name}" rescue puts "Problem loading Kit: #{kit_name}"
+ require "caboodle/kits/#{kit_name}/#{kit_name}" #rescue puts "Problem loading Kit: #{kit_name}"
added = Caboodle.constants - orig
added.each do |d|
c = Caboodle.const_get(d)
if c.respond_to?(:is_a_caboodle_kit)
c.unregister
@@ -99,54 +99,81 @@
end
end
Site.kits << self.to_s.split("::").last
Site.kits.uniq!
Caboodle::Kits << self
+ Caboodle::Kits
end
def unregister
Caboodle::Kits.delete(self)
Caboodle::Site.kits.delete(self.to_s)
Caboodle::Kit.dump_config
+ Caboodle::Kits
end
def require_all
if(Caboodle::Site.kits)
Caboodle::Site.kits.each { |k| load_kit k }
else
STDERR.puts "Kits not registered"
end
+ Caboodle::Kits
end
def use_all
Caboodle::Kits.each { |p| p.start }
end
- def menu display, link
- Caboodle::MenuItems << {:display=>display, :link=>link}
+ def menu display, path, &block
+ path = "/" if Site.home_kit == self.to_s.gsub("Caboodle::","")
+ Caboodle::MenuItems << {:display=>display, :link=>path}
+ self.get path, &block
end
def required keys
if keys.class == Array
keys.each do |k|
self.required_settings << k
end
else
self.required_settings << keys
end
+ self.required_settings
end
def stylesheets array_of_css_files
- array_of_css_files.each { |a| Caboodle::Stylesheets << a }
+ if array_of_css_files.class == Array
+ array_of_css_files.each { |a| Caboodle::Stylesheets << a.to_s }
+ else
+ Caboodle::Stylesheets << array_of_css_files.to_s
+ end
Caboodle::Stylesheets.uniq!
end
+ alias_method :stylesheet, :stylesheets
+
def javascripts array_of_js_files
- array_of_js_files.each { |a| Caboodle::Javascripts << a }
+ if array_of_js_files.class == Array
+ array_of_js_files.each { |a| Caboodle::Javascripts << a.to_s }
+ else
+ Caboodle::Javascripts << array_of_js_files.to_s
+ end
Caboodle::Javascripts.uniq!
end
+ alias_method :javascript, :javascripts
+
+ def rss array_of_feeds
+ if array_of_feeds.class == Array
+ array_of_feeds.each { |a| Caboodle::RSS << a.to_s }
+ else
+ Caboodle::RSS << array_of_feeds.to_s
+ end
+ Caboodle::RSS.uniq!
+ end
+
def add_to_layout hash_of_items
hash_of_items.each do |k,v|
unless Caboodle::Layout[k.to_sym].blank?
Caboodle::Layout[k.to_sym] << "\n"
Caboodle::Layout[k.to_sym] << v
@@ -159,9 +186,13 @@
def defaults hash
if hash.class == Hash
hash.each {|k,v| Site[k] = v }
end
+ end
+
+ def original url
+ set :credit, "<a href='#{url}' rel='me'>via #{self.class.name.split("::").last}</a>"
end
def required_settings
r = RequiredSettings[self.ancestors.first.to_s.split("::").last] ||= [:title, :description, :logo_url, :author]
RequiredSettings[self.ancestors.first.to_s.split("::").last]
\ No newline at end of file