mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 09:17:36 +13:00
Add Self-Hosted Polr support
This commit is contained in:
parent
ef8b070c76
commit
4aa71f9bc7
11 changed files with 6448 additions and 1600 deletions
|
@ -168,6 +168,8 @@ public enum UrlShortenerType
|
||||||
VURL,
|
VURL,
|
||||||
[Description("2.gp")]
|
[Description("2.gp")]
|
||||||
TwoGP,
|
TwoGP,
|
||||||
|
[Description("Polr")]
|
||||||
|
Polr,
|
||||||
CustomURLShortener // Localized
|
CustomURLShortener // Localized
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
ShareX.UploadersLib/Favicons/Polr.ico
Normal file
BIN
ShareX.UploadersLib/Favicons/Polr.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
File diff suppressed because it is too large
Load diff
|
@ -116,6 +116,7 @@ private void FormSettings()
|
||||||
AddIconToTab(tpLambda, Resources.Lambda);
|
AddIconToTab(tpLambda, Resources.Lambda);
|
||||||
AddIconToTab(tpUp1, Resources.Up1);
|
AddIconToTab(tpUp1, Resources.Up1);
|
||||||
AddIconToTab(tpOneTimeSecret, Resources.OneTimeSecret);
|
AddIconToTab(tpOneTimeSecret, Resources.OneTimeSecret);
|
||||||
|
AddIconToTab(tpPolr, Resources.Polr);
|
||||||
|
|
||||||
tcFileUploaders.TabPages.Remove(tpHubic);
|
tcFileUploaders.TabPages.Remove(tpHubic);
|
||||||
|
|
||||||
|
@ -2190,6 +2191,20 @@ private void txtCoinURLUUID_TextChanged(object sender, EventArgs e)
|
||||||
|
|
||||||
#endregion CoinURL
|
#endregion CoinURL
|
||||||
|
|
||||||
|
#region Polr
|
||||||
|
|
||||||
|
private void txtPolrAPIHostname_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Config.PolrAPIHostname = txtPolrAPIHostname.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void txtPolrAPIKey_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Config.PolrAPIKey = txtPolrAPIKey.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Polr
|
||||||
|
|
||||||
#endregion URL Shorteners
|
#endregion URL Shorteners
|
||||||
|
|
||||||
#region Other Uploaders
|
#region Other Uploaders
|
||||||
|
|
File diff suppressed because it is too large
Load diff
10
ShareX.UploadersLib/Properties/Resources.Designer.cs
generated
10
ShareX.UploadersLib/Properties/Resources.Designer.cs
generated
|
@ -846,6 +846,16 @@ internal static System.Drawing.Icon Picasa {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Icon Polr {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("Polr", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -470,4 +470,7 @@ Created folders:</value>
|
||||||
<data name="OneTimeSecret" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="OneTimeSecret" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Favicons\OneTimeSecret.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Favicons\OneTimeSecret.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Polr" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Favicons\Polr.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -287,6 +287,7 @@
|
||||||
<Compile Include="TextUploaders\Slexy.cs" />
|
<Compile Include="TextUploaders\Slexy.cs" />
|
||||||
<Compile Include="Uploader.cs" />
|
<Compile Include="Uploader.cs" />
|
||||||
<Compile Include="URLShortener.cs" />
|
<Compile Include="URLShortener.cs" />
|
||||||
|
<Compile Include="URLShorteners\PolrURLShortener.cs" />
|
||||||
<Compile Include="URLShorteners\TwoGPURLShortener.cs" />
|
<Compile Include="URLShorteners\TwoGPURLShortener.cs" />
|
||||||
<Compile Include="URLShorteners\AdFlyURLShortener.cs" />
|
<Compile Include="URLShorteners\AdFlyURLShortener.cs" />
|
||||||
<Compile Include="URLShorteners\BitlyURLShortener.cs" />
|
<Compile Include="URLShorteners\BitlyURLShortener.cs" />
|
||||||
|
@ -706,6 +707,7 @@
|
||||||
<None Include="Favicons\Mega.ico" />
|
<None Include="Favicons\Mega.ico" />
|
||||||
<None Include="Favicons\Picasa.ico" />
|
<None Include="Favicons\Picasa.ico" />
|
||||||
<None Include="Favicons\OneTimeSecret.ico" />
|
<None Include="Favicons\OneTimeSecret.ico" />
|
||||||
|
<None Include="Favicons\Polr.ico" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Resources\server-network.png" />
|
<None Include="Resources\server-network.png" />
|
||||||
<None Include="Resources\mail.png" />
|
<None Include="Resources\mail.png" />
|
||||||
|
|
62
ShareX.UploadersLib/URLShorteners/PolrURLShortener.cs
Normal file
62
ShareX.UploadersLib/URLShorteners/PolrURLShortener.cs
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
#region License Information (GPL v3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
|
Copyright © 2007-2015 ShareX Developers
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using ShareX.HelpersLib;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ShareX.UploadersLib.URLShorteners
|
||||||
|
{
|
||||||
|
public sealed class PolrURLShortener : URLShortener
|
||||||
|
{
|
||||||
|
public string API_KEY { get; set; }
|
||||||
|
|
||||||
|
public string API_HOST { get; set; }
|
||||||
|
|
||||||
|
public override UploadResult ShortenURL(string url)
|
||||||
|
{
|
||||||
|
UploadResult result = new UploadResult { URL = url };
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(API_HOST))
|
||||||
|
{
|
||||||
|
API_HOST = "https://polr.me";
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
|
args.Add("apikey", API_KEY);
|
||||||
|
args.Add("action", "shorten");
|
||||||
|
args.Add("url", url);
|
||||||
|
|
||||||
|
string response = SendRequest(HttpMethod.GET, URLHelpers.CombineURL(API_HOST, "api.php"), args);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(response))
|
||||||
|
{
|
||||||
|
result.ShortenedURL = response;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -287,6 +287,10 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
|
||||||
// coinurl.com
|
// coinurl.com
|
||||||
public string CoinURLUUID = string.Empty;
|
public string CoinURLUUID = string.Empty;
|
||||||
|
|
||||||
|
// polr
|
||||||
|
public string PolrAPIHostname = string.Empty;
|
||||||
|
public string PolrAPIKey = string.Empty;
|
||||||
|
|
||||||
#endregion URL shorteners
|
#endregion URL shorteners
|
||||||
|
|
||||||
#region URL sharing services
|
#region URL sharing services
|
||||||
|
@ -446,6 +450,8 @@ public bool IsValid(UrlShortenerType destination)
|
||||||
return !string.IsNullOrEmpty(LnkUAPIKEY);
|
return !string.IsNullOrEmpty(LnkUAPIKEY);
|
||||||
case UrlShortenerType.CoinURL:
|
case UrlShortenerType.CoinURL:
|
||||||
return !string.IsNullOrEmpty(CoinURLUUID);
|
return !string.IsNullOrEmpty(CoinURLUUID);
|
||||||
|
case UrlShortenerType.Polr:
|
||||||
|
return !string.IsNullOrEmpty(PolrAPIKey);
|
||||||
case UrlShortenerType.CustomURLShortener:
|
case UrlShortenerType.CustomURLShortener:
|
||||||
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomURLShortenerSelected);
|
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomURLShortenerSelected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1125,6 +1125,13 @@ public UploadResult ShortenURL(string url)
|
||||||
case UrlShortenerType.TwoGP:
|
case UrlShortenerType.TwoGP:
|
||||||
urlShortener = new TwoGPURLShortener();
|
urlShortener = new TwoGPURLShortener();
|
||||||
break;
|
break;
|
||||||
|
case UrlShortenerType.Polr:
|
||||||
|
urlShortener = new PolrURLShortener
|
||||||
|
{
|
||||||
|
API_HOST = Program.UploadersConfig.PolrAPIHostname,
|
||||||
|
API_KEY = Program.UploadersConfig.PolrAPIKey
|
||||||
|
};
|
||||||
|
break;
|
||||||
case UrlShortenerType.CustomURLShortener:
|
case UrlShortenerType.CustomURLShortener:
|
||||||
CustomUploaderItem customUploader = GetCustomUploader(Program.UploadersConfig.CustomURLShortenerSelected);
|
CustomUploaderItem customUploader = GetCustomUploader(Program.UploadersConfig.CustomURLShortenerSelected);
|
||||||
if (customUploader != null)
|
if (customUploader != null)
|
||||||
|
|
Loading…
Reference in a new issue