Skip to content

Commit

Permalink
rdoc to md
Browse files Browse the repository at this point in the history
  • Loading branch information
dejan committed Jul 5, 2010
1 parent cdf0e0b commit 6865115
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 121 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test.sqlite3
TODO
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## 1.2.1, released 2009-10-28

* more options for vimeo filter
* switch to gemcutter

## 1.2.0, released 2009-09-26

* link filter now uses Rails' link discovery engine. Closes: <http://github.com/dejan/auto_html/issues#issue/2> and <http://github.com/dejan/auto_html/issues#issue/3> if Rails 2.3+ is in use.
* added dailymotion filter
* added sanitize filter

## 1.1.2, released 2009-09-24

* link filter fix. Closes: <http://github.com/dejan/auto_html/issues#issue/2>

## 1.1.1, released 2009-09-06

* test_helper fix

## 1.1.0, released 2009-09-05

* Plugin gemified
* AutoHtmlFor.options[:htmlized_attribute_suffix] is now AutoHtmlFor.auto_html_for_options[:htmlized_attribute_suffix]. Closes gh-1
* Removed deezer filter since deezer.com no longer provides sharing of this kind

## 1.0.0

* Stuff described here: <http://www.elctech.com/projects/auto_html-plugin>

29 changes: 0 additions & 29 deletions CHANGELOG.rdoc

This file was deleted.

92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
auto_html
=========

Rails plugin for transforming urls to appropriate resource (image, link, YouTube, Vimeo video,...). Check out the [live demo](http://auto-html.rors.org).


## Synopsis

auto_html plugin is the perfect choice if you don't want to bother visitors with rich HTML editor or markup code, but you still want to allow them to embed video, images, links and more on your site, purely by pasting URL.

Let's say you have model Comment with attribute body. Create another column in table Comments called body_html. Now have something like this:

class Comment < ActiveRecord::Base
auto_html_for :body do
html_escape
image
youtube(:width => 400, :height => 250)
link :target => "_blank", :rel => "nofollow"
simple_format
end
end

... and you'll have this behaviour:

Comment.create(:body => 'Hey check out this cool video: http://www.youtube.com/watch?v=WdsGihou8J4')
=> #<Comment id: 123, body: 'Hey check out this cool video: http://www.youtube.com/watch?v=WdsGihou8J4', body_html: '<p>Hey check out this cool video: <object height="250" width="400"><param name="movie" value="http://www.youtube.com/v/WdsGihou8J4" /><param name="wmode" value="transparent" /><embed src="http://www.youtube.com/v/WdsGihou8J4" type="application/x-shockwave-flash" height="250" wmode="transparent" width="400"></embed></object></p>'>

Note that order of invoking filters is important, ie. you want html_escape as first and link amongst last, so that it doesn't transform youtube URL to plain link.


Now all you have to do is to display it in template without escaping, since plugin took care of that:

<% for comment in @comments %>
<li><%= comment.body_html %></li>
<% end %>


If you need to display preview, no problem. Have something like this as action in your controller:

def preview
comment = Comment.new(params[:comment])
comment.auto_html_prepare
render :text => comment.body_html
end

Plugin is highly customizable, and you can easily create new filters that will transform user input any way you like. For instance, this is the image filter that comes bundled with plugin:

AutoHtml.add_filter(:image) do |text|
text.gsub(/http:\/\/.+\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match|
%|<img src="#{match}" alt=""/>|
end
end


## Bundled filters

For filter list and options they support check: http://github.com/dejan/auto_html/tree/master/lib/auto_html/filters


## Install

### Important note on versions

As from version 1.2.0 auto_html uses Rails' engine for discovering links. There are some bugs with that engine in versions under Rails 2.3.2. so it's recommended you use auto_html 1.1.2 in that case, since internal engine is used in that version.

for Rails <= 2.3.1 use auto_html 1.1.2
for Rails >= 2.3.2 use auto_html 1.2.1


### As a gem

To enable the library in your Rails 2.1 (or greater) project, use the gem configuration method in "config/environment.rb"

Rails::Initializer.run do |config|
config.gem 'auto_html', :version => '~> 1.2.1'
end

### As a Rails plugin

script/plugin install git://github.com/dejan/auto_html.git


## Links

* http://auto-html.rors.org
* http://www.elctech.com/projects/auto_html-plugin


## Credits

Author: [Dejan Simic](http://github.com/dejan)
Contributor: [Claudio Perez Gamayo](http://github.com/crossblaim)
92 changes: 0 additions & 92 deletions README.rdoc

This file was deleted.

0 comments on commit 6865115

Please sign in to comment.