Skip to content

Commit

Permalink
allow SemanticScholarAuth without key
Browse files Browse the repository at this point in the history
SQUASHED: AUTO-COMMIT-src-client-fileindex.js,AUTO-COMMIT-src-client-preferences.js,AUTO-COMMIT-src-client-protocols-scholar.js,Merge-branch-gh-pages-of-https-github.com-LivelyKernel-lively4-core-into-gh-pages,
  • Loading branch information
JensLincke committed Mar 4, 2025
1 parent ee18fcf commit d0ac088
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/client/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class Preferences {
AIShadowText: {default: false, short: "complete w/ shadow text (key required)"},
AILukasExperiment: {default: false, short: "AI Lukas Experiment"},
DisableBabelCaching: {default: false, short: "Disable babel transpile caching"},
SemanticScholarAuth: {default: false, short: "use Semantic Scholar API key"},
}
}

Expand Down
22 changes: 14 additions & 8 deletions src/client/protocols/scholar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import focalStorage from "src/external/focalStorage.js";

import {Author, Paper, MicrosoftAcademicEntities} from "src/client/literature.js"

import Preferences from 'src/client/preferences.js';


import _ from 'src/external/lodash/lodash.js';
/*MD
Expand Down Expand Up @@ -122,10 +124,12 @@ export default class SemanticScholarScheme extends Scheme {

var url = this.baseURL + query

var key = await SemanticScholarScheme.ensureSubscriptionKey() // maybe only get... ?
var headers = new Headers({})
if (key) {
headers.set("x-api-key", key)
if (Preferences.get("SemanticScholarAuth")) {
var key = await SemanticScholarScheme.ensureSubscriptionKey() // maybe only get... ?
var headers = new Headers({})
if (key) {
headers.set("x-api-key", key)
}
}

var content = await fetch(url, {
Expand Down Expand Up @@ -157,10 +161,12 @@ fetch("scholar://data/paper/batch?fields=referenceCount,citationCount,title", {

var url = this.baseURL + query

var key = await SemanticScholarScheme.ensureSubscriptionKey() // maybe only get... ?
var headers = new Headers({})
if (key) {
headers.set("x-api-key", key)
if (Preferences.get("SemanticScholarAuth")) {
var key = await SemanticScholarScheme.ensureSubscriptionKey() // maybe only get... ?
var headers = new Headers({})
if (key) {
headers.set("x-api-key", key)
}
}

var content = await fetch(url, {
Expand Down

0 comments on commit d0ac088

Please sign in to comment.