mirror of https://github.com/miniflux/v2.git
Merge branch 'main' into patch-2
This commit is contained in:
commit
be2d507a9d
|
@ -35,8 +35,3 @@ func CharsetReader(charsetLabel string, input io.Reader) (io.Reader, error) {
|
||||||
// Transform document to UTF-8 from the specified encoding in XML prolog.
|
// Transform document to UTF-8 from the specified encoding in XML prolog.
|
||||||
return charset.NewReaderLabel(charsetLabel, r)
|
return charset.NewReaderLabel(charsetLabel, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CharsetReaderFromContentType is used when the encoding is not specified for the input document.
|
|
||||||
func CharsetReaderFromContentType(contentType string, input io.Reader) (io.Reader, error) {
|
|
||||||
return charset.NewReader(input, contentType)
|
|
||||||
}
|
|
||||||
|
|
|
@ -15,11 +15,11 @@ import (
|
||||||
"miniflux.app/v2/internal/config"
|
"miniflux.app/v2/internal/config"
|
||||||
"miniflux.app/v2/internal/crypto"
|
"miniflux.app/v2/internal/crypto"
|
||||||
"miniflux.app/v2/internal/model"
|
"miniflux.app/v2/internal/model"
|
||||||
"miniflux.app/v2/internal/reader/encoding"
|
|
||||||
"miniflux.app/v2/internal/reader/fetcher"
|
"miniflux.app/v2/internal/reader/fetcher"
|
||||||
"miniflux.app/v2/internal/urllib"
|
"miniflux.app/v2/internal/urllib"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
"golang.org/x/net/html/charset"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IconFinder struct {
|
type IconFinder struct {
|
||||||
|
@ -191,7 +191,7 @@ func findIconURLsFromHTMLDocument(body io.Reader, contentType string) ([]string,
|
||||||
"link[rel='apple-touch-icon-precomposed.png']",
|
"link[rel='apple-touch-icon-precomposed.png']",
|
||||||
}
|
}
|
||||||
|
|
||||||
htmlDocumentReader, err := encoding.CharsetReaderFromContentType(contentType, body)
|
htmlDocumentReader, err := charset.NewReader(body, contentType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("icon: unable to create charset reader: %w", err)
|
return nil, fmt.Errorf("icon: unable to create charset reader: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"miniflux.app/v2/internal/config"
|
"miniflux.app/v2/internal/config"
|
||||||
"miniflux.app/v2/internal/reader/encoding"
|
|
||||||
"miniflux.app/v2/internal/reader/fetcher"
|
"miniflux.app/v2/internal/reader/fetcher"
|
||||||
"miniflux.app/v2/internal/reader/readability"
|
"miniflux.app/v2/internal/reader/readability"
|
||||||
"miniflux.app/v2/internal/urllib"
|
"miniflux.app/v2/internal/urllib"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
"golang.org/x/net/html/charset"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ScrapeWebsite(requestBuilder *fetcher.RequestBuilder, websiteURL, rules string) (string, error) {
|
func ScrapeWebsite(requestBuilder *fetcher.RequestBuilder, websiteURL, rules string) (string, error) {
|
||||||
|
@ -42,9 +42,9 @@ func ScrapeWebsite(requestBuilder *fetcher.RequestBuilder, websiteURL, rules str
|
||||||
var content string
|
var content string
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
htmlDocumentReader, err := encoding.CharsetReaderFromContentType(
|
htmlDocumentReader, err := charset.NewReader(
|
||||||
responseHandler.ContentType(),
|
|
||||||
responseHandler.Body(config.Opts.HTTPClientMaxBodySize()),
|
responseHandler.Body(config.Opts.HTTPClientMaxBodySize()),
|
||||||
|
responseHandler.ContentType(),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("scraper: unable to read HTML document: %v", err)
|
return "", fmt.Errorf("scraper: unable to read HTML document: %v", err)
|
||||||
|
|
|
@ -14,12 +14,12 @@ import (
|
||||||
"miniflux.app/v2/internal/integration/rssbridge"
|
"miniflux.app/v2/internal/integration/rssbridge"
|
||||||
"miniflux.app/v2/internal/locale"
|
"miniflux.app/v2/internal/locale"
|
||||||
"miniflux.app/v2/internal/model"
|
"miniflux.app/v2/internal/model"
|
||||||
"miniflux.app/v2/internal/reader/encoding"
|
|
||||||
"miniflux.app/v2/internal/reader/fetcher"
|
"miniflux.app/v2/internal/reader/fetcher"
|
||||||
"miniflux.app/v2/internal/reader/parser"
|
"miniflux.app/v2/internal/reader/parser"
|
||||||
"miniflux.app/v2/internal/urllib"
|
"miniflux.app/v2/internal/urllib"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
"golang.org/x/net/html/charset"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -150,7 +150,7 @@ func (f *SubscriptionFinder) FindSubscriptionsFromWebPage(websiteURL, contentTyp
|
||||||
"link[type='application/feed+json']": parser.FormatJSON,
|
"link[type='application/feed+json']": parser.FormatJSON,
|
||||||
}
|
}
|
||||||
|
|
||||||
htmlDocumentReader, err := encoding.CharsetReaderFromContentType(contentType, body)
|
htmlDocumentReader, err := charset.NewReader(body, contentType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, locale.NewLocalizedErrorWrapper(err, "error.unable_to_parse_html_document", err)
|
return nil, locale.NewLocalizedErrorWrapper(err, "error.unable_to_parse_html_document", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,10 @@
|
||||||
|
|
||||||
{{ if and .user .user.Stylesheet }}
|
{{ if and .user .user.Stylesheet }}
|
||||||
{{ $stylesheetNonce := nonce }}
|
{{ $stylesheetNonce := nonce }}
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src * data:; media-src *; frame-src *; style-src 'self' 'nonce-{{ $stylesheetNonce }}'">
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src * data:; media-src *; frame-src *; style-src 'self' 'nonce-{{ $stylesheetNonce }}'; require-trusted-types-for 'script'; trusted-types ttpolicy;">
|
||||||
<style nonce="{{ $stylesheetNonce }}">{{ .user.Stylesheet | safeCSS }}</style>
|
<style nonce="{{ $stylesheetNonce }}">{{ .user.Stylesheet | safeCSS }}</style>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src * data:; media-src *; frame-src *">
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src * data:; media-src *; frame-src *; require-trusted-types-for 'script'; trusted-types ttpolicy;">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<script src="{{ route "javascript" "name" "app" "checksum" .app_js_checksum }}" defer></script>
|
<script src="{{ route "javascript" "name" "app" "checksum" .app_js_checksum }}" defer></script>
|
||||||
|
|
|
@ -352,7 +352,7 @@ function handleFetchOriginalContent() {
|
||||||
|
|
||||||
response.json().then((data) => {
|
response.json().then((data) => {
|
||||||
if (data.hasOwnProperty("content") && data.hasOwnProperty("reading_time")) {
|
if (data.hasOwnProperty("content") && data.hasOwnProperty("reading_time")) {
|
||||||
document.querySelector(".entry-content").innerHTML = data.content;
|
document.querySelector(".entry-content").innerHTML = ttpolicy.createHTML(data.content);
|
||||||
const entryReadingtimeElement = document.querySelector(".entry-reading-time");
|
const entryReadingtimeElement = document.querySelector(".entry-reading-time");
|
||||||
if (entryReadingtimeElement) {
|
if (entryReadingtimeElement) {
|
||||||
entryReadingtimeElement.textContent = data.reading_time;
|
entryReadingtimeElement.textContent = data.reading_time;
|
||||||
|
|
|
@ -2,7 +2,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
handleSubmitButtons();
|
handleSubmitButtons();
|
||||||
|
|
||||||
if (!document.querySelector("body[data-disable-keyboard-shortcuts=true]")) {
|
if (!document.querySelector("body[data-disable-keyboard-shortcuts=true]")) {
|
||||||
let keyboardHandler = new KeyboardHandler();
|
const keyboardHandler = new KeyboardHandler();
|
||||||
keyboardHandler.on("g u", () => goToPage("unread"));
|
keyboardHandler.on("g u", () => goToPage("unread"));
|
||||||
keyboardHandler.on("g b", () => goToPage("starred"));
|
keyboardHandler.on("g b", () => goToPage("starred"));
|
||||||
keyboardHandler.on("g h", () => goToPage("history"));
|
keyboardHandler.on("g h", () => goToPage("history"));
|
||||||
|
@ -48,7 +48,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
keyboardHandler.listen();
|
keyboardHandler.listen();
|
||||||
}
|
}
|
||||||
|
|
||||||
let touchHandler = new TouchHandler();
|
const touchHandler = new TouchHandler();
|
||||||
touchHandler.listen();
|
touchHandler.listen();
|
||||||
|
|
||||||
if (WebAuthnHandler.isWebAuthnSupported()) {
|
if (WebAuthnHandler.isWebAuthnSupported()) {
|
||||||
|
@ -56,7 +56,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
|
||||||
onClick("#webauthn-delete", () => { webauthnHandler.removeAllCredentials(); });
|
onClick("#webauthn-delete", () => { webauthnHandler.removeAllCredentials(); });
|
||||||
|
|
||||||
let registerButton = document.getElementById("webauthn-register");
|
const registerButton = document.getElementById("webauthn-register");
|
||||||
if (registerButton != null) {
|
if (registerButton != null) {
|
||||||
registerButton.disabled = false;
|
registerButton.disabled = false;
|
||||||
|
|
||||||
|
@ -65,13 +65,13 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let loginButton = document.getElementById("webauthn-login");
|
const loginButton = document.getElementById("webauthn-login");
|
||||||
if (loginButton != null) {
|
if (loginButton != null) {
|
||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
loginButton.disabled = false;
|
loginButton.disabled = false;
|
||||||
|
|
||||||
onClick("#webauthn-login", () => {
|
onClick("#webauthn-login", () => {
|
||||||
let usernameField = document.getElementById("form-username");
|
const usernameField = document.getElementById("form-username");
|
||||||
if (usernameField != null) {
|
if (usernameField != null) {
|
||||||
abortController.abort();
|
abortController.abort();
|
||||||
webauthnHandler.login(usernameField.value).catch(err => WebAuthnHandler.showErrorMessage(err));
|
webauthnHandler.login(usernameField.value).catch(err => WebAuthnHandler.showErrorMessage(err));
|
||||||
|
@ -89,7 +89,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
onClick(":is(a, button)[data-action=markPageAsRead]", (event) => handleConfirmationMessage(event.target, markPageAsRead));
|
onClick(":is(a, button)[data-action=markPageAsRead]", (event) => handleConfirmationMessage(event.target, markPageAsRead));
|
||||||
onClick(":is(a, button)[data-toggle-status]", (event) => handleEntryStatus("next", event.target));
|
onClick(":is(a, button)[data-toggle-status]", (event) => handleEntryStatus("next", event.target));
|
||||||
onClick(":is(a, button)[data-confirm]", (event) => handleConfirmationMessage(event.target, (url, redirectURL) => {
|
onClick(":is(a, button)[data-confirm]", (event) => handleConfirmationMessage(event.target, (url, redirectURL) => {
|
||||||
let request = new RequestBuilder(url);
|
const request = new RequestBuilder(url);
|
||||||
|
|
||||||
request.withCallback((response) => {
|
request.withCallback((response) => {
|
||||||
if (redirectURL) {
|
if (redirectURL) {
|
||||||
|
@ -127,9 +127,9 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
onClick(".header nav li", (event) => onClickMainMenuListItem(event));
|
onClick(".header nav li", (event) => onClickMainMenuListItem(event));
|
||||||
|
|
||||||
if ("serviceWorker" in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
let scriptElement = document.getElementById("service-worker-script");
|
const scriptElement = document.getElementById("service-worker-script");
|
||||||
if (scriptElement) {
|
if (scriptElement) {
|
||||||
navigator.serviceWorker.register(scriptElement.src);
|
navigator.serviceWorker.register(ttpolicy.createScriptURL(scriptElement.src));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,17 +4,17 @@ class DomHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
static openNewTab(url) {
|
static openNewTab(url) {
|
||||||
let win = window.open("");
|
const win = window.open("");
|
||||||
win.opener = null;
|
win.opener = null;
|
||||||
win.location = url;
|
win.location = url;
|
||||||
win.focus();
|
win.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
static scrollPageTo(element, evenIfOnScreen) {
|
static scrollPageTo(element, evenIfOnScreen) {
|
||||||
let windowScrollPosition = window.pageYOffset;
|
const windowScrollPosition = window.pageYOffset;
|
||||||
let windowHeight = document.documentElement.clientHeight;
|
const windowHeight = document.documentElement.clientHeight;
|
||||||
let viewportPosition = windowScrollPosition + windowHeight;
|
const viewportPosition = windowScrollPosition + windowHeight;
|
||||||
let itemBottomPosition = element.offsetTop + element.offsetHeight;
|
const itemBottomPosition = element.offsetTop + element.offsetHeight;
|
||||||
|
|
||||||
if (evenIfOnScreen || viewportPosition - itemBottomPosition < 0 || viewportPosition - element.offsetTop > windowHeight) {
|
if (evenIfOnScreen || viewportPosition - itemBottomPosition < 0 || viewportPosition - element.offsetTop > windowHeight) {
|
||||||
window.scrollTo(0, element.offsetTop - 10);
|
window.scrollTo(0, element.offsetTop - 10);
|
||||||
|
|
|
@ -12,7 +12,7 @@ class KeyboardHandler {
|
||||||
|
|
||||||
listen() {
|
listen() {
|
||||||
document.onkeydown = (event) => {
|
document.onkeydown = (event) => {
|
||||||
let key = this.getKey(event);
|
const key = this.getKey(event);
|
||||||
if (this.isEventIgnored(event, key) || this.isModifierKeyDown(event)) {
|
if (this.isEventIgnored(event, key) || this.isModifierKeyDown(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ class KeyboardHandler {
|
||||||
|
|
||||||
this.queue.push(key);
|
this.queue.push(key);
|
||||||
|
|
||||||
for (let combination in this.shortcuts) {
|
for (const combination in this.shortcuts) {
|
||||||
let keys = combination.split(" ");
|
const keys = combination.split(" ");
|
||||||
|
|
||||||
if (keys.every((value, index) => value === this.queue[index])) {
|
if (keys.every((value, index) => value === this.queue[index])) {
|
||||||
this.queue = [];
|
this.queue = [];
|
||||||
|
@ -64,7 +64,7 @@ class KeyboardHandler {
|
||||||
'Right': 'ArrowRight'
|
'Right': 'ArrowRight'
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let key in mapping) {
|
for (const key in mapping) {
|
||||||
if (mapping.hasOwnProperty(key) && key === event.key) {
|
if (mapping.hasOwnProperty(key) && key === event.key) {
|
||||||
return mapping[key];
|
return mapping[key];
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ModalHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
static getFocusableElements() {
|
static getFocusableElements() {
|
||||||
let container = this.getModalContainer();
|
const container = this.getModalContainer();
|
||||||
|
|
||||||
if (container === null) {
|
if (container === null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -18,14 +18,14 @@ class ModalHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
static setupFocusTrap() {
|
static setupFocusTrap() {
|
||||||
let focusableElements = this.getFocusableElements();
|
const focusableElements = this.getFocusableElements();
|
||||||
|
|
||||||
if (focusableElements === null) {
|
if (focusableElements === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let firstFocusableElement = focusableElements[0];
|
const firstFocusableElement = focusableElements[0];
|
||||||
let lastFocusableElement = focusableElements[focusableElements.length - 1];
|
const lastFocusableElement = focusableElements[focusableElements.length - 1];
|
||||||
|
|
||||||
this.getModalContainer().onkeydown = (e) => {
|
this.getModalContainer().onkeydown = (e) => {
|
||||||
if (e.key !== 'Tab') {
|
if (e.key !== 'Tab') {
|
||||||
|
@ -57,13 +57,13 @@ class ModalHandler {
|
||||||
|
|
||||||
this.activeElement = document.activeElement;
|
this.activeElement = document.activeElement;
|
||||||
|
|
||||||
let container = document.createElement("div");
|
const container = document.createElement("div");
|
||||||
container.id = "modal-container";
|
container.id = "modal-container";
|
||||||
container.setAttribute("role", "dialog");
|
container.setAttribute("role", "dialog");
|
||||||
container.appendChild(document.importNode(fragment, true));
|
container.appendChild(document.importNode(fragment, true));
|
||||||
document.body.appendChild(container);
|
document.body.appendChild(container);
|
||||||
|
|
||||||
let closeButton = document.querySelector("button.btn-close-modal");
|
const closeButton = document.querySelector("button.btn-close-modal");
|
||||||
if (closeButton !== null) {
|
if (closeButton !== null) {
|
||||||
closeButton.onclick = (event) => {
|
closeButton.onclick = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -89,7 +89,7 @@ class ModalHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
static close() {
|
static close() {
|
||||||
let container = this.getModalContainer();
|
const container = this.getModalContainer();
|
||||||
if (container !== null) {
|
if (container !== null) {
|
||||||
container.parentNode.removeChild(container);
|
container.parentNode.removeChild(container);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ class TouchHandler {
|
||||||
|
|
||||||
calculateDistance() {
|
calculateDistance() {
|
||||||
if (this.touch.start.x >= -1 && this.touch.move.x >= -1) {
|
if (this.touch.start.x >= -1 && this.touch.move.x >= -1) {
|
||||||
let horizontalDistance = Math.abs(this.touch.move.x - this.touch.start.x);
|
const horizontalDistance = Math.abs(this.touch.move.x - this.touch.start.x);
|
||||||
let verticalDistance = Math.abs(this.touch.move.y - this.touch.start.y);
|
const verticalDistance = Math.abs(this.touch.move.y - this.touch.start.y);
|
||||||
|
|
||||||
if (horizontalDistance > 30 && verticalDistance < 70 || this.touch.moved) {
|
if (horizontalDistance > 30 && verticalDistance < 70 || this.touch.moved) {
|
||||||
return this.touch.move.x - this.touch.start.x;
|
return this.touch.move.x - this.touch.start.x;
|
||||||
|
@ -54,8 +54,8 @@ class TouchHandler {
|
||||||
this.touch.move.x = event.touches[0].clientX;
|
this.touch.move.x = event.touches[0].clientX;
|
||||||
this.touch.move.y = event.touches[0].clientY;
|
this.touch.move.y = event.touches[0].clientY;
|
||||||
|
|
||||||
let distance = this.calculateDistance();
|
const distance = this.calculateDistance();
|
||||||
let absDistance = Math.abs(distance);
|
const absDistance = Math.abs(distance);
|
||||||
|
|
||||||
if (absDistance > 0) {
|
if (absDistance > 0) {
|
||||||
this.touch.moved = true;
|
this.touch.moved = true;
|
||||||
|
@ -78,7 +78,7 @@ class TouchHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.touch.element !== null) {
|
if (this.touch.element !== null) {
|
||||||
let absDistance = Math.abs(this.calculateDistance());
|
const absDistance = Math.abs(this.calculateDistance());
|
||||||
|
|
||||||
if (absDistance > 75) {
|
if (absDistance > 75) {
|
||||||
toggleEntryStatus(this.touch.element);
|
toggleEntryStatus(this.touch.element);
|
||||||
|
@ -118,9 +118,9 @@ class TouchHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let distance = this.calculateDistance();
|
const distance = this.calculateDistance();
|
||||||
let absDistance = Math.abs(distance);
|
const absDistance = Math.abs(distance);
|
||||||
let now = Date.now();
|
const now = Date.now();
|
||||||
|
|
||||||
if (now - this.touch.time <= 1000 && absDistance > 75) {
|
if (now - this.touch.time <= 1000 && absDistance > 75) {
|
||||||
if (distance > 0) {
|
if (distance > 0) {
|
||||||
|
@ -138,10 +138,10 @@ class TouchHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let now = Date.now();
|
const now = Date.now();
|
||||||
|
|
||||||
if (this.touch.start.x !== -1 && now - this.touch.time <= 200) {
|
if (this.touch.start.x !== -1 && now - this.touch.time <= 200) {
|
||||||
let innerWidthHalf = window.innerWidth / 2;
|
const innerWidthHalf = window.innerWidth / 2;
|
||||||
|
|
||||||
if (this.touch.start.x >= innerWidthHalf && event.changedTouches[0].clientX >= innerWidthHalf) {
|
if (this.touch.start.x >= innerWidthHalf && event.changedTouches[0].clientX >= innerWidthHalf) {
|
||||||
goToPage("next");
|
goToPage("next");
|
||||||
|
@ -158,19 +158,16 @@ class TouchHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
listen() {
|
listen() {
|
||||||
let hasPassiveOption = DomHelper.hasPassiveEventListenerOption();
|
const hasPassiveOption = DomHelper.hasPassiveEventListenerOption();
|
||||||
|
|
||||||
let elements = document.querySelectorAll(".entry-swipe");
|
document.querySelectorAll(".entry-swipe").forEach((element) => {
|
||||||
|
|
||||||
elements.forEach((element) => {
|
|
||||||
element.addEventListener("touchstart", (e) => this.onItemTouchStart(e), hasPassiveOption ? { passive: true } : false);
|
element.addEventListener("touchstart", (e) => this.onItemTouchStart(e), hasPassiveOption ? { passive: true } : false);
|
||||||
element.addEventListener("touchmove", (e) => this.onItemTouchMove(e), hasPassiveOption ? { passive: false } : false);
|
element.addEventListener("touchmove", (e) => this.onItemTouchMove(e), hasPassiveOption ? { passive: false } : false);
|
||||||
element.addEventListener("touchend", (e) => this.onItemTouchEnd(e), hasPassiveOption ? { passive: true } : false);
|
element.addEventListener("touchend", (e) => this.onItemTouchEnd(e), hasPassiveOption ? { passive: true } : false);
|
||||||
element.addEventListener("touchcancel", () => this.reset(), hasPassiveOption ? { passive: true } : false);
|
element.addEventListener("touchcancel", () => this.reset(), hasPassiveOption ? { passive: true } : false);
|
||||||
});
|
});
|
||||||
|
|
||||||
let element = document.querySelector(".entry-content");
|
const element = document.querySelector(".entry-content");
|
||||||
|
|
||||||
if (element) {
|
if (element) {
|
||||||
if (element.classList.contains("gesture-nav-tap")) {
|
if (element.classList.contains("gesture-nav-tap")) {
|
||||||
element.addEventListener("touchend", (e) => this.onTapEnd(e), hasPassiveOption ? { passive: true } : false);
|
element.addEventListener("touchend", (e) => this.onTapEnd(e), hasPassiveOption ? { passive: true } : false);
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
let ttpolicy;
|
||||||
|
if (window.trustedTypes && trustedTypes.createPolicy) {
|
||||||
|
//TODO: use an allow-list for `createScriptURL`
|
||||||
|
if (!ttpolicy) {
|
||||||
|
ttpolicy = trustedTypes.createPolicy('ttpolicy', {
|
||||||
|
createScriptURL: src => src,
|
||||||
|
createHTML: html => html,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ttpolicy = {
|
||||||
|
createScriptURL: src => src,
|
||||||
|
createHTML: html => html,
|
||||||
|
};
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ class WebAuthnHandler {
|
||||||
|
|
||||||
static showErrorMessage(errorMessage) {
|
static showErrorMessage(errorMessage) {
|
||||||
console.log("webauthn error: " + errorMessage);
|
console.log("webauthn error: " + errorMessage);
|
||||||
let alertElement = document.getElementById("webauthn-error");
|
const alertElement = document.getElementById("webauthn-error");
|
||||||
if (alertElement) {
|
if (alertElement) {
|
||||||
alertElement.textContent += " (" + errorMessage + ")";
|
alertElement.textContent += " (" + errorMessage + ")";
|
||||||
alertElement.classList.remove("hidden");
|
alertElement.classList.remove("hidden");
|
||||||
|
@ -79,14 +79,14 @@ class WebAuthnHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let credentialCreationOptions = await registerBeginResponse.json();
|
const credentialCreationOptions = await registerBeginResponse.json();
|
||||||
credentialCreationOptions.publicKey.challenge = this.decodeBuffer(credentialCreationOptions.publicKey.challenge);
|
credentialCreationOptions.publicKey.challenge = this.decodeBuffer(credentialCreationOptions.publicKey.challenge);
|
||||||
credentialCreationOptions.publicKey.user.id = this.decodeBuffer(credentialCreationOptions.publicKey.user.id);
|
credentialCreationOptions.publicKey.user.id = this.decodeBuffer(credentialCreationOptions.publicKey.user.id);
|
||||||
if (Object.hasOwn(credentialCreationOptions.publicKey, 'excludeCredentials')) {
|
if (Object.hasOwn(credentialCreationOptions.publicKey, 'excludeCredentials')) {
|
||||||
credentialCreationOptions.publicKey.excludeCredentials.forEach((credential) => credential.id = this.decodeBuffer(credential.id));
|
credentialCreationOptions.publicKey.excludeCredentials.forEach((credential) => credential.id = this.decodeBuffer(credential.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
let attestation = await navigator.credentials.create(credentialCreationOptions);
|
const attestation = await navigator.credentials.create(credentialCreationOptions);
|
||||||
|
|
||||||
let registrationFinishResponse;
|
let registrationFinishResponse;
|
||||||
try {
|
try {
|
||||||
|
@ -108,7 +108,7 @@ class WebAuthnHandler {
|
||||||
throw new Error("Login failed with HTTP status code " + response.status);
|
throw new Error("Login failed with HTTP status code " + response.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
let jsonData = await registrationFinishResponse.json();
|
const jsonData = await registrationFinishResponse.json();
|
||||||
window.location.href = jsonData.redirect;
|
window.location.href = jsonData.redirect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class WebAuthnHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let credentialRequestOptions = await loginBeginResponse.json();
|
const credentialRequestOptions = await loginBeginResponse.json();
|
||||||
credentialRequestOptions.publicKey.challenge = this.decodeBuffer(credentialRequestOptions.publicKey.challenge);
|
credentialRequestOptions.publicKey.challenge = this.decodeBuffer(credentialRequestOptions.publicKey.challenge);
|
||||||
|
|
||||||
if (Object.hasOwn(credentialRequestOptions.publicKey, 'allowCredentials')) {
|
if (Object.hasOwn(credentialRequestOptions.publicKey, 'allowCredentials')) {
|
||||||
|
|
|
@ -113,6 +113,7 @@ func GenerateStylesheetsBundles() error {
|
||||||
func GenerateJavascriptBundles() error {
|
func GenerateJavascriptBundles() error {
|
||||||
var bundles = map[string][]string{
|
var bundles = map[string][]string{
|
||||||
"app": {
|
"app": {
|
||||||
|
"js/tt.js", // has to be first
|
||||||
"js/dom_helper.js",
|
"js/dom_helper.js",
|
||||||
"js/touch_handler.js",
|
"js/touch_handler.js",
|
||||||
"js/keyboard_handler.js",
|
"js/keyboard_handler.js",
|
||||||
|
|
Loading…
Reference in New Issue