$def with (user, mybooks, key=None, owners_page=False, public=False, counts=None, lists=None, component_times={}) $ username = user.key.split('/')[-1] $def year_span(year, use_local_year=False): $if use_local_year: $year $else: $year
$if owners_page: $ year = current_year() $ current_goal = get_reading_goals(year=year) $ hidden = 'hidden' if current_goal else ''
$# Hide "Set reading goal" call to action with `hidden` class if a goal has already been set:
$ year_markup = year_span(year) $:_('Set %(year_span)s reading goal', year_span=year_markup) $ reading_goal_form = render_template('check_ins/reading_goal_form', year=year) $:render_template('native_dialog', 'yearly-goal-modal', reading_goal_form, title=_('Yearly Reading Goal'))
$if current_goal: $:render_template('check_ins/reading_goal_progress', [current_goal])
$code: def compact_carousel(data): key, title, url = data books = mybooks[key].docs count = mybooks[key].total_results return render_template("books/custom_carousel", **{ "books": books, "title": "%s (%d)" % (title, count), "url": url, "key": key, "min_books": 1, "load_more": None, "compact_mode": True, "test": False }) if books else None $def empty_carousel(data): $ key, title, url = data

$_("No books are on this shelf")

$# Data for carousels $ readlog_url = "/people/%s/books/" % username $ loans = ["loans", _('My Loans'), "/account/loans"] $ currently_reading = ["currently-reading", _('Currently Reading'), readlog_url + "currently-reading"] $ want_to_read = ["want-to-read", _('Want to Read'), readlog_url + "want-to-read"] $ already_read = ["already-read", _('Already Read'), readlog_url + "already-read"] $# Render carousels $if owners_page: $:(compact_carousel(loans) or empty_carousel(loans)) $if owners_page or public: $:(compact_carousel(currently_reading) or empty_carousel(currently_reading)) $:(compact_carousel(want_to_read) or empty_carousel(want_to_read)) $:(compact_carousel(already_read) or empty_carousel(already_read)) $:render_template("lists/showcase", lists, username) $else:

$_("This reader has chosen to make their Reading Log private.")

$code: def mobile_carousel(data): key, title, url = data books = mybooks[key].docs count = mybooks[key].total_results return render_template("books/mobile_carousel", **{ "books": books, "title": "%s (%d)" % (title, count), "url": url, "key": key, "min_books": 1, "load_more": None, "compact_mode": True, "test": False }) if books else None $def empty_mobile_carousel(data): $ key, title, url = data $ component_times['Sidebar'] = time()
$if owners_page:

$_("My Stats")

$ component_times['Sidebar'] = time() - component_times['Sidebar']