Framework in place, most of the details worked out
- Legacy-Id: 10275
This commit is contained in:
parent
effd727a83
commit
ada7e48ed4
|
@ -1,12 +1,12 @@
|
|||
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||
|
||||
from django.contrib.syndication.views import Feed, FeedDoesNotExist
|
||||
from django.utils.feedgenerator import Atom1Feed
|
||||
from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
|
||||
from django.core.urlresolvers import reverse as urlreverse
|
||||
from django.template.defaultfilters import truncatewords, truncatewords_html, date as datefilter, linebreaks
|
||||
from django.utils.html import strip_tags
|
||||
|
||||
from ietf.doc.models import Document, State, LastCallDocEvent
|
||||
from ietf.doc.models import Document, State, LastCallDocEvent, DocEvent
|
||||
from ietf.doc.utils import augment_events_with_revision
|
||||
from ietf.doc.templatetags.ietf_filters import format_textarea
|
||||
|
||||
|
@ -75,3 +75,78 @@ class InLastCallFeed(Feed):
|
|||
def item_pubdate(self, item):
|
||||
return item.lc_event.time
|
||||
|
||||
class Rss201WithNamespacesFeed(Rss201rev2Feed):
|
||||
def root_attributes(self):
|
||||
attrs = super(Rss201WithNamespacesFeed, self).root_attributes()
|
||||
attrs['xmlns:dcterms'] = 'http://purl.org/dc/terms/'
|
||||
attrs['xmlns:media'] = 'http://search.yahoo.com/mrss/'
|
||||
attrs['xmlns:xsi'] = 'http://www.w3.org/2001/XMLSchema-instance'
|
||||
return attrs
|
||||
|
||||
def add_item_elements(self, handler, item):
|
||||
super(Rss201WithNamespacesFeed, self).add_item_elements(handler, item)
|
||||
|
||||
for element_name in ['abstract','accessRights', 'format', ]:
|
||||
dc_item_name = 'dcterms_%s' % element_name
|
||||
dc_element_name = 'dcterms:%s' % element_name
|
||||
if dc_item_name in item and item[dc_item_name] is not None:
|
||||
handler.addQuickElement(dc_element_name,item[dc_item_name])
|
||||
|
||||
if 'doi' in item and item['doi'] is not None:
|
||||
handler.addQuickElement('dcterms:identifier',item['doi'],{'xsi:type':'dcterms:doi'})
|
||||
|
||||
if 'media_content' in item and item['media_content'] is not None:
|
||||
handler.startElement('media:content',{'url':item['media_content']['url'],'type':'text/plain'})
|
||||
handler.addQuickElement('dcterms:isFormatOf',item['media_content']['link_url'])
|
||||
handler.endElement('media:content')
|
||||
|
||||
class RfcFeed(Feed):
|
||||
feed_type = Rss201WithNamespacesFeed
|
||||
title = "RFCs"
|
||||
author_name = "RFC Editor"
|
||||
link = "https://www.rfc-editor.org/rfc-index2.html"
|
||||
|
||||
def items(self):
|
||||
rfc_events = DocEvent.objects.filter(type='published_rfc').order_by('-time')
|
||||
results = [(e.doc, e.time) for e in rfc_events[:5]]
|
||||
for doc,time in results:
|
||||
doc.publication_time = time
|
||||
return [doc for doc,time in results]
|
||||
|
||||
def item_title(self, item):
|
||||
return item.canonical_name()
|
||||
|
||||
def item_description(self, item):
|
||||
return item.title
|
||||
|
||||
def item_link(self, item):
|
||||
return "https://rfc-editor.org/info/%s"%item.canonical_name()
|
||||
|
||||
def item_pubdate(self, item):
|
||||
return item.publication_time
|
||||
|
||||
def item_extra_kwargs(self, item):
|
||||
extra = super(RfcFeed, self).item_extra_kwargs(item)
|
||||
extra.update({'dcterms_abstract': item.abstract})
|
||||
extra.update({'dcterms_accessRights': 'gratis'})
|
||||
extra.update({'dcterms_format': 'text/html'})
|
||||
extra.update({'media_content': {'url': 'https://rfc-editor.org/rfc/%s.txt' % item.canonical_name(),
|
||||
'link_url': self.item_link(item)
|
||||
}
|
||||
})
|
||||
extra.update({'doi':'http://dx.doi.org/10.17487/%s' % item.canonical_name().upper()})
|
||||
|
||||
#TODO
|
||||
# R104 Publisher (Mandatory - but we need a string from them first)
|
||||
|
||||
#TODO MAYBE (Optional stuff)
|
||||
# R108 License
|
||||
# R115 Creator/Contributor (which would we use?)
|
||||
# F305 Checksum (do they use it?) (or should we put the our digital signature in here somewhere?)
|
||||
# F308 Holder of rights (copyright)
|
||||
|
||||
# Stuff we can't do yet given what's in the datatracker
|
||||
# R118 Keyword
|
||||
|
||||
return extra
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from django.conf.urls import patterns
|
||||
from django.views.generic import RedirectView
|
||||
|
||||
from ietf.doc.feeds import DocumentChangesFeed, InLastCallFeed
|
||||
from ietf.doc.feeds import DocumentChangesFeed, InLastCallFeed, RfcFeed
|
||||
from ietf.group.feeds import GroupChangesFeed
|
||||
from ietf.iesg.feeds import IESGAgendaFeed
|
||||
from ietf.ipr.feeds import LatestIprDisclosuresFeed
|
||||
|
@ -18,4 +18,5 @@ urlpatterns = patterns(
|
|||
(r'^ipr/$', LatestIprDisclosuresFeed()),
|
||||
(r'^liaison/(?P<kind>recent|from|to|subject)/(?:(?P<search>[^/]+)/)?$', LiaisonStatementsFeed()),
|
||||
(r'^wg-proceedings/$', LatestMeetingMaterialFeed()),
|
||||
(r'^rfc/$', RfcFeed())
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue