feat: challenge registry-driven platform + XVI/XVII imports + admin toggle + domain rename

- Rename repo/domain: attack-defense-platform / attackdefense.imrnes.team (all refs replaced)
- challenge_registry.json: single source of truth (28 challs across gemastik18/xvi/xvii)
- teams.py: registry-driven CHALLENGES, set_challenge_enabled, sync_challenge_runtime
  (apply enable/disable to live teams: build/up or stop/remove + receiver restart)
- compose_gen.py: render per-team compose from canonical per-challenge templates
  (image reuse, per-team ports 30xxx, flag mounts, passwords)
- gen_canonical_composes.py: canonical docker-compose.yml for all services
- import_new_challenges.py: import XVI/XVII services + EOL base image fixes
  (debian:buster→bookworm, node:14→20, python:3.7-slim→3.11)
- receiver: xvi package (10 checkers) + xvii package (12 generic checkers),
  Challenge base reads PASSWORD_<team_port> from env; gen_receiver_main.py
  generates per-team main.py from registry
- main.py: /api/challenges returns full registry; PATCH /api/challenges/<name>
  toggles enabled + applies to live teams
- index.html: 🏗️ Challenge Manager tab (toggle per challenge, grouped by set)
- SLA bonus now dynamic (all enabled challenges, not hardcoded 6)
This commit is contained in:
MythEclipse
2026-09-25 14:04:33 +08:00
parent c35b23a37f
commit c6fd9ec268
1317 changed files with 306586 additions and 128 deletions
+25
View File
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
+56
View File
@@ -0,0 +1,56 @@
# compiled output
/dist
/node_modules
/build
/redis-data
# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# OS
.DS_Store
# Tests
/coverage
/.nyc_output
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# temp directory
.temp
.tmp
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
+4
View File
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
+26
View File
@@ -0,0 +1,26 @@
FROM node:20-slim-bookworm
ARG PASSWORD
RUN echo root:${PASSWORD} | chpasswd
COPY apt-insecure.conf /etc/apt/apt.conf.d/99gemastik-insecure
RUN apt-get -o Acquire::AllowInsecureRepositories=true update && apt-get install -y openssh-server curl
RUN echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
RUN service ssh start
WORKDIR /ctf/kode-viewer/
COPY package*.json ./
RUN npm install
COPY src/ src/
COPY views/ views/
COPY public/ public/
COPY *.json .
COPY start.sh .
RUN npm run build
RUN chmod +x start.sh
CMD ./start.sh
+3
View File
@@ -0,0 +1,3 @@
Acquire::AllowInsecureRepositories "true";
Acquire::AllowDowngradeToInsecureRepositories "true";
Apt::Get::AllowUnauthenticated "true";
+27
View File
@@ -0,0 +1,27 @@
services:
kode-viewer:
container_name: kode-viewer_container
hostname: kode-viewer
restart: always
build:
context: .
args:
- PASSWORD=$PASSWORD_10000
volumes:
- ../receiver/flags/kode-viewer.txt:/flag.txt:ro
- ../utils/bashrc:/root/.bashrc:ro
- ../utils/preexec.sh:/root/.preexec.sh:ro
ports:
- "10000:3000"
- "10022:22"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
- REDIS_HOST=redis
- REDIS_PORT=6379
depends_on:
- redis
redis:
image: redis:alpine
volumes:
- ./redis-data:/data
+8
View File
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
File diff suppressed because it is too large Load Diff
+79
View File
@@ -0,0 +1,79 @@
{
"name": "kode-viewer",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@types/uuid": "^10.0.0",
"bcrypt": "^5.1.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"cookie-parser": "^1.4.6",
"hbs": "^4.2.0",
"ioredis": "^5.4.1",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1",
"uuid": "^10.0.0"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
"@types/bcrypt": "^5.0.2",
"@types/cookie-parser": "^1.4.7",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.1",
"@types/supertest": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"eslint": "^8.42.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"prettier": "^3.0.0",
"source-map-support": "^0.5.21",
"supertest": "^7.0.0",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+15
View File
@@ -0,0 +1,15 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="h-6 w-6"
>
<polyline points="16 18 22 12 16 6"></polyline>
<polyline points="8 6 2 12 8 18"></polyline>
</svg>

After

Width:  |  Height:  |  Size: 350 B

+11
View File
@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { AuthModule } from './auth/auth.module';
import { KodeModule } from './kode/kode.module';
import { ViewModule } from './view/view.module';
@Module({
imports: [AuthModule, KodeModule, ViewModule],
controllers: [],
providers: [],
})
export class AppModule {}
@@ -0,0 +1,49 @@
import {
Controller,
Render,
Get,
Post,
Body,
Res,
UseGuards,
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthDTO } from './auth.dto';
import { AuthGuard } from './auth.guard';
@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}
@Get('login')
@Render('login')
async loginPage() {}
@Post('login')
async login(@Res({ passthrough: true }) res, @Body() dto: AuthDTO) {
const { sessionId } = await this.authService.login(dto);
if (sessionId) {
res.cookie('session', sessionId, { httpOnly: true });
}
return res.redirect('/kode');
}
@Get('register')
@Render('register')
async registerPage() {}
@Post('register')
async register(@Res() res, @Body() dto: AuthDTO) {
await this.authService.register(dto);
return res.redirect('/auth/login');
}
@Get('logout')
@UseGuards(AuthGuard)
async logout(@Res() res) {
const sessionId = res.req.cookies['session'];
res.clearCookie('session');
await this.authService.logout(sessionId);
return res.redirect('/auth/login');
}
}
@@ -0,0 +1,9 @@
import { IsNotEmpty, IsAlphanumeric } from 'class-validator';
export class AuthDTO {
@IsNotEmpty()
email: string;
@IsNotEmpty()
password: string;
}
@@ -0,0 +1,22 @@
import {
ExceptionFilter,
Catch,
ArgumentsHost,
HttpException,
} from '@nestjs/common';
import { Response } from 'express';
@Catch(HttpException)
export class AuthFilter implements ExceptionFilter {
catch(exception: HttpException, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const res = ctx.getResponse<Response>();
if (exception.getStatus() === 401) {
res.redirect('/auth/login');
return;
}
res.redirect(`/error?message=${exception.message}`);
}
}
@@ -0,0 +1,29 @@
import {
CanActivate,
ExecutionContext,
Injectable,
UnauthorizedException,
ForbiddenException,
} from '@nestjs/common';
import { AuthService } from './auth.service';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private authService: AuthService) {}
async canActivate(context: ExecutionContext): Promise<boolean> {
const request = context.switchToHttp().getRequest();
const session = request.cookies['session'];
if (!session) {
throw new UnauthorizedException();
}
const user = await this.authService.getUser(session);
if (!user) {
throw new UnauthorizedException();
}
request.user = user;
return true;
}
}
@@ -0,0 +1,10 @@
export class User {
email: string;
hashedPassword: string;
isAdmin: boolean;
}
export class Session {
email: string;
isAdmin: boolean;
}
@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
import { KVService } from 'src/kv/kv.service';
@Module({
imports: [],
controllers: [AuthController],
providers: [AuthService, KVService],
})
export class AuthModule {}
@@ -0,0 +1,51 @@
import { Injectable } from '@nestjs/common';
import * as bcrypt from 'bcrypt';
import { v4 as uuidv4 } from 'uuid';
import { KVService } from 'src/kv/kv.service';
import { AuthDTO } from './auth.dto';
import { User } from './auth.model';
@Injectable()
export class AuthService {
constructor(private kv: KVService) {}
async login(payload: AuthDTO) {
const user: User = await this.kv.get(payload.email);
if (!user) {
return { message: 'User not found', sessionId: null };
}
if (!(await bcrypt.compare(payload.password, user.hashedPassword))) {
return { message: 'Invalid password', sessionId: null };
}
delete user.hashedPassword;
const sessionId = uuidv4();
await this.kv.set(sessionId, user, 1800);
return { message: 'Login successful', sessionId };
}
async register(payload: AuthDTO) {
const userExists = await this.kv.get(payload.email);
if (userExists) {
return { message: 'User already exists' };
}
const hashedPassword = await bcrypt.hash(payload.password, 10);
const data = { email: payload.email, hashedPassword, isAdmin: false };
await this.kv.set(payload.email, data, 0);
return { message: 'User registered' };
}
async logout(sessionId: string) {
await this.kv.del(sessionId);
return { message: 'Logged out' };
}
async getUser(sessionId: string) {
return this.kv.get(sessionId);
}
}
@@ -0,0 +1,56 @@
import {
Controller,
Post,
Body,
UseGuards,
Req,
Render,
Get,
Param,
Res,
Query,
} from '@nestjs/common';
import { KodeService } from './kode.service';
import { KodeDTO, SearchKodeDTO } from './kode.dto';
import { AuthGuard } from 'src/auth/auth.guard';
@Controller('kode')
export class KodeController {
constructor(private readonly kodeService: KodeService) {}
@Post()
@UseGuards(AuthGuard)
async create(@Req() req, @Res() res, @Body() dto: KodeDTO) {
await this.kodeService.create(req.user.email, dto);
res.redirect('/kode');
}
@Get()
@UseGuards(AuthGuard)
async list(@Req() req, @Res() res, @Query() query) {
const kodes = query.pattern
? await this.kodeService.find(query.pattern)
: await this.kodeService.list(req.user);
return res.render('search', { kodes });
}
@Get('create')
@UseGuards(AuthGuard)
@Render('create')
async createPage() {}
@Post('find')
@UseGuards(AuthGuard)
async find(@Res() res, @Body() dto: SearchKodeDTO) {
return res.redirect(`/kode?pattern=${dto.pattern}`);
}
@Get(':id')
@UseGuards(AuthGuard)
async get(@Res() res, @Param() params) {
const kode = await this.kodeService.show(params.id);
return kode
? res.render('kode', { kode })
: res.redirect(`/error?message=Kode Not Found`);
}
}
+21
View File
@@ -0,0 +1,21 @@
import { IsNotEmpty, MaxLength } from 'class-validator';
export class KodeDTO {
@IsNotEmpty()
@MaxLength(128)
name: string;
@IsNotEmpty()
@MaxLength(4096)
kode: string;
kind?: string;
@IsNotEmpty()
lang: string;
}
export class SearchKodeDTO {
@IsNotEmpty()
pattern: string;
}
@@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';
import { KodeController } from './kode.controller';
import { KodeService } from './kode.service';
import { KVService } from 'src/kv/kv.service';
import { AuthService } from 'src/auth/auth.service';
@Module({
imports: [],
controllers: [KodeController],
providers: [AuthService, KodeService, KVService],
})
export class KodeModule {}
@@ -0,0 +1,39 @@
import { Injectable } from '@nestjs/common';
import { Session } from 'src/auth/auth.model';
import { KVService } from 'src/kv/kv.service';
import { KodeDTO } from './kode.dto';
@Injectable()
export class KodeService {
constructor(private kv: KVService) {}
async create(email: string, payload: KodeDTO) {
payload.kind = payload.kind ? 'private' : 'public';
const key = `kode-${email}-${payload.name}-${payload.lang}-${payload.kind}`;
return this.kv.set(key, { email, ...payload }, 1200);
}
async list(user: Session) {
const kodes = user.isAdmin
? await this.kv.find('kode-*')
: await this.kv.find(`kode-${user.email}-*`);
return this.parse(kodes);
}
async show(key) {
return this.kv.get(key);
}
async find(pattern: string) {
const kodes = await this.kv.find(`*${pattern}*-public`);
return this.parse(kodes);
}
parse(keys: string[]) {
return keys.map((key) => {
const [_, email, name, lang, kind] = key.split('-');
return { id: key, email, name, lang, kind };
});
}
}
+35
View File
@@ -0,0 +1,35 @@
import { Injectable } from '@nestjs/common';
import { Redis } from 'ioredis';
@Injectable()
export class KVService {
private readonly redisClient: Redis;
constructor() {
this.redisClient = new Redis(
`redis://${process.env.REDIS_HOST}:${process.env.REDIS_PORT}`,
);
}
async find(pattern: string): Promise<string[]> {
return this.redisClient.keys(pattern);
}
async get(key: string): Promise<any> {
return JSON.parse(await this.redisClient.get(key));
}
async set(key: string, value: any, ttl: number = 0): Promise<void> {
value = JSON.stringify(value);
await this.redisClient.set(key, value);
if (ttl) {
await this.redisClient.expire(key, ttl);
}
}
async del(key: string): Promise<void> {
await this.redisClient.del(key);
}
}
+25
View File
@@ -0,0 +1,25 @@
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path';
import * as cookieParser from 'cookie-parser';
import * as hbs from 'hbs';
import { AppModule } from './app.module';
import { AuthFilter } from './auth/auth.filter';
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.useStaticAssets(join(__dirname, '..', 'public'));
app.setBaseViewsDir(join(__dirname, '..', 'views'));
hbs.registerPartials(join(__dirname, '..', 'views/partials'));
app.setViewEngine('hbs');
app.useGlobalPipes(new ValidationPipe());
app.useGlobalFilters(new AuthFilter());
app.use(cookieParser());
await app.listen(3000);
}
bootstrap();
@@ -0,0 +1,16 @@
import { Controller, Get, Render, Query, Res } from '@nestjs/common';
@Controller()
export class ViewController {
constructor() {}
@Get()
@Render('index')
async indexPage() {}
@Get('error')
async errorPage(@Res() res, @Query('message') message: string) {
return res.render('error', { message });
}
}
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ViewController } from './view.controller';
@Module({
imports: [],
controllers: [ViewController],
providers: [],
})
export class ViewModule {}
+5
View File
@@ -0,0 +1,5 @@
# run sshd
/usr/sbin/sshd -D &
# run the command
node dist/main.js
+4
View File
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}
+21
View File
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false
}
}
File diff suppressed because one or more lines are too long
+27
View File
@@ -0,0 +1,27 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<div class="flex flex-col min-h-screen">
{{> header}}
<main class="flex-1 flex flex-col items-center justify-center text-center">
<div class="w-full max-w-md space-y-8">
<div>
<h2 class="mt-6 text-center text-3xl font-bold tracking-tight text-foreground">Oops</h2>
</div>
<div>
<p class="text-center text-foreground">{{ message }}</p>
</div>
<div>
<a href="/kode" class="rounded-md text-sm w-full bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 border border-blue-700 rounded">
Go back
</a>
</div>
</div>
</main>
</div>
</html>
+25
View File
@@ -0,0 +1,25 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<div class="flex flex-col min-h-screen">
{{> header}}
<main class="flex-1 flex flex-col items-center justify-center space-y-4 text-center">
<div class="space-y-2">
<h1 class="text-3xl font-bold tracking-tighter sm:text-5xl xl:text-6xl/none">kode-viewer</h1>
<p class="max-w-[600px] text-muted-foreground text-gray-500 md:text-xl">
Elevate your kode-share experience with kode-viewer.
</p>
</div>
<a class="flex justify-center" href="/auth/login">
<button class="rounded-md text-sm font-medium bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 border border-blue-700 rounded">
Get Started
</button>
</a>
</main>
</div>
</html>
+56
View File
@@ -0,0 +1,56 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.3/styles/xcode.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/{{ kode.lang }}.min.js"></script>
<script>hljs.highlightAll();</script>
</head>
<div class="flex flex-col h-full w-full">
<div class="bg-background border-b flex px-4 sm:px-6 h-14">
<div class="flex flex-row justify-between items-center w-full">
<a class="flex items-center" href="#">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-6 w-6">
<polyline points="16 18 22 12 16 6"></polyline>
<polyline points="8 6 2 12 8 18"></polyline>
</svg>
<span class="sr-only">kode-viewer</span>
</a>
<div class="flex">
<div>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="h-5 w-5"
>
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
<polyline points="16 17 21 12 16 7" />
<line x1="21" x2="9" y1="12" y2="12" />
</svg>
</div>
</div>
</div>
</div>
<main class="flex justify-center items-center h-full w-full my-5">
<div class="rounded-lg border bg-card text-card-foreground shadow-sm w-3/4 h-3/4" data-v0-t="card">
<div class="flex flex-col space-y-1.5 p-6">
<h3 class="whitespace-nowrap text-2xl font-semibold leading-none tracking-tight">{{ kode.name }}</h3>
<p class="text-sm text-muted-foreground">by {{ kode.email }}</p>
</div>
<pre><code class="language-{{ kode.lang }}">{{ kode.kode }}</code></pre>
</div>
</main>
</div>
</html>
+59
View File
@@ -0,0 +1,59 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<div class="flex flex-col min-h-screen">
{{> header}}
<main class="flex-1 flex flex-col items-center justify-center text-center">
<div class="w-full max-w-md space-y-8">
<div>
<h2 class="mt-6 text-center text-3xl font-bold tracking-tight text-foreground">Sign in to Kode Viewer</h2>
</div>
<form class="space-y-4" action="/auth/login" method="POST">
<div>
<input
class="h-10 bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 relative block w-full appearance-none rounded-md border border-muted px-3 py-2 text-foreground placeholder-muted-foreground focus:z-10 focus:border-primary focus:outline-none focus:ring-primary sm:text-sm"
type="email"
id="email"
autocomplete="email"
placeholder="Email"
name="email"
required
/>
</div>
<div>
<label
class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 sr-only"
for="password"
>
Password
</label>
<input
class="h-10 bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 relative block w-full appearance-none rounded-md border border-muted px-3 py-2 text-foreground placeholder-muted-foreground focus:z-10 focus:border-primary focus:outline-none focus:ring-primary sm:text-sm"
type="password"
id="password"
autocomplete="current-password"
required
placeholder="Password"
name="password"
/>
</div>
<div>
<button type="submit" class="rounded-md text-sm w-full bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 border border-blue-700 rounded">
Sign in
</button>
</div>
<div class="text-center">
<a class="text-sm font-medium text-muted-foreground text-gray-500 hover:text-gray-900" href="/auth/register">
Don't have an account? Register
</a>
</div>
</form>
</div>
</main>
</div>
</html>
@@ -0,0 +1,20 @@
<div class="px-4 lg:px-6 h-14 flex items-center">
<div class="flex items-center justify-center" href="#">
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="h-6 w-6"
>
<polyline points="16 18 22 12 16 6"></polyline>
<polyline points="8 6 2 12 8 18"></polyline>
</svg>
<span class="sr-only">kode-viewer</span>
</div>
</div>
@@ -0,0 +1,31 @@
<div class="bg-background border-b flex px-4 sm:px-6 h-14">
<div class="flex flex-row justify-between items-center w-full">
<a class="flex items-center" href="/kode">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-6 w-6">
<polyline points="16 18 22 12 16 6"></polyline>
<polyline points="8 6 2 12 8 18"></polyline>
</svg>
<span class="sr-only">kode-viewer</span>
</a>
<div class="flex">
<a href="/auth/logout">
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="h-5 w-5"
>
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
<polyline points="16 17 21 12 16 7" />
<line x1="21" x2="9" y1="12" y2="12" />
</svg>
</a>
</div>
</div>
</div>
File diff suppressed because one or more lines are too long
+52
View File
@@ -0,0 +1,52 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kode-viewer</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<div class="flex flex-col h-full w-full">
{{> navbar}}
<main class="flex flex-col items-center h-full w-full my-5 gap-4">
<form class="flex h-10 w-1/2" action="/kode/find" method="POST">
<div class="flex flex-row justify-center items-center h h-full w-full gap-4">
<input
class="flex w-5/6 bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 w-full rounded-lg px-4 py-2 border border-neutral-400 focus:border-primary focus:ring-primary"
placeholder="Search items..."
type="search"
id="pattern"
name="pattern"
required
/>
<button type="submit" class="h-10 rounded-md text-md w-1/6 bg-blue-500 hover:bg-blue-700 text-white font-bold border border-blue-700 rounded">
Search
</button>
</div>
</form>
<div class="w-full gap-4">
<a class="w-full flex justify-center items-center" href="/kode/create">
<button class="h-10 rounded-md text-md w-1/2 bg-blue-500 hover:bg-blue-700 text-white font-bold border border-blue-700 rounded">
Create
</button>
</a>
</div>
{{#if kodes}}
{{#each kodes}}
<a href="/kode/{{ this.id }}" class="block flex flex-col p-6 w-1/2 bg-white border border-gray-200 rounded-lg shadow hover:bg-gray-100 gap-2 justify-center items-center">
<h5 class="mb-2 text-2xl font-bold tracking-tight">{{ this.name }}</h5>
<div class="gap-1">
<span class="bg-blue-500 text-white text-md font-medium me-2 px-2.5 py-1 rounded-full">{{ this.kind }}</span>
<span class="bg-gray-900 text-white text-md font-medium me-2 px-2.5 py-1 rounded-full">{{ this.email }}</span>
<span class="bg-blue-500 text-white text-md font-medium me-2 px-2.5 py-1 rounded-full">{{ this.lang }}</span>
</div>
</a>
{{/each}}
{{else}}
<div class="flex flex-col items-center justify-center gap-4">
<h1 class="text-muted-foreground text-gray-500 md:text-xl">No kodes found</h1>
</div>
{{/if}}
</main>
</div>
</html>