From 1b8accd85ef8707422246eb5950d5067df1ae1d5 Mon Sep 17 00:00:00 2001 From: Tanishq Sangwan Date: Mon, 1 Jun 2026 17:00:43 +0530 Subject: [PATCH 1/3] Comment out broken unique visitors stats chart (Issue #12823) --- openlibrary/core/admin.py | 33 +- openlibrary/i18n/messages.pot | 497 ++------------------------ openlibrary/templates/home/stats.html | 14 +- 3 files changed, 61 insertions(+), 483 deletions(-) diff --git a/openlibrary/core/admin.py b/openlibrary/core/admin.py index 86369d8012e..cdc2e70b946 100644 --- a/openlibrary/core/admin.py +++ b/openlibrary/core/admin.py @@ -99,27 +99,28 @@ def get_counts(self, ndays=28, times=False): @cache.memoize(engine="memcache", key="admin._get_visitor_counts_from_graphite", expires=5 * 60) -def _get_visitor_counts_from_graphite(self, ndays: int = 28) -> list[list[int]]: +def _get_visitor_counts_from_graphite(ndays: int = 28) -> list[list[int]]: """ Read the unique visitors (IP addresses) per day for the last ndays from graphite. :param ndays: number of days to read :return: list containing [count, timestamp] for ndays """ - try: - response = requests.get( - "http://graphite.us.archive.org/render/", - params={ - "target": "summarize(stats.uniqueips.openlibrary, '1d')", - "from": f"-{ndays}days", - "tz": "UTC", - "format": "json", - }, - ) - response.raise_for_status() - visitors = response.json()[0]["datapoints"] - except requests.exceptions.RequestException: - visitors = [] - return visitors + # try: + # response = requests.get( + # "http://graphite.us.archive.org/render/", + # params={ + # "target": "summarize(stats.uniqueips.openlibrary, '1d')", + # "from": f"-{ndays}days", + # "tz": "UTC", + # "format": "json", + # }, + # ) + # response.raise_for_status() + # visitors = response.json()[0]["datapoints"] + # except requests.exceptions.RequestException: + # visitors = [] + # return visitors + return [] class VisitorStats(Stats): diff --git a/openlibrary/i18n/messages.pot b/openlibrary/i18n/messages.pot index c0e92bfa750..99ffbb8d407 100644 --- a/openlibrary/i18n/messages.pot +++ b/openlibrary/i18n/messages.pot @@ -461,12 +461,12 @@ msgstr "" msgid "Fiction" msgstr "" -#: design.html openlibrary/plugins/openlibrary/home.py +#: design.html msgid "Science" msgstr "" #: databarDiff.html databarEdit.html databarTemplate.html databarView.html -#: design.html lib/history.html openlibrary/plugins/openlibrary/home.py +#: design.html lib/history.html msgid "History" msgstr "" @@ -900,7 +900,7 @@ msgid "" "email and password to access your Open Library account." msgstr "" -#: login.html openlibrary/plugins/upstream/forms.py +#: login.html msgid "Email" msgstr "" @@ -909,7 +909,6 @@ msgid "Forgot your Internet Archive email?" msgstr "" #: account/email/forgot-ia.html login.html -#: openlibrary/plugins/upstream/forms.py msgid "Password" msgstr "" @@ -1120,8 +1119,8 @@ msgid "Title" msgstr "" #: books/add.html books/edit.html books/edit/edition.html lib/nav_head.html -#: openlibrary/plugins/worksearch/code.py search/advancedsearch.html -#: search/work_search_selected_facets.html status.html +#: search/advancedsearch.html search/work_search_selected_facets.html +#: status.html msgid "Author" msgstr "" @@ -1272,7 +1271,7 @@ msgstr "" msgid "All Time" msgstr "" -#: home/index.html openlibrary/plugins/openlibrary/api.py trending.html +#: home/index.html trending.html msgid "Trending Books" msgstr "" @@ -1516,11 +1515,11 @@ msgid "" "information form." msgstr "" -#: account/create.html openlibrary/plugins/upstream/forms.py +#: account/create.html msgid "Must be a valid email address" msgstr "" -#: account/create.html openlibrary/plugins/upstream/forms.py +#: account/create.html msgid "Must be between 3 and 20 characters" msgstr "" @@ -1846,7 +1845,7 @@ msgstr "" #. (bookshelf ID 3). Used as a button label and shelf name. #: account/mybooks.html account/readinglog_shelf_name.html account/sidebar.html #: my_books/dropdown_content.html my_books/primary_action.html -#: openlibrary/plugins/upstream/mybooks.py search/sort_options.html +#: search/sort_options.html msgid "Already Read" msgstr "" @@ -1872,7 +1871,7 @@ msgid "My Reading Stats" msgstr "" #: account/mybooks.html account/sidebar.html -#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/account.py +#: books/mybooks_breadcrumb_select.html msgid "Loan History" msgstr "" @@ -1988,7 +1987,7 @@ msgid "Save" msgstr "" #: EditionNavBar.html account/observations.html -#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py +#: books/mybooks_breadcrumb_select.html msgid "Reviews" msgstr "" @@ -2238,7 +2237,6 @@ msgid "Click on a bar to see matching works" msgstr "" #: account/sidebar.html books/mybooks_breadcrumb_select.html -#: openlibrary/plugins/upstream/mybooks.py msgid "My Feed" msgstr "" @@ -2677,7 +2675,7 @@ msgstr "" msgid "Failed" msgstr "" -#: admin/imports_by_date.html openlibrary/core/edits.py +#: admin/imports_by_date.html msgid "Pending" msgstr "" @@ -2807,7 +2805,7 @@ msgstr "" msgid "Star Rating Patrons" msgstr "" -#: admin/index.html home/stats.html +#: admin/index.html msgid "Unique Visitors" msgstr "" @@ -2889,8 +2887,7 @@ msgid "Admin Center" msgstr "" #: RelatedSubjects.html SubjectTags.html admin/menu.html -#: admin/people/index.html admin/people/view.html -#: openlibrary/plugins/worksearch/code.py type/author/view.html +#: admin/people/index.html admin/people/view.html type/author/view.html #: type/list/view_body.html msgid "People" msgstr "" @@ -3396,7 +3393,7 @@ msgid "Anonymize Account" msgstr "" #: admin/people/view.html books/mybooks_breadcrumb_select.html -#: openlibrary/plugins/upstream/account.py type/user/view.html +#: type/user/view.html msgid "Loans" msgstr "" @@ -4146,51 +4143,39 @@ msgid "in %(languagelist)s" msgstr "" #: SearchNavigation.html books/mybooks_breadcrumb_select.html lib/nav_foot.html -#: openlibrary/plugins/upstream/mybooks.py msgid "Books" msgstr "" -#. Page title for the "Want to Read" shelf page. -#. Example: "Want to Read (17)". %(count)d is the number of books on this -#. shelf. -#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py +#: books/mybooks_breadcrumb_select.html #, python-format msgid "Want to Read (%(count)d)" msgstr "" -#. Page title for the "Currently Reading" shelf page. -#. Example: "Currently Reading (42)". %(count)d is the number of books on this -#. shelf. -#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py +#: books/mybooks_breadcrumb_select.html #, python-format msgid "Currently Reading (%(count)d)" msgstr "" -#. Page title for the "Already Read" shelf page. -#. Example: "Already Read (203)". %(count)d is the number of books on this -#. shelf. -#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py +#: books/mybooks_breadcrumb_select.html #, python-format msgid "Already Read (%(count)d)" msgstr "" -#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py +#: books/mybooks_breadcrumb_select.html #, python-format msgid "Stopped Reading (%(count)d)" msgstr "" #: books/mybooks_breadcrumb_select.html -#: openlibrary/plugins/openlibrary/lists.py #, python-format msgid "Lists (%(count)d)" msgstr "" -#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py -#: type/edition/modal_links.html +#: books/mybooks_breadcrumb_select.html type/edition/modal_links.html msgid "Notes" msgstr "" -#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/account.py +#: books/mybooks_breadcrumb_select.html msgid "Imports and Exports" msgstr "" @@ -5085,7 +5070,7 @@ msgstr[1] "" msgid "Welcome to Open Library" msgstr "" -#: home/index.html openlibrary/plugins/openlibrary/api.py +#: home/index.html msgid "Classic Books" msgstr "" @@ -5093,21 +5078,19 @@ msgstr "" msgid "Recently Returned" msgstr "" -#: home/index.html openlibrary/plugins/openlibrary/api.py -#: openlibrary/plugins/openlibrary/home.py +#: home/index.html msgid "Romance" msgstr "" -#: home/index.html openlibrary/plugins/openlibrary/api.py +#: home/index.html msgid "Kids" msgstr "" -#: home/index.html openlibrary/plugins/openlibrary/api.py +#: home/index.html msgid "Thrillers" msgstr "" -#: home/index.html openlibrary/plugins/openlibrary/api.py -#: openlibrary/plugins/openlibrary/home.py +#: home/index.html msgid "Textbooks" msgstr "" @@ -5146,14 +5129,6 @@ msgid "" "href=\"/recentchanges\">recent changes" msgstr "" -#: home/stats.html -msgid "See all visitors to OpenLibrary.org" -msgstr "" - -#: home/stats.html -msgid "Area graph of recent unique visitors" -msgstr "" - #: home/stats.html msgid "How many new Open Library members have we welcomed?" msgstr "" @@ -5428,7 +5403,7 @@ msgstr "" msgid "Just a sentence or two is good." msgstr "" -#: lib/nav_foot.html openlibrary/plugins/openlibrary/api.py site/head.html +#: lib/nav_foot.html site/head.html msgid "Open Library" msgstr "" @@ -5489,8 +5464,8 @@ msgid "Explore subjects" msgstr "" #: RelatedSubjects.html SearchNavigation.html SubjectTags.html -#: lib/nav_foot.html lib/nav_head.html openlibrary/plugins/worksearch/code.py -#: subjects/notfound.html type/author/view.html type/list/view_body.html +#: lib/nav_foot.html lib/nav_head.html subjects/notfound.html +#: type/author/view.html type/list/view_body.html msgid "Subjects" msgstr "" @@ -6108,11 +6083,11 @@ msgstr "" msgid "Request Status" msgstr "" -#: merge_request_table/table_header.html openlibrary/core/edits.py +#: merge_request_table/table_header.html msgid "Merged" msgstr "" -#: merge_request_table/table_header.html openlibrary/core/edits.py +#: merge_request_table/table_header.html msgid "Declined" msgstr "" @@ -6404,8 +6379,8 @@ msgstr "" msgid "Publisher: %(name)s" msgstr "" -#: openlibrary/plugins/worksearch/code.py publishers/view.html -#: search/advancedsearch.html type/edition/view.html type/work/view.html +#: publishers/view.html search/advancedsearch.html type/edition/view.html +#: type/work/view.html msgid "Publisher" msgstr "" @@ -7170,8 +7145,8 @@ msgstr "" msgid "— Show everything by this author?" msgstr "" -#: RelatedSubjects.html SubjectTags.html openlibrary/plugins/worksearch/code.py -#: type/author/view.html type/list/view_body.html +#: RelatedSubjects.html SubjectTags.html type/author/view.html +#: type/list/view_body.html msgid "Places" msgstr "" @@ -7305,8 +7280,7 @@ msgstr "" msgid "Search for other books from %(publisher)s" msgstr "" -#: openlibrary/plugins/worksearch/code.py type/edition/view.html -#: type/work/view.html +#: type/edition/view.html type/work/view.html msgid "Language" msgstr "" @@ -7645,8 +7619,7 @@ msgstr "" msgid "Derived from seed metadata" msgstr "" -#: RelatedSubjects.html SubjectTags.html openlibrary/plugins/worksearch/code.py -#: type/list/view_body.html +#: RelatedSubjects.html SubjectTags.html type/list/view_body.html msgid "Times" msgstr "" @@ -8553,399 +8526,3 @@ msgstr "" msgid "View Volume %(num)d" msgstr "" -#: openlibrary/core/bookshelves.py -msgid "[Record deleted]" -msgstr "" - -#: openlibrary/core/edits.py -msgid "Unknown" -msgstr "" - -#: openlibrary/plugins/openlibrary/api.py -msgid "Search Results" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Arabic" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Czech" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "German" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "English" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Spanish" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "French" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Hindi" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Croatian" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Italian" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Portuguese" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Romanian" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Sardinian" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Telugu" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Ukrainian" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Chinese" -msgstr "" - -#: openlibrary/plugins/openlibrary/code.py -msgid "Filipino" -msgstr "" - -#: openlibrary/plugins/openlibrary/home.py -msgid "Art" -msgstr "" - -#: openlibrary/plugins/openlibrary/home.py -msgid "Science Fiction" -msgstr "" - -#: openlibrary/plugins/openlibrary/home.py -msgid "Fantasy" -msgstr "" - -#: openlibrary/plugins/openlibrary/home.py -msgid "Biographies" -msgstr "" - -#: openlibrary/plugins/openlibrary/home.py -msgid "Recipes" -msgstr "" - -#: openlibrary/plugins/openlibrary/home.py -msgid "Children" -msgstr "" - -#: openlibrary/plugins/openlibrary/home.py -msgid "Medicine" -msgstr "" - -#: openlibrary/plugins/openlibrary/home.py -msgid "Religion" -msgstr "" - -#: openlibrary/plugins/openlibrary/home.py -msgid "Mystery and Detective Stories" -msgstr "" - -#: openlibrary/plugins/openlibrary/home.py -msgid "Plays" -msgstr "" - -#: openlibrary/plugins/openlibrary/home.py -msgid "Music" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "At least 1 subject" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "At least 1 author" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "At least 1 edition" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "Has work (orphaned)" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "Has publication year" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "Has cover" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "Has language" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "Has publisher" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "At least 2 editions" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "Has dewey decimal" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "Has LoC classification" -msgstr "" - -#: openlibrary/plugins/openlibrary/librarian_dashboard.py -msgid "Has number of pages" -msgstr "" - -#: openlibrary/plugins/openlibrary/lists.py -#, python-format -msgid "Are you sure you want to remove %(title)s from your list?" -msgstr "" - -#: openlibrary/plugins/openlibrary/partials.py -msgid "Better World Books" -msgstr "" - -#: openlibrary/plugins/openlibrary/partials.py -msgid " - includes shipping" -msgstr "" - -#: openlibrary/plugins/openlibrary/partials.py -msgid "Amazon" -msgstr "" - -#: openlibrary/plugins/openlibrary/partials.py -msgid "Bookshop.org" -msgstr "" - -#: openlibrary/plugins/openlibrary/partials.py -msgid "This work does not appear on any lists." -msgstr "" - -#: openlibrary/plugins/openlibrary/pd.py -msgid "I don't have one yet" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "The email address you entered is invalid" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "This account has been blocked" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "This account has been locked" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "No account was found with this email. Please try again" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "The password you entered is incorrect. Please try again" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "Wrong password. Please try again" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "Please verify your Open Library account before logging in" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "Please verify your Internet Archive account before logging in" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "Please fill out all fields and try again" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "This email is already registered" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "This username is already registered" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "A problem occurred and we were unable to log you in." -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "Login attempted with invalid Internet Archive s3 credentials." -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "" -"Servers are experiencing unusually high traffic, please try again later " -"or email openlibrary@archive.org for help." -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "Email provider not recognized." -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "Password requirements not met." -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "A problem occurred and we were unable to log you in" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "" -"Login or registration attempt hit an unexpected error, please try again " -"or contact info@archive.org" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -#, python-format -msgid "Request failed with error code: %(error_code)s" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "" -"Thank you for registering an Open Library account and requesting special " -"print disability access. You should receive an email detailing next steps" -" in the process." -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "Username unavailable" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -#: openlibrary/plugins/upstream/forms.py -msgid "Email already registered" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "An Internet Archive account already exists with this email" -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "" -"Verification failed. The link may be invalid or expired. Please try " -"registering again." -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "Your email has been verified. You are now logged in." -msgstr "" - -#: openlibrary/plugins/upstream/account.py -msgid "Notification preferences have been updated successfully." -msgstr "" - -#: openlibrary/plugins/upstream/borrow.py -msgid "this book" -msgstr "" - -#: openlibrary/plugins/upstream/borrow.py -#, python-format -msgid "Unable to return %s. Please try again later or contact info@archive.org." -msgstr "" - -#: openlibrary/plugins/upstream/borrow.py -#, python-format -msgid "%s has been returned." -msgstr "" - -#: openlibrary/plugins/upstream/borrow.py -msgid "" -"Your account has hit a lending limit. Please try again later or contact " -"info@archive.org." -msgstr "" - -#: openlibrary/plugins/upstream/forms.py -msgid "Username" -msgstr "" - -#: openlibrary/plugins/upstream/forms.py -msgid "No user registered with this email address" -msgstr "" - -#: openlibrary/plugins/upstream/forms.py -msgid "Disposable email not permitted" -msgstr "" - -#: openlibrary/plugins/upstream/forms.py -msgid "Your email provider is not recognized." -msgstr "" - -#: openlibrary/plugins/upstream/forms.py -msgid "Username already used" -msgstr "" - -#: openlibrary/plugins/upstream/forms.py -msgid "Must be between 3 and 20 letters and numbers" -msgstr "" - -#: openlibrary/plugins/upstream/forms.py -msgid "Screen Name" -msgstr "" - -#: openlibrary/plugins/upstream/forms.py -msgid "Public and cannot be changed later." -msgstr "" - -#: openlibrary/plugins/upstream/forms.py -msgid "Invalid password" -msgstr "" - -#: openlibrary/plugins/upstream/forms.py -msgid "Your email address" -msgstr "" - -#: openlibrary/plugins/upstream/forms.py -msgid "Choose a password" -msgstr "" - -#: openlibrary/plugins/upstream/mybooks.py -#, python-format -msgid "" -"Continue %(action)s " -"%(name)s" -msgstr "" - -#: openlibrary/plugins/worksearch/code.py -msgid "eBook?" -msgstr "" - -#: openlibrary/plugins/worksearch/code.py -msgid "First published" -msgstr "" - -#: openlibrary/plugins/worksearch/code.py -msgid "Classic eBooks" -msgstr "" - diff --git a/openlibrary/templates/home/stats.html b/openlibrary/templates/home/stats.html index b9255f92b55..78b8aa1ea26 100644 --- a/openlibrary/templates/home/stats.html +++ b/openlibrary/templates/home/stats.html @@ -7,12 +7,12 @@

$_('Around the Library')

- + $#
@@ -43,7 +43,7 @@

$_('Around the Library')

- + $# From 07673280c84e2a1ac22943bb6ad36202e7558564 Mon Sep 17 00:00:00 2001 From: Tanishq Sangwan Date: Mon, 1 Jun 2026 17:07:15 +0530 Subject: [PATCH 2/3] Use template conditionals to hide unique visitors stat on homepage and admin page (Issue #12823) --- openlibrary/core/admin.py | 32 +- openlibrary/i18n/messages.pot | 497 +++++++++++++++++++++++-- openlibrary/templates/admin/index.html | 6 +- openlibrary/templates/home/stats.html | 50 ++- static/css/components/home.css | 16 +- 5 files changed, 507 insertions(+), 94 deletions(-) diff --git a/openlibrary/core/admin.py b/openlibrary/core/admin.py index cdc2e70b946..ba6bf350431 100644 --- a/openlibrary/core/admin.py +++ b/openlibrary/core/admin.py @@ -105,22 +105,22 @@ def _get_visitor_counts_from_graphite(ndays: int = 28) -> list[list[int]]: :param ndays: number of days to read :return: list containing [count, timestamp] for ndays """ - # try: - # response = requests.get( - # "http://graphite.us.archive.org/render/", - # params={ - # "target": "summarize(stats.uniqueips.openlibrary, '1d')", - # "from": f"-{ndays}days", - # "tz": "UTC", - # "format": "json", - # }, - # ) - # response.raise_for_status() - # visitors = response.json()[0]["datapoints"] - # except requests.exceptions.RequestException: - # visitors = [] - # return visitors - return [] + try: + response = requests.get( + "http://graphite.us.archive.org/render/", + params={ + "target": "summarize(stats.uniqueips.openlibrary, '1d')", + "from": f"-{ndays}days", + "tz": "UTC", + "format": "json", + }, + timeout=5, + ) + response.raise_for_status() + visitors = response.json()[0]["datapoints"] + except requests.exceptions.RequestException: + visitors = [] + return visitors class VisitorStats(Stats): diff --git a/openlibrary/i18n/messages.pot b/openlibrary/i18n/messages.pot index 99ffbb8d407..c0e92bfa750 100644 --- a/openlibrary/i18n/messages.pot +++ b/openlibrary/i18n/messages.pot @@ -461,12 +461,12 @@ msgstr "" msgid "Fiction" msgstr "" -#: design.html +#: design.html openlibrary/plugins/openlibrary/home.py msgid "Science" msgstr "" #: databarDiff.html databarEdit.html databarTemplate.html databarView.html -#: design.html lib/history.html +#: design.html lib/history.html openlibrary/plugins/openlibrary/home.py msgid "History" msgstr "" @@ -900,7 +900,7 @@ msgid "" "email and password to access your Open Library account." msgstr "" -#: login.html +#: login.html openlibrary/plugins/upstream/forms.py msgid "Email" msgstr "" @@ -909,6 +909,7 @@ msgid "Forgot your Internet Archive email?" msgstr "" #: account/email/forgot-ia.html login.html +#: openlibrary/plugins/upstream/forms.py msgid "Password" msgstr "" @@ -1119,8 +1120,8 @@ msgid "Title" msgstr "" #: books/add.html books/edit.html books/edit/edition.html lib/nav_head.html -#: search/advancedsearch.html search/work_search_selected_facets.html -#: status.html +#: openlibrary/plugins/worksearch/code.py search/advancedsearch.html +#: search/work_search_selected_facets.html status.html msgid "Author" msgstr "" @@ -1271,7 +1272,7 @@ msgstr "" msgid "All Time" msgstr "" -#: home/index.html trending.html +#: home/index.html openlibrary/plugins/openlibrary/api.py trending.html msgid "Trending Books" msgstr "" @@ -1515,11 +1516,11 @@ msgid "" "information form." msgstr "" -#: account/create.html +#: account/create.html openlibrary/plugins/upstream/forms.py msgid "Must be a valid email address" msgstr "" -#: account/create.html +#: account/create.html openlibrary/plugins/upstream/forms.py msgid "Must be between 3 and 20 characters" msgstr "" @@ -1845,7 +1846,7 @@ msgstr "" #. (bookshelf ID 3). Used as a button label and shelf name. #: account/mybooks.html account/readinglog_shelf_name.html account/sidebar.html #: my_books/dropdown_content.html my_books/primary_action.html -#: search/sort_options.html +#: openlibrary/plugins/upstream/mybooks.py search/sort_options.html msgid "Already Read" msgstr "" @@ -1871,7 +1872,7 @@ msgid "My Reading Stats" msgstr "" #: account/mybooks.html account/sidebar.html -#: books/mybooks_breadcrumb_select.html +#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/account.py msgid "Loan History" msgstr "" @@ -1987,7 +1988,7 @@ msgid "Save" msgstr "" #: EditionNavBar.html account/observations.html -#: books/mybooks_breadcrumb_select.html +#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py msgid "Reviews" msgstr "" @@ -2237,6 +2238,7 @@ msgid "Click on a bar to see matching works" msgstr "" #: account/sidebar.html books/mybooks_breadcrumb_select.html +#: openlibrary/plugins/upstream/mybooks.py msgid "My Feed" msgstr "" @@ -2675,7 +2677,7 @@ msgstr "" msgid "Failed" msgstr "" -#: admin/imports_by_date.html +#: admin/imports_by_date.html openlibrary/core/edits.py msgid "Pending" msgstr "" @@ -2805,7 +2807,7 @@ msgstr "" msgid "Star Rating Patrons" msgstr "" -#: admin/index.html +#: admin/index.html home/stats.html msgid "Unique Visitors" msgstr "" @@ -2887,7 +2889,8 @@ msgid "Admin Center" msgstr "" #: RelatedSubjects.html SubjectTags.html admin/menu.html -#: admin/people/index.html admin/people/view.html type/author/view.html +#: admin/people/index.html admin/people/view.html +#: openlibrary/plugins/worksearch/code.py type/author/view.html #: type/list/view_body.html msgid "People" msgstr "" @@ -3393,7 +3396,7 @@ msgid "Anonymize Account" msgstr "" #: admin/people/view.html books/mybooks_breadcrumb_select.html -#: type/user/view.html +#: openlibrary/plugins/upstream/account.py type/user/view.html msgid "Loans" msgstr "" @@ -4143,39 +4146,51 @@ msgid "in %(languagelist)s" msgstr "" #: SearchNavigation.html books/mybooks_breadcrumb_select.html lib/nav_foot.html +#: openlibrary/plugins/upstream/mybooks.py msgid "Books" msgstr "" -#: books/mybooks_breadcrumb_select.html +#. Page title for the "Want to Read" shelf page. +#. Example: "Want to Read (17)". %(count)d is the number of books on this +#. shelf. +#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py #, python-format msgid "Want to Read (%(count)d)" msgstr "" -#: books/mybooks_breadcrumb_select.html +#. Page title for the "Currently Reading" shelf page. +#. Example: "Currently Reading (42)". %(count)d is the number of books on this +#. shelf. +#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py #, python-format msgid "Currently Reading (%(count)d)" msgstr "" -#: books/mybooks_breadcrumb_select.html +#. Page title for the "Already Read" shelf page. +#. Example: "Already Read (203)". %(count)d is the number of books on this +#. shelf. +#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py #, python-format msgid "Already Read (%(count)d)" msgstr "" -#: books/mybooks_breadcrumb_select.html +#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py #, python-format msgid "Stopped Reading (%(count)d)" msgstr "" #: books/mybooks_breadcrumb_select.html +#: openlibrary/plugins/openlibrary/lists.py #, python-format msgid "Lists (%(count)d)" msgstr "" -#: books/mybooks_breadcrumb_select.html type/edition/modal_links.html +#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/mybooks.py +#: type/edition/modal_links.html msgid "Notes" msgstr "" -#: books/mybooks_breadcrumb_select.html +#: books/mybooks_breadcrumb_select.html openlibrary/plugins/upstream/account.py msgid "Imports and Exports" msgstr "" @@ -5070,7 +5085,7 @@ msgstr[1] "" msgid "Welcome to Open Library" msgstr "" -#: home/index.html +#: home/index.html openlibrary/plugins/openlibrary/api.py msgid "Classic Books" msgstr "" @@ -5078,19 +5093,21 @@ msgstr "" msgid "Recently Returned" msgstr "" -#: home/index.html +#: home/index.html openlibrary/plugins/openlibrary/api.py +#: openlibrary/plugins/openlibrary/home.py msgid "Romance" msgstr "" -#: home/index.html +#: home/index.html openlibrary/plugins/openlibrary/api.py msgid "Kids" msgstr "" -#: home/index.html +#: home/index.html openlibrary/plugins/openlibrary/api.py msgid "Thrillers" msgstr "" -#: home/index.html +#: home/index.html openlibrary/plugins/openlibrary/api.py +#: openlibrary/plugins/openlibrary/home.py msgid "Textbooks" msgstr "" @@ -5129,6 +5146,14 @@ msgid "" "href=\"/recentchanges\">recent changes" msgstr "" +#: home/stats.html +msgid "See all visitors to OpenLibrary.org" +msgstr "" + +#: home/stats.html +msgid "Area graph of recent unique visitors" +msgstr "" + #: home/stats.html msgid "How many new Open Library members have we welcomed?" msgstr "" @@ -5403,7 +5428,7 @@ msgstr "" msgid "Just a sentence or two is good." msgstr "" -#: lib/nav_foot.html site/head.html +#: lib/nav_foot.html openlibrary/plugins/openlibrary/api.py site/head.html msgid "Open Library" msgstr "" @@ -5464,8 +5489,8 @@ msgid "Explore subjects" msgstr "" #: RelatedSubjects.html SearchNavigation.html SubjectTags.html -#: lib/nav_foot.html lib/nav_head.html subjects/notfound.html -#: type/author/view.html type/list/view_body.html +#: lib/nav_foot.html lib/nav_head.html openlibrary/plugins/worksearch/code.py +#: subjects/notfound.html type/author/view.html type/list/view_body.html msgid "Subjects" msgstr "" @@ -6083,11 +6108,11 @@ msgstr "" msgid "Request Status" msgstr "" -#: merge_request_table/table_header.html +#: merge_request_table/table_header.html openlibrary/core/edits.py msgid "Merged" msgstr "" -#: merge_request_table/table_header.html +#: merge_request_table/table_header.html openlibrary/core/edits.py msgid "Declined" msgstr "" @@ -6379,8 +6404,8 @@ msgstr "" msgid "Publisher: %(name)s" msgstr "" -#: publishers/view.html search/advancedsearch.html type/edition/view.html -#: type/work/view.html +#: openlibrary/plugins/worksearch/code.py publishers/view.html +#: search/advancedsearch.html type/edition/view.html type/work/view.html msgid "Publisher" msgstr "" @@ -7145,8 +7170,8 @@ msgstr "" msgid "— Show everything by this author?" msgstr "" -#: RelatedSubjects.html SubjectTags.html type/author/view.html -#: type/list/view_body.html +#: RelatedSubjects.html SubjectTags.html openlibrary/plugins/worksearch/code.py +#: type/author/view.html type/list/view_body.html msgid "Places" msgstr "" @@ -7280,7 +7305,8 @@ msgstr "" msgid "Search for other books from %(publisher)s" msgstr "" -#: type/edition/view.html type/work/view.html +#: openlibrary/plugins/worksearch/code.py type/edition/view.html +#: type/work/view.html msgid "Language" msgstr "" @@ -7619,7 +7645,8 @@ msgstr "" msgid "Derived from seed metadata" msgstr "" -#: RelatedSubjects.html SubjectTags.html type/list/view_body.html +#: RelatedSubjects.html SubjectTags.html openlibrary/plugins/worksearch/code.py +#: type/list/view_body.html msgid "Times" msgstr "" @@ -8526,3 +8553,399 @@ msgstr "" msgid "View Volume %(num)d" msgstr "" +#: openlibrary/core/bookshelves.py +msgid "[Record deleted]" +msgstr "" + +#: openlibrary/core/edits.py +msgid "Unknown" +msgstr "" + +#: openlibrary/plugins/openlibrary/api.py +msgid "Search Results" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Arabic" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Czech" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "German" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "English" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Spanish" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "French" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Hindi" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Croatian" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Italian" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Portuguese" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Romanian" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Sardinian" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Telugu" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Ukrainian" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Chinese" +msgstr "" + +#: openlibrary/plugins/openlibrary/code.py +msgid "Filipino" +msgstr "" + +#: openlibrary/plugins/openlibrary/home.py +msgid "Art" +msgstr "" + +#: openlibrary/plugins/openlibrary/home.py +msgid "Science Fiction" +msgstr "" + +#: openlibrary/plugins/openlibrary/home.py +msgid "Fantasy" +msgstr "" + +#: openlibrary/plugins/openlibrary/home.py +msgid "Biographies" +msgstr "" + +#: openlibrary/plugins/openlibrary/home.py +msgid "Recipes" +msgstr "" + +#: openlibrary/plugins/openlibrary/home.py +msgid "Children" +msgstr "" + +#: openlibrary/plugins/openlibrary/home.py +msgid "Medicine" +msgstr "" + +#: openlibrary/plugins/openlibrary/home.py +msgid "Religion" +msgstr "" + +#: openlibrary/plugins/openlibrary/home.py +msgid "Mystery and Detective Stories" +msgstr "" + +#: openlibrary/plugins/openlibrary/home.py +msgid "Plays" +msgstr "" + +#: openlibrary/plugins/openlibrary/home.py +msgid "Music" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "At least 1 subject" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "At least 1 author" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "At least 1 edition" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "Has work (orphaned)" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "Has publication year" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "Has cover" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "Has language" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "Has publisher" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "At least 2 editions" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "Has dewey decimal" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "Has LoC classification" +msgstr "" + +#: openlibrary/plugins/openlibrary/librarian_dashboard.py +msgid "Has number of pages" +msgstr "" + +#: openlibrary/plugins/openlibrary/lists.py +#, python-format +msgid "Are you sure you want to remove %(title)s from your list?" +msgstr "" + +#: openlibrary/plugins/openlibrary/partials.py +msgid "Better World Books" +msgstr "" + +#: openlibrary/plugins/openlibrary/partials.py +msgid " - includes shipping" +msgstr "" + +#: openlibrary/plugins/openlibrary/partials.py +msgid "Amazon" +msgstr "" + +#: openlibrary/plugins/openlibrary/partials.py +msgid "Bookshop.org" +msgstr "" + +#: openlibrary/plugins/openlibrary/partials.py +msgid "This work does not appear on any lists." +msgstr "" + +#: openlibrary/plugins/openlibrary/pd.py +msgid "I don't have one yet" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "The email address you entered is invalid" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "This account has been blocked" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "This account has been locked" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "No account was found with this email. Please try again" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "The password you entered is incorrect. Please try again" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "Wrong password. Please try again" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "Please verify your Open Library account before logging in" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "Please verify your Internet Archive account before logging in" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "Please fill out all fields and try again" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "This email is already registered" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "This username is already registered" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "A problem occurred and we were unable to log you in." +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "Login attempted with invalid Internet Archive s3 credentials." +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "" +"Servers are experiencing unusually high traffic, please try again later " +"or email openlibrary@archive.org for help." +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "Email provider not recognized." +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "Password requirements not met." +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "A problem occurred and we were unable to log you in" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "" +"Login or registration attempt hit an unexpected error, please try again " +"or contact info@archive.org" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +#, python-format +msgid "Request failed with error code: %(error_code)s" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "" +"Thank you for registering an Open Library account and requesting special " +"print disability access. You should receive an email detailing next steps" +" in the process." +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "Username unavailable" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +#: openlibrary/plugins/upstream/forms.py +msgid "Email already registered" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "An Internet Archive account already exists with this email" +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "" +"Verification failed. The link may be invalid or expired. Please try " +"registering again." +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "Your email has been verified. You are now logged in." +msgstr "" + +#: openlibrary/plugins/upstream/account.py +msgid "Notification preferences have been updated successfully." +msgstr "" + +#: openlibrary/plugins/upstream/borrow.py +msgid "this book" +msgstr "" + +#: openlibrary/plugins/upstream/borrow.py +#, python-format +msgid "Unable to return %s. Please try again later or contact info@archive.org." +msgstr "" + +#: openlibrary/plugins/upstream/borrow.py +#, python-format +msgid "%s has been returned." +msgstr "" + +#: openlibrary/plugins/upstream/borrow.py +msgid "" +"Your account has hit a lending limit. Please try again later or contact " +"info@archive.org." +msgstr "" + +#: openlibrary/plugins/upstream/forms.py +msgid "Username" +msgstr "" + +#: openlibrary/plugins/upstream/forms.py +msgid "No user registered with this email address" +msgstr "" + +#: openlibrary/plugins/upstream/forms.py +msgid "Disposable email not permitted" +msgstr "" + +#: openlibrary/plugins/upstream/forms.py +msgid "Your email provider is not recognized." +msgstr "" + +#: openlibrary/plugins/upstream/forms.py +msgid "Username already used" +msgstr "" + +#: openlibrary/plugins/upstream/forms.py +msgid "Must be between 3 and 20 letters and numbers" +msgstr "" + +#: openlibrary/plugins/upstream/forms.py +msgid "Screen Name" +msgstr "" + +#: openlibrary/plugins/upstream/forms.py +msgid "Public and cannot be changed later." +msgstr "" + +#: openlibrary/plugins/upstream/forms.py +msgid "Invalid password" +msgstr "" + +#: openlibrary/plugins/upstream/forms.py +msgid "Your email address" +msgstr "" + +#: openlibrary/plugins/upstream/forms.py +msgid "Choose a password" +msgstr "" + +#: openlibrary/plugins/upstream/mybooks.py +#, python-format +msgid "" +"Continue %(action)s " +"%(name)s" +msgstr "" + +#: openlibrary/plugins/worksearch/code.py +msgid "eBook?" +msgstr "" + +#: openlibrary/plugins/worksearch/code.py +msgid "First published" +msgstr "" + +#: openlibrary/plugins/worksearch/code.py +msgid "Classic eBooks" +msgstr "" + diff --git a/openlibrary/templates/admin/index.html b/openlibrary/templates/admin/index.html index 3eaa77af901..1f6f9c60953 100644 --- a/openlibrary/templates/admin/index.html +++ b/openlibrary/templates/admin/index.html @@ -245,8 +245,10 @@

$_("Members")

-

$_("Unique Visitors")

- $_('Unique visitors IPs per day graph') + $# Conditional check since the graphite source is currently unreliable, hiding the stat when it returns nothing + $if counts.get("visitors") and counts["visitors"].get_summary(28): +

$_("Unique Visitors")

+ $_('Unique visitors IPs per day graph')

$_("Borrows")

$_('Borrows, last 3 months graph') diff --git a/openlibrary/templates/home/stats.html b/openlibrary/templates/home/stats.html index 78b8aa1ea26..9e8613f431c 100644 --- a/openlibrary/templates/home/stats.html +++ b/openlibrary/templates/home/stats.html @@ -7,43 +7,39 @@

$_('Around the Library')

- $# - -
-
-
- $:commify(stats["members"].get_summary(28))$_('New Members') + $# Conditional check since the graphite source is currently unreliable, hiding the stat when it returns nothing + $if stats["visitors"].get_summary(28): + + + -
- + + - - $# + $# Conditional check since the graphite source is currently unreliable, hiding the stat when it returns nothing + $if stats["visitors"].get_summary(28): + diff --git a/static/css/components/home.css b/static/css/components/home.css index e04bb83b942..2b1aafff902 100644 --- a/static/css/components/home.css +++ b/static/css/components/home.css @@ -55,26 +55,20 @@ div.chartHome a:hover, #home-stats-charts { display: flex; flex-wrap: wrap; + justify-content: space-between; } #home-stats-charts .statschart { - flex: 1; height: 110px; text-align: center; - padding: 1px; + margin: 0 var(--spacing-inline-sm); + cursor: pointer; } -/* stylelint-disable-next-line max-nesting-depth */ -#home-stats-charts .statschart .chartShow { - width: 145px; - height: 60px; - margin: 0 var(--spacing-inline-sm); +#home-stats-charts .statschart div { border-bottom: 1px solid var(--grey); - cursor: pointer; } -/* stylelint-disable no-descending-specificity */ -/* stylelint-disable max-nesting-depth */ #home-stats-charts .statschart a { color: var(--black); text-decoration: none; @@ -97,8 +91,6 @@ div.chartHome a:hover, font-size: 0.625em; text-transform: uppercase; } -/* stylelint-enable no-descending-specificity */ -/* stylelint-enable max-nesting-depth */ #home-resource { font-size: 13px; From 115d11395f97f23c0975a66baeb667cb211a6cb2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Jun 2026 15:31:27 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- openlibrary/templates/home/stats.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlibrary/templates/home/stats.html b/openlibrary/templates/home/stats.html index 9e8613f431c..aa913c8523e 100644 --- a/openlibrary/templates/home/stats.html +++ b/openlibrary/templates/home/stats.html @@ -33,7 +33,7 @@

$_('Around the Library')

$:commify(stats["loans"].get_summary(28))$_('eBooks Borrowed')
- +