internetarchive / openlibrary

One webpage for every book ever published!
https://openlibrary.org
GNU Affero General Public License v3.0
5.11k stars 1.33k forks source link

Remove unused macros #4272

Closed cdrini closed 3 years ago

cdrini commented 3 years ago

There are a lot of macros which are no longer used. Lets delete them.

Here are the macros without any usages in the repo:

(Determined with this command: for f in *.html; do echo "$f | \`$(grep --exclude-dir=.idea --exclude-dir=.vs --exclude-dir=.git --exclude-dir=build --exclude-dir=node_modules --exclude-dir=vendor --exclude-dir= venv --exclude-dir=venv-py3 --exclude-dir=coverage -F ${f/.html/} -l -r ../.. | sed 's:../..::' | tr '\n' ' ')\`"; done)

Since macros can also be used on regular pages in openlibrary (e.g. {{AlertChanges(...)}}), need to check there as well.

(Note: This will only test for singly unused macros; it won't catch a cluster of interdependent unused macros.)

Macro Usages in repo Usages in dump 2020-10-31
AlertChanges.html None None
AlertTour.html None None
AllPagination.html None None
AuthorEditRow.html None None
EditionCount.html None None
EditionEditRow.html None None
EnrollUsergroup.html None None
FormatExpiry2.html None None
FullTextCount.html None None
GoButton.html None None
HasFulltext.html None None
HelpWikilanguage.html None None
MergeHistory.html None None
ModifyTemplate.html None None
MostRecent.html None None
MostRecentHome.html None None
NavigationDev.html None None
QueryCarousel.html None /collections/k-12 /collections/tv-people-books /collections/Marley-Dias-1000BlackGirlBooks-Library /collections/cascaborra-historia-de-espana-en-vinetas /collections/black-lives-matter /collections/Rainbow_Magic /collections/read-the-movie /collections/mat-su-valley-banned-book-challenge /help/faq/editing /collections/summer /playground
RowButtons.html None None
SponsorCarousel.html None /sponsorship
UniqueIPcount.html None None
databarMerge.html None None
databari18n.html None None
miframe.html None None

Stakeholder

@ArunTeltia

cdrini commented 3 years ago

Full table for reference:

File | Usages | -- | -- | AffiliateLinks.html | `/openlibrary/macros/databarWork.html /tests/integration/test_affiliate_links.py ` AlertChanges.html | `` AlertTour.html | `` AllPagination.html | `` AuthorEditRow.html | `` AuthorList.html | `/openlibrary/templates/account/borrow.html /openlibrary/templates/admin/loans_table.html /openlibrary/templates/borrow_admin.html ` BookCount.html | `/openlibrary/plugins/upstream/pages/home.page /scripts/dev-instance/dev_db.pg_dump ` BookPreview.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/macros/LoanStatus.html /scripts/i18n-messages ` BookSearchInside.html | `/openlibrary/macros/LoanStatus.html ` BorrowTrouble.html | `/openlibrary/templates/account/borrow.html ` CoverImage.html | `/openlibrary/templates/type/edition-history/view.html /static/css/legacy.less ` DisplayCode.html | `/openlibrary/templates/type/macro/view.html /openlibrary/templates/type/rawtext/view.html /openlibrary/templates/type/template/view.html ` DownloadOptions.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/macros/databarWork.html /scripts/i18n-messages ` EditButtons.html | `/openlibrary/i18n/cs/messages.po /openlibrary/i18n/de/messages.po /openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/i18n/te/messages.po /openlibrary/templates/books/edit.html /openlibrary/templates/edit_yaml.html /openlibrary/templates/permission.html /openlibrary/templates/type/about/edit.html /openlibrary/templates/type/author/edit.html /openlibrary/templates/type/doc/edit.html /openlibrary/templates/type/home/edit.html /openlibrary/templates/type/i18n/edit.html /openlibrary/templates/type/list/edit.html /openlibrary/templates/type/macro/edit.html /openlibrary/templates/type/page/edit.html /openlibrary/templates/type/permission/edit.html /openlibrary/templates/type/rawtext/edit.html /openlibrary/templates/type/template/edit.html /openlibrary/templates/type/user/edit.html /openlibrary/templates/type/usergroup/edit.html /scripts/i18n-messages /static/css/legacy.less /static/css/page-edit.less ` EditButtonsMacros.html | `/openlibrary/templates/type/macro/edit.html /openlibrary/templates/type/rawtext/edit.html /static/css/legacy.less ` EditionCount.html | `` EditionEditRow.html | `` EditionNavBar.html | `/openlibrary/templates/type/edition/view.html ` EnrollUsergroup.html | `` FlourishButton.html | `/openlibrary/templates/type/edition-history/view.html ` FormatExpiry.html | `/openlibrary/macros/ManageLoansButtons.html /openlibrary/templates/account/borrow.html /openlibrary/templates/admin/loans_table.html /openlibrary/templates/borrow_admin.html ` FormatExpiry2.html | `` FullTextCount.html | `` FulltextResults.html | `/openlibrary/templates/search/inside.html /scripts/i18n-messages /static/css/legacy.less ` FulltextSnippet.html | `/openlibrary/macros/FulltextResults.html /static/css/legacy.less ` GoButton.html | `` HasFulltext.html | `` Hello.html | `/.pytest_cache/v/cache/lastfailed /.pytest_cache/v/cache/nodeids /openlibrary/catalog/merge/test_normalize.py /openlibrary/components/dev.js /openlibrary/components/HelloWorld.vue /openlibrary/components/README.md /openlibrary/plugins/upstream/code.py /openlibrary/plugins/upstream/code.pyc /openlibrary/plugins/upstream/jsdef.py /openlibrary/plugins/upstream/jsdef.pyc /openlibrary/plugins/upstream/tests/test_merge_authors.py /openlibrary/plugins/upstream/utils.py /openlibrary/plugins/upstream/utils.pyc /openlibrary/plugins/upstream/__pycache__/code.cpython-38.pyc /openlibrary/plugins/upstream/__pycache__/jsdef.cpython-38.pyc /openlibrary/plugins/upstream/__pycache__/utils.cpython-38.pyc /openlibrary/templates/admin/email_reassign.html /openlibrary/templates/email/account/verify.html /openlibrary/templates/email/email/verify.html /openlibrary/templates/email/support_case.html /openlibrary/templates/email/waitinglist_book_available.html /openlibrary/templates/email/waitinglist_people_waiting.html /openlibrary/tests/catalog/test_utils.py ` HelpFormatting.html | `/openlibrary/macros/HelpFormatting.html /openlibrary/templates/type/home/edit.html ` HelpWikilanguage.html | `` LoanReadForm.html | `/openlibrary/macros/LoanReadForm.html /openlibrary/macros/ManageLoansButtons.html /openlibrary/templates/account/borrow.html /static/css/components/borrowTable.less ` LoanStatus.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/macros/databarWork.html /openlibrary/macros/LoanStatus.html /openlibrary/macros/SearchResultsWork.html /openlibrary/plugins/openlibrary/js/ol.js /openlibrary/templates/books/custom_carousel.html /openlibrary/templates/books/edition-sort.html /scripts/i18n-messages ` ManageLoansButtons.html | `/openlibrary/templates/account/books.html ` ManageWaitlistButton.html | `/openlibrary/templates/account/books.html ` MemberCount.html | `/openlibrary/admin/templates/admin/index.html ` MergeHistory.html | `` Metatags.html | `/openlibrary/templates/type/edition/view.html ` ModifyTemplate.html | `` MostRecent.html | `` MostRecentHome.html | `` NavigationDev.html | `` PageList.html | `/openlibrary/templates/notfound.html /scripts/dev-instance/dev_db.pg_dump /static/css/legacy.less ` Pager.html | `/.pytest_cache/v/cache/lastfailed /openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/macros/FulltextResults.html /openlibrary/macros/RecentChanges.html /openlibrary/macros/RecentChangesAdmin.html /openlibrary/macros/RecentChangesUsers.html /openlibrary/macros/RecentPageList.html /openlibrary/templates/account/books.html /openlibrary/templates/admin/people/edits.html /openlibrary/templates/recentchanges/render.html /openlibrary/templates/search/authors.html /openlibrary/templates/search/subjects.html /openlibrary/templates/type/author/view.html /openlibrary/templates/type/list/embed.html /openlibrary/templates/type/list/view.html /openlibrary/templates/work_search.html /scripts/i18n-messages /static/css/legacy.less ` Paginate.html | `/openlibrary/plugins/openlibrary/js/editions-table/index.js /openlibrary/templates/type/homepage/view.html ` QueryCarousel.html | `` ReadButton.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/macros/LoanStatus.html /scripts/i18n-messages ` ReadMore.html | `/openlibrary/plugins/openlibrary/js/index.js /openlibrary/plugins/openlibrary/js/readmore.js /openlibrary/templates/type/edition/view.html ` ReadingLogButton.html | `/openlibrary/templates/account/books.html /static/css/legacy.less ` RecentChanges.html | `/openlibrary/macros/RecentChangesAdmin.html /openlibrary/macros/RecentChangesUsers.html /openlibrary/templates/type/user/view.html /scripts/sync /static/css/legacy.less ` RecentChangesAdmin.html | `/static/css/legacy.less ` RecentChangesUsers.html | `/openlibrary/templates/type/user/view.html /static/css/legacy.less ` RecentPageList.html | `/static/css/legacy.less ` ReturnForm.html | `/openlibrary/macros/ManageLoansButtons.html /openlibrary/templates/account/borrow.html ` RowButtons.html | `` SRPCoverImage.html | `/static/css/legacy.less ` SearchResults.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/macros/FulltextResults.html /openlibrary/templates/account/books.html /openlibrary/templates/stats/readinglog.html /openlibrary/templates/type/author/view.html /openlibrary/templates/work_search.html /scripts/i18n-messages /static/css/legacy.less ` SearchResultsWork.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/macros/FulltextResults.html /openlibrary/templates/account/books.html /openlibrary/templates/stats/readinglog.html /openlibrary/templates/type/author/view.html /openlibrary/templates/work_search.html /scripts/i18n-messages /static/css/legacy.less ` SocialShare.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/macros/databarWork.html /scripts/i18n-messages /static/css/components/shareLinks.less ` SponsorCarousel.html | `` StarRatings.html | `/openlibrary/templates/lists/widget.html /openlibrary/templates/type/edition/view.html ` StarRatingsStats.html | `/openlibrary/templates/type/edition/view.html ` SubjectTags.html | `/openlibrary/templates/type/edition/view.html ` Subnavigation.html | `/openlibrary/templates/type/page/view.html ` TableOfContents.html | `/openlibrary/templates/type/edition/view.html ` ThingReference.html | `/openlibrary/templates/type/language/input.html ` TruncateString.html | `/openlibrary/macros/CoverImage.html /openlibrary/macros/RecentChangesAdmin.html /openlibrary/macros/SRPCoverImage.html /openlibrary/templates/books/custom_carousel.html /openlibrary/templates/covers/book_cover.html /openlibrary/templates/covers/book_cover_single_edition.html ` TypeChanger.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/templates/type/doc/edit.html /openlibrary/templates/type/home/edit.html /openlibrary/templates/type/i18n/edit.html /openlibrary/templates/type/i18n_page/edit.html /openlibrary/templates/type/macro/edit.html /openlibrary/templates/type/page/edit.html /openlibrary/templates/type/permission/edit.html /openlibrary/templates/type/rawtext/edit.html /openlibrary/templates/type/template/edit.html /openlibrary/templates/type/user/edit.html /openlibrary/templates/type/usergroup/edit.html /scripts/i18n-messages ` UniqueIPcount.html | `` UserEditRow.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/templates/type/user/edit.html /scripts/i18n-messages ` UserMetadata.html | `/openlibrary/templates/lists/widget.html ` WorkInfo.html | `/static/css/legacy.less ` WorldcatLink.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/macros/databarWork.html /scripts/i18n-messages ` WorldcatUrl.html | `/openlibrary/macros/WorldcatLink.html ` YouTube.html | `/openlibrary/catalog/add_book/tests/test_data/v38.i37.records.utf8--16478504-1254 /openlibrary/catalog/add_book/tests/test_data/v39.i28.records.utf8--5362776-1764 /scripts/dev-instance/dev_db.pg_dump ` daisy.html | `/openlibrary/core/models.py /openlibrary/core/models.pyc /openlibrary/core/__pycache__/models.cpython-38.pyc /openlibrary/macros/daisy.html /openlibrary/macros/DownloadOptions.html /openlibrary/macros/LoanStatus.html /openlibrary/plugins/openlibrary/js/subjects.js /openlibrary/plugins/upstream/addbook.py /openlibrary/plugins/upstream/addbook.pyc /openlibrary/plugins/upstream/models.py /openlibrary/plugins/upstream/models.pyc /openlibrary/plugins/upstream/__pycache__/addbook.cpython-38.pyc /openlibrary/plugins/upstream/__pycache__/models.cpython-38.pyc /openlibrary/plugins/worksearch/code.py /openlibrary/plugins/worksearch/code.pyc /openlibrary/plugins/worksearch/__pycache__/code.cpython-38.pyc /openlibrary/solr/process_stats.py /openlibrary/solr/process_stats.pyc /openlibrary/solr/__pycache__/process_stats.cpython-38.pyc /openlibrary/templates/books/custom_carousel.html /openlibrary/templates/books/daisy.html /openlibrary/templates/books/edition-sort.html /openlibrary/templates/type/list/embed.html /openlibrary/templates/type/list/view.html /static/css/legacy.less /static/css/page-home.less /static/css/page-plain.less ` databarAuthor.html | `/static/css/components/dropper--tablet.less /static/css/components/dropper.less ` databarDiff.html | `/openlibrary/templates/diff.html /static/css/legacy.less ` databarEdit.html | `/openlibrary/templates/type/author/edit.html /openlibrary/templates/type/list/edit.html /static/css/legacy.less ` databarHistory.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/templates/history.html /scripts/i18n-messages ` databarMerge.html | `` databarTemplate.html | `/openlibrary/templates/type/macro/view.html /openlibrary/templates/type/rawtext/view.html /openlibrary/templates/type/template/view.html ` databarView.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/templates/type/about/view.html /openlibrary/templates/type/author/view.html /openlibrary/templates/type/doc/view.html /openlibrary/templates/type/edition/view.html /openlibrary/templates/type/edition-history/view.html /openlibrary/templates/type/homepage/view.html /openlibrary/templates/type/language/view.html /openlibrary/templates/type/list/view.html /openlibrary/templates/type/local_id/view.html /openlibrary/templates/type/object/view.html /openlibrary/templates/type/page/view.html /openlibrary/templates/type/permission/view.html /openlibrary/templates/type/type/view.html /openlibrary/templates/type/user/view.html /scripts/i18n-messages ` databarWork.html | `/openlibrary/i18n/es/messages.po /openlibrary/i18n/fr/messages.po /openlibrary/i18n/hr/messages.po /openlibrary/i18n/messages.pot /openlibrary/plugins/openlibrary/opds.py /openlibrary/templates/type/edition/view.html /openlibrary/templates/type/edition-history/view.html /scripts/i18n-messages /static/css/components/shareLinks.less /static/css/legacy.less ` databari18n.html | `` i18n.html | `/.github/workflows/python_tests.yml /.pytest_cache/v/cache/lastfailed /.pytest_cache/v/cache/nodeids /0001-TMP-html5-validation.patch /Makefile /openlibrary/code.py /openlibrary/code.pyc /openlibrary/conftest.py /openlibrary/core/helpers.py /openlibrary/core/helpers.pyc /openlibrary/core/loanstats.py /openlibrary/core/loanstats.pyc /openlibrary/core/__pycache__/helpers.cpython-38.pyc /openlibrary/core/__pycache__/loanstats.cpython-38.pyc /openlibrary/i18n/it/starting-strings.it /openlibrary/i18n/mr/starting-strings.mr /openlibrary/i18n/README.md /openlibrary/i18n/__init__.py /openlibrary/i18n/__init__.pyc /openlibrary/i18n/__pycache__/__init__.cpython-38.pyc /openlibrary/macros/AuthorEditRow.html /openlibrary/macros/databarHistory.html /openlibrary/macros/databari18n.html /openlibrary/macros/databarView.html /openlibrary/macros/EditionEditRow.html /openlibrary/macros/HasFulltext.html /openlibrary/macros/HelpFormatting.html /openlibrary/macros/HelpWikilanguage.html /openlibrary/macros/ModifyTemplate.html /openlibrary/macros/MostRecentHome.html /openlibrary/macros/RecentChangesAdmin.html /openlibrary/macros/RecentChangesUsers.html /openlibrary/macros/SearchResults.html /openlibrary/macros/UserEditRow.html /openlibrary/macros/UserMetadata.html /openlibrary/macros/WorkInfo.html /openlibrary/plugins/openlibrary/js/i18n.js /openlibrary/plugins/openlibrary/js/index.js /openlibrary/plugins/openlibrary/js/patron-metadata/index.js /openlibrary/plugins/openlibrary/js/realtime_account_validation.js /openlibrary/plugins/openlibrary/js/validate.js /openlibrary/plugins/openlibrary/tests/test_home.py /openlibrary/plugins/openlibrary/types/i18n.type /openlibrary/plugins/openlibrary/types/i18n_page.type /openlibrary/plugins/upstream/account.py /openlibrary/plugins/upstream/account.pyc /openlibrary/plugins/upstream/addbook.py /openlibrary/plugins/upstream/addbook.pyc /openlibrary/plugins/upstream/code.py /openlibrary/plugins/upstream/code.pyc /openlibrary/plugins/upstream/forms.py /openlibrary/plugins/upstream/forms.pyc /openlibrary/plugins/upstream/__pycache__/account.cpython-38.pyc /openlibrary/plugins/upstream/__pycache__/addbook.cpython-38.pyc /openlibrary/plugins/upstream/__pycache__/code.cpython-38.pyc /openlibrary/plugins/upstream/__pycache__/forms.cpython-38.pyc /openlibrary/templates/type/author/input.html /openlibrary/templates/type/doc/edit.html /openlibrary/templates/type/doc/view.html /openlibrary/templates/type/edition/view.html /openlibrary/templates/type/edition-history/view.html /openlibrary/templates/type/home/edit.html /openlibrary/templates/type/homepage/view.html /openlibrary/templates/type/i18n/edit.html /openlibrary/templates/type/i18n/view.html /openlibrary/templates/type/i18n_page/edit.html /openlibrary/templates/type/i18n_page/view.html /openlibrary/templates/type/macro/edit.html /openlibrary/templates/type/page/view.html /openlibrary/tests/core/test_i18n.py /openlibrary/__pycache__/code.cpython-38.pyc /scripts/dev-instance/dev_db.pg_dump /scripts/i18n-messages /static/css/page-edit.less ` iframe.html | `/openlibrary/macros/BookPreview.html /openlibrary/macros/iframe.html /openlibrary/macros/miframe.html /openlibrary/macros/SocialShare.html /openlibrary/plugins/openlibrary/js/ol.js /openlibrary/templates/covers/add.html /openlibrary/templates/covers/change.html /openlibrary/templates/site/body.html /scripts/2009/01/olpc/src/index.html /scripts/2009/01/olpc/src/js/carousel.js /scripts/2009/01/olpc/src/js/jquery-1.2.6.min.js /scripts/2009/01/olpc/src/js/jquery.cluetip.js /scripts/2009/01/olpc/src/js/yui.css /scripts/2009/01/olpc/src/js/yui.js /static/css/components/cbox.less /static/css/components/preview.less ` miframe.html | ``
SaravgiYash commented 3 years ago

@cdrini I would like to work on this issue.

cdrini commented 3 years ago

Here are the db results:

pv ol_dump_2020-10-31.txt.gz | zcat | grep -i -E '\{\{(AlertChanges|AlertTour|AllPagination|AuthorEditRow|EditionCount|EditionEditRow|EnrollUsergroup|FormatExpiry2|FullTextCount|GoButton|HasFulltext|HelpWikilanguage|MergeHistory|ModifyTemplate|MostRecent|MostRecentHome|NavigationDev|QueryCarousel|RowButtons|SponsorCarousel|UniqueIPcount|databarMerge|databari18n|miframe)' > ~/macro_matches.txt

for macro in AlertChanges AlertTour AllPagination AuthorEditRow EditionCount EditionEditRow EnrollUsergroup FormatExpiry2 FullTextCount GoButton HasFulltext HelpWikilanguage MergeHistory ModifyTemplate MostRecent MostRecentHome NavigationDev QueryCarousel RowButtons SponsorCarousel UniqueIPcount databarMerge databari18n miframe; do echo "$macro | $(grep -i -F $macro ~/macro_matches.txt | cut -f2 | tr '\n' ' ')"; done

cdrini commented 3 years ago

Awesome, thank you @Yashs911 ! Anything with "None" in both columns should be deleteable :)

ArunTeltia commented 3 years ago

I will also start deleting the files :D

cdrini commented 3 years ago

Ah, my apologies @ArunTeltia ! That's my bad, I didn't realize you wanted to work on it as well 🙇

ArunTeltia commented 3 years ago

No Problem I will look into other issues :D @cdrini