Skip to content

Commit

Permalink
V:: v.0.9.2
Browse files Browse the repository at this point in the history
Data URLs
  • Loading branch information
RussCoder committed Apr 9, 2023
1 parent 96ed1af commit 466f0d1
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "DjVu.js Viewer",
"short_name": "DV",
"version": "0.9.1.0",
"version": "0.9.2.0",
"author": "RussCoder",
"homepage_url": "https://github.com/RussCoder/djvujs",
"description": "Opens links to .djvu files. Allows opening files from a local disk. Processes <object> & <embed> tags.",
Expand Down
4 changes: 4 additions & 0 deletions viewer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# DjVu.js Viewer's Changelog

## v.0.9.2 (09.04.2023)

- Support for "data:" URLs

## v.0.9.1 (01.02.2023)

- Spanish translation update.
Expand Down
2 changes: 1 addition & 1 deletion viewer/src/DjVuViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Events = constant({

export default class DjVuViewer extends EventEmitter {

static VERSION = '0.9.1';
static VERSION = '0.9.2';

static Events = Events;
static Constants = Constants;
Expand Down
7 changes: 4 additions & 3 deletions viewer/src/components/InitialScreen/LinkBlock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ const LinkBlock = () => {
return (
<LinkBlockRoot onSubmit={(e) => {
e.preventDefault();
if (/^https?:\/\/.+/.test(url.trim())) {
const trimmedUrl = url.trim();
if (/((^https?:\/\/)|(^data:)).+/.test(trimmedUrl)) {
dispatch({
type: ActionTypes.LOAD_DOCUMENT_BY_URL,
url: url,
url: trimmedUrl,
});
} else {
alert(t('Enter a valid URL (it should start with "http(s)://")'));
alert(t('Enter a valid URL (it should start with "http(s)://" | "data:")'));
}
}}>
<input
Expand Down
2 changes: 2 additions & 0 deletions viewer/src/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { get } from './reducers';

export default function initHotkeys(store) {
document.addEventListener('keydown', (e) => {
if (!get.isDocumentLoaded(store.getState())) return;

if ((e.key === 's' || e.code === 'KeyS') && e.ctrlKey) { // code property isn't supported in Edge yet
e.preventDefault();
store.dispatch(Actions.tryToSaveDocument());
Expand Down
4 changes: 2 additions & 2 deletions viewer/src/locales/ChineseSimplified.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default {
"在此处粘贴djvu文件的地址",
"Open URL":
"打开地址",
'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL
'输入一个有效的地址 (应当以 "http(s)://" 开头)',
'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL
'输入一个有效的地址 (应当以 "http(s)://" | "data:" 开头)',

// Errors. Usually there is a header and a message for each error type.
// For the web request error there are different types of messages depending on the HTTP status.
Expand Down
4 changes: 2 additions & 2 deletions viewer/src/locales/English.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default {
"Paste a URL to a djvu file here",
"Open URL":
"Open URL",
'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL
'Enter a valid URL (it should start with "http(s)://")',
'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL
'Enter a valid URL (it should start with "http(s)://" | "data:")',

// Errors. Usually there is a header and a message for each error type.
// For the web request error there are different types of messages depending on the HTTP status.
Expand Down
4 changes: 2 additions & 2 deletions viewer/src/locales/French.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default {
"Copier un lien vers un fichier .djvu",
"Open URL":
"Ouvrir le lien",
'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL
'Insérer une URL valide (doit commencer par "http(s)://")',
'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL
'Insérer une URL valide (doit commencer par "http(s)://" | "data:")',

// Errors. Usually there is a header and a message for each error type.
// For the web request error there are different types of messages depending on the HTTP status.
Expand Down
4 changes: 2 additions & 2 deletions viewer/src/locales/Italian.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default {
"Incolla qui l'URL al file DjVu",
"Open URL":
"Apri URL",
'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL
'Inserire un URL valido (deve iniziare con "http(s)://")',
'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL
'Inserire un URL valido (deve iniziare con "http(s)://" | "data:")',

// Errors. Usually there is a header and a message for each error type.
// For the web request error there are different types of messages depending on the HTTP status.
Expand Down
4 changes: 2 additions & 2 deletions viewer/src/locales/Portuguese.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default {
"Colar aqui um URL a um ficheiro djvu",
"Open URL":
"Abrir URL",
'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL
'Introduza um URL válido (deve começar com "http(s)://")',
'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL
'Introduza um URL válido (deve começar com "http(s)://" | "data:")',

// Errors. Usually there is a header and a message for each error type.
// For the web request error there are different types of messages depending on the HTTP status.
Expand Down
4 changes: 2 additions & 2 deletions viewer/src/locales/Russian.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export default {
"Вставьте ссылку на .djvu файл",
"Open URL":
"Открыть ссылку",
'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL
'Введите корректную ссылку (она должна начинаться с "http(s)://")',
'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL
'Введите корректную ссылку (она должна начинаться с "http(s)://" | "data:")',

// Errors. Usually there is a header and a message for each error type.
// For the web request error there are different types of messages depending on the HTTP status.
Expand Down
4 changes: 2 additions & 2 deletions viewer/src/locales/Spanish.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default {
"Pegar una URL al archivo djvu aquí",
"Open URL":
"Abrir URL",
'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL
'Introducir una URL válida (debe comenzar con "http(s)://")',
'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL
'Introducir una URL válida (debe comenzar con "http(s)://" | "data:")',

// Errors. Usually there is a header and a message for each error type.
// For the web request error there are different types of messages depending on the HTTP status.
Expand Down
2 changes: 1 addition & 1 deletion viewer/src/locales/Swedish.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default {
"Klistra in en URL till en .djvu-fil här",
"Open URL":
"Öppna URL",
'Enter a valid URL (it should start with "http(s)://")': // an alert shown when you try to open an empty URL
'Enter a valid URL (it should start with "http(s)://" | "data:")': // an alert shown when you try to open an empty URL
'Ange en giltig URL (den ska börja med "http (s): //")',

// Errors. Usually there is a header and a message for each error type.
Expand Down
2 changes: 1 addition & 1 deletion viewer/src/sagas/rootSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class RootSaga {
}

// responseUrl is the URL after all redirects
config.djvuOptions = { baseUrl: new URL('./', responseURL).href };
config.djvuOptions = { baseUrl: url.startsWith('data:') ? null : new URL('./', responseURL).href };
yield* this.createDocumentFromArrayBuffer({
arrayBuffer: buffer,
fileName: config.name === undefined ? getFileNameFromUrl(url) : config.name,
Expand Down

0 comments on commit 466f0d1

Please sign in to comment.