~jan0sch/smederee
Showing details for patch 98b6f691e96bcd1aa31b674bc8a3a184b343ed5a.
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala --- old-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala 2025-02-02 22:44:29.341764619 +0000 +++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala 2025-02-02 22:44:29.341764619 +0000 @@ -110,6 +110,41 @@ } yield resp } + private val showRepositories: AuthedRoutes[Account, F] = AuthedRoutes.of { + case ar @ GET -> Root / UsernamePathParameter(repositoriesOwner) as user => + for { + csrf <- Sync[F].delay(ar.req.getCsrfToken) + directory <- Sync[F].delay( + os.Path( + Paths.get( + config.repositoriesDirectory.toPath.toString, + repositoriesOwner.toString + ) + ) + ) + listing <- Sync[F].delay( + os.walk + .attrs(directory, skip = (path, _) => !os.isDir(path), maxDepth = 1) + .map((path, attrs) => (path.relativeTo(directory), attrs)) + ) + actionBaseUri <- Sync[F].delay( + Uri(path = + Uri.Path.Root |+| Uri.Path( + Vector(Uri.Path.Segment(s"~$repositoriesOwner")) + ) + ) + ) + resp <- Ok.apply( + views.html.showRepositories()( + actionBaseUri, + csrf, + s"Smederee/~$repositoriesOwner".some, + user + )(listing, repositoriesOwner) + ) + } yield resp + } + private val showRepository: AuthedRoutes[Account, F] = AuthedRoutes.of { case ar @ GET -> Root / UsernamePathParameter(repositoryOwner) / VcsRepositoryNamePathParameter( repositoryName @@ -210,6 +245,6 @@ } val protectedRoutes = - parseCreateRepositoryForm <+> showCreateRepositoryForm <+> showRepositoryFiles <+> showRepository + showRepositories <+> parseCreateRepositoryForm <+> showCreateRepositoryForm <+> showRepositoryFiles <+> showRepository } diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/navbar.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/navbar.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/navbar.scala.html 2025-02-02 22:44:29.341764619 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/navbar.scala.html 2025-02-02 22:44:29.341764619 +0000 @@ -5,6 +5,9 @@ <ul class="pure-menu-list"> @if(user.nonEmpty) { + @for(account <- user) { + <li class="pure-menu-item"><a class="pure-menu-link" href="@pathPrefix/~@account.name">Your repositories</a></li> + } <li class="pure-menu-item"><a class="pure-menu-link" href="@pathPrefix/repo/create">+ @Messages("global.navbar.top.repository.new")</a></li> <li class="pure-menu-item"> <form action="@pathPrefix/logout" method="POST" accept-charset="UTF-8" class="pure-form"> diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositories.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositories.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositories.scala.html 1970-01-01 00:00:00.000000000 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositories.scala.html 2025-02-02 22:44:29.341764619 +0000 @@ -0,0 +1,31 @@ +@(lang: LanguageCode = LanguageCode("en"), pathPrefix: Option[Uri] = None)(actionBaseUri: Uri, csrf: Option[CsrfToken] = None, title: Option[String] = None, user: Account)(listing: IndexedSeq[(os.RelPath, os.StatInfo)], repositoriesOwner: Username) +@main(lang, pathPrefix)()(csrf, title, user.some) { +@defining(lang.toLocale) { implicit locale => + <div class="content"> + <div class="pure-g"> + <div class="l-box pure-u-1-1 pure-u-md-1-1"> + <table class="pure-table pure-table-horizontal"> + <thead> + <tr> + <th></th> + <th>Name</th> + <th>Size</th> + <th>Modified</th> + </tr> + </thead> + <tbody> + @for(entry <- listing) { + <tr> + <td><i class="fa-solid fa-folder"></i></td> + <td><a href="@createFullPath(pathPrefix)(actionBaseUri.addSegment(entry._1.last))">@{entry._1}</a></td> + <td>@{entry._2.size}</td> + <td>@{entry._2.mtime}</td> + </tr> + } + </tbody> + </table> + </div> + </div> + </div> +} +}