Compare commits

...

14 commits

Author SHA1 Message Date
Korbs
ea0a1670de update 2024-10-25 14:54:04 -04:00
Korbs
b0a9bffc76 Update web search 2024-10-25 14:53:56 -04:00
Korbs
2db5a5abab Check cookies for theme toggle 2024-10-25 14:53:49 -04:00
Korbs
1e66c7cd9a Update search menu 2024-10-25 14:53:39 -04:00
Korbs
05511d7400 Add theme toggle with cookies 2024-10-25 14:53:27 -04:00
Korbs
e235a064ec Update footer links 2024-10-25 14:53:16 -04:00
Korbs
4a50e5df39 Use endpoint request over script workaround 2024-10-25 14:53:06 -04:00
Korbs
f608045b47 Update icons 2024-10-25 14:52:51 -04:00
Korbs
be1ae93f35 Update styling 2024-10-25 14:52:40 -04:00
Korbs
88be8aab63 update 2024-10-25 14:51:27 -04:00
Korbs
29a35e41f4 Fix typo 2024-10-25 14:51:17 -04:00
Korbs
297c435f4c Add Docker files 2024-10-25 14:51:07 -04:00
Korbs
e4035a3089 Make search box it's own componet, update scripts 2024-10-25 14:50:58 -04:00
Korbs
9da485dee0 Add Mona Sans font 2024-10-25 14:50:37 -04:00
174 changed files with 380 additions and 73 deletions

8
.dockerignore Normal file
View file

@ -0,0 +1,8 @@
# User is expected to provide their own .env file in their Docker Compose file.
# Either with volumes or using the Enviroment option.
.env
# Other Files
.DS_Store
dist
node_modules

39
Dockerfile Normal file
View file

@ -0,0 +1,39 @@
#########################################################
# SudoVanilla will never use images from Docker Hub, as #
# Docker Hub is proprietary. SudoVanilla hosts slim #
# versions of Bun's Docker image on SudoVanilla Ark. #
#########################################################
#########################################################
# Other locations to download the image is available #
# #
# Codeberg: #
# codeberg.org/korbs/bun:amd64 #
# codeberg.org/korbs/bun:arm64 #
# #
# Quay: #
# quay.io/sudovanilla/bun:amd64 #
# quay.io/sudovanilla/bun:arm64 #
# #
#########################################################
# Base
## For AMD64 Servers:
FROM oven/bun:alpine AS based
## For ARM64 Servers:
## FROM ark.sudovanilla.org/korbs/bun:arm64 as based
# Copy Files
WORKDIR /app
COPY . .
# Run in Production
ENV NODE_ENV=production
# Build
RUN bun install && bun run build
# Run
USER bun
EXPOSE 1550/tcp
CMD bun ./.zarro/generated/astro/dist/server/entry.mjs

BIN
bun.lockb

Binary file not shown.

View file

