Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Url/Languages/de.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
<system:String x:Key="flowlauncher_plugin_url_plugin_set_tip">Bitte legen Sie Ihren Browser-Pfad fest:</system:String>
<system:String x:Key="flowlauncher_plugin_url_plugin_choose">Wählen</system:String>
<system:String x:Key="flowlauncher_plugin_url_plugin_filter">Anwendung (*.exe)|*.exe|Alle Dateien|*.*</system:String>

<system:String x:Key="flowlauncher_plugin_url_usehttps">https über http bevorzugen</system:String>

</ResourceDictionary>
2 changes: 2 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Url/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
<system:String x:Key="flowlauncher_plugin_url_plugin_set_tip">Please set your browser path:</system:String>
<system:String x:Key="flowlauncher_plugin_url_plugin_choose">Choose</system:String>
<system:String x:Key="flowlauncher_plugin_url_plugin_filter">Application(*.exe)|*.exe|All files|*.*</system:String>

<system:String x:Key="flowlauncher_plugin_url_usehttps">Prefer https over http</system:String>
</ResourceDictionary>
19 changes: 15 additions & 4 deletions Plugins/Flow.Launcher.Plugin.Url/Main.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Controls;

namespace Flow.Launcher.Plugin.Url
{
public class Main : IPlugin, IPluginI18n
public class Main : IPlugin, IPluginI18n, ISettingProvider
{
//based on https://gist.github.com/dperini/729294
private const string urlPattern = "^" +
Expand All @@ -21,7 +22,7 @@
// IP address dotted notation octets
// excludes loopback network 0.0.0.0
// excludes reserved space >= 224.0.0.0
// excludes network & broacast addresses

Check warning on line 25 in Plugins/Flow.Launcher.Plugin.Url/Main.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`broacast` is not a recognized word. (unrecognized-spelling)
// (first & last IP address of each class)
"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
"(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
Expand Down Expand Up @@ -58,13 +59,13 @@
Score = 8,
Action = _ =>
{
if (!raw.ToLower().StartsWith("http"))
if (!raw.StartsWith("http://", StringComparison.OrdinalIgnoreCase) && !raw.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
{
raw = "http://" + raw;
raw = GetHttpPreference() + "://" + raw;
}
try
{
Context.API.OpenUrl(raw);
Context.API.OpenUrl(raw);

return true;
}
Expand All @@ -80,6 +81,11 @@
return new List<Result>(0);
}

private string GetHttpPreference()
{
return _settings.AlwaysOpenWithHttps ? "https": "http";
}

public bool IsURL(string raw)
{
raw = raw.ToLower();
Expand Down Expand Up @@ -113,5 +119,10 @@
{
return Localize.flowlauncher_plugin_url_plugin_description();
}

public Control CreateSettingPanel()
{
return new URLSettings(_settings);
}
}
}
1 change: 1 addition & 0 deletions Plugins/Flow.Launcher.Plugin.Url/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ public class Settings
public string BrowserPath { get; set; }

public bool OpenInNewBrowserWindow { get; set; } = true;
public bool AlwaysOpenWithHttps { get; set; } = false;
}
}
9 changes: 9 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Url/SettingsViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;
using System.Linq;

namespace Flow.Launcher.Plugin.Url;

public class SettingsViewModel(Settings settings) : BaseModel
{
public Settings Settings { get; } = settings;
}
31 changes: 31 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Url/URLSettings.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<UserControl
x:Class="Flow.Launcher.Plugin.Url.URLSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:url="clr-namespace:Flow.Launcher.Plugin.Url"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Url"
d:DataContext="{d:DesignInstance Type=viewModels:SettingsViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

<Grid Margin="{StaticResource SettingPanelMargin}">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<CheckBox
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource flowlauncher_plugin_url_usehttps}"

Check warning on line 28 in Plugins/Flow.Launcher.Plugin.Url/URLSettings.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`usehttps` is not a recognized word. (unrecognized-spelling)
IsChecked="{Binding Settings.AlwaysOpenWithHttps, Mode=TwoWay}" />
</Grid>
</UserControl>
15 changes: 15 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Url/URLSettings.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Windows.Controls;

namespace Flow.Launcher.Plugin.Url;

public partial class URLSettings : UserControl
{
private readonly SettingsViewModel _viewModel;

public URLSettings(Settings settings)
{
_viewModel = new SettingsViewModel(settings);
DataContext = _viewModel;
InitializeComponent();
}
}
Loading