mattmccray

 
« Comatose v0.4 | Home | Monstas of the Lil' V… »

Comatose v0.5

» Published July 11, 2006 under Comatose, Rails, Software
Can you guess what time it is? That’s right! It’s time for another Comatose update! So, what’s new? Here are the main things:
  • Page reordering
  • Updated administration UI
  • Parameterized inline rendering
  • Fragment caching, and a pre-caching hook if you want more control of such things
  • Better importing/exporting of pages
  • Misc. bug-fixes
New-Page-List New-Page-Reordering

Installation

It's as simple as ever:
$ ./script/plugin source http://mattmccray.com/svn/rails/plugins
$ ./script/plugin install comatose
$ ./script/generate comatose_migration
$ rake migrate
Or, for you (OK, us) early adopters:
$ rapt discover --no-prompt
$ rapt install comatose
$ ./script/generate comatose_migration
$ rake migrate
Then, in your routes.rb:
map.comatose_root ''

Upgrading

For those of you upgrading from version 0.4, there aren’t any new db fields — so you won’t need to worry about migrations. However, there are changes to the CSS, JavaScript, and Views. So you might want to diff those with your customized versions (if you’re customizing the Admin). Oh, and I’ve also bit the bullet and added a few images to spice it up. For new installations, it’ll automatically copy them into RAILS_ROOT/public/images/comatose/. For existing installations, you’ll want to run:
$ rake comatose:copy_images
That should pretty much do it. Don’t forget to glance over the 400+ line README file. From the ChangeLog:
[version 0.5]
  * Added support for parameterized inline rendering of comatose pages. Use
    like a partial: render :comatose=>'path', :locals=>{:username=>'stuff'}
    the locals hash will be sent to the ERB context for use when rendering 
    the page.
  * Support for a Hash ERB context exists all the way down to the TextFilters.
  * Initial support for fragment caching for inline rendering. It's turned off
    by default. Send :use_cache=>true in the render :comatose=>'' tag to use it. 
    Caching will also not be used if you are sending the page parameters via the 
    :locals hash. Oh, and don't forget to set your 
    ActionController::Base.fragment_cache_store
  * Return reloadable? false for the ComatoseController by default... This 
    should prevent the development mode hassles people have been having. 
  * Updated data migration tasks to better support nested pages.
     - comatose:data:export FROM=page_path TO_FILE=file_path
     - comatose:data:import TO=page_path FROM_FILE=file_path
     - FROM_FILE and TO_FILE default to 'db/comatose-pages.yml'
     - FROM and TO default to '', the page tree root
  * Fixed 'Clear Page Cache' bug -- it didn't handle the page root being an
    array like it should have.
  * Removed :page_title and :page_keywords from session
  * Updated the rails_version in the about.yml to 1.1+ -- just because I 
    haven't tested it on anything less than that. If you have, and it works,
    let me know!
  * Adds the utf8 header to all output (text/html; charset=utf-8). Use
    ComatoseController.force_utf8 = false to disable.
  * Initial support for page reordering (via AJAX) 
  * Updated the administration look-n-feel.
Enjoy! As always, if you have any questions/problems feel free to give me a shout.

17 comments

07.11.06 @ 16:21 Cameron Booth said...
Hey Matt…thanks for another update. Looking good so far! I am getting an error running rake comatose:copy_images – but I manually copied the folder over, and it’s just fine.

Cheers!! Cameron
07.11.06 @ 16:37 manuel said...
Hey, thanks for this. I’m using Comatose for a new site, and so far it’s being great.

Question/Suggestion: What about allowing ActionView::Helpers methods within a page body? That would be useful for linking to other pages within the Rails app.
07.11.06 @ 16:42 M@ said...
Cameron: D’oh! Thanks for the heads-up. I just checked in the fix — Not that helps you now, though, huh? ;-)

manuel: Yeah, that’s been brought up before. The helpers themselves isn’t too big of a deal, you can extend the ComatoseBinding to include them. It gets trickier when the helper methods require access to a controller. Partly because the ComatoseController doesn’t, at this point, extend ApplicationController, it extends ActionController::Base.

It think it’s a good suggestion, but I haven’t thought of a clean way of implementing it yet. I’ve had a couple of thoughts, but they’re both pretty hacky… Not that I’m above a hack, they’re just too ugly even for my taste. If you have any ideas — I’m all ears. :-)
07.11.06 @ 20:23 Chris Corriveau said...
Matt,

Another great job! Just upgraded and loving the changes…at this page you shoulbe at 1.0 by next week!
07.11.06 @ 21:21 scott said...
Very nice! Thanks.

