mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
[platform] provide a way to compute URLs for context help pages in ExternalProductResourceUrls (IJPL-204)
The logic which constructs the full URL is moved to ExternalProductResourceUrls's implementations, allowing third-party IDEs to have their own schemas of URLs for context help. IntelliJ IDEA has been migrated to use the new property. GitOrigin-RevId: b57b021c07eb84fdd0dd968e057100156a646fb1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
eee554c5ba
commit
8e07ad9bc1
@@ -15,7 +15,6 @@
|
||||
<plugins url="https://plugins.jetbrains.com/"
|
||||
builtin-url="__BUILTIN_PLUGINS_URL__"/>
|
||||
|
||||
<help webhelp-url="https://www.jetbrains.com/help/idea/"/>
|
||||
<whatsnew show-on-update="true"/>
|
||||
|
||||
<statistics settings="https://www.jetbrains.com/idea/statistics/stat-assistant.xml"
|
||||
|
||||
@@ -51,4 +51,7 @@ class IntelliJIdeaExternalResourceUrls : BaseJetBrainsExternalProductResourceUrl
|
||||
|
||||
override val gettingStartedPageUrl: Url
|
||||
get() = Urls.newFromEncoded("https://www.jetbrains.com/idea/resources/")
|
||||
|
||||
override val baseWebHelpUrl: String
|
||||
get() = "https://www.jetbrains.com/help/idea/"
|
||||
}
|
||||
@@ -108,6 +108,13 @@ interface ExternalProductResourceUrls {
|
||||
*/
|
||||
val gettingStartedPageUrl: Url?
|
||||
get() = null
|
||||
|
||||
/**
|
||||
* Returns a function which computes URL of a help page by a given `topicId`.
|
||||
* This URL is used by [HelpManager][com.intellij.openapi.help.HelpManager] to show context help.
|
||||
*/
|
||||
val helpPageUrl: ((topicId: String) -> Url)?
|
||||
get() = null
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,12 +3,13 @@ package com.intellij.help.impl;
|
||||
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.openapi.application.IdeUrlTrackingParametersProvider;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.help.WebHelpProvider;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.io.URLUtil;
|
||||
import com.intellij.platform.ide.customization.ExternalProductResourceUrls;
|
||||
import com.intellij.util.Url;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class HelpManagerImpl extends HelpManager {
|
||||
@@ -39,13 +40,8 @@ public class HelpManagerImpl extends HelpManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
ApplicationInfoEx info = ApplicationInfoEx.getInstanceEx();
|
||||
String productVersion = info.getShortVersion();
|
||||
|
||||
String url = info.getWebHelpUrl();
|
||||
if (!url.endsWith("/")) url += "/";
|
||||
url += productVersion + "/?" + URLUtil.encodeURIComponent(id);
|
||||
|
||||
return IdeUrlTrackingParametersProvider.getInstance().augmentUrl(url);
|
||||
Function1<String, Url> urlSupplier = ExternalProductResourceUrls.getInstance().getHelpPageUrl();
|
||||
if (urlSupplier == null) return null;
|
||||
return IdeUrlTrackingParametersProvider.getInstance().augmentUrl(urlSupplier.invoke(id).toExternalForm());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,13 @@ abstract class BaseJetBrainsExternalProductResourceUrls : ExternalProductResourc
|
||||
*/
|
||||
abstract val productPageUrl: String
|
||||
|
||||
/**
|
||||
* Returns base URL of context help pages.
|
||||
* The current IDE version number and ID of the requested topic are added to it to obtain the actual URL:
|
||||
* [baseWebHelpUrl]`/<version>/?<topicId>`.
|
||||
*/
|
||||
abstract val baseWebHelpUrl: String
|
||||
|
||||
/**
|
||||
* Returns ID of the form used to contact support at intellij-support.jetbrains.com site
|
||||
*/
|
||||
@@ -86,6 +93,13 @@ abstract class BaseJetBrainsExternalProductResourceUrls : ExternalProductResourc
|
||||
|
||||
override val whatIsNewPageUrl: Url?
|
||||
get() = Urls.newFromEncoded(productPageUrl).resolve("whatsnew")
|
||||
|
||||
override val helpPageUrl: ((topicId: String) -> Url)
|
||||
get() = { topicId ->
|
||||
Urls.newFromEncoded(baseWebHelpUrl).resolve("${ApplicationInfo.getInstance().shortVersion}/").addParameters(mapOf(
|
||||
topicId to ""
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,4 +87,14 @@ class LegacyExternalProductResourceUrls : ExternalProductResourceUrls {
|
||||
|
||||
override val gettingStartedPageUrl: Url?
|
||||
get() = ApplicationInfoEx.getInstanceEx().documentationUrl?.let { Urls.newFromEncoded(it) }
|
||||
|
||||
override val helpPageUrl: ((topicId: String) -> Url)?
|
||||
get() {
|
||||
val baseHelpUrl = ApplicationInfoEx.getInstanceEx().webHelpUrl ?: return null
|
||||
return { topicId ->
|
||||
Urls.newFromEncoded(baseHelpUrl).resolve("${ApplicationInfo.getInstance().shortVersion}/").addParameters(mapOf(
|
||||
topicId to ""
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user