Code Monkey home page Code Monkey logo

auto_html's People

Contributors

ademange-legion avatar alexdenisov avatar alfakini avatar arehberg avatar blarralde avatar brettfishman avatar crossblaim avatar danielweinmann avatar dejan avatar dependabot[bot] avatar dgilperez avatar dhaulagiri avatar dlackty avatar ebeigarts avatar henningthies avatar hinrik avatar jbhannah avatar joaomilho avatar joemasilotti avatar josiasds avatar kirs avatar mattpolito avatar n8 avatar petergoldstein avatar schustafa avatar strivedi183 avatar subicura avatar theabrad avatar toxix avatar unreal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

auto_html's Issues

Seeing Mixed Content Warning (I Believe)

I am running version 1.6.0. I'm using this in a Rails 4 Ruby 2 application. I started having intermittent errors unrelated to the page where I embed a video when I run the Rails 4 version of the application. These errors occurred on Safari, Google and Firefox on Mac and Windows computers. I decided to try and look for a needle in a haystack. When I did Web Inspector in Safari I saw the following error:

[Error] Blocked a frame with origin "http://www.youtube.com" from accessing a frame with origin "http://myrailsapp.com". Protocols, domains, and ports must match.

Here is my code in my model:

auto_html_for :body do
html_escape
image
youtube(:width => 640, :height => 360, :autoplay => false, :hide_related => true)
link :rel => "nofollow"
simple_format
end

My view updates body with the link and uses body_html to display the embedded YouTube video.

From what I have read in GitHub I believe the gem is supposed to take care of mixed content warnings. If I'm wrong please let me know. I will look at other options if the gem is not supposed to take care of this.

rails 3.2 compatibility

i just upgraded from 3.0.10 to 3.2 and sadly auto_html stopped working. here is the code of my model:

  auto_html_for :text do
      html_escape
      lazyimage
      youtube(:width => 450, :height => 300)
      link :target => "_blank", :rel => "nofollow"
      simple_format
  end

and my view:

    <p><%=comment.text_html%></p>

this was working in rails 3.0.10 but when using 3.2 this happens:

ActiveModel::MissingAttributeError in Posts#show

Showing /Users/phaser/Sites/porlaputa/app/views/comments/_comment.html.erb where line #7 raised:

