mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-04 22:21:23 +12:00
fixed #11: Added yourls.org url shortener support
This commit is contained in:
parent
bbfc9b7017
commit
d256efdb44
|
@ -857,6 +857,15 @@ public UploadResult ShortenURL(string url)
|
||||||
case UrlShortenerType.TURL:
|
case UrlShortenerType.TURL:
|
||||||
urlShortener = new TurlURLShortener();
|
urlShortener = new TurlURLShortener();
|
||||||
break;
|
break;
|
||||||
|
case UrlShortenerType.YOURLS:
|
||||||
|
urlShortener = new YourlsURLShortener
|
||||||
|
{
|
||||||
|
APIURL = Program.UploadersConfig.YourlsAPIURL,
|
||||||
|
Signature = Program.UploadersConfig.YourlsSignature,
|
||||||
|
Username = Program.UploadersConfig.YourlsUsername,
|
||||||
|
Password = Program.UploadersConfig.YourlsPassword
|
||||||
|
};
|
||||||
|
break;
|
||||||
case UrlShortenerType.CustomURLShortener:
|
case UrlShortenerType.CustomURLShortener:
|
||||||
if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomURLShortenerSelected))
|
if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomURLShortenerSelected))
|
||||||
{
|
{
|
||||||
|
|
|
@ -200,6 +200,13 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
|
||||||
public AccountType GoogleURLShortenerAccountType = AccountType.Anonymous;
|
public AccountType GoogleURLShortenerAccountType = AccountType.Anonymous;
|
||||||
public OAuth2Info GoogleURLShortenerOAuth2Info = null;
|
public OAuth2Info GoogleURLShortenerOAuth2Info = null;
|
||||||
|
|
||||||
|
// yourls.org
|
||||||
|
|
||||||
|
public string YourlsAPIURL = "http://yoursite.com/yourls-api.php";
|
||||||
|
public string YourlsSignature = string.Empty;
|
||||||
|
public string YourlsUsername = string.Empty;
|
||||||
|
public string YourlsPassword = string.Empty;
|
||||||
|
|
||||||
#endregion URL shorteners
|
#endregion URL shorteners
|
||||||
|
|
||||||
#region Social networking services
|
#region Social networking services
|
||||||
|
|
|
@ -129,6 +129,8 @@ public enum UrlShortenerType
|
||||||
TINYURL,
|
TINYURL,
|
||||||
[Description("turl.ca")]
|
[Description("turl.ca")]
|
||||||
TURL,
|
TURL,
|
||||||
|
[Description("yourls.org")]
|
||||||
|
YOURLS,
|
||||||
[Description("Custom URL shortener")]
|
[Description("Custom URL shortener")]
|
||||||
CustomURLShortener
|
CustomURLShortener
|
||||||
}
|
}
|
||||||
|
|
BIN
UploadersLib/Favicons/Yourls.ico
Normal file
BIN
UploadersLib/Favicons/Yourls.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 318 B |
835
UploadersLib/GUI/UploadersConfigForm.Designer.cs
generated
835
UploadersLib/GUI/UploadersConfigForm.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
@ -985,6 +985,31 @@ private void oauth2Bitly_CompleteButtonClicked(string code)
|
||||||
|
|
||||||
#endregion bit.ly
|
#endregion bit.ly
|
||||||
|
|
||||||
|
#region yourls.org
|
||||||
|
|
||||||
|
private void txtYourlsAPIURL_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Config.YourlsAPIURL = txtYourlsAPIURL.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void txtYourlsSignature_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Config.YourlsSignature = txtYourlsSignature.Text;
|
||||||
|
txtYourlsUsername.Enabled = txtYourlsPassword.Enabled = string.IsNullOrEmpty(Config.YourlsSignature);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void txtYourlsUsername_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Config.YourlsUsername = txtYourlsUsername.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void txtYourlsPassword_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Config.YourlsPassword = txtYourlsPassword.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion yourls.org
|
||||||
|
|
||||||
#endregion URL Shorteners
|
#endregion URL Shorteners
|
||||||
|
|
||||||
#region Other Services
|
#region Other Services
|
||||||
|
|
|
@ -82,6 +82,7 @@ private void ControlSettings()
|
||||||
urlShortenersImageList.ColorDepth = ColorDepth.Depth32Bit;
|
urlShortenersImageList.ColorDepth = ColorDepth.Depth32Bit;
|
||||||
urlShortenersImageList.Images.Add("Google", Resources.Google);
|
urlShortenersImageList.Images.Add("Google", Resources.Google);
|
||||||
urlShortenersImageList.Images.Add("Bitly", Resources.Bitly);
|
urlShortenersImageList.Images.Add("Bitly", Resources.Bitly);
|
||||||
|
urlShortenersImageList.Images.Add("Yourls", Resources.Yourls);
|
||||||
tcURLShorteners.ImageList = urlShortenersImageList;
|
tcURLShorteners.ImageList = urlShortenersImageList;
|
||||||
|
|
||||||
ImageList socialNetworkingServicesImageList = new ImageList();
|
ImageList socialNetworkingServicesImageList = new ImageList();
|
||||||
|
@ -114,6 +115,7 @@ private void ControlSettings()
|
||||||
tpPastebin.ImageKey = "Pastebin";
|
tpPastebin.ImageKey = "Pastebin";
|
||||||
tpGoogleURLShortener.ImageKey = "Google";
|
tpGoogleURLShortener.ImageKey = "Google";
|
||||||
tpBitly.ImageKey = "Bitly";
|
tpBitly.ImageKey = "Bitly";
|
||||||
|
tpYourls.ImageKey = "Yourls";
|
||||||
tpTwitter.ImageKey = "Twitter";
|
tpTwitter.ImageKey = "Twitter";
|
||||||
tpMega.ImageKey = "Mega";
|
tpMega.ImageKey = "Mega";
|
||||||
tpGist.ImageKey = "Gist";
|
tpGist.ImageKey = "Gist";
|
||||||
|
@ -404,6 +406,14 @@ public void LoadSettings(UploadersConfig uploadersConfig)
|
||||||
oauth2Bitly.LoginStatus = true;
|
oauth2Bitly.LoginStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// yourls.org
|
||||||
|
|
||||||
|
txtYourlsAPIURL.Text = Config.YourlsAPIURL;
|
||||||
|
txtYourlsSignature.Text = Config.YourlsSignature;
|
||||||
|
txtYourlsUsername.Enabled = txtYourlsPassword.Enabled = string.IsNullOrEmpty(Config.YourlsSignature);
|
||||||
|
txtYourlsUsername.Text = Config.YourlsUsername;
|
||||||
|
txtYourlsPassword.Text = Config.YourlsPassword;
|
||||||
|
|
||||||
#endregion URL Shorteners
|
#endregion URL Shorteners
|
||||||
|
|
||||||
#region Other Services
|
#region Other Services
|
||||||
|
|
10
UploadersLib/Properties/Resources.Designer.cs
generated
10
UploadersLib/Properties/Resources.Designer.cs
generated
|
@ -659,5 +659,15 @@ internal class Resources {
|
||||||
return ((System.Drawing.Icon)(obj));
|
return ((System.Drawing.Icon)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Icon Yourls {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("Yourls", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,4 +298,7 @@
|
||||||
<data name="Gist" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="Gist" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Favicons\Gist.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Favicons\Gist.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Yourls" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\favicons\yourls.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
74
UploadersLib/URLShorteners/YourlsURLShortener.cs
Normal file
74
UploadersLib/URLShorteners/YourlsURLShortener.cs
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
#region License Information (GPL v3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
|
Copyright (C) 2008-2014 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 System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UploadersLib.HelperClasses;
|
||||||
|
|
||||||
|
namespace UploadersLib.URLShorteners
|
||||||
|
{
|
||||||
|
public sealed class YourlsURLShortener : URLShortener
|
||||||
|
{
|
||||||
|
public string APIURL { get; set; }
|
||||||
|
public string Signature { get; set; }
|
||||||
|
public string Username { get; set; }
|
||||||
|
public string Password { get; set; }
|
||||||
|
|
||||||
|
public override UploadResult ShortenURL(string url)
|
||||||
|
{
|
||||||
|
UploadResult result = new UploadResult { URL = url };
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(url))
|
||||||
|
{
|
||||||
|
Dictionary<string, string> arguments = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Signature))
|
||||||
|
{
|
||||||
|
arguments.Add("signature", Signature);
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
|
||||||
|
{
|
||||||
|
arguments.Add("username", Username);
|
||||||
|
arguments.Add("password", Password);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Signature or Username/Password is missing.");
|
||||||
|
}
|
||||||
|
|
||||||
|
arguments.Add("action", "shorturl");
|
||||||
|
arguments.Add("url", url);
|
||||||
|
//arguments.Add("keyword", "");
|
||||||
|
//arguments.Add("title", "");
|
||||||
|
arguments.Add("format", "simple");
|
||||||
|
|
||||||
|
result.Response = SendGetRequest(APIURL, arguments);
|
||||||
|
result.ShortenedURL = result.Response;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -301,6 +301,7 @@
|
||||||
<Compile Include="URLShorteners\TinyURLShortener.cs" />
|
<Compile Include="URLShorteners\TinyURLShortener.cs" />
|
||||||
<Compile Include="URLShorteners\TurlURLShortener.cs" />
|
<Compile Include="URLShorteners\TurlURLShortener.cs" />
|
||||||
<Compile Include="ImageUploaders\MediaCrushUploader.cs" />
|
<Compile Include="ImageUploaders\MediaCrushUploader.cs" />
|
||||||
|
<Compile Include="URLShorteners\YourlsURLShortener.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="ApiKeys\ApiKeysUI.resx">
|
<EmbeddedResource Include="ApiKeys\ApiKeysUI.resx">
|
||||||
|
@ -372,6 +373,7 @@
|
||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="Favicons\Yourls.ico" />
|
||||||
<None Include="Resources\gist.ico" />
|
<None Include="Resources\gist.ico" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<EmbeddedResource Include="ApiKeys\jira_sharex.pfx" />
|
<EmbeddedResource Include="ApiKeys\jira_sharex.pfx" />
|
||||||
|
|
Loading…
Reference in a new issue