From a3f7b47957e500c98066380c32874320b96185c3 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Wed, 22 Aug 2007 21:33:57 +0000 Subject: [PATCH] ActionItem18: customizing comatose --- app/controllers/application.rb | 2 +- app/helpers/document_helper.rb | 17 ++++++++++++++++- app/views/comatose_admin/_page_list_item.rhtml | 9 +++------ config/environment.rb | 2 +- lib/comatose_extensions.rb | 7 ------- 5 files changed, 21 insertions(+), 16 deletions(-) delete mode 100644 lib/comatose_extensions.rb diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 7a25154..f919da3 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -2,7 +2,7 @@ # available in all controllers. class ApplicationController < ActionController::Base -# helper :all + helper :document design :holder => 'virtual_community' diff --git a/app/helpers/document_helper.rb b/app/helpers/document_helper.rb index 212cdb9..3085430 100644 --- a/app/helpers/document_helper.rb +++ b/app/helpers/document_helper.rb @@ -1,7 +1,22 @@ module DocumentHelper + # displays an icon corresponding to the document passed in +doc+. + # + # The class of the document can define its icon by providing an +icon+ + # method (i.e. +doc.class.icon+ will be called) def icon_for_document(doc) - design_display_icon(doc.class.icon) + icon = + case doc + when Comatose::Page + 'text-x-generic' + else + if doc.class.respond_to?(:icon) + doc.class.icon + else + 'none' + end + end + design_display_icon(icon) end end diff --git a/app/views/comatose_admin/_page_list_item.rhtml b/app/views/comatose_admin/_page_list_item.rhtml index a83b899..cf83114 100644 --- a/app/views/comatose_admin/_page_list_item.rhtml +++ b/app/views/comatose_admin/_page_list_item.rhtml @@ -23,24 +23,21 @@ collapse_children = (level >= Comatose.config.default_tree_level)
  • - - - - diff --git a/config/environment.rb b/config/environment.rb index 9e89577..79b3a2f 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -80,4 +80,4 @@ Comatose::AdminController.before_filter do |controller| end controller.instance_variable_set('@virtual_community', virtual_community) end -#require 'comatose_extensions' + diff --git a/lib/comatose_extensions.rb b/lib/comatose_extensions.rb deleted file mode 100644 index c9c25e5..0000000 --- a/lib/comatose_extensions.rb +++ /dev/null @@ -1,7 +0,0 @@ - -# FIXME: for some reason adding the following makes comatose migration to not -# work - -#def (Comatose::Page).icon -# 'text-x-generic' -#end -- libgit2 0.21.2
    + <% if !page.children.empty? %> <%= image_tag( ((collapse_children) ? 'comatose/collapsed.gif' : 'comatose/expanded.gif'), :title=>'Expand/Collapse', :onclick=>"ComatoseList.toggle_tree_nodes(this,#{page.id});", :class=>'tree-controller', :size=>'12x12', :id=>"page_controller_#{page.id}" ) %> <% else %> <%= image_tag 'comatose/no-children.gif', :size=>'12x12', :class=>'tree-controller' %> <% end %> - <%= image_tag 'comatose/page.gif', :size=>'25x31', :align=>"absmiddle" %> + + <%= icon_for_document(page) %> DRAG <%= link_to page.title, {:action=>'edit', :id=>page}, :title=>"Path:#{page.full_path}", :class=>'page' %>
    - Updated <%= time_ago_in_words page.updated_on, true %> ago<%= " by #{page.author}" unless page.author.nil? or page.author.empty? %>, <%= links.join(', ') %>.