Forum: Ruby on Rails [ANN] acts_as_blog

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
89d967359903c639d31e4cad4569f537?d=identicon&s=25 Charlie Bowman (Guest)
on 2006-05-31 19:40
(Received via mailing list)

Here is a simple plugin to allow you to allow the use of
RedCloth,BlueCloth, or SmartyPants in your blog.
It's super simple  to use.  It will take your blog post or comment and
transform it into html.
This allows you to write in a much simpler syntax and allows your users
to post valid html into their comment.
It  also allows you to block all html tags that weren't created using
the markup.
This model uses two fields, one to store the raw post (this way you can
edit it later) and the other to store the transformed text.
This also keeps you from having to do it on the fly each time the post
is accessed.
This creates a pretty good speedup for some applications.
You can pass in any of the available filters for each of the markup

## example of posts model
class Post < ActiveRecord::Base

  ## before we save, we need to transform the markup into html
  before_save :transform_post
  has_many  :comments

  # we need to keep the posts table in good shape!

validates_presence_of   :date, :raw_post, :title, :category,

  ## transform the text into valid html
  def transform_post = Post.convert_to_html(self.raw_post, 'textile')

#Here is an example of the comments model.
class Comment < ActiveRecord::Base


  belongs_to :post
  before_save :transform_comment

  ## validation checks
  validates_presence_of :name, :raw_comment

  ## we filter out all html tags except those created by the markup
  def transform_comment
    self.comment =

The available markup style are markdown,textile,smartypants.
To run the method, you just need to pass the raw text,markup style, and
then any filters you need to use.
It will return the valid html from your raw text.
Just remember, to use one of the markup styles, they need to be

gem install RedCloth
gem install BlueCloth
gem install RubyPants

author: Charlie Bowman
summary: Simple Markup for you Blog.
license: MIT

**** TODO ***
I am looking to add the ability to surround text with <view></view> and
having that code rendered as a template.  I haven't found a way to do
this in a plugin yet, If you know how and are willing to help I would
love to hear from you!

Charlie Bowman
This topic is locked and can not be replied to.