Login

Tag "twitter"

Snippet List

Tweet embed template tag

Takes a tweet url, requests the json from Twitter oEmbed, parses the json for the html element and returns it to your template. The html returned is ready to go and will be shown as a tweet on your web page. This uses the Requests library for Python. A full example can be found on GitHub https://github.com/z3ke1r/django-tweet-embed.

  • django
  • templatetag
  • json
  • embed
  • twitter
  • parse
  • requests
  • tweet
Read More

tweetparser filter

Django Template Filter that parse a tweet in plain text and turn it with working Urls Ceck it on [GitHub](https://github.com/VincentLoy/tweetparser-django-template-filter) # tweetParser Django Template Filter this is a port of [tweetParser.js](https://github.com/VincentLoy/tweetParser.js) to work as a Django template filter ## How does it work ? Once installed, just : ``` <p>{{ your_tweet|tweetparser }}</p> ``` ## Installation Take a look at the [Django Documentation](https://docs.djangoproject.com/en/1.8/howto/custom-template-tags/) #### You can change the classes given to each anchor tags ``` USER_CLASS = 'tweet_user' URL_CLASS = 'tweet_url' HASHTAG_CLASS = 'hashtag' ```

  • filter
  • templatetag
  • templatetags
  • twitter
  • parse
  • parser
  • tweet
Read More

Latest tweets Templatetag

Based on [http://djangosnippets.org/snippets/1615/](http://djangosnippets.org/snippets/1615/) Added tweets cache. Cache time is configurable through project settings: TWITTER_TIMEOUT=300. Default time is 300 seconds = 5 minutes. This improve performance by reducing the twitter api queries interval.

  • templatetag
  • twitter
  • social
Read More

Share button

This template can be included by other template passing the vars page_url and title: {% with content.get_url as page_url %} {% with content.title as title %} {% include 'share.html' %} {% endwith %} {% endwith %}

  • google
  • facebook
  • twitter
  • html5
  • linkedin
  • reader
  • share
Read More

Twitter template tags and filters

A simple template filter for parsing tweets (linking @ replies, hashtages and standard URLs whilst stripping out links to yFrog and TwitPic images), and two simple tags for displaying the yFrog and TwitPic images linked to in tweets. If you put the snippet in a file called tweets.py, as long as it lives in an app's templatetags directory, you should be able to do the following (where `text` refers to the text of a tweet): {% load twitter %} <p>{{ text|tweet }}</p> {% yfrog_images text 1 'fancybox' %} {% twitpic_images text 1 'fancybox' %} The first argument in the two tags controls how many images to render. Set this to -1 for an unlimited number, per tweet. Thumbnail images are displayed, and you can specify the class that is applied to the `<a>` tags rendered. Here I've used 'fancybox', and I would normally include jQuery code to turn the images inside the `<a>` tags into lightboxes.

  • twitter
Read More

Template filter to turn Twitter names into links

Quick and simple twitterize filter to turn Twitter usernames into profile links on your own sites. Add the filter code to your own template tags (http://docs.djangoproject.com/en/dev/howto/custom-template-tags/).

  • twitter
  • twtterize
Read More

Twitterfy

Improved version of my snippet #1346. Now works correctly with multiple usernames and hash tags. Both twitter usernames and hashtags are converted into links to twitter profiles and twitter search. Updated, forgot about underscores in usernames.

  • template-filter
  • twitter
  • hash-tag
  • at-reply
Read More

Template tag: Last x twitter msgs of user

A template tag which returns the n last tweets of a given user. It uses the twitter python lib. {% get_twitter_messages user foo limit 5 as tweets %} {% for tweet in tweets %} {{ tweet.text }} {{ tweet.time }} {{ tweet.url }} {% endfor %}

  • templatetag
  • twitter
Read More

automating twitter

Assume you have a model called Delegate and you want to tweet whenever a new Delegate registers, the code above will do this. You need to install python-twitter.

  • twitter
Read More

TwitterBackend

TwitterBackend is the twitter authentication backend. This backend makes use of OAuth based "Sign-in with Twitter" Configure your settings.py as per [Django - Specifying Authentication Backends](http://docs.djangoproject.com/en/dev/topics/auth/#specifying-authentication-backends)

  • django
  • authentication
  • python
  • backend
  • twitter
  • oauth
Read More

twitterize filter

This filter links twitter user names prefixed with '@', hash tags, and URLs. Usage example: `{{var|twitterize}}` Note: Do not use this in conjunction with the urlize filter. Twitterize does this for you.

  • filter
  • twitter
  • hash-tags
  • @replies
Read More

Twitter oAuth example

**UPDATE**: A more complete example is up on [GitHub](http://github.com/henriklied/django-twitter-oauth/tree/master) Based around Simon Willison's [Fire Eagle oAuth](http://www.djangosnippets.org/snippets/655/), this will allow you to develop Twitter oAuth applications (…that is – if you're in the closed beta)

  • twitter
  • oauth
Read More

Signal to post new saved objects to Twitter

Post new saved objects to Twitter. **Example:** from django.db import models class MyModel(models.Model): text = models.CharField(max_length=255) link = models.CharField(max_length=255) def __unicode__(self): return u'%s' % self.text def get_absolute_url(self): return self.link # the following method is optional def get_twitter_message(self): return u'my-custom-twitter-message: %s - %s' % (self.text, self.link) models.signals.post_save.connect(post_to_twitter, sender=MyModel)

  • twitter
  • signal
Read More

18 snippets posted so far.