Skip to content

Commit

Permalink
GH-2254 Landing page based on stub data
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Nov 2, 2024
1 parent a331f41 commit 895af30
Show file tree
Hide file tree
Showing 24 changed files with 264 additions and 36 deletions.
File renamed without changes.
69 changes: 62 additions & 7 deletions reposilite-backend/src/main/kotlin/com/reposilite/ui/UiPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,83 @@ import com.reposilite.web.api.HttpServerConfigurationEvent
import io.javalin.http.Context
import io.javalin.router.JavalinDefaultRouting

@Plugin(name = "ui")
@Plugin(name = "reposilite-test/workspace/ui")
internal class UiPlugin : ReposilitePlugin() {

override fun initialize(): Facade? {
event { event: HttpServerConfigurationEvent ->
event.config.registerPlugin(
JtexPlugin {
it.mode = JtexConfig.Mode.RESOURCE
it.mode = JtexConfig.Mode.DIRECTORY
it.path = "ui"
}
)

val view =
IndexView(
title = "Reposilite Repository",
description = "Official public Maven repository powered by Reposilite",
logo = "logo.png",
website = "https://reposilite.com",
repositories = listOf(
IndexView.Repository("assets", "Generic"),
IndexView.Repository("releases", "Maven"),
IndexView.Repository("snapshots", "Maven"),
IndexView.Repository("packages", "NPM"),
IndexView.Repository("registry", "Docker"),
),
highlightedProjects = listOf(
IndexView.Project(
name = "Reposilite",
description = "Reposilite is a lightweight repository management software dedicated to simplicity and speed.",
routes = listOf(
IndexView.Route(IndexView.Repository("releases", "Maven"), "/com/reposilite/reposilite-backend"),
IndexView.Route(IndexView.Repository("snapshots", "Maven"), "/com/reposilite/reposilite-backend"),
IndexView.Route(IndexView.Repository("registry", "Docker"), "/dzikoysk/reposilite")
)
),
IndexView.Project(
name = "Javalin",
description = "A simple web framework for Java and Kotlin.",
routes = listOf(
IndexView.Route(IndexView.Repository("releases", "Maven"), "/io/javalin/javalin"),
IndexView.Route(IndexView.Repository("snapshots", "Maven"), "/io/javalin/javalin"),
)
),
IndexView.Project(
name = "Khangul",
description = "Hangul processor for Kotlin Multiplatform & JavaScript projects, based on reverse-engineered enhanced version of Branah keyboard algorithm \uD83C\uDDF0\uD83C\uDDF7",
routes = listOf(
IndexView.Route(IndexView.Repository("packages", "NPM"), "@dzikoysk/khangul")
)
)
)
)

event.config.router.mount { routing: JavalinDefaultRouting ->
routing
.get("/") {
it.render(
"index.jte",
mapOf("view" to IndexView(
title = "Reposilite",
description = "Reposilite is a lightweight repository management software dedicated to simplicity and speed.",
logo = "https://avatars.githubusercontent.com/u/88636591",
website = "https://reposilite.com"
mapOf("view" to view)
)
}
.get("/releases") {
it.render(
"index.jte",
mapOf("view" to view.copy(
browsedRepository = IndexView.BrowsedRepository(
name = "releases",
files = listOf(
IndexView.BrowsedRepository.Directory("assets"),
IndexView.BrowsedRepository.Directory("com"),
IndexView.BrowsedRepository.Directory("io"),
IndexView.BrowsedRepository.Directory("org"),
IndexView.BrowsedRepository.File("index.html", "1.2 KB"),
IndexView.BrowsedRepository.File("index.js", "2.3 KB"),
IndexView.BrowsedRepository.File("index.css", "0.5 KB"),
)
)
))
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
package com.reposilite.ui.views

class IndexView(
data class IndexView(
val title: String,
val description: String,
val logo: String,
val website: String,
)
val highlightedProjects: List<Project>,
val repositories: List<Repository>,
val browsedRepository: BrowsedRepository? = null,
) {
data class Project(
val name: String,
val description: String,
val routes: List<Route>
) {
fun getSupportedPackages(): Set<String> = routes.map { it.repository.type }.toSet()
}
data class Route(
val repository: Repository,
val path: String,
)
data class Repository(
val name: String,
val type: String
)
data class BrowsedRepository(
val name: String,
val files: List<Entry>
) {
interface Entry

data class File(
val name: String,
val size: String,
) : Entry

data class Directory(
val name: String,
) : Entry
}
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.reposilite.web.infrastructure.ApiCacheBypassHandler
import com.reposilite.web.infrastructure.EndpointAccessLoggingHandler
import com.reposilite.web.infrastructure.createReposiliteDsl
import io.javalin.config.JavalinConfig
import io.javalin.http.staticfiles.Location
import io.javalin.json.JavalinJackson
import io.javalin.openapi.plugin.OpenApiPlugin
import kotlin.time.Duration.Companion.minutes
Expand Down Expand Up @@ -67,6 +68,12 @@ internal object JavalinConfiguration {
configureOpenApi(config, "Title", "Description")
configureDebug(reposilite, localConfiguration, config)
configureRoutingPlugin(config, reposilite)

config.staticFiles.add {
it.location = Location.EXTERNAL
it.directory = "./static"
it.hostedPath = "/"
}
}

private fun configureJavalin(config: JavalinConfig, localConfiguration: LocalConfiguration, webSettings: Reference<WebSettings>) {
Expand Down
1 change: 1 addition & 0 deletions reposilite-backend/src/main/resources/ui
18 changes: 0 additions & 18 deletions reposilite-backend/src/main/resources/ui/index.jte

This file was deleted.

Binary file added reposilite-test/workspace/static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
@param String title

<header class="border-b-1 border-gray-50 h-16 flex items-center w-full">
<div class="mx-auto container-xl flex justify-between w-full">
<nav>
${title}
<header class="border-b-1 border-gray-50 flex items-center w-full py-10">
<div class="mx-auto container flex justify-between w-full">
<nav class="font-medium text-xl">
<a href="/">${title}</a>
</nav>
<nav>
<button id="theme-switcher" class="flex bg-gray-900 rounded px-4 py-1">
Switch
<button id="theme-switcher" class="flex bg-white dark:bg-zinc-800 rounded-full px-2 py-2">
<span class="sun-icon color-white">
@template.lib.icons.SunIcon()
</span>
Expand Down
119 changes: 119 additions & 0 deletions reposilite-test/workspace/ui/index.jte
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
@import com.reposilite.ui.views.IndexView
@import com.reposilite.ui.views.IndexView.Project

@param com.reposilite.ui.views.IndexView view

<!DOCTYPE html>
<html lang="en">
@template.component.Head(title = "Reposilite")

<body class="min-h-full text-black dark:text-white min-w-full bg-zinc-100 dark:bg-zinc-900">
@template.component.Header(title = view.getTitle())

<main class="container mx-auto">
<div class="flex">
<div class="w-32">
<img alt="Logo" src="${view.getLogo()}" class="rounded-full border-2 border-zinc-200 dark:border-zinc-500" />
</div>
<div class="flex flex-col pl-6 justify-center">
<h1>${view.getDescription()}</h1>
<p class="flex pt-3">
@template.lib.icons.GlobeIcon()
<a href="${view.getWebsite()}" class="text-zinc-500 px-2">
${view.getWebsite()}
</a>
</p>
</div>
</div>
<div class="flex justify-between flex-wrap w-full pt-12 gap-2">
@for(Project project : view.getHighlightedProjects())
<div class="flex flex-1 flex-col justify-between border rounded-md border-white shadow-sm dark:border-zinc-700 min-w-1/3 max-w-1/3 px-4 pt-3 pb-4 bg-white dark:bg-zinc-800">
<div class="flex-col">
<h2 class="font-bold">${project.getName()}</h2>
<p class="text-wrap break-normal text-sm pt-1">${project.getDescription()}</p>
</div>
<div class="flex pt-3 gap-2">
@for(String packageName : project.getSupportedPackages())
<p class="text-sm">
@if(packageName.equals("Generic"))
<span class="px-3 py-0.5 bg-zinc-500 text-black rounded-full">Generic</span>
@elseif(packageName.equals("Maven"))
<span class="px-3 py-0.5 bg-orange-500 text-black rounded-full">Maven</span>
@elseif(packageName.equals("Docker"))
<span class="px-3 py-0.5 bg-blue-500 text-black rounded-full">Docker</span>
@elseif(packageName.equals("NPM"))
<span class="px-3 py-0.5 bg-yellow-500 text-black rounded-full">NPM</span>
@endif
</p>
@endfor
</div>
</div>
@endfor
</div>
<div class="py-12">
<hr class="border-zinc-200 dark:border-zinc-700" />
</div>
<div class="flex">
<div class="flex flex-col gap-2">
@for(IndexView.Repository repository : view.getRepositories())
<div class="flex flex-1 bg-white dark:bg-zinc-800 rounded-md items-center min-w-44">
<div class="
@if(repository.getType().equals("Generic"))
bg-zinc-500
@elseif(repository.getType().equals("Maven"))
bg-orange-500
@elseif(repository.getType().equals("Docker"))
bg-blue-500
@elseif(repository.getType().equals("NPM"))
bg-yellow-500
@endif
w-1 h-full">
</div>
<a href="/${repository.getName()}" class="h-full w-full">
<div class="flex justify-between h-full w-full">
<p class="px-5 py-3 text-sm font-bold">${repository.getName().toUpperCase()}</p>
<div class="w-2 h-full
@if(view.getBrowsedRepository() != null && repository.getName().equals(view.getBrowsedRepository().getName()))
bg-white dark:bg-zinc-800
@else
bg-zinc-100 dark:bg-zinc-900
@endif
"></div>
</div>
</a>
</div>
@endfor
</div>
<div class="flex flex-col w-full">
@if (view.getBrowsedRepository() == null)
<input class="w-full bg-white dark:bg-zinc-800 rounded-sm py-2.5 px-3" placeholder="🔍 Search" />
@else
<div class="bg-white dark:bg-zinc-800 w-fit px-4 py-2 rounded-md min-w-44">
@for(IndexView.BrowsedRepository.Entry entry : view.getBrowsedRepository().getFiles())
@if (entry instanceof IndexView.BrowsedRepository.Directory directory)
<div class="py-1 flex items-center gap-3">
<div class="bg-yellow-300 w-2 h-2 mt-0.5 rounded-full"></div>
<p>${directory.getName()}</p>
</div>
@elseif (entry instanceof IndexView.BrowsedRepository.File file)
<div class="py-1 flex items-center gap-3">
<div class="bg-white w-2 h-2 mt-0.5 rounded-full"></div>
<p>${file.getName()}</p>
</div>
@endif
@endfor
</div>
@endif
</div>
</div>

<%-- <button hx-post="/clicked" hx-swap="innerHTML">--%>
<%-- Click me--%>
<%-- </button>--%>

<%-- @template.component.Foo()--%>
</main>

@template.component.Footer()
</body>
</html>
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">

<style>
* {
font-family: 'Inter', sans-serif;
}
/** {*/
/* font-family: 'Inter', sans-serif;*/
/*}*/
</style>
16 changes: 16 additions & 0 deletions reposilite-test/workspace/ui/lib/fonts/OpenSans.jte
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<style>
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap');
* {
font-family: 'Open Sans', sans-serif;
}
.open-sans-500 {
font-family: "Open Sans", sans-serif;
font-optical-sizing: auto;
font-weight: 500;
font-style: normal;
font-variation-settings:
"wdth" 100;
}
</style>
15 changes: 15 additions & 0 deletions reposilite-test/workspace/ui/lib/icons/GlobeIcon.jte
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Source: https://heroicons.dev/ -->
<svg
class="w-6 h-6"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>

0 comments on commit 895af30

Please sign in to comment.