Just a note on my usage…To make managing “private” sections of the CMS tree easier, I created a child page off of the root named “private” and then coded my authorize filter so that every child hanging from that page requires authentication. To do that (without doubling-up on calls to authorize), I open-up ComatoseController and add “skip_before_filter :authorize” followed-by “before_filter :my_authorize”. This is necessary because ComatoseController has the “show” action as an exception to the authorize filter declaration (and I require authentication on “show”). I also disable caching on pages that are children of the “private” page (as well as the private page itself).

I’ll probably be adding a “drafts” page to my page tree and modifying my authorize filter so that pages under it cannot be accessed via the “show” method under any circumstance. Being able to change the parent of a page easily makes such a feature simple to implement and use.

Thanks again for your great plugin.

– Scott
07.12.06 @ 06:23 Vrensk said...
M@, I’m impressed by your development speed. There is a slight confusion in the docs, though: the Changelog says “Adds the utf8 header to all output (text/html; charset=utf-8). Use ComatoseController.force_utf8 = false to disable.”, but the README says “You can tell Comatose to set the response headers to utf8 (text/html; charset=utf-8) by setting:

ComatoseController.force_utf8 = true

By default, it’s set to false.”

I’ll find out quickly which it is, of course, but I thought you wanted to know.
07.12.06 @ 07:53 mikkel said...
Nice release….

Im a couple of hours from releasing a build of my project using comatose….

thanks a bunch!
07.12.06 @ 15:46 finn said...
It’s probably worth mentioning somewhere that the “none” text filter is actually a “newline to “ text filter. It might be preferable to just have “none” actually do nothing and have a “simple” filter that converts newlines to line breaks.

I changed this code:
#

  1. NONE


#
TextFilters.define “None” do |text|
def render_text(text)
text.gsub(”n”, ‘’)
end
end

To this:
#

  1. NONE


#
TextFilters.define “None” do |text|
def render_text(text)
text
end
end

#

  1. SIMPLE


#
TextFilters.define “Simple” do |text|
def render_text(text)
text.gsub(”n”, ‘’)
end
end
07.12.06 @ 15:47 finn said...
It looks like all the &ltbr/> (br tags) got filtered out of that last comment, making it read somewhat nonsensically.
07.13.06 @ 12:10 M@ said...
Thanks for the kind words! It’s nice to know that y’all find comatose useful.

scott: Thanks for sharing your implementation story. It helps me to know how people are using the plugin.

I’ve been thinking that the page administration stuff should be pulled out of the ComatoseController and added to a ComatoseAdminController. They would each have an #authorize method that you could override. Plus, I’d add support to map.comatose_root for passing along any extra parameters.

That way you can separate administration authentication from display authentication. Plus, you could send in information for your ComatoseController#authorize method to test on. For example, in your routes.rb you could have:

map.comatose_root ‘private’, :index=>‘private’, :auth_mode=>‘authenticate’
map.comatose_root ‘drafts’, :index=>‘drafts’, :auth_mode=>‘deny’
map.comatose_root ‘’, :auth_mode=>‘allow’

Then, your custom ComatoseController#authorize method could look like this:

class ComatoseController
def authorize
case params[:auth_mode]
when ‘authenticate’
# Your authentication code here…
when ‘deny’
redirect_to ‘/’ and return false
else
true
end
end
end

Consider this a question… Do you guys think this would be useful?

Vrensk: Oops! You’re right. I’ll fix that. Thanks for the heads-up.

finn: That’s a good point. None isn’t exactly none, and that’s probably bad. I’ll update that too. I planned on adding another couple of default filters anyway (SmartyPants and Markdown + SmartyPants).
07.13.06 @ 12:18 mikkel said...
makes sense to extract the admin part from the comatosecontroller…especially splitting the authorize for show/admin….
07.13.06 @ 12:19 mikkel said...
oops…forgot to mention….www.hill107 is running comatose as of 2 hours ago ;-)
07.13.06 @ 12:32 M@ said...
mikkel: Very nice! It looks good. Are you using Comatose for the ‘news’ section?
07.14.06 @ 00:46 mikkel said...
m@ yeah, frontpage, news, faq, about…will do a rss feed also using comatose…. I had to tweak it a bit to fit into my app, but otherwise i find comatose has a really nice level of (un)complexity….
07.18.06 @ 02:33 mikkel said...
oh…just found out the reordering pages updates the updated_on attribute…

thats not what I expected…

Any way to get around this??
07.18.06 @ 12:56 M@ said...
mikkel: Yeah, I find that annoying too. I’ve been looking into that… Hopefully I’ll have that fixed in the next version.

Everyone: Does Model.update_attribute(name, value) trigger the updated_on magic?
07.18.06 @ 14:09 mikkel said...
m@: yes…must be some way to override that??

No trackbacks

Trackback link:

Please enable javascript to generate a trackback url


You may use Textile, or simple html tags (B,I). Feel free to use Emoticons too. Oh, and please limit yourself to only five links per comment. Anything more and you'll probably get detained by the spam police.