Compare commits

..

No commits in common. "main" and "v0.4.0" have entirely different histories.
main ... v0.4.0

13 changed files with 480 additions and 641 deletions

View file

@ -18,5 +18,4 @@ repos:
name: ui/menu lint+fmt
language: system
files: ^ui/menu/
pass_filenames: false
entry: npm run --prefix ui/menu pc
entry: sh -c "npm run --prefix ui/menu pc"

View file

@ -2,31 +2,6 @@
All notable changes to this project will be documented in this file.
## [0.4.2] - 2023-07-22
### Bug Fixes
- Container entrypoint
- Website version ordering
### Miscellaneous Tasks
- Fix npm pre-commit hook
## [0.4.1] - 2023-04-05
### Bug Fixes
- Stop propagation of key events on menu search
- Use sh
- Remove version prefix from "latest" tag
- Detect CI commit SHA
- Use better abbreviations for page names
### Features
- Add upload script
## [0.4.0] - 2023-04-02
### Features

958
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[package]
name = "talon"
version = "0.4.2"
version = "0.4.0"
edition = "2021"
authors = ["ThetaDev <t.testboy@gmail.com>"]
license = "MIT"

View file

@ -48,7 +48,7 @@ commit_parsers = [
{ message = "^refactor", group = "Refactor"},
{ message = "^style", group = "Styling"},
{ message = "^test", group = "Testing"},
{ message = "^chore\\(release\\):", skip = true},
{ message = "^chore\\(release\\): (prepare for|bump)", skip = true},
{ message = "(^chore)|(^ci)", group = "Miscellaneous Tasks"},
{ body = ".*security", group = "Security"},
]

View file

@ -41,8 +41,7 @@ for arch in "${ARCHITECTURES[@]}"; do
# Finalize container
buildah umount "$container"
# entrypoint syntax: see issue https://github.com/containers/buildah/issues/1768
buildah config --entrypoint '["/talon"]' --cmd "run -d /data" --arch "$arch" --port 3000 --author "ThetaDev" "$container"
buildah config --entrypoint "/talon" --cmd "run -d /data" --arch "$arch" --port 3000 --author "ThetaDev" "$container"
buildah commit "$container" "$IMAGE:$arch-$TAG"
buildah manifest add "$REGISTRY/$IMAGE:$TAG" "$IMAGE:$arch-$TAG"

View file

@ -1,75 +0,0 @@
#!/bin/sh
set -e
# Check for dependencies
which curl > /dev/null
which jq > /dev/null
# Assert required variables
if [ -z "$TALON_KEY" ]; then echo "TALON_KEY unset"; exit 1; fi
if [ -z "$TALON_URL" ]; then echo "TALON_URL unset"; exit 1; fi
if [ -z "$SUBDOMAIN" ]; then echo "SUBDOMAIN unset"; exit 1; fi
API_URL="$TALON_URL/api"
API_KEY_H="x-api-key: $TALON_KEY"
# Check if the website already exists
WEBSITE_STATUS=$(curl --head -o /dev/null -s -w "%{http_code}" "$API_URL/website/$SUBDOMAIN")
if [ "$WEBSITE_STATUS" = "200" ]; then
echo "Website '$SUBDOMAIN' found"
else
# Create the website if it does not exist
if [ -z "$WEBSITE_NAME" ]; then echo "WEBSITE_NAME unset"; exit 1; fi
CREATE_BODY=$(jq -c --null-input --arg name "$WEBSITE_NAME" --arg color "$WEBSITE_COLOR" \
--arg visibility "$WEBSITE_VISIBILITY" --arg source_url "$WEBSITE_SOURCE_URL" \
--arg source_icon "$WEBSITE_SOURCE_ICON" \
'{"name": $name, "color": $color, "visibility": $visibility, "source_url": $source_url, "source_icon": $source_icon} | delpaths([path(.[]| select(.==""))])')
echo "Creating website '$SUBDOMAIN': $CREATE_BODY"
curl -Ss --fail -X "PUT" -H "$API_KEY_H" -H "content-type: application/json" --data "$CREATE_BODY" "$API_URL/website/$SUBDOMAIN"
fi
# Check the upload directory
if [ ! -d "$1" ]; then echo "Upload directory does not exist"; exit 1; fi
if [ ! -f "$1/index.html" ]; then echo "Upload directory does not contain index.html"; exit 1; fi
# Validate fallback page param
if [ "$FALLBACK" ] && [ ! -f "$1/$FALLBACK" ]; then echo "fallback page $FALLBACK does not exist"; exit 1; fi
# Automatically detect fallback pages
if [ -z "$SPA" ] && [ -z "$FALLBACK" ]; then
if [ -f "$1/404.html" ]; then FALLBACK="404.html"; fi
if [ -f "$1/200.html" ]; then SPA=true; FALLBACK="200.html"; fi
fi
push_arg() {
if [ "$UPLOAD_ARGS" ]; then UPLOAD_ARGS="$UPLOAD_ARGS&"; fi
UPLOAD_ARGS="$UPLOAD_ARGS$1"
}
if [ "$FALLBACK" ]; then push_arg "fallback=$FALLBACK"; fi
if [ "$SPA" = "true" ]; then push_arg "spa=true"; fi
if [ "$UPLOAD_ARGS" ]; then UPLOAD_ARGS="?$UPLOAD_ARGS"; fi
if [ "$CI_COMMIT_SHA" ]; then
echo "Git commit: $CI_COMMIT_SHA"
push_arg "commit=$CI_COMMIT_SHA"
elif GIT_COMMIT=$(git rev-parse HEAD 2> /dev/null); then
echo "Git commit: $GIT_COMMIT"
push_arg "commit=$GIT_COMMIT"
fi
# Compress website
ARCHIVE=$(mktemp)
tar -cz --directory "$1" --file "$ARCHIVE" .
# Upload website
echo "Version params: $UPLOAD_ARGS"
echo "Uploading..."
curl --fail -X "POST" -H "$API_KEY_H" -H "content-type: application/octet-stream" --data-binary "@$ARCHIVE" "$API_URL/website/$SUBDOMAIN/upload$UPLOAD_ARGS"
rm "$ARCHIVE"
echo "Website uploaded ;-)"

