feat(windows): cleanup server names

This makes server URLs version agnostic and works with
tiers and debug overrides in all URLs. This is groundwork
for universal links and integrated new keyboard search.

Also uses /windows/ instead of /desktop/ where possible.
This commit is contained in:
Marc Durdin 2020-07-09 10:16:21 +10:00
parent 17c7868ac0
commit 4fb3d7ca3a
10 changed files with 59 additions and 23 deletions

View file

@ -210,7 +210,8 @@ begin
// Ensures keyman.com hosted site opens locally
cef.ShouldOpenRemoteUrlsInBrowser := False;
FRenderPage := 'downloadkeyboard';
Content_Render;
Content_Render(False);
inherited;
end;

View file

@ -4,14 +4,14 @@ inherited frmMain: TfrmMain
HelpContext = 1050
BorderIcons = [biSystemMenu, biMinimize, biMaximize, biHelp]
ClientHeight = 494
ClientWidth = 617
ClientWidth = 846
Constraints.MinHeight = 530
Constraints.MinWidth = 600
OldCreateOrder = True
Position = poScreenCenter
OnClose = TntFormClose
OnCloseQuery = TntFormCloseQuery
ExplicitWidth = 633
ExplicitWidth = 862
ExplicitHeight = 533
PixelsPerInch = 96
TextHeight = 13

View file

