diff --git a/cs b/cs new file mode 100755 index 000000000..474669679 Binary files /dev/null and b/cs differ diff --git a/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala b/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala index c3d3f8aaf..aca22b3f9 100644 --- a/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala +++ b/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala @@ -63,7 +63,7 @@ class ProjectPages(env: Env, database: SchedulerDatabase, searchEngine: SearchEn val sortedArtifactsByVersion = SortedMap.from(artifactsByVersion)( Ordering.Tuple2(Ordering[Instant].reverse, Ordering[SemanticVersion].reverse) ) - val page = html.artifacts( + val page = html.versions( env, user, project, @@ -113,6 +113,57 @@ class ProjectPages(env: Env, database: SchedulerDatabase, searchEngine: SearchEn } } }, + get { + path(projectM / "artifacts") { ref => + artifactsParams { params => + getProjectOrRedirect(ref, user) { project => + val headerF = projectService.getProjectHeader(project) + for { + header <- headerF + } yield { + val allArtifacts = header.toSeq.flatMap(_.artifacts) + + val binaryVersions = allArtifacts + .map(_.binaryVersion) + .distinct + .sorted(BinaryVersion.ordering.reverse) + + // Group by artifact name + val artifactsByName = allArtifacts.groupBy(_.artifactName) + + val groupedArtifacts = artifactsByName + .groupBy { + case (_, artifacts) => + artifacts.maxBy(_.version).version + } + .map { + case (latestVersion, artifactsByName) => + latestVersion -> artifactsByName + .map { + case (name, artifacts) => + name -> artifacts + .filter(_.version == latestVersion) + } + .filter { + case (_, artifacts) => + params.binaryVersions.forall(binaryVersion => + artifacts + .exists(_.binaryVersion == binaryVersion) + ) + } + } + .filter { + case (_, artifactsByName) => + artifactsByName.nonEmpty + } + + val page = html.artifacts(env, user, project, header, groupedArtifacts, params, binaryVersions) + complete(page) + } + } + } + } + }, get { path(projectM / "version-matrix") { ref => getProjectOrRedirect(ref, user) { project => diff --git a/modules/template/src/main/scala/scaladex/view/html/package.scala b/modules/template/src/main/scala/scaladex/view/html/package.scala index 6c073cf16..a43251566 100644 --- a/modules/template/src/main/scala/scaladex/view/html/package.scala +++ b/modules/template/src/main/scala/scaladex/view/html/package.scala @@ -91,6 +91,15 @@ package object html { Uri(s"/$ref/artifacts/$artifactName") .appendQuery("binary-versions", binaryVersion.map(_.label)) + def artifactsUri(ref: Project.Reference, params: ArtifactsPageParams): Uri = + Uri(s"/$ref/artifacts") + .appendQuery("binary-versions", params.binaryVersions.map(_.label)) + .appendQuery(("pre-releases", params.preReleases.toString)) + + def artifactsUri(ref: Project.Reference, binaryVersion: Option[BinaryVersion]): Uri = + Uri(s"/$ref/artifacts") + .appendQuery("binary-versions", binaryVersion.map(_.label)) + // https://www.reddit.com/r/scala/comments/4n73zz/scala_puzzle_gooooooogle_pagination/d41jor5 def paginationRender(selected: Int, max: Int, toShow: Int = 10): (Option[Int], List[Int], Option[Int]) = { val min = 1 diff --git a/modules/template/src/main/twirl/scaladex/view/project/artifacts.scala.html b/modules/template/src/main/twirl/scaladex/view/project/artifacts.scala.html index 09146b2c8..c2dcd7d29 100644 --- a/modules/template/src/main/twirl/scaladex/view/project/artifacts.scala.html +++ b/modules/template/src/main/twirl/scaladex/view/project/artifacts.scala.html @@ -10,117 +10,87 @@ @import scaladex.view.Formats @import java.time.Instant + @( env: Env, user: Option[UserState], project: Project, - header: ProjectHeader, - artifactName: Artifact.Name, - allBinaryVersions: Seq[BinaryVersion], - artifactByVersions: SortedMap[(Instant, SemanticVersion), Seq[Artifact]], - params: ArtifactsPageParams + header: Option[ProjectHeader], + groupedArtifacts: Map[SemanticVersion, Map[Artifact.Name, Seq[Artifact]]], + params: ArtifactsPageParams, + allBinaryVersions: Seq[BinaryVersion] ) @main(env, title = project.repository.toString, user) {
- @headproject(env, user, project, Some(header), "Artifacts") + @headproject(env, user, project, header, "Artifacts")
+ @artifactsfilters(params,allBinaryVersions) @filters()
- @artifactByVersions.size - @Formats.wordPlural(artifactByVersions.size, "version") found for - @artifactName + @groupedArtifacts.values.flatten.size @Formats.wordPlural(groupedArtifacts.values.flatten.size, "artifact") found
- @if(artifactByVersions.isEmpty) { -
We can't find any release that matches all you criteria
+ @if(groupedArtifacts.isEmpty) { +
We can't find any artifacts for this project.
} else { -
- @artifactByVersions.map { case ((releaseDate, version), artifacts) => -
-
-
- @version -
-
- -
- @for( - (platform, binaryVersions) <- artifacts - .map(_.binaryVersion) - .distinct - .sorted - .reverse - .groupBy(_.platform) - .toSeq - ) { -
@platform:
- @for(binaryVersion <- binaryVersions) { - - @binaryVersion.language.label - - } -
- } -
-
-
+
+ @for((version, artifactsByName) <- groupedArtifacts.toSeq.sortBy(_._1).reverse) { +

Version @version

+ @for((artifactName, artifacts) <- artifactsByName.toSeq.sortBy(_._1)) { +
+
+ +
+ +
+ @for( + (platform, binaryVersions) <- artifacts + .groupBy(_.platform) + .toSeq + .sortBy(_._1) + .reverse + ) { +
@platform:
+ @for(binaryVersion <- binaryVersions.map(_.binaryVersion).distinct.sorted.reverse) { + + @binaryVersion.language.label + + } +
+ } +
+
+
+
+ } + }
- } } -
} - @filters() = { -
- - - - -
-
-} \ No newline at end of file +} diff --git a/modules/template/src/main/twirl/scaladex/view/project/artifactsfilters.scala.html b/modules/template/src/main/twirl/scaladex/view/project/artifactsfilters.scala.html new file mode 100644 index 000000000..c2cf0f06f --- /dev/null +++ b/modules/template/src/main/twirl/scaladex/view/project/artifactsfilters.scala.html @@ -0,0 +1,32 @@ +@import scaladex.core.model._ +@import scaladex.view.html.main +@import scaladex.view.html._ +@import scaladex.core.web.ArtifactsPageParams +@import scaladex.core.model.Language +@import scaladex.core.model.Platform +@import scala.collection.SortedMap +@import scaladex.core.util.ScalaExtensions._ +@import scaladex.core.util.TimeUtils +@import scaladex.view.Formats + +@(params: ArtifactsPageParams, allBinaryVersions: Seq[BinaryVersion]) + +
+ + +
\ No newline at end of file diff --git a/modules/template/src/main/twirl/scaladex/view/project/headproject.scala.html b/modules/template/src/main/twirl/scaladex/view/project/headproject.scala.html index 9f16b48b9..b1c14f604 100644 --- a/modules/template/src/main/twirl/scaladex/view/project/headproject.scala.html +++ b/modules/template/src/main/twirl/scaladex/view/project/headproject.scala.html @@ -111,7 +111,8 @@