Permalink
Browse files

Created gh-pages branch via GitHub

  • Loading branch information...
0 parents commit 5b18d4a298573de8f3b1f7c1dadc6f3d15bbcc9b @dejan committed Apr 2, 2012
Showing with 586 additions and 0 deletions.
  1. BIN images/checker.png
  2. +142 −0 index.html
  3. +20 −0 javascripts/scale.fix.js
  4. +1 −0 params.json
  5. +60 −0 stylesheets/pygment_trac.css
  6. +363 −0 stylesheets/styles.css
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,142 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="chrome=1">
+ <title>Auto html by dejan</title>
+
+ <link rel="stylesheet" href="stylesheets/styles.css">
+ <link rel="stylesheet" href="stylesheets/pygment_trac.css">
+ <script src="javascripts/scale.fix.js"></script>
+ <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+
+ <!--[if lt IE 9]>
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
+ <![endif]-->
+ </head>
+ <body>
+ <div class="wrapper">
+ <header>
+ <h1>Auto html</h1>
+<p>Rails extension for transforming URLs to appropriate resource (image, link, YouTube, Vimeo video,...) </p>
+ <p class="view"><a href="https://github.com/dejan/auto_html">View the Project on GitHub <small>dejan/auto_html</small></a></p>
+ <ul>
+ <li><a href="https://github.com/dejan/auto_html/zipball/master">Download <strong>ZIP File</strong></a></li>
+ <li><a href="https://github.com/dejan/auto_html/tarball/master">Download <strong>TAR Ball</strong></a></li>
+ <li><a href="https://github.com/dejan/auto_html">View On <strong>GitHub</strong></a></li>
+ </ul>
+ </header>
+ <section>
+ <h1>auto_html</h1>
+
+<p>auto_html is a Rails extension for transforming URLs to appropriate resource (image, link, YouTube, Vimeo video,...). It's 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. Check out the <a href="http://auto-html.rors.org">live demo</a>.</p>
+
+<h2>Example usage</h2>
+
+<p>Transforming string with text and URLs is done with <em>auto_html</em> method:</p>
+
+<pre><code>include AutoHtml
+
+auto_html('Hey! Checkout out: <a href="http://vukajlija.com'">http://vukajlija.com'</a>) { simple_format; link(:target =&gt; 'blank') }
+=&gt; "&lt;p&gt;Hey! Checkout out: &lt;a href='<a href="http://vukajlija.com">http://vukajlija.com</a>' target='blank'&gt;<a href="http://vukajlija.com&lt;/a&gt;&lt;/p&gt;">http://vukajlija.com&lt;/a&gt;&lt;/p&gt;</a>"
+</code></pre>
+
+<p>You'll probably have user input stored in model, so it's a good place to automate and even store this conversion for performance reason. This is done with <em>auto_html_for</em> method. Let's say you have model Comment with attribute body. Create another column in table Comments called body_html (again, this is optional but recommended for performance reasons). Now have something like this: </p>
+
+<pre><code>class Comment &lt; ActiveRecord::Base
+ auto_html_for :body do
+ html_escape
+ image
+ youtube(:width =&gt; 400, :height =&gt; 250)
+ link :target =&gt; "_blank", :rel =&gt; "nofollow"
+ simple_format
+ end
+end
+</code></pre>
+
+<p>... and you'll have this behaviour: </p>
+
+<pre><code>Comment.create(:body =&gt; 'Hey check out this cool video: <a href="http://www.youtube.com/watch?v=WdsGihou8J4'">http://www.youtube.com/watch?v=WdsGihou8J4'</a>)
+=&gt; #&lt;Comment id: 123, body: '&lt;p&gt;Hey check out this cool video: &lt;iframe class="youtube-player" type="text/html" width="587" height="350" src="<a href="http://www.youtube.com/embed/WdsGihou8J4">http://www.youtube.com/embed/WdsGihou8J4</a>" frameborder="0"&gt; &lt;br /&gt;&lt;/iframe&gt;&lt;/p&gt;'&gt;
+</code></pre>
+
+<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.</p>
+
+<p>Now all you have to do is to display it in template without escaping, since plugin took care of that:</p>
+
+<pre><code>&lt;% for comment in @comments %&gt;
+ &lt;li&gt;&lt;%= comment.body_html %&gt;&lt;/li&gt;
+&lt;% end %&gt;
+</code></pre>
+
+<p>If you need to display preview, no problem. Have something like this as action in your controller:</p>
+
+<pre><code>def preview
+ comment = Comment.new(params[:comment])
+ render :text =&gt; comment.body_html
+end
+</code></pre>
+
+<p>AutoHtml 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:</p>
+
+<pre><code>AutoHtml.add_filter(:image) do |text|
+ text.gsub(/http:\/\/.+\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match|
+ %|&lt;img src="#{match}" alt=""/&gt;|
+ end
+end
+</code></pre>
+
+<h2>Non-ActiveRecord models</h2>
+
+<p>AutoHtml uses standard ActiveModel API, which means that you can include AutoHtmlFor module (that automates transformation of the field) in any non-ActiveRecord model that uses ActiveModel. Here's working <a href="http://mongoid.org/">mongoid</a> example:</p>
+
+<pre><code>class Post
+ include Mongoid::Document
+ include AutoHtmlFor
+
+ field :body
+
+ auto_html_for :body do
+ simple_format
+ link
+ end
+end
+</code></pre>
+
+<h2>Rake and Capistrano tasks</h2>
+
+<p>AutoHtml has a Rake task for rebuilding cached in DB column values
+Usage: <code>rake auto_html:rebuild CLASS=[your model]</code>
+Where <code>[your model]</code> is the name of model which values you want to rebuild.</p>
+
+<p>If you want to run it on remote server, just add this to your <code>deploy.rb</code>:</p>
+
+<pre><code>require 'auto_html/capistrano'
+</code></pre>
+
+<p>Now you can run <code>cap auto_html:rebuild CLASS=[your_model]</code>.</p>
+
+<h2>Bundled filters</h2>
+
+<p>For filter list and options they support check: <a href="http://github.com/dejan/auto_html/tree/master/lib/auto_html/filters">http://github.com/dejan/auto_html/tree/master/lib/auto_html/filters</a></p>
+
+<h2>Install</h2>
+
+<p>Specify the gem in Gemfile of the project</p>
+
+<pre><code>gem "auto_html"
+</code></pre>
+
+<h2>Credits</h2>
+
+<p>Author: <a href="http://github.com/dejan">Dejan Simic</a><br>
+Contributors: <a href="https://github.com/dejan/auto_html/contributors">https://github.com/dejan/auto_html/contributors</a></p>
+ </section>
+ </div>
+ <footer>
+ <p>Project maintained by <a href="https://github.com/dejan">dejan</a></p>
+ <p>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></p>
+ </footer>
+ <!--[if !IE]><script>fixScale(document);</script><!--<![endif]-->
+ </body>
+</html>
@@ -0,0 +1,20 @@
+fixScale = function(doc) {
+
+ var addEvent = 'addEventListener',
+ type = 'gesturestart',
+ qsa = 'querySelectorAll',
+ scales = [1, 1],
+ meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
+
+ function fix() {
+ meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
+ doc.removeEventListener(type, fix, true);
+ }
+
+ if ((meta = meta[meta.length - 1]) && addEvent in doc) {
+ fix();
+ scales = [.25, 1.6];
+ doc[addEvent](type, fix, true);
+ }
+
+};
@@ -0,0 +1 @@
+{"name":"Auto html","body":"auto_html\r\n=========\r\n\r\n\r\nauto_html is a Rails extension for transforming URLs to appropriate resource (image, link, YouTube, Vimeo video,...). It's 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. Check out the [live demo](http://auto-html.rors.org).\r\n\r\n## Example usage\r\n\r\nTransforming string with text and URLs is done with *auto_html* method:\r\n\r\n include AutoHtml\r\n \r\n auto_html('Hey! Checkout out: http://vukajlija.com') { simple_format; link(:target => 'blank') }\r\n => \"<p>Hey! Checkout out: <a href='http://vukajlija.com' target='blank'>http://vukajlija.com</a></p>\"\r\n\r\nYou'll probably have user input stored in model, so it's a good place to automate and even store this conversion for performance reason. This is done with *auto_html_for* method. Let's say you have model Comment with attribute body. Create another column in table Comments called body_html (again, this is optional but recommended for performance reasons). Now have something like this: \r\n\r\n class Comment < ActiveRecord::Base\r\n auto_html_for :body do\r\n html_escape\r\n image\r\n youtube(:width => 400, :height => 250)\r\n link :target => \"_blank\", :rel => \"nofollow\"\r\n simple_format\r\n end\r\n end\r\n\r\n... and you'll have this behaviour: \r\n\r\n Comment.create(:body => 'Hey check out this cool video: http://www.youtube.com/watch?v=WdsGihou8J4') \r\n => #<Comment id: 123, body: '<p>Hey check out this cool video: <iframe class=\"youtube-player\" type=\"text/html\" width=\"587\" height=\"350\" src=\"http://www.youtube.com/embed/WdsGihou8J4\" frameborder=\"0\"> <br /></iframe></p>'>\r\n\r\nNote 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.\r\n\r\n\r\nNow all you have to do is to display it in template without escaping, since plugin took care of that:\r\n\r\n <% for comment in @comments %>\r\n <li><%= comment.body_html %></li>\r\n <% end %>\r\n\r\n\r\nIf you need to display preview, no problem. Have something like this as action in your controller:\r\n\r\n def preview\r\n comment = Comment.new(params[:comment])\r\n render :text => comment.body_html\r\n end\r\n\r\nAutoHtml 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:\r\n\r\n AutoHtml.add_filter(:image) do |text|\r\n text.gsub(/http:\\/\\/.+\\.(jpg|jpeg|bmp|gif|png)(\\?\\S+)?/i) do |match|\r\n %|<img src=\"#{match}\" alt=\"\"/>|\r\n end\r\n end\r\n\r\n\r\n## Non-ActiveRecord models\r\n\r\nAutoHtml uses standard ActiveModel API, which means that you can include AutoHtmlFor module (that automates transformation of the field) in any non-ActiveRecord model that uses ActiveModel. Here's working [mongoid](http://mongoid.org/) example:\r\n\r\n class Post\r\n include Mongoid::Document\r\n include AutoHtmlFor\r\n\r\n field :body\r\n\r\n auto_html_for :body do\r\n simple_format\r\n link\r\n end\r\n end\r\n\r\n## Rake and Capistrano tasks\r\n\r\nAutoHtml has a Rake task for rebuilding cached in DB column values\r\nUsage: `rake auto_html:rebuild CLASS=[your model]`\r\nWhere `[your model]` is the name of model which values you want to rebuild.\r\n\r\nIf you want to run it on remote server, just add this to your `deploy.rb`:\r\n\r\n require 'auto_html/capistrano'\r\n \r\nNow you can run `cap auto_html:rebuild CLASS=[your_model]`.\r\n\r\n## Bundled filters\r\n\r\nFor filter list and options they support check: <http://github.com/dejan/auto_html/tree/master/lib/auto_html/filters>\r\n\r\n\r\n## Install\r\n\r\nSpecify the gem in Gemfile of the project\r\n\r\n gem \"auto_html\"\r\n\r\n\r\n## Credits\r\n\r\nAuthor: [Dejan Simic](http://github.com/dejan)<br/>\r\nContributors: https://github.com/dejan/auto_html/contributors","tagline":"Rails extension for transforming URLs to appropriate resource (image, link, YouTube, Vimeo video,...) ","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}
@@ -0,0 +1,60 @@
+.highlight .hll { background-color: #49483e }
+.highlight { background: #3A3C42; color: #f8f8f2 }
+.highlight .c { color: #75715e } /* Comment */
+.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
+.highlight .k { color: #66d9ef } /* Keyword */
+.highlight .l { color: #ae81ff } /* Literal */
+.highlight .n { color: #f8f8f2 } /* Name */
+.highlight .o { color: #f92672 } /* Operator */
+.highlight .p { color: #f8f8f2 } /* Punctuation */
+.highlight .cm { color: #75715e } /* Comment.Multiline */
+.highlight .cp { color: #75715e } /* Comment.Preproc */
+.highlight .c1 { color: #75715e } /* Comment.Single */
+.highlight .cs { color: #75715e } /* Comment.Special */
+.highlight .ge { font-style: italic } /* Generic.Emph */
+.highlight .gs { font-weight: bold } /* Generic.Strong */
+.highlight .kc { color: #66d9ef } /* Keyword.Constant */
+.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
+.highlight .kn { color: #f92672 } /* Keyword.Namespace */
+.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
+.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
+.highlight .kt { color: #66d9ef } /* Keyword.Type */
+.highlight .ld { color: #e6db74 } /* Literal.Date */
+.highlight .m { color: #ae81ff } /* Literal.Number */
+.highlight .s { color: #e6db74 } /* Literal.String */
+.highlight .na { color: #a6e22e } /* Name.Attribute */
+.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
+.highlight .nc { color: #a6e22e } /* Name.Class */
+.highlight .no { color: #66d9ef } /* Name.Constant */
+.highlight .nd { color: #a6e22e } /* Name.Decorator */
+.highlight .ni { color: #f8f8f2 } /* Name.Entity */
+.highlight .ne { color: #a6e22e } /* Name.Exception */
+.highlight .nf { color: #a6e22e } /* Name.Function */
+.highlight .nl { color: #f8f8f2 } /* Name.Label */
+.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
+.highlight .nx { color: #a6e22e } /* Name.Other */
+.highlight .py { color: #f8f8f2 } /* Name.Property */
+.highlight .nt { color: #f92672 } /* Name.Tag */
+.highlight .nv { color: #f8f8f2 } /* Name.Variable */
+.highlight .ow { color: #f92672 } /* Operator.Word */
+.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
+.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
+.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
+.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
+.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
+.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
+.highlight .sc { color: #e6db74 } /* Literal.String.Char */
+.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
+.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
+.highlight .se { color: #ae81ff } /* Literal.String.Escape */
+.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
+.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
+.highlight .sx { color: #e6db74 } /* Literal.String.Other */
+.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
+.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
+.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
+.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
+.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
+.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
+.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
+.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
Oops, something went wrong.

0 comments on commit 5b18d4a

Please sign in to comment.