Skip to content

atarukodaka/middleman-twitter-oembed

Repository files navigation

Gem Version Build Status Coverage Status Code Climate

Middleman::TwitterOembed

An extension to render and/or convert twitter stauts id into o-Embed status. see https://dev.twitter.com/rest/reference/get/statuses/oembed for detail of twitter o-Embed.

Installation

Add this line to your application's Gemfile:

gem 'middleman-twitter-oembed'

And then execute:

$ bundle

Or install it yourself as:

$ gem install middleman-twitter-oembed

Usage

in config.rb:

activate :twitter_oembed

convert before rendering

on default, twitter url(like 'http://twitter.com/foo/status/123456789') will be converted to twitter box before rendering.

You can change the regex to match:

activate :twitter_oembed do |twitter|
  twitter.convert_regex = %r{\[\[twitter: *(\d+)\]\]}
end

If you don't want to convert, set false for enable_convert option:

activate :twitter_oembed do |twitter|
  twitter.enable_convert = false
end

helper

in *.erb:

<%= twitter_oembed('123456789') %>

or

<%= twitter_oembed_by_url('http://twitter.com/foo/status/123456789') %>

caching

in default, the result of oEmbed will be cached.

activate :twitter_oembed do |twitter|
  twitter.use_cache = true
  twitter.cache_dir = ".caches/twitter-oembed"
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

  1. Fork it ( https://github.com/atarukodaka/middleman-twitter-oembed/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published