Browse Source

Update feeds to meet PEP requirements and minor adjustments to base.html

tags/v1.2.0
Isaac Bythewood 11 years ago
parent
commit
70a797c5af
2 changed files with 36 additions and 24 deletions
  1. +25
    -13
      pinry/core/feeds.py
  2. +11
    -11
      pinry/templates/base.html

+ 25
- 13
pinry/core/feeds.py View File

@@ -28,12 +28,13 @@ class LatestPins(Feed):

def get_object(self, request):
"""
Doing this as a fix for Django's not including the domain name in enclosure urls.
Doing this as a fix for Django's not including the domain name in
enclosure urls.
"""
request_type = 'http'
if request.is_secure(): request_type = 'https'
self.domain_name = ''.join([request_type, '://', get_current_site(request).domain])
return get_object_or_404(Pin)
self.domain_name = ''.join([request_type, '://',
get_current_site(request).domain])

def items(self):
return Pin.objects.order_by('-published')[:15]
@@ -49,10 +50,12 @@ class LatestPins(Feed):

def item_description(self, item):
tags = ', '.join(tag.name for tag in item.tags.all())
return ''.join(['Description: ', item.description or 'None', ' | Tags: ', tags or 'None'])
return ''.join(['Description: ', item.description or 'None',
' | Tags: ', tags or 'None'])

def item_enclosure_url(self, item):
return self.domain_name + unicode(filter_generator_for('standard')(item.image).image.url)
slug = unicode(filter_generator_for('standard')(item.image).image.url)
return self.domain_name + slug

def item_enclosure_length(self, item):
return filter_generator_for('standard')(item.image).image.size
@@ -67,11 +70,13 @@ class LatestUserPins(Feed):

def get_object(self, request, user):
"""
Doing this as a fix for Django's not including the domain name in enclosure urls.
Doing this as a fix for Django's not including the domain name in
enclosure urls.
"""
request_type = 'http'
if request.is_secure(): request_type = 'https'
self.domain_name = ''.join([request_type, '://', get_current_site(request).domain])
self.domain_name = ''.join([request_type, '://',
get_current_site(request).domain])
return get_object_or_404(User, username=user)

def title(self, obj):
@@ -94,10 +99,12 @@ class LatestUserPins(Feed):

def item_description(self, item):
tags = ', '.join(tag.name for tag in item.tags.all())
return ''.join(['Description: ', item.description or 'None', ' | Tags: ', tags or 'None'])
return ''.join(['Description: ', item.description or 'None',
' | Tags: ', tags or 'None'])

def item_enclosure_url(self, item):
return self.domain_name + unicode(filter_generator_for('standard')(item.image).image.url)
slug = unicode(filter_generator_for('standard')(item.image).image.url)
return self.domain_name + slug

def item_enclosure_length(self, item):
return filter_generator_for('standard')(item.image).image.size
@@ -113,11 +120,13 @@ class LatestTagPins(Feed):

def get_object(self, request, tag):
"""
Doing this as a fix for Django's not including the domain name in enclosure urls.
Doing this as a fix for Django's not including the domain name in
enclosure urls.
"""
request_type = 'http'
if request.is_secure(): request_type = 'https'
self.domain_name = ''.join([request_type, '://', get_current_site(request).domain])
self.domain_name = ''.join([request_type, '://',
get_current_site(request).domain])
return get_object_or_404(Tag, name=tag)

def title(self, obj):
@@ -140,10 +149,13 @@ class LatestTagPins(Feed):

def item_description(self, item):
tags = ', '.join(tag.name for tag in item.tags.all())
return ''.join(['Description: ', item.description or 'None', ' | Tags: ', tags or 'None'])
return ''.join(['Description: ', item.description or 'None',
' | Tags: ', tags or 'None'])

def item_enclosure_url(self, item):
return self.domain_name + unicode(filter_generator_for('standard')(item.image).image.url)
slug = unicode(filter_generator_for('standard')(item.image).image.url)
return self.domain_name + slug

def item_enclosure_length(self, item):
return filter_generator_for('standard')(item.image).image.size


+ 11
- 11
pinry/templates/base.html View File

@@ -1,6 +1,6 @@
<!DOCTYPE html>
{% load static from staticfiles %}
{% load compress %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
@@ -32,12 +32,12 @@
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.0/css/bootstrap.min.css"/>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/file-uploader/3.1.1/fineuploader.css"/>
{% compress css %}
<link rel="stylesheet" href="{% static "css/messages.css" %}"/>
<link rel="stylesheet" href="{% static "css/lightbox.css" %}"/>
<link rel="stylesheet" href="{% static "css/pinry.css" %}"/>
<link rel="stylesheet" href="{% static "css/messages.css" %}"/>
<link rel="stylesheet" href="{% static "css/lightbox.css" %}"/>
<link rel="stylesheet" href="{% static "css/pinry.css" %}"/>
{% endcompress %}
{% compress css inline %}
{% block extra_css %}{% endblock %}
{% block extra_css %}{% endblock %}
{% endcompress %}
<!-- End CSS -->

@@ -112,14 +112,14 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/file-uploader/3.1.1/jquery.fineuploader.min.js"></script>
{% compress js %}
<script src="{% static "js/helpers.js" %}"></script>
<script src="{% static "js/messages.js" %}"></script>
<script src="{% static "js/lightbox.js" %}"></script>
<script src="{% static "js/pinry.js" %}"></script>
<script src="{% static "js/pin-form.js" %}"></script>
<script src="{% static "js/helpers.js" %}"></script>
<script src="{% static "js/messages.js" %}"></script>
<script src="{% static "js/lightbox.js" %}"></script>
<script src="{% static "js/pinry.js" %}"></script>
<script src="{% static "js/pin-form.js" %}"></script>
{% endcompress %}
{% compress js inline %}
{% block extra_js %}{% endblock %}
{% block extra_js %}{% endblock %}
{% endcompress %}
<!-- End JavaScript -->
</body>


Loading…
Cancel
Save