About
Tweets allows you add a Twitter feed to your site in minuites. This version of refinerycms-tweets
supports Refinery 3.x and Rails 4.1.x. To use Rails 3.x / Refinery 2.1.x use the refinerycms-tweets "Refinery CMS 2-1 stable branch".
Features
- Use either a Twitter widget or a jQuery implementation using the Public API
- JQuery implementation accepts an optional callback to override the default response rendering
- Twitter widget can be fully customised
Note: The Twitter widget doesn't require jQuery however if you choose to use the Public API jQuery is required. I do plan to add a vanilla javascript implementation in future but pull requests are welcome!
Installation
Add this line to your application's Gemfile:
gem 'refinerycms-tweets', git: 'https://github.com/cih/refinerycms-tweets', branch: 'master'
Next run:
bundle
rails generate refinery:tweets
rake db:migrate
Now when you start up your Refinery application, there should be a new "Twitter" tab to manage the account.
Usage
Just add an account and put the following into your view.
<%= tweets %>
Note: If you do not have a view template already then you will need to override one, here is an example of how to do that.
rake refinery:override view=refinery/_footer
Configuration
By default the Twitter widget will be used if the twitter account has a username and widget_id. If there is a username but no widget_id then it will fallback to use the jQuery list. This behaviour can be changed in the initializer as required.
# config/initializers/refinery/tweets.rb
Refinery::Tweets.use_twitter_widget = true
Refinery::Tweets.fallback_to_jquery_tweet_list = true
Customising
Just pass in you options as a hash. Here is an example using the twitter widget. You can see a fill list of options in the docs
<%= tweets("data-chrome"=> "noheader", "data-theme" => "dark", :callback => "testalert") %>
<%= content_for :javascripts do %>
<script>
function testalert(response){
alert(response);
}
</script>
<% end %>
In this case the callback will only be triggered if there is no widget_id.
Screenshot
Testing
The refinerycms-testing gem allows you to generate a dummy app within the engine to run the tests against.
rake refinery:testing:dummy_app
rake spec
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request