Showing posts with label Comatose. Show all posts
Showing posts with label Comatose. Show all posts

Thursday, October 25, 2007

AJAX Is X-TREME!

Author’s Note: I actually wrote this back in 2006, but it kind of fell through the cracks. So I present it now, for your amusement/pleasure/whatever…

The term “Web 2.0” has become synonymous with AJAX. With the hype and buzz that’s surrounded “Web 2.0”, people seem to invent reasons for using it. Even when it makes no sense. Sometimes especially when it makes no sense. Just because it’s “cool!”

ZooDotCom Presents - AJAX is X-TREME!!!


Oh yes, AJAX is cool. It can really enhance the user experience of your application. And yes, you can do some interesting single page applications that don’t require a server. But hopefully you’re not quite as gung-ho about it as Charlie here (from the comic above). Rails makes it easy to use AJAX. Really easy. Too easy? Perhaps. And occasionally even I’ve been sucked into the trap of throwing out a quick, AJAXified, solution rather than taking the time to build it right, to build it compatible with the “Web 1.0” (or non-JavaScript enabled) folks. But I shouldn’t have. And neither should you.

ZooDotCom Presents - Fine, then how do I it?!

That, Charlie, is a good question. In my next post I’ll talk a bit about Comatose, and how I went about ensuring that it’s backward compatible with non-JavaScript enabled browsers.

Author’s Other Note: I will post the second part to this soon… Probably next week. Cheers.

Friday, June 29, 2007

Comatose 0.8.1

It’s been a long time coming, but it’s finally here: Comatose 0.8.1!

Over the next few days, I’ll be transitioning the project to Google Code and Google Groups please start using them for reporting bugs and such. Here are the important URLs:

I’ve also updated the docs to reflect the new 0.8+ way of doing things. They’ll wind up on the wiki so that they’ll be easily maintained by all.

