Explorar el Código

Remove unused RSS feed system, we aren't going to update it anymore

1.x
Isaac Bythewood hace 7 años
padre
commit
d0db375d1f
Se han modificado 3 ficheros con 0 adiciones y 177 borrados
  1. +0
    -164
      pinry/core/feeds.py
  2. +0
    -5
      pinry/core/urls.py
  3. +0
    -8
      pinry/templates/base.html

+ 0
- 164
pinry/core/feeds.py Ver fichero

@@ -1,164 +0,0 @@
from __future__ import unicode_literals

from django.contrib.syndication.views import Feed
from django.contrib.sites.models import get_current_site
from django.shortcuts import get_object_or_404
from django.contrib.auth.models import User

from django_images.models import Thumbnail
from taggit.models import Tag

from .models import Pin


def filter_generator_for(size):
def wrapped_func(obj):
return Thumbnail.objects.get_or_create_at_size(obj.pk, size)
return wrapped_func


class LatestPins(Feed):
title = 'Latest Pins'
link = '/'
description = 'The latest pins from around the internet.'

domain_name = None

item_enclosure_mime_type = 'image/jpeg'

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

def items(self):
return Pin.objects.order_by('-published')[:15]

def item_pubdate(self, item):
return item.published

def item_link(self, item):
return item.url

def item_title(self, item):
return item.url

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'])

def item_enclosure_url(self, item):
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


class LatestUserPins(Feed):
description = 'The latest pins from around the internet.'

domain_name = None

item_enclosure_mime_type = 'image/jpeg'

def get_object(self, request, user):
"""
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(User, username=user)

def title(self, obj):
return 'Latest Pins from ' + obj.username

def link(self, obj):
return '/pins/user/' + obj.username + '/'

def items(self, obj):
return Pin.objects.filter(submitter=obj).order_by('-published')[:15]

def item_pubdate(self, item):
return item.published

def item_link(self, item):
return item.url

def item_title(self, item):
return item.url

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'])

def item_enclosure_url(self, item):
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


class LatestTagPins(Feed):
link = '/'
description = 'The latest pins from around the internet.'

domain_name = None

item_enclosure_mime_type = 'image/jpeg'

def get_object(self, request, tag):
"""
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(Tag, name=tag)

def title(self, obj):
return 'Latest Pins in ' + obj.name

def link(self, obj):
return '/pins/tag/' + obj.name + '/'

def items(self, obj):
return Pin.objects.filter(tags=obj).order_by('-published')[:15]

def item_pubdate(self, item):
return item.published

def item_link(self, item):
return item.url

def item_title(self, item):
return item.url

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'])

def item_enclosure_url(self, item):
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


+ 0
- 5
pinry/core/urls.py Ver fichero

@@ -4,7 +4,6 @@ from django.views.generic import TemplateView
from tastypie.api import Api

from .api import ImageResource, ThumbnailResource, PinResource, UserResource
from .feeds import LatestPins, LatestUserPins, LatestTagPins
from .views import CreateImage


@@ -18,10 +17,6 @@ v1_api.register(UserResource())
urlpatterns = patterns('',
url(r'^api/', include(v1_api.urls, namespace='api')),

url(r'feeds/latest-pins/tag/(?P<tag>(\w|-)+)/', LatestTagPins()),
url(r'feeds/latest-pins/user/(?P<user>(\w|-)+)/', LatestUserPins()),
url(r'feeds/latest-pins/', LatestPins()),

url(r'^pins/pin-form/$', TemplateView.as_view(template_name='core/pin_form.html'),
name='pin-form'),
url(r'^pins/create-image/$', CreateImage.as_view(), name='create-image'),


+ 0
- 8
pinry/templates/base.html Ver fichero

@@ -5,14 +5,6 @@
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
{% if request.resolver_match.kwargs.user %}
<link rel="alternate" type="application/rss+xml" href="/feeds/latest-pins/user/{{ request.resolver_match.kwargs.user }}/">
{% elif request.resolver_match.kwargs.tag %}
<link rel="alternate" type="application/rss+xml" href="/feeds/latest-pins/tag/{{ request.resolver_match.kwargs.tag }}/">
{% else %}
<link rel="alternate" type="application/rss+xml" href="/feeds/latest-pins/">
{% endif %}

<title>{% block title %}Pinry{% endblock %}</title>

<!-- CSS -->


Cargando…
Cancelar
Guardar