8d75ea2ae6de

Goodbye thoughts, youll live on in version control!
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 15 Feb 2009 00:54:05 -0500
parents 3a51bfa414da
children 02c8b7019c84
branches/tags (none)
files settings.py templates/feeds/thoughts_description.html templates/feeds/thoughts_title.html templates/thoughts/list.html thoughts/__init__.py thoughts/admin.py thoughts/import.py thoughts/models.py thoughts/urls.py thoughts/views.py urls.py

Changes

--- a/settings.py	Sun Feb 15 00:50:20 2009 -0500
+++ b/settings.py	Sun Feb 15 00:54:05 2009 -0500
@@ -89,7 +89,6 @@
     'django.contrib.flatpages',
     'stevelosh.blog',
     'stevelosh.projects',
-    'stevelosh.thoughts',
     'stevelosh.photoblog',
     'mobileadmin',
     'typogrify',
--- a/templates/feeds/thoughts_description.html	Sun Feb 15 00:50:20 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-{% load markup %}
-
-{% ifequal obj.type 'thought-text' %}
-	{{ obj.item.body|markdown }}
-{% endifequal %}
-
-{% ifequal obj.type 'thought-link' %}
-	<a href="{{ obj.item.url }}">
-		{% if obj.item.name %}
-			{{ obj.item.name }}
-		{% else %}
-			{{ obj.item.url }}
-		{% endif %}
-	</a>
-	{% if obj.item.description %}
-		{{ obj.item.description|markdown }}
-	{% endif %}
-{% endifequal %}
\ No newline at end of file
--- a/templates/feeds/thoughts_title.html	Sun Feb 15 00:50:20 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-{% ifequal obj.type 'thought-text' %}
-	{% if obj.item.title %}
-		{{ obj.item.title }}
-	{% else %}
-		{{ obj.item.body|truncatewords:10 }}
-	{% endif %}
-{% endifequal %}
-
-{% ifequal obj.type 'thought-link' %}
-	{% if obj.item.name %}
-		{{ obj.item.name }}
-	{% else %}
-		{{ obj.item.url }}
-	{% endif %}
-{% endifequal %}
\ No newline at end of file
--- a/templates/thoughts/list.html	Sun Feb 15 00:50:20 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-{% extends "base.html" %}
-{% load markup %}
-{% load typogrify %}
-
-{% block title %}Thoughts{% endblock %}
-
-{% block style %}
-    <link rel="stylesheet" href="/site-media/style/thoughts.css" 
-          type="text/css"/>
-{% endblock %}
-
-{% block header %}/ thoughts{% endblock %}
-
-{% block content %}
-    <div id="thoughts-list">
-        {% for thought in thoughts %}
-            <div class="thought">
-                {% ifequal thought.type 'text' %}
-                    <a name="text-{{ thought.id }}"></a>
-                    <div class="thought-type span-2">
-                        <h2>text</h2>
-                    </div>
-                    <div class="thought-content text-thought colborder-left span-14 last">
-                        {% ifnotequal thought.title None %}
-                            <h2>{{ thought.title|typogrify }}</h2>
-                        {% endifnotequal %}
-                        {{ thought.body|markdown|typogrify }}
-                    </div>
-                {% endifequal %}
-                {% ifequal thought.type 'link' %}
-                    <a name="link-{{ thought.id }}"></a>
-                    <div class="thought-type span-2">
-                        <h2>link</h2>
-                    </div>
-                    <div class="thought-content link-thought colborder-left span-14 last">
-                        <h2><a href="{{ thought.url }}">
-                            {% if thought.name %}
-                                {{ thought.name|typogrify }}
-                            {% else %}
-                                {{ thought.url }}
-                            {% endif %}
-                        </a></h2>
-                        {% if thought.description %}
-                            {{ thought.description|markdown|typogrify }}
-                        {% endif %}
-                    </div>
-                {% endifequal %}
-            </div>
-        {% endfor %}
-        
-        {% ifnotequal newer_page older_page  %}
-            <div class="thought thought-navigation prepend-3">
-            {% ifnotequal newer_page None %}
-                {% ifequal newer_page 0 %}
-                    {% url thoughts-list-newest as new_page %}
-                {% else %}
-                    {% url thoughts-list-page newer_page as new_page %}
-                {% endifequal %}
-                <span id="thought-list-newer">
-                    <h2><a href="{{ new_page }}">
-                        Newer &raquo;
-                    </a></h2>
-                </span>
-            {% endifnotequal %}
-            {% ifnotequal older_page None %}
-                <span id="thought-list-older">
-                    <h2><a href="{% url thoughts-list-page older_page %}">
-                        &laquo; Older
-                    </a></h2>
-                </span>
-            {% else %}
-                <span id="thought-list-older">
-                    <h2>&nbsp;</h2>
-                </span>
-            {% endifnotequal %}
-            </div>
-        {% endifnotequal %}
-    </div>
-{% endblock %}
\ No newline at end of file
--- a/thoughts/admin.py	Sun Feb 15 00:50:20 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-from stevelosh.thoughts.models import TextThought, LinkThought
-from django.contrib import admin
-
-class TextAdmin(admin.ModelAdmin):
-    list_display = ('posted', 'title', 'body',)
-    search_fields = ('title', 'body',)
-    list_filter = ('posted',)
-    date_hierarchy = 'posted'
-    ordering = ('-posted',)
-
-class LinkAdmin(admin.ModelAdmin):
-    list_display = ('url', 'name', 'posted', 'description',)
-    search_fields = ('name', 'url', 'description',)
-    list_filter = ('posted',)
-    date_hierarchy = 'posted'
-    ordering = ('-posted',)
-
-
-admin.site.register(TextThought, TextAdmin)
-admin.site.register(LinkThought, LinkAdmin)
\ No newline at end of file
--- a/thoughts/import.py	Sun Feb 15 00:50:20 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-#!/usr/local/bin/python2.5
-
-import sys, os
-sys.path.append('/home/sjl/webapps/stevelosh')
-os.environ['DJANGO_SETTINGS_MODULE'] = 'stevelosh.settings'
-
-import simplejson, urllib, urllib2
-from stevelosh.thoughts.models import TextThought, LinkThought
-from datetime import datetime
-
-
-TUMBLR_API_URL = r'http://stevelosh.tumblr.com/api/read/json'
-
-def parse_tumblr_json(data):
-    tumblr_prefix = r'var tumblr_api_read = '
-    if data.startswith(tumblr_prefix):
-        data = data.strip()
-        data = data[len(tumblr_prefix):-1]
-    else:
-        return None
-    return simplejson.loads(data)
-
-def fetch_tumblr_data(type):
-    parameters = {'type': type, 'filter': 'none'}
-    url_parameters = urllib.urlencode(parameters)
-    full_api_url = TUMBLR_API_URL + '?' + url_parameters
-    response = urllib2.urlopen(full_api_url)
-    return parse_tumblr_json(response.read())
-
-def update_text_thoughts():
-    recent_thoughts = fetch_tumblr_data('regular')
-    for thought in recent_thoughts['posts']:
-        tumblr_id = thought['id']
-        try:
-            TextThought.objects.get(tumblr_id=tumblr_id)
-        except TextThought.DoesNotExist:
-            title = thought['regular-title'] \
-                    if thought['regular-title'] != "" else None
-            new_thought = TextThought(
-                    tumblr_id=tumblr_id,
-                    title=title,
-                    body=thought['regular-body'],
-                    posted=datetime.fromtimestamp(thought['unix-timestamp']) )
-            new_thought.save()
-
-def update_link_thoughts():
-    recent_thoughts = fetch_tumblr_data('link')
-    for thought in recent_thoughts['posts']:
-        tumblr_id = thought['id']
-        try:
-            LinkThought.objects.get(tumblr_id=tumblr_id)
-        except LinkThought.DoesNotExist:
-            name = thought['link-text'] \
-                    if thought['link-text'] != "" else None
-            description = thought['link-description'] \
-                    if thought['link-description'] != "" else None
-            new_thought = LinkThought(
-                    tumblr_id=tumblr_id,
-                    name=name,
-                    description=description,
-                    url=thought['link-url'],
-                    posted=datetime.fromtimestamp(thought['unix-timestamp']) )
-            new_thought.save()
-
-update_text_thoughts()
-update_link_thoughts()
--- a/thoughts/models.py	Sun Feb 15 00:50:20 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-from django.db import models
-import datetime
-
-class TextThought(models.Model):
-    title = models.CharField(blank=True, null=True, max_length=1000)
-    posted = models.DateTimeField()
-    body = models.TextField()
-    tumblr_id = models.IntegerField(blank=False, null=False)
-    type = models.CharField(default='text', max_length=100)
-    
-    def get_absolute_url(self):
-        return u'/thoughts/#text-' + str(self.id)
-    
-    def __unicode__(self):
-        return u'%s' % (self.body[:20],)
-
-class LinkThought(models.Model):
-    name = models.CharField(blank=True, null=True, max_length=1000)
-    posted = models.DateTimeField()
-    url = models.URLField(blank=False, verify_exists=False)
-    description = models.TextField(blank=True, null=True)
-    tumblr_id = models.IntegerField(blank=False, null=False)
-    type = models.CharField(default='link', max_length=100)
-    
-    def get_absolute_url(self):
-        return u'/thoughts/#text-' + str(self.id)
-    
-    def __unicode__(self):
-        return u'%s' % (self.url,)
-
--- a/thoughts/urls.py	Sun Feb 15 00:50:20 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-from django.conf.urls.defaults import *
-
-urlpatterns = patterns('stevelosh.thoughts.views',
-    url(r'^$',            'list', name='thoughts-list-newest'),
-    url(r'^page/(\d+)/$', 'list', name='thoughts-list-page'),
-)
\ No newline at end of file
--- a/thoughts/views.py	Sun Feb 15 00:50:20 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-from stevelosh.thoughts.models import TextThought, LinkThought
-from django.shortcuts import render_to_response
-from django.core.paginator import Paginator
-import operator
-
-ENTRIES_PER_PAGE = 10
-
-def list(request, page=1):
-    page = int(page)
-    
-    thoughts = []
-    thoughts += TextThought.objects.all().order_by('-posted')
-    thoughts += LinkThought.objects.all().order_by('-posted')
-    thoughts.sort(key=operator.attrgetter('posted'))
-    thoughts.reverse()
-    
-    paginator = Paginator(thoughts, 5, orphans=2)
-    p = paginator.page(page)
-    
-    return render_to_response('thoughts/list.html', 
-        { 'thoughts': p.object_list,
-          'older_page': p.next_page_number() if p.has_next() else None,
-          'newer_page': p.previous_page_number() if p.has_previous() else None } )
--- a/urls.py	Sun Feb 15 00:50:20 2009 -0500
+++ b/urls.py	Sun Feb 15 00:54:05 2009 -0500
@@ -11,7 +11,6 @@
     (r'^m/(.*)', mobileadmin.sites.site.root),
     url(r'^blog/', include('stevelosh.blog.urls')),
     url(r'^projects/', include('stevelosh.projects.urls')),
-    url(r'^thoughts/', include('stevelosh.thoughts.urls')),
     url(r'^photoblog/', include('stevelosh.photoblog.urls')),
     url(r'^rss/', include('stevelosh.rss.urls')),
 )