mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-18 06:15:49 +02:00
Open TweetDuck guide links directly in the app
This commit is contained in:
parent
15bc6c1d73
commit
b2f3b245b7
Core
@ -8,14 +8,35 @@
|
|||||||
using TweetDuck.Core.Handling.General;
|
using TweetDuck.Core.Handling.General;
|
||||||
using TweetDuck.Core.Other.Analytics;
|
using TweetDuck.Core.Other.Analytics;
|
||||||
using TweetDuck.Core.Utils;
|
using TweetDuck.Core.Utils;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace TweetDuck.Core.Other{
|
namespace TweetDuck.Core.Other{
|
||||||
sealed partial class FormGuide : Form{
|
sealed partial class FormGuide : Form{
|
||||||
private const string GuideUrl = "https://tweetduck.chylex.com/guide/v2/";
|
private const string GuideUrl = "https://tweetduck.chylex.com/guide/v2/";
|
||||||
|
private const string GuidePathRegex = @"^guide(?:/v\d+)?(?:/(#.*))?";
|
||||||
|
|
||||||
|
public static bool CheckGuideUrl(string url, out string hash){
|
||||||
|
if (!url.Contains("//tweetduck.chylex.com/guide")){
|
||||||
|
hash = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string path = url.Substring(url.IndexOf("/guide")+1);
|
||||||
|
Match match = Regex.Match(path, GuidePathRegex);
|
||||||
|
|
||||||
|
if (match.Success){
|
||||||
|
hash = match.Groups[1].Value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
hash = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private readonly ChromiumWebBrowser browser;
|
private readonly ChromiumWebBrowser browser;
|
||||||
|
|
||||||
public FormGuide(){
|
public FormGuide(string hash = null){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Text = Program.BrandName+" Guide";
|
Text = Program.BrandName+" Guide";
|
||||||
@ -29,7 +50,7 @@ public FormGuide(){
|
|||||||
owner.TriggerAnalyticsEvent(AnalyticsFile.Event.OpenGuide);
|
owner.TriggerAnalyticsEvent(AnalyticsFile.Event.OpenGuide);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.browser = new ChromiumWebBrowser(GuideUrl){
|
this.browser = new ChromiumWebBrowser(GuideUrl+(hash ?? string.Empty)){
|
||||||
MenuHandler = new ContextMenuGuide(),
|
MenuHandler = new ContextMenuGuide(),
|
||||||
JsDialogHandler = new JavaScriptDialogHandler(),
|
JsDialogHandler = new JavaScriptDialogHandler(),
|
||||||
LifeSpanHandler = new LifeSpanHandler(),
|
LifeSpanHandler = new LifeSpanHandler(),
|
||||||
|
@ -70,7 +70,13 @@ public static void OpenExternalBrowser(string url){
|
|||||||
|
|
||||||
switch(CheckUrl(url)){
|
switch(CheckUrl(url)){
|
||||||
case UrlCheckResult.Fine:
|
case UrlCheckResult.Fine:
|
||||||
WindowsUtils.OpenAssociatedProgram(url);
|
if (FormGuide.CheckGuideUrl(url, out string hash)){
|
||||||
|
new FormGuide(hash).Show();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
WindowsUtils.OpenAssociatedProgram(url);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UrlCheckResult.Tracking:
|
case UrlCheckResult.Tracking:
|
||||||
|
Loading…
Reference in New Issue
Block a user