Skip to content

feat: support open reference at google scholar #13153

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

brandon-lau0
Copy link
Contributor

@brandon-lau0 brandon-lau0 commented May 20, 2025

Summary of Changes

This PR adds a new "Search Google Scholar" feature to JabRef, similar to the existing "Search ShortScience" functionality. The feature allows users to quickly search for a selected entry's title in Google Scholar directly from the main table's context menu. Addresses feature in #12268.

Changes:

  • Added new SearchGoogleScholarAction class
  • Added Google Scholar search URL builder in ExternalLinkCreator
  • Added localization strings for all supported languages
  • Integrated the feature into the right-click context menu

The feature is enabled when a single entry with a title field is selected. Clicking the menu item opens the default browser with a Google Scholar search for the entry's title.

Collaborators

@lydia-yan @yoasaaa @brandon-lau0 @FlyJoanne

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • [.] Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • [.] Tests created for changes (if applicable)
  • [.] Manually tested changed features in running JabRef (always required)
  • [.] Screenshots added in PR description (if change is visible to the user)
  • [.] Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • [.] Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@@ -37,6 +37,7 @@ public enum StandardActions implements Action {
EXTRACT_FILE_REFERENCES_OFFLINE(Localization.lang("Extract references from file (offline)"), IconTheme.JabRefIcons.FILE_STAR),
OPEN_URL(Localization.lang("Open URL or DOI"), IconTheme.JabRefIcons.WWW, KeyBinding.OPEN_URL_OR_DOI),
SEARCH_SHORTSCIENCE(Localization.lang("Search ShortScience")),
SEARCH_GOOGLE_SCHOLAR(Localization.lang("Search Google Scholar")),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new action 'SEARCH_GOOGLE_SCHOLAR' uses title case for its label. According to the guidelines, all labels and texts should be in sentence case.

@@ -102,6 +102,7 @@ public static ContextMenu create(BibEntryTableViewModel entry,

factory.createMenuItem(StandardActions.OPEN_URL, new OpenUrlAction(dialogService, stateManager, preferences)),
factory.createMenuItem(StandardActions.SEARCH_SHORTSCIENCE, new SearchShortScienceAction(dialogService, stateManager, preferences)),
factory.createMenuItem(StandardActions.SEARCH_GOOGLE_SCHOLAR, new SearchGoogleScholarAction(dialogService, stateManager, preferences)),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request title should contain a short title of the issue fixed or what the PR addresses, not just 'Fix issue xyz'. This ensures clarity and context for the changes made.

final List<BibEntry> bibEntries = stateManager.getSelectedEntries();

if (bibEntries.size() != 1) {
dialogService.notify(Localization.lang("This operation requires exactly one item to be selected."));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The notification message should be in sentence case, not title case, to maintain consistency with other user interface text.

uriBuilder = new URIBuilder(GOOGLE_SCHOLAR_SEARCH_URL);
} catch (URISyntaxException e) {
// This should never be able to happen as it would require the field to be misconfigured.
throw new AssertionError("Google Scholar URL is invalid.", e);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using exceptions for control flow is not recommended. The code should handle the exception in a way that doesn't rely on throwing an AssertionError for expected conditions.

@jabref-machine
Copy link
Collaborator

Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. You can see which checks are failing by locating the box "Some checks were not successful" on the pull request page. To see the test output, locate "Tests / Checkstyle (pull_request)" and click on it.

In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports.

Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues, commit, and push.

@jabref-machine
Copy link
Collaborator

Note that your PR will not be reviewed/accepted until you have gone through the mandatory checks in the description and marked each of them them exactly in the format of [x] (done), [ ] (not done yet) or [/] (not applicable).

@koppor
Copy link
Member

koppor commented May 20, 2025

Update following are wrong comments; the feature is about opening using the web browser

Please investigate org.jabref.logic.importer.fetcher.GoogleScholar and read on at https://devdocs.jabref.org/code-howtos/fetchers.html.

Also look at #7075

You can try to work on JabRef#695.

@koppor koppor changed the title feat: support searching via google scholar feat: support open reference at google scholar May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants