From f39f3d9225857673ec2256af660cb95b7bf44e9f Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Mon, 21 Aug 2023 17:02:52 +0400 Subject: [PATCH 1/8] Frontend: error page --- static/common.css | 10 ++++--- static/form.css | 60 +++++++++++++++++++++++++++++++++++++++++ static/index.css | 65 +++------------------------------------------ templates/error.ejs | 21 +++++++++++++++ templates/index.ejs | 3 ++- 5 files changed, 93 insertions(+), 66 deletions(-) create mode 100644 static/form.css create mode 100644 templates/error.ejs diff --git a/static/common.css b/static/common.css index 7c455f4..f8a6360 100644 --- a/static/common.css +++ b/static/common.css @@ -9,8 +9,10 @@ --bg2: #bbb; --fg2: #333; - --accent: hsl(207, 100%, 40%); - --accent-hl: hsl(207, 100%, 20%); + --accent: #0070cc; /* hsl(207, 100%, 40%) */ + --accent-hl: #003866; /* hsl(207, 100%, 20%) */ + + --error: #ff9400; } @media (prefers-color-scheme: dark) { @@ -21,8 +23,8 @@ --bg2: #444; --fg2: #bbb; - --accent: hsl(207, 100%, 60%); - --accent-hl: hsl(207, 100%, 80%); + --accent: #33a3ff; /* hsl(207, 100%, 60%) */ + --accent-hl: #99d1ff; /* hsl(207, 100%, 80%) */ } } diff --git a/static/form.css b/static/form.css new file mode 100644 index 0000000..67e9cd7 --- /dev/null +++ b/static/form.css @@ -0,0 +1,60 @@ +.input-grid { + display: grid; + /* 2 columns: auto width, min-content width */ + grid-template-columns: auto min-content; + + /* gap: row column */ + gap: 0.5rem 0.25rem; + + width: fit-content; +} + +.input-row { + display: flex; + flex-direction: row; + align-items: center; + gap: 0.75rem; +} + +.input { + display: flex; + flex-direction: row; + align-items: center; + gap: 0.25rem; +} + +label { + font-size: 0.9rem; +} + +#url { + width: 100%; + height: 100%; /* shrink to #submit height */ + + outline: none; + border: 0; + border-bottom: 0.125rem solid var(--fg2); + + background: var(--bg); + color: var(--fg); + font-size: 1rem; +} +#url::placeholder { + color: var(--fg2); + opacity: 1; +} + +#submit { + font-size: 1rem; +} + +select { + border: 0; + border-bottom: 0.125rem solid var(--accent); + + background: var(--bg); + color: var(--fg); + + font-weight: 500; + font-size: 0.9rem; +} diff --git a/static/index.css b/static/index.css index 4c3fc3d..9d17548 100644 --- a/static/index.css +++ b/static/index.css @@ -8,67 +8,10 @@ h1 { width: fit-content; margin: auto; } -h1 > span { + +h1 > .dot { color: var(--accent); } - -.input-grid { - display: grid; - /* 2 columns: auto width, min-content width */ - grid-template-columns: auto min-content; - - /* gap: row column */ - gap: 0.5rem 0.25rem; - - width: fit-content; -} - -.input-row { - display: flex; - flex-direction: row; - align-items: center; - gap: 0.75rem; -} - -.input { - display: flex; - flex-direction: row; - align-items: center; - gap: 0.25rem; -} - -label { - font-size: 0.9rem; -} - -#url { - width: 100%; - height: 100%; /* shrink to #submit height */ - - outline: none; - border: 0; - border-bottom: 0.125rem solid var(--fg2); - - background: var(--bg); - color: var(--fg); - font-size: 1rem; -} -#url::placeholder { - color: var(--fg2); - opacity: 1; -} - -#submit { - font-size: 1rem; -} - -select { - border: 0; - border-bottom: 0.125rem solid var(--accent); - - background: var(--bg); - color: var(--fg); - - font-weight: 500; - font-size: 0.9rem; +h1 > .dot-err { + color: var(--error); } diff --git a/templates/error.ejs b/templates/error.ejs new file mode 100644 index 0000000..361311e --- /dev/null +++ b/templates/error.ejs @@ -0,0 +1,21 @@ + + + + + + + + txt. <%= title %> + + + + +
+
+

