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): 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' request_type = 'http'
if request.is_secure(): request_type = 'https' 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): def items(self):
return Pin.objects.order_by('-published')[:15] return Pin.objects.order_by('-published')[:15]
@@ -49,10 +50,12 @@ class LatestPins(Feed):


def item_description(self, item): def item_description(self, item):
tags = ', '.join(tag.name for tag in item.tags.all()) 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): 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): def item_enclosure_length(self, item):
return filter_generator_for('standard')(item.image).image.size return filter_generator_for('standard')(item.image).image.size
@@ -67,11 +70,13 @@ class LatestUserPins(Feed):


def get_object(self, request, user): 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' request_type = 'http'
if request.is_secure(): request_type = 'https' 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) return get_object_or_404(User, username=user)


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


def item_description(self, item): def item_description(self, item):
tags = ', '.join(tag.name for tag in item.tags.all()) 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): 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): def item_enclosure_length(self, item):
return filter_generator_for('standard')(item.image).image.size return filter_generator_for('standard')(item.image).image.size
@@ -113,11 +120,13 @@ class LatestTagPins(Feed):


def get_object(self, request, tag): 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' request_type = 'http'
if request.is_secure(): request_type = 'https' 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) return get_object_or_404(Tag, name=tag)


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


def item_description(self, item): def item_description(self, item):
tags = ', '.join(tag.name for tag in item.tags.all()) 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): 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): def item_enclosure_length(self, item):
return filter_generator_for('standard')(item.image).image.size 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 static from staticfiles %}
{% load compress %} {% load compress %}
<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"/> <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/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"/> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/file-uploader/3.1.1/fineuploader.css"/>
{% compress 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 %} {% endcompress %}
{% compress css inline %} {% compress css inline %}
{% block extra_css %}{% endblock %}
{% block extra_css %}{% endblock %}
{% endcompress %} {% endcompress %}
<!-- End CSS --> <!-- 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/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> <script src="//cdnjs.cloudflare.com/ajax/libs/file-uploader/3.1.1/jquery.fineuploader.min.js"></script>
{% compress js %} {% 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 %} {% endcompress %}
{% compress js inline %} {% compress js inline %}
{% block extra_js %}{% endblock %}
{% block extra_js %}{% endblock %}
{% endcompress %} {% endcompress %}
<!-- End JavaScript --> <!-- End JavaScript -->
</body> </body>


Loading…
Cancel
Save