Skip to content

Commit

Permalink
17 : UI Change: Add metadata fields (version scheme, developers, scal…
Browse files Browse the repository at this point in the history
…a doc) on artifact pages (#18)

UI changes for adding following fields to Artifact page:

- Version Scheme
- Developers 
- Scala Doc link from POM's property.info.apiURL


![image](https://github.com/user-attachments/assets/55a8e894-7fef-4fa7-8ee6-1358e8a323f6)

![image](https://github.com/user-attachments/assets/f276b436-585e-4fde-9e9d-fffad79b0355)

![image](https://github.com/user-attachments/assets/05dabdc4-ddbf-4220-8702-66fef3e44249)
  • Loading branch information
skingle authored Aug 20, 2024
2 parents 326a389 + b7fa6a9 commit 18566ff
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
5 changes: 4 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ lazy val infra = project
"io.circe" %% "circe-core",
"io.circe" %% "circe-generic",
"io.circe" %% "circe-parser"
).map(_ % V.circe),
).map(_ % V.circe) ++ Seq(
"io.circe" %% "circe-generic-extras"
).map(_ % V.circeGenericExtra),
Elasticsearch.settings(defaultPort = 9200),
Postgres.settings(Compile, defaultPort = 5432, database = "scaladex"),
javaOptions ++= {
Expand Down Expand Up @@ -243,6 +245,7 @@ lazy val V = new {
val nscalaTime = "2.32.0"
val scalatest = "3.2.19"
val circe = "0.14.9"
val circeGenericExtra = "0.14.4"
val json4s = "4.0.7"
val coursier = "2.1.6"
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ case class Artifact(
fullScalaVersion: Option[SemanticVersion],
scaladocUrl: Option[Url],
versionScheme: Option[String],
developers: Seq[Contributor]
developers: Seq[Contributor] = Seq.empty
) {
val binaryVersion: BinaryVersion = BinaryVersion(platform, language)
val mavenReference: Artifact.MavenReference = Artifact.MavenReference(groupId.value, artifactId, version.encode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ case class Project(
image = githubInfo.flatMap(_.logo).orElse(Some(Url("https://index.scala-lang.org/assets/img/scaladex-brand.svg")))
)

def scaladoc(artifact: Artifact): Option[LabeledLink] =
settings.customScalaDoc
.map(DocumentationPattern("Scaladoc", _).eval(artifact))
.orElse(artifact.defaultScaladoc.map(LabeledLink("Scaladoc", _)))
def scaladoc(artifact: Artifact): Option[LabeledLink] = artifact.scaladocUrl
.map(_.labeled("Scaladoc"))
.orElse(
settings.customScalaDoc
.map(DocumentationPattern("Scaladoc", _).eval(artifact))
.orElse(artifact.defaultScaladoc.map(LabeledLink("Scaladoc", _)))
)

private def globalDocumentation: Seq[LabeledLink] =
settings.customScalaDoc.flatMap(DocumentationPattern("Scaladoc", _).asGlobal).toSeq ++
Expand Down
6 changes: 5 additions & 1 deletion modules/infra/src/main/scala/scaladex/infra/Codecs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package scaladex.infra
import java.time.Instant

import io.circe._
import io.circe.generic.extras.Configuration
import io.circe.generic.extras.semiauto.deriveConfiguredCodec
import io.circe.generic.semiauto._
import scaladex.core.model._
import scaladex.core.model.search.GithubInfoDocument
Expand Down Expand Up @@ -44,7 +46,8 @@ object Codecs {
implicit val languageCodec: Codec[Language] = fromString(_.label, Language.fromLabel(_).get)
implicit val resolverCodec: Codec[Resolver] = deriveCodec
implicit val licenseCodec: Codec[License] = fromString(_.shortName, License.allByShortName.apply)
implicit val artifactCodec: Codec[Artifact] = deriveCodec
implicit val customConfig: Configuration = Configuration.default.withDefaults
implicit val artifactCodec: Codec[Artifact] = deriveConfiguredCodec[Artifact]
implicit val scopeCodec: Codec[ArtifactDependency.Scope] = fromString(_.value, ArtifactDependency.Scope.apply)

implicit val mavenRefCodec: Codec[Artifact.MavenReference] = deriveCodec
Expand All @@ -62,4 +65,5 @@ object Codecs {

private def fromString[A](encode: A => String, decode: String => A): Codec[A] =
Codec.from(Decoder[String].map(decode), Encoder[String].contramap(encode))

}
11 changes: 11 additions & 0 deletions modules/server/src/main/assets/css/partials/_project.scss
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,15 @@
display: block;
}
}

.developers {
a {
color: $gray;
&:hover,
&:focus {
color: $brand-primary;
text-decoration: none;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ <h3>
@info("Group ID") { @artifact.groupId }
@info("Artifact ID") { @artifact.artifactId }
@info("Version") { @artifact.version }
@artifact.versionScheme.map { scheme =>
@info("Version Scheme"){
<a href="https://www.scala-sbt.org/1.x/docs/Publishing.html#Version+scheme" rel="nofollow">
@scheme
</a>
}
}
@info("Release Date") { @artifact.releaseDateFormat }
@info("Licenses") {
@for(license <- artifact.licenses) {
Expand All @@ -62,6 +69,7 @@ <h3>
@info("Files") { <a href="@artifact.mavenReference.repoUrl">View all</a> }
}
@artifact.fullScalaVersion.map{ version => @info("Full Scala Version") { @version.toString }}
@developers
</div>
@installBox(InstallTab.allOf(artifact, project.settings.cliArtifacts))
</div>
Expand Down Expand Up @@ -97,7 +105,21 @@ <h4>Documentation</h4>
</div>
}
}

@developers = {
@if(artifact.developers.nonEmpty){
@info("Developers"){
<div class="developers">
@for(developer <- artifact.developers) {
<span>
<a href="@developer.url">
@developer.name
</a> |
</span>
}
</div>
}
}
}
@scastieBox = {
@if(artifact.scastieURL.nonEmpty) {
<div class="box">
Expand Down

0 comments on commit 18566ff

Please sign in to comment.