Skip to content

Commit ce1a980

Browse files
committed
Revert "Merge branch 'release/3.15'"
This reverts commit 0008037, reversing changes made to e189756.
1 parent 0008037 commit ce1a980

File tree

3 files changed

+2
-197
lines changed

3 files changed

+2
-197
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,10 @@ CHANGELOG
66
3.15
77
----
88

9-
Zotero Integration Enhancement:
9+
Zotero Integration Enhancement:
1010
- Improve Zotero integration by changing the old method of MARC and unAPI to COinS metadata.
1111
- This allows Zotero to automatically detect and import citation data from the PPA archive with the correct item type, PPA URL, page range, etc.
1212

13-
- As a researcher, I want to see the source of the works in my results, so that I can see where the texts are coming from.
14-
- Revise footer to make menu more flexible (and support moving Technical content page to "About" menu so it is easier to find)
15-
16-
Editorial improvements:
17-
- As a content editor, I want to add tags to editorial essays so I can categorize and group essays for discovery.
18-
- As a content editor, I want a way to generating PDFs from editorial essays without developer assistance, so that I can deposit versions of the essays for DOIs.
19-
- As a user, I want to discover and navigate editorial essays by tag so I can find the content most relevant to my interests.
20-
- Revise print styles for images in editorial essays
21-
- Add configuration for DocRaptor API key in Wagtail settings
22-
23-
Maintenance updates and bug fixes:
24-
- Upgraded to Python 3.12, Django 5.2, Wagtail 7.0
25-
- Replace deprecated calls in JS/TS code
26-
- bugfix: disallow requesting nonexistent result pages in archive search pagination
27-
- bugfix: Fix redirect logic for DigitizedWorkDetailView
28-
- bugfix: Help text "Displaying x digitized works or clusters of works" reverts
29-
to "Displaying x digitized works" after search
30-
- bugfix: Browser in mobile view hides second hit for keyword search results with 2 hits
31-
- bugfix: Decrease responsiveness of title and author search fields only
32-
- bugfix: handle 500 error from Gale API when indexing pages
33-
34-
Developer Documentation:
35-
- Document how to get PPA full-text content for local development
36-
37-
3813
3.14.1
3914
----
4015

DEPLOYNOTES.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Deploy and Upgrade notes
77
----
88
* The footer has been updated such that the Technical page must now be manually set to appear in menus in Wagtail.
99
* Need to run `./manage.py index -i work` to update the index for the new COinS metadata for Zotero citation.
10-
* DocRaptor API key must be configured in Wagtail settings in order to generate PDFs of Editorial essays.
1110

1211
3.14
1312
----
Lines changed: 1 addition & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import re
22

3-
from django import template
43
from django.template.defaultfilters import stringfilter
4+
from django.template.defaulttags import register
55
from django.utils.html import conditional_escape
66
from django.utils.safestring import mark_safe
7-
from urllib.parse import urlencode
8-
9-
register = template.Library()
107

118

