Skip to content

Commit 88c95d4

Browse files
SFR-2478: Make webpub pdf profile a constant (#516)
1 parent 620adc1 commit 88c95d4

17 files changed

+15
-43
lines changed

config/example.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ MUSE_MARC_URL: xxx
6464
# DOAB OAI-PMH endpoint
6565
DOAB_OAI_URL: xxx
6666

67-
# Webpub PDF Profile
68-
WEBPUB_PDF_PROFILE: http://librarysimplified.org/terms/profiles/pdf
69-
7067
# Allowed sources of CORS requests to proxy endpoint
7168
API_PROXY_CORS_ALLOWED: (?:Source1:Source2)
7269

config/production.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ DOAB_OAI_URL: https://directory.doabooks.org/oai/request?
8585
# Default Cover Image for OPDS2 Feed
8686
DEFAULT_COVER_URL: https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png
8787

88-
# Webpub PDF Profile
89-
WEBPUB_PDF_PROFILE: http://librarysimplified.org/terms/profiles/pdf
90-
9188
# Allowed sources of CORS requests to proxy endpoint
9289
API_PROXY_CORS_ALLOWED: http[s]?://.*nypl.org
9390

config/qa.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ DOAB_OAI_URL: https://directory.doabooks.org/oai/request?
8585
# Default Cover Image for OPDS2 Feed
8686
DEFAULT_COVER_URL: https://drb-files-qa.s3.amazonaws.com/covers/default/defaultCover.png
8787

88-
# Webpub PDF Profile
89-
WEBPUB_PDF_PROFILE: http://librarysimplified.org/terms/profiles/pdf
90-
9188
# Allowed sources of CORS requests to proxy endpoint
9289
API_PROXY_CORS_ALLOWED: (?:http[s]?:\/\/.*nypl.org|https:\/\/.*(?:nypl|sfr).*vercel.app|http[s]?:\/\/.*tugboat.qa)
9390

config/sample-compose.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ DRB_API_PORT: '5050'
7474
# Bardo CCE API URL
7575
BARDO_CCE_API: http://sfr-bardo-copyright-development.us-east-1.elasticbeanstalk.com/search
7676

77-
# Webpub PDF Profile
78-
WEBPUB_PDF_PROFILE: http://librarysimplified.org/terms/profiles/pdf
79-
8077
# Allowed sources of CORS requests to proxy endpoint
8178
API_PROXY_CORS_ALLOWED: '*'
8279

managers/muse.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ def addReadableLinks(self):
100100

101101
def constructWebpubManifest(self):
102102
pdfManifest = WebpubManifest(self.link, self.mediaType)
103-
pdfManifest.addMetadata(
104-
self.record.record, conformsTo=os.environ['WEBPUB_PDF_PROFILE']
105-
)
103+
pdfManifest.addMetadata(self.record.record)
106104

107105
chapterTable = self.museSoup.find(id='available_items_list_wrap')
108106

managers/parsers/abstractParser.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ def createLinks(self):
3737
def generateManifest(self, sourceURI, manifestURI):
3838
manifest = WebpubManifest(sourceURI, 'application/pdf')
3939

40-
manifest.addMetadata(
41-
self.record, conformsTo=os.environ['WEBPUB_PDF_PROFILE']
42-
)
40+
manifest.addMetadata(self.record)
4341

4442
manifest.addChapter(sourceURI, self.record.title)
4543

managers/webpubManifest.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55

66
class WebpubManifest:
7+
# TODO: change - the library simplified PDF profile no longer exists
8+
WEBPUB_PDF_PROFILE = 'http://librarysimplified.org/terms/profiles/pdf'
9+
710
def __init__(self, source, sourceType):
811
self.metadata: dict = {'@type': 'https://schema.org/Book'}
912
self.links: list = [{'href': source, 'type': sourceType, 'rel': 'alternate'}]
@@ -14,7 +17,7 @@ def __init__(self, source, sourceType):
1417
self.openSection = None
1518

1619
# TODO validate kwargs against schema.org/Book
17-
def addMetadata(self, dcdwRecord: object, conformsTo=None) -> None:
20+
def addMetadata(self, dcdwRecord: object, conformsTo: str=WEBPUB_PDF_PROFILE) -> None:
1821
self.metadata['title'] = dcdwRecord.title
1922

2023
if len(dcdwRecord.authors) > 0:

processes/ingest/chicago_isac.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ def change_has_part_url_array_to_string(record):
8787
def generate_manifest(record, source_url, manifest_url):
8888
manifest = WebpubManifest(source_url, 'application/pdf')
8989

90-
manifest.addMetadata(
91-
record,
92-
conformsTo=os.environ['WEBPUB_PDF_PROFILE']
93-
)
90+
manifest.addMetadata(record)
9491

9592
manifest.addChapter(source_url, record.title)
9693

processes/ingest/loc.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,7 @@ def addEPUBManifest(self, record, itemNo, source, flagStr, mediaType, location):
266266
def generateManifest(record, sourceURI, manifestURI):
267267
manifest = WebpubManifest(sourceURI, 'application/pdf')
268268

269-
manifest.addMetadata(
270-
record,
271-
conformsTo=os.environ['WEBPUB_PDF_PROFILE']
272-
)
269+
manifest.addMetadata(record)
273270

274271
manifest.addChapter(sourceURI, record.title)
275272

processes/ingest/met.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,7 @@ def storePDFManifest(self, record):
191191
def generateManifest(record, sourceURI, manifestURI):
192192
manifest = WebpubManifest(sourceURI, 'application/pdf')
193193

194-
manifest.addMetadata(
195-
record,
196-
conformsTo=os.environ['WEBPUB_PDF_PROFILE']
197-
)
194+
manifest.addMetadata(record)
198195

199196
manifest.addChapter(sourceURI, record.title)
200197

services/sources/publisher_backlist_service.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,7 @@ def store_pdf_manifest(self, record: Record, requires_login: bool):
281281
def generate_manifest(record, source_url, manifest_url):
282282
manifest = WebpubManifest(source_url, 'application/pdf')
283283

284-
manifest.addMetadata(
285-
record,
286-
conformsTo=os.environ['WEBPUB_PDF_PROFILE']
287-
)
284+
manifest.addMetadata(record)
288285

289286
manifest.addChapter(source_url, record.title)
290287

tests/helper.py

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class TestHelpers:
4646
'MUSE_MARC_URL': 'test_muse_url',
4747
'MUSE_CSV_URL': 'test_muse_csv',
4848
'DOAB_OAI_URL': 'test_doab_url',
49-
'WEBPUB_PDF_PROFILE': 'test_profile_uri',
5049
'ENVIRONMENT': 'test'
5150
}
5251

