Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install mdx-twitter

How to install mdx-twitter

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install mdx-twitter
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
Linux (64-bit)
0.2.6 Available View build log
 
License
BSD
Imports
Lastest release
version 0.2.6 on Jan 9th, 2014
https://badge.fury.io/py/mdx-twitter.png https://travis-ci.org/zen4ever/mdx-twitter.png?branch=master https://pypip.in/d/mdx-twitter/badge.png

Markdown extension for embedding tweets using twitter OEmbed API

  • Free software: BSD license

How to use

Allows you to embed tweets into your Markdown.

Just install the package:

System Message: ERROR/3 (<string>, line 26)

Unknown directive type "code-block".

.. code-block:: bash

    pip install mdx-twitter

Because Twitter API 1.1 requires you to authenticate, you will need to create a config file with your credentials at '~/.mdx_twitter.cfg':

[Twitter]
CONSUMER_KEY=xxxxxxxxxxxx
CONSUMER_SECRET=xxxxxxxxxxxx
ACCESS_TOKEN=xxxxxxxxxxxx
ACCESS_TOKEN_SECRET=xxxxxxxxxxxx

Then just add 'twitter' to the list of your extensions:

System Message: ERROR/3 (<string>, line 41)

Unknown directive type "code-block".

.. code-block:: python

    import markdown

    md = markdown.Markdown(extensions=['twitter'])

Twitter urls in your Makdown will become embedded tweets:

https://twitter.com/jasoncosta/status/240192632003911681

Django integration

Since Twitter has a rate limit on their APIs, and doing network calls all the time just to render Markdown is a bad idea anyways, we would need some caching.

If you are using mdx-twitter in a Django project, it will automatically use your cache settings to cache HTML returned from Twitter API.

Also, you could place your API credentials in TWITTER_SETTINGS variable in your project's settings.py, instead of using .cfg file

System Message: ERROR/3 (<string>, line 63)

Unknown directive type "code-block".

.. code-block:: python

    TWITTER_SETTINGS = {
        'CONSUMER_KEY': '',
        'CONSUMER_SECRET': '',
        'ACCESS_TOKEN': '',
        'ACCESS_TOKEN_SECRET': '',
    }

Embedding tweets in UIWebView

There are currently some problems with embedding tweets in UIWebView.

  • Protocol agnostic src attribute "//platform.twitter.com/widgets.js" doesn't allow script to load

  • There seems to be a problem with automatically determining width of the container

    https://dev.twitter.com/discussions/15450

So there is a 'width' configuration option that offers a quick 'fix' for those problems. Just specify expected width of your tweet in pixels.

System Message: ERROR/3 (<string>, line 88)

Unknown directive type "code-block".

.. code-block:: python

    import markdown

    md = markdown.Markdown(extensions=['twitter(width=300)'])

It will only work with 'style' full.

Styles

You can customize appearance of your tweets using 'style' configuration options. Default style is 'full', which includes script javascript, you could also use 'simple' style, which just includes tweet in a blockquote tag without javascript.

Another option would be to specify a path to your own function, which accepts Twitter response json as an argument and should return final html.

An example custom style is included in the library. You can use it by specifying 'style=mdx_twitter.custom_style'

TODO

  • If we embed multiple tweets, we don't need to have script tag after each tweet. We should probably just have a script tag at the end of the document.

History

0.1.0 (2013-08-31)
  • First release on PyPI.

Subscribe to package updates

Last updated Jan 9th, 2014

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.