Add support for book front covers, again#14777
Conversation
…book-front-cover-10120
…ded experimental "covers" subfolder
…SuggestedFileName()
…ionalNotPresentToIsEmpty
…changed single wrong isEmpty to isPresent
| return Optional.empty(); | ||
| } | ||
| String realFileNameString = realFileName.toString(); | ||
| String extension = FilenameUtils.getExtension(realFileNameString); |
There was a problem hiding this comment.
I think we should use our own implementation here for getFileExtension and getBaseName, because other implementations will have different goals and behaviour, and then we have control over how it works.
Specifically:
- FilenameUtils.getExtension doesn't trim whitspace or convert to lowercase ("file.PdF " gives "PdF " instead of "pdf")
- FilenameUtils.getBaseName appears to use both windows and unix path seperators (a/b\c" gives "c" on all operating systems instead of either "b\c" or "c")
- FilenameUtils.getBaseName treats files starting with a dot as extensions (".name" gives "" instead of ".name")
Alternatively, we could use FilenameUtils and just explicity cover its edge cases, though this may be hard for the path seperator issue.
There was a problem hiding this comment.
I am not sure about the casings - lets see, what happens. Maybe, you see the consequences.
b\c is a fucked-up filename.
FilenameUtils.getBaseName is patched to reteurn .tmp for .tmp . See tetts for .StartsWithADotIsNotAnExtension
| LOGGER.warn("Was not a valid URL {}", link, e); | ||
| return Optional.empty(); | ||
| } | ||
| Path fileName = Path.of(uri.getPath()).getFileName(); |
There was a problem hiding this comment.
Path.of(uri.getPath()).getFileName() will get the directory if there is no file name, instead of a null or empty string ("https://www.example.com/path/to/" gives "to")
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
* upstream/main: (64 commits) New Crowdin updates (JabRef#14862) Make JDK25 available (JabRef#14861) Fix empty entries array when exporting group chat to JSON (JabRef#14814) feat: add right-click copy context menu to AI chat messages (JabRef#14722) FIX : generic error dialog and icon in Source Tab parsing (JabRef#14828) Factor out setup-* actions (JabRef#14859) Link .http files. Update dependency org.postgresql:postgresql to v42.7.9 (JabRef#14857) Add more commands to JabSrv (JabRef#14855) Fix JabRef#14821: Hide identifier action buttons when field is empty (JabRef#14831) Add GH_TOKEN to closed issues/PRs processing step New Crowdin updates (JabRef#14854) New Crowdin updates (JabRef#14849) Chore(deps): Bump jablib/src/main/resources/csl-styles from `0201999` to `f345aa8` (JabRef#14833) Add support for book front covers, again (JabRef#14777) Readd min width to button in new enty dialog (JabRef#14791) Replace plugin impl from jbang plugin (JabRef#14846) Revise AI policy wording Chore(deps): Bump jablib/src/main/resources/csl-locales (JabRef#14677) Update dependency com.konghq:unirest-modules-gson to v4.7.1 (JabRef#14845) ...
User description
Closes #10120
This pull request adds support for cover images which can display in the preview of entries. It also allows new entries to automatically download cover images from either "https://bookcover.longitood.com" or "https://covers.openlibrary.org", and preferences to control downloading behaviour. Key changes are:
PreviewViewerto display imagesBookCoverFetcherclass to download cover imagesNewEntryViewModelto do cover fetchingFilePreferencesandLinkedFilesTabSteps to test
Mandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)Images
PR Type
Enhancement
Description
Add book cover image support for entry previews
Implement automatic cover downloading from ISBN via two APIs
Add user preference to control cover image downloading behavior
Refactor file utility methods for better URL and filename handling
Diagram Walkthrough
File Walkthrough
17 files
New class for downloading book cover imagesAdd cover image display in preview panelIntegrate cover fetching into entry creationAdd UI checkbox for cover download preferenceAdd property binding for cover download settingAdd cover download preference propertyAdd NullMarked annotation for null safetyAdd method to get cover image directoryRefactor filename extraction from URLsAdd method to extract filename from linkSimplify filename suggestion logicUse Files API instead of File.existsUse Files API for directory checksUse Files API for directory checksUse Files API for path existence checkUse Files API for path existence checkAdd checkbox UI for cover download preference2 files
Add preference storage for cover image downloadAdd permissions for workflow execution2 files
Use FileUtil for URL filename extractionRemove duplicate URL filename extraction8 files
Add helper method for file existence assertionsAdd file existence assertion helper methodsUse new file assertion helper methodsUse new file assertion helper methodsUse new file assertion helper methodsUse new file assertion helper methodsExpand test coverage for filename suggestionsAdd comprehensive URL filename extraction tests4 files
Add localization for cover download optionDocument book cover image feature additionAdd privacy policies for cover image APIsUpdate image paths to assets directory1 files