can't write unknown attribute `text_html'
Extracted source (around line #7):

4:
5:
6: <div class="comment <%="reply" unless comment.post%>" id="comment<%=comment.id%>">
7:

<%=comment.text_html%>


8:

9: <%=comment.vomits.sample()%>
10: <% if comment.user %>

CSS Media queries

Using the Gem for Youtube and Vimeo embeds. However, I'm also using media queries and 'hard coding' the render size in the videos controller does not allow for a change in size when the window is smaller. Any ideas / workarounds?

Thank you,
Ed

vimeo videos support for "https"

For example
https://vimeo.com/32765088

Outputs as url instead of video embed link.

In the filters for vimeo, i think regex will change from
text.gsub(/http:\/\/(www.)?vimeo\.com\/([A-Za-z0-9._%-]*)((\?|#)\S+)?/)
text.gsub(/(https?):\/\/(www.)?vimeo\.com\/([A-Za-z0-9._%-]*)((\?|#)\S+)?/) similar to what you did for youtube.

Access object within filter

Is there any way to get at the object that this is being called on from within a filter? I would like to make a filter for Liquid templating, but need to pass the object itself into the render rather than just text.

AutoHtml.add_filter(:liquid).with({}) do |text, options|
  Liquid::Template.parse(text).render(options)
end

enable youtube iframe fullscreen button in webkit

Hi,
thanks for the great work! I started to learn rails (4 weeks ago). Using auto_html is great fun and easy.
The fullscreenoption was not shown while embedding a youtube video via iframe. The iframe Markup needs to be altered a little.

Because I am new to github, I dont know how to proceed in the right way. (can I commit somehow?) So to provide a possible sollution I forked your Repo and added a Filter called "youtube_with_fullscreen_option". If someone could point me to a how to of Github contributing?

So please feel free to add the change to your master code if you think the solution is valuable.
before:
Bildschirmfoto 2012-12-17 um 19 16 51
after:
Bildschirmfoto 2012-12-17 um 19 16 25

Thank you

j

How about short URL with bit.ly?

When I paste short URL with bit.ly into content text, it isn't shown up in the preview mode as images, youtube, or so.
What can I do for this?

Hyo Seong Choi

It doesn't work on Rails3.2.11

I'm using another gem called "acts_as_commentable_with_threading". It automatically creates "models/comment.rb" so I added this to it in order to make it changed to playable thumbnail every time when it's posted. However it doesn't do any. Why is that?
I'm using RoR3.2.11, RInku1.5.0, and auto_html1.5.2

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

Facebook Style Preview

I am new to rails! It would be really nice to see a facebook style preview when someone enters a link, it returns the title, content if its a video retuns embeded video, image returns image, if content just some content, also returns a favicon.ico image... instead of just a link with a target="_blank" feature.

pismo, Mechanize, feedzirra, Nokogiri etc help us get there but I want it to be with auto_html, it is very easy to use!

(v. 1.5.3) inline auto_html working, but auto_html_for does nothing in rails 3.2.5

I saw post on StackExchange similar to this: http://stackoverflow.com/questions/9928200/rails-auto-html-gem-is-not-working
for v 1.5.1, but it sounded like the newer version 1.5.2 resolved this. However, I loaded v 1.5.2 and it also did nothing.

Is it possible it wasn't resolved, or that there was a regression? Or am I perhaps doing something wrong?

#post.rb

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

vs:

<%= auto_html(post.body) { html_escape; image; youtube(:width => 500, :height => 280); link :target => "_blank", :rel => "nofollow"; simple_format } %>

Which works fine.

Is there some type of gotcha here? I would think this would have been logged here as a bug already.

Handling errors

I see that Tweets were working a few days ago, but no longer. I think there should be a generic way for handling errors arising from wrong URLs or when a service is longer responding according to older protocols.

undefined method `auto_html_for' for #<Class:0x00000003c6d038>

I'm using ruby 1.9.2 with rails 3.0.0, I included auto_html into my gem file like this: gem 'auto_html'
and included this into my model (I have a field called body)

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

however, I am getting an error saying: undefined method `auto_html_for' for #Class:0x00000003c6d038

c extensions and jruby

jruby support for c extensions, such as Riku and Redcloth used here, is limited and in some cases nonexistant.

Does anyone have good ideas for alternatives to these gems? Crappy ideas?

Cheers

STI problems

Does this work with single table inheritance? It seems to work fine on regular tables, but the auto_html_prepare method isn't even recognized on instances of an STI model. Perhaps I have something else wrong with the model.

youtube urls: https and params appearing before v=

auto_html (1.4.2) doesn't seem to like http__s__ youtube links, for example:

 > auto_html("https://www.youtube.com/watch?v=t7NdBIA4zJg") {youtube;}
 => "https://www.youtube.com/watch?v=t7NdBIA4zJg"

Also, auto_html doesn't seem to like parameters appearing before the v param in youtube urls, for example:

 >  auto_html("http://www.youtube.com/watch?NR=1&v=t7NdBIA4zJg") {youtube;}
 => "http://www.youtube.com/watch?NR=1&v=t7NdBIA4zJg" 
 >  auto_html("http://www.youtube.com/watch?v=t7NdBIA4zJg&NR=1") {youtube;}
 => "<iframe class=\"youtube-player\" type=\"text/html\" width=\"390\" height=\"250\" src=\"http://www.youtube.com/embed/t7NdBIA4zJg\" frameborder=\"0\">\n</iframe>"

Note that I copied this url straight from youtube: https://www.youtube.com/watch?NR=1&v=t7NdBIA4zJg

Thanks for this library, I'm hoping to use it in a current project!

Running migration cause error

Model Comment has code as in example:

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

Migration for this model also fine.

create_table "comments", :force => true do |t|
      t.text :comment,              :default => ""
      t.text :comment_html,         :default => ""
      t.references :creator
      t.references :userpost
      t.integer :people_rate,       :default=>0, :null=>false       
      t.integer :votes_cnt,         :default=>0, :null=>false       
      t.integer :parent_id,         :default=>nil                   
      t.integer :lft                                                
      t.integer :rgt                                               
      t.integer :depth,              :default=>0                    
      t.boolean :is_public,          :default=>true, :null=>false    
      t.boolean :delta,              :default=>true                
      t.timestamps
    end
   add_index :comments, :creator_id
   add_index :comments, :userpost_id

Everything has worked, till I've updated gem. Now AR exception rised:

PG::Error: ERROR:  relation "comments" does not exist
LINE 4:              WHERE a.attrelid = '"comments"'::regclass
                                        ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"comments"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum

Renaming colomn doesn't solve issue.

auto_html_for problem when running db:schema:load

I have a Post model and an auto_html_for(body), I have also created the field body_html, but when I run db:schema:load it throws me the error Mysql2::Error: Table 'finepanel_dev.posts' doesn't exist: SHOW FULL FIELDS FROM `posts. I remove the auto_html_for line and started to work ok...

YouTube full screen mode

I noticed that full screen mode isn't working. Attribute allowfullscreen doesn't change anything.

Can't get 'rake auto_html:rebuild' task to run

Been using this cool gem auto_html for a while, but I can't get the rake tasks it comes with to run.

"rake auto_html:rebuild CLASS=Attachment"

I keep getting a rake error: "Don't know how to build task 'auto_html:rebuild'"

The gem runs fine otherwise.

Do I need to edit the Rakefile or application.rb file?

Any ideas?

Thanks!

NameError: uninitialized constant Post on auto_html:rebuild

Hello,

I try to launch RAILS_ENV=production bundle exec rake auto_html:rebuild CLASS=Post on production but I get this error: NameError: uninitialized constant Post.

It works on my development environment. Do you have an idea of what is happening?

Environment: Rails 3.2.17, Ruby 2.1.1, auto_html 1.6.4

Thanks.

Typo in README

It says "inlcude AutoHtml". Great plugin BTW. I'm trying it out right now. :)

auto_html is breaking rails migrations

this code in my posts model

 auto_html_for :body do
    strip_tags
    html_escape
    image
    youtube(:width => 600, :height => 375)
    vimeo(:width => 600, :height => 375)
    link :target => "_blank", :rel => "nofollow"
    simple_format
  end

is causing this error when I run rails migrations:

rake aborted!
PG::Error: ERROR:  relation "posts" does not exist
LINE 4:              WHERE a.attrelid = '"posts"'::regclass
                                        ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"posts"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum

This looks similar to another issue that was supposed to be fixed in 1.6.0. I am running 1.6.0 though.... #42

thoughts?

gem not loading

In a running app, I'm putting the auto_html in gemfile, bundle install but none methods from autohtml seems to work.

rails server load normally, but auto_html method, and auto_html_for doesnt work always get errors like: undefined methodauto_html' for #<#Class:0x00000102c63330:0x00000102c60ae0>

I know is a loading problem, but I am not getting any error, and I use many others gems.

any clue

Setting wmode for flash embedded object?

Is there a way to set the wmode parameter to prevent the video from sitting on top of everything?
Essentially, adding one of these tags within the tag?

.....param name="wmode" value="transparent"

Dailymotion filter clobbers HTML

This seems to be an issue with lots of the filters - but DailyMotion filter specifically is clobbering HTML embeds. For instance, if you already have the HTML embed and run auto_html on it, the code tries to embed it inside the embed - breaking HTML.

I believe the default behavior should be to ignore all URLs already encased within a HTML tag.

PS: I fixed a similar issue with the image filter here https://github.com/subimage/auto_html/commit/110c62727a9cc30bcb4a11c7a58d8f462dfa58c0

TypeError: can't dup NilClass

TypeError: can't dup NilClass

The above mentioned error occurs when the original field is nil.

lib/filter.rb should read something like text.to_s.dup instead of text.dup

Mixed content warning when app protocol is https

My app is running ssl enabled and non enabled mode. When youtube video with http protocol is added it works fine in http mode mode but in https it is throwing mixed content warning. Is there any way to change protocol of video url in code generated by auto_html dynamically by checking my app's protocol? is there any other alternative solutions?

Is this meant to eventually support pre-existing HTML markup?

Hi all,

I notice that there are a lot of areas where this would break existing HTML markup (i.e. any link where the src= one of the supported urls). I see related pull requests @subimage #116, #114 that would fix this in certain situations. But if this is really meant to work with anyone's existing markup, and you need URL filters to only target text, some architectural changes (possibly involving parsing content into nodes via Nokogiri and then only running filters on text) would be easier and more DRY than adding the conditions onto every regex. That's a big change in functionality.

The content of README.md seems to indicate that this is meant to be used as either a complete filter on very simple content fields (without much previous markup, which gets escaped), or as a simple filter called individually when you know you need it (once you've isolated exactly the text that needs changing).

I love the respository - it works very well for my project when used in the latter way. But if it's meant to work on all prexisting markup it needs some changes. If not, perhaps this could be indicated in the readme so similar issues and pull requests aren't raised.

@dejan, could you let us know if you see this repository eventually fully supporting pre-existing markup? Or should we plan on calling filters on isolated sections in those cases?

AutoHtml on ActiceResource object

Hi,

I've some problems using auto_html on my ActiveResource object.

The problem comes from the fact ActiveResource doesn't bring the write_attribute and read_attribute methods.
I tried implementing my own solution but it ends in an infinite loop, quite normal in fact.

Have you got some ideas ?

Ty

Mongoid Support

Dears,

i tried auto_html the gem and also the master git and both return errors with mongoid.

e.g. undefined method `column_names'

vimeo filter

I found a little problem in vimeo filter. When someone post link to vimeo user profile for example: http://vimeo.com/staff . it is trying to generate video.

"There was a problem loading this video."

This problem is also when I add this link http://vimeo.com/channels/vimeohq and many other. This filter should generate only Vimeo videos just like Youtube.

How can I fix it?

flickr filter

When enabled and using any flickr url I have tried, I get the following:
ActionView::Template::Error (A JSON text must at least contain two octets!):

ruby 1.9.3p547

auto_html (1.6.4)
redcarpet (~> 3.1)

activemodel (support for other mappers like mongoid)?

Seems like this would be a great addition to activemodel for Rails3 so it could be used across other database mappers (mongoid, mongo_mapper, datamapper).

I'd love to use it with mongoid right now. How easy would a port be?

youtube filter swallows text that comes after a link, when used together wysiwyghtml5 editor

In a similar way to #29, I'm seeing a similar behavior when using auto_hml together with https://github.com/xing/wysihtml5. It seams that WYSIWYG editors wrap different lines with <br/> tags, removing white space after the link.

Better explained with an example, this works:

AutoHtml::auto_html("bar http://www.youtube.com/watch?v=hsl3ckR_D7Q <br>foo"){ youtube(:width => 400, :height => 240)}
=> "bar <iframe width=\"400\" height=\"240\" src=\"//www.youtube.com/embed/hsl3ckR_D7Q\" frameborder=\"0\" allowfullscreen></iframe> <br>foo"

But this doesn't:

AutoHtml::auto_html("bar http://www.youtube.com/watch?v=hsl3ckR_D7Q<br>foo"){ youtube(:width => 400, :height => 240)}
=> "bar <iframe width=\"400\" height=\"240\" src=\"//www.youtube.com/embed/hsl3ckR_D7Q\" frameborder=\"0\" allowfullscreen></iframe>"

Ideas?

auto_html is not working with rails 4

When i'm trying to run auto_html gem on rails 4 i got this error:

can't write unknown attribute `body_html'

It looks like it is not working because of strong parameters.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.