Sunday, July 30, 2006

Create An FAQ

Example page structure:

- Home Page
  - FAQ
    - Question One?
    - Question Two?

“FAQ” page content:

{% for child in page.children %}
* "{{ child.title }}":#{{ child.slug }}
{% endfor %}

< hr >

{% for child in page.children %}
h3. {{ child.title }} <a name="{{ child.slug }}"></a>

{{ child.content }}

"Top":#
{% endfor %}

Create A Simplistic Blog

Updated to reflect changes as of v0.8.1

Example Page structure:

- Home Page
  - Blog
    - First Post
    - Second Post
    - Latest Post

Page content for “Blog” page:

{% for child in page.rchildren %}
{% unless child.has_keyword.draft %}
<div class="post">

h3. {{ child.link }}

<div class="post-meta">by {{ child.author }} {{ child.created_on | time_ago }} ago</div>

{{ child.content }}

</div>
{% endunless %}
{% endfor %}

Adding Comments Via HaloScan

You can create a ComatoseDrop to add Haloscan comment support (this would probably go in your environment.rb, or a separate file required by your environment.rb):

# This defines a Drop for use with the Liquid processor
# And an object you can call from the ERB processor

Comatose.define_drop "haloscan" do 

  # Your HaloScan USERNAME here:
  @halo_user = 'user_x'

  def script
    %Q|<notextile><script type="text/javascript" src="http://www.haloscan.com/load/#{ @halo_user }"> </script></notextile>|
  end

  def trackbacks(slug=nil)
    # Look for the varable 'child.slug' in the context, unless the slug has been passed in
    slug = @context['child']['slug'] if @context.has_key? 'child' and slug.nil?
    # If it's not found, use the 'page.slug'
    slug = @context['page']['slug'] unless slug
    %Q|<notextile><a href="javascript:HaloScanTB('#{slug}');" target="_self"><script type="text/javascript">postCountTB('#{slug}'); </script></a></notextile>|               
  end

  def comments(slug=nil)
    slug = @context['child']['slug'] if @context.has_key? 'child' and slug.nil?
    slug = @context['page']['slug'] unless slug
    puts "Comments ~> Slug = #{slug}"
    %Q|<notextile><a href="javascript:HaloScan('#{slug}');" target="_self"><script type="text/javascript">postCount('#{slug}');</script></a></notextile>|
  end

end

Then, on your Blog listing page:

{{ haloscan.script }}

{% for child in page.rchildren %}
{% unless child.has_keyword.draft %}
<div class="post">

h3. {{ child.link }}

<div class="post-meta">by {{ child.author }} on {{ child.created_on | time_ago | date: '%m/%d/%Y @ %H:%M' }}, 
{{ haloscan.comments }} {{ haloscan.trackbacks }}</div>

{{ child.content }}

</div>
{% endunless %}
{% endfor %}

Thursday, July 27, 2006

Comatose 0.6.8

There’s been a few more updates I thought I’d summarize:

version: 0.6.8

  • ComatoseController now references plugin_layout_path correctly
  • HTML/CSS/JS cleanup on the administration view—it now works with or without JavaScript

version: 0.6.7

  • Removed Comatose::Page.record_timestamps = false—it was breaking the magic. Override the record_timestamp methods instead
  • AdminController was still referencing, in a few places, ComatoseController for page cache expiration

version: 0.6.6

  • The cache expiration code is now on the ComatoseAdminController, as it should have been in the first place
  • Changed internal references from root_paths or cms_root to mount_point, since that’s what I’ve started calling them… And it seems to make the most sense
  • Cleaned up the class_options code
  • Added initial support for pre-caching pages (generating static HTML), there’s not a UI element for it yet, however, nor does it really work right
  • Changes to content-type handling:
    • Removed Comatose::Options.force_utf8
    • Added support for Comatose::Options.content_type = "utf-8" This will affect the HTTP headers, as well as the META tag in the admin views
  • Changed this log file to yaml format. And yes, there’s a method to my madness… Wait for it.

Monday, July 24, 2006

Comatose 0.6.5, Maintenance Release

Version 0.6.5 is another maintenance release. I haven’t created a post for each update, but here’s summary of the updates since 0.6

  • Fixed a bug in comatose_admin.js—if you hid any of the meta_fields it would barf
  • Fixed a typo in comatose_admin_customize.rhtml
  • Controller now keeps all information about mount points not just the :root (uri) and :index (page tree)
  • Fixed the customization tasks
  • Added support for the new Routes system in Edge Rails
  • Removed the getting started guide—it’s now available at: http://comatose.rubyforge.org/getting-started-guide
  • Fixed an issue with named_routes
  • Fixed a bug in the migration

Comatose 0.6.3 and Edge Rails

As most of you should know, "Edge" Rails – the latest code that’s on it's way to becoming Rails 1.2 – has a completely re-written routes engine. It’s usage is the same, but the internals are pretty drastically different. That’s why Comatose hasn’t really supported Edge Rails, only official releases. Well, Comatose 0.6.3 contains some initial work for Edge Rails. I wouldn’t call Edge Rails 'supported' yet, but it does run. Gotchas To get the administration to be accessible, I had to add an empty comatose_admin_controller.rb file in the app/controllers folder.

Sunday, July 23, 2006

Welcome to the Comatose Development Site

Welcome, you are looking at the new development website for the Rails plugin Comatose.