From b88372f0327976c31e6b508b26729bab60743f82 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Tue, 6 Feb 2007 23:34:08 -0800 Subject: photos app roughed in, style tweaked TODO: search code --- bn_django/photos/manual_import.py | 64 +++++++++++++++++++++++ bn_django/settings.py | 2 +- bn_django/templates/.about.html.swp | Bin 12288 -> 0 bytes bn_django/templates/about.html | 11 +++- bn_django/templates/base.html | 14 +++-- bn_django/templates/frontpage.html | 66 ++++++++++++++++++++++-- bn_django/templates/static/directory_index | 18 +++++++ bn_django/templates/static/directory_index.html | 13 ----- bn_django/urls.py | 1 + 9 files changed, 163 insertions(+), 26 deletions(-) create mode 100644 bn_django/photos/manual_import.py delete mode 100644 bn_django/templates/.about.html.swp create mode 100644 bn_django/templates/static/directory_index delete mode 100644 bn_django/templates/static/directory_index.html (limited to 'bn_django') diff --git a/bn_django/photos/manual_import.py b/bn_django/photos/manual_import.py new file mode 100644 index 0000000..a9b5448 --- /dev/null +++ b/bn_django/photos/manual_import.py @@ -0,0 +1,64 @@ +# Create your views here. + +# django imports +from django.conf import settings + +# other imports +import zipfile +import os +import stat +import shutil +from datetime import datetime +from tempfile import NamedTemporaryFile, mkdtemp +import Image +try: + from cStringIO import StringIO +except ImportError: + from StringIO import StringIO + +# Handling settings here +STOCKPHOTO_BASE = '/home/bnewbold/bn-project/media/photos' + +# models +from bn_django.photos.models import Gallery, Photo + +# views + + +def manual_import_photos(thezipfile, thegallery): + # Check if the gallery is valid + gallery = thegallery; + + f = file(thezipfile); + zip = zipfile.ZipFile(f) + #date = the_date + #if not date: + date = datetime.date(datetime.now()) + + destdir= os.path.join(settings.MEDIA_ROOT, STOCKPHOTO_BASE, + datetime.strftime(datetime.now(), + "%Y/%m/%d/")) + if not os.path.isdir(destdir): + os.makedirs(destdir, 0775) + for filename in zip.namelist(): + photopath = os.path.join(destdir, os.path.basename(filename)) + data = zip.read(filename) + file_data = StringIO(data) + try: + Image.open(file_data) + except: + # don't save and process non Image files + continue + photo = file(photopath, "wb") + photo.write(data) + + # Create the object + if photopath.startswith(os.path.sep): + photopath = photopath[len(settings.MEDIA_ROOT):] + photo = Photo(image=photopath, date=date, + photographer='Bryan Newbold', + title = os.path.basename(filename), + gallery_id = thegallery) + # Save it -- the thumbnails etc. get created. + photo.save() + return diff --git a/bn_django/settings.py b/bn_django/settings.py index 282f4c9..e8ee891 100644 --- a/bn_django/settings.py +++ b/bn_django/settings.py @@ -38,7 +38,7 @@ MEDIA_ROOT = '/home/bnewbold/bn-project/media/' # URL that handles the media served from MEDIA_ROOT. # Example: "http://media.lawrence.com" -MEDIA_URL = 'http://bryannewbold.com/media/' +MEDIA_URL = '/media/' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. diff --git a/bn_django/templates/.about.html.swp b/bn_django/templates/.about.html.swp deleted file mode 100644 index 40f88fd..0000000 Binary files a/bn_django/templates/.about.html.swp and /dev/null differ diff --git a/bn_django/templates/about.html b/bn_django/templates/about.html index eb03970..f8db11a 100644 --- a/bn_django/templates/about.html +++ b/bn_django/templates/about.html @@ -9,7 +9,7 @@ {% block content %}

-

+

the perp
@@ -22,10 +22,17 @@ This website is the web presence of Bryan Newbold.
browsable code repository
so people (including myself!) don't have to rewrite
home for other projects -
like... mmmmm +
like... hhmmmmm
waste of time
(most importantly!)

If you're curious about the technology that runs the site, see the credits. +
+
+
+
+
+
+ {% endblock %} diff --git a/bn_django/templates/base.html b/bn_django/templates/base.html index a87d0a5..84f7ffb 100644 --- a/bn_django/templates/base.html +++ b/bn_django/templates/base.html @@ -12,20 +12,24 @@ bryannewbold.com knowledge  photos  - code  - projects + code +

+
+
+
+ + +
+
{% block path %}{% endblock %}

{% block title %}Hey Hey Hey!{% endblock %}

{% block right_stuff %} -  -hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey hey -hey hey hey {% endblock %}
diff --git a/bn_django/templates/frontpage.html b/bn_django/templates/frontpage.html index 47a55dd..ac9323c 100644 --- a/bn_django/templates/frontpage.html +++ b/bn_django/templates/frontpage.html @@ -2,13 +2,13 @@ {% block path %}{% endblock %} -{% block title %}Welcome to a brave new bold world!{% endblock %} +{% block title %}A Brave New Bold World!{% endblock %} {% block right_stuff %} -Other sites: : : : : : : : : : : : : : - +Other sites:
+   - athena locker
+   - facebook?
+   - git repository {% endblock %} {% block content %} @@ -26,6 +26,62 @@ Other sites: : : : : : : : : : : : : : There will be more forthcoming ... There will be more forthcoming ... There will be more forthcoming ... +
+ + there is no spoon! there is no spoon! + there is no spoon! there is no spoon! + there is no spoon! there is no spoon! + +
+ There will be more forthcoming ... + There will be more stuff forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + +
+
+what if i put more content over here? also, will it wrap correctly? +
+
+
+ There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more stuff forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more stuff forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... + There will be more forthcoming ... {% endblock %} diff --git a/bn_django/templates/static/directory_index b/bn_django/templates/static/directory_index new file mode 100644 index 0000000..61e7f02 --- /dev/null +++ b/bn_django/templates/static/directory_index @@ -0,0 +1,18 @@ +{% extends "base.html" %} + +{% block title %} +

Index of /{{ directory }}

+{% endblock %} + +{% block content %} +
+ +
+
+
+ +{% endblock %} diff --git a/bn_django/templates/static/directory_index.html b/bn_django/templates/static/directory_index.html deleted file mode 100644 index 6df279d..0000000 --- a/bn_django/templates/static/directory_index.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "base.html" %} - -{% block title %} -

Index of {{ directory }}

-{% endblock %} - -{% block content %} - -{% endblock %} diff --git a/bn_django/urls.py b/bn_django/urls.py index f8b1b62..327e9ec 100644 --- a/bn_django/urls.py +++ b/bn_django/urls.py @@ -17,4 +17,5 @@ urlpatterns = patterns('', (r'^admin/', include('django.contrib.admin.urls')), (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': '/home/bnewbold/bn-project/static', 'show_indexes': True}), (r'^style/(?P.*)$', 'django.views.static.serve', {'document_root': '/home/bnewbold/bn-project/static/style'}), + (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': '/home/bnewbold/bn-project/media'}), ) -- cgit v1.2.3