web search done right
Build frontend using Astro (#37)
Oliver Bøvinge1a6e3322d20
diff --git a/askama.toml b/askama.tomlnew file mode 100644index 00000000..2e7370c4--- /dev/null+++ b/askama.toml@@ -0,0 +1,5 @@+[general]+# Directories to search for templates, relative to the crate root.+dirs = ["frontend/dist/"]+# Unless you add a `-` in a block, whitespace characters won't be trimmed.+whitespace = "preserve"diff --git a/build.rs b/build.rsindex 98dcc47d..b0b30318 100644--- a/build.rs+++ b/build.rs@@ -2,14 +2,16 @@ use std::process::Command;fn main() {Command::new("npm")+ .current_dir("frontend")+ .arg("install")+ .status()+ .unwrap();++ Command::new("npm")+ .current_dir("frontend").args(&["run", "build"]).status().unwrap();- println!("cargo:rerun-if-changed=tailwind.css");- println!("cargo:rerun-if-changed=package.json");- println!("cargo:rerun-if-changed=yarn.lock");- println!("cargo:rerun-if-changed=tailwind.config.js");- println!("cargo:rerun-if-changed=postcss.config.js");lalrpop::process_root().unwrap();}diff --git a/frontend/.gitignore b/frontend/.gitignorenew file mode 100644index 00000000..7329a851--- /dev/null+++ b/frontend/.gitignore@@ -0,0 +1,20 @@+# build output+dist/+.output/++# dependencies+node_modules/++# logs+npm-debug.log*+yarn-debug.log*+yarn-error.log*+pnpm-debug.log*+++# environment variables+.env+.env.production++# macOS-specific files+.DS_Storediff --git a/frontend/.npmrc b/frontend/.npmrcnew file mode 100644index 00000000..ef83021a--- /dev/null+++ b/frontend/.npmrc@@ -0,0 +1,2 @@+# Expose Astro dependencies for `pnpm` users+shamefully-hoist=truediff --git a/frontend/.vscode/extensions.json b/frontend/.vscode/extensions.jsonnew file mode 100644index 00000000..22a15055--- /dev/null+++ b/frontend/.vscode/extensions.json@@ -0,0 +1,4 @@+{+ "recommendations": ["astro-build.astro-vscode"],+ "unwantedRecommendations": []+}diff --git a/frontend/.vscode/launch.json b/frontend/.vscode/launch.jsonnew file mode 100644index 00000000..d6422097--- /dev/null+++ b/frontend/.vscode/launch.json@@ -0,0 +1,11 @@+{+ "version": "0.2.0",+ "configurations": [+ {+ "command": "./node_modules/.bin/astro dev",+ "name": "Development server",+ "request": "launch",+ "type": "node-terminal"+ }+ ]+}diff --git a/frontend/.vscode/settings.json b/frontend/.vscode/settings.jsonnew file mode 100644index 00000000..91352e3e--- /dev/null+++ b/frontend/.vscode/settings.json@@ -0,0 +1,6 @@+{+ "prettier.documentSelectors": ["**/*.astro"],+ "[astro]": {+ "editor.defaultFormatter": "esbenp.prettier-vscode"+ }+}diff --git a/frontend/astro.config.mjs b/frontend/astro.config.mjsnew file mode 100644index 00000000..13bdcb42--- /dev/null+++ b/frontend/astro.config.mjs@@ -0,0 +1,9 @@+import { defineConfig } from "astro/config";+import tailwind from "@astrojs/tailwind";++import mdx from "@astrojs/mdx";++// https://astro.build/config+export default defineConfig({+ integrations: [tailwind(), mdx()]+});\ No newline at end of filediff --git a/frontend/package.json b/frontend/package.jsonnew file mode 100644index 00000000..9c71e487--- /dev/null+++ b/frontend/package.json@@ -0,0 +1,23 @@+{+ "name": "@example/basics",+ "version": "0.0.1",+ "private": true,+ "scripts": {+ "dev": "astro dev",+ "start": "astro dev",+ "build": "astro build",+ "preview": "astro preview",+ "astro": "astro"+ },+ "dependencies": {+ "astro": "^1.1.6"+ },+ "devDependencies": {+ "@astrojs/mdx": "^0.11.1",+ "@astrojs/tailwind": "^1.0.0",+ "@tailwindcss/typography": "^0.5.7",+ "prettier": "^2.7.1",+ "prettier-plugin-astro": "^0.5.4",+ "prettier-plugin-tailwindcss": "^0.1.13"+ }+}diff --git a/static/images/favicon.ico b/frontend/public/assets/favicon.icosimilarity index 100%rename from static/images/favicon.icorename to frontend/public/assets/favicon.icodiff --git a/static/fonts/Montserrat-Black.ttf b/frontend/public/assets/fonts/Montserrat-Black.ttfsimilarity index 100%rename from static/fonts/Montserrat-Black.ttfrename to frontend/public/assets/fonts/Montserrat-Black.ttfdiff --git a/static/fonts/Montserrat-Black.woff b/frontend/public/assets/fonts/Montserrat-Black.woffsimilarity index 100%rename from static/fonts/Montserrat-Black.woffrename to frontend/public/assets/fonts/Montserrat-Black.woffdiff --git a/static/fonts/Montserrat-BlackItalic.ttf b/frontend/public/assets/fonts/Montserrat-BlackItalic.ttfsimilarity index 100%rename from static/fonts/Montserrat-BlackItalic.ttfrename to frontend/public/assets/fonts/Montserrat-BlackItalic.ttfdiff --git a/static/fonts/Montserrat-BlackItalic.woff b/frontend/public/assets/fonts/Montserrat-BlackItalic.woffsimilarity index 100%rename from static/fonts/Montserrat-BlackItalic.woffrename to frontend/public/assets/fonts/Montserrat-BlackItalic.woffdiff --git a/static/fonts/Montserrat-Bold.ttf b/frontend/public/assets/fonts/Montserrat-Bold.ttfsimilarity index 100%rename from static/fonts/Montserrat-Bold.ttfrename to frontend/public/assets/fonts/Montserrat-Bold.ttfdiff --git a/static/fonts/Montserrat-Bold.woff b/frontend/public/assets/fonts/Montserrat-Bold.woffsimilarity index 100%rename from static/fonts/Montserrat-Bold.woffrename to frontend/public/assets/fonts/Montserrat-Bold.woffdiff --git a/static/fonts/Montserrat-BoldItalic.ttf b/frontend/public/assets/fonts/Montserrat-BoldItalic.ttfsimilarity index 100%rename from static/fonts/Montserrat-BoldItalic.ttfrename to frontend/public/assets/fonts/Montserrat-BoldItalic.ttfdiff --git a/static/fonts/Montserrat-BoldItalic.woff b/frontend/public/assets/fonts/Montserrat-BoldItalic.woffsimilarity index 100%rename from static/fonts/Montserrat-BoldItalic.woffrename to frontend/public/assets/fonts/Montserrat-BoldItalic.woffdiff --git a/static/fonts/Montserrat-ExtraBold.ttf b/frontend/public/assets/fonts/Montserrat-ExtraBold.ttfsimilarity index 100%rename from static/fonts/Montserrat-ExtraBold.ttfrename to frontend/public/assets/fonts/Montserrat-ExtraBold.ttfdiff --git a/static/fonts/Montserrat-ExtraBold.woff b/frontend/public/assets/fonts/Montserrat-ExtraBold.woffsimilarity index 100%rename from static/fonts/Montserrat-ExtraBold.woffrename to frontend/public/assets/fonts/Montserrat-ExtraBold.woffdiff --git a/static/fonts/Montserrat-ExtraBoldItalic.ttf b/frontend/public/assets/fonts/Montserrat-ExtraBoldItalic.ttfsimilarity index 100%rename from static/fonts/Montserrat-ExtraBoldItalic.ttfrename to frontend/public/assets/fonts/Montserrat-ExtraBoldItalic.ttfdiff --git a/static/fonts/Montserrat-ExtraBoldItalic.woff b/frontend/public/assets/fonts/Montserrat-ExtraBoldItalic.woffsimilarity index 100%rename from static/fonts/Montserrat-ExtraBoldItalic.woffrename to frontend/public/assets/fonts/Montserrat-ExtraBoldItalic.woffdiff --git a/static/fonts/Montserrat-ExtraLight.ttf b/frontend/public/assets/fonts/Montserrat-ExtraLight.ttfsimilarity index 100%rename from static/fonts/Montserrat-ExtraLight.ttfrename to frontend/public/assets/fonts/Montserrat-ExtraLight.ttfdiff --git a/static/fonts/Montserrat-ExtraLight.woff b/frontend/public/assets/fonts/Montserrat-ExtraLight.woffsimilarity index 100%rename from static/fonts/Montserrat-ExtraLight.woffrename to frontend/public/assets/fonts/Montserrat-ExtraLight.woffdiff --git a/static/fonts/Montserrat-ExtraLightItalic.ttf b/frontend/public/assets/fonts/Montserrat-ExtraLightItalic.ttfsimilarity index 100%rename from static/fonts/Montserrat-ExtraLightItalic.ttfrename to frontend/public/assets/fonts/Montserrat-ExtraLightItalic.ttfdiff --git a/static/fonts/Montserrat-ExtraLightItalic.woff b/frontend/public/assets/fonts/Montserrat-ExtraLightItalic.woffsimilarity index 100%rename from static/fonts/Montserrat-ExtraLightItalic.woffrename to frontend/public/assets/fonts/Montserrat-ExtraLightItalic.woffdiff --git a/static/fonts/Montserrat-Italic.ttf b/frontend/public/assets/fonts/Montserrat-Italic.ttfsimilarity index 100%rename from static/fonts/Montserrat-Italic.ttfrename to frontend/public/assets/fonts/Montserrat-Italic.ttfdiff --git a/static/fonts/Montserrat-Italic.woff b/frontend/public/assets/fonts/Montserrat-Italic.woffsimilarity index 100%rename from static/fonts/Montserrat-Italic.woffrename to frontend/public/assets/fonts/Montserrat-Italic.woffdiff --git a/static/fonts/Montserrat-Light.ttf b/frontend/public/assets/fonts/Montserrat-Light.ttfsimilarity index 100%rename from static/fonts/Montserrat-Light.ttfrename to frontend/public/assets/fonts/Montserrat-Light.ttfdiff --git a/static/fonts/Montserrat-Light.woff b/frontend/public/assets/fonts/Montserrat-Light.woffsimilarity index 100%rename from static/fonts/Montserrat-Light.woffrename to frontend/public/assets/fonts/Montserrat-Light.woffdiff --git a/static/fonts/Montserrat-LightItalic.ttf b/frontend/public/assets/fonts/Montserrat-LightItalic.ttfsimilarity index 100%rename from static/fonts/Montserrat-LightItalic.ttfrename to frontend/public/assets/fonts/Montserrat-LightItalic.ttfdiff --git a/static/fonts/Montserrat-LightItalic.woff b/frontend/public/assets/fonts/Montserrat-LightItalic.woffsimilarity index 100%rename from static/fonts/Montserrat-LightItalic.woffrename to frontend/public/assets/fonts/Montserrat-LightItalic.woffdiff --git a/static/fonts/Montserrat-Medium.ttf b/frontend/public/assets/fonts/Montserrat-Medium.ttfsimilarity index 100%rename from static/fonts/Montserrat-Medium.ttfrename to frontend/public/assets/fonts/Montserrat-Medium.ttfdiff --git a/static/fonts/Montserrat-Medium.woff b/frontend/public/assets/fonts/Montserrat-Medium.woffsimilarity index 100%rename from static/fonts/Montserrat-Medium.woffrename to frontend/public/assets/fonts/Montserrat-Medium.woffdiff --git a/static/fonts/Montserrat-MediumItalic.ttf b/frontend/public/assets/fonts/Montserrat-MediumItalic.ttfsimilarity index 100%rename from static/fonts/Montserrat-MediumItalic.ttfrename to frontend/public/assets/fonts/Montserrat-MediumItalic.ttfdiff --git a/static/fonts/Montserrat-MediumItalic.woff b/frontend/public/assets/fonts/Montserrat-MediumItalic.woffsimilarity index 100%rename from static/fonts/Montserrat-MediumItalic.woffrename to frontend/public/assets/fonts/Montserrat-MediumItalic.woffdiff --git a/static/fonts/Montserrat-Regular.ttf b/frontend/public/assets/fonts/Montserrat-Regular.ttfsimilarity index 100%rename from static/fonts/Montserrat-Regular.ttfrename to frontend/public/assets/fonts/Montserrat-Regular.ttfdiff --git a/static/fonts/Montserrat-Regular.woff b/frontend/public/assets/fonts/Montserrat-Regular.woffsimilarity index 100%rename from static/fonts/Montserrat-Regular.woffrename to frontend/public/assets/fonts/Montserrat-Regular.woffdiff --git a/static/fonts/Montserrat-SemiBold.ttf b/frontend/public/assets/fonts/Montserrat-SemiBold.ttfsimilarity index 100%rename from static/fonts/Montserrat-SemiBold.ttfrename to frontend/public/assets/fonts/Montserrat-SemiBold.ttfdiff --git a/static/fonts/Montserrat-SemiBold.woff b/frontend/public/assets/fonts/Montserrat-SemiBold.woffsimilarity index 100%rename from static/fonts/Montserrat-SemiBold.woffrename to frontend/public/assets/fonts/Montserrat-SemiBold.woffdiff --git a/static/fonts/Montserrat-SemiBoldItalic.ttf b/frontend/public/assets/fonts/Montserrat-SemiBoldItalic.ttfsimilarity index 100%rename from static/fonts/Montserrat-SemiBoldItalic.ttfrename to frontend/public/assets/fonts/Montserrat-SemiBoldItalic.ttfdiff --git a/static/fonts/Montserrat-SemiBoldItalic.woff b/frontend/public/assets/fonts/Montserrat-SemiBoldItalic.woffsimilarity index 100%rename from static/fonts/Montserrat-SemiBoldItalic.woffrename to frontend/public/assets/fonts/Montserrat-SemiBoldItalic.woffdiff --git a/static/fonts/Montserrat-Thin.ttf b/frontend/public/assets/fonts/Montserrat-Thin.ttfsimilarity index 100%rename from static/fonts/Montserrat-Thin.ttfrename to frontend/public/assets/fonts/Montserrat-Thin.ttfdiff --git a/static/fonts/Montserrat-Thin.woff b/frontend/public/assets/fonts/Montserrat-Thin.woffsimilarity index 100%rename from static/fonts/Montserrat-Thin.woffrename to frontend/public/assets/fonts/Montserrat-Thin.woffdiff --git a/static/fonts/Montserrat-ThinItalic.ttf b/frontend/public/assets/fonts/Montserrat-ThinItalic.ttfsimilarity index 100%rename from static/fonts/Montserrat-ThinItalic.ttfrename to frontend/public/assets/fonts/Montserrat-ThinItalic.ttfdiff --git a/static/fonts/Montserrat-ThinItalic.woff b/frontend/public/assets/fonts/Montserrat-ThinItalic.woffsimilarity index 100%rename from static/fonts/Montserrat-ThinItalic.woffrename to frontend/public/assets/fonts/Montserrat-ThinItalic.woffdiff --git a/static/images/arrow.svg b/frontend/public/assets/images/arrow.svgsimilarity index 100%rename from static/images/arrow.svgrename to frontend/public/assets/images/arrow.svgdiff --git a/static/images/discord.svg b/frontend/public/assets/images/discord.svgsimilarity index 100%rename from static/images/discord.svgrename to frontend/public/assets/images/discord.svgdiff --git a/static/images/github.svg b/frontend/public/assets/images/github.svgsimilarity index 100%rename from static/images/github.svgrename to frontend/public/assets/images/github.svgdiff --git a/static/images/globe.png b/frontend/public/assets/images/globe.pngsimilarity index 100%rename from static/images/globe.pngrename to frontend/public/assets/images/globe.pngdiff --git a/static/images/logo.svg b/frontend/public/assets/images/logo.svgsimilarity index 100%rename from static/images/logo.svgrename to frontend/public/assets/images/logo.svgdiff --git a/static/images/logo16.png b/frontend/public/assets/images/logo16.pngsimilarity index 100%rename from static/images/logo16.pngrename to frontend/public/assets/images/logo16.pngdiff --git a/static/images/logo180.png b/frontend/public/assets/images/logo180.pngsimilarity index 100%rename from static/images/logo180.pngrename to frontend/public/assets/images/logo180.pngdiff --git a/static/images/logo32.png b/frontend/public/assets/images/logo32.pngsimilarity index 100%rename from static/images/logo32.pngrename to frontend/public/assets/images/logo32.pngdiff --git a/static/images/logo58.png b/frontend/public/assets/images/logo58.pngsimilarity index 100%rename from static/images/logo58.pngrename to frontend/public/assets/images/logo58.pngdiff --git a/static/images/search.svg b/frontend/public/assets/images/search.svgsimilarity index 100%rename from static/images/search.svgrename to frontend/public/assets/images/search.svgdiff --git a/frontend/src/askama.ts b/frontend/src/askama.tsnew file mode 100644index 00000000..8604df1c--- /dev/null+++ b/frontend/src/askama.ts@@ -0,0 +1 @@+export const askama = (s: TemplateStringsArray) => `{{ ${s} }}`;diff --git a/frontend/src/components/AskamaElse.astro b/frontend/src/components/AskamaElse.astronew file mode 100644index 00000000..4bc622b5--- /dev/null+++ b/frontend/src/components/AskamaElse.astro@@ -0,0 +1,8 @@+---+export interface Props {}+---++<Fragment>+ <Fragment set:html={`{% else %}`} />+ <slot />+</Fragment>diff --git a/frontend/src/components/AskamaFor.astro b/frontend/src/components/AskamaFor.astronew file mode 100644index 00000000..768a3bb2--- /dev/null+++ b/frontend/src/components/AskamaFor.astro@@ -0,0 +1,17 @@+---+export interface Props {+ elem: string;+ in: string;+}++const { props } = Astro;++const header = `{% for ${props.elem} in ${props.in} %} `;+const footer = `{% endfor %} `;+---++<Fragment>+ <Fragment set:html={header} />+ <slot />+ <Fragment set:html={footer} />+</Fragment>diff --git a/frontend/src/components/AskamaIf.astro b/frontend/src/components/AskamaIf.astronew file mode 100644index 00000000..001da079--- /dev/null+++ b/frontend/src/components/AskamaIf.astro@@ -0,0 +1,13 @@+---+export interface Props {+ expr: string;+}++const { expr } = Astro.props;+---++<Fragment>+ <Fragment set:html={`{% if ${expr} %}`} />+ <slot />+ <Fragment set:html={"{% endif %}"} />+</Fragment>diff --git a/frontend/src/components/AskamaMatch.astro b/frontend/src/components/AskamaMatch.astronew file mode 100644index 00000000..d8de9317--- /dev/null+++ b/frontend/src/components/AskamaMatch.astro@@ -0,0 +1,13 @@+---+export interface Props {+ expr: string;+}++const { expr } = Astro.props;+---++<Fragment>+ <Fragment set:html={`{% match ${expr} %}`} />+ <slot />+ <Fragment set:html={"{% endmatch %}"} />+</Fragment>diff --git a/frontend/src/components/AskamaWhen.astro b/frontend/src/components/AskamaWhen.astronew file mode 100644index 00000000..9c3b0fa0--- /dev/null+++ b/frontend/src/components/AskamaWhen.astro@@ -0,0 +1,17 @@+---+export interface Props {+ pat: string;+ with?: string;+}++const { props } = Astro;+---++<Fragment>+ <Fragment+ set:html={`{% when ${props.pat}${+ props.with ? ` with ${props.with}` : ""+ } %}`}+ />+ <slot />+</Fragment>diff --git a/frontend/src/components/Entity.astro b/frontend/src/components/Entity.astronew file mode 100644index 00000000..dbee5eba--- /dev/null+++ b/frontend/src/components/Entity.astro@@ -0,0 +1,90 @@+---+import AskamaFor from "./AskamaFor.astro";+import AskamaIf from "./AskamaIf.astro";+import AskamaMatch from "./AskamaMatch.astro";+import AskamaWhen from "./AskamaWhen.astro";+import { askama } from "../askama";++export interface Props {+ entity: string;+}+---++<div class="flex grow justify-center pt-3">+ <div class="max-w-md flex flex-col items-center">+ <AskamaMatch expr="entity.image">+ <AskamaWhen pat="Some(image)">+ <div class="w-lg mb-3">+ <a href="https://en.wikipedia.org/wiki/{{ entity.title|urlencode }}">+ <img+ class="h-full w-full rounded-full"+ src="/entity/image/{{ image|urlencode }}"+ />+ </a>+ </div>+ </AskamaWhen>+ <AskamaWhen pat="None" />+ </AskamaMatch>+ <div class="text-xl mb-1">+ <a href="https://en.wikipedia.org/wiki/{{ entity.title }}"+ >{askama`entity.title`}+ </a>+ </div>+ <div class="text-sm">+ {askama`entity.small_abstract`}+ <span class="italic">+ source: <a+ class="text-blue-600"+ href="https://en.wikipedia.org/wiki/{{ entity.title|urlencode }}"+ >wikipedia</a+ >+ </span>+ </div>+ <AskamaIf expr="!entity.info.is_empty()">+ <div class="flex flex-col text-sm mt-5 w-full px-4">+ <div+ class="border-separate border-spacing-x-4 gap-x-4 grid grid-cols-[auto_1fr] border-spacing-y-1.5"+ >+ <AskamaFor elem="(key, value)" in="entity.info">+ <div class="text-gray-400">+ {askama`key`}+ </div>+ <div>+ {askama`value`}+ </div>+ </AskamaFor>+ </div>+ </div>+ </AskamaIf>+ <AskamaIf expr="!entity.related_entities.is_empty()">+ <div class="flex flex-col mt-5 text-gray-500 w-full">+ <div class="font-light">Related Searches</div>+ <div class="flex">+ <AskamaFor elem="entity" in="entity.related_entities">+ <div class="flex flex-col items-center p-4">+ <AskamaMatch expr="entity.image">+ <AskamaWhen pat="Some(image)">+ <div class="h-20 w-20 mb-3">+ <a href="/search?q={{ entity.title|urlencode }}">+ <img+ class="h-full object-cover w-full rounded-full"+ src="/entity/image/{{ image|urlencode }}"+ />+ </a>+ </div>+ </AskamaWhen>+ <AskamaWhen pat="None" />+ </AskamaMatch>++ <div class="text-center">+ <a href="/search?q={{ entity.title|urlencode }}">+ {askama`entity.title`}+ </a>+ </div>+ </div>+ </AskamaFor>+ </div>+ </div>+ </AskamaIf>+ </div>+</div>diff --git a/frontend/src/components/Footer.astro b/frontend/src/components/Footer.astronew file mode 100644index 00000000..f1e91934--- /dev/null+++ b/frontend/src/components/Footer.astro@@ -0,0 +1,3 @@+<div class="flex w-full justify-center items-center h-10">+ <a href="/privacy-and-happy-lawyers">Terms & Privacy</a>+</div>diff --git a/frontend/src/components/Navbar.astro b/frontend/src/components/Navbar.astronew file mode 100644index 00000000..42b57063--- /dev/null+++ b/frontend/src/components/Navbar.astro@@ -0,0 +1,37 @@+<navbar class="flex-grow flex justify-end pr-10 space-x-10">+ <a href="/about">About</a>+ <a href="https://discord.gg/BmzKHffWJM">+ <div class="discord-logo"></div>+ </a>+ <a href="https://github.com/cuely/cuely">+ <div class="github-logo"></div>+ </a>+</navbar>++<style>+ .github-logo {+ background-color: gray;+ width: 22px;+ height: 22px;+ -webkit-mask: url(/assets/images/github.svg) no-repeat center;+ mask: url(/assets/images/github.svg) no-repeat center;+ mask-size: contain;+ }++ .github-logo:hover {+ background-color: black;+ }++ .discord-logo {+ background-color: gray;+ width: 22px;+ height: 22px;+ -webkit-mask: url(/assets/images/discord.svg) no-repeat center;+ mask: url(/assets/images/discord.svg) no-repeat center;+ mask-size: contain;+ }++ .discord-logo:hover {+ background-color: black;+ }+</style>diff --git a/frontend/src/components/Searchbar.astro b/frontend/src/components/Searchbar.astronew file mode 100644index 00000000..ada4fae7--- /dev/null+++ b/frontend/src/components/Searchbar.astro@@ -0,0 +1,244 @@+---+export interface Props {+ autofocus?: boolean;+ query?: string;+}++const { autofocus, query } = Astro.props;+---++<style is:global>+ .suggestion-item {+ @apply hidden group-focus-within:flex group-focus-within:peer-placeholder-shown:hidden;+ @apply col-span-3 py-2 pl-5;+ }+ .suggestion-item:nth-child(4) {+ @apply relative;+ }+ .suggestion-item:nth-child(4)::before {+ @apply absolute inset-4 -top-px h-px bg-gray-200;+ content: "";+ }+ .suggestion-item-hover {+ @apply cursor-pointer bg-gray-50;+ }+</style>++<form+ class="w-full md:max-w-2xl relative"+ method="GET"+ action="/search"+ autocomplete="off"+>+ <div class="h-12 relative">+ <div+ id="searchbar"+ class="absolute group bg-white top-0 grid grid-cols-[auto_1fr_auto] grid-rows-[3rem] border rounded-3xl inset-x-0 focus-within:shadow transition-shadow"+ >+ <img+ class="col-[1/2] row-start-1 w-5 self-center ml-5"+ loading="lazy"+ src="/assets/images/search.svg"+ />+ <input+ type="text"+ value={query}+ autofocus={autofocus}+ name="q"+ class="searchbar-input peer h-full flex inset-y-0 col-[1/3] py-0 row-start-1 w-full grow focus:ring-0 pl-12 border-none outline-none bg-transparent"+ placeholder="Search"+ />+ <div class="flex w-12 justify-center items-center">+ <button+ type="submit"+ class="bg-transparent p-0 m-0"+ style="border: none"+ >+ <img+ loading="lazy"+ src="/assets/images/arrow.svg"+ class="h-5 cursor-pointer bg-transparent"+ />+ </button>+ </div>+ </div>+ </div>+</form>++<script>+ const searchbar = document.querySelector("#searchbar")!;+ const searchbarInput: HTMLInputElement =+ document.querySelector(".searchbar-input")!;+ let suggestionItems = () =>+ Array.from(document.querySelectorAll(".suggestion-item")) as HTMLElement[];++ let currentHighlighted = -1;+ let currentSuggestions: string[] = [];+ let originalQuery = searchbarInput.value;++ function updateSuggestions(+ suggestionsData: { raw: string; highlighted: string }[]+ ) {+ suggestionItems().forEach((item) => item.remove());++ currentSuggestions = suggestionsData.map((item) => item.raw);+ currentHighlighted = -1;++ suggestionsData.forEach((item) => {+ const node = document.createElement("div");++ node.classList.add("flex");+ node.classList.add("suggestion-item");+ node.setAttribute("data-suggestion", item.raw);++ node.innerHTML = `+ <div class="flex w-4 mr-3 items-center">+ <img class="h-5" loading="lazy" src="/assets/images/search.svg" />+ </div>+ <div>+ ${item.highlighted}+ </div>+ `.trim();++ searchbar.appendChild(node);+ });++ const items = suggestionItems();++ items.forEach((item) =>+ item.addEventListener("mousedown", (event) => {+ if (event.button == 0) handleSuggestionClick(event.target);+ })+ );++ items.forEach((item, idx) =>+ item.addEventListener("mouseenter", () => {+ currentHighlighted = idx;+ updateHighlighted(false);+ })+ );+ }++ function handleSuggestionClick(element: EventTarget | null) {+ if (element == null || !(element instanceof HTMLElement)) {+ return;+ }++ var suggestion = element.dataset.suggestion;++ if (suggestion == undefined) {+ handleSuggestionClick(element.parentElement);+ return;+ }++ searchbarInput.value = suggestion;++ var searchParams = new URLSearchParams(window.location.search);+ searchParams.set("q", suggestion);+ searchParams.set("p", "0");+ window.location.href = "/search?" + searchParams.toString();+ }++ function fetchAndUpdateSuggestions() {+ const q = searchbarInput.value;++ if (q == "") {+ return;+ }++ fetch(+ "/autosuggest?" ++ new URLSearchParams({+ q: q,+ })+ )+ .then((response) => response.json())+ .then((data) => updateSuggestions(data));+ }++ function updateHighlighted(updateInputField: boolean) {+ if (updateInputField) {+ if (currentHighlighted == -1) {+ searchbarInput.value = originalQuery;+ } else {+ searchbarInput.value = htmlDecode(+ currentSuggestions[currentHighlighted]+ );+ }+ }++ suggestionItems().forEach((item, idx) =>+ item.classList.toggle("suggestion-item-hover", idx == currentHighlighted)+ );+ }++ function handleUpKey(event: KeyboardEvent) {+ event.preventDefault();++ if (!searchbar.classList.contains("suggestions-visible")) {+ return;+ }++ if (currentHighlighted < 0) {+ currentHighlighted = currentSuggestions.length - 1;+ } else {+ currentHighlighted--;+ }+ updateHighlighted(true);+ }++ function handleDownKey(event: KeyboardEvent) {+ event.preventDefault();++ if (!searchbar.classList.contains("suggestions-visible")) {+ return;+ }++ if (currentHighlighted == currentSuggestions.length - 1) {+ currentHighlighted = -1;+ } else {+ currentHighlighted++;+ }++ updateHighlighted(true);+ }++ function handleArrowKeys(event: KeyboardEvent) {+ if (event.keyCode == 38) {+ handleUpKey(event);+ } else if (event.keyCode == 40) {+ handleDownKey(event);+ }+ }++ function htmlDecode(input: string) {+ var doc = new DOMParser().parseFromString(input, "text/html");+ return doc.documentElement.textContent || "";+ }++ searchbarInput.addEventListener("keydown", (event) => handleArrowKeys(event));++ searchbarInput.addEventListener("keyup", (event) => {+ if (event.keyCode == 38 || event.keyCode == 40) {+ return;+ }++ if (event.keyCode == 27) {+ searchbarInput.blur();+ searchbar.classList.remove("suggestions-visible");+ return;+ }++ originalQuery = searchbarInput.value;++ if (![16, 224, 18, 17, 27].includes(event.keyCode)) {+ searchbar.classList.add("suggestions-visible");+ }+ fetchAndUpdateSuggestions();+ });++ searchbarInput.addEventListener("focusin", () => {+ searchbar.classList.add("suggestions-visible");+ fetchAndUpdateSuggestions();+ });+</script>diff --git a/frontend/src/env.d.ts b/frontend/src/env.d.tsnew file mode 100644index 00000000..f964fe0c--- /dev/null+++ b/frontend/src/env.d.ts@@ -0,0 +1 @@+/// <reference types="astro/client" />diff --git a/frontend/src/layouts/Layout.astro b/frontend/src/layouts/Layout.astronew file mode 100644index 00000000..705ddb47--- /dev/null+++ b/frontend/src/layouts/Layout.astro@@ -0,0 +1,195 @@+---+export interface Props {+ title: string;+}++const { title } = Astro.props;+---++<!DOCTYPE html>+<html lang="en">+ <head>+ <meta charset="UTF-8" />+ <meta name="viewport" content="width=device-width" />+ <!-- <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> -->+ <link rel="icon" type="image/x-icon" href="/assets/favicon.ico" />+ <title>{title}</title>+ </head>+ <body>+ <slot />++ <style is:global>+ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-Light.ttf") format("truetype");+ font-style: normal;+ font-weight: 400;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-Medium.ttf") format("truetype");+ font-style: normal;+ font-weight: 500;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-SemiBold.ttf") format("truetype");+ font-style: normal;+ font-weight: 600;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-Bold.ttf") format("truetype");+ font-style: normal;+ font-weight: 700;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-LightItalic.ttf") format("truetype");+ font-style: italic;+ font-weight: 400;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-MediumItalic.ttf") format("truetype");+ font-style: italic;+ font-weight: 500;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-SemiBoldItalic.ttf")+ format("truetype");+ font-style: italic;+ font-weight: 600;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-BoldItalic.ttf") format("truetype");+ font-style: italic;+ font-weight: 700;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-Light.woff") format("woff");+ font-style: normal;+ font-weight: 400;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-Medium.woff") format("woff");+ font-style: normal;+ font-weight: 500;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-SemiBold.woff") format("woff");+ font-style: normal;+ font-weight: 600;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-Bold.woff") format("woff");+ font-style: normal;+ font-weight: 700;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-LightItalic.woff") format("woff");+ font-style: italic;+ font-weight: 400;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-MediumItalic.woff") format("woff");+ font-style: italic;+ font-weight: 500;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-SemiBoldItalic.woff") format("woff");+ font-style: italic;+ font-weight: 600;+ }++ @font-face {+ font-family: Montserrat;+ src: url("/assets/fonts/Montserrat-BoldItalic.woff") format("woff");+ font-style: italic;+ font-weight: 700;+ }++ html,+ body {+ position: relative;+ width: 100%;+ height: 100%;+ }++ a:hover {+ text-decoration: underline;+ }++ label {+ display: block;+ }++ input,+ button,+ select,+ textarea {+ font-family: inherit;+ font-size: inherit;+ -webkit-padding: 0.4em 0;+ padding: 0.4em;+ margin: 0 0 0.5em 0;+ box-sizing: border-box;+ border: 1px solid #ccc;+ border-radius: 2px;+ }++ input:disabled {+ color: #ccc;+ }++ button {+ color: #333;+ background-color: #f4f4f4;+ outline: none;+ }++ button:disabled {+ color: #999;+ }++ button:not(:disabled):active {+ background-color: #ddd;+ }++ button:focus {+ border-color: #666;+ }++ b {+ font-weight: 600 !important;+ }++ pre > code {+ font-size: 0.8rem;+ }+ </style>+ </body>+</html>diff --git a/frontend/src/layouts/Markdown.astro b/frontend/src/layouts/Markdown.astronew file mode 100644index 00000000..c3afa933--- /dev/null+++ b/frontend/src/layouts/Markdown.astro@@ -0,0 +1,36 @@+---+import Footer from "../components/Footer.astro";+import Navbar from "../components/Navbar.astro";+import Layout from "../layouts/Layout.astro";++export interface Props {+ frontmatter: { title: string };+}++const { frontmatter } = Astro.props;+---++<Layout title={frontmatter.title}>+ <div class="flex flex-col h-full w-full">+ <div class="min-h-max w-full">+ <header class="flex items-center w-full h-24">+ <div class="ml-14 mr-14 w-12 h-12">+ <a href="/">+ <img src="/assets/images/logo.svg" class="w-full h-full" />+ </a>+ </div>+ <Navbar />+ </header>+ </div>++ <div class="flex flex-col w-full h-fit items-center pt-10">+ <div+ class="prose prose-headings:text-center prose-headings:font-medium prose-h4:float-left prose-h4:mr-3 prose-h4:my-0 prose-h4:leading-7"+ >+ <slot />+ </div>+ </div>+ <div class="flex flex-grow"></div>+ <Footer />+ </div>+</Layout>diff --git a/frontend/src/pages/about.mdx b/frontend/src/pages/about.mdxnew file mode 100644index 00000000..4555cc5a--- /dev/null+++ b/frontend/src/pages/about.mdx@@ -0,0 +1,22 @@+---+layout: "../layouts/Markdown.astro"+title: About us+---++# About Us++Cuely is an open source search engine where the user has the ability to see exactly what is going on and customize almost everything about their search results. It's a search engine made for hackers just like us. No more searches where some of the terms in the query arent used, and the engine tries to guess what you _really_ meant. You get what you search for.++## Our Values++- _Complete transparency_ -- You can view our code and follow the development directly on [Github](https://github.com/cuely/cuely)+- _Privacy focussed_ -- We will never track you. Period. And you can always verify this in our [code.](https://github.com/cuely/cuely)+- _Immensely customizable_ -- We aim to give you the ability to customize everything about the search. e.g. block sites, boost sites, prioritize links from specific sites etc.++Oh, and if we ever become evil (e.g. by changing our motto) please take our code and start a competitor. The fact that you have this ability will make sure that our values will always be aligned with our users.++## How do you make money?++Well, currently we don't. We are bootstraped and trying to keep costs low. In the future we will have contextual ads based on your current search query. Just to re-iterate; we will only use your current search to match ads and will never track you across searches.++We will also have a paid api for developers.diff --git a/frontend/src/pages/index.astro b/frontend/src/pages/index.astronew file mode 100644index 00000000..de63d12a--- /dev/null+++ b/frontend/src/pages/index.astro@@ -0,0 +1,32 @@+---+import Footer from "../components/Footer.astro";+import Navbar from "../components/Navbar.astro";+import Searchbar from "../components/Searchbar.astro";+import Layout from "../layouts/Layout.astro";+---++<Layout title="Cuely">+ <div class="flex flex-col h-full w-full">+ <header class="flex items-center h-24">+ <Navbar />+ </header>++ <div+ class="flex justify-center items-center flex-col"+ style="flex-grow: 3;"+ >+ <div class="flex">+ <h1 class="text-5xl uppercase mb-1" style="color: #0b7bff">cuely</h1>+ <span style="color: #828282">BETA</span>+ </div>++ <h3 class="mb-8" style="color: #828282">Completely Open Search Engine</h3>++ <Searchbar autofocus />+ </div>++ <div class="flex grow flex-col" style="flex-grow: 2;"></div>++ <Footer />+ </div>+</Layout>diff --git a/frontend/src/pages/privacy-and-happy-lawyers.mdx b/frontend/src/pages/privacy-and-happy-lawyers.mdxnew file mode 100644index 00000000..64a8bed4--- /dev/null+++ b/frontend/src/pages/privacy-and-happy-lawyers.mdx@@ -0,0 +1,64 @@+---+layout: "../layouts/Markdown.astro"+title: Privacy+---++# We will always respect your privacy.++We will be good stewards of any personal information you share with us and we promise not to share your data with anyone else in any way, shape or form.++When using Cuely, you can have peace of mind knowing that we do whatever is possible to keep your private information - private. We mostly do this by simply not storing any of your private information at all. This keeps things simple, both for you and for us.++Here is a brief overview of your privacy:++- Searches are anonymous and private to you.+- We don't log or store your IP address.+- We do not use any web browser analytics or other frontend telemetry.+- We do not share any user data with any third parties.+- We collect only the data needed to provide and protect the service.+- We serve all images and other static content directly from our servers to prevent tracking from third parties.+- We use HTTPS encryption everywhere.++You don't have to take our word for these claims as our [source code is available to everyone.](https://github.com/cuely/cuely)++## Terms of Service++Keep in mind that all services provided in Cuely are provided “as is” and there are no warranties. By using our services you agree with the following terms.++#### Introduction++These Terms of Service ("Terms") govern your use of Cuely (the "Services").++#### Privacy Policy++We use the information we receive through the Services as described in our Privacy Policy.++#### Source code++The source code for Cuely is distributed under the license described in the [git repository.](https://github.com/Cuely/Cuely/blob/main/LICENSE.md)++#### Proprietary Rights++Cuely does not grant you any intellectual property rights in the Services that are not specifically stated in these Terms. For example, these Terms do not provide the right to use any of Cuely's copyrights, trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.++#### Indemnification++You agree to defend, indemnify and hold harmless Cuely, its contractors, contributors, licensors, and partners, and their respective directors, officers, employees and agents ("Indemnified Parties") from and against any and all third party claims and expenses, including attorneys' fees, arising out of or related to your use of the Services.++#### Limitation of Liability++THE SERVICES ARE PROVIDED "AS IS" WITH ALL FAULTS. TO THE EXTENT PERMITTED BY LAW, CUELY AND THE INDEMNIFIED PARTIES HEREBY DISCLAIM ALL WARRANTIES, WHETHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES THAT THE SERVICES ARE FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, AND NON-INFRINGING. YOU BEAR THE ENTIRE RISK AS TO SELECTING THE SERVICES FOR YOUR PURPOSES AND AS TO THE QUALITY AND PERFORMANCE OF THE SERVICES, INCLUDING WITHOUT LIMITATION THE RISK THAT YOUR CONTENT IS DELETED OR CORRUPTED OR THAT SOMEONE ELSE ACCESSES YOUR ONLINE ACCOUNTS. THIS LIMITATION WILL APPLY NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF IMPLIED WARRANTIES, SO THIS DISCLAIMER MAY NOT APPLY TO YOU. EXCEPT AS REQUIRED BY LAW, CUELY AND THE INDEMNIFIED PARTIES WILL NOT BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR EXEMPLARY DAMAGES ARISING OUT OF OR IN ANY WAY RELATING TO THESE TERMS OR THE USE OF OR INABILITY TO USE THE SERVICES, INCLUDING WITHOUT LIMITATION DIRECT AND INDIRECT DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, LOST PROFITS, LOSS OF DATA, AND COMPUTER FAILURE OR MALFUNCTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE THEORY (CONTRACT, TORT, OR OTHERWISE) UPON WHICH SUCH CLAIM IS BASED. THE COLLECTIVE LIABILITY OF CUELY AND THE INDEMNIFIED PARTIES UNDER THIS AGREEMENT WILL NOT EXCEED $500 (FIVE HUNDRED DOLLARS). SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL, CONSEQUENTIAL, OR SPECIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.++#### Modifications to these++Terms Cuely may update these Terms from time to time to address a new feature of the Services or to clarify a provision. The updated Terms will be posted online. If the changes are substantive, we will announce the update through Cuely's usual channels for such announcements such as Discord. Your continued use of the Services after the effective date of such changes constitutes your acceptance of such changes.++#### Miscellaneous++These Terms constitute the entire agreement between you and Cuely concerning the Services and are governed by the laws of Denmark, excluding its conflict of law provisions. If any portion of these Terms is held to be invalid or unenforceable, the remaining portions will remain in full force and effect. In the event of a conflict between a translated version of these terms and the English language version, the English language version shall control.++## Changelog++#### 31-08-2022:++Initial commitdiff --git a/frontend/src/pages/search.astro b/frontend/src/pages/search.astronew file mode 100644index 00000000..89f41961--- /dev/null+++ b/frontend/src/pages/search.astro@@ -0,0 +1,219 @@+---+import Layout from "../layouts/Layout.astro";+import Searchbar from "../components/Searchbar.astro";+import AskamaFor from "../components/AskamaFor.astro";+import AskamaMatch from "../components/AskamaMatch.astro";+import AskamaWhen from "../components/AskamaWhen.astro";+import AskamaIf from "../components/AskamaIf.astro";+import AskamaElse from "../components/AskamaElse.astro";+import Navbar from "../components/Navbar.astro";+import Footer from "../components/Footer.astro";+import Entity from "../components/Entity.astro";+import { askama } from "../askama";+---++<Layout title="Cuely - {{ query }}">+ <main class="flex flex-col w-full">+ <div class="flex items-center h-24 border bg-neutral-50">+ <div class="ml-14 mr-14 w-12 h-12">+ <a href="/">+ <img src="/assets/images/logo.svg" class="w-full h-full" />+ </a>+ </div>+ <Searchbar query={askama`query`} />+ <Navbar />+ </div>++ <div class="flex">+ <div class="flex pl-40 flex-col">+ <div class="flex mt-1 pl-3 pt-2 max-w-3xl pr-24 w-full justify-between">+ <div+ class="flex flex-col h-full justify-center text-sm text-gray-600"+ >+ <p class="h-fit">+ Found {askama`num_matches`} results in {+ askama`search_duration_sec`+ } seconds+ </p>+ </div>+ <div+ class="select-region h-full flex flex-col justify-center p-0 m-0"+ >+ <select+ form="searchbar-form"+ name="gl"+ class="p-0 m-0 hover:cursor-pointer"+ >+ <AskamaFor elem="region_selection" in="all_regions">+ <AskamaMatch expr="region_selection">+ <AskamaWhen pat="RegionSelection::Selected" with="(region)">+ <option value="{{ region.gl() }}" selected>+ {askama`region.name()`}+ </option>+ </AskamaWhen>+ <AskamaWhen pat="RegionSelection::Unselected" with="(region)">+ <option value="{{ region.gl() }}">+ {askama`region.name()`}+ </option>+ </AskamaWhen>+ </AskamaMatch>+ </AskamaFor>+ </select>+ </div>+ </div>+ <div class="flex flex-col pt-4 pb-8">+ <AskamaMatch expr="spell_correction">+ <AskamaWhen pat="Some" with="(correction)">+ <div class="pl-3 pb-3">+ Did you mean: <a+ class="italic title-link font-bold"+ href="/search?q={{ correction|urlencode }}"+ >+ {askama`correction`}+ </a>+ </div>+ </AskamaWhen>+ <AskamaWhen pat="None" />+ </AskamaMatch>++ <div class="search-result flex flex-col space-y-3">+ <AskamaFor elem="item" in="search_result">+ <div class="flex max-w-3xl w-full p-3">+ <div class="flex flex-col w-full">+ <div class="text-sm mb-1 flex">+ <div class="flex items-center mr-2">+ <img+ src="/favicons/{{ item.domain|urlencode }}"+ width="13px"+ />+ </div>+ <div>+ <a+ class="hover:no-underline text-gray-600"+ href="{{ item.url }}"+ >{askama`item.pretty_url`}+ </a>+ </div>+ </div>+ <div class="text-lg font-medium mb-1">+ <a class="title-link" href="{{ item.url }}"+ >{askama`item.title`}+ </a>+ </div>+ <div class="text-sm">+ <AskamaMatch expr="item.last_updated">+ <AskamaWhen pat="Some" with="(val)">+ <span class="text-gray-500">+ {askama`val`}+ </span> —+ </AskamaWhen>+ <AskamaWhen pat="None" />+ </AskamaMatch>+ {askama`item.snippet`}+ </div>+ </div>+ <div class="flex h-full items-center">+ <div class="h-20 w-20 pl-2 pt-1 pb-1">+ <AskamaMatch expr="item.primary_image_uuid">+ <AskamaWhen pat="Some" with="(val)">+ <a href="{{ item.url|urlencode }}">+ <img+ class="h-full w-full object-cover rounded-full"+ src="/image/{{ val|urlencode }}"+ />+ </a>+ </AskamaWhen>+ <AskamaWhen pat="None" />+ </AskamaMatch>+ </div>+ </div>+ </div>+ </AskamaFor>+ </div>++ <div class="flex w-full justify-center items-center pr-24 mt-5">+ <AskamaIf expr="current_page == 1">+ <div class="prev-page gray-arrow"></div>++ <AskamaElse>+ <AskamaMatch expr="prev_page_url">+ <AskamaWhen pat="Some" with="(url)">+ <a href="{{ url }}">+ <div class="prev-page cuely-color-arrow"></div>+ </a>+ </AskamaWhen>+ <AskamaWhen pat="None">+ <div class="prev-page gray-arrow"></div>+ </AskamaWhen>+ </AskamaMatch>+ </AskamaElse>+ </AskamaIf>+ <div class="mr-2 ml-2">+ Page {askama`current_page`}+ </div>+ <a href="{{ next_page_url }}">+ <div class="next-page cuely-color-arrow"></div>+ </a>+ </div>+ </div>+ </div>++ <AskamaMatch expr="entity">+ <AskamaWhen pat="Some" with="(entity)">+ <Entity entity="entity" />+ </AskamaWhen>+ <AskamaWhen pat="None" />+ </AskamaMatch>+ </div>+ </main>++ <Footer />+</Layout>++<style>+ .prev-page {+ width: 16px;+ height: 16px;+ -webkit-mask: url(/assets/images/arrow.svg) no-repeat center;+ mask: url(/assets/images/arrow.svg) no-repeat center;+ mask-size: contain;+ transform: rotate(180deg);+ }++ .next-page {+ width: 16px;+ height: 16px;+ -webkit-mask: url(/assets/images/arrow.svg) no-repeat center;+ mask: url(/assets/images/arrow.svg) no-repeat center;+ mask-size: contain;+ }++ .gray-arrow {+ background-color: gray;+ }++ .cuely-color-arrow {+ background-color: #0b7bff;+ }++ .title-link {+ color: #1a0dab;+ }++ .title-link:visited {+ color: #609;+ }++ .search-result {+ text-rendering: optimizeLegibility;+ font-smooth: grayscale;+ -moz-osx-font-smoothing: grayscale;+ }++ .select-region > select {+ background-color: transparent;+ border: 0px;+ font-size: small;+ width: 105px;+ }+</style>diff --git a/frontend/tailwind.config.cjs b/frontend/tailwind.config.cjsnew file mode 100644index 00000000..d960ee02--- /dev/null+++ b/frontend/tailwind.config.cjs@@ -0,0 +1,14 @@+const defaultTheme = require("tailwindcss/defaultTheme");++/** @type {import('tailwindcss').Config} */+module.exports = {+ content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"],+ theme: {+ extend: {+ fontFamily: {+ sans: ["Montserrat", ...defaultTheme.fontFamily.sans],+ },+ },+ },+ plugins: [require("@tailwindcss/typography")],+};diff --git a/frontend/tsconfig.json b/frontend/tsconfig.jsonnew file mode 100644index 00000000..77da9dd0--- /dev/null+++ b/frontend/tsconfig.json@@ -0,0 +1,3 @@+{+ "extends": "astro/tsconfigs/strict"+}\ No newline at end of filediff --git a/justfile b/justfileindex 2590b869..733721a9 100644--- a/justfile+++ b/justfile@@ -19,6 +19,9 @@@frontend:cargo watch -x 'run -- frontend data/index data/queries_us.csv data/entity data/bangs.json'+@astro:+ cd frontend; npm run dev+@local:rm -rf data/index/RUSTFLAGS="-C target-cpu=native" cargo run --release -- indexer local configs/indexer/local.tomldiff --git a/package.json b/package.jsondeleted file mode 100644index 012729c2..00000000--- a/package.json+++ /dev/null@@ -1,9 +0,0 @@-{- "license": "ISC",- "scripts": {- "build": "npx tailwindcss build -i tailwind.css -o ./static/css/main.css"- },- "devDependencies": {- "tailwindcss": "*"- }-}\ No newline at end of filediff --git a/src/frontend/about.rs b/src/frontend/about.rsindex 3851d204..e945436a 100644--- a/src/frontend/about.rs+++ b/src/frontend/about.rs@@ -25,5 +25,5 @@ pub async fn route() -> impl IntoResponse {}#[derive(Template)]-#[template(path = "about.html")]+#[template(path = "about/index.html")]struct AboutTemplate {}diff --git a/src/frontend/favicons.rs b/src/frontend/favicons.rsindex 047bbccc..43d4001f 100644--- a/src/frontend/favicons.rs+++ b/src/frontend/favicons.rs@@ -36,7 +36,7 @@ pub async fn route(let bytes = match img {Some(img) => img.as_raw_bytes(),- None => include_bytes!("../../static/images/globe.png").to_vec(),+ None => include_bytes!("../../frontend/dist/assets/images/globe.png").to_vec(),};Response::builder()diff --git a/src/frontend/mod.rs b/src/frontend/mod.rsindex 93ed84bd..895c444e 100644--- a/src/frontend/mod.rs+++ b/src/frontend/mod.rs@@ -70,7 +70,7 @@ pub async fn favicon() -> impl IntoResponse {Response::builder().status(StatusCode::OK).body(Body::from(- include_bytes!("../../static/images/favicon.ico").to_vec(),+ include_bytes!("../../frontend/dist/assets/favicon.ico").to_vec(),)).unwrap()}@@ -103,7 +103,7 @@ pub fn router(.route("/about", get(about::route)).route("/privacy-and-happy-lawyers", get(privacy::route)).route("/api/beta/search", get(api::search))- .merge(SpaRouter::new("/static", "static"))+ .merge(SpaRouter::new("/assets", "frontend/dist/assets")).layer(Extension(state)).layer(CompressionLayer::new()))}diff --git a/src/frontend/privacy.rs b/src/frontend/privacy.rsindex afa5a2c7..ebf54d38 100644--- a/src/frontend/privacy.rs+++ b/src/frontend/privacy.rs@@ -25,5 +25,5 @@ pub async fn route() -> impl IntoResponse {}#[derive(Template)]-#[template(path = "privacy.html")]+#[template(path = "privacy-and-happy-lawyers/index.html")]struct PrivacyTemplate {}diff --git a/src/frontend/search.rs b/src/frontend/search.rsindex cc2b5abe..25966423 100644--- a/src/frontend/search.rs+++ b/src/frontend/search.rs@@ -17,6 +17,7 @@use axum::Extension;use chrono::{NaiveDate, NaiveDateTime, Utc};use itertools::{intersperse, Itertools};+use serde::Serialize;use crate::{entity_index::{entity::Span, StoredEntity},@@ -133,6 +134,7 @@ impl From<RetrievedWebpage> for DisplayedWebpage {}}+#[derive(Serialize)]pub struct DisplayedEntity {pub title: String,pub small_abstract: String,@@ -237,7 +239,7 @@ fn maybe_prettify_entity_date(value: String) -> String {}#[derive(Template)]-#[template(path = "search.html", escape = "none")]+#[template(path = "search/index.html", escape = "none")]struct SearchTemplate {search_result: Vec<DisplayedWebpage>,query: String,diff --git a/static/.gitkeep b/static/.gitkeepdeleted file mode 100644index e69de29b..00000000diff --git a/tailwind.config.js b/tailwind.config.jsdeleted file mode 100644index b5a5e968..00000000--- a/tailwind.config.js+++ /dev/null@@ -1,7 +0,0 @@-module.exports = {- content: ["./templates/**/*.html"],- theme: {- extend: {},- },- plugins: [],-}\ No newline at end of filediff --git a/tailwind.css b/tailwind.cssdeleted file mode 100644index bd6213e1..00000000--- a/tailwind.css+++ /dev/null@@ -1,3 +0,0 @@-@tailwind base;-@tailwind components;-@tailwind utilities;\ No newline at end of filediff --git a/templates/about.html b/templates/about.htmldeleted file mode 100644index 2f65a38d..00000000--- a/templates/about.html+++ /dev/null@@ -1,70 +0,0 @@-{% extends "base.html" %}-{% import "navbar.html" as navbar %}-{% import "footer.html" as footer %}--{% block content %}-<div class="flex flex-col h-full w-full">- <header class="flex items-center h-24">- <div class="ml-14 mr-14 w-12 h-12">- <a href="/">- <img src="/static/images/logo.svg" class="w-full h-full" />- </a>- </div>- {% call navbar::navbar() %}- </header>-- <div class="flex flex-col w-full items-center">- <div class="flex items-center flex-col max-w-4xl mr-10 ml-10" style="flex-grow: 2;">- <div class="flex flex-col items-center">- <h1 class="text-2xl mb-3">About Us</h1>- <div>- <p>Cuely is an open source search engine where the user has the ability to see exactly what is- going- on and customize almost everything about their search results. It's a search engine made for- hackers just like us. No more searches where some of the terms in the query arent used, and- the engine tries to guess what you <i>really</i> meant. You get what you search for.</p>- </div>- </div>-- <div class="flex flex-col items-center mt-16">- <h1 class="text-lg mb-3">Our Values</h1>- <div>- <ul class="list-disc pl-5">- <li class="mb-1"><span class="italic">Complete transparency</span> – You can view our code and- follow the- development directly on <a href="https://github.com/cuely/cuely">Github</a></li>- <li class="mb-1"><span class="italic">Privacy focussed</span> – We will never track you. Period.- And you can- always verify this in our <a href="https://github.com/cuely/cuely">code.</a></li>- <li class="mb-1"><span class="italic">Immensely customizable</span> – We aim to give you the- ability to- customize everything about the search. e.g. block sites, boost sites, prioritize links from- specific sites etc.</li>- </ul>- <p class="mt-3">Oh, and if we ever become evil (e.g. by changing our motto) please take our code- and start a- competitor. The fact that you have this ability will make sure that our values will always- be aligned with our users.</p>- </div>-- </div>-- <div class="flex flex-col items-center mt-16 w-full">- <h1 class="text-lg mb-3">How do you make money?</h1>- <div class="w-full">- <p>Well, currently we don't. We are bootstraped and trying to keep costs low. In the future we will- have contextual ads based on your current search- query. Just to re-iterate; we will only use your current search to match ads and will never- track- you across searches.</p>- <p class="mt-3">We will also have a paid api for developers.</p>- </div>- </div>-- </div>- </div>- <div class="flex flex-grow"></div>- {% call footer::footer() %}-</div>--{% endblock %}\ No newline at end of filediff --git a/templates/base.html b/templates/base.htmldeleted file mode 100644index 76d65ef0..00000000--- a/templates/base.html+++ /dev/null@@ -1,200 +0,0 @@-<!DOCTYPE html>-<html lang="en">--<head>- <meta charset="UTF-8" />- <meta name="viewport" content="width=device-width, initial-scale=1.0" />- <title>Cuely</title>- {% block meta %}{% endblock %}- <link rel="stylesheet" type="text/css" href="/static/css/main.css" />- <link rel="icon" type="image/x-icon" href="/favicon.ico">- <style>- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-Light.ttf") format("truetype");- font-style: normal;- font-weight: 400;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-Medium.ttf") format("truetype");- font-style: normal;- font-weight: 500;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-SemiBold.ttf") format("truetype");- font-style: normal;- font-weight: 600;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-Bold.ttf") format("truetype");- font-style: normal;- font-weight: 700;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-LightItalic.ttf") format("truetype");- font-style: italic;- font-weight: 400;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-MediumItalic.ttf") format("truetype");- font-style: italic;- font-weight: 500;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-SemiBoldItalic.ttf") format("truetype");- font-style: italic;- font-weight: 600;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-BoldItalic.ttf") format("truetype");- font-style: italic;- font-weight: 700;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-Light.woff") format("woff");- font-style: normal;- font-weight: 400;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-Medium.woff") format("woff");- font-style: normal;- font-weight: 500;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-SemiBold.woff") format("woff");- font-style: normal;- font-weight: 600;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-Bold.woff") format("woff");- font-style: normal;- font-weight: 700;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-LightItalic.woff") format("woff");- font-style: italic;- font-weight: 400;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-MediumItalic.woff") format("woff");- font-style: italic;- font-weight: 500;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-SemiBoldItalic.woff") format("woff");- font-style: italic;- font-weight: 600;- }-- @font-face {- font-family: Montserrat;- src: url("/static/fonts/Montserrat-BoldItalic.woff") format("woff");- font-style: italic;- font-weight: 700;- }-- html,- body {- position: relative;- width: 100%;- height: 100%;- }--- body {- font-family: Montserrat, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;- box-sizing: border-box;- padding: 0;- margin: 0;- }--- a:hover {- text-decoration: underline;- }-- label {- display: block;- }-- input,- button,- select,- textarea {- font-family: inherit;- font-size: inherit;- -webkit-padding: 0.4em 0;- padding: 0.4em;- margin: 0 0 0.5em 0;- box-sizing: border-box;- border: 1px solid #ccc;- border-radius: 2px;- }-- input:disabled {- color: #ccc;- }-- button {- color: #333;- background-color: #f4f4f4;- outline: none;- }-- button:disabled {- color: #999;- }-- button:not(:disabled):active {- background-color: #ddd;- }-- button:focus {- border-color: #666;- }--- b {- font-weight: 600 !important;- }-- pre>code {- font-size: 0.8rem;- }- </style>- {% block head %}{% endblock %}-</head>--<body>- {% block content %}{% endblock %}-</body>--</html>\ No newline at end of filediff --git a/templates/entity.html b/templates/entity.htmldeleted file mode 100644index d4670703..00000000--- a/templates/entity.html+++ /dev/null@@ -1,69 +0,0 @@-{% macro show_entity(entity) %}-<div class="flex grow justify-center pt-3">- <div class="max-w-md flex flex-col items-center">- {% match entity.image %}- {% when Some(image) %}- <div class="w-lg mb-3">- <a href="https://en.wikipedia.org/wiki/{{ entity.title|urlencode }}">- <img class="h-full w-full rounded-full" src="/entity/image/{{ image|urlencode }}" />- </a>- </div>- {% when None %}- {% endmatch %}- <div class="text-xl mb-1">- <a href="https://en.wikipedia.org/wiki/{{ entity.title }}">{{ entity.title }}</a>- </div>- <div class="text-sm">- {{ entity.small_abstract }}- <span class="italic">- source: <a class="text-blue-600"- href="https://en.wikipedia.org/wiki/{{ entity.title|urlencode }}">wikipedia</a>- </span>- </div>- {% if !entity.info.is_empty() %}- <div class="flex flex-col text-sm mt-5 w-full">- <table class="border-separate border-spacing-x-4 border-spacing-y-1.5">- {% for (key, value) in entity.info %}- <tr class="align-top">- <td class="text-gray-400">- {{ key }}- </td>- <td>- {{ value }}- </td>- </tr>- {% endfor %}- </table>- </div>- {% endif %}- {% if !entity.related_entities.is_empty() %}- <div class="flex flex-col mt-5 text-gray-500 w-full">- <div class="font-light">- Related Searches- </div>- <div class="flex">- {% for entity in entity.related_entities %}- <div class="flex flex-col items-center p-4">- {% match entity.image %}- {% when Some(image) %}- <div class="h-20 w-20 mb-3">- <a href="/search?q={{ entity.title|urlencode }}">- <img class="h-full object-cover w-full rounded-full"- src="/entity/image/{{ image|urlencode }}" />- </a>- </div>- {% when None %}- {% endmatch %}- <div class="text-center">- <a href="/search?q={{ entity.title|urlencode }}">- {{ entity.title }}- </a>- </div>- </div>- {% endfor %}- </div>- </div>- {% endif %}- </div>-</div>-{% endmacro %}\ No newline at end of filediff --git a/templates/footer.html b/templates/footer.htmldeleted file mode 100644index 0c50e814..00000000--- a/templates/footer.html+++ /dev/null@@ -1,5 +0,0 @@-{% macro footer() %}-<div class="flex w-full justify-center items-center h-10">- <a href="/privacy-and-happy-lawyers">Terms & Privacy</a>-</div>-{% endmacro %}\ No newline at end of filediff --git a/templates/index.html b/templates/index.htmldeleted file mode 100644index 9f815321..00000000--- a/templates/index.html+++ /dev/null@@ -1,30 +0,0 @@-{% extends "base.html" %}-{% import "searchbar.html" as scope %}-{% import "navbar.html" as navbar %}-{% import "footer.html" as footer %}--{% block content %}-<div class="flex flex-col h-full w-full">- <header class="flex items-center h-24">- {% call navbar::navbar() %}- </header>-- <div class="flex justify-center items-center flex-col" style="flex-grow: 3;">- <div class="flex">- <h1 class="text-5xl uppercase mb-1" style="color: #0b7bff">cuely</h1>- <span style="color: #828282">BETA</span>- </div>-- <h3 class="mb-8" style="color: #828282">Completely Open Search Engine</h3>-- {% call scope::searchbar("autofocus", "") %}-- </div>-- <div class="flex grow flex-col" style="flex-grow: 2;">- </div>-- {% call footer::footer() %}-</div>--{% endblock %}\ No newline at end of filediff --git a/templates/navbar.html b/templates/navbar.htmldeleted file mode 100644index 637a021a..00000000--- a/templates/navbar.html+++ /dev/null@@ -1,39 +0,0 @@-{% macro navbar() %}-<navbar class="flex-grow flex justify-end pr-10 space-x-10">- <a href="/about">About</a>- <a href="https://discord.gg/BmzKHffWJM">- <div class="discord-logo"></div>- </a>- <a href="https://github.com/cuely/cuely">- <div class="github-logo"></div>- </a>-</navbar>--<style>- .github-logo {- background-color: gray;- width: 22px;- height: 22px;- -webkit-mask: url(/static/images/github.svg) no-repeat center;- mask: url(/static/images/github.svg) no-repeat center;- mask-size: contain;- }-- .github-logo:hover {- background-color: black;- }-- .discord-logo {- background-color: gray;- width: 22px;- height: 22px;- -webkit-mask: url(/static/images/discord.svg) no-repeat center;- mask: url(/static/images/discord.svg) no-repeat center;- mask-size: contain;- }-- .discord-logo:hover {- background-color: black;- }-</style>-{% endmacro %}\ No newline at end of filediff --git a/templates/privacy.html b/templates/privacy.htmldeleted file mode 100644index f8acda4c..00000000--- a/templates/privacy.html+++ /dev/null@@ -1,179 +0,0 @@-{% extends "base.html" %}-{% import "navbar.html" as navbar %}-{% import "footer.html" as footer %}--{% block content %}-<div class="flex flex-col h-full w-full">- <div class="min-h-max w-full">- <header class="flex items-center w-full h-24">- <div class="ml-14 mr-14 w-12 h-12">- <a href="/">- <img src="/static/images/logo.svg" class="w-full h-full" />- </a>- </div>- {% call navbar::navbar() %}- </header>- </div>-- <div class="flex flex-col w-full h-fit items-center pt-10">- <div class="flex flex-col w-full items-center max-w-4xl mr-10 ml-10 space-y-16">- <div class="space-y-3">- <h1 class="text-2xl font-medium pb-2">We will always respect your privacy.</h1>-- <p>We will be good stewards of any personal information you share with us and we promise not to share- your- data- with anyone else in any way, shape or form.</p>-- <p>When using Cuely, you can have peace of mind knowing that we do whatever is possible to keep- your- private information - private. We mostly do this by simply not storing any of your private- information at all. This keeps things simple, both for you and for us.</p>-- <p>Here is a brief overview of your privacy:</p>-- <ul class="list-disc pl-7">- <li>Searches are anonymous and private to you.</li>- <li>We don't log or store your IP address.</li>- <li>We do not use any web browser analytics or other frontend telemetry.</li>- <li>We do not share any user data with any third parties.</li>- <li>We collect only the data needed to provide and protect the service.</li>- <li>We serve all images and other static content directly from our servers to prevent tracking from- third parties.</li>- <li>We use HTTPS encryption everywhere.</li>- </ul>-- <p>You don't have to take our word for these claims as our <a- href="https://github.com/cuely/cuely">source code is available to everyone.</a></p>- </div>- <div class="space-y-3">- <h1 class="text-xl">Terms of Service</h1>-- <p>Keep in mind that all services provided in Cuely are provided “as is” and there are no warranties. By- using our services you agree with the following terms.- </p>-- <p><span class="font-medium">Introduction</span> These Terms of Service ("Terms") govern your use of- Cuely (the "Services").</p>-- <p><span class="font-medium">Privacy Policy</span> We use the information we receive through the- Services as described in our Privacy Policy.</p>-- <p><span class="font-medium">Source code </span> The source code for Cuely is distributed under the- license described in the <a href="https://github.com/Cuely/Cuely/blob/main/LICENSE.md">git- repository.</a></p>-- <p><span class="font-medium">Proprietary Rights</span> Cuely does not grant you any intellectual- property- rights in the Services that are- not- specifically stated in these Terms. For example, these Terms do not provide the right to use any of- Cuely's- copyrights, trade names, trademarks, service marks, logos, domain names, or other distinctive brand- features.</p>-- <p><span class="font-medium">Indemnification</span> You agree to defend, indemnify and hold harmless- Cuely, its contractors, contributors,- licensors,- and partners, and their respective directors, officers, employees and agents ("Indemnified Parties")- from- and- against any and all third party claims and expenses, including attorneys' fees, arising out of or- related to- your use of the Services.</p>-- <p><span class="font-medium">Limitation of Liability</span> THE SERVICES ARE PROVIDED "AS IS"- WITH ALL FAULTS. TO THE EXTENT- PERMITTED- BY LAW, CUELY AND THE INDEMNIFIED PARTIES HEREBY DISCLAIM ALL WARRANTIES, WHETHER EXPRESS OR- IMPLIED,- INCLUDING- WITHOUT LIMITATION WARRANTIES THAT THE SERVICES ARE FREE OF DEFECTS, MERCHANTABLE, FIT FOR A- PARTICULAR- PURPOSE,- AND NON-INFRINGING. YOU BEAR THE ENTIRE RISK AS TO SELECTING THE SERVICES FOR YOUR PURPOSES AND AS- TO- THE- QUALITY AND PERFORMANCE OF THE SERVICES, INCLUDING WITHOUT LIMITATION THE RISK THAT YOUR CONTENT IS- DELETED- OR- CORRUPTED OR THAT SOMEONE ELSE ACCESSES YOUR ONLINE ACCOUNTS. THIS LIMITATION WILL APPLY- NOTWITHSTANDING- THE- FAILURE OF ESSENTIAL PURPOSE OF ANY REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR- LIMITATION- OF- IMPLIED WARRANTIES, SO THIS DISCLAIMER MAY NOT APPLY TO YOU. EXCEPT AS REQUIRED BY LAW, CUELY AND- THE- INDEMNIFIED- PARTIES WILL NOT BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR EXEMPLARY- DAMAGES- ARISING- OUT OF OR IN ANY WAY RELATING TO THESE TERMS OR THE USE OF OR INABILITY TO USE THE SERVICES,- INCLUDING- WITHOUT- LIMITATION DIRECT AND INDIRECT DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, LOST PROFITS, LOSS OF- DATA,- AND- COMPUTER FAILURE OR MALFUNCTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS- OF- THE- THEORY- (CONTRACT, TORT, OR OTHERWISE) UPON WHICH SUCH CLAIM IS BASED. THE COLLECTIVE LIABILITY OF CUELY AND- THE- INDEMNIFIED PARTIES UNDER THIS AGREEMENT WILL NOT EXCEED $500 (FIVE HUNDRED DOLLARS). SOME- JURISDICTIONS- DO- NOT- ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL, CONSEQUENTIAL, OR SPECIAL DAMAGES, SO THIS- EXCLUSION- AND- LIMITATION MAY NOT APPLY TO YOU.</p>-- <p><span class="font-medium">Modifications to these Terms</span> Cuely may update these Terms from time- to time to address a new feature- of- the- Services or to clarify a provision. The updated Terms will be posted online. If the changes are- substantive,- we- will announce the update through Cuely's usual channels for such announcements such as Discord.- Your continued use of the Services after the effective date of such changes constitutes your- acceptance- of- such- changes.- </p>-- <p><span class="font-medium">Miscellaneous</span> These Terms constitute the entire agreement between- you and Cuely concerning the- Services- and- are- governed by the laws of Denmark, excluding its conflict of law provisions. If any- portion- of these Terms is held to be invalid or unenforceable, the remaining portions will remain in full- force- and- effect. In the event of a conflict between a translated version of these terms and the English- language- version,- the English language version shall control.</p>-- </div>- <div class="w-full pb-10">- <h1>Changelog</h1>- <div>- <div class="flex space-x-1">- <h3 class="font-medium">31-08-2022:</h3>- <p>Initial commit</p>- </div>- </div>- </div>- </div>- </div>- <div class="flex flex-grow"></div>- {% call footer::footer() %}-</div>--{% endblock %}\ No newline at end of filediff --git a/templates/search.html b/templates/search.htmldeleted file mode 100644index eeb7a437..00000000--- a/templates/search.html+++ /dev/null@@ -1,179 +0,0 @@-{% extends "base.html" %}-{% import "searchbar.html" as scope %}-{% import "entity.html" as entity_scope %}-{% import "navbar.html" as navbar %}-{% import "footer.html" as footer %}--{% block content %}--<div class="flex flex-col w-full">- <div class="flex items-center h-24 border bg-neutral-50">- <div class="ml-14 mr-14 w-12 h-12">- <a href="/">- <img src="/static/images/logo.svg" class="w-full h-full" />- </a>- </div>- {% call scope::searchbar("", query) %}- {% call navbar::navbar() %}- </div>-- <div class="flex">- <div class="flex pl-40 flex-col">- <div class="flex mt-1 pl-3 pt-2 max-w-3xl pr-24 w-full justify-between">- <div class="flex flex-col h-full justify-center text-sm text-gray-600">- <p class="h-fit">Found {{ num_matches }} results in {{ search_duration_sec }} seconds</p>- </div>- <div class="select-region h-full flex flex-col justify-center p-0 m-0">- <select form="searchbar-form" name="gl" class="p-0 m-0 hover:cursor-pointer">- {% for region_selection in all_regions %}- {% match region_selection %}- {% when RegionSelection::Selected with (region) %}- <option value="{{ region.gl() }}" selected>{{ region.name() }}</option>- {% when RegionSelection::Unselected with (region) %}- <option value="{{ region.gl() }}">{{ region.name() }}</option>- {% endmatch %}- {% endfor %}- </select>- </div>- </div>- <div class="flex flex-col pt-4 pb-8">- {% match spell_correction %}- {% when Some with (correction) %}- <div class="pl-3 pb-3 ">- Did you mean: <a class="italic title-link font-bold" href="/search?q={{ correction|urlencode }}">{{- correction- }}</a>- </div>- {% when None %}- {% endmatch %}-- <div class="search-result flex flex-col space-y-3">- {% for item in search_result %}- <div class="flex max-w-3xl w-full p-3">- <div class="flex flex-col w-full">- <div class="text-sm mb-1 flex">- <div class="flex items-center mr-2">- <img src="/favicons/{{ item.domain|urlencode }}" width="13px" />- </div>- <div>- <a class="hover:no-underline text-gray-600" href="{{ item.url }}">{{- item.pretty_url- }}</a>- </div>- </div>- <div class="text-lg font-medium mb-1">- <a class="title-link" href="{{ item.url }}">{{ item.title }}</a>- </div>- <div class="text-sm">- {% match item.last_updated %}- {% when Some with (val) %}- <span class="text-gray-500">- {{ val }}- </span> —- {% when None %}- {% endmatch %}- {{ item.snippet }}- </div>- </div>- <div class="flex h-full items-center">- <div class="h-20 w-20 pl-2 pt-1 pb-1">- {% match item.primary_image_uuid %}- {% when Some with (val) %}- <a href="{{ item.url|urlencode }}">- <img class="h-full w-full object-cover rounded-full"- src="/image/{{ val|urlencode }}" />- </a>- {% when None %}- {% endmatch %}- </div>- </div>- </div>- {% endfor %}- </div>- <div class="flex w-full justify-center items-center pr-24 mt-5">- {% if current_page == 1 %}- <div class="prev-page gray-arrow">- </div>- {% else %}- {% match prev_page_url %}- {% when Some with (url) %}- <a href="{{ url }}">- <div class="prev-page cuely-color-arrow">- </div>- </a>- {% when None %}- <div class="prev-page gray-arrow">- </div>- {% endmatch %}- {% endif %}- <div class="mr-2 ml-2">- Page {{ current_page }}- </div>- <a href="{{ next_page_url }}">- <div class="next-page cuely-color-arrow">- </div>- </a>- </div>- </div>-- </div>-- {% match entity %}- {% when Some with (entity) %}- {% call entity_scope::show_entity(entity) %}- {% when None %}- {% endmatch %}- </div>-</div>--{% call footer::footer() %}--<style>- .prev-page {- width: 16px;- height: 16px;- -webkit-mask: url(/static/images/arrow.svg) no-repeat center;- mask: url(/static/images/arrow.svg) no-repeat center;- mask-size: contain;- transform: rotate(180deg);- }-- .next-page {- width: 16px;- height: 16px;- -webkit-mask: url(/static/images/arrow.svg) no-repeat center;- mask: url(/static/images/arrow.svg) no-repeat center;- mask-size: contain;- }-- .gray-arrow {- background-color: gray;- }-- .cuely-color-arrow {- background-color: #0b7bff;- }-- .title-link {- color: #1a0dab;- }-- .title-link:visited {- color: #609;- }-- .search-result {- text-rendering: optimizeLegibility;- font-smooth: grayscale;- -moz-osx-font-smoothing: grayscale;- }-- .select-region>select {- background-color: transparent;- border: 0px;- font-size: small;- width: 105px;- }-</style>--{% endblock %}\ No newline at end of filediff --git a/templates/searchbar.html b/templates/searchbar.htmldeleted file mode 100644index 07b54d9a..00000000--- a/templates/searchbar.html+++ /dev/null@@ -1,294 +0,0 @@-{% macro searchbar(autofocus, query) %}---<style>- .searchbar {- border-color: #dadada;- border-radius: 30px;- border-width: 1px;- }-- .searchbar:hover {- box-shadow: rgba(0, 0, 0, 0.08) 0px 1px 3px 1px;- }-- .searchbar:focus-within {- border-width: 1px 1px 1px 1px;- box-shadow: rgba(0, 0, 0, 0.08) 0px 1px 3px 1px;- }-- .searchbar-suggestions-visible {- border-width: 1px 1px 0px 1px !important;- border-radius: 25px 25px 0px 0px;- }-- .suggestions {- top: 100%;- box-shadow: rgba(0, 0, 0, 0.08) 0px 2px 3px 0px;- visibility: hidden;- border-color: #dadada;- border-radius: 0px 0px 25px 25px;- border-width: 0px 1px 1px 1px;- padding-bottom: 10px;- padding-top: 0px;- }-- .sep-bar {- margin-right: 20px;- margin-left: 20px;- }-- .sep-bar-margin-bottom {- margin-bottom: 20px;- }-- .suggestions-visible {- visibility: visible;- overflow: hidden;- }-- .suggestion-item {- padding-bottom: 7px;- padding-top: 7px;- padding-left: 19px;- }-- .suggestions:last-child {- padding-bottom: 0px;- }-- .suggestions:nth-child(2) {- padding-top: 0px;- }-- .suggestion-item-hover {- background-color: rgb(245, 245, 245);- cursor: pointer;- }-</style>--<form id="searchbar-form" class="w-full md:max-w-2xl relative" method="GET" action="/search" autocomplete="off">- <div class="searchbar-container">- <div class="searchbar w-full flex flex-col bg-white overflow-hidden">- <div class="h-12 w-full flex flex-col">- <div class="flex h-full">- <div class="flex ml-5 mr-1 w-5 items-center">- <img class="h-5" loading="lazy" src="/static/images/search.svg" />- </div>- <input type="text" value="{{ query|escape }}" {{ autofocus }} name="q"- class="searchbar-input flex w-full h-full grow focus:ring-0" placeholder="Search"- style="background-color: transparent; border: none; outline: none;" />-- <div class="flex w-12 h-full justify-center items-center">- <button type="submit" class="bg-transparent p-0 m-0" style="border: none">- <img loading="lazy" src="/static/images/arrow.svg"- class="h-5 cursor-pointer bg-transparent" />- </button>- </div>- </div>- </div>- </div>- <div class="suggestions absolute flex flex-col w-full bg-white">- <div class="sep-bar sep-bar-margin-bottom">- <hr />- </div>- </div>-- </div>-</form>--<script>- const searchbarContainer = document.querySelector('.searchbar-container');- const searchbar = document.querySelector('.searchbar');- const searchbarInput = document.querySelector('.searchbar-input');- const suggestions = document.querySelector('.suggestions');- const sepBar = document.querySelector('.sep-bar');- let suggestionItems = document.querySelectorAll('.suggestion-item');-- let currentHighlighted = -1;- let currentSuggestions = [];- let originalQuery = "{{ query|escape }}";--- function updateSuggestions(suggestionsData) {- suggestionItems.forEach(item => {- item.remove();- });-- if (suggestionsData.length == 0) {- sepBar.classList.add("sep-bar-margin-bottom");- } else {- sepBar.classList.remove("sep-bar-margin-bottom");- }-- currentSuggestions = suggestionsData.map(item => item.raw);- currentHighlighted = -1;-- suggestionsData.forEach(item => {- const node = document.createElement("div");-- console.log(item);- node.classList.add("flex");- node.classList.add("suggestion-item");- node.setAttribute("data-suggestion", item.raw)- console.log(node);-- node.innerHTML = `- <div class="flex w-4 mr-3 items-center">- <img class="h-5" loading="lazy" src="/static/images/search.svg" />- </div>- <div>- ${item.highlighted}- </div>- `.trim();-- suggestions.appendChild(node);- });-- suggestionItems = document.querySelectorAll('.suggestion-item')-- suggestionItems.forEach(item => item.addEventListener("mousedown", (event) => {- handleSuggestionClick(event.target);- }));-- suggestionItems.forEach((item, idx) => item.addEventListener("mouseenter", (event) => {- currentHighlighted = idx;- updateHighlighted(false);- }));- }-- function handleSuggestionClick(element) {- if (element == null) {- return;- }-- var suggestion = element.dataset.suggestion;-- if (suggestion == undefined) {- return handleSuggestionClick(element.parentElement);- }-- var searchParams = new URLSearchParams(window.location.search);- searchParams.set("q", suggestion);- searchParams.set("p", "0");- window.location = "/search?" + searchParams.toString();-- return;- }-- function fetchAndUpdateSuggestions() {- const q = searchbarInput.value;-- if (q == "") {- return;- }-- fetch('/autosuggest?' + new URLSearchParams({- q: q,- }))- .then(response => response.json())- .then(data => updateSuggestions(data));- }-- function updateHighlighted(updateInputField) {- if (updateInputField) {- if (currentHighlighted == -1) {- searchbarInput.value = originalQuery;- } else {- searchbarInput.value = htmlDecode(currentSuggestions[currentHighlighted]);- }- }-- suggestionItems.forEach(item => item.classList.remove("suggestion-item-hover"))-- if (currentHighlighted != -1) {- suggestionItems[currentHighlighted].classList.add("suggestion-item-hover");- }- }-- function handleUpKey(event) {- event.preventDefault();-- if (!suggestions.classList.contains("suggestions-visible")) {- return;- }-- if (currentHighlighted < 0) {- currentHighlighted = currentSuggestions.length - 1;- } else {- currentHighlighted--;- }- updateHighlighted(true);- }-- function handleDownKey(event) {- event.preventDefault();-- if (!suggestions.classList.contains("suggestions-visible")) {- return;- }-- if (currentHighlighted == currentSuggestions.length - 1) {- currentHighlighted = -1;- } else {- currentHighlighted++;- }-- updateHighlighted(true);- }-- function handleArrowKeys(event) {- if (event.keyCode == 38) {- handleUpKey(event);- } else if (event.keyCode == 40) {- handleDownKey(event);- }- }-- function htmlDecode(input) {- var doc = new DOMParser().parseFromString(input, "text/html");- return doc.documentElement.textContent;- }--- searchbarInput.addEventListener('keydown', (event) => {- handleArrowKeys(event);- });-- searchbarInput.addEventListener('keyup', (event) => {- if (event.keyCode == 38 || event.keyCode == 40) {- return;- }-- if (event.keyCode == 27) {- suggestions.classList.remove("suggestions-visible");- searchbar.classList.remove("searchbar-suggestions-visible");- return;- }-- originalQuery = searchbarInput.value;-- if (![16, 224, 18, 17, 27].includes(event.keyCode)) {- suggestions.classList.add("suggestions-visible");- searchbar.classList.add("searchbar-suggestions-visible");- }- fetchAndUpdateSuggestions();- });-- searchbarContainer.addEventListener("focusin", (event) => {- suggestions.classList.add("suggestions-visible");- searchbar.classList.add("searchbar-suggestions-visible");- fetchAndUpdateSuggestions();- });- searchbarInput.addEventListener("click", (event) => {- suggestions.classList.add("suggestions-visible");- searchbar.classList.add("searchbar-suggestions-visible");- });-- searchbarContainer.addEventListener("focusout", (event) => {- suggestions.classList.remove("suggestions-visible");- searchbar.classList.remove("searchbar-suggestions-visible");- });-</script>--{% endmacro %}\ No newline at end of file