~jan0sch/smederee
Showing details for patch 1b04b10ea7f70c4d5479fe40116fb9a6ab5195cf.
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 23:01:15.163637798 +0000 +++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/VcsRepositoryRoutes.scala 2025-02-02 23:01:15.163637798 +0000 @@ -244,7 +244,55 @@ } yield resp } + private val showRepositoryHistory: AuthedRoutes[Account, F] = AuthedRoutes.of { + case ar @ GET -> Root / UsernamePathParameter(repositoryOwner) / VcsRepositoryNamePathParameter( + repositoryName + ) / "history" as user => + for { + csrf <- Sync[F].delay(ar.req.getCsrfToken) + directory <- Sync[F].delay( + os.Path( + Paths.get( + config.repositoriesDirectory.toPath.toString, + repositoryOwner.toString + ) + ) + ) + _ <- Sync[F].delay(log.info(s"DARCS LOG: $directory/$repositoryName")) + history <- darcs.log(directory.toNIO)(repositoryName.toString)(Chain.empty) + actionBaseUri <- Sync[F].delay( + Uri(path = + Uri.Path.Root |+| Uri.Path( + Vector( + Uri.Path.Segment(s"~$repositoryOwner"), + Uri.Path.Segment(repositoryName.toString) + ) + ) + ) + ) + goBackUri <- Sync[F].delay( + Uri(path = + Uri.Path.Root |+| Uri.Path( + Vector( + Uri.Path.Segment(s"~$repositoryOwner"), + Uri.Path.Segment(repositoryName.toString) + ) + ) + ) + ) + resp <- Ok.apply( + views.html.showRepositoryHistory()( + actionBaseUri, + csrf, + Option(goBackUri), + s"Smederee - History of ~$repositoryOwner/$repositoryName".some, + user + )(history.stdout.toList.mkString("\n"), repositoryName) + ) + } yield resp + } + val protectedRoutes = - showRepositories <+> parseCreateRepositoryForm <+> showCreateRepositoryForm <+> showRepositoryFiles <+> showRepository + showRepositories <+> parseCreateRepositoryForm <+> showCreateRepositoryForm <+> showRepositoryHistory <+> showRepositoryFiles <+> showRepository } diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryHistory.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryHistory.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryHistory.scala.html 1970-01-01 00:00:00.000000000 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryHistory.scala.html 2025-02-02 23:01:15.163637798 +0000 @@ -0,0 +1,12 @@ +@(lang: LanguageCode = LanguageCode("en"), pathPrefix: Option[Uri] = None)(actionBaseUri: Uri, csrf: Option[CsrfToken] = None, goBackUri: Option[Uri] = None, title: Option[String] = None, user: Account)(history: String, repositoryName: VcsRepositoryName) +@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"> + <pre><code>@history</code></pre> + </div> + </div> + </div> +} +}