lib/caboodle/kit.rb in caboodle-0.2.14 vs lib/caboodle/kit.rb in caboodle-0.2.15

- old
+ new

@@ -25,10 +25,17 @@ haml File.open(File.join(Caboodle::Kit.root, "views","error.haml")).read end Config = Hashie::Mash.new + def markdown sym + puts sym + md = File.expand_path(File.join(Caboodle::App.root,"config","#{sym.to_s}.md")) + @content = Maruku.new(open(md).read).to_html_document + haml ".page.about.thin_page= @content" + end + class << self attr_accessor :credit_link def configure_site config_path @@ -222,14 +229,24 @@ def use_all Caboodle::Kits.each { |p| p.start } end - def menu display, path, &block + def menu display, path=nil, &block + #todo proper slugify + slug = display.downcase.gsub(" ","-").gsub("'","") + path = "/#{slug}" unless path path = "/" if Site.home_kit == self.to_s.gsub("Caboodle::","") Caboodle::MenuItems << {:display=>display, :link=>path, :kit=>self} - self.get path, &block + self.before {@title = display} + if block + self.get path, &block + else + eval "self.get '#{path}' do + haml :#{slug.gsub("-","_")} + end" + end @@has_menu = true end def has_menu? defined?(@@has_menu) @@ -272,10 +289,19 @@ Caboodle::SASS << array_of_sass_files.to_s end Caboodle::SASS.uniq! end + def add_layout k, v + unless Caboodle::Layout[k.to_sym].blank? + Caboodle::Layout[k.to_sym] << "\n" + Caboodle::Layout[k.to_sym] << v + else + Caboodle::Layout[k.to_sym] = v + end + end + alias_method :stylesheet, :stylesheets def javascripts array_of_js_files if array_of_js_files.class == Array array_of_js_files.each { |a| Caboodle::Javascripts << a.to_s } @@ -296,28 +322,23 @@ 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 - else - Caboodle::Layout[k.to_sym] = v - end + add_layout k, v end end def defaults hash if hash.class == Hash hash.each {|k,v| Site[k] = v } end end - def credit url + def credit url, title=nil #todo there must be an easier way class_eval "def credit_link - \"<a rel='me' href='#{url}'>#{self.name.split("::").last}</a>\" + \"<a rel='me' href='#{url}'>#{title || self.name.split("::").last}</a>\" end" end def required_settings RequiredSettings[kit_name] ||= [] \ No newline at end of file