|
11 | 11 | from infogami.utils.view import public, render_template
|
12 | 12 | from openlibrary.core import admin, cache, ia, lending
|
13 | 13 | from openlibrary.i18n import gettext as _
|
14 |
| -from openlibrary.plugins.upstream.utils import get_blog_feeds, get_coverstore_public_url |
| 14 | +from openlibrary.plugins.upstream.utils import get_blog_feeds |
15 | 15 | from openlibrary.plugins.worksearch import search, subjects
|
16 | 16 | from openlibrary.utils import dateutil
|
17 | 17 |
|
@@ -201,64 +201,6 @@ def generic_carousel(
|
201 | 201 | return storify(books) if books else books
|
202 | 202 |
|
203 | 203 |
|
204 |
| -def format_list_editions(key): |
205 |
| - """Formats the editions of a list suitable for display in carousel.""" |
206 |
| - if 'env' not in web.ctx: |
207 |
| - delegate.fakeload() |
208 |
| - |
209 |
| - seed_list = web.ctx.site.get(key) |
210 |
| - if not seed_list: |
211 |
| - return [] |
212 |
| - |
213 |
| - editions = {} |
214 |
| - for seed in seed_list.seeds: |
215 |
| - if not isinstance(seed, str): |
216 |
| - if seed.type.key == "/type/edition": |
217 |
| - editions[seed.key] = seed |
218 |
| - else: |
219 |
| - try: |
220 |
| - e = pick_best_edition(seed) |
221 |
| - except StopIteration: |
222 |
| - continue |
223 |
| - editions[e.key] = e |
224 |
| - return [format_book_data(e) for e in editions.values()] |
225 |
| - |
226 |
| - |
227 |
| -# cache the results of format_list_editions in memcache for 5 minutes |
228 |
| -format_list_editions = cache.memcache_memoize( |
229 |
| - format_list_editions, "home.format_list_editions", timeout=5 * 60 |
230 |
| -) |
231 |
| - |
232 |
| - |
233 |
| -def pick_best_edition(work): |
234 |
| - return next(e for e in work.editions if e.ocaid) |
235 |
| - |
236 |
| - |
237 |
| -def format_work_data(work): |
238 |
| - d = dict(work) |
239 |
| - |
240 |
| - key = work.get('key', '') |
241 |
| - # New solr stores the key as /works/OLxxxW |
242 |
| - if not key.startswith("/works/"): |
243 |
| - key = "/works/" + key |
244 |
| - |
245 |
| - d['url'] = key |
246 |
| - d['title'] = work.get('title', '') |
247 |
| - |
248 |
| - if 'author_key' in work and 'author_name' in work: |
249 |
| - d['authors'] = [ |
250 |
| - {"key": key, "name": name} |
251 |
| - for key, name in zip(work['author_key'], work['author_name']) |
252 |
| - ] |
253 |
| - |
254 |
| - if 'cover_edition_key' in work: |
255 |
| - coverstore_url = get_coverstore_public_url() |
256 |
| - d['cover_url'] = f"{coverstore_url}/b/olid/{work['cover_edition_key']}-M.jpg" |
257 |
| - |
258 |
| - d['read_url'] = "//archive.org/stream/" + work['ia'][0] |
259 |
| - return d |
260 |
| - |
261 |
| - |
262 | 204 | def format_book_data(book, fetch_availability=True):
|
263 | 205 | d = web.storage()
|
264 | 206 | d.key = book.get('key')
|
|
0 commit comments