* initial commit federation * more federation * more federation * more federation * completes follow, accept, undo * add trail create activity * process trail create activity * more trail create activity * adds missing endpoints * adds update and delete activity * adds comment activities * adds activities back * adds summit logs activities * deletes follow counts table * fixes migrations * fixes migrations * fixes migrations * fixes migrations * adds remote profiles * ctd * ctd * we are getting closer... * adds public summit logs * fixes federated trails in lists * adds remote lists * adds list activites * fixes lists * adds notifications * adds iri redirect * fixes comments and summitlogs * fixes follows and profiles * adds asynchronous send * fixes list search * adds encryption key * bug fixes * fixes activity signing * removes custon activity object types * adds html editor * fixes html editor * fixes display issues on mastodon * adds federated sharing * finishes announcements * fixes small summit log issues * adds trail likes * finalizes likes * fixes images for komoot * add disable federation option * adds private profiles * updates docs * adds federated comments * adds trail and comments actvitiypub routes * adds mentions to editor * adds mentions to trails, comments, summit logs * updates theme * updates theme * update docs * update docs * updates docs * fixes various frontend problems * fixes activitypub follows api * updates docs * updates docs --------- Co-authored-by: Christian Beutel <>
222 lines
5.5 KiB
TypeScript
222 lines
5.5 KiB
TypeScript
import type { Actor } from "./activitypub/actor";
|
|
import type { Category } from "./category";
|
|
import type { Comment } from "./comment";
|
|
import type { SummitLog } from "./summit_log";
|
|
import type { Tag } from "./tag";
|
|
import type { TrailLike } from "./trail_like";
|
|
import type { TrailShare } from "./trail_share";
|
|
import type { Waypoint } from "./waypoint";
|
|
|
|
class Trail {
|
|
id?: string;
|
|
name: string;
|
|
location?: string;
|
|
date?: string;
|
|
public: boolean;
|
|
distance?: number;
|
|
elevation_gain?: number;
|
|
elevation_loss?: number;
|
|
duration?: number;
|
|
difficulty?: "easy" | "moderate" | "difficult"
|
|
lat?: number;
|
|
lon?: number;
|
|
thumbnail?: number;
|
|
photos: string[];
|
|
gpx?: string;
|
|
created?: string;
|
|
category?: string;
|
|
tags: string[];
|
|
waypoints: string[];
|
|
polyline?: string;
|
|
domain?: string;
|
|
iri?: string;
|
|
like_count: number;
|
|
expand?: {
|
|
tags?: Tag[]
|
|
category?: Category;
|
|
waypoints?: Waypoint[]
|
|
summit_logs_via_trail?: SummitLog[]
|
|
author?: Actor
|
|
comments_via_trail?: Comment[]
|
|
gpx_data?: string
|
|
trail_share_via_trail?: TrailShare[]
|
|
trail_like_via_trail?: TrailLike[]
|
|
|
|
}
|
|
description?: string;
|
|
author: string;
|
|
|
|
constructor(name: string,
|
|
params?: {
|
|
id?: string,
|
|
location?: string,
|
|
date?: string,
|
|
public?: boolean,
|
|
distance?: number,
|
|
elevation_gain?: number,
|
|
elevation_loss?: number,
|
|
duration?: number,
|
|
difficulty?: "easy" | "moderate" | "difficult",
|
|
lat?: number,
|
|
lon?: number,
|
|
thumbnail?: number,
|
|
photos?: string[],
|
|
gpx?: string,
|
|
category?: Category,
|
|
waypoints?: Waypoint[],
|
|
summit_logs?: SummitLog[],
|
|
comments?: Comment[],
|
|
shares?: TrailShare[],
|
|
tags?: string[],
|
|
description?: string
|
|
created?: string
|
|
}
|
|
|
|
) {
|
|
this.id = params?.id;
|
|
this.name = name;
|
|
this.location = params?.location;
|
|
this.date = params?.date ?? new Date().toISOString().split('T')[0];
|
|
this.public = params?.public ?? false
|
|
this.distance = params?.distance ?? 0;
|
|
this.elevation_gain = params?.elevation_gain ?? 0;
|
|
this.elevation_loss = params?.elevation_loss ?? 0;
|
|
this.duration = params?.duration ?? 0;
|
|
this.difficulty = params?.difficulty ?? "easy";
|
|
this.lat = params?.lat;
|
|
this.lon = params?.lon;
|
|
this.thumbnail = params?.thumbnail ?? 0;
|
|
this.photos = params?.photos ?? [];
|
|
this.waypoints = [];
|
|
this.tags = []
|
|
this.gpx = params?.gpx;
|
|
this.like_count = 0
|
|
this.expand = {
|
|
category: params?.category,
|
|
waypoints: params?.waypoints ?? [],
|
|
summit_logs_via_trail: params?.summit_logs ?? [],
|
|
comments_via_trail: params?.comments ?? [],
|
|
trail_share_via_trail: params?.shares ?? []
|
|
}
|
|
this.description = params?.description ?? "";
|
|
this.created = params?.created;
|
|
this.author = "000000000000000"
|
|
}
|
|
}
|
|
|
|
interface TrailFilter {
|
|
q: string,
|
|
category: string[],
|
|
tags: string[],
|
|
difficulty: ("easy" | "moderate" | "difficult")[]
|
|
author?: string;
|
|
public?: boolean;
|
|
shared?: boolean;
|
|
private?: boolean;
|
|
near: {
|
|
lat?: number,
|
|
lon?: number,
|
|
radius: number
|
|
}
|
|
distanceMin: number,
|
|
distanceMax: number,
|
|
distanceLimit: number,
|
|
elevationGainMin: number;
|
|
elevationGainMax: number;
|
|
elevationGainLimit: number;
|
|
elevationLossMin: number;
|
|
elevationLossMax: number;
|
|
elevationLossLimit: number;
|
|
startDate?: string;
|
|
endDate?: string;
|
|
completed?: boolean;
|
|
liked?: boolean;
|
|
sort: "name" | "distance" | "elevation_gain" | "created";
|
|
sortOrder: "+" | "-"
|
|
}
|
|
|
|
interface TrailFilterValues {
|
|
min_distance: number,
|
|
max_distance: number,
|
|
min_elevation_gain: number,
|
|
max_elevation_gain: number,
|
|
min_elevation_loss: number,
|
|
max_elevation_loss: number,
|
|
min_durtation: number,
|
|
max_duration: number,
|
|
}
|
|
|
|
interface TrailBoundingBox {
|
|
max_lat: number,
|
|
min_lat: number,
|
|
max_lon: number,
|
|
min_lon: number,
|
|
}
|
|
|
|
|
|
interface TrailSearchResult {
|
|
id: string;
|
|
author: string;
|
|
author_name: string;
|
|
author_avatar: string;
|
|
name: string;
|
|
description: string;
|
|
location: string;
|
|
distance: number;
|
|
elevation_gain: number;
|
|
elevation_loss: number;
|
|
duration: number;
|
|
difficulty: "easy" | "moderate" | "difficult";
|
|
category: string;
|
|
completed: boolean;
|
|
date: number;
|
|
created: number;
|
|
public: boolean;
|
|
thumbnail: string;
|
|
polyline?: string;
|
|
likes?: string[];
|
|
like_count: number;
|
|
shares?: string[];
|
|
tags?: string[]
|
|
domain?: string;
|
|
iri?: string;
|
|
gpx: string;
|
|
_geo: {
|
|
lat: number,
|
|
lng: number
|
|
};
|
|
}
|
|
|
|
export const defaultTrailSearchAttributes = [
|
|
"id",
|
|
"author",
|
|
"author_name",
|
|
"author_avatar",
|
|
"name",
|
|
"description",
|
|
"location",
|
|
"distance",
|
|
"elevation_gain",
|
|
"elevation_loss",
|
|
"duration",
|
|
"difficulty",
|
|
"category",
|
|
"completed",
|
|
"date",
|
|
"created",
|
|
"public",
|
|
"thumbnail",
|
|
"domain",
|
|
"gpx",
|
|
"tags",
|
|
"like_count",
|
|
"shares",
|
|
"iri",
|
|
"_geo",]
|
|
|
|
|
|
export { Trail };
|
|
|
|
export type { TrailBoundingBox, TrailFilter, TrailFilterValues, TrailSearchResult };
|
|
|