-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Support searching references at Google Scholar & Semantic Scholar #14370
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
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
274c813
Rework openreference PR
subhramit 1895625
Remove some redundant preference parameters
subhramit c1925f2
Run formatter
subhramit 434428d
Openrewrite
subhramit f93ffd5
Remove hilarious copy paste error
subhramit 8a73bce
Almost fix tests
subhramit 5f224ee
Refactor tests
subhramit 24900b7
Fix tests
subhramit 478acea
Use `create`
subhramit ebd6660
Illegal arg
subhramit 7b0f76a
Illegal arg
subhramit 2b0f3d0
Add back omitted tests
subhramit 00294d6
Add back remove latex braces test
subhramit e407071
Maintain test parity
subhramit bf9cd1d
Reformat code
subhramit 77f53cc
Comments
subhramit 5d2c159
Merge branch 'main' into open-reference
subhramit 4632e7e
Remove more redundant parameters
subhramit 96d92e9
Merge remote-tracking branch 'origin/open-reference' into open-reference
subhramit 8964400
boy scout woohoo - remove redundant get calls
subhramit 83d35cb
underscores
subhramit 79c7717
boy scout - remove redundant constructors from `WebSearchTabViewModel`
subhramit b820113
more boy scout
subhramit 85416a4
Merge branch 'main' into open-reference
subhramit d0ae921
Merge branch 'main' into open-reference
subhramit 06c61df
Swap order of search engines
subhramit 8e3e763
Swap constants
subhramit d6d5add
l10n
subhramit 6144478
Use dialogservice.notify, link comment
subhramit 712e5eb
Move isValid to url utils
subhramit afaaa3b
Use JSpecify `@Nullable`
subhramit c4c9b10
Defensive checks, add tests
subhramit 2d7204c
URL checking optimizations
subhramit f77a720
Javadoc
subhramit e47b3ed
fix checkValue
subhramit 83207e3
Reformat URLUtilTest
subhramit d4d843c
Stricter online link check in LinkedFile
subhramit 2af144c
Merge branch 'main' into open-reference
subhramit 4d3484e
Revert "Stricter online link check in LinkedFile"
subhramit 0bda89c
feat(external-search): add Semantic Scholar search
InAnYan ef502f1
chore: fix submodules
InAnYan 8e6316c
try: remove submodule
InAnYan c21889b
fix: submodules
InAnYan 68237f2
fix(search): add proper search for Semantic Scholar when author is pr…
InAnYan da26f2a
Merge remote-tracking branch 'origin/main' into open-reference
koppor c05d993
First the grouping element, then the sub menu elements
koppor ef1aa53
Add CHANGELOG.md entry for the update at UrlChecker
koppor 64a636e
Remove static imports, syserr artifacts and run formatter
subhramit e8718ac
Merge branch 'main' into open-reference
subhramit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
jabgui/src/main/java/org/jabref/gui/maintable/SearchGoogleScholarAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package org.jabref.gui.maintable; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
|
|
||
| import javafx.beans.binding.BooleanExpression; | ||
|
|
||
| import org.jabref.gui.DialogService; | ||
| import org.jabref.gui.StateManager; | ||
| import org.jabref.gui.actions.SimpleCommand; | ||
| import org.jabref.gui.desktop.os.NativeDesktop; | ||
| import org.jabref.gui.preferences.GuiPreferences; | ||
| import org.jabref.logic.l10n.Localization; | ||
| import org.jabref.logic.util.ExternalLinkCreator; | ||
| import org.jabref.model.entry.BibEntry; | ||
| import org.jabref.model.entry.field.StandardField; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import static org.jabref.gui.actions.ActionHelper.isFieldSetForSelectedEntry; | ||
| import static org.jabref.gui.actions.ActionHelper.needsEntriesSelected; | ||
|
|
||
| public class SearchGoogleScholarAction extends SimpleCommand { | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(SearchGoogleScholarAction.class); | ||
|
|
||
| private final DialogService dialogService; | ||
| private final StateManager stateManager; | ||
| private final GuiPreferences preferences; | ||
| private final ExternalLinkCreator externalLinkCreator; | ||
|
|
||
| public SearchGoogleScholarAction(DialogService dialogService, StateManager stateManager, GuiPreferences preferences) { | ||
| this.dialogService = dialogService; | ||
| this.stateManager = stateManager; | ||
| this.preferences = preferences; | ||
|
|
||
| this.externalLinkCreator = new ExternalLinkCreator(preferences.getImporterPreferences()); | ||
|
|
||
| BooleanExpression fieldIsSet = isFieldSetForSelectedEntry(StandardField.TITLE, stateManager); | ||
| this.executable.bind(needsEntriesSelected(1, stateManager).and(fieldIsSet)); | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| stateManager.getActiveDatabase().ifPresent(databaseContext -> { | ||
| final List<BibEntry> bibEntries = stateManager.getSelectedEntries(); | ||
| externalLinkCreator.getGoogleScholarSearchURL(bibEntries.getFirst()).ifPresent(url -> { | ||
| try { | ||
| NativeDesktop.openExternalViewer(databaseContext, preferences, url, StandardField.URL, dialogService, bibEntries.getFirst()); | ||
| } catch (IOException ex) { | ||
| LOGGER.warn("Could not open Google Scholar", ex); | ||
| dialogService.notify(Localization.lang("Unable to open Google Scholar.") + " " + ex.getMessage()); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
55 changes: 55 additions & 0 deletions
55
jabgui/src/main/java/org/jabref/gui/maintable/SearchSemanticScholarAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package org.jabref.gui.maintable; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
|
|
||
| import javafx.beans.binding.BooleanExpression; | ||
|
|
||
| import org.jabref.gui.DialogService; | ||
| import org.jabref.gui.StateManager; | ||
| import org.jabref.gui.actions.ActionHelper; | ||
| import org.jabref.gui.actions.SimpleCommand; | ||
| import org.jabref.gui.desktop.os.NativeDesktop; | ||
| import org.jabref.gui.preferences.GuiPreferences; | ||
| import org.jabref.logic.l10n.Localization; | ||
| import org.jabref.logic.util.ExternalLinkCreator; | ||
| import org.jabref.model.entry.BibEntry; | ||
| import org.jabref.model.entry.field.StandardField; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class SearchSemanticScholarAction extends SimpleCommand { | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(SearchSemanticScholarAction.class); | ||
|
|
||
| private final DialogService dialogService; | ||
| private final StateManager stateManager; | ||
| private final GuiPreferences preferences; | ||
| private final ExternalLinkCreator externalLinkCreator; | ||
|
|
||
| public SearchSemanticScholarAction(DialogService dialogService, StateManager stateManager, GuiPreferences preferences) { | ||
| this.dialogService = dialogService; | ||
| this.stateManager = stateManager; | ||
| this.preferences = preferences; | ||
|
|
||
| this.externalLinkCreator = new ExternalLinkCreator(preferences.getImporterPreferences()); | ||
|
|
||
| BooleanExpression fieldIsSet = ActionHelper.isFieldSetForSelectedEntry(StandardField.TITLE, stateManager); | ||
| this.executable.bind(ActionHelper.needsEntriesSelected(1, stateManager).and(fieldIsSet)); | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| stateManager.getActiveDatabase().ifPresent(databaseContext -> { | ||
| final List<BibEntry> bibEntries = stateManager.getSelectedEntries(); | ||
| externalLinkCreator.getSemanticScholarSearchURL(bibEntries.getFirst()).ifPresent(url -> { | ||
| try { | ||
| NativeDesktop.openExternalViewer(databaseContext, preferences, url, StandardField.URL, dialogService, bibEntries.getFirst()); | ||
| } catch (IOException ex) { | ||
| LOGGER.warn("Could not open Semantic Scholar", ex); | ||
| dialogService.notify(Localization.lang("Unable to open Semantic Scholar.") + " " + ex.getMessage()); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
jabgui/src/main/java/org/jabref/gui/preferences/websearch/SearchEngineItem.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package org.jabref.gui.preferences.websearch; | ||
|
|
||
| import javafx.beans.property.SimpleStringProperty; | ||
| import javafx.beans.property.StringProperty; | ||
|
|
||
| public class SearchEngineItem { | ||
| private final StringProperty name; | ||
| private final StringProperty urlTemplate; | ||
|
|
||
| public SearchEngineItem(String name, String urlTemplate) { | ||
| this.name = new SimpleStringProperty(name); | ||
| this.urlTemplate = new SimpleStringProperty(urlTemplate); | ||
| } | ||
|
|
||
| public StringProperty nameProperty() { | ||
| return name; | ||
| } | ||
|
|
||
| public StringProperty urlTemplateProperty() { | ||
| return urlTemplate; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name.get(); | ||
| } | ||
|
|
||
| public String getUrlTemplate() { | ||
| return urlTemplate.get(); | ||
| } | ||
|
|
||
| public void setUrlTemplate(String urlTemplate) { | ||
| this.urlTemplate.set(urlTemplate); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.