rename to comic from manga
This commit is contained in:
parent
531152d821
commit
dafce3ebf6
4
plan.md
4
plan.md
@ -5,7 +5,7 @@
|
|||||||
### server routing
|
### server routing
|
||||||
- content
|
- content
|
||||||
- \d+
|
- \d+
|
||||||
- manga
|
- comic
|
||||||
- (?P<page>\d+)
|
- (?P<page>\d+)
|
||||||
- video
|
- video
|
||||||
- diff
|
- diff
|
||||||
@ -34,7 +34,7 @@
|
|||||||
- server push
|
- server push
|
||||||
- ~~permission~~
|
- ~~permission~~
|
||||||
- diff
|
- diff
|
||||||
- ~~manga~~
|
- ~~comic~~
|
||||||
- video
|
- video
|
||||||
- html
|
- html
|
||||||
- ~~hash~~
|
- ~~hash~~
|
||||||
|
@ -5,7 +5,7 @@ import { LoadingCircle } from '../component/loading';
|
|||||||
import { Link, Paper, makeStyles, Theme, Box, useTheme, Typography } from '@material-ui/core';
|
import { Link, Paper, makeStyles, Theme, Box, useTheme, Typography } from '@material-ui/core';
|
||||||
import { ThumbnailContainer } from '../page/reader/reader';
|
import { ThumbnailContainer } from '../page/reader/reader';
|
||||||
import { TagChip } from '../component/tagchip';
|
import { TagChip } from '../component/tagchip';
|
||||||
import { MangaReader } from '../page/reader/manga';
|
import { ComicReader } from '../page/reader/comic';
|
||||||
|
|
||||||
export const makeContentInfoUrl = (id: number) => `/doc/${id}`;
|
export const makeContentInfoUrl = (id: number) => `/doc/${id}`;
|
||||||
export const makeContentReaderUrl = (id: number) => `/doc/${id}/reader`;
|
export const makeContentReaderUrl = (id: number) => `/doc/${id}/reader`;
|
||||||
@ -117,14 +117,14 @@ export const ContentInfo = (props: {
|
|||||||
{props.short ? (<Box className={propclasses.tag_list || classes.tag_list}>{document.tags.map(x =>
|
{props.short ? (<Box className={propclasses.tag_list || classes.tag_list}>{document.tags.map(x =>
|
||||||
(<TagChip key={x} label={x} clickable tagname={x} size="small"></TagChip>)
|
(<TagChip key={x} label={x} clickable tagname={x} size="small"></TagChip>)
|
||||||
)}</Box>) : (
|
)}</Box>) : (
|
||||||
<MangaDetailTag tags={document.tags} classes={({tag_list:classes.tag_list})}></MangaDetailTag>)
|
<ComicDetailTag tags={document.tags} classes={({tag_list:classes.tag_list})}></ComicDetailTag>)
|
||||||
}
|
}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Paper>);
|
</Paper>);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MangaDetailTag(prop:{tags:string[],classes:{
|
function ComicDetailTag(prop:{tags:string[],classes:{
|
||||||
tag_list:string
|
tag_list:string
|
||||||
}}){
|
}}){
|
||||||
let allTag = prop.tags;
|
let allTag = prop.tags;
|
||||||
|
@ -32,7 +32,7 @@ export function CommonMenuList(props?:{url?:string}) {
|
|||||||
return (<NavList>
|
return (<NavList>
|
||||||
{url !== "" && <><BackItem /> <Divider /></>}
|
{url !== "" && <><BackItem /> <Divider /></>}
|
||||||
<NavItem name="All" to="/" icon={<HomeIcon />} />
|
<NavItem name="All" to="/" icon={<HomeIcon />} />
|
||||||
<NavItem name="Manga" to="/search?content_type=manga" icon={<CollectionIcon />}></NavItem>
|
<NavItem name="Comic" to="/search?content_type=comic" icon={<CollectionIcon />}></NavItem>
|
||||||
<NavItem name="Video" to="/search?content_type=video" icon={<VideoIcon />} />
|
<NavItem name="Video" to="/search?content_type=video" icon={<VideoIcon />} />
|
||||||
<Divider />
|
<Divider />
|
||||||
<NavItem name="Difference" to="/difference" icon={<FolderIcon/>}></NavItem>
|
<NavItem name="Difference" to="/difference" icon={<FolderIcon/>}></NavItem>
|
||||||
|
@ -9,7 +9,7 @@ import { BackItem, CommonMenuList, ContentInfo, Headline, NavItem, NavList } fro
|
|||||||
import {NotFoundPage} from './404';
|
import {NotFoundPage} from './404';
|
||||||
|
|
||||||
export const makeContentInfoUrl = (id: number) => `/doc/${id}`;
|
export const makeContentInfoUrl = (id: number) => `/doc/${id}`;
|
||||||
export const makeMangaReaderUrl = (id: number) => `/doc/${id}/reader`;
|
export const makeComicReaderUrl = (id: number) => `/doc/${id}/reader`;
|
||||||
|
|
||||||
type DocumentState = {
|
type DocumentState = {
|
||||||
doc: Document | undefined,
|
doc: Document | undefined,
|
||||||
|
@ -2,18 +2,18 @@ import React, {useState, useEffect} from 'react';
|
|||||||
import { Typography, useTheme } from '@material-ui/core';
|
import { Typography, useTheme } from '@material-ui/core';
|
||||||
import { Document } from '../../accessor/document';
|
import { Document } from '../../accessor/document';
|
||||||
|
|
||||||
type MangaType = "manga"|"artist cg"|"donjinshi"|"western"
|
type ComicType = "comic"|"artist cg"|"donjinshi"|"western"
|
||||||
|
|
||||||
export type PresentableTag = {
|
export type PresentableTag = {
|
||||||
artist:string[],
|
artist:string[],
|
||||||
group: string[],
|
group: string[],
|
||||||
series: string[],
|
series: string[],
|
||||||
type: MangaType,
|
type: ComicType,
|
||||||
character: string[],
|
character: string[],
|
||||||
tags: string[],
|
tags: string[],
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MangaReader = (props:{doc:Document})=>{
|
export const ComicReader = (props:{doc:Document})=>{
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const additional = props.doc.additional;
|
const additional = props.doc.additional;
|
||||||
const [curPage,setCurPage] = useState(0);
|
const [curPage,setCurPage] = useState(0);
|
||||||
@ -40,9 +40,9 @@ export const MangaReader = (props:{doc:Document})=>{
|
|||||||
});
|
});
|
||||||
//theme.mixins.toolbar.minHeight;
|
//theme.mixins.toolbar.minHeight;
|
||||||
return (<div style={{overflow: 'hidden', alignSelf:'center'}}>
|
return (<div style={{overflow: 'hidden', alignSelf:'center'}}>
|
||||||
<img onClick={PageUP} src={`/api/doc/${props.doc.id}/manga/${curPage}`}
|
<img onClick={PageUP} src={`/api/doc/${props.doc.id}/comic/${curPage}`}
|
||||||
style={{maxWidth:'100%', maxHeight:'calc(100vh - 64px)'}}></img>
|
style={{maxWidth:'100%', maxHeight:'calc(100vh - 64px)'}}></img>
|
||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MangaReader;
|
export default ComicReader;
|
@ -1,7 +1,7 @@
|
|||||||
import { Typography } from '@material-ui/core';
|
import { Typography } from '@material-ui/core';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Document, makeThumbnailUrl } from '../../accessor/document';
|
import { Document, makeThumbnailUrl } from '../../accessor/document';
|
||||||
import {MangaReader} from './manga';
|
import {ComicReader} from './comic';
|
||||||
import {VideoReader} from './video'
|
import {VideoReader} from './video'
|
||||||
|
|
||||||
export interface PagePresenterProp{
|
export interface PagePresenterProp{
|
||||||
@ -14,8 +14,8 @@ interface PagePresenter{
|
|||||||
|
|
||||||
export const getPresenter = (content:Document):PagePresenter => {
|
export const getPresenter = (content:Document):PagePresenter => {
|
||||||
switch (content.content_type) {
|
switch (content.content_type) {
|
||||||
case "manga":
|
case "comic":
|
||||||
return MangaReader;
|
return ComicReader;
|
||||||
case "video":
|
case "video":
|
||||||
return VideoReader;
|
return VideoReader;
|
||||||
}
|
}
|
||||||
|
@ -3,19 +3,19 @@ import {readZip, readAllFromZip} from '../util/zipwrap';
|
|||||||
import { DocumentBody } from '../model/doc';
|
import { DocumentBody } from '../model/doc';
|
||||||
import {extname} from 'path';
|
import {extname} from 'path';
|
||||||
|
|
||||||
type MangaType = "doujinshi"|"artist cg"|"manga"|"western";
|
type ComicType = "doujinshi"|"artist cg"|"manga"|"western";
|
||||||
interface MangaDesc{
|
interface ComicDesc{
|
||||||
title:string,
|
title:string,
|
||||||
artist?:string[],
|
artist?:string[],
|
||||||
group?:string[],
|
group?:string[],
|
||||||
series?:string[],
|
series?:string[],
|
||||||
type:MangaType|[MangaType],
|
type:ComicType|[ComicType],
|
||||||
character?:string[],
|
character?:string[],
|
||||||
tags?:string[]
|
tags?:string[]
|
||||||
}
|
}
|
||||||
const ImageExt = ['.gif', '.png', '.jpeg', '.bmp', '.webp', '.jpg'];
|
const ImageExt = ['.gif', '.png', '.jpeg', '.bmp', '.webp', '.jpg'];
|
||||||
export class MangaReferrer extends createDefaultClass("manga"){
|
export class ComicReferrer extends createDefaultClass("comic"){
|
||||||
desc: MangaDesc|undefined;
|
desc: ComicDesc|undefined;
|
||||||
pagenum: number;
|
pagenum: number;
|
||||||
additional: ContentConstructOption| undefined;
|
additional: ContentConstructOption| undefined;
|
||||||
constructor(path:string,option?:ContentConstructOption){
|
constructor(path:string,option?:ContentConstructOption){
|
||||||
@ -62,4 +62,4 @@ export class MangaReferrer extends createDefaultClass("manga"){
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
registerContentReferrer(MangaReferrer);
|
registerContentReferrer(ComicReferrer);
|
@ -1,3 +1,3 @@
|
|||||||
import './manga';
|
import './comic';
|
||||||
import './video';
|
import './video';
|
||||||
export {ContentFile, createContentFile} from './file';
|
export {ContentFile, createContentFile} from './file';
|
@ -1 +1 @@
|
|||||||
{"$schema":"http://json-schema.org/draft-07/schema#","$ref":"#/definitions/MangaConfig","definitions":{"MangaConfig":{"type":"object","properties":{"watch":{"type":"array","items":{"type":"string"}},"$schema":{"type":"string"}},"required":["watch"],"additionalProperties":false}}}
|
{"$schema":"http://json-schema.org/draft-07/schema#","$ref":"#/definitions/ComicConfig","definitions":{"ComicConfig":{"type":"object","properties":{"watch":{"type":"array","items":{"type":"string"}},"$schema":{"type":"string"}},"required":["watch"],"additionalProperties":false}}}
|
8
src/diff/watcher/ComicConfig.ts
Normal file
8
src/diff/watcher/ComicConfig.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import {ConfigManager} from '../../util/configRW';
|
||||||
|
import ComicSchema from "./ComicConfig.schema.json"
|
||||||
|
export interface ComicConfig{
|
||||||
|
watch:string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ComicConfig = new ConfigManager<ComicConfig>("comic_config.json",{watch:[]},ComicSchema);
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
import {ConfigManager} from '../../util/configRW';
|
|
||||||
import MangaSchema from "./MangaConfig.schema.json"
|
|
||||||
export interface MangaConfig{
|
|
||||||
watch:string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export const MangaConfig = new ConfigManager<MangaConfig>("manga_config.json",{watch:[]},MangaSchema);
|
|
||||||
|
|
@ -3,15 +3,15 @@ import {EventEmitter} from 'events';
|
|||||||
import { DocumentAccessor } from '../../model/doc';
|
import { DocumentAccessor } from '../../model/doc';
|
||||||
import { WatcherFilter } from './watcher_filter';
|
import { WatcherFilter } from './watcher_filter';
|
||||||
import { RecursiveWatcher } from './recursive_watcher';
|
import { RecursiveWatcher } from './recursive_watcher';
|
||||||
import { MangaConfig } from './MangaConfig';
|
import { ComicConfig } from './ComicConfig';
|
||||||
import {WatcherCompositer} from './compositer'
|
import {WatcherCompositer} from './compositer'
|
||||||
|
|
||||||
|
|
||||||
const createMangaWatcherBase = (path:string)=> {
|
const createComicWatcherBase = (path:string)=> {
|
||||||
return new WatcherFilter(new RecursiveWatcher(path),(x)=>x.endsWith(".zip"));
|
return new WatcherFilter(new RecursiveWatcher(path),(x)=>x.endsWith(".zip"));
|
||||||
}
|
}
|
||||||
export const createMangaWatcher = ()=>{
|
export const createComicWatcher = ()=>{
|
||||||
const file = MangaConfig.get_config_file();
|
const file = ComicConfig.get_config_file();
|
||||||
console.log(`register manga ${file.watch.join(",")}`)
|
console.log(`register comic ${file.watch.join(",")}`)
|
||||||
return new WatcherCompositer(file.watch.map(path=>createMangaWatcherBase(path)));
|
return new WatcherCompositer(file.watch.map(path=>createComicWatcherBase(path)));
|
||||||
}
|
}
|
@ -2,11 +2,11 @@ import { DefaultContext, Middleware, Next, ParameterizedContext } from 'koa';
|
|||||||
import compose from 'koa-compose';
|
import compose from 'koa-compose';
|
||||||
import Router, { IParamMiddleware } from 'koa-router';
|
import Router, { IParamMiddleware } from 'koa-router';
|
||||||
import { ContentContext } from './context';
|
import { ContentContext } from './context';
|
||||||
import MangaRouter from './manga';
|
import ComicRouter from './comic';
|
||||||
import VideoRouter from './video';
|
import VideoRouter from './video';
|
||||||
|
|
||||||
const table:{[s:string]:Router|undefined} = {
|
const table:{[s:string]:Router|undefined} = {
|
||||||
"manga": new MangaRouter,
|
"comic": new ComicRouter,
|
||||||
"video": new VideoRouter
|
"video": new VideoRouter
|
||||||
}
|
}
|
||||||
const all_middleware = (cont: string|undefined, restarg: string|undefined)=>async (ctx:ParameterizedContext<ContentContext,DefaultContext>,next:Next)=>{
|
const all_middleware = (cont: string|undefined, restarg: string|undefined)=>async (ctx:ParameterizedContext<ContentContext,DefaultContext>,next:Next)=>{
|
||||||
|
@ -84,7 +84,7 @@ async function renderZipImage(ctx: Context, path: string, page: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MangaRouter extends Router<ContentContext> {
|
export class ComicRouter extends Router<ContentContext> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.get("/", async (ctx, next) => {
|
this.get("/", async (ctx, next) => {
|
||||||
@ -100,4 +100,4 @@ export class MangaRouter extends Router<ContentContext> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MangaRouter;
|
export default ComicRouter;
|
@ -14,7 +14,7 @@ import {createUserMiddleWare, createLoginRouter, isAdminFirst, getAdmin} from '.
|
|||||||
|
|
||||||
import {createInterface as createReadlineInterface} from 'readline';
|
import {createInterface as createReadlineInterface} from 'readline';
|
||||||
import { DocumentAccessor, UserAccessor } from './model/mod';
|
import { DocumentAccessor, UserAccessor } from './model/mod';
|
||||||
import { createMangaWatcher } from './diff/watcher/manga_watcher';
|
import { createComicWatcher } from './diff/watcher/comic_watcher';
|
||||||
|
|
||||||
class ServerApplication{
|
class ServerApplication{
|
||||||
readonly userController: UserAccessor;
|
readonly userController: UserAccessor;
|
||||||
@ -50,7 +50,7 @@ class ServerApplication{
|
|||||||
app.use(createUserMiddleWare(this.userController));
|
app.use(createUserMiddleWare(this.userController));
|
||||||
|
|
||||||
let diff_router = createDiffRouter(this.diffManger);
|
let diff_router = createDiffRouter(this.diffManger);
|
||||||
this.diffManger.register("manga",createMangaWatcher());
|
this.diffManger.register("comic",createComicWatcher());
|
||||||
let router = new Router();
|
let router = new Router();
|
||||||
|
|
||||||
router.use('/api/diff',diff_router.routes());
|
router.use('/api/diff',diff_router.routes());
|
||||||
|
Loading…
Reference in New Issue
Block a user