GithubHelp home page GithubHelp logo

jekyll-tweet-tag's Introduction

Liquid Tweet Tag for Jekyll and Octopress

This is a simple Liquid tag that makes it easy to embed tweets. This is great for quoting a tweet in a blog post, for example. It uses Twitter's oEmbed API for their Embedded Tweet feature. Features include:

  • Easy to install
  • Easy to embed tweets
  • Displays tweets with familiar twitter style
  • Optional parameters to control layout (as described in Twitter's oEmbed API)
  • Provides twitter features such as retweet, follow, and favorite without leaving your page

How To Install

  1. Copy tweet_tag.rb into <your-jekyll-project>/_plugins or <your-ocotpress-project>/plugins.
  2. That is all.

How To use

Place a tweet tag in your content file, using the URL to the tweet, e.g.:

{% tweet https://twitter.com/DEVOPS_BORAT/statuses/159849628819402752 %}

You can also just copy the Wordpress shortcode generated by Twitter's "Embed this Tweet" UI and change the [...] to {% ... %}. For example:

{% tweet https://twitter.com/DEVOPS_BORAT/status/159849628819402752 align='right' width='350' %}

The first argument to the tweet tag must be the tweet URL, but everything after that is optional. You can pass any parameter supported by the Twitter oEmbed API in the form key='value'.

In an attempt to maintain compatibility with Robert Böhnke's Embed.ly Tag, the tweet tag wraps the embedded code with a <div class='embed tweet'>.

Caching

The Twitter oEmbed API is rate-limited. The tweet tag caches all API responses in a directory named .tweet-cache. This way, regenerating your site does not re-query for every embedded tweet every time. You can safely delete the .tweet-cache directory. It will be recreated and embedded tweets will be re-queried.

You can also use the tweetnocache tag to embed a tweet that bypasses the cache. This is not recommended since it will request the embed code from twitter every time that page is regenerated.

Author

Scott W. Bradley -- http://scottwb.com

Credits

This code is inspired by the Gist Tag plugin by Brandon Tilley and the oEmbed Tag by Tammo van Lessen.

License

This code is licensed under Apache License 2.0

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.