From 2e2e274172c577e3b91afe6ce867b8f29b26ae1b Mon Sep 17 00:00:00 2001 From: Oleksandr Liemiahov Date: Wed, 18 Nov 2026 17:55:18 +0100 Subject: [PATCH 1/2] Show a single link in the achievement post shared to X The X share intent put "Learn more at hyperskill.org/courses" into the text and also passed the tracked courses link as the `url` parameter. X turns the bare domain into a link and appends `url` to the text, so the post showed two links. Both X and LinkedIn now share the same text, which ends with the tracked link, and the X intent no longer passes `url`. The dialog in the IDE still shows the short link without tracking parameters. --- .../academy/socialMedia/SocialMediaUtils.kt | 31 ++++---- .../socialMedia/SocialMediaUtilsTest.kt | 72 +++++++++++++++++++ 2 files changed, 89 insertions(+), 14 deletions(-) create mode 100644 intellij-plugin/hs-core/testSrc/org/hyperskill/academy/socialMedia/SocialMediaUtilsTest.kt diff --git a/intellij-plugin/hs-core/src/org/hyperskill/academy/socialMedia/SocialMediaUtils.kt b/intellij-plugin/hs-core/src/org/hyperskill/academy/socialMedia/SocialMediaUtils.kt index c4d460b30..3396a0316 100644 --- a/intellij-plugin/hs-core/src/org/hyperskill/academy/socialMedia/SocialMediaUtils.kt +++ b/intellij-plugin/hs-core/src/org/hyperskill/academy/socialMedia/SocialMediaUtils.kt @@ -23,7 +23,7 @@ object SocialMediaUtils { /** * Hyperskill courses page the achievement points to. UTM tags are part of the agreed link and must be kept as is. - * Used both as the `url` parameter of the X share intent and embedded into the LinkedIn share text. + * Embedded into the share text for both X and LinkedIn. */ const val SHARE_URL: String = "https://hyperskill.org/courses?source=ide_share&utm_source=jetbrains&utm_medium=social&utm_campaign=ide_plugin" @@ -53,7 +53,7 @@ object SocialMediaUtils { return allProjectTasksSolved } - /** The achievement sentence without any link. Shown as the base of the dialog message and used as the X post text. */ + /** The achievement sentence without any link. The base of both the dialog message and the share text. */ private fun achievementCore(solvedTask: Task): String { val course = solvedTask.course val projectName = (course as? HyperskillCourse)?.getProjectLesson()?.presentableName ?: course.presentableName @@ -65,23 +65,26 @@ object SocialMediaUtils { "${achievementCore(solvedTask)} ${EduCoreBundle.message("social.media.learn.more.at", COURSES_DISPLAY_LINK)}" /** - * X share intent. The post text includes the "Learn more at ..." part (the same text shown in the dialog), - * and the tracked [SHARE_URL] is additionally passed via the `url` parameter. - * https://twitter.com/intent/tweet?text=...&url=... + * Text of the post itself: the achievement plus the tracked [SHARE_URL]. It must contain exactly one link, + * so it never includes [COURSES_DISPLAY_LINK]: X turns a bare `hyperskill.org/courses` into a second link. */ - fun buildXShareUrl(solvedTask: Task): String { - val text = getDisplayMessage(solvedTask) - return "https://twitter.com/intent/tweet?text=${encode(text)}&url=${encode(SHARE_URL)}" - } + fun getShareText(solvedTask: Task): String = + "${achievementCore(solvedTask)} ${EduCoreBundle.message("social.media.learn.more.at", SHARE_URL)}" /** - * LinkedIn share intent. LinkedIn has no separate `url` parameter, so the tracked [SHARE_URL] is embedded into the text. + * X share intent. The link is part of [getShareText], so the intent's `url` parameter is not passed: + * X appends it to the text, and the post would show the link twice. + * https://twitter.com/intent/tweet?text=... + */ + fun buildXShareUrl(solvedTask: Task): String = + "https://twitter.com/intent/tweet?text=${encode(getShareText(solvedTask))}" + + /** + * LinkedIn share intent. LinkedIn has no separate `url` parameter, so the link is part of [getShareText]. * https://www.linkedin.com/feed/?shareActive=true&text=... */ - fun buildLinkedInShareUrl(solvedTask: Task): String { - val text = "${achievementCore(solvedTask)} ${EduCoreBundle.message("social.media.learn.more.at", SHARE_URL)}" - return "https://www.linkedin.com/feed/?shareActive=true&text=${encode(text)}" - } + fun buildLinkedInShareUrl(solvedTask: Task): String = + "https://www.linkedin.com/feed/?shareActive=true&text=${encode(getShareText(solvedTask))}" /** * Loads the full-resolution banner and returns a DPI-aware icon that downscales it to the exact device size diff --git a/intellij-plugin/hs-core/testSrc/org/hyperskill/academy/socialMedia/SocialMediaUtilsTest.kt b/intellij-plugin/hs-core/testSrc/org/hyperskill/academy/socialMedia/SocialMediaUtilsTest.kt new file mode 100644 index 000000000..2dfd591ce --- /dev/null +++ b/intellij-plugin/hs-core/testSrc/org/hyperskill/academy/socialMedia/SocialMediaUtilsTest.kt @@ -0,0 +1,72 @@ +package org.hyperskill.academy.socialMedia + +import org.hyperskill.academy.learning.EduTestCase +import org.hyperskill.academy.learning.courseFormat.tasks.Task +import org.hyperskill.academy.learning.stepik.hyperskill.hyperskillCourseWithFiles +import org.junit.Test +import java.net.URLDecoder +import java.nio.charset.StandardCharsets + +class SocialMediaUtilsTest : EduTestCase() { + + @Test + fun `test X share intent passes the link only inside the text`() { + val task = createProjectTask() + + val params = queryParams(SocialMediaUtils.buildXShareUrl(task)) + + // X appends the `url` parameter to the text, so passing it would put a second link into the post + assertEquals(setOf("text"), params.keys) + assertSingleLink(params.getValue("text")) + assertEquals(SocialMediaUtils.getShareText(task), params.getValue("text")) + } + + @Test + fun `test LinkedIn share intent passes the link only inside the text`() { + val task = createProjectTask() + + val params = queryParams(SocialMediaUtils.buildLinkedInShareUrl(task)) + + assertEquals(setOf("shareActive", "text"), params.keys) + assertSingleLink(params.getValue("text")) + assertEquals(SocialMediaUtils.getShareText(task), params.getValue("text")) + } + + @Test + fun `test dialog message shows the link without tracking parameters`() { + val task = createProjectTask() + + val message = SocialMediaUtils.getDisplayMessage(task) + + assertEquals(1, message.occurrencesOf(COURSES_LINK)) + assertFalse("Tracking parameters must not be shown in the dialog", message.contains("utm_")) + } + + private fun assertSingleLink(text: String) { + // A bare `hyperskill.org/courses` is turned into a link by X too, so it must not appear next to the tracked link + assertEquals("The post must contain exactly one link: $text", 1, text.occurrencesOf(COURSES_LINK)) + assertTrue("The post must end with the tracked link: $text", text.endsWith(SocialMediaUtils.SHARE_URL)) + } + + private fun queryParams(url: String): Map = + url.substringAfter('?').split('&').associate { + it.substringBefore('=') to URLDecoder.decode(it.substringAfter('='), StandardCharsets.UTF_8) + } + + private fun String.occurrencesOf(substring: String): Int = split(substring).size - 1 + + private fun createProjectTask(): Task { + val course = hyperskillCourseWithFiles { + frameworkLesson("Project") { + eduTask("Task1") { + taskFile("task.txt") + } + } + } + return course.getProjectLesson()?.getTask("Task1") ?: error("No Task1") + } + + companion object { + private const val COURSES_LINK = "hyperskill.org/courses" + } +} From a7cbf8d2be1aaba19fa5b07fe861cfbe12f06b22 Mon Sep 17 00:00:00 2001 From: Oleksandr Liemiahov Date: Wed, 18 Nov 2026 10:51:27 +0100 Subject: [PATCH 2/2] Remove the dead JetBrains Space Maven repository maven.pkg.jetbrains.space no longer resolves: JetBrains Space package hosting is shut down. Gradle asks repositories in declaration order, and this one came before the IntelliJ Platform and Marketplace repositories, so every artifact that was not cached yet failed on it instead of falling through to the next repository. The new Rust plugin build for 263 (263.7307.313) broke `:intellij-plugin:hs-Rust:compileKotlin` this way, and any build against a new IDE version would too. The only artifact taken from it, kotlin-css-jvm 2026.8.4, is on Maven Central. (cherry picked from commit 53c5a41218d4486e1ddb6a69e7b5c4efdb45847d) --- buildSrc/src/main/kotlin/common-conventions.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/common-conventions.gradle.kts b/buildSrc/src/main/kotlin/common-conventions.gradle.kts index f668325d3..2f389b31c 100644 --- a/buildSrc/src/main/kotlin/common-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/common-conventions.gradle.kts @@ -41,7 +41,6 @@ kotlin { repositories { mavenCentral() maven("https://cache-redirector.jetbrains.com/intellij-dependencies") - maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers") maven("https://packages.jetbrains.team/maven/p/edu/maven") maven("https://packages.jetbrains.team/maven/p/edu/educational-ml-library") maven("https://packages.jetbrains.team/maven/p/grazi/grazie-platform-public")