Skip to content

Commit

Permalink
chore(deps): Bumping absto
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Aug 22, 2023
1 parent 0167feb commit e8fe05e
Show file tree
Hide file tree
Showing 13 changed files with 217 additions and 219 deletions.
2 changes: 1 addition & 1 deletion cmd/fibr/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type adapters struct {
}

func newAdapters(config configuration, clients client) (adapters, error) {
storageApp, err := absto.New(config.absto, clients.telemetry.TracerProvider().Tracer("absto"))
storageApp, err := absto.New(config.absto, clients.telemetry.TracerProvider())
if err != nil {
return adapters{}, err
}
Expand Down
58 changes: 29 additions & 29 deletions cmd/fibr/static/scripts/async-image.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// from https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_for_webp
function isWebPCompatible() {
const animatedImage =
'UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA';
"UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA";

return new Promise((resolve, reject) => {
const image = new Image();
Expand Down Expand Up @@ -79,32 +79,32 @@ function encode(content) {
output.push(String.fromCharCode(rune));
}

return btoa(output.join(''));
return btoa(output.join(""));
}

/**
* Async image loading
*/
async function fetchThumbnail() {
let fetchURL = document.location.search;
if (fetchURL.includes('?')) {
if (!fetchURL.endsWith('&')) {
fetchURL += '&';
if (fetchURL.includes("?")) {
if (!fetchURL.endsWith("&")) {
fetchURL += "&";
}
fetchURL += 'thumbnail';
fetchURL += "thumbnail";
} else {
fetchURL += '?thumbnail';
fetchURL += "?thumbnail";
}

const response = await fetch(fetchURL, { credentials: 'same-origin' });
const response = await fetch(fetchURL, { credentials: "same-origin" });

if (response.status >= 400) {
throw new Error('unable to load thumbnails');
throw new Error("unable to load thumbnails");
}

let lazyImageObserver;

if (typeof lazyLoadThumbnail !== 'undefined' && lazyLoadThumbnail) {
if (typeof lazyLoadThumbnail !== "undefined" && lazyLoadThumbnail) {
lazyImageObserver = new IntersectionObserver(async (entries, observer) => {
for (const entry of entries) {
if (!entry.isIntersecting) {
Expand All @@ -115,20 +115,20 @@ async function fetchThumbnail() {
const parent = lazyImage.parentElement.parentElement;

const storyThrobber = generateThrobber([
'throbber-white',
'throbber-overlay',
"throbber-white",
"throbber-overlay",
]);
parent.appendChild(storyThrobber);

lazyImage.addEventListener(
'load',
"load",
() => parent.removeChild(storyThrobber),
{ once: true },
);

if (window.webpHero) {
const response = await fetch(lazyImage.dataset.src, {
credentials: 'same-origin',
credentials: "same-origin",
});
const content = await response.arrayBuffer();

Expand All @@ -147,7 +147,7 @@ async function fetchThumbnail() {
for await (let chunk of readChunk(response)) {
const commaIndex = chunk.findIndex((element) => element === 44);
if (commaIndex === -1) {
console.error('invalid line for thumbnail:', line);
console.error("invalid line for thumbnail:", line);
continue;
}

Expand All @@ -162,7 +162,7 @@ async function fetchThumbnail() {
img.src = `data:image/webp;base64,${encode(chunk.slice(commaIndex + 1))}`;
img.alt = picture.dataset.alt;
img.dataset.src = picture.dataset.src;
img.classList.add('thumbnail', 'full', 'block');
img.classList.add("thumbnail", "full", "block");

replaceContent(picture, img);

Expand All @@ -172,48 +172,48 @@ async function fetchThumbnail() {
}
}

document.addEventListener('readystatechange', async (event) => {
if (event.target.readyState !== 'complete') {
document.addEventListener("readystatechange", async (event) => {
if (event.target.readyState !== "complete") {
return;
}

let dateTimeFormatter = new Intl.DateTimeFormat(navigator.language, {
dateStyle: 'full',
timeStyle: 'long',
dateStyle: "full",
timeStyle: "long",
});

document.querySelectorAll('.date').forEach((item) => {
document.querySelectorAll(".date").forEach((item) => {
item.innerHTML = dateTimeFormatter.format(new Date(item.innerHTML));
});
});

document.addEventListener(
'readystatechange',
"readystatechange",
async (event) => {
if (event.target.readyState !== 'complete') {
if (event.target.readyState !== "complete") {
return;
}

if (typeof hasThumbnail === 'undefined' || !hasThumbnail) {
if (typeof hasThumbnail === "undefined" || !hasThumbnail) {
return;
}

const thumbnailsElem = document.querySelectorAll('[data-thumbnail]');
const thumbnailsElem = document.querySelectorAll("[data-thumbnail]");
if (!thumbnailsElem) {
return;
}

thumbnailsElem.forEach((picture) => {
replaceContent(picture, generateThrobber(['throbber-white']));
replaceContent(picture, generateThrobber(["throbber-white"]));
});

try {
await isWebPCompatible();
} catch (e) {
await resolveScript(
'https://unpkg.com/[email protected]/dist-cjs/webp-hero.bundle.js',
'sha512-DA6h9H5Sqn55/uVn4JI4aSPFnAWoCQYYDXUnvjOAMNVx11///hX4QaFbQt5yWsrIm9hSI5fLJYfRWt3KXneSXQ==',
'anonymous',
"https://unpkg.com/[email protected]/dist-cjs/webp-hero.bundle.js",
"sha512-DA6h9H5Sqn55/uVn4JI4aSPFnAWoCQYYDXUnvjOAMNVx11///hX4QaFbQt5yWsrIm9hSI5fLJYfRWt3KXneSXQ==",
"anonymous",
);
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/fibr/static/scripts/confirm.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
document.addEventListener('readystatechange', (event) => {
if (event.target.readyState !== 'complete') {
document.addEventListener("readystatechange", (event) => {
if (event.target.readyState !== "complete") {
return;
}

document.querySelectorAll('[data-confirm]').forEach((element) => {
element.addEventListener('click', (e) => {
document.querySelectorAll("[data-confirm]").forEach((element) => {
element.addEventListener("click", (e) => {
if (
!confirm(`Are you sure you want to delete ${element.dataset.confirm}?`)
) {
Expand Down
12 changes: 6 additions & 6 deletions cmd/fibr/static/scripts/error.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
document.addEventListener('readystatechange', (event) => {
if (event.target.readyState !== 'complete') {
document.addEventListener("readystatechange", (event) => {
if (event.target.readyState !== "complete") {
return;
}

const link = document.getElementById('go-back');
const link = document.getElementById("go-back");

if (link) {
link.setAttribute('href', document.referrer);
link.addEventListener('click', (e) => {
link.setAttribute("href", document.referrer);
link.addEventListener("click", (e) => {
e.preventDefault();
window.addEventListener('popstate', () => {
window.addEventListener("popstate", () => {
window.location.reload(true);
});
history.back();
Expand Down
Loading

0 comments on commit e8fe05e

Please sign in to comment.