From b288760eb87f1b9c853791ed23ed9d267122286d Mon Sep 17 00:00:00 2001 From: Nikita Iarychenko Date: Fri, 22 Nov 2024 10:45:31 +0400 Subject: [PATCH] OPENIDE #39 Analysis and replacement of external links for OpenIDE (cherry picked from commit b0138a5045360e83e95748ba8deec3b84f137bc0) (cherry picked from commit 423f41e2427e240c008f5ae96799a5cfa4f53a1b) --- .../base/src/OpenIdeExternalResourceUrls.kt | 56 +++++++++++++++---- .../customization/OpenIdeFeedbackReporter.kt | 13 +++++ 2 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/platform/ide/impl/customization/OpenIdeFeedbackReporter.kt diff --git a/idea/customization/base/src/OpenIdeExternalResourceUrls.kt b/idea/customization/base/src/OpenIdeExternalResourceUrls.kt index 53ac5da7d413..427b43320839 100644 --- a/idea/customization/base/src/OpenIdeExternalResourceUrls.kt +++ b/idea/customization/base/src/OpenIdeExternalResourceUrls.kt @@ -2,31 +2,65 @@ // Use is subject to license terms. package com.intellij.idea.customization.base +import com.intellij.openapi.application.ApplicationInfo +import com.intellij.openapi.updateSettings.impl.PatchInfo import com.intellij.openapi.util.BuildNumber +import com.intellij.openapi.util.SystemInfo import com.intellij.platform.ide.customization.ExternalProductResourceUrls +import com.intellij.platform.ide.impl.customization.OpenIdeFeedbackReporter import com.intellij.util.Url import com.intellij.util.Urls +import com.intellij.util.system.CpuArch -// TODO [OpenIDE]: replaces urls class OpenIdeExternalResourceUrls : ExternalProductResourceUrls { - override val helpPageUrl: ((topicId: String) -> Url)? = null + private val productUrl = Urls.newFromEncoded("https://openide.ru") - override val gettingStartedPageUrl = null + override val updateMetadataUrl = productUrl.resolve("update/updates.xml") - override val youTubeChannelUrl = null + override fun computePatchUrl(from: BuildNumber, to: BuildNumber): Url = + Urls.newFromEncoded("https://download.openide.ru/ide").resolve(computePatchFileName(from, to)) - override val updateMetadataUrl = Urls.newFromEncoded("https://www.openide.com") + override val bugReportUrl: ((String) -> Url) + get() = { description -> + Urls.newFromEncoded("https://youtrack.openide.ru/newissue").addParameters(mapOf( + "project" to "12345", + "clearDraft" to "true", + "description" to description, + "c" to "Affected versions: ${ApplicationInfo.getInstance().fullVersion}" + )) + } - override fun computePatchUrl(from: BuildNumber, to: BuildNumber): Url = Urls.newFromEncoded("https://www.openide.com") + override val technicalSupportUrl: ((description: String) -> Url) = { productUrl.resolve("contacts") } - override val bugReportUrl: ((String) -> Url)? = null + override val feedbackReporter = OpenIdeFeedbackReporter() - override val technicalSupportUrl: ((description: String) -> Url) ? = null + override val downloadPageUrl = productUrl.resolve("download") - override val feedbackReporter = null + override val youTubeChannelUrl = Urls.newFromEncoded("https://www.youtube.com/openide") - override val downloadPageUrl = null + override val keyboardShortcutsPdfUrl: Url + get() { + val suffix = if (SystemInfo.isMac) "_Mac" else "" + return productUrl.resolve("ide/docs/OpenIDE_ReferenceCard$suffix.pdf") + } - override val whatIsNewPageUrl = null + override val whatIsNewPageUrl = productUrl.resolve("whatsnew") + + override val gettingStartedPageUrl = productUrl.resolve("ide/resources") + + override val helpPageUrl: ((topicId: String) -> Url) + get() = productUrl.resolve("help/ide/").let { baseUrl -> + { topicId -> + baseUrl.resolve("${ApplicationInfo.getInstance().shortVersion}/").addParameters(mapOf( + topicId to "" + )) + } + } + + private fun computePatchFileName(from: BuildNumber, to: BuildNumber): String { + val product = ApplicationInfo.getInstance().build.productCode + val runtime = if (CpuArch.isArm64()) "-aarch64" else "" + return "${product}-${from.withoutProductCode().asString()}-${to.withoutProductCode().asString()}-patch${runtime}-${PatchInfo.OS_SUFFIX}.jar" + } } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/platform/ide/impl/customization/OpenIdeFeedbackReporter.kt b/platform/platform-impl/src/com/intellij/platform/ide/impl/customization/OpenIdeFeedbackReporter.kt new file mode 100644 index 000000000000..7e5c74507954 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/platform/ide/impl/customization/OpenIdeFeedbackReporter.kt @@ -0,0 +1,13 @@ +// Copyright (c) Haulmont 2024. All Rights Reserved. +// Use is subject to license terms. +package com.intellij.platform.ide.impl.customization + +import com.intellij.platform.ide.customization.FeedbackReporter +import com.intellij.util.Urls + +class OpenIdeFeedbackReporter : FeedbackReporter { + + override val destinationDescription = "openide.ru" + + override fun feedbackFormUrl(description: String) = Urls.newFromEncoded("https://openide.ru/feedback") +} \ No newline at end of file