tests/unit/processes/ingest/test_chicago_isac_process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,5 @@ def test_generate_manifest(self, mocker):
9292
assert test_manifest == 'test_json'
9393
assert mock_manifest.links[0] == {'rel': 'self', 'href': 'manifest_url', 'type': 'application/webpub+json'}
9494

95-
mock_manifest.addMetadata.assert_called_once_with(mock_record, conformsTo='test_profile_uri')
95+
mock_manifest.addMetadata.assert_called_once_with(mock_record)
9696
mock_manifest.addChapter.assert_called_once_with('source_url', 'test_title')

tests/unit/processes/ingest/test_loc_process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,5 @@ def test_generateManifest(self, mocker):
140140
assert testManifest == 'testJSON'
141141
assert mockManifest.links[0] == {'rel': 'self', 'href': 'manifestURI', 'type': 'application/webpub+json'}
142142

143-
mockManifest.addMetadata.assert_called_once_with(mockRecord, conformsTo='test_profile_uri')
143+
mockManifest.addMetadata.assert_called_once_with(mockRecord)
144144
mockManifest.addChapter.assert_called_once_with('sourceURI', 'testTitle')

tests/unit/processes/ingest/test_met_process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def test_generateManifest(self, mocker):
206206
assert testManifest == 'testJSON'
207207
assert mockManifest.links[0] == {'rel': 'self', 'href': 'manifestURI', 'type': 'application/webpub+json'}
208208

209-
mockManifest.addMetadata.assert_called_once_with(mockRecord, conformsTo='test_profile_uri')
209+
mockManifest.addMetadata.assert_called_once_with(mockRecord)
210210
mockManifest.addChapter.assert_called_once_with('sourceURI', 'Test')
211211

212212
def test_queryMetAPI_success_non_head(self, mocker):

tests/unit/test_muse_manager.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,7 @@ def test_constructWebpubManifest(self, testManager, testMUSEPage, mocker):
167167
assert testManager.pdfWebpubManifest == mockManifest
168168

169169
mockManifestConstructor.assert_called_once_with('testLink', 'testType')
170-
mockManifest.addMetadata.assert_called_once_with(
171-
'testRecord', conformsTo='test_profile_uri'
172-
)
170+
mockManifest.addMetadata.assert_called_once_with('testRecord')
173171

174172
mockManifest.addSection.assert_has_calls([
175173
mocker.call('Part One. Reading Reading Historically', ''),

tests/unit/test_parser_abstract.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_generateManifest(self, testParser, mocker):
5858
assert testManifest == 'jsonManifest'
5959
assert mockManifest.links == [{'rel': 'self', 'href': 'manifestURI', 'type': 'application/webpub+json'}]
6060
mockManifestManager.assert_called_once_with('sourceURI', 'application/pdf')
61-
mockManifest.addMetadata.assert_called_once_with(testParser.record, conformsTo='test_profile_uri')
61+
mockManifest.addMetadata.assert_called_once_with(testParser.record)
6262
mockManifest.addChapter.assert_called_once_with('sourceURI', 'testRecord')
6363
mockManifest.toJson.assert_called_once()
6464

0 commit comments

Comments
 (0)