@ -160,8 +160,6 @@ implementation
{$R *.DFM}
uses
axctrls,
ActiveX,
BaseKeyboards,
ComObj,
GetOSVersion,
@ -171,6 +169,7 @@ uses
initprog,
Keyman.Configuration.UI.UfrmDiagnosticTests,
KeymanOptionNames,
KeymanVersion,
KeyNames,
custinterfaces,
KLog,
@ -277,7 +276,7 @@ procedure TfrmMain.Do_Content_Render(FRefreshKeyman: Boolean);
var
sharedDataIntf: IConfigMainSharedData;
sharedData: TConfigMainSharedData;
s: string;
DefaultServersTag, s: string;
begin
if FPageTag > 0 then
begin
@ -300,7 +299,7 @@ begin
XMLEncode(sharedDataIntf.State),
Cardinal(kmcom.Options[KeymanOptionName(koBaseLayout)].Value),
XMLEncode(TBaseKeyboards.GetName(kmcom.Options[KeymanOptionName(koBaseLayout)].Value))
]);
]) + DefaultServersXMLTags + DefaultVersionXMLTags;
sharedData.Init(
FXMLRenderers.TempPath,

View file

@ -73,6 +73,7 @@ uses
LanguagesXMLRenderer,
OptionsXMLRenderer,
SupportXMLRenderer,
Upload_Settings,
utilxml;
{ THttpServerApp }
@ -237,12 +238,13 @@ procedure TAppHttpResponder.ProcessXMLPage(const s: string);
var
FXML: string;
PageTag: string;
DefaultServersTag: string;
begin
PageTag := RequestInfo.Params.Values['tag'];
if PageTag <> '' then
PageTag := '<PageTag>'+PageTag+'</PageTag>';
FXML := FXMLRenderers.RenderToString(False, s + PageTag);
FXML := FXMLRenderers.RenderToString(False, s + PageTag + DefaultServersXMLTags + DefaultVersionXMLTags);
FResponseInfo.ContentStream := TStringStream.Create(FXML, TEncoding.UTF8);
FResponseInfo.FreeContentStream := True;

View file

@ -63,7 +63,7 @@
<body>
<div id="size"></div>
<iframe id="contentframe" frameborder="0">
<xsl:attribute name="src">https://keyman.com/go/desktop/10.0/download-keyboards?version=<xsl:value-of select="/Keyman/Version" /></xsl:attribute>&#160;
<xsl:attribute name="src"><xsl:value-of select='/Keyman/keyman-com' />/go/windows/<xsl:value-of select="/Keyman/version-info/@versionRelease" />/download-keyboards?version=<xsl:value-of select="/Keyman/Version" /></xsl:attribute>&#160;
</iframe>
<div id="footerframe">
<!--<div style="float:left; font-size: 13.3px;">

View file

@ -5,7 +5,7 @@
<script>
window['menuframe_activate_keepintouch'] = function() {
document.getElementById('keepintouch_frame').src = 'https://keyman.com/go/desktop/10.0/keep-in-touch?embed=1';
document.getElementById('keepintouch_frame').src = '<xsl:value-of select='/Keyman/keyman-com' />/go/windows/<xsl:value-of select="/Keyman/version-info/@versionRelease" />/keep-in-touch?embed=1';
}
</script>

View file

@ -282,13 +282,13 @@
<div class='qrcode-caption'>
<xsl:value-of select="$locale/String[@Id='S_Keyboard_Share_QRCode']"/>
<a>
<xsl:attribute name="href">keyman:link?url=https://keyman.com/go/keyboard/<xsl:value-of select="../../id" />/share</xsl:attribute>
<xsl:attribute name="href">keyman:link?url=<xsl:value-of select="/Keyman/keyman-com" />/go/keyboard/<xsl:value-of select="../../id" />/share</xsl:attribute>
<xsl:value-of select="$locale/String[@Id='S_Keyboard_Share_Link']"/>
</a>
<xsl:value-of select="$locale/String[@Id='S_Keyboard_Share_LinkSuffix']"/>
</div>
<script>new QRCode(document.getElementById("qrcode-img-<xsl:value-of select="../../id"/>"), {
text: 'https://keyman.com/go/keyboard/<xsl:value-of select="../../id"/>/share',
text: '<xsl:value-of select="/Keyman/keyman-com" />/go/keyboard/<xsl:value-of select="../../id"/>/share',
width: 256,
height: 256
});

View file

@ -16,14 +16,14 @@
</div>
<div class="support_edition">
<xsl:value-of select="$locale/String[@Id='S_Support_Version']"/>&#160;<xsl:value-of select="/Keyman/support/version" /><xsl:value-of select="$locale/String[@Id='S_BETA']"/><br />
<xsl:value-of select="$locale/String[@Id='S_Support_Version']"/>&#160;<xsl:value-of select="/Keyman/version-info/@versionWithTag" /><br />
</div>
<div class="support_contact">
<p><xsl:value-of select="$locale/String[@Id='S_Support_ContactInstructions_Free']"/></p>
<xsl:call-template name="button">
<xsl:with-param name="caption"><xsl:value-of select="$locale/String[@Id='S_Button_CommunitySupport']"/></xsl:with-param>
<xsl:with-param name="command">keyman:link?url=https://keyman.com/go/desktop/10.0/forums</xsl:with-param>
<xsl:with-param name="command">keyman:link?url=<xsl:value-of select="/Keyman/keyman-com" />/go/<xsl:value-of select="/Keyman/version-info/@versionRelease" />/community/</xsl:with-param>
<xsl:with-param name="width">220px</xsl:with-param>
</xsl:call-template>
</div>
@ -39,10 +39,12 @@
<div class="support_links">
<h2><xsl:value-of select="$locale/String[@Id='S_Support_UsefulLinks']"/></h2>
<ul>
<li><a href="https://www.keyman.com/">www.keyman.com</a></li>
<li><a><xsl:attribute name="href">keyman:link?url=<xsl:value-of select="/Keyman/keyman-com"/>/</xsl:attribute>keyman.com</a></li>
<li><a href="keyman:support_diagnostics"><xsl:value-of select="$locale/String[@Id='S_Menu_Diagnostics_Diagnostics']"/></a></li>
<li><a href="keyman:support_updatecheck"><xsl:value-of select="$locale/String[@Id='S_Button_CheckForUpdates']"/></a></li>
<li><a href="keyman:link?url=https://keyman.com/go/desktop/10.0/support"><xsl:value-of select="$locale/String[@Id='S_Button_OnlineSupport']"/></a></li>
<li><a>
<xsl:attribute name="href">keyman:link?url=<xsl:value-of select="/Keyman/keyman-com" />/go/<xsl:value-of select="/Keyman/version-info/@versionRelease" />/support</xsl:attribute
><xsl:value-of select="$locale/String[@Id='S_Button_OnlineSupport']"/></a></li>
</ul>
</div>
</div>

View file

@ -66,6 +66,21 @@ const
SKeymanDesktopName = 'Keyman';
// Keyman Desktop was renamed to Keyman [for Windows] in 14.0
function DefaultVersionXMLTags: string;
implementation
uses
System.SysUtils;
function DefaultVersionXMLTags: string;
begin
with CKeymanVersionInfo do
Result := Format(
'<version-info version="%s" versionWin="%s" versionRelease="%s" versionMajor="%d" versionMinor="%d" '+
'versionPatch="%d" tier="%s" tag="%s" versionWithTag="%s" environment="%s" />',
[Version, VersionWin, VersionRelease, VersionMajor, VersionMinor,
VersionPatch, Tier, Tag, VersionWithTag, Environment]);
end;
end.

View file

@ -33,6 +33,7 @@ const
// https://api.keyman.com/ - programmatic endpoints
API_Path_UpdateCheck_Windows = '/windows/14.0/update'; // version will only update when the api changes
// TODO: use /windows/ instead of /desktop/
API_Path_UpdateCheck_Desktop = '/desktop/'+SKeymanVersion+'/update'; // TODO: use updatecheck_windows
API_Path_UpdateCheck_Developer = '/developer/'+SKeymanVersion+'/update';
API_Path_DownloadLocale = '/desktop/'+SKeymanVersion+'/locale';
@ -40,14 +41,15 @@ const
API_Path_IsOnline = '/desktop/'+SKeymanVersion+'/isonline';
// https://www.keyman.com/ - web pages
URLPath_KeymanLanguageLookup = '/go/developer/'+SKeymanVersion+'/language-lookup';
URLPath_CreateTranslation = '/go/desktop/'+SKeymanVersion+'/create-locale';
URLPath_KeepInTouch = '/go/desktop/'+SKeymanVersion+'/keep-in-touch';
URLPath_KeymanDeveloperDocumentation = '/go/developer/'+SKeymanVersion+'/docs';
URLPath_CreateTranslation = '/go/windows/'+SKeymanVersion+'/create-locale'; //TODO: i18n
URLPath_KeepInTouch = '/go/windows/'+SKeymanVersion+'/keep-in-touch';
URLPath_KeymanHome = '/go/windows/'+SKeymanVersion+'/home';
URLPath_ArchivedDownloads = '/go/windows/'+SKeymanVersion+'/archived-downloads';
URLPath_KeymanLanguageLookup = '/go/developer/'+SKeymanVersion+'/language-lookup';
URLPath_KeymanDeveloperDocumentation = '/go/developer/'+SKeymanVersion+'/docs';
URLPath_KeymanDeveloperHome = '/go/developer/'+SKeymanVersion+'/home';
URLPath_KeymanHome = '/go/desktop/'+SKeymanVersion+'/home';
URLPath_ArchivedDownloads = '/go/desktop/'+SKeymanVersion+'/archived-downloads';
URLPath_Support = '/go/'+SKeymanVersion+'/support';
URLPath_Privacy = '/go/'+SKeymanVersion+'/privacy';
URLPath_Community = '/go/'+SKeymanVersion+'/community';
@ -65,10 +67,17 @@ function MakeAPIURL(path: string): string;
function MakeKeymanURL(const path: string): string;
function DefaultServersXMLTags: string;
implementation
uses
DebugPaths, ErrorControlledRegistry, RegistryKeys, Windows,
System.SysUtils,
Winapi.Windows,
DebugPaths,
ErrorControlledRegistry,
RegistryKeys,
utilxml,
VersionInfo;
const
@ -133,4 +142,12 @@ begin
Result := API_Protocol + '://' + API_Server + path;
end;
function DefaultServersXMLTags: string;
begin
Result := Format('<keyman-com>%s</keyman-com><api-keyman-com>%s</api-keyman-com>', [
XMLEncode(KeymanCom_Protocol_Server),
XMLEncode(MakeAPIURL(''))
]);
end;
end.