Skip to content

Commit

Permalink
fix(widget): support encoded doi and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Reddine authored and AOelen committed Nov 20, 2024
1 parent 3bc2cb4 commit 1d5224c
Show file tree
Hide file tree
Showing 7 changed files with 2,123 additions and 2,505 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,5 @@
"parserOptions": {
"project": "./tsconfig.json"
},
"ignorePatterns": ["next.config.js"]
"ignorePatterns": ["next.config.js", "widget/*", "public/widget.js"]
}
2 changes: 1 addition & 1 deletion public/widget.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
]
},
"include": ["commitlint.config.ts", "jest.config.ts", "src", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "widget/node_modules"]
}
4 changes: 2 additions & 2 deletions widget/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ORKG Widget Documentation

bundle size: **9.08 kB**
bundle size: **8.97 kB**

### How to use:

Expand Down Expand Up @@ -54,7 +54,7 @@ The orkg widget uses this following html template to render the widget:

### Building

minimum supported Node.js version is `14.15.0`
minimum supported Node.js version is `18.12.0`

```
npm run build
Expand Down
4,588 changes: 2,103 additions & 2,485 deletions widget/package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"start": "./node_modules/.bin/webpack serve --port=9060 --mode=development"
},
"devDependencies": {
"@babel/core": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"babel-loader": "^9.1.2",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.3",
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"babel-loader": "^9.2.1",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"file-loader": "^6.2.0",
"html-loader": "^4.2.0",
"style-loader": "^3.3.2",
"terser-webpack-plugin": "^5.3.7",
"html-loader": "^5.1.0",
"style-loader": "^4.0.0",
"terser-webpack-plugin": "^5.3.10",
"url-loader": "^4.1.1",
"webpack": "^5.79.0",
"webpack-cli": "^5.0.1"
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4"
}
}
10 changes: 5 additions & 5 deletions widget/src/views/paper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ const dictionary = {
},
};

export const getItemByDoi = doi => {
export const getItemByDoi = (doi) => {
// http://localhost:8000/api/widgets/?doi=10.1007/s00799-015-0158-y
const url = `${process.env.BACKEND_URL}widgets/?doi=${encodeURIComponent(doi)}`;
const url = `${process.env.BACKEND_URL}widgets/?doi=${encodeURIComponent(decodeURIComponent(doi))}`;
return new Promise((resolve, reject) => {
fetch(url)
.then(response => {
.then((response) => {
if (!response.ok) {
const error = new Error(`Error response. (${response.status}) ${response.statusText}`);
error.statusCode = response.status;
Expand All @@ -33,7 +33,7 @@ export const getItemByDoi = doi => {
jsonPromise.then(resolve).catch(reject); // Resolving or rejecting based on the promise
}
})
.catch(error => {
.catch((error) => {
reject(error); // Rejecting with the caught error
});
});
Expand All @@ -57,7 +57,7 @@ export function show(params) {
// Paper DOI
const doi = ORKGWidget.getAttribute('data-doi');
getItemByDoi(doi)
.then(result => {
.then((result) => {
temporary.getElementsByClassName('orkg-widget-txt-link')[0].textContent = dictionary.open[language];
temporary.getElementsByClassName('orkg-widget-text-statements')[0].textContent = dictionary.numStatements[language];
let url = `${process.env.FRONTEND_SERVER_URL}paper/${result.id}`;
Expand Down

0 comments on commit 1d5224c

Please sign in to comment.