View file

@ -300,17 +300,18 @@ impl TalonApi {
subdomain: Path<String>,
) -> Result<Response<Json<Vec<Version>>>> {
let website = talon.db.get_website(&subdomain)?;
let mut versions = talon
talon
.db
.get_website_versions(&subdomain)
.map(|r| r.map(Version::from))
.collect::<Result<Vec<_>, _>>()?;
versions.sort_by_key(|v| v.id);
Ok(Response::new(Json(versions)).header(
header::LAST_MODIFIED,
httpdate::fmt_http_date(website.updated_at.into()),
))
.collect::<Result<Vec<_>, _>>()
.map(|data| {
Response::new(Json(data)).header(
header::LAST_MODIFIED,
httpdate::fmt_http_date(website.updated_at.into()),
)
})
.map_err(Error::from)
}
/// Get version

View file

@ -49,7 +49,7 @@
closeSearch();
}
function searchKeyup(e: KeyboardEvent) {
function searchKeypress(e: KeyboardEvent) {
switch (e.key) {
case "Enter":
if (!searchText) {
@ -96,7 +96,7 @@
active={searchOpen || Boolean(searchText).valueOf()}
on:click={openSearch}
on:focusout={closeSearch}
on:keyup={searchKeyup}
on:keyup={searchKeypress}
bind:input={searchInput}
bind:text={searchText}
/>

View file

@ -26,9 +26,7 @@
bind:this={inputElm}
bind:value={text}
on:focusout
on:keypress|stopPropagation
on:keydown|stopPropagation
on:keyup|stopPropagation
on:keyup
use:selectTextOnFocus
/>
<Icon iconName="search" size={40} scale={0.6} />

View file

@ -3,7 +3,6 @@
import Icon from "./Icon.svelte";
import type { Website } from "talon-client";
import { talonConfig } from "../util/talonData";
import { getAbbreviation } from "../util/functions";
export let website: Website;
export let size = 40;
@ -16,7 +15,7 @@
? `${talonConfig.internal}/icons/${website.subdomain}`
: null}
color={website.color}
alt={getAbbreviation(website.name)}
alt={website.name.substring(0, 2)}
{size}
{scale}
/>

View file

@ -3,7 +3,6 @@
import {
formatDate,
getSubdomainAndVersion,
getWebsiteUrl,
getWebsiteVersionUrl,
isUrl,
trimCommit,
@ -76,7 +75,9 @@
Current version #{currentVersion.id}
{#if latestVersion && latestVersion !== currentVersion}
<a class="latest-tag" href={getWebsiteUrl(currentWebsite.subdomain)}
<a
class="latest-tag"
href={getWebsiteVersionUrl(currentWebsite.subdomain, latestVersion.id)}
>Latest: #{latestVersion.id}</a
>
{/if}

View file

@ -81,23 +81,3 @@ export function trimCommit(commit: string | undefined): string | undefined {
export function isMobile(): boolean {
return window.innerWidth < 768;
}
/**
* Get a 2-letter abbreviation of the website name.
*
* If the name consists of multiple words
* (separated by spaces, underscores or CamelCase), output
* the first letters of these words.
*
* Otherwise output the first letters of the name.
*/
export function getAbbreviation(name: string): string {
const split_sep = name
.replace(/([a-z])([A-Z])/g, "$1_$2")
.split(/[ ,.;_-]/)
.filter((x) => x.length > 0);
if (split_sep.length >= 2) {
return split_sep[0].charAt(0) + split_sep[1].charAt(0);
}
return name.substring(0, 2);
}