txt.

+

<%= description %>

+
+ Home +
+ + diff --git a/templates/index.ejs b/templates/index.ejs index 70e1c72..d4c7528 100644 --- a/templates/index.ejs +++ b/templates/index.ejs @@ -9,11 +9,12 @@ txt. main page +
-

txt.

+

txt.

<%= desc %>

From 7cb254f523ac9320d846761af7967c29d57b04cd Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Mon, 21 Aug 2023 17:03:28 +0400 Subject: [PATCH 2/8] Weird error matching --- src/errors/handler.ts | 23 ++++++++++++++++++++++- src/errors/main.ts | 11 +++++++++-- src/handlers/main.ts | 4 ++-- src/types/requests.ts | 6 +----- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/errors/handler.ts b/src/errors/handler.ts index 58365ae..fd2681b 100644 --- a/src/errors/handler.ts +++ b/src/errors/handler.ts @@ -1,5 +1,5 @@ import { FastifyReply, FastifyRequest } from "fastify"; -import { NotHtmlMimetypeError } from "./main"; +import { EngineParseError, IFastifyValidationError, InvalidParameterError, LocalResourceError, NotHtmlMimetypeError } from "./main"; export default function errorHandler( error: Error, @@ -8,7 +8,28 @@ export default function errorHandler( ) { if (error instanceof NotHtmlMimetypeError) { return reply.redirect(301, error.url); + } else if (error instanceof EngineParseError) { + return reply.code(500).view("/templates/error.ejs", { + title: "parse error", + description: "Engine can not parse the HTML page received from the remote server.", + }); + } else if ( + error instanceof InvalidParameterError || + ( + error as unknown as IFastifyValidationError + )?.statusCode === 400 + ) { + return reply.code(400).view("/templates/error.ejs", { + title: "invalid parameter", + description: `Specified parameters are invalid.`, + }); + } else if (error instanceof LocalResourceError) { + return reply.code(403).view("/templates/error.ejs", { + title: "local resource", + description: "Proxying local resources is forbidden.", + }); } else { + console.log(error); return error; } } diff --git a/src/errors/main.ts b/src/errors/main.ts index bd528bd..07893e6 100644 --- a/src/errors/main.ts +++ b/src/errors/main.ts @@ -1,10 +1,17 @@ export class EngineParseError extends Error {} export class InvalidParameterError extends Error {} export class LocalResourceError extends Error {} + export class NotHtmlMimetypeError extends Error { url: string; - constructor(params: { url: string }) { + constructor(url: string) { super(); - this.url = params?.url; + this.url = url; } } + +export interface IFastifyValidationError { + statusCode: number; + code: string; + validation: any; +} diff --git a/src/handlers/main.ts b/src/handlers/main.ts index 0fbb172..27863d9 100644 --- a/src/handlers/main.ts +++ b/src/handlers/main.ts @@ -29,14 +29,14 @@ export default async function handlePage( } if (engine && engineList.indexOf(engine) === -1) { - throw new InvalidParameterError("Invalid engine"); + throw new InvalidParameterError("engine"); } const response = await axios.get(url); const mime: string | undefined = response.headers["content-type"]?.toString(); if (mime && mime.indexOf("text/html") === -1) { - throw new NotHtmlMimetypeError({ url }); + throw new NotHtmlMimetypeError(url); } const window = new JSDOM(response.data, { url }).window; diff --git a/src/types/requests.ts b/src/types/requests.ts index e395149..37271f9 100644 --- a/src/types/requests.ts +++ b/src/types/requests.ts @@ -3,11 +3,7 @@ import { handlerSchema } from "../handlers/handler.interface"; import { engineList } from "../handlers/main"; export type GetRequest = FastifyRequest<{ - Querystring: { - url: string; - format?: string; - engine?: string; - }; + Querystring: IGetQuery; }>; export interface IGetQuery { From 77058ede74f89bab958f00a3edbafbad1085d1e6 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Mon, 21 Aug 2023 18:35:25 +0400 Subject: [PATCH 3/8] Refactored error handling --- src/errors/handler.ts | 51 +++++++++++++++++++++------------------- src/errors/main.ts | 32 ++++++++++++++++++------- src/errors/validation.ts | 9 +++++++ src/handlers/main.ts | 13 +++++----- templates/error.ejs | 2 +- 5 files changed, 66 insertions(+), 41 deletions(-) create mode 100644 src/errors/validation.ts diff --git a/src/errors/handler.ts b/src/errors/handler.ts index fd2681b..34782b6 100644 --- a/src/errors/handler.ts +++ b/src/errors/handler.ts @@ -1,35 +1,38 @@ import { FastifyReply, FastifyRequest } from "fastify"; -import { EngineParseError, IFastifyValidationError, InvalidParameterError, LocalResourceError, NotHtmlMimetypeError } from "./main"; +import { NotHtmlMimetypeError, TxtDotError } from "./main"; +import { getFastifyError } from "./validation"; export default function errorHandler( error: Error, _: FastifyRequest, reply: FastifyReply ) { + // TODO: check if req.url starts with "/api/" and return JSON + + return htmlErrorHandler(error, reply); +} + +function htmlErrorHandler(error: Error, reply: FastifyReply) { if (error instanceof NotHtmlMimetypeError) { return reply.redirect(301, error.url); - } else if (error instanceof EngineParseError) { - return reply.code(500).view("/templates/error.ejs", { - title: "parse error", - description: "Engine can not parse the HTML page received from the remote server.", - }); - } else if ( - error instanceof InvalidParameterError || - ( - error as unknown as IFastifyValidationError - )?.statusCode === 400 - ) { - return reply.code(400).view("/templates/error.ejs", { - title: "invalid parameter", - description: `Specified parameters are invalid.`, - }); - } else if (error instanceof LocalResourceError) { - return reply.code(403).view("/templates/error.ejs", { - title: "local resource", - description: "Proxying local resources is forbidden.", - }); - } else { - console.log(error); - return error; } + + if (getFastifyError(error)?.statusCode === 400) { + return reply.code(400).view("/templates/error.ejs", { + code: 400, + description: `Invalid parameter specified: ${error.message}`, + }) + } + + if (error instanceof TxtDotError) { + return reply.code(error.code).view("/templates/error.ejs", { + code: error.code, + description: error.description, + }); + } + + return reply.code(500).view("/templates/error.ejs", { + code: 500, + description: `${error.name}: ${error.message}`, + }); } diff --git a/src/errors/main.ts b/src/errors/main.ts index 07893e6..7a07f65 100644 --- a/src/errors/main.ts +++ b/src/errors/main.ts @@ -1,17 +1,31 @@ -export class EngineParseError extends Error {} -export class InvalidParameterError extends Error {} -export class LocalResourceError extends Error {} +export class TxtDotError extends Error { + code: number; + description: string; + + constructor(code: number, description: string) { + super(description); + this.code = code; + this.description = description; + } +} + +export class EngineParseError extends TxtDotError { + constructor(message: string) { + super(500, `Parse error: ${message}`); + } +} + +export class LocalResourceError extends TxtDotError { + constructor() { + super(403, "Proxying local resources is forbidden."); + } +} export class NotHtmlMimetypeError extends Error { url: string; + constructor(url: string) { super(); this.url = url; } } - -export interface IFastifyValidationError { - statusCode: number; - code: string; - validation: any; -} diff --git a/src/errors/validation.ts b/src/errors/validation.ts new file mode 100644 index 0000000..5304da8 --- /dev/null +++ b/src/errors/validation.ts @@ -0,0 +1,9 @@ +export interface IFastifyValidationError { + statusCode?: number; + code?: string; + validation?: any; +} + +export function getFastifyError(error: Error) { + return error as unknown as IFastifyValidationError; +} diff --git a/src/handlers/main.ts b/src/handlers/main.ts index 27863d9..7a37f5b 100644 --- a/src/handlers/main.ts +++ b/src/handlers/main.ts @@ -6,16 +6,15 @@ import { DOMWindow } from "jsdom"; import readability from "./readability"; import google from "./google"; +import stackoverflow from "./stackoverflow/main"; import { generateProxyUrl } from "../utils/generate"; import isLocalResource from "../utils/islocal"; import { - InvalidParameterError, LocalResourceError, NotHtmlMimetypeError, } from "../errors/main"; -import stackoverflow from "./stackoverflow/main"; export default async function handlePage( url: string, // remote URL @@ -28,10 +27,6 @@ export default async function handlePage( throw new LocalResourceError(); } - if (engine && engineList.indexOf(engine) === -1) { - throw new InvalidParameterError("engine"); - } - const response = await axios.get(url); const mime: string | undefined = response.headers["content-type"]?.toString(); @@ -42,7 +37,11 @@ export default async function handlePage( const window = new JSDOM(response.data, { url }).window; [...window.document.getElementsByTagName("a")].forEach((link) => { - link.href = generateProxyUrl(requestUrl, link.href, engine); + try { + link.href = generateProxyUrl(requestUrl, link.href, engine); + } catch (_err) { + // ignore TypeError: Invalid URL + } }); if (engine) { diff --git a/templates/error.ejs b/templates/error.ejs index 361311e..10aba6b 100644 --- a/templates/error.ejs +++ b/templates/error.ejs @@ -5,7 +5,7 @@ - txt. <%= title %> + txt. <%= code %> From e106509c45149d3bde15c973aab83f3c61025a0c Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Mon, 21 Aug 2023 18:36:05 +0400 Subject: [PATCH 4/8] CSS: centered text --- static/index.css | 1 + 1 file changed, 1 insertion(+) diff --git a/static/index.css b/static/index.css index 9d17548..5a2d551 100644 --- a/static/index.css +++ b/static/index.css @@ -2,6 +2,7 @@ main { display: flex; flex-direction: column; align-items: center; + text-align: center; } h1 { From 66ce1caab02dc0292565b63f6c2f446300b981ae Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Wed, 23 Aug 2023 13:46:19 +0400 Subject: [PATCH 5/8] Error handler for API, separated schemas --- src/errors/api.ts | 34 +++++++++++++ src/errors/handler.ts | 34 +++++++++++-- src/errors/main.ts | 11 ++-- src/routes/get.ts | 2 +- src/routes/index.ts | 2 +- src/routes/parse.ts | 23 +++++---- src/routes/raw-html.ts | 4 +- src/types/requests.ts | 95 ----------------------------------- src/types/requests/api.ts | 66 ++++++++++++++++++++++++ src/types/requests/browser.ts | 48 ++++++++++++++++++ 10 files changed, 205 insertions(+), 114 deletions(-) create mode 100644 src/errors/api.ts delete mode 100644 src/types/requests.ts create mode 100644 src/types/requests/api.ts create mode 100644 src/types/requests/browser.ts diff --git a/src/errors/api.ts b/src/errors/api.ts new file mode 100644 index 0000000..4d0728c --- /dev/null +++ b/src/errors/api.ts @@ -0,0 +1,34 @@ +export interface IApiError { + code: number; + name: string; + message: string; +} + +export const errorSchema = { + type: "object", + properties: { + code: { + type: "number", + description: "HTTP error code", + }, + name: { + type: "string", + description: "Exception class name", + }, + message: { + type: "string", + description: "Exception message", + }, + }, +}; + +export const errorResponseSchema = { + type: "object", + properties: { + data: { + type: "object", + nullable: true, + }, + error: errorSchema, + }, +}; diff --git a/src/errors/handler.ts b/src/errors/handler.ts index 34782b6..b23560b 100644 --- a/src/errors/handler.ts +++ b/src/errors/handler.ts @@ -4,14 +4,42 @@ import { getFastifyError } from "./validation"; export default function errorHandler( error: Error, - _: FastifyRequest, + req: FastifyRequest, reply: FastifyReply ) { - // TODO: check if req.url starts with "/api/" and return JSON - + if (req.originalUrl.startsWith("/api/")) { + return apiErrorHandler(error, reply); + } return htmlErrorHandler(error, reply); } +function apiErrorHandler(error: Error, reply: FastifyReply) { + function generateResponse(code: number) { + return reply.code(code).send({ + data: null, + error: { + code: code, + name: error.name, + message: error.message, + }, + }); + } + + if (error instanceof NotHtmlMimetypeError) { + return generateResponse(501); + } + + if (getFastifyError(error)?.statusCode === 400) { + return generateResponse(400); + } + + if (error instanceof TxtDotError) { + return generateResponse(error.code); + } + + return generateResponse(500); +} + function htmlErrorHandler(error: Error, reply: FastifyReply) { if (error instanceof NotHtmlMimetypeError) { return reply.redirect(301, error.url); diff --git a/src/errors/main.ts b/src/errors/main.ts index 7a07f65..29190c9 100644 --- a/src/errors/main.ts +++ b/src/errors/main.ts @@ -1,27 +1,30 @@ -export class TxtDotError extends Error { +export abstract class TxtDotError extends Error { code: number; + name: string; description: string; - constructor(code: number, description: string) { + constructor(code: number, name: string, description: string) { super(description); this.code = code; + this.name = name; this.description = description; } } export class EngineParseError extends TxtDotError { constructor(message: string) { - super(500, `Parse error: ${message}`); + super(422, "EngineParseError", `Parse error: ${message}`); } } export class LocalResourceError extends TxtDotError { constructor() { - super(403, "Proxying local resources is forbidden."); + super(403, "LocalResourceError", "Proxying local resources is forbidden."); } } export class NotHtmlMimetypeError extends Error { + name: string = "NotHtmlMimetypeError"; url: string; constructor(url: string) { diff --git a/src/routes/get.ts b/src/routes/get.ts index dbd1e59..795b7e2 100644 --- a/src/routes/get.ts +++ b/src/routes/get.ts @@ -1,6 +1,6 @@ import { FastifyInstance } from "fastify"; -import { GetSchema, IGetSchema } from "../types/requests"; +import { GetSchema, IGetSchema } from "../types/requests/browser"; import handlePage from "../handlers/main"; import { generateRequestUrl } from "../utils/generate"; diff --git a/src/routes/index.ts b/src/routes/index.ts index ea3ff2d..00d6dba 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -1,6 +1,6 @@ import { FastifyInstance } from "fastify"; import { engineList } from "../handlers/main"; -import { indexSchema } from "../types/requests"; +import { indexSchema } from "../types/requests/browser"; export default async function indexRoute(fastify: FastifyInstance) { fastify.get("/", { schema: indexSchema }, async (_, reply) => { diff --git a/src/routes/parse.ts b/src/routes/parse.ts index 24b5738..bca7d1d 100644 --- a/src/routes/parse.ts +++ b/src/routes/parse.ts @@ -1,5 +1,7 @@ -import { EngineRequest, IParseSchema, parseSchema } from "../types/requests"; import { FastifyInstance } from "fastify"; + +import { EngineRequest, IParseSchema, parseSchema } from "../types/requests/api"; + import handlePage from "../handlers/main"; import { generateRequestUrl } from "../utils/generate"; @@ -8,15 +10,18 @@ export default async function parseRoute(fastify: FastifyInstance) { "/api/parse", { schema: parseSchema }, async (request: EngineRequest) => { - return await handlePage( - request.query.url, - generateRequestUrl( - request.protocol, - request.hostname, - request.originalUrl + return { + data: await handlePage( + request.query.url, + generateRequestUrl( + request.protocol, + request.hostname, + request.originalUrl + ), + request.query.engine ), - request.query.engine - ); + error: null, + }; } ); } diff --git a/src/routes/raw-html.ts b/src/routes/raw-html.ts index 83ac62f..4665fe2 100644 --- a/src/routes/raw-html.ts +++ b/src/routes/raw-html.ts @@ -1,6 +1,8 @@ import { FastifyInstance } from "fastify"; -import { GetRequest, IParseSchema, rawHtmlSchema } from "../types/requests"; +import { IParseSchema, rawHtmlSchema } from "../types/requests/api"; +import { GetRequest } from "../types/requests/browser"; + import handlePage from "../handlers/main"; import { generateRequestUrl } from "../utils/generate"; diff --git a/src/types/requests.ts b/src/types/requests.ts deleted file mode 100644 index 37271f9..0000000 --- a/src/types/requests.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { FastifyRequest, FastifySchema } from "fastify"; -import { handlerSchema } from "../handlers/handler.interface"; -import { engineList } from "../handlers/main"; - -export type GetRequest = FastifyRequest<{ - Querystring: IGetQuery; -}>; - -export interface IGetQuery { - url: string; - format?: string; - engine?: string; -} - -export interface IParseQuery { - url: string; - engine?: string; -} - -export interface IGetSchema { - Querystring: IGetQuery; -} - -export interface IParseSchema { - Querystring: IParseQuery; -} - -export const indexSchema = { - produces: ["text/html"], - hide: true -}; - -export const getQuerySchema = { - type: "object", - required: ["url"], - properties: { - url: { - type: "string", - description: "URL", - }, - format: { - type: "string", - enum: ["text", "html", ""], - default: "html", - }, - engine: { - type: "string", - enum: [...engineList, ""], - }, - }, -}; - -export const parseQuerySchema = { - type: "object", - required: ["url"], - properties: { - url: { - type: "string", - description: "URL", - }, - engine: { - type: "string", - enum: [...engineList, ""], - }, - }, -}; - -export const GetSchema: FastifySchema = { - description: "Get page", - hide: true, - querystring: getQuerySchema, - produces: ["text/html", "text/plain"], -}; - -export const parseSchema: FastifySchema = { - description: "Parse page", - querystring: parseQuerySchema, - response: { - "2xx": handlerSchema, - }, - produces: ["text/json"], -}; - -export const rawHtmlSchema: FastifySchema = { - description: "Get raw HTML", - querystring: parseQuerySchema, - produces: ["text/html"], -}; - -export type EngineRequest = FastifyRequest<{ - Querystring: { - url: string; - engine?: string; - }; -}>; diff --git a/src/types/requests/api.ts b/src/types/requests/api.ts new file mode 100644 index 0000000..9e13803 --- /dev/null +++ b/src/types/requests/api.ts @@ -0,0 +1,66 @@ +import { FastifySchema, FastifyRequest } from "fastify"; +import { IApiError, errorResponseSchema } from "../../errors/api"; +import { handlerSchema } from "../../handlers/handler.interface"; +import { engineList } from "../../handlers/main"; + +export interface IApiResponse { + data?: T; + error?: IApiError; +} + +export interface IParseQuery { + url: string; + engine?: string; +} + +export interface IParseSchema { + Querystring: IParseQuery; +} + +export const parseQuerySchema = { + type: "object", + required: ["url"], + properties: { + url: { + type: "string", + description: "URL", + }, + engine: { + type: "string", + enum: [...engineList, ""], + }, + }, +}; + +export const parseSchema: FastifySchema = { + description: "Parse the page and get all data from the engine", + querystring: parseQuerySchema, + response: { + "2xx": { + type: "object", + properties: { + data: handlerSchema, + error: { + type: "object", + nullable: true, + }, + }, + }, + "4xx": errorResponseSchema, + "5xx": errorResponseSchema, + }, + produces: ["text/json"], +}; + +export const rawHtmlSchema: FastifySchema = { + description: "Parse the page and get raw HTML from the engine", + querystring: parseQuerySchema, + produces: ["text/html"], +}; + +export type EngineRequest = FastifyRequest<{ + Querystring: { + url: string; + engine?: string; + }; +}>; diff --git a/src/types/requests/browser.ts b/src/types/requests/browser.ts new file mode 100644 index 0000000..df526d9 --- /dev/null +++ b/src/types/requests/browser.ts @@ -0,0 +1,48 @@ +import { FastifyRequest, FastifySchema } from "fastify"; +import { engineList } from "../../handlers/main"; + +export type GetRequest = FastifyRequest<{ + Querystring: IGetQuery; +}>; + +export interface IGetQuery { + url: string; + format?: string; + engine?: string; +} + +export interface IGetSchema { + Querystring: IGetQuery; +} + +export const indexSchema = { + produces: ["text/html"], + hide: true +}; + +export const getQuerySchema = { + type: "object", + required: ["url"], + properties: { + url: { + type: "string", + description: "URL", + }, + format: { + type: "string", + enum: ["text", "html", ""], + default: "html", + }, + engine: { + type: "string", + enum: [...engineList, ""], + }, + }, +}; + +export const GetSchema: FastifySchema = { + description: "Get page", + hide: true, + querystring: getQuerySchema, + produces: ["text/html", "text/plain"], +}; From bfc871f3957e890890c04addf95ee17f41af9887 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Wed, 23 Aug 2023 15:43:57 +0400 Subject: [PATCH 6/8] CSS: border instead of hr, default margin --- static/get.css | 3 ++- templates/get.ejs | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/static/get.css b/static/get.css index 2ad8a71..b1ba611 100644 --- a/static/get.css +++ b/static/get.css @@ -5,9 +5,10 @@ font-size: 0.9rem; } + .title { + border-bottom: 0.125rem solid var(--bg2); font-weight: 600; - margin: 1rem; } a { diff --git a/templates/get.ejs b/templates/get.ejs index 20cbf27..6e7d18d 100644 --- a/templates/get.ejs +++ b/templates/get.ejs @@ -15,10 +15,9 @@ Home Original page -
+

<%= parsed.title %> -

-
+

<%- parsed.content %>
From 912a887179e65d55827ff5e6e0292c81192fee39 Mon Sep 17 00:00:00 2001 From: Artemy Egorov Date: Wed, 23 Aug 2023 17:23:17 +0300 Subject: [PATCH 7/8] 1.2.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8ce5347..eae6db3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "txtdot", - "version": "1.1.1", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "txtdot", - "version": "1.1.1", + "version": "1.2.0", "license": "MIT", "dependencies": { "@fastify/static": "^6.10.2", diff --git a/package.json b/package.json index 87583ee..40132d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "txtdot", - "version": "1.1.1", + "version": "1.2.0", "private": true, "description": "", "main": "dist/app.js", From c2ed53d3bbc472f53fe20cccba65460105aa8280 Mon Sep 17 00:00:00 2001 From: Artemy Egorov Date: Wed, 23 Aug 2023 17:24:17 +0300 Subject: [PATCH 8/8] doc: api version fix --- src/publicConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publicConfig.ts b/src/publicConfig.ts index bb34e36..847469e 100644 --- a/src/publicConfig.ts +++ b/src/publicConfig.ts @@ -1,5 +1,5 @@ export default { - version: "1.1.0", + version: "1.1.1", description: "HTTP proxy that parses only text, links and pictures from pages reducing internet traffic, removing ads and heavy scripts", };