-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement book cover feature #12198
base: main
Are you sure you want to change the base?
Implement book cover feature #12198
Conversation
…ion. Add tests for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code currently does not meet JabRef's code guidelines.
We use OpenRewrite to ensure "modern" Java coding practices.
The issues found can be automatically fixed.
Please execute the gradle task rewriteRun
, check the results, commit, and push.
You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
@subhramit May I have your help please - is there anyway to run I am not sure what part of my code is causing it to fail - the report on GitHub says So I am trying to fix any issues in Thank-you! :) |
Run the command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
@damgam0288 right now, checkstyle test is red as well. You can take help from the same FAQ page about what to do. You have to have your IntelliJ configured for the local checkstyle warnings to see which part of the code is causing it. |
No worries, that checkstyle error was a result of a previous trial-and-error attempt with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
Please revert your last commit, and use the gradle sidebar (double click on the task) to fix it. Your JDK is outdated, so using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
I removed it from the drafts, hope that's fine? |
Of course, no problem 👍 Sorry I missed your last message but I think I fixed the rewrite issues? Or is it still a problem? |
No, all good now. Thanks. |
I am re-writing my tests to suit OpenRewrite, then will re-request review |
You don't have to manually "suit" openrewrite when coding. As long as your code works, running the task will refactor it as per openrewrite. You can then just commit and push changes. |
@subhramit The following test was causing an
The error:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While reviewing, it came clear to me that the "architecture" of the solution is wrong.
isImage
is good, the other things maybe not. We need to try out. In your solution, the types with a cover are hard-coded. I would go the extreme other way and show the first image as cover in all cases... Let me describe below:
JabRef offers configurability. For the preview, this is https://docs.jabref.org/setup/preview Read about the syntax at https://docs.jabref.org/collaborative-work/export/customexports.
JabRef should also be "knobless". It should "magically" do something if possible - and not force the user.
Steps:
- Understand
FileLink(filetype)
. Implementation is at org.jabref.logic.layout.format.FileLink#format - Add a jpg image to an entry
- Adapt JabRef prview preferences to use filelink to show that image
- Add a png image to another entry
- Adapt JabReff preview preferences to use filelink+png to show that image
- Adapt FileLink to support "image" as general file type -- it then searches for all image types and returns the first hit. This makes JabRef "knobless", because JabRef automatically finds the image
- Adapt
defaults.put(PREVIEW_STYLE,
inorg.jabref.gui.preferences.JabRefGuiPreferences#JabRefGuiPreferences
to contain your adaption - Adapt
org.jabref.migrations.PreferencesMigrations#upgradePreviewStyle
to migrate to your new style
I think, step 3 is the most challenging
Screenshot of the preferences:
highlightLayoutText(); | ||
this.setHvalue(0); | ||
} | ||
|
||
private String getBookCoverURI() { | ||
if (entry != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this check really necessary? I would convert it into assert entry != null;
@@ -218,14 +218,35 @@ private void setPreviewText(String text) { | |||
layoutText = """ | |||
<html> | |||
<body id="previewBody"> | |||
<div id="content"> %s </div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. See general review comments.
Description
This PR is a first iteration of the feature request for a book cover in JabRef in issue 10120.
Changes
When users add an image as a File for a Book, In-book or Booklet citation with the description "cover", it will appear on the right side of the Preview panel.
Code changes
BibEntry.java
getCoverImageFile
method - searches the Entry's files for an image with theCOVER_TAG
in the descriptionCOVER_TAG
string field - the text that users must include in the file's description to be detected as the book coverisCoverable
method - checks if given Entry type can have a cover imageCOVERABLE_TYPES
COVERABLE_TYPES
field - a list of BibEntry types that can have a book cover (at the moment, this isBook
,In-book
andBooklet
)PreviewViewer.java
setPreviewText
method - edited the HTML to include animg
tag for the book covergetBookCoverURI
method - supplies the source for theimg
tag mentioned aboveBibEntryTest.java
getCoverImageReturnsEmptyIfNoFiles
getCoverImageReturnsEmptyIfNoImageFiles
getCoverImageReturnsEmptyIfEntryIsNotCoverable
getCoverImageDoesNotReturnImagesWithoutCoverDescription
getCoverImageDoesNotReturnDocumentsWithCoverDescription
getCoverImageReturnsCorrectImage
getCoverImageUpdatesWithChangeToDescription
Notes
setPreviewText
method.Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)