129
@register.filter
@@ -116,169 +113,3 @@ def esc(x):
116113
]
117114
)
118115
)
119-
120-
121-
def _get_item_value(obj, key, default=None):
122-
"""Get value from Solr object or dictionary.
123-
For Solr objects, tries clean field name first, then falls back to
124-
raw Solr field name with _s suffix if aliasing isn't working.
125-
"""
126-
if isinstance(obj, dict):
127-
return obj.get(key, default)
128-
else:
129-
# Try clean field name first (from aliasing)
130-
value = getattr(obj, key, None)
131-
if value is not None:
132-
return value
133-
134-
# Fall back to raw Solr field name with _s suffix
135-
raw_field_name = f"{key}_s"
136-
return getattr(obj, raw_field_name, default)
137-
138-
139-
def _generate_absolute_url(context, item):
140-
"""Generate absolute URL for the item from Solr result."""
141-
from django.urls import reverse
142-
143-
source_id = _get_item_value(item, "source_id")
144-
first_page = _get_item_value(item, "first_page")
145-
146-
if first_page:
147-
detail_url = reverse(
148-
"archive:detail",
149-
kwargs={"source_id": source_id, "start_page": first_page},
150-
)
151-
else:
152-
detail_url = reverse("archive:detail", kwargs={"source_id": source_id})
153-
return context["request"].build_absolute_uri(detail_url)
154-
155-
156-
def _add_common_fields(item):
157-
"""Return common metadata fields from Solr object."""
158-
return {
159-
"title": _get_item_value(item, "title"),
160-
"au": _get_item_value(item, "author"),
161-
"date": _get_item_value(item, "pub_date"),
162-
"pub": _get_item_value(item, "publisher"),
163-
"pub_place": _get_item_value(item, "pub_place"),
164-
}
165-
166-
167-
def _add_full_work_fields(item, existing_data):
168-
"""Return fields specific to full works."""
169-
return {
170-
"rft_val_fmt": "info:ofi/fmt:kev:mtx:book",
171-
"genre": "book",
172-
"title": existing_data.get("title"),
173-
"place": _get_item_value(item, "pub_place"),
174-
}
175-
176-
177-
def _add_excerpt_fields(item, existing_data):
178-
"""Return fields specific to excerpts."""
179-
fields = {
180-
"rft_val_fmt": "info:ofi/fmt:kev:mtx:book",
181-
"genre": "bookitem",
182-
"atitle": existing_data.get("title"),
183-
"btitle": _get_item_value(item, "book_journal"),
184-
"place": _get_item_value(item, "pub_place"),
185-
}
186-
187-
# Add page information for excerpts if available
188-
first_page = _get_item_value(item, "first_page")
189-
if first_page:
190-
last_page = _get_item_value(item, "last_page")
191-
fields.update(
192-
{
193-
"spage": first_page,
194-
"epage": last_page or first_page,
195-
"pages": f"{first_page}-{last_page}"
196-
if last_page and last_page != first_page
197-
else first_page,
198-
}
199-
)
200-
201-
return fields
202-
203-
204-
def _add_article_fields(item, existing_data):
205-
"""Return fields specific to articles."""
206-
fields = {
207-
"rft_val_fmt": "info:ofi/fmt:kev:mtx:journal",
208-
"genre": "article",
209-
"atitle": existing_data.get("title"),
210-
"jtitle": _get_item_value(item, "book_journal"),
211-
"volume": _get_item_value(item, "enumcron"),
212-
}
213-
214-
# Add page information for articles if available
215-
first_page = _get_item_value(item, "first_page")
216-
if first_page:
217-
last_page = _get_item_value(item, "last_page")
218-
fields.update(
219-
{
220-
"spage": first_page,
221-
"epage": last_page or first_page,
222-
"pages": f"{first_page}-{last_page}"
223-
if last_page and last_page != first_page
224-
else first_page,
225-
}
226-
)
227-
228-
return fields
229-
230-
231-
def _add_work_type_specific_fields(item, existing_data, work_type_str):
232-
"""Return fields based on work type."""
233-
if work_type_str == "full-work":
234-
return _add_full_work_fields(item, existing_data)
235-
elif work_type_str == "excerpt":
236-
return _add_excerpt_fields(item, existing_data)
237-
elif work_type_str == "article":
238-
return _add_article_fields(item, existing_data)
239-
return {}
240-
241-
242-
@register.simple_tag(takes_context=True)
243-
def coins_data(context, item):
244-
"""Generate COinS metadata dictionary for Zotero from Solr results."""
245-
work_type_str = _get_item_value(item, "work_type", "full-work")
246-
absolute_url = _generate_absolute_url(context, item)
247-
248-
data = {
249-
"ctx_ver": "Z39.88-2004",
250-
"rft_id": absolute_url,
251-
}
252-
253-
# Add common fields first
254-
common_fields = _add_common_fields(item)
255-
data.update(common_fields)
256-
257-
# Add work-type-specific fields
258-
work_type_fields = _add_work_type_specific_fields(item, data, work_type_str)
259-
data.update(work_type_fields)
260-
261-
# Add rft. prefix to fields (except those already prefixed)
262-
coins_fields = {
263-
f"rft.{k}" if not k.startswith(("rft", "ctx_ver")) else k: v
264-
for k, v in data.items()
265-
if v is not None # Skip None values
266-
}
267-
268-
return coins_fields
269-
270-
271-
@register.filter
272-
def coins_encode(coins_data):
273-
"""Convert COinS metadata dictionary to encoded HTML span element."""
274-
if not coins_data:
275-
return ""
276-
277-
title_parts = []
278-
for key, value in coins_data.items():
279-
if value:
280-
encoded_value = urlencode({"": str(value)})[1:]
281-
title_parts.append(f"{key}={encoded_value}")
282-
283-
title_attr = "&".join(str(part) for part in title_parts)
284-
return mark_safe(f'<span class="Z3988" title="{title_attr}"></span>')

0 commit comments

Comments
 (0)