From be4091ffec211d8d01f58f1e2fabee057140c243 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Mon, 17 May 2021 13:59:52 +0100 Subject: [PATCH 1/5] Fix markdown for Badge links in README I contributed slightly broken versions of these in https://github.com/scalacenter/scaladex/pull/660 --- README.MD | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.MD b/README.MD index e97169ddd..9ddac971a 100644 --- a/README.MD +++ b/README.MD @@ -53,14 +53,14 @@ read the [developer guide](/CONTRIBUTING.md) You can add this badge to the README.MD of your own GitHub projects to show the versions of Scala they support: -[![Scala version Badge](https://index.scala-lang.org/typelevel/cats/cats-core/latest-by-scala-version.svg) +[![cats-core Scala version support](https://index.scala-lang.org/typelevel/cats/cats-core/latest-by-scala-version.svg)](https://index.scala-lang.org/typelevel/cats/cats-core) ...the badge above only summarises latest JVM artifacts, if you'd like a badge for Scala JS or Scala Native, add a `targetType=...` query-string parameter: -[![Scala version Badge](https://index.scala-lang.org/typelevel/cats/cats-core/latest-by-scala-version.svg?targetType=js) +[![cats-core Scala version support](https://index.scala-lang.org/typelevel/cats/cats-core/latest-by-scala-version.svg?targetType=js)](https://index.scala-lang.org/typelevel/cats/cats-core) -[![Scala version Badge](https://index.scala-lang.org/typelevel/cats/cats-core/latest-by-scala-version.svg?targetType=native) +[![cats-core Scala version support](https://index.scala-lang.org/typelevel/cats/cats-core/latest-by-scala-version.svg?targetType=native)](https://index.scala-lang.org/typelevel/cats/cats-core) ### Smaller, shorter badges From b3257760f43e20d7931bb5fde127b731e58885e9 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Fri, 28 May 2021 17:17:28 +0100 Subject: [PATCH 2/5] Fix broken links to Scala tools in dependency incantations --- .../ch.epfl.scala.index.views/project/install.scala.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/template/src/main/twirl/ch.epfl.scala.index.views/project/install.scala.html b/template/src/main/twirl/ch.epfl.scala.index.views/project/install.scala.html index 2d18fc9b0..aeaefd836 100644 --- a/template/src/main/twirl/ch.epfl.scala.index.views/project/install.scala.html +++ b/template/src/main/twirl/ch.epfl.scala.index.views/project/install.scala.html @@ -30,13 +30,13 @@
- Ammonite REPL + Ammonite REPL
@release.ammInstall
@if(cliArtifacts.contains(release.reference.artifact)) {
- Coursier + Coursier
./coursier launch @release.maven.groupId:@release.maven.artifactId:@release.maven.version
@@ -50,7 +50,7 @@
- Mill build tool + Mill build tool
@release.millInstall
From 4ae6d0ef9d5981e39bc1aa16b8082471a994be95 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Fri, 28 May 2021 17:23:38 +0100 Subject: [PATCH 3/5] Provide a 'Create Badge' function for users The markdown required to create a badge is fairly verbose: ``` [![algebra-laws Scala version support](https://index.scala-lang.org/typelevel/algebra/algebra-laws/latest-by-scala-version.svg)](https://index.scala-lang.org/typelevel/algebra/algebra-laws) ``` ...it's nice to be able to help people to create it. Travis CI, GitHub and others follow this pattern to show both the badge, and the recommended markdown to display it. --- .../ch.epfl.scala.index.model/Release.scala | 6 +- .../src/main/assets/css/partials/_main.scss | 63 +++++++++++++++++-- .../project/headproject.scala.html | 22 +++++++ .../project/install.scala.html | 12 ++-- 4 files changed, 91 insertions(+), 12 deletions(-) diff --git a/model/src/main/scala/ch.epfl.scala.index.model/Release.scala b/model/src/main/scala/ch.epfl.scala.index.model/Release.scala index 6085696a0..2bdb1f7e1 100644 --- a/model/src/main/scala/ch.epfl.scala.index.model/Release.scala +++ b/model/src/main/scala/ch.epfl.scala.index.model/Release.scala @@ -227,10 +227,14 @@ object Release { def projectReference = Project.Reference(organization, repository) def name = s"$organization/$artifact" + + def artifactHttpPath = s"/$organization/$repository/$artifact" + def artifactFullHttpUrl = s"https://index.scala-lang.org$artifactHttpPath" + def badgeUrl: String = s"$artifactFullHttpUrl/latest-by-scala-version.svg" def httpUrl = { val targetQuery = target.map(t => s"?target=${t.encode}").getOrElse("") - s"/$organization/$repository/$artifact/$version$targetQuery" + s"$artifactHttpPath/$version$targetQuery" } def isScalaLib: Boolean = { diff --git a/server/src/main/assets/css/partials/_main.scss b/server/src/main/assets/css/partials/_main.scss index b6a04ab73..f9f82e988 100755 --- a/server/src/main/assets/css/partials/_main.scss +++ b/server/src/main/assets/css/partials/_main.scss @@ -14,6 +14,10 @@ main { flex: 1; } +.copyable-incantation { + user-select: all; +} + .banner { background: #0c353c; text-align: center; @@ -493,6 +497,11 @@ main { margin-bottom: ($line-height-computed / 1.5); } .install { + .btn-copy { + position: absolute; + top: 50px; + right: 6px; + } .nav-tabs > li:not(.active) > a { color: white; } @@ -587,11 +596,6 @@ main { .tab-pane { height: 85px; } - .btn-copy { - position: absolute; - top: 50px; - right: 6px; - } } .head-project { @@ -643,6 +647,55 @@ main { padding: 6px 12px; } } + .overlay { + position: fixed; + z-index: 10; + top: 0; + bottom: 0; + left: 0; + right: 0; + background: rgba(0, 0, 0, 0.7); + transition: opacity 500ms; + visibility: hidden; + opacity: 0; + } + .overlay:target { + visibility: visible; + opacity: 1; + } + + .popup { + margin: 70px auto; + padding: 20px; + background: #fff; + border-radius: 5px; + width: 60%; + position: relative; + transition: all 5s ease-in-out; + } + + .popup h2 { + margin-top: 0; + color: #333; + font-family: Tahoma, Arial, sans-serif; + } + .popup .close { + position: absolute; + top: 20px; + right: 30px; + transition: all 200ms; + font-size: 30px; + font-weight: bold; + text-decoration: none; + color: #333; + } + .popup .close:hover { + color: #06D85F; + } + .popup .content { + max-height: 30%; + overflow: auto; + } } .artifact-project { margin-top: 10px; diff --git a/template/src/main/twirl/ch.epfl.scala.index.views/project/headproject.scala.html b/template/src/main/twirl/ch.epfl.scala.index.views/project/headproject.scala.html index be5b677af..365416237 100644 --- a/template/src/main/twirl/ch.epfl.scala.index.views/project/headproject.scala.html +++ b/template/src/main/twirl/ch.epfl.scala.index.views/project/headproject.scala.html @@ -52,6 +52,28 @@

GitHub } + + + +
+ +
@for(github <- project.github) { @if(!github.topics.isEmpty) { diff --git a/template/src/main/twirl/ch.epfl.scala.index.views/project/install.scala.html b/template/src/main/twirl/ch.epfl.scala.index.views/project/install.scala.html index aeaefd836..fca8a6d9e 100644 --- a/template/src/main/twirl/ch.epfl.scala.index.views/project/install.scala.html +++ b/template/src/main/twirl/ch.epfl.scala.index.views/project/install.scala.html @@ -26,32 +26,32 @@
-
@release.sbtInstall
+
@release.sbtInstall
Ammonite REPL -
@release.ammInstall
+
@release.ammInstall
@if(cliArtifacts.contains(release.reference.artifact)) {
Coursier -
./coursier launch @release.maven.groupId:@release.maven.artifactId:@release.maven.version
+
cs launch @release.maven.groupId:@release.maven.artifactId:@release.maven.version
}
-
@release.mavenInstall
+
@release.mavenInstall
-
@release.gradleInstall
+
@release.gradleInstall
Mill build tool -
@release.millInstall
+
@release.millInstall
From 3e7498e8631576a8badba63a4268c5eb93ab52c3 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Tue, 1 Jun 2021 23:19:57 +0100 Subject: [PATCH 4/5] Display badge for targetType appropriate to release So if we're looking at: https://index.scala-lang.org/typelevel/cats/cats-core/2.6.1?target=_sjs1.x_3.x ...we want to see the badge with `targetType=js`, rather than the default badge that displays JVM-based artifacts. --- .../src/main/scala/ch.epfl.scala.index.model/Release.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/model/src/main/scala/ch.epfl.scala.index.model/Release.scala b/model/src/main/scala/ch.epfl.scala.index.model/Release.scala index 2bdb1f7e1..b571dd06f 100644 --- a/model/src/main/scala/ch.epfl.scala.index.model/Release.scala +++ b/model/src/main/scala/ch.epfl.scala.index.model/Release.scala @@ -230,7 +230,12 @@ object Release { def artifactHttpPath = s"/$organization/$repository/$artifact" def artifactFullHttpUrl = s"https://index.scala-lang.org$artifactHttpPath" - def badgeUrl: String = s"$artifactFullHttpUrl/latest-by-scala-version.svg" + private def nonDefaultTargetType = { + target.map(_.targetType).filter(_ != Jvm) + } + def badgeUrl: String = + s"$artifactFullHttpUrl/latest-by-scala-version.svg" + + nonDefaultTargetType.map("?targetType=" + _).mkString def httpUrl = { val targetQuery = target.map(t => s"?target=${t.encode}").getOrElse("") From 84e826e2da09d7d4c1135f0576fbdb611ebd3318 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Tue, 1 Jun 2021 23:22:26 +0100 Subject: [PATCH 5/5] Move badge display to it's own box on RHS bar Suggested in https://github.com/scalacenter/scaladex/pull/670#issuecomment-851336668 Advantages ---------- * If the project already has the badge in it's project README, then it would be repetitious to show the badge immediately above it in the project header. * If we consider the visible badge on the project page as just a link to the markdown-generator lightbox, rather than informational in itself (given that version information is already visible in the versions dropdown), then there is no need to prominently display the full badge. Disadvantages ------------- * Narrower space usually truncates the (very wide) badge. Mitigating against this is the argument that the badge here is just a link, rather than informational. * Takes up more space vertically, so the consumed screen-area is somewhat larger than with the badge in the project header, even though it's narrower! It would be nice if there was a visual indication that the badge was truncated on the right. Using `overflow: scroll` gives an always-present scrollbar, which I find visually cluttered and more than what's needed- we don't really want to scroll the badge from side-to-side, when we can just click on it to view the whole thing. --- .../src/main/assets/css/partials/_main.scss | 101 +++++++++--------- .../project/badges.scala.html | 30 ++++++ .../project/headproject.scala.html | 23 +--- .../project/project.scala.html | 1 + 4 files changed, 84 insertions(+), 71 deletions(-) create mode 100644 template/src/main/twirl/ch.epfl.scala.index.views/project/badges.scala.html diff --git a/server/src/main/assets/css/partials/_main.scss b/server/src/main/assets/css/partials/_main.scss index f9f82e988..b788f679c 100755 --- a/server/src/main/assets/css/partials/_main.scss +++ b/server/src/main/assets/css/partials/_main.scss @@ -647,55 +647,6 @@ main { padding: 6px 12px; } } - .overlay { - position: fixed; - z-index: 10; - top: 0; - bottom: 0; - left: 0; - right: 0; - background: rgba(0, 0, 0, 0.7); - transition: opacity 500ms; - visibility: hidden; - opacity: 0; - } - .overlay:target { - visibility: visible; - opacity: 1; - } - - .popup { - margin: 70px auto; - padding: 20px; - background: #fff; - border-radius: 5px; - width: 60%; - position: relative; - transition: all 5s ease-in-out; - } - - .popup h2 { - margin-top: 0; - color: #333; - font-family: Tahoma, Arial, sans-serif; - } - .popup .close { - position: absolute; - top: 20px; - right: 30px; - transition: all 200ms; - font-size: 30px; - font-weight: bold; - text-decoration: none; - color: #333; - } - .popup .close:hover { - color: #06D85F; - } - .popup .content { - max-height: 30%; - overflow: auto; - } } .artifact-project { margin-top: 10px; @@ -729,6 +680,58 @@ main { } } +.badge-showcase { + .overlay { + position: fixed; + z-index: 10; + top: 0; + bottom: 0; + left: 0; + right: 0; + background: rgba(0, 0, 0, 0.7); + transition: opacity 500ms; + visibility: hidden; + opacity: 0; + } + .overlay:target { + visibility: visible; + opacity: 1; + } + + .popup { + margin: 70px auto; + padding: 20px; + background: #fff; + border-radius: 5px; + width: 60%; + position: relative; + transition: all 5s ease-in-out; + } + + .popup h2 { + margin-top: 0; + color: #333; + font-family: Tahoma, Arial, sans-serif; + } + .popup .close { + position: absolute; + top: 20px; + right: 30px; + transition: all 200ms; + font-size: 30px; + font-weight: bold; + text-decoration: none; + color: #333; + } + .popup .close:hover { + color: #06D85F; + } + .popup .content { + max-height: 30%; + overflow: auto; + } +} + .documentation-link { ul { padding-left: 0; diff --git a/template/src/main/twirl/ch.epfl.scala.index.views/project/badges.scala.html b/template/src/main/twirl/ch.epfl.scala.index.views/project/badges.scala.html new file mode 100644 index 000000000..4c15884f4 --- /dev/null +++ b/template/src/main/twirl/ch.epfl.scala.index.views/project/badges.scala.html @@ -0,0 +1,30 @@ +@import ch.epfl.scala.index.model.Release +@(release: Release) +
+

Markdown Badge

+
+ + + +
+
+ +
+ +
\ No newline at end of file diff --git a/template/src/main/twirl/ch.epfl.scala.index.views/project/headproject.scala.html b/template/src/main/twirl/ch.epfl.scala.index.views/project/headproject.scala.html index 365416237..6c33e9b5e 100644 --- a/template/src/main/twirl/ch.epfl.scala.index.views/project/headproject.scala.html +++ b/template/src/main/twirl/ch.epfl.scala.index.views/project/headproject.scala.html @@ -52,28 +52,7 @@

GitHub } - - - -
- -
+ @for(github <- project.github) { @if(!github.topics.isEmpty) { diff --git a/template/src/main/twirl/ch.epfl.scala.index.views/project/project.scala.html b/template/src/main/twirl/ch.epfl.scala.index.views/project/project.scala.html index 6f7410cd6..858dcd6c8 100644 --- a/template/src/main/twirl/ch.epfl.scala.index.views/project/project.scala.html +++ b/template/src/main/twirl/ch.epfl.scala.index.views/project/project.scala.html @@ -31,6 +31,7 @@

[DEPRECATED]

} @documentation(release, project) + @badges(release) @install(release, project.cliArtifacts) @release.scastieURL.map(url => scastie(url)) @project.github.map(gh => statistic(gh, project.githubRepo, project.releaseCount, allDeps.reverseDependencies.size))