|
2 | 2 | import itertools |
3 | 3 | import typing |
4 | 4 |
|
| 5 | +from django.utils import timezone |
5 | 6 | from django.utils.translation import gettext as _ |
6 | 7 | from primitive_metadata import primitive_rdf as rdf |
7 | 8 |
|
@@ -38,31 +39,37 @@ def _dates(*path: str) -> Iterator[str]: |
38 | 39 | _xb = XmlBuilder('feed', {'xmlns': 'http://www.w3.org/2005/Atom'}) |
39 | 40 | _xb.leaf('title', text=_('shtrove search results')) |
40 | 41 | _xb.leaf('subtitle', text=_('feed of metadata records matching given filters')) |
41 | | - _xb.leaf('link', text=self.response_focus.single_iri()) |
| 42 | + _xb.leaf('link', {'href': self.response_focus.single_iri()}) |
42 | 43 | _xb.leaf('id', text=self.response_focus.single_iri()) |
| 44 | + _xb.leaf('updated', text=datetime_isoformat_z(timezone.now())) |
43 | 45 | for _card_iri, _osfmap_json in itertools.chain.from_iterable(card_pages): |
44 | 46 | with _xb.nest('entry'): |
45 | 47 | _iri = _osfmap_json.get('@id', _card_iri) |
46 | 48 | _xb.leaf('link', {'href': _iri}) |
47 | 49 | _xb.leaf('id', text=self._atom_id(_card_iri)) |
48 | 50 | for _title in _strs('title'): |
49 | 51 | _xb.leaf('title', text=_title) |
| 52 | + for _filename in _strs('fileName'): |
| 53 | + _xb.leaf('title', text=_filename) |
50 | 54 | for _desc in _strs('description'): |
51 | 55 | _xb.leaf('summary', text=_desc) |
52 | 56 | for _keyword in _strs('keyword'): |
53 | | - _xb.leaf('category', text=_keyword) |
| 57 | + _xb.leaf('category', {'term': _keyword}) |
54 | 58 | for _created in _dates('dateCreated'): |
55 | 59 | _xb.leaf('published', text=_created) |
56 | | - for _creator_obj in json_vals(_osfmap_json, 'creator'): |
| 60 | + for _modified in _dates('dateModified'): |
| 61 | + _xb.leaf('updated', text=_modified) |
| 62 | + _creator_objs = list(json_vals(_osfmap_json, ['creator'])) |
| 63 | + if not _creator_objs: |
| 64 | + _creator_objs = list(json_vals(_osfmap_json, ['isContainedBy', 'creator'])) |
| 65 | + for _creator_obj in _creator_objs: |
57 | 66 | assert isinstance(_creator_obj, dict) |
58 | 67 | with _xb.nest('author'): |
59 | 68 | for _name in json_strs(_creator_obj, ['name']): |
60 | 69 | _xb.leaf('name', text=_name) |
61 | 70 | _creator_iri = _creator_obj.get('@id') |
62 | 71 | if _creator_iri: |
63 | 72 | _xb.leaf('uri', text=_creator_iri) |
64 | | - for _sameas_iri in json_strs(_creator_obj, ['sameAs']): |
65 | | - _xb.leaf('uri', text=_sameas_iri) |
66 | 73 | return EntireRendering( |
67 | 74 | mediatype=self.MEDIATYPE, |
68 | 75 | entire_content=bytes(_xb), |
|
0 commit comments