🪛 Refactoring to use the updated rendition path
This commit is contained in:
@@ -22,23 +22,17 @@ class Card extends React.Component<IProps, IState> {
|
|||||||
public drawCoverCard = (
|
public drawCoverCard = (
|
||||||
metadata: IExtractedComicBookCoverFile,
|
metadata: IExtractedComicBookCoverFile,
|
||||||
): JSX.Element => {
|
): JSX.Element => {
|
||||||
const filePath = encodeURI(
|
const encodedFilePath = encodeURI(
|
||||||
"http://localhost:3000" +
|
"http://localhost:3000" + removeLeadingPeriod(metadata.path),
|
||||||
removeLeadingPeriod(metadata.path) +
|
|
||||||
"/" +
|
|
||||||
metadata.name,
|
|
||||||
);
|
);
|
||||||
|
const filePath = escapePoundSymbol(encodedFilePath);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="card generic-card">
|
<div className="card generic-card">
|
||||||
<div>
|
<div>
|
||||||
<div className="card-image">
|
<div className="card-image">
|
||||||
<figure className="image">
|
<figure className="image">
|
||||||
<img
|
<img src={filePath} alt="Placeholder image" />
|
||||||
src={escapePoundSymbol(filePath)}
|
|
||||||
alt="Placeholder image"
|
|
||||||
/>
|
|
||||||
</figure>
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
<div className="card-content">
|
<div className="card-content">
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
getRecentlyImportedComicBooks({
|
getRecentlyImportedComicBooks({
|
||||||
paginationOptions: {
|
paginationOptions: {
|
||||||
page: 0,
|
page: 0,
|
||||||
limit: 18,
|
limit: 31,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -166,8 +166,8 @@ export const refineQuery = (inputString) => {
|
|||||||
return {
|
return {
|
||||||
searchParams: {
|
searchParams: {
|
||||||
searchTerms: {
|
searchTerms: {
|
||||||
name: queryObj.sentence_tokens.detailed[0].text,
|
name: queryObj.comicbook_identifier_tokens.inputString,
|
||||||
number: queryObj.comicbook_identifier_tokens.issueNumbers,
|
number: queryObj.comicbook_identifier_tokens.parsedIssueNumber,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ export const removeLeadingPeriod = (input: string): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const escapePoundSymbol = (input: string): string => {
|
export const escapePoundSymbol = (input: string): string => {
|
||||||
return input.replace(/\#/gi, "%23");
|
return input.replace(/\#/gm, "%23");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,15 +9,33 @@ export const matchScorer = (searchMatches, searchQuery) => {
|
|||||||
// 5. Check if issue year matches strongly (score: +)
|
// 5. Check if issue year matches strongly (score: +)
|
||||||
const score = 0;
|
const score = 0;
|
||||||
each(searchMatches, (match, idx) => {
|
each(searchMatches, (match, idx) => {
|
||||||
if (!isNull(searchQuery.issue.meta.normalized) && !isNull(match.name)) {
|
console.log("SEARCH QUERY IN SMS:", searchQuery);
|
||||||
|
console.log("MATCH NAME:", match);
|
||||||
|
match.score = 0;
|
||||||
|
if (
|
||||||
|
!isNull(searchQuery.issue.searchParams.searchTerms.name) &&
|
||||||
|
!isNull(match.name)
|
||||||
|
) {
|
||||||
const issueNameScore = stringSimilarity.compareTwoStrings(
|
const issueNameScore = stringSimilarity.compareTwoStrings(
|
||||||
searchQuery.issue.meta.normalized,
|
searchQuery.issue.searchParams.searchTerms.name,
|
||||||
match.name,
|
match.name,
|
||||||
);
|
);
|
||||||
match.score = issueNameScore;
|
match.score = issueNameScore;
|
||||||
console.log("name score" + idx + ":", issueNameScore);
|
console.log("name score" + idx + ":", issueNameScore);
|
||||||
} else {
|
}
|
||||||
console.log("match not possible");
|
|
||||||
|
// issue number matches
|
||||||
|
if (
|
||||||
|
!isNull(searchQuery.issue.searchParams.searchTerms.number) &&
|
||||||
|
!isNull(match.issue_number)
|
||||||
|
) {
|
||||||
|
if (
|
||||||
|
parseInt(searchQuery.issue.searchParams.searchTerms.number, 10) ===
|
||||||
|
parseInt(match.issue_number, 10)
|
||||||
|
) {
|
||||||
|
match.score += 2;
|
||||||
|
console.log(match.score);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return searchMatches;
|
return searchMatches;
|
||||||
|
|||||||
@@ -11,11 +11,6 @@ import { EnumLinkRel } from "opds-extra/lib/const";
|
|||||||
import { async as FastGlob } from "@bluelovers/fast-glob/bluebird";
|
import { async as FastGlob } from "@bluelovers/fast-glob/bluebird";
|
||||||
import { Entry, Feed } from "opds-extra/lib/v1";
|
import { Entry, Feed } from "opds-extra/lib/v1";
|
||||||
import { Link } from "opds-extra/lib/v1/core";
|
import { Link } from "opds-extra/lib/v1/core";
|
||||||
import SocketService from "./utils/airdcpp.socket.service";
|
|
||||||
|
|
||||||
function sleep(ms) {
|
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
// call express
|
// call express
|
||||||
const app: Express = express(); // define our app using express
|
const app: Express = express(); // define our app using express
|
||||||
@@ -48,9 +43,7 @@ export function opdsRouter() {
|
|||||||
}).each((file) => {
|
}).each((file) => {
|
||||||
const ext = extname(file);
|
const ext = extname(file);
|
||||||
const title = basename(file, ext);
|
const title = basename(file, ext);
|
||||||
|
|
||||||
const href = encodeURI(`/file/${file}`);
|
const href = encodeURI(`/file/${file}`);
|
||||||
|
|
||||||
const type = lookup(ext) || "application/octet-stream";
|
const type = lookup(ext) || "application/octet-stream";
|
||||||
|
|
||||||
const entry = Entry.deserialize<Entry>({
|
const entry = Entry.deserialize<Entry>({
|
||||||
@@ -99,45 +92,9 @@ app.get("/", (req: Request, res: Response) => {
|
|||||||
console.log("sending index.html");
|
console.log("sending index.html");
|
||||||
res.sendFile("/dist/index.html");
|
res.sendFile("/dist/index.html");
|
||||||
});
|
});
|
||||||
interface SearchInstance {
|
|
||||||
current_search_id: string;
|
|
||||||
expires_in: number;
|
|
||||||
id: number;
|
|
||||||
owner: string;
|
|
||||||
query: Record<string, unknown>;
|
|
||||||
queue_time: number;
|
|
||||||
queued_count: number;
|
|
||||||
result_count: number;
|
|
||||||
searches_sent_ago: number;
|
|
||||||
}
|
|
||||||
app.use(opdsRouter());
|
app.use(opdsRouter());
|
||||||
|
|
||||||
const foo = SocketService.connect("admin", "password");
|
|
||||||
foo.then(async (data) => {
|
|
||||||
const instance: SearchInstance = await SocketService.post("search");
|
|
||||||
await sleep(10000);
|
|
||||||
|
|
||||||
const searchInfo = await SocketService.post(
|
|
||||||
`search/${instance.id}/hub_search`,
|
|
||||||
{
|
|
||||||
query: {
|
|
||||||
pattern: "H.P. Lovecraft",
|
|
||||||
file_type: "compressed",
|
|
||||||
extensions: ["cbz", "cbr"],
|
|
||||||
},
|
|
||||||
hub_urls: [
|
|
||||||
"nmdcs://piter.feardc.net:411",
|
|
||||||
"dchub://dc.rutrack.net",
|
|
||||||
"dchub://dc.elitedc.ru",
|
|
||||||
],
|
|
||||||
priority: 1,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
await sleep(10000);
|
|
||||||
const results = await SocketService.get(`search/${instance.id}/results/0/5`);
|
|
||||||
console.log(results);
|
|
||||||
});
|
|
||||||
|
|
||||||
// REGISTER ROUTES
|
// REGISTER ROUTES
|
||||||
// all of the routes will be prefixed with /api
|
// all of the routes will be prefixed with /api
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user