# HG changeset patch # User Peter Sanchez # Date 1289318039 28800 # Tue Nov 09 07:53:59 2010 -0800 # Node ID 9aeb480e9f533a9ab85b504708304c052ddb03a1 # Parent 6b4ef36644735a8aae45d77d47f5f061b250c8a6 Updated README.txt and added license file diff --git a/BSD-LICENSE b/BSD-LICENSE new file mode 100644 --- /dev/null +++ b/BSD-LICENSE @@ -0,0 +1,32 @@ +Copyright (c) 2009, Peter Sanchez +All rights reserved. + +Redistribution and use in source and binary forms, with or +without modification, are permitted provided that the +following conditions are met: + + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + + * Neither the name of Peter Sanchez nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.txt b/README.txt --- a/README.txt +++ b/README.txt @@ -0,0 +1,80 @@ +django-twittersync +------------------ + +Very basic application to sync a Twitter account's stream to +the local storage engine. + +There are a few other applications that handle this for you +but none of them fit my needs, so here we are. The idea behind +this app is to be very light weight - do one thing and do it well. + +There is no need for a Twitter consumer key or token for use with +this app. It makes use of the public facing (non-auth required) REST +API. This also means that if the account you are trying to sync is +setup as private, this app will not sync that account. + + +Install +------- + +Basic Install: + + $ python setup.py build + $ sudo python setup.py install + +Alternative Install (Manually): + +Place webutils directory in your Python path. Either in your Python +installs site-packages directory or set your $PYTHONPATH environment +variable to include a directory where the webutils directory lives. + + +Use +--- +1) Add 'twittersync' to your INSTALLED_APPS + +2) Run 'python manage.py syncdb' + +3) Add a twitter account via the admin interface + +4) Run 'python manage.py sync_twitter_accounts' + +There you go. You might want to setup a cron job to run the +sync_twitter_accounts command (like on step 4) every hour or so. + +To display your tweets in a template, simple do something like: + +{% load twittersync_tags %} + +{% get_latest_tweets "accountname" 5 as "tweets" %} +{% for tweet in tweets %} + {{ tweet.content }}
+{% endfor %} + +This will grab the last 5 status updated for the twitter account +"accountname" and place it in the context as the variable named +"tweets" + +Replace "accountname" with the name of the account you want to +sync. It can be a string or an actual TwitterAccount (model) +instance. + +Replace 5 with the number of updates to fetch. If it's not given +the template tag will check for the following settings variable: + +TWITTERSYNC_LATEST_TWEETS + +It will default to 5 if that variable doesn't exist. + + +That's it! Simple right? + +Enjoy. + + +Copyright & Warranty +-------------------- +All documentation, libraries, and sample code are +Copyright 2010 Peter Sanchez . The library and +sample code are made available to you under the terms of the BSD license +which is contained in the included file, BSD-LICENSE. diff --git a/twittersync/management/commands/sync_twitter_accounts.py b/twittersync/management/commands/sync_twitter_accounts.py --- a/twittersync/management/commands/sync_twitter_accounts.py +++ b/twittersync/management/commands/sync_twitter_accounts.py @@ -11,5 +11,5 @@ help = 'Sync all active Twitter account streams.' def handle_noargs(self, **options): - for account in TwitterAccount.objects.filter(is_active=True): + for account in TwitterAccount.active.all(): sync_twitter_account(account)