Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
thumbnail support!
Browse files Browse the repository at this point in the history
  • Loading branch information
thraxil committed Apr 24, 2008
1 parent bc199ed commit 69b9736
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 230 deletions.
21 changes: 17 additions & 4 deletions fu/models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
from django.db import models
from sorl.thumbnail.fields import ImageWithThumbnailsField

class Author(models.Model):
class Admin:
pass
first_name = models.CharField(maxlength=30)
last_name = models.CharField(maxlength=30)
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
email = models.EmailField()
bio = models.TextField(blank=True)
headshot = ImageWithThumbnailsField(upload_to="headshots",
thumbnail = {
'size' : (65,65)
},
extra_thumbnails={
'admin': {
'size': (70, 50),
'options': ('sharpen',),
}
}
)

class Meta:
ordering = ["first_name","last_name"]
Expand All @@ -29,7 +41,7 @@ class Issue(models.Model):
class Admin:
pass
pub_date = models.DateField()
status = models.CharField(maxlength=30,default="draft",
status = models.CharField(max_length=30,default="draft",
choices=(('draft','Draft'),
('published','Published')))

Expand All @@ -52,7 +64,7 @@ def main_article(self):
class Article(models.Model):
class Admin:
pass
headline = models.CharField(maxlength=256)
headline = models.CharField(max_length=256)
slug = models.SlugField(prepopulate_from=["headline"])
lede = models.TextField(blank=True)
content = models.TextField(blank=True)
Expand All @@ -61,6 +73,7 @@ class Admin:
modified = models.DateTimeField(auto_now=True)
main = models.BooleanField(default=False)
cardinality = models.PositiveSmallIntegerField(default=1)
cartoon = models.ImageField(upload_to="cartoons/%Y/%m/%d",blank=True)

class Meta:
order_with_respect_to = 'issue'
Expand Down
14 changes: 10 additions & 4 deletions fu/templates/issue.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% load markup %}
{% extends "base.html" %}
{% load markup %}
{% load thumbnail %}


{% block content %}
<h1 id="masthead"><span>the-fu.com: {{ issue.pub_date }}</span></h1>
Expand All @@ -24,8 +26,10 @@ <h2>{{ main_article.headline }}</h2>
{{ main_article.content|markdown }}

<div id="byline">
<div class="article-thumb"><img src="/site_media/images/gray.png"
width="75" height="75" /></div>
<div class="article-thumb">
<img src="{% thumbnail main_article.author.headshot 65x65 crop,upscale %}"
width="65" height="65" />
</div>
<p>by {{ main_article.author.fullname}}</p>
</div>
</div>
Expand All @@ -36,7 +40,9 @@ <h2>{{ main_article.headline }}</h2>
{% for article in issue.non_main_articles %}

<div class="article">
<div class="article-thumb"><img src="/site_media/images/gray.png" width="75" height="75" /></div>
<div class="article-thumb">
<img src="{% thumbnail article.author.headshot 65x65 crop,bw,upscale %}" width="65" height="65" />
</div>
<h2><a href="{{ article.get_absolute_url }}">{{ article.headline }}</a></h2>
<p>{{ article.author.fullname }}</p>
<div class="clear"></div>
Expand Down
2 changes: 2 additions & 0 deletions media/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@ p.lede { font-weight: bold;}
p { margin-bottom: 2em;}

a { color: #000; text-decoration: none;}

h2 { font-size: 1.2em;}
77 changes: 6 additions & 71 deletions settings.py
Original file line number Diff line number Diff line change
@@ -1,87 +1,22 @@
# Django settings for fusite project.

from settings_shared import *

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_email@domain.com'),
('Anders Pearson','anders@columbia.edu')
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'fu' # Or path to database file if using sqlite3.
DATABASE_USER = 'anders' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
# although not all variations may be possible on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/New_York'

# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = False
TEMPLATE_DIRS = (
"/var/www/fu/stage/fusite/fu/templates"
)

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
MEDIA_ROOT = '/tmp/fusite/data/'

# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '7meh%(ope+brcma0#fwf=(rugh_iw&ak51=fjdf%4zo7la$m&#'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

ROOT_URLCONF = 'fusite.urls'

TEMPLATE_DIRS = (
"/var/www/fu/stage/fusite/fu/templates"
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.flatpages',
'fusite.fu',
'django.contrib.admin',
'django.contrib.markup',
)
Binary file modified settings.pyc
Binary file not shown.
85 changes: 7 additions & 78 deletions settings_production.py
Original file line number Diff line number Diff line change
@@ -1,87 +1,16 @@
# Django settings for fusite project.
from settings_shared import *

DEBUG = True
DEBUG = False
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_email@domain.com'),
('Anders Pearson','anders@columbia.edu')
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'fu' # Or path to database file if using sqlite3.
DATABASE_USER = 'anders' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
# although not all variations may be possible on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/New_York'

# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = False

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '7meh%(ope+brcma0#fwf=(rugh_iw&ak51=fjdf%4zo7la$m&#'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

ROOT_URLCONF = 'fusite.urls'
DATABASE_NAME = 'fu'

TEMPLATE_DIRS = (
"/var/www/fu/prod/fusite/fu/templates"
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.flatpages',
'fusite.fu',
'django.contrib.admin',
'django.contrib.markup',
)
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/var/www/fu/prod/data/'

77 changes: 4 additions & 73 deletions settings_stage.py
Original file line number Diff line number Diff line change
@@ -1,87 +1,18 @@
# Django settings for fusite project.
from settings_shared import *

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_email@domain.com'),
('Anders Pearson','anders@columbia.edu')
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'fu_stage' # Or path to database file if using sqlite3.
DATABASE_USER = 'anders' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
# although not all variations may be possible on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/New_York'

# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = False

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '7meh%(ope+brcma0#fwf=(rugh_iw&ak51=fjdf%4zo7la$m&#'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
TEMPLATE_DIRS = (
"/var/www/fu/stage/fusite/fu/templates"
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)
MEDIA_ROOT = '/var/www/fu/stage/data/'

ROOT_URLCONF = 'fusite.urls'

TEMPLATE_DIRS = (
"/var/www/fu/stage/fusite/fu/templates"
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.flatpages',
'fusite.fu',
'django.contrib.admin',
'django.contrib.markup',
)
1 change: 1 addition & 0 deletions urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
(r'^issues/(?P<year>\d+)\-(?P<month>\d+)\-(?P<day>\d+)/$', 'fusite.fu.views.issue'),
(r'^issues/(?P<year>\d+)\-(?P<month>\d+)\-(?P<day>\d+)/(?P<slug>[^/]+)/$', 'fusite.fu.views.article'),
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/home/anders/code/python/fusite/media/'}),
(r'^uploads/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/tmp/fusite/data'}),
(r'^admin/', include('django.contrib.admin.urls')),
)
Binary file modified urls.pyc
Binary file not shown.

0 comments on commit 69b9736

Please sign in to comment.