@ -1,6 +1,6 @@
{
"name": "zerro",
"version": "24.10.22",
"version": "24.10.25",
"description": "A search engine",
"repository": "https://ark.sudovanilla.org/Korbs/Zarro",
"author": "Korbs <korbs@sudovanilla.org>",

View file

@ -6,8 +6,8 @@ import bun from "@nurodev/astro-bun"
// https://astro.build/config
export default defineConfig({
// Project Structure
cacheDir: './.zerro/generated/astro/cache/',
outDir: './.zerro/generated/astro/dist/',
cacheDir: './.zarro/generated/astro/cache/',
outDir: './.zarro/generated/astro/dist/',
publicDir: './source/src/public',
root: './source',
srcDir: './source/src',

View file

@ -11,13 +11,13 @@ import {
<p>Zarro Search, a search engine by SudoVanilla</p>
</div>
<div class="footer-end">
<a href="#">About</a>
<a href="#">Instances</a>
<a href="https://ark.sudovanilla.org/Korbs/Zarro/src/branch/main/README.md">About</a>
<!-- <a href="#">Instances</a>
<a href="#">Settings</a>
<a href="#">News</a>
<a href="#">API</a>
<a href="#">Source Code</a>
<a href="#">Report Issue</a>
<a href="#">API</a> -->
<a href="https://ark.sudovanilla.org/Korbs/Zarro">Source Code</a>
<a href="https://ark.sudovanilla.org/Korbs/Zarro/issues">Report Issue</a>
</div>
</footer>

View file

@ -1,6 +1,13 @@
---
// Components
import { Tooltips } from 'astro-tooltips'
// User Configuration
if (Astro.cookies.get("Theme").value === "Light") {
var ThemeScheme = 'light'
} else if (Astro.cookies.get("Theme").value === "Dark") {
var ThemeScheme = 'dark'
}
---
<head>
@ -15,6 +22,23 @@ import { Tooltips } from 'astro-tooltips'
<!-- Favicon -->
<link rel="apple-touch-icon" href="https://md.sudovanilla.org/images/Union.png" />
<link rel="icon" href="https://md.sudovanilla.org/images/Union.png" />
<!-- Fonts -->
<link rel="preload" href="/fonts/Mona-Sans/Mona-Sans.woff2" as="font" type="font/woff2" crossorigin>
<!-- Tooltip -->
<Tooltips interactive={false} delay={[15, 1000]} />
</head>
</head>
<body class={ThemeScheme}>
<script>
// If First Launch
if (localStorage.getItem('BeenHereBefore') === 'true') {
null
} else {
SetDefaults()
}
function SetDefaults() {
localStorage.setItem('BeenHereBefore', 'true')
document.cookie = "Theme=Dark";
}
</script>

View file

@ -2,24 +2,41 @@
// Properties
const {Query, QueryText} = Astro.props
// Components
import SearchBox from "./SearchBox.astro";
// Icons
import { HalfMoon, Menu } from "@iconoir/vue";
import { HalfMoon, Menu, SunLight } from "@iconoir/vue";
---
<header>
<div class="header-start">
<a href="/"><img width="18px" src="https://md.sudovanilla.org/images/Union.png"/></a>
<form class="search-box" onsubmit="return Search()">
<input type="search" value={QueryText} placeholder="Search" />
</form>
<SearchBox/>
</div>
<div class="header-end">
<button>English</button>
<button title="Toggle Theme" class="button-icon"><HalfMoon /></button>
<button onclick="ThemeToggle()" title="Toggle Theme" class="button-icon">
<SunLight class:list={'theme-light'}/>
<HalfMoon class:list={'theme-dark'}/>
</button>
<button title="Options" class="button-icon" data-tooltip-placement="right"><Menu /></button>
</div>
</header>
<script is:inline>
function ThemeToggle() {
if (document.body.getAttribute('class') === 'dark') {
document.body.setAttribute('class', 'light')
document.cookie = "Theme=Light";
} else if (document.body.getAttribute('class') === 'light') {
document.body.setAttribute('class', 'dark')
document.cookie = "Theme=Dark";
}
}
</script>
<style lang="scss">
header {
padding: 16px 0px;
@ -39,9 +56,10 @@ header {
border-radius: 3rem;
border: 1px white solid;
padding: 0px 12px;
background: white;
background: var(--box-background);
border: 1px rgb(192, 192, 192) solid;
cursor: pointer;
color: var(--text);
}
.button-icon {
aspect-ratio: 1;
@ -52,36 +70,13 @@ header {
}
}
}
.search-box {
background: white;
border: 1px rgb(192, 192, 192) solid;
border-radius: 3rem;
display: flex;
align-items: center;
gap: 6px;
padding: 16px 8px;
position: relative;
max-width: 500px;
width: 300px;
input {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
border-radius: 3rem;
border: none;
background: transparent;
padding: 0px 12px;
}
}
}
</style>
<!-- Search Scripts -->
<!-- From https://ark.sudovanilla.org/MinPluto/MinPluto/src/branch/master/source/src/components/Search.astro#L18-L94 as of writing -->
<script is:inline>
/*
<script>
/*
@licstart The following is the entire license notice for the
JavaScript code in this page.
@ -111,9 +106,13 @@ function FocusSearch() {
document.querySelector('input[type="search"]').focus();
}
// The "Search()" function does not work for Zarro, an API request
// will be made to an endpoint instead with a redirect parameter.
// Learn More: https://docs.astro.build/en/guides/endpoints/#redirects
// Trigger Search
function Search() {
var SearchQuery = document.querySelector('form > input[type="search"]').value;
location.href = `/web?=${SearchQuery}`;
}
// function Search() {
// var SearchQuery = document.querySelector('form > input[type="search"]').value;
// location.href = `/web?=${SearchQuery}`;
// }
</script>

View file

@ -0,0 +1,39 @@
---
// Properties
const {Query, QueryText} = Astro.props
---
<form class="search-box" action="/api/search/web" method="post">
<input name="websearch" value={QueryText} placeholder="Search"/>
</form>
<style lang="scss">
.search-box {
background: var(--box-background);
border: 1px rgb(192, 192, 192) solid;
border-radius: 3rem;
display: flex;
align-items: center;
gap: 6px;
padding: 16px 8px;
position: relative;
max-width: 500px;
width: 300px;
input {
color: var(--text);
position: absolute;
top: 0px;
left: 0px;
width: calc(100% - 24px);
height: 28px;
border-radius: 3rem;
border: none;
background: transparent;
padding: 0px 12px;
border: 1px transparent solid;
&:focus {
outline: none;
}
}
}
</style>

View file

@ -16,9 +16,9 @@ const {Type} = Astro.props
<style lang="scss">
.search-menu {
a {
color: black;
color: var(--text);
text-decoration: none;
background: rgba(255, 255, 255, 0.25);
background: var(--box-background);
border-width: 2px;
border-style: solid;
border-color: transparent;
@ -37,15 +37,15 @@ const {Type} = Astro.props
{
()=> {
if (Type === "Web") {
return <style>#search-type-item-web {background: white; border-color: #ddd;} </style>
return <style>#search-type-item-web {background: var(--box-background); border-color: #ddd;} </style>
} else if (Type === "Images") {
return <style>#search-type-item-images {background: white; border-color: #ddd;} </style>
return <style>#search-type-item-images {background: var(--box-background); border-color: #ddd;} </style>
} else if (Type === "Videos") {
return <style>#search-type-item-videos {background: white; border-color: #ddd;} </style>
return <style>#search-type-item-videos {background: var(--box-background); border-color: #ddd;} </style>
} else if (Type === "News") {
return <style>#search-type-item-news {background: white; border-color: #ddd;} </style>
return <style>#search-type-item-news {background: var(--box-background); border-color: #ddd;} </style>
} else if (Type === "Map") {
return <style>#search-type-item-map {background: white; border-color: #ddd;} </style>
return <style>#search-type-item-map {background: var(--box-background); border-color: #ddd;} </style>
}
}
}

View file

@ -27,9 +27,11 @@ if (Image === null) {
display: flex;
flex-direction: column;
gap: 6px;
background: white;
background: var(--box-background);
transition: 0.6s background, 0.6s color;
border-radius: 6px;
padding: 12px;
color: var(--text);
* {
margin: 0px;
}

View file

@ -13,7 +13,7 @@ const {
<style lang="scss">
.search-correction {
border: 2px #ddd solid;
border: 2px #4c4f69 solid;
padding: 6px 24px;
font-size: 14px;
margin-bottom: 6px;

View file

@ -9,12 +9,13 @@
display: flex;
flex-wrap: wrap;
a {
background: white;
background: var(--box-background);
transition: 0.6s background, 0.6s color;
border-radius: 3rem;
text-decoration: none;
font-size: 14px;
padding: 6px 8px;
color: black;
color: var(--text);
text-wrap: nowrap;
margin-bottom: 6px;
margin-right: 4px;

View file

@ -23,14 +23,14 @@ const {
display: flex;
flex-direction: column;
gap: 6px;
background: white;
background: var(--box-background);
margin-bottom: 12px;
border-radius: 6px;
padding: 6px 12px;
padding: 12px;
box-shadow: 0px 4px 10px 0px #0000000a;
transition: 0.3s box-shadow;
transition: 0.6s background, 0.3s box-shadow;
&:hover {
box-shadow: 0px 0px 10px 10px rgba(0, 0, 0, 0.04);
box-shadow: 0px 0px 10px 10px rgba(0, 0, 0, 0.2);
transition: 0.3s box-shadow;
}
* {
@ -43,12 +43,13 @@ const {
text-decoration: none;
h2 {
font-size: 20px;
color: black;
color: var(--text);
}
p {
font-size: 12px;
text-decoration: underline;
color: rgb(82, 82, 82);
color: var(--link);
transition: 0.6s color;
}
}
.search-result-web-sublinks {
@ -57,7 +58,6 @@ const {
grid-template-columns: auto auto;
a {
font-size: 18px;
color: black;
}
}
}

View file

@ -10,6 +10,13 @@ import Footer from "@components/global/Footer.astro";
// Styles
import '@styles/index.scss'
import '@styles/mobile.scss'
// User Configuration
if (Astro.cookies.get("Theme").value === "Light") {
var ThemeScheme = 'light'
} else if (Astro.cookies.get("Theme").value === "Dark") {
var ThemeScheme = 'dark'
}
---
<Head/>

View file

@ -24,8 +24,10 @@ import SearchMenu from "@components/global/SearchMenu.astro"
<style>
.search-results {
margin-top: 16px;
display: grid;
grid-template-columns: 64% 34%;
display: flex;
gap: 24px;
.search-results-end {
max-width: 400px;
}
}
</style>

View file

@ -0,0 +1,15 @@
import type { APIRoute } from "astro"
export const POST: APIRoute = async ({ request, redirect }) => {
// Get Form Data
const formData = await request.formData()
const web_search = formData.get("websearch")?.toString()
// If the user presses "Enter" on a blank search, return to home
if (!web_search) {
return redirect("/")
}
// Go to search term
return redirect("/web?=" + web_search)
}

View file

@ -1,17 +1,33 @@
---
// Layout
import Base from "@layouts/Base.astro";
// Components
import SearchBox from "@components/global/SearchBox.astro";
---
<Base>
<a href="http://localhost:1550/web?=Queen%20Band">Example Search</a>
<br class="full"/>
<div class="home-center">
<SearchBox/>
</div>
</Base>
<style is:global>
/* Don't show header search */
header form {
display: none !important;
}
/* Home CSS */
.home-center {
position: absolute;
top: 42%;
left: 50%;
transform: translate(-50%, -50%);
}
footer {
position: absolute;
bottom: 0px;
width: 100%;
max-width: 1200px;
}
</style>
</style>
<script is:inline>FocusSearch()</script>

View file

@ -13,7 +13,6 @@ import Answer from "@components/search/Answer.astro";
import RelatedSearches from "@components/search/RelatedSearches.astro";
import WebLink from "@components/search/WebLink.astro";
import WebLinkSkeleton from "@components/search/WebLinkSkeleton.astro";
import { undefined } from "astro:schema";
// Fetch
const QueryString = Astro.url.href.split("web?=").pop() // Get user's search query from URL
@ -52,8 +51,8 @@ console.log(ShowRelated + '' + Query.related[0])
<slot slot="sublinks">
{query.sublink.map((link) =>
<a href={link.url}>
<p style="font-size: 18px; text-decoration: none;">{link.title}</p>
<p style="font-size: 14px;">{link.url}</p>
<p style="font-size: 18px; text-decoration: none; color: inherit !important; transition: 0.8s color;">{link.title}</p>
<p style="font-size: 14px; color: var(--link);">{link.url}</p>
</a>
)}
</slot>

View file

Before

Width:  |  Height:  |  Size: 349 KiB

After

Width:  |  Height:  |  Size: 349 KiB

View file

Before

Width:  |  Height:  |  Size: 900 B

After

Width:  |  Height:  |  Size: 900 B

View file

@ -0,0 +1,93 @@
Copyright (c) 2023, GitHub https://github.com/github/mona-sans
with Reserved Font Name "Mona Sans"
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting — in part or in whole — any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more