Middleman::Blog::Twitter
Tweet about the latest article on Middleman blog.
Installation
Add this line to your application's Gemfile:
gem 'middleman-blog-twitter'
And then execute:
$ bundle
Or install it yourself as:
$ gem install middleman-blog-twitter
Usage
1. Settings(Tweet text template)
Create ERB for tweet text(ex. tweet_template.txt.erb
).
Blog updated: <%= latest_article.title %> <%= hostname %><%= latest_article.url %>
Available variables
name | value |
---|---|
latest_article | Middleman::Sitemap::Resource included Middleman::Blog::BlogArticle object of the latest blog article |
hostname | Your blog hostname(set in the next section) |
2. Settings(Tokens, hostname, and template path)
On config.rb
activate :blog_twitter do |twitter|
twitter.consumer_key = 'YOUR CONSUMER KEY'
twitter.consumer_secret = 'YOUR CONSUMER SECRET'
twitter.access_token = 'YOUR ACCESS TOKEN'
twitter.access_token_secret = 'YOUR ACCESS TOKEN SECRET'
twitter.hostname = 'http://example.com' # your blog hostname
twitter.template_path = 'tweet_template.txt.erb'
twitter.force_tweet = false # If true, tweet regardless of the date of latest article. (Default: false)
twitter.new_article_threshold = 1.hour # Tweet if date of latest article newer than threshold. (Default: 1.hour)
end
3. Execute command
$ middleman tweet
then
Blog updated: <latest article title> <latest article url>
Contributing
- Fork it ( http://github.com//middleman-blog-twitter/fork )
- 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