documentation/search/search_index.json

1 line
12 KiB
JSON
Raw Normal View History

{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Getting Started","text":""},{"location":"#what-is-this","title":"What is this","text":"<p>txtdot is a proxy that requests the page by the given URL, extracts only useful data including text, links, pictures and tables, and returns it as an HTML page with a minimalistic design optimized for text reading.</p> <p>txtdot increases the loading speed and reduces client's bandwidth usage since no unnecessary code and no scripts are transferred. Also, you won't see any advertisement (unless it's a static picture that is hard to detect as ads). There are no trackers too.</p>"},{"location":"#how-to-use-it","title":"How to use it","text":"<p>txtdot is an open source software, so everyone can host it on his own server. The official instance is txt.dc09.ru, the list of all instances is here.</p> <p>On the main page, there's a handy form where you can specify a URL, choose an engine and a format for parsed data. On the <code>/get</code> page, \"Home\" button returns you to <code>/</code>, \"Original page\" opens the entered URL in the same window without txtdot proxy.</p> <p>The latest docs for API endpoints can be found here. For handy JSON API, use <code>/api/parse</code> returning an engine result object (see below). For pure HTML response, use <code>/api/raw-html</code>. Note that both API and browser endpoints on txt.dc09.ru are ratelimited to 2 requests per second.</p>"},{"location":"#how-it-works","title":"How it works","text":"<p>This project exists thanks to great Mozilla's Readability.js library. The initial idea was to process HTML with it on the server so the client does not need to download and execute heavy JS, doesn't need to use an adblock.</p> <p>Readability performs its work very well in most cases.</p> <p>If an <code>?engine=</code> parameter wasn't passed, but txtdot found that a specific engine is assigned to the requested domain, for example, <code>\"stackoverflow.com\": engines.StackOverflow</code>, it uses that engine to process the URL. Otherwise, the page is parsed with the engine assigned to <code>*</code> (it's Readability).</p>"},{"location":"#plugins","title":"Plugins","text":"<p>Readability is good, but now always, so artegoser wrote the basis of the code keeping in mind that we'll extend txtdot with other engines. Back then, it was functions taking a URL as a parameter, returning an object that contains extracted HTML and plain text, page title and language. The object is rendered with ejs template (or, in <code>/api/parse</code>, just sent as JSON).</p> <p>But after a while it became unwieldy and we decided to create a monorepo. We created classes Engines, Middlewares that handle the necessary parts. Now you can create such functions for different domains, and routes. Also we added support for JSX for simplifying the code of plugins.</p>"},{"location":"#engines","title":"Engines","text":"<p>Creation of engines is easy.</p> <pre><code>import { Engine, Route } from \"@txtdot/sdk\";\n\nconst Readability = new Engine(\n \"Readability\", // Name of the engine\n \"Engine for parsing content with Readability\", // Description\n [\"*\"] // Domains that use this engine\n);\n\nReadability.route(\"*path\", async (input, ro: Route&lt;{ path: string }&gt;) =&gt; {\n // ...\n\n // If any of the parameters except content is empty, txtdot will try to extract it from the page automatically\n return {\n content: parsed.content,\n title: parsed.title,\n lang: parsed.lang,\n };\n});\n</code></pre>"},{"location":"#middlewares","title":"Middlewares","text":"<p>Creation of middlewares similar to engines.</p> <pre><code>import { Middleware } from \"@txtdot/sdk\";\n\nconst Highlight = new Middleware(\n \"Highlight\",\n \"Highlights code with highlight.js only when needed\",\n [\"*\"]\n);\n\nHighlight.use(async (input, ro, out) =&gt; {\n if (out.content.indexOf(\"&lt;code\") !== -1)\n return {\n ...out,\n content: &lt;Highlighter content={out.content} /&gt;,\n };\n\n return out;\n