From the changelog:

  • All includes and helpers are loaded at the end of the ComatoseController and ComatoseAdminController classes
  • Fixed the ComatoseController#show action to correctly send an HTTP status of 404 even if it finds, and renders, a page at ‘/404’
  • Fixed the migration to default a page’s full_path to ” instead of null
  • Formalized ComatoseDrops. Use Comatose.define_drop "drop_name", do ... end. Every method within that block should return a value for use with a Liquid and/or ERB template. Usage in a comatose page: {{ drop_name.def_name }}
  • Added support for a config.after_setup block that gets called after Comatose is setup (in the Dispatcher#to_prepare event)
  • Added HTML comment output for calls that result in a method_missing on the ProcessingContext
  • Updated page tree to remember collapsed/expanded nodes between page visits
  • Fixed some errors that were caused by null revisions (usually happened after initial installation)
  • Added my javascript test_runner lib for testing slugs generated by JavaScript. More JS tests to come.
  • Bugfix #8640 (rubyforge bug)

For more see the devblog

Tuesday, January 30, 2007

Comatose 0.8 Released

Tada! Comatose finally supports Rails 1.2!

In fact, it only supports Rails 1.2 now. If you are still on Rails 1.1, don’t upgrade Comatose — It won’t work. Consider yourself warned. (version 0.7.1 is tagged, so all you Rails 1.1ers can still get to it)

OK, so I made quite a few changes whilst upgrading Comatose. No functionality was removed, yet, but enough has changed that we should hit the high points here… I’ll post a more in-depth article on the dev blog later.

First up, there’s a new configuration system. It’s quite dandy, really. It single-handedly made the DEFER_COMATOSE_LOAD and controller class hacking obsolete.

You can still use all the same old settings, only you set them in a configuration block in your environment.rb now. Here’s an example from an app I’m currently working on:

Comatose.configure do |comatose|
  comatose.includes << :authenticated_system
  comatose.helpers <<  :application_helper
  # admin
  comatose.admin_title = "My App's CMS"
  comatose.admin_sub_title = "... its' fun for the whole family!"
  comatose.admin_includes << :authenticated_system
  comatose.admin_helpers << :application_helper
  comatose.admin_authorization = :admin_required
  comatose.default_tree_level = 1
  comatose.admin_get_author do
    current_user.login
  end
  comatose.admin_get_root_page do
    roots = %w(public-root content-fragments)
    roots.collect {|path| Comatose::Page.find_by_path(path)}
  end
end

Look over that example closely, there’s a lot hidden in there.

  • comatose.includes is an array of module names (as symbols) that will be included in the ComatoseController.
  • comatose.helpers is also an array of module names, only these are loaded as helpers so you can use them in a view, most likely in your layout.

Remember, you no longer extend ComatoseController to add functionality. * All that holds true for ComatoseAdminController and the comatose.admin_includes and comatose.admin_helpers as well. * comatose.admin_get_author and comatose.admin_get_root_page both accept a block of code that should return the author and root_page respectively.

You can use any default controller method, as well as methods from included modules * comatose.admin_authorization is using a method from an included module directly, the :admin_required method from the AuthenticatedSystem module.

The options that accept blocks will also accept symbols representing module methods. * Have a look at the config class for all the options

Also, there are unit tests now. Yay!

You can get an overview of the coverage, if you like. Oh, using rake test:plugins doesn’t work, to run them you will need to change into the vendor/plugins/comatose directory and run rake, after you’ve run the Comatose migrations.

From the CHANGELOG:

  • Now ONLY supports Rails 1.2 (not even tested in Rails 1.1)
  • New configuration system
  • DEFERCOMATOSELOAD is gone — Using Dispatcher.to_prepare replaces it
  • You no longer extend the base classes to add functionality. You configure Comatose to include modules and send it symbols for providing said functionality. e.g. Comatose.config.includes << :authentiationsystem; Comatose.config.authorization = :requirelogin
  • The automatic loading of RAILS_ROOT/lib/comatose/*.rb files is NO longer supported.
  • In addition to mapping comatoseroot in your routes.rb, you’ll want to map.comatoseadmin as well

Obviously, if you have any issues with this version, please let me know.

Monday, January 22, 2007

Comatose, TaskTHIS, and Theme Support. Oh My!

Well, I’ve been a little remiss in my open-source development of late. Many apologies, things have been a bit hectic. You know the feeling, I’m sure.

But that’s not why I’m posting. I thought I’d outline my ideas for the future of these projects and get your feedback and/or ideas.

Comatose, The Micro CMS Plugin

The things that are definitely coming…

Edge Rails - Since Rails 1.2 is now official, it’s time to finally support ‘edge rails’. :-D

Actually, I have a version that runs on Rails 1.2 now, but I’m debating about Rails 1.1 backward compatibility. The new version changes quite a bit. The DEFER_COMATOSE_LOAD stuff goes away, replaced by better configuration support and a Dispatch::to_prepare block. Plus you no longer override the ComatoseAdminController for authentication, instead in the configuration you specify modules to include in the class. Oh yeah, and the controllers no longer extend ApplicationController.

Test Harness - The tests in the plugin itself are very spartan, at best. I have a horribly ugly test harness I use for the actual unit testing that I’m going to clean up and release.

Some possibilities

Liquid Only - I really think I’m going to drop ERb support. How many of you use ERb over Liquid for page processing?

RESTful Pages - Perhaps using the new RESTfully CRUDDY support would be useful. The idea of having an API for pages is interesting.

Mount Behaviors - I haven’t thought this through yet, it just popped into my head: map.comatose_root 'devblog', :index=>'blog', :behavior=>'blog'

This example would add ‘blog-like’ support such as all children being paged entries (showing last 10, next page, last page, etc.), automatic hAtom microformat support, and maybe some sort of archives… I don’t know. I still haven’t thought about this too much.

The behavior support would be pluggable, much like text-filters and drops… Can you think of any other behavior that would make sense?

Maybe :behavior=>'syndicated' to create RSS/ATOM feeds of the child pages? Perhaps they’d be mixable by saying :behavior=>'blog syndicated' or :behavior=>'blog,syndicated'.

The probably nots

Media Management - It just feels like too much. I have a hacked up version of Comatose that supports page attachments. But you wind up having to deal with upload directories, and file permissions and… It just feels too heavy. And too heavy != micro.

Perhaps it could be a separate plugin?

TaskTHIS

TaskTHIS is getting a bit long in the tooth. It was written right about the time some of my AJAX patches were being added to Rails. Which was pre 1.0. So, yeah. It needs some love.

It was created as a show-and-tell for the then-new-and-nifty AJAX support. Which, of course, is now old hat.

In keeping with the tradition of show-and-tell, I thought TaskTHIS would be an excellent application to show how to use the new CRUD/REST/Resources stuff in Rails 1.2.

I have a few ideas outlined here. The biggest ones are:

API - This is fairly straight-forward, we’ll get most if it from Rails. We’ll just add the appropriate authentication for the XML requests.

OpenID - I was thinking replacing the existing login system with OpenID authentication. I like the idea of just typing in my domain to login… Who needs passwords? Seriously though, this may be a bit controversial — please weigh in.

Oh, I forgot to mention, TaskTHIS.com is working again.

Theme Support Plugin

Basically, just add any outstanding patches and ensure it works on Rails 1.2. I imagine the routing stuff will need to be tweaked.

Whadda Ya Think?

What would/wouldn’t you like to see in any of these projects?

Wednesday, September 20, 2006

Comatose 'Compatibility Mode'

OK, so after mentioning it in my last post, I’ve decided to go ahead and implement it. Comatose version 0.7.1 adds a DEFER_COMATOSE_LOAD flag that you can use to, well, defer comatose’s loading. You will have to manually tell it to load in your environment.rb using Comatose.load.

See this devblog post for more.

Normally, I’d only post this on the Comatose development blog, but I wanted to make sure anybody who’s having problems using Comatose with other plugins/applications knows about this. If you have problems or questions, leave a comment here. Thanks!

Tuesday, September 19, 2006

Comatose Version 0.7

This release finally adds support for versioning. It also adds an auto-loader for any comatose customizations you put in a RAILS_ROOT/lib/comatose folder.

See the devblog post for more.

Comatose has been having a few problems co-existing with some kinds of plugins lately. The problems seem to be caused, at least in part, because the comatose controllers extend ApplicationController and therefore requires the application.rb before the rest of the plugins load.

Plus, some plugins seem to take issue with any previous plugins defining an Active Record model before they’re loaded—very picky stuff.

To combat this, I’m thinking of adding a DEFER_LOADING flag in comatose/init.rb. When the plugin initializes, if that flag is true it won’t load the controllers or the models. You’ll then need to add a call to Comatose::Load in your environment.rb that would then load the controllers and models—after the rest of your app had loaded. By default, the flag will be set to false so that it remains backward compatible.

Look for that in the next release.

Tuesday, August 29, 2006

Retrograde: Part One

Working Area:

I designed it to have some nifty UI stuff like an expandable tree view of pages, drag-n-drop reordering of pages, page previews using AJAX. You know, the standard web 2.0ish stuff.

  • How to handle Drag-n-drop
    • Look further up the track
    • Make the link smart, point to the HTML version of the page and have the onclick handler return false
  • How to handle expandable trees when there’s no AJAX
    • Show all the entries, don’t show the ‘twisties’
  • How to handle AJAX page previews
    • Look for features you can disable
    • Remove button if JS isn’t available

Testing

Disabling JavaScript via the web developer extension in Firefox

Does your application work if JavaScript is disabled? It should.

Sunday, July 23, 2006

Comatose v0.6

Comatose 0.6 is out! Here’s a quick summary of the new stuff:

  • ComatoseController has been split into ComatoseController and ComatoseAdminController
  • Both controllers extend your ApplicationController
  • The views, stylesheets, and javascripts have been updated and renamed to reflect the controller change
  • Configuration via Comatose::Options class
  • Liquid is the default text processor
  • Support for named routes
  • A Getting Started Guide
  • Pages now have a created_on field
  • Bug-fixes

For more, see the CHANGELOG.

Turns out I spoke too soon in my earlier post, there is a schema change. So if you're upgrading you'll need to run:

$ ./script/generate comatose_migration --upgrade --from=0.5

If you have questions/problems/feedback, drop by the Comatose project site and post in the forum or report a bug.

Saturday, July 22, 2006

Comatose Development Site

Rubyforge has been kind enough to create a project site for Comatose. I’ve enabled the following project tools for it:

Rubyforge also provides a project-specific wiki. I haven’t enabled it, at this point — If you think it’d be useful, lemme know and I can.

So from here on, if you have problems with Comatose you can add a bug ticket. Or better yet, fix it and submit a patch. ;-) If you need help with something, feel free to post on the mailing list or the help forum.

If you’ve used Comatose, I’d like to encourage you to drop by the open-discussion forum and leave a note. If you’ve done anything special with it, I’d love to hear it!

Wednesday, July 19, 2006

Comatose and PostgreSQL

Apparently, there’s an issue in Comatose that causes an error when migrating the first time when using PostgreSQL. Here’s the fix, courtesy of Lyle Troxell.

Changing comatose_page.rb’s line

acts_as_list :scope=>'parent_id'

to

acts_as_list :scope=>:parent_id

Fixes the problem.

This fix will be put in the next version...

Thanks Lyle!

Tuesday, July 18, 2006

Comatose, TNG

The response I’ve gotten on Comatose is somewhat overwhelming. I’m glad so many of you have found it useful!

Hopefully I won’t annoy you guys too much with the next release… It has quite a lot of updates, and changes. Enough to warrant this post on it as a kind of ‘heads up’.

If you’ve made customizations to the admin, and if you have used an svn:external to keep up to date with Comatose — you may want to remove the external and commit the current version (0.5) into your plugin directory… Otherwise you will need to tweak some things when I commit the next version.

In the next release, what is now the ComatoseController is going to be broken down into two separate controllers. There will still be a ComatoseController, it’s purpose will be rendering and caching pages. A new ComatoseAdminController will be the home for all of the administration tools. They will each have a before_filter that calls #authorize for authentication purposes.

The way layouts are handled internally has changed too. The controllers will now extend your ApplicationController, so you should be able to use partials and application helpers in your content layouts.

The biggest change, however, is in the page processing. Liquid will be the new default text processor. Don’t panic — ERB will still be available as a configuration option. But I really want a safer way to support content processing. To go along with that, I’m adding a simple method for adding custom functions to the processors that’ll work for both Liquid and ERB. Also, Liquid will be packaged with the plugin, so you won’t have to worry about having it as a dependency.

There are, at this point, no schema changes — so there won’t be a need for new migrations. There’s quite a few more changes I could talk about, but these are the main things that are some-what breaking changes.

I’ll be releasing the new version later this week.

Tuesday, July 11, 2006

Comatose v0.5

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-ListNew-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
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.

Thursday, July 6, 2006

Comatose v0.4

I’ve just checked in a big update for Comatose.

Here’s a list of the major changes from the CHANGELOG:

[version 0.4]
* Added keywords field
* Abstracted text filters into a micro plugin structure, default
support for
- Textile
- Markdown
- RDoc
* It will only show the filters as a choice in the admin if you have
the necessary libraries for the filters to function.
* Added ComatoseController.hidden_meta_info = [] as a way of showing/hiding
the meta fields
* The comatose_migration generator now accepts an --upgrade flag which
will create a micro migration that only has the new fields in it
* get_root_page will now support returning an array of root pages to show
in the admin page list
* Created some initial tests... (Can you tell I'm not a test _first_ guy?)
* Inline rendering now handles :silent flag -- it will just return and
empty string if :silent=>true
* Modified all the internal references to ComatoseController to self.class.
The views reference controller.class. Redirects redirect to :controller=>
self.controller_name or controller.controller_name (action and view
respectively). This show allow you to sub-class the ComatoseController.

As always, I’ve tried to keep the README up to date with the changes.

Upgrading from the previous version...

I’ve added a couple of fields to the comatose page model… If you have already installed the comatose plugin, and have the add_comatose_support migration applied, you can get a migration of just the new fields by running:

$ ./script/generate comatose_migration --upgrade

There’s only one other feature that I know I’m going to add in the near future—The ability to re-order the pages. It won’t be a big deal when I release that one though, I already have the field I need in there.

Feedback

As always, check it out, kick the tires, etc. Let me know if you have any issues/questions/suggestions…. darthapo at gmail dot com

Sunday, July 2, 2006

Comatose Screenshots

I've had some requests for screenshots of the administration ui... So, without further ado, here they are.

Page ListPage DeletePage EditPage Edit - MorePage Edit - ReparentingPage Edit - Preview

Hmmm... After looking at the screenshots myself, I think I'm going to re-label "Expire Page Cache" to "Clear Page Cache". But still, you get the idea. That's the default administration ui that comes out of the box. It's straight CSS -- no images.

You can, however, completely customize it to look like your application by running:

$ rake comatose:customize

That will copy all the necessary files to your application folders for customization. The README talks more about that.

From Version 0.5

Update! The following screen shots are from version 0.5:

New-Page-ListNew-Page-Reordering

Technorati Tags: , ,

Comatose Update

There’s a new version of Comatose, the micro CMS plugin, out there.

I wanted to give you guys a quick heads up. This new version has a couple of breaking changes… After this release, if there are any data model changes, I’ll add a generator to the plugin that will create an ‘upgrade’ migration so you can update smoothly. But I’m hoping since it’s only been a few hours since the initial release, not too many people will have to revert anything!

If you’re not sure what Comatose is, you can read my last post on it for the background.

New Features

  • Hierarchal pages
  • Updated administration styles
  • Page previews
  • ERB pre-processing

Installation

$ ./script/plugin source http://mattmccray.com/svn/rails/plugins
$ ./script/plugin install comatose
$ ./script/generate comatose_migration
$ rake migrate

Add to the bottom of your config/routes.rb file:

map.comatose_root ''

That’s it—you’re good to go.

There’s a lot more info, and an FAQ example, in the README.