GithubHelp home page GithubHelp logo

rob-murray / jekyll-twitter-plugin Goto Github PK

View Code? Open in Web Editor NEW
238.0 238.0 30.0 957 KB

A Liquid tag plugin for the Jekyll blogging engine that embeds Tweets, Timelines and more from Twitter API

License: MIT License

Ruby 100.00%
jekyll ruby twitter-api

jekyll-twitter-plugin's People

Contributors

harryscholes avatar jwithington avatar kenirwin avatar rob-murray avatar ryanburnette 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

jekyll-twitter-plugin's Issues

tweet embed options not being passed

I'm using the latest version 2.1.0 but I'm having trouble getting multiple options working:

{% twitter https://twitter.com/moyix/status/1486860078477156355 dnt=true width=350 conversation=none cards=hidden %}

Produces:

<div class='jekyll-twitter-plugin'><blockquote class="twitter-tweet" data-dnt="true"><p lang="en" dir="ltr">Wow, this looks like a big step forward for Binary Ninja! Congrats to <a href="https://twitter.com/vector35?ref_src=twsrc%5Etfw">@vector35</a>, I&#39;m looking forward to trying it out (especially the new Pseudo-C decompiler)! <a href="https://t.co/4GiBoS8NhP">https://t.co/4GiBoS8NhP</a></p>&mdash; Brendan Dolan-Gavitt (@moyix) <a href="https://twitter.com/moyix/status/1486860078477156355?ref_src=twsrc%5Etfw">January 28, 2022</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>

Notice that the width, conversation, and cards options are not being passed.

If I manually replace the liquid with the HTML and add the data-conversation, data-width, data-cards fields, the embed works as expected.

Allow customisation of content via options

The previous plugin enabled you to pass extra options to Twitter API via KV pairs to customise the appearance of the content to be rendered.

{% request etc... align='right' width='350' %}

Grab everything after the N required arguments as optional params and pass to the Twitter API.

So, in the form of an Oembed request like this below would get the correctly specified content.

{% twitter oembed https://twitter.com/rubygems/status/518821243320287232 align='right' width='350' %}

Jekyll won't build when trying to use the plugin

Hi,
After successful installing the plugin it seems every time i actually try and use the plugin i get the following error:

Liquid Exception: SSL_connect returned=1 errno=0 state=error: certificate verify

Any ideas why this would be the case?

Can't get plugin to work

I've been troubleshooting for about an hour now and I can't get the plugin to work at all. I've double-checked that my credentials are correct and that the links I'm trying to oembed are correct.

I'll update this issue if I can find anything but I wanted to see if I was the only one dead in the water on v1.2.0.

strip newlines from twitter embed

See #31

Background on this is that Jekyll was choking on the newline when a tweet was included as part of a list item, causing the list to close early and leaving a dangling

The Twitter embed comes back with \n between the blockquote and the script. For whatever reason Jekyll hated this. ¯_(ツ)_/¯

no feed shown, just a link to the twitter page

On the rendered page, nothing but the link to the twitter page shows. No twitter feed embedded. Could I have misinstalled or have a setting wrong? I believe I had this working at some point.

This is what I get when I put {% twitter https://twitter.com/username maxwidth=500 limit=5 %} in my .html and after I've run jekyll serve:

 <div class="jekyll-twitter-plugin">
<a class="twitter-timeline" data-width="500" data-tweet-limit="5" href="https://twitter.com/username?ref_src=values">Tweets by Username</a>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
</div>

Cache not working

It seems that tweets are always fetched. From my debugging and limited Ruby experience, the problem is the following:

An Oembed instance gets created. It's key is <url>- (note the empty right part). After the tweet is fetched, that key becomes <url>-{id: <id>}. So when we check on the cache, we use one hash, but when we store, the hash changes.

I'm not sure how @params gets modified (unless when calling @client.oembed tweet, @params that modifies them, of course).

At least for my use case, making the key just <url> works, but having the @params as part of the key might have some implications I'm not fully aware of.

Replace Twitter gem?

It seems with the (new ?) publish platform that we do not need to use the Twitter gem, we can take the status, timeline, list or search url and pass straight to this api.

Pros:

  • No external dependencies, just a json api - remove the Twitter gem
  • Extra features I have wanted - timeline, tweet button
  • No auth required - remove code for API keys
  • No rate limit - remove caching code?
  • Existing format of public api works - drop the api type, the params still applicable and correct
  • Better to understand (?) - we use the Twitter gem that supports posting, updating, etc and things we will never need, this gem is now a jekyll extension of the publish platform, we can publish twitter stuff in jekyll pages. Simple.

Cons:

  • Twitter gem hides the Twitter API nicely, now we would be directly coupled to their API, any major changes their end mean we break. What happens if they decided to shut it down?

Allow destination of cache directory

For my current site, I use Jekyll Assets and Webmentions and they provide the changing of the cache directory. It's handy when doing things like buildpack-based deployment on Heroku or using Docker and intermediary builds.

Having something like twitter_cache: .cache/twitter would be great.

Using variable?

Hello,
I'm trying to use variable (for my example: page.tweet) without luck. What I tried:

method 1

{% include tweet.html
  tweet = page.tweet
%}

tweet.html:

{% twitter include.tweet align='center' %}

method 2

{% twitter page.tweet align='center' %}

Thank you

Toggle data cards option

If you manually set <blockquote class="twitter-tweet" data-cards="hidden"> it will hide data cards. Is there any way to pass that into the {% twitter %} tag?

If I try to edit the cached version to include that, then it just writes out a new cache file and ignores the modified version.

Caching does not take additional params into account

Using additional parameters does not change the cache key so the same cache content is always used regardless of parameters.

Therefore only possible to display a Tweet with new options by deleting the cache.

The cache key currently just takes the Tweet specific elements of the status url and not additional params - fix this to build a key from the param hash too.

More updates off the back of Twitter

The Twitter API seems to be returning a few Http 403's with "Sorry, you are not authorized to see this status.". These are raised as Twitter::Error::Forbidden via the Twitter gem.

This could be due so some Twitter API changes or Twitter user changes? Think if the Dev account used via the API does not follow the Tweet poster, and they mark their Tweets as private then the request fails.

Error: `getaddrinfo: nodename nor servname provided`

I installed this plugin using the ruby gem as instructed. I can't get it to work. Every time I've tried, I get the following message:

  Liquid Exception: Failed to open TCP connection to : (getaddrinfo: nodename nor servname provided, or not known) in //path/to/file/_posts/2022-04-26-April26.md

I thought I would try and run the tests as described. When I run the test I get the following output

$ ruby spec/integration_tests.rb                                                                                                                                                                                  [7:32:32]
<internal:/usr/local/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- byebug (LoadError)
        from <internal:/usr/local/Cellar/ruby/3.0.2_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from spec/integration_tests.rb:8:in `<main>'

I don't know ruby very well so I'm not sure what is happening here. Please advise

Feature Request : Embed tweets of public profile based on tags.

I don't know if this is even possible. but I am looking for a solution where I would like to embed all my tweets with a specific tag to be embedded in my jekyll site.

For ex: I would like to have a Tweets page where I would want all my tweets with tag #TIL to be embedded in a list or grid.

I am not sure if this is possible or very difficult. Please close this issue if not possible.

Thanks.

Implementing twitter

I am using the Manual process to implement twitter

I have followed the following steps

$ mkdir -p _plugins && cd _plugins
$ wget https://raw.githubusercontent.com/rob-murray/jekyll-twitter-plugin/master/lib/jekyll-twitter-plugin.rb

And I also added
plugins: ['jekyll-twitter-plugin'] ---> this in _config.yml

I also added the following piece of code in my index.html

{% twitter https://twitter.com/jekyllrb maxwidth=500 limit=5 %}

But nothing seems to be work on my local machine

Embedding 2+ tweets on same page causes them to be nested

Reproducible with a sample page:

---
title: Example
---

{% twitter https://twitter.com/DegenRolf/status/1286929770488487936 %}

aaa

{% twitter https://twitter.com/DegenRolf/status/806044913854976000 %}

And outputted HTML:

<div class="jekyll-twitter-plugin">
  <blockquote class="twitter-tweet">
    <p lang="en" dir="ltr">Just saying “have a nice day” to a stranger helped people have a nicer day themselves. <a href="https://t.co/qt01mlakJB">https://t.co/qt01mlakJB</a> <a hr
    <p>— Rolf Degen (@DegenRolf) <a href="https://twitter.com/DegenRolf/status/1286929770488487936?ref_src=twsrc%5Etfw">July 25, 2020</a>&lt;/blockquote&gt;
<script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
&lt;/div&gt;</p>
                                                                                                                                                                                     
    <p>aaa</p>

    <div class="jekyll-twitter-plugin">
      <blockquote class="twitter-tweet">
        <p lang="en" dir="ltr">Gift-givers are often too much focussed on the moment of the gift handover to achieve the optimal impact. <a href="https://t.co/a3OTE1Nm9c">https://t.
        <p>— Rolf Degen (@DegenRolf) <a href="https://twitter.com/DegenRolf/status/806044913854976000?ref_src=twsrc%5Etfw">December 6, 2016</a>&lt;/blockquote&gt;
<script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
&lt;/div&gt;</p>
      </blockquote>
    </div>
  </blockquote>
</div>

Make the oembed the default tag type

This plugin was intended to be able to use any of the Twitter API functions, so the tag arguments are as follows.

{% plugin_type api_type *params %}

At the moment the need has not arisen for more api types so maybe make the current oembed type the default so that you can just do this.

{% twitter https://twitter.com/rubygems/status/518821243320287232 %}

Embedding Tweets works fine but inserts a line of unwanted HTML

Hi Rob,

I searched for an easy way to embed Tweets into my Octopress/Jekyll blog and your plugin was really easy to install and set up.

Only problem I have is a line of HTML after each embedded tweet reading:

<script async src=”//platform.twitter.com/widgets.js” charset=”utf-8”>

The copy & pasted HTML from Safaris Source view is:

<div class="embed twitter"><blockquote class="twitter-tweet"><p>jekyll-twitter-plugin (1.0.0): A Liquid tag plugin for Jekyll that renders Tweets from Twitter API <a href="http://t.co/m4EIQPM9h4">http://t.co/m4EIQPM9h4</a></p>&mdash; RubyGems (@rubygems) <a href="https://twitter.com/rubygems/status/518821243320287232">October 5, 2014</a></blockquote>
&lt;script async src=&#8221;//platform.twitter.com/widgets.js&#8221; charset=&#8221;utf-8&#8221;&gt;</div>

Here is a screenshot of the problem:

embedded_tweet_screenshot

I am running OS X 10.10 and Ruby 1.9.3 via rbenv.

Is there some way to get rid of this last line? Did you see something like this before?

Regards

Dennis

Cache never gets used

Hi,

I'm using the {% twitter ... %} tag and it correctly writes out a hashed file for a Tweet in the .tweet-cache folder but I don't think this file ever gets read.

If I edit the cached file to modify a tweet it still pulls the original. This holds true even if I completely shut down and rebuild the site with Jekyll. I even went as far as modifying the render method to only return the cached_response but it seems to still pull the live_response.

jekyll 2.4.0 | Error ... read server certificate B: certificate verify failed

I'm having trouble getting this running. Here are the steps I've taken so far:

  • I've added gem 'jekyll-twitter-plugin' and gem 'twitter' to my Gemfile
  • I've added gems: ['jekyll-twitter-plugin', 'twitter'] to _config.yml
  • I've added an app on Twitter and exported all of the required environment variables
  • I've double checked the variables by calling echo $TWITTER_<name> for each variable
  • I've run bundle update

But I always get the following result:

$ rake generate## Generating Site with Jekyll
identical source/stylesheets/screen.css
Configuration file: /Users/jeremykendall/dev/blog/jeremykendall.net/_config.yml
            Source: source
       Destination: public
      Generating...
  Liquid Exception: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed in _posts/2013-11-24-php-and-capistrano-3-notes-to-self.markdown/#excerpt
jekyll 2.4.0 | Error:  SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

What am I missing?

GDPR compilent opt-in / opt-ot for twitter usage

Hi,

I am in the process of implementing a cookie consent dialog for the al-folio template (alshedivat/al-folio#199). It should allow users to individually opt-in / opt-out of using cookies. This means I need to disable / enable the twitter post when the website is displayed in the browser. It is not enough to hide the <div> the plugin is using for the twitter post. I need to prevent the actual API calls from happening, so no cookies are set by twitter.

Is this possible? And how would I achieve this?

show comments on a tweet?

If you would also show comments of a tweet one could use it as a kind of comment via twitter function on a blog

Can be used in Github pages?

Hello,

I added manually this plugin to my jekyll blog, but when commited to github I get an error:

The tag twitteron line 5 in_posts/xxx.md is not a recognized Liquid tag. For more information, see https://help.github.com/articles/page-build-failed-unknown-tag-error/.

I thought as this is a liquid plugin it would work, but it doesn't. What am I missing here?

Thank you in advance,
Alex

Twitter options does not work

It seems to me that Twitter options (conversation) does not work or I did not understand how to configure it. When I use

{% twitter https://twitter.com/Split82/status/766572568585404420 conversation=none %}

I still see the conversation. I have tried to clear the twitter cache but with no effect.

tweet

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.