Skip to content

Commit

Permalink
use local filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
Moebits committed Feb 6, 2023
1 parent b5054a4 commit a6bfd22
Show file tree
Hide file tree
Showing 18 changed files with 735 additions and 23 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.env
node_modules
dist
json/database.js
json/database.js
json/database-nsfw.js
2 changes: 2 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Context, {EnableDragContext, MobileContext} from "./Context"
import axios from "axios"
import functions from "./structures/Functions"
import HomePage from "./pages/HomePage"
import HiddenPage from "./pages/HiddenPage"
import MangaInfoPage from "./pages/MangaInfoPage"
import MangaPage from "./pages/MangaPage"
import AboutPage from "./pages/AboutPage"
Expand Down Expand Up @@ -59,6 +60,7 @@ const App: React.FunctionComponent = (props) => {
<Route exact path="/manga/:id" render={(props) => <MangaInfoPage {...props}/>}></Route>
<Route exact path="/manga/:id/:num" render={(props) => <MangaPage {...props}/>}></Route>
<Route exact path="/viewer"><ViewerPage/></Route>
<Route exact path="/hidden"><HiddenPage/></Route>
<Route exact path="/about"><AboutPage/></Route>
<Route exact path={["/tos", "/terms", "/privacy"]}><TermsPage/></Route>
<Route path="*"><$404Page/></Route>
Expand Down
Binary file modified assets/.DS_Store
Binary file not shown.
8 changes: 6 additions & 2 deletions components/MangaGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import database from "../json/database"
import dbFunctions from "../structures/DatabaseFunctions"
import "./styles/mangagrid.less"

const MangaGrid: React.FunctionComponent = (props) => {
interface Props {
hidden?: boolean
}

const MangaGrid: React.FunctionComponent<Props> = (props) => {
const {enableDrag, setEnableDrag} = useContext(EnableDragContext)
const {search, setSearch} = useContext(SearchContext)
const {searchFlag, setSearchFlag} = useContext(SearchFlagContext)
Expand All @@ -22,7 +26,7 @@ const MangaGrid: React.FunctionComponent = (props) => {
const history = useHistory()

const updateMangaList = () => {
const list = dbFunctions.getSorted(search, genre, sort, reverse)
const list = props.hidden ? dbFunctions.getSortedHidden(search, genre, sort, reverse) : dbFunctions.getSorted(search, genre, sort, reverse)
setMangaList(list)
}

Expand Down
2 changes: 1 addition & 1 deletion components/MangaInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const MangaInfo: React.FunctionComponent<Props> = (props) => {
</div>
<div className="manga-info-text-row">
<span className="manga-info-text-category">Synopsis:</span>
<span className="manga-info-text-content">{props.info.synopsis} <span className="manga-info-text-content-link" onClick={() => window.open(props.info.synopsisSource, "_blank")}>[{functions.websiteName(props.info.synopsisSource)}]</span></span>
<span className="manga-info-text-content">{props.info.synopsis} {props.info.synopsisSource ? <span className="manga-info-text-content-link" onClick={() => window.open(props.info.synopsisSource, "_blank")}>[{functions.websiteName(props.info.synopsisSource)}]</span> : null}</span>
</div>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions components/PDFControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import color from "../assets/icons/color.png"
import invertIcon from "../assets/icons/invert.png"
import invertOnIcon from "../assets/icons/invert-on.png"
import database from "../json/database"
import hiddenDatabase from "../json/database-hidden"
import Slider from "react-slider"
import "./styles/pdfcontrols.less"

Expand Down Expand Up @@ -166,7 +167,8 @@ const PDFControls: React.FunctionComponent<Props> = (props) => {
}

const triggerSupport = () => {
const manga = database.find((m) => m.id === props.id)
let manga = database.find((m) => m.id === props.id)
if (!manga) manga = hiddenDatabase.find((m) => m.id === props.id)
if (manga) {
window.open(manga.website, "_blank")
}
Expand Down Expand Up @@ -256,7 +258,7 @@ const PDFControls: React.FunctionComponent<Props> = (props) => {
}, [])

return (
<div className="pdf-controls" onMouseEnter={() => setEnableDrag(false)}>
<div className="pdf-controls" onMouseEnter={() => setEnableDrag(true)}>
<div className="pdf-controls-box">
{!mobile ? <img className="pdf-controls-icon-small" src={hamburger} onClick={() => setShowThumbnails((prev: boolean) => !prev)}/> : null}
<div className="pdf-controls-page-container">
Expand Down
19 changes: 11 additions & 8 deletions components/PDFRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import functions from "../structures/Functions"
import WrappedPage from "./WrappedPage"
import * as pdfjsWorker from "pdfjs-dist/legacy/build/pdf.worker.entry"
import database from "../json/database"
import hiddenDatabase from "../json/database-hidden"
import axios from "axios"
import "./styles/pdfrenderer.less"

Expand All @@ -32,7 +33,7 @@ const PDFPage = forwardRef(function PDFPage({visible, pageIndex, width, scale, i
)
})

const PDFThumbnail = forwardRef(function PDFThumbnail({visible, pageNumber, width, className, key, onRenderSuccess, style, loading, noData, renderAnnotationLayer, renderTextLayer, onClick}: any, ref: any) {
const PDFThumbnail = forwardRef(function PDFThumbnail({pageNumber, width, className, key, onRenderSuccess, style, loading, noData, renderAnnotationLayer, renderTextLayer, onClick}: any, ref: any) {
return (
<div ref={ref} data-page-index={pageNumber - 1} style={style}>
<Page className={className} key={key} onRenderSuccess={onRenderSuccess} width={width} pageNumber={pageNumber} loading={loading} noData={noData} renderAnnotationLayer={renderAnnotationLayer} renderTextLayer={renderTextLayer} onClick={onClick}/>
Expand Down Expand Up @@ -77,9 +78,10 @@ const PDFRenderer: React.FunctionComponent<Props> = (props) => {
setJaPDF(props.source)
return
}
const manga = database.find((m) => m.id === props.id)
let manga = database.find((m) => m.id === props.id)
if (!manga) manga = hiddenDatabase.find((m) => m.id === props.id)
if (!manga) return history.push(`/404`)
const volume = manga.volumes.find((v) => v.volumeNumber === Number(props.num))
const volume = manga.volumes.find((v: any) => v.volumeNumber === Number(props.num))
if (!volume) return history.push(`/404`)
setJaPDF(volume.japaneseSource)
setEnPDF(volume.englishSource)
Expand All @@ -100,9 +102,9 @@ const PDFRenderer: React.FunctionComponent<Props> = (props) => {
setShowEn((prev: boolean) => !prev)
}
}
window.addEventListener("keydown", keyDown)
document.addEventListener("keydown", keyDown)
return () => {
window.removeEventListener("keydown", keyDown)
document.removeEventListener("keydown", keyDown)
}
})

Expand Down Expand Up @@ -220,7 +222,8 @@ const PDFRenderer: React.FunctionComponent<Props> = (props) => {
const thumbsToRenderJA = Math.min(thumbsRenderedJA + 1, numPagesJA)
const thumbsToRenderEN = Math.min(thumbsRenderedEN + 1, numPagesEN)
return (
<>
// @ts-ignore
<div onClick={((e) => {showEn ? e.currentTarget.firstElementChild?.focus() : e.currentTarget.lastElementChild?.focus(); e.stopPropagation()})}>
<Document className={`pdf-thumbnail-container ${!showThumbnails || !showEn ? horizontal ? "thumbnail-hidden-horizontal" : "thumbnail-hidden" : ""} ${horizontal ? "thumbnail-horizontal" : ""}`} file={enPDF} noData="" loading="" options={{disableAutoFetch: true, disableStream: true}}>
{Array.from(new Array(thumbsToRenderEN), (el, index) => {
const rendering = thumbsToRenderEN === index + 1
Expand All @@ -241,7 +244,7 @@ const PDFRenderer: React.FunctionComponent<Props> = (props) => {
)
})}
</Document>
</>
</div>
)
}

Expand Down Expand Up @@ -302,7 +305,7 @@ const PDFRenderer: React.FunctionComponent<Props> = (props) => {
}

return (
<div className={`pdf-renderer drag ${horizontal ? "pdf-renderer-horizontal" : ""}`} ref={rootRef} style={{maxHeight: horizontal ? 773 : 1600}}>
<div className={`pdf-renderer drag ${horizontal ? "pdf-renderer-horizontal" : ""}`} ref={rootRef} style={{maxHeight: horizontal ? 773 : 1600}} onClick={((e) => e.currentTarget.focus())}>
{generateThumbnails()}
<Document renderMode="svg" className={`pdf-document ${!showEn ? "hidden" : ""} ${horizontal ? "horizontal" : ""}`} file={enPDF} onLoadSuccess={onLoadSuccessEN} noData="" loading="" options={{disableAutoFetch: true, disableStream: true}}>
{visibilitiesEN.map((visible: boolean, index: number) => (
Expand Down
8 changes: 6 additions & 2 deletions components/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import dbFunctions from "../structures/DatabaseFunctions"
import functions from "../structures/Functions"
import "./styles/sidebar.less"

const SideBar: React.FunctionComponent= (props) => {
interface Props {
hidden?: boolean
}

const SideBar: React.FunctionComponent<Props> = (props) => {
const {enableDrag, setEnableDrag} = useContext(EnableDragContext)
const {search, setSearch} = useContext(SearchContext)
const {searchFlag, setSearchFlag} = useContext(SearchFlagContext)
Expand Down Expand Up @@ -57,7 +61,7 @@ const SideBar: React.FunctionComponent= (props) => {
const generateLinksJSX = () => {
let jsx = [] as any
if (sidebarSort === "recent") {
const recent = dbFunctions.getRecent()
const recent = props.hidden ? dbFunctions.getRecentHidden() : dbFunctions.getRecent()
for (let i = 0; i < recent.length; i++) {
jsx.push(<span className="sidebar-link" onClick={() => history.push(`/manga/${recent[i].id}`)}>{recent[i].title}</span>)
}
Expand Down
5 changes: 3 additions & 2 deletions components/TitleBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const colorList = {

interface Props {
rerender: () => void
hidden?: boolean
}

const TitleBar: React.FunctionComponent<Props> = (props) => {
Expand Down Expand Up @@ -111,8 +112,8 @@ const TitleBar: React.FunctionComponent<Props> = (props) => {
</div>
<div className="titlebar-container">
<div className="titlebar-nav-container">
{!mobile ? <span className="titlebar-nav-text" onClick={() => history.push("/manga")}>Manga</span> : null}
{!mobile ? <span className="titlebar-nav-text" onClick={() => window.open("https://cuteanime.moe", "_blank")}>Anime</span> : null}
{!mobile ? <span className="titlebar-nav-text" onClick={() => props.hidden ? history.push("/hidden") : history.push("/manga")}>Manga</span> : null}
{!mobile ? <span className="titlebar-nav-text" onClick={() => window.open(functions.isLocalHost() ? "http://localhost:8081" : "https://cuteanime.moe", "_blank")}>Anime</span> : null}
<span className="titlebar-nav-text" onClick={() => history.push("/about")}>About</span>
</div>
{!mobile ?
Expand Down
Loading

0 comments on commit a6bfd22

Please sign in to comment.