Skip to content

Commit

Permalink
bug fixes and minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nesaku committed Jan 15, 2024
1 parent f57ca6d commit f0e13fd
Show file tree
Hide file tree
Showing 10 changed files with 560 additions and 175 deletions.
21 changes: 18 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.19.0] - Jan 14, 2024

### Added

- Add a loading indicator to the book editions page when filtering

### Changed

- Update the instances list in the README and instances.json

### Fixed

- Fix "Get A Copy" dropdown obstructing the similar books section - [(ISSUE)](https://codeberg.org/nesaku/BiblioReads/issues/79)
- Fix the default format returning no results when filtering by edition - [(ISSUE)](https://codeberg.org/nesaku/BiblioReads/issues/80)

## [2.18.0] - Dec 26, 2023

## Added
### Added

- Add support for multiple tabs on the library page
- Add the library page link to the footer
Expand All @@ -29,9 +44,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [2.17.0] - Dec 20, 2023

## Added
### Added

- Add the library page and saving books function - [(ISSUE)](https://codeberg.org/nesaku/BiblioReads/issues/76)
- Add the library page and saving books functionality - [(ISSUE)](https://codeberg.org/nesaku/BiblioReads/issues/76)
- Add the option to save and list locally stored books.
- Add a toast component

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Inspired by [Nitter](https://github.com/zedeus/nitter), [libremdb](https://githu
| [biblioreads.privacyfucking.rocks](https://biblioreads.privacyfucking.rocks) | :de: | 1Blu.de | Run by [PrivacyFucking.Rocks](https://privacyfucking.rocks) |
| [read.seitan-ayoub.lol](https://read.seitan-ayoub.lol) | :de: | Hetzner | Run by [unstablemaple](https://seitan-ayoub.lol) |
| [read.freedit.eu](https://read.freedit.eu) | :us: | Cloudflare | Run by [Freedit](https://freedit.eu) |
| [biblioreads.ducks.party](https://biblioreads.ducks.party) | :netherlands: | Timeweb | Run by [nyuuzyou](https://ducks.party) |
| Onion: | | | |
| [bl.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion](http://bl.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion) | :us: | Hetzner | Run by [~vern](https://vern.cc) |
| I2P: | | | |
Expand Down
46 changes: 29 additions & 17 deletions components/editionspage/EditionsResultData.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,42 @@ import { useEffect, useState } from "react";
import Meta from "../global/Meta";
import EditionsList from "./EditionsList";
import Link from "next/link";
import SmallLoader from "../global/SmallLoader";

const EditionResults = ({ scrapedData }) => {
const [selectedEdition, setSelectedEdition] = useState(null);
const [filteredData, setFilteredData] = useState({});
const [error, setError] = useState(false);
const [isLoading, setIsLoading] = useState(false);

const editionChangeHandler = (e) => {
const edition = e.target.value;
setSelectedEdition(edition);
};

useEffect(() => {
setIsLoading(true);
const fetchData = async () => {
const res = await fetch(`/api/works/editions`, {
method: "POST",
headers: {
"content-type": "application/json",
},
body: JSON.stringify({
queryURL: `${scrapedData.scrapeURL}${
selectedEdition != "default" &&
`?filter_by_format=${selectedEdition}&sort=avg_rating&utf8=✓`
}`,
queryURL: `${scrapedData.scrapeURL}?filter_by_format=${selectedEdition}&sort=avg_rating&utf8=✓`,
}),
});
if (res.ok) {
const data = await res.json();
setFilteredData(data);
setIsLoading(false);
} else {
setError(true);
setIsLoading(false);
}
};

selectedEdition && fetchData();
selectedEdition && selectedEdition != "default" && fetchData();
}, [selectedEdition]);

return (
Expand Down Expand Up @@ -109,23 +111,33 @@ const EditionResults = ({ scrapedData }) => {
)}
{scrapedData.editions && (
<>
<EditionsList
editions={
filteredData.editions
? filteredData.editions
: scrapedData.editions
}
/>
{isLoading &&
filteredData.editions &&
selectedEdition != "default" ? (
<div className="mt-40 min-h-[80vh]">
<SmallLoader height="10" />
</div>
) : (
<EditionsList
editions={
filteredData.editions && selectedEdition != "default"
? filteredData.editions
: scrapedData.editions
}
/>
)}
{error && (
<p className="pt-10 text-red-600 font-bold text-3xl capitalize">
An Error Has Occurred. Please Try Again Later.
</p>
)}
{filteredData.editions && filteredData.editions.length === 0 && (
<p className="pt-10 text-lg capitalize min-h-[42vh]">
There are no editions with the selected format.
</p>
)}
{filteredData.editions &&
filteredData.editions.length === 0 &&
selectedEdition != "default" && (
<p className="pt-10 text-lg capitalize min-h-[42vh]">
There are no editions with the selected format.
</p>
)}
</>
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/global/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from "react";
import Link from "next/link";

const Footer = () => {
const version = "v2.18.0";
const versionSlug = "2180---dec-26-2023";
const version = "v2.19.0";
const versionSlug = "2190---jan-14-2024";

if (typeof sessionStorage !== "undefined") {
if (!sessionStorage.getItem("version")) {
Expand Down
9 changes: 4 additions & 5 deletions components/librarypage/LibraryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const LibraryList = ({ libraryData }) => {
}
return (
<div key={i} className="max-w-[1000px] w-full">
<a href={`/book/show/${data.slug}`}>
<Link href={`/book/show/${data.slug}`}>
<div className="flex items-center justify-between text-left mt-8 py-6 sm:p-8 bg-white/40 dark:bg-slate-800 rounded-2xl hover:ring hover:ring-rose-600 hover:bg-rose-300 dark:hover:bg-rose-900 transition duration-300 delay-40 hover:delay-40">
<div className="ml-8 sm:ml-16 w-48 sm:w-full">
<h3 className="text-xl sm:text-2xl font-semibold hover:underline">
Expand All @@ -24,12 +24,12 @@ const LibraryList = ({ libraryData }) => {
{data.author &&
data.author.map((data, i) => (
<span key={i}>
<Link
<a
className="text-md hover:underline hover:text-rose-600"
href={data.url}
>
{(i ? ", " : "") + data.name}
</Link>
</a>
</span>
))}
<div className="flex items-center mt-4">
Expand Down Expand Up @@ -63,7 +63,6 @@ const LibraryList = ({ libraryData }) => {
day: "numeric",
hour: "numeric",
minute: "numeric",
// second: "numeric",
hour12: true,
})}
</span>
Expand Down Expand Up @@ -104,7 +103,7 @@ const LibraryList = ({ libraryData }) => {
)}
</div>
</div>
</a>
</Link>
</div>
);
})}
Expand Down
46 changes: 5 additions & 41 deletions components/resultpage/ResultData.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ const ResultData = ({ scrapedData }) => {
}
}

/*
// List all books in DB
const allBooks = await db.getAll("books");
// console.log(allBooks);
console.log(allBooks);
*/
}
} catch (error) {
console.error("Error managing books:", error);
Expand All @@ -90,25 +93,6 @@ const ResultData = ({ scrapedData }) => {
manageBooks();
}, [isSaved, scrapedData]);

/* Save books using local storage
useEffect(() => {
let slugs = JSON.parse(localStorage.getItem("slugs")) || {};
if (isSaved) {
slugs[router.query.slug[0]] = {
timestamp: Date.now(),
imageUrl: scrapedData.cover,
title: scrapedData.title,
author: scrapedData.author,
};
localStorage.setItem("slugs", JSON.stringify(slugs));
} else {
delete slugs[router.query.slug[0]];
localStorage.setItem("slugs", JSON.stringify(slugs));
}
}, [isSaved]); */

const externalSVG = (
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -258,29 +242,9 @@ const ResultData = ({ scrapedData }) => {
)}

<div className="flex flex-col mt-0 lg:mt-16 xl:mt-0">
{/* <div id="addToLibrary" className="mt-4 items-center justify-center flex">
<button>
<a className="flex justify-center items-center h-16 w-72 py-5 px-4 mt-4 font-semibold text-md text-gray-900 dark:text-gray-300 bg-rose-50 dark:bg-gray-800 rounded-2xl shadow-sm shadow-rose-800 hover:shadow-xl hover:bg-rose-300 dark:hover:bg-slate-800 transition duration-300 delay-40 hover:delay-40 ring ring-gray-400 dark:ring-gray-500 hover:ring-rose-600 dark:hover:ring-rose-600">
Add to Library
<svg
aria-hidden="true"
className="w-5 h-5 ml-2 -mr-1"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
d="M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z"
clipRule="evenodd"
></path>
</svg>
</a>
</button>
</div> */}
<div
id="purchaseOptions"
className="flex flex-col justify-center items-center relative"
className="flex flex-col justify-center items-center relative z-10"
>
<button
onClick={() => setIsOpened(!isOpened)}
Expand Down
5 changes: 5 additions & 0 deletions instances.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,10 @@
"url": "https://read.freedit.eu",
"countries": ["us"],
"cloudflare": true
},
{
"url": "https://biblioreads.ducks.party",
"countries": ["nl"],
"cloudflare": false
}
]
Loading

0 comments on commit f0e13fd

Please sign in to comment.