summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorluxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f>2010-03-12 03:42:13 +0000
committerluxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f>2010-03-12 03:42:13 +0000
commitef35853e54e1572dc1de4fd2311d00dfd16e4f75 (patch)
treefe712fa6a1a2c38761e0458bf1684274a510df32 /apps
parent0882d73ca1ba4c84ce24c946548c80d9e4d1c04e (diff)
added projects
Diffstat (limited to 'apps')
-rw-r--r--apps/blog/admin.py2
-rw-r--r--apps/blog/models.py2
-rw-r--r--apps/links/utils.py49
-rw-r--r--apps/photos/models.py1
-rw-r--r--apps/projects/__init__.py0
-rw-r--r--apps/projects/models.py142
-rw-r--r--apps/projects/urls.py15
7 files changed, 164 insertions, 47 deletions
diff --git a/apps/blog/admin.py b/apps/blog/admin.py
index c5c5c5d..6f1cbb9 100644
--- a/apps/blog/admin.py
+++ b/apps/blog/admin.py
@@ -23,7 +23,7 @@ class EntryAdmin(OSMGeoAdmin):
list_filter = ('pub_date', 'enable_comments', 'status','region','location')
fieldsets = (
('Entry', {'fields': ('title','body_markdown', ('location','region'), 'pub_date', ('status','enable_comments'), 'tags', 'slug','photo_gallery'), 'classes': ('show','extrapretty','wide')}),
- ('Pub Location', {'fields': ('point',('thumbnail',),'dek', 'topics', 'title_keywords'), 'classes': ('collapse', 'wide')}),
+ ('Pub Location', {'fields': ('point',('thumbnail',),'dek', 'topics', 'meta_description'), 'classes': ('collapse', 'wide')}),
)
class Media:
diff --git a/apps/blog/models.py b/apps/blog/models.py
index bdbcd82..fb0dac6 100644
--- a/apps/blog/models.py
+++ b/apps/blog/models.py
@@ -66,7 +66,7 @@ class Entry(models.Model):
status = models.IntegerField(choices=PUB_STATUS, default=0)
photo_gallery = models.ForeignKey(PhotoGallery, blank=True, null=True, verbose_name='photo set')
thumbnail = models.FileField(upload_to=get_upload_path, null=True,blank=True)
- title_keywords = models.CharField(max_length=200, null=True, blank=True)
+ meta_description = models.CharField(max_length=256, null=True, blank=True)
topics = models.ManyToManyField(Topic, blank=True)
@property
diff --git a/apps/links/utils.py b/apps/links/utils.py
index 9acbd52..9e5aea5 100644
--- a/apps/links/utils.py
+++ b/apps/links/utils.py
@@ -70,9 +70,9 @@ def sync_magnolia_links(*args, **kwargs):
break
def sync_delicious_links(*args, **kwargs):
- b = delicious.get(settings.DELICIOUS_USER, settings.DELICIOUS_PASS)
+ b = delicious.get_all(settings.DELICIOUS_USER, settings.DELICIOUS_PASS)
dupe = False
- for post in b['posts']:
+ for post in b:
taglist = []
try:
row = Link.objects.get(magnolia_id=safestr(post['hash']))
@@ -91,7 +91,7 @@ def sync_delicious_links(*args, **kwargs):
break
else:
status = 0
- descr = markdown.markdown(unquotehtml(safestr(post['extended'])), safe_mode = False)
+ descr = markdown.markdown(unquotehtml(safestr(post['extended'])), safe_mode = False)
l, created = Link.objects.get_or_create(
title = post['description'],
magnolia_id = safestr(post['hash']),
@@ -115,48 +115,7 @@ def sync_delicious_links(*args, **kwargs):
break
-
- """
- b, created = Link.objects.get_or_create(
- url = info['href'],
- description = info['extended'],
- tags = info.get('tag', ''),
- date = parsedate(info['time']),
- title = info['description']
- )
- for b in bookmarks.bookmarks.bookmark:
-
- try:
- row = Link.objects.get(magnolia_id=safestr(b.id))
- # If the row exists already, set the dupe flag
- print b.title.PCDATA
- dupe = True
- except ObjectDoesNotExist:
- tags=", ".join(t.name for t in b.tags.tag if t.name != "2lux")
- # grab the photo (local copies are good, should I ever change bookmark services)
- local_image_url = "%s/%s.jpg" %(safestr(datetime.datetime.today().strftime("%b").lower()), safestr(b.id))
- f = copy_file(safestr(b.screenshot.PCDATA), safestr(b.id))
- # set the privacy flag (default to false to be on the safe side)
- public = 0
- if safestr(b.private) == 'false': public=1
- # Create and save a new link obj
- l = Link.objects.create(
- title = safestr(b.title.PCDATA),
- magnolia_id = safestr(b.id),
- url = safestr(b.url.PCDATA),
- description = unquotehtml(safestr(b.description.PCDATA)),
- screen_url = local_image_url,
- rating = safestr(b.rating),
- pub_date = datetime.datetime(*(time.strptime(str(b.created[:-6]), '%Y-%m-%dT%H:%M:%S')[0:6])),
- status = public,
- enable_comments = True,
-
- )
- email_link(l)
- send_to_delicious(l)
- if (dupe):
- break
- """
+
def email_link(link):
diff --git a/apps/photos/models.py b/apps/photos/models.py
index 73098b3..a157c6e 100644
--- a/apps/photos/models.py
+++ b/apps/photos/models.py
@@ -138,6 +138,7 @@ class PhotoGallery(models.Model):
class Meta:
ordering = ('id',)
+ verbose_name_plural = 'Photo Galleries'
def __unicode__(self):
return self.set_title
diff --git a/apps/projects/__init__.py b/apps/projects/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apps/projects/__init__.py
diff --git a/apps/projects/models.py b/apps/projects/models.py
new file mode 100644
index 0000000..bdbcd82
--- /dev/null
+++ b/apps/projects/models.py
@@ -0,0 +1,142 @@
+import datetime
+from django.contrib.gis.db import models
+from django.conf import settings
+from django.contrib.syndication.feeds import Feed
+from django.contrib.sitemaps import Sitemap
+from django.template.defaultfilters import truncatewords_html
+
+
+import markdown2 as markdown
+from tagging.fields import TagField
+from tagging.models import Tag
+
+from photos.models import PhotoGallery
+from locations.models import Location,Region
+#from locations.signals import create_location_item
+from blog.signals import update_recent
+
+def get_upload_path(self, filename):
+ return "images/post-thumbs/%s/%s" %(datetime.datetime.today().strftime("%Y"), filename)
+
+def markdown_processor(md):
+ processed = markdown.markdown(md, safe_mode = False).split('<break>')
+ html = processed[0]+processed[1]
+ lede = processed[0]
+ return html, lede
+
+class PostImage(models.Model):
+ title = models.CharField(max_length=100)
+ image = models.ImageField(upload_to="%s%s" %(settings.IMAGES_ROOT, datetime.datetime.today().strftime("%Y")))
+
+ def __unicode__(self):
+ return self.title
+
+ def output_tags(self):
+ return force_unicode('<img src="%s%s" alt="%s" class="postpic"/>' % \
+ (settings.IMAGES_URL, self.image.url.split('images')[1].split('/',1)[1], self.title))
+
+
+class Topic(models.Model):
+ name = models.CharField(max_length=100)
+ slug = models.SlugField()
+
+ def __unicode__(self):
+ return self.name
+
+ def get_absolute_url(self):
+ return "/topics/%s/" % (self.slug)
+
+class Entry(models.Model):
+ title = models.CharField(max_length=200)
+ slug = models.SlugField(unique_for_date='pub_date')
+ lede = models.TextField(blank=True)
+ body_html = models.TextField(blank=True)
+ body_markdown = models.TextField()
+ dek = models.TextField(null=True,blank=True)
+ pub_date = models.DateTimeField('Date published')
+ tags = TagField()
+ enable_comments = models.BooleanField(default=True)
+ point = models.PointField(null=True)
+ location = models.ForeignKey(Location, null=True)
+ region = models.ForeignKey(Region, null=True)
+ PUB_STATUS = (
+ (0, 'Draft'),
+ (1, 'Published'),
+ )
+ status = models.IntegerField(choices=PUB_STATUS, default=0)
+ photo_gallery = models.ForeignKey(PhotoGallery, blank=True, null=True, verbose_name='photo set')
+ thumbnail = models.FileField(upload_to=get_upload_path, null=True,blank=True)
+ title_keywords = models.CharField(max_length=200, null=True, blank=True)
+ topics = models.ManyToManyField(Topic, blank=True)
+
+ @property
+ def longitude(self):
+ '''Get the site's longitude.'''
+ return self.point.x
+
+ @property
+ def latitude(self):
+ '''Get the site's latitude.'''
+ return self.point.y
+
+ class Meta:
+ ordering = ('-pub_date',)
+ get_latest_by = 'pub_date'
+ verbose_name_plural = 'entries'
+
+ def __unicode__(self):
+ return self.title
+
+ def get_absolute_url(self):
+ return "/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(), self.slug)
+
+ def get_previous_published(self):
+ return self.get_previous_by_pub_date(status__exact=1)
+
+ def get_next_published(self):
+ return self.get_next_by_pub_date(status__exact=1)
+
+ def get_tags(self):
+ return Tag.objects.get_for_object(self)
+
+ def comment_period_open(self):
+ return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date
+
+ def get_thumbnail_url(self):
+ if settings.DEVELOPMENT == True:
+ return '%s%s' %(settings.IMAGES_URL, self.thumbnail.url[35:])
+ else:
+ return '%s%s' %(settings.IMAGES_URL, self.thumbnail.url[33:])
+
+ def save(self):
+ html,lede = markdown_processor(self.body_markdown)
+ self.body_html = html
+ self.lede = lede
+ self.dek == markdown.markdown(self.dek, safe_mode = False)
+ super(Entry, self).save()
+
+class BlogSitemap(Sitemap):
+ changefreq = "never"
+ priority = 1.0
+
+ def items(self):
+ return Entry.objects.filter(status=1)
+
+ def lastmod(self, obj):
+ return obj.pub_date
+
+class LatestFull(Feed):
+ title = "Luxagraf: Topographical Writings"
+ link = "/writing/"
+ description = "Latest postings to luxagraf.net"
+ description_template = 'feeds/blog_description.html'
+
+ def items(self):
+ return Entry.objects.filter(status__exact=1).order_by('-pub_date')[:10]
+
+
+from django.dispatch import dispatcher
+from django.db.models import signals
+
+signals.post_save.connect(update_recent, sender=Entry)
+
diff --git a/apps/projects/urls.py b/apps/projects/urls.py
new file mode 100644
index 0000000..ed2dbfb
--- /dev/null
+++ b/apps/projects/urls.py
@@ -0,0 +1,15 @@
+from django.conf.urls.defaults import *
+from django.views.generic.list_detail import object_list
+from django.views.generic.simple import redirect_to,direct_to_template
+
+#from blog.models import Entry
+
+
+
+urlpatterns = patterns('',
+
+ #(r'(?P<slug>[-\w]+)/(?P<page>\d+)/$', 'blog.views.entry_list_by_area'),
+ #(r'(?P<page>\d+)/$', 'blog.views.entry_list'),
+ #(r'(?P<slug>[-\w]+)/$', redirect_to, {'url': '/writing/%(slug)s/1/'}),
+ (r'^$', direct_to_template, {'template': 'projects/base.html'}),
+)