mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added Adf.ly URL Shortener
This commit is contained in:
parent
3d2b4a269f
commit
4bb877ffcc
8 changed files with 122 additions and 2 deletions
|
@ -30,7 +30,9 @@
|
|||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=ShareX/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="ShareX"><CSReformatCode>True</CSReformatCode><CSOptimizeUsings><OptimizeUsings>False</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><XAMLCollapseEmptyTags>False</XAMLCollapseEmptyTags></Profile></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">ShareX</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">ShareX</s:String>
|
||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AROUND_AUTO_PROPERTY/@EntryValue">0</s:Int64>
|
||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AROUND_FIELD/@EntryValue">0</s:Int64>
|
||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AROUND_PROPERTY/@EntryValue">0</s:Int64>
|
||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_CODE/@EntryValue">1</s:Int64>
|
||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
|
||||
|
@ -42,4 +44,5 @@
|
|||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_SIZEOF_PARENTHESES/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_BEFORE_TYPEOF_PARENTHESES/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINES/@EntryValue">False</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINES/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
|
@ -981,6 +981,13 @@ public UploadResult ShortenURL(string url)
|
|||
urlShortener = new CustomURLShortener(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomURLShortenerSelected]);
|
||||
}
|
||||
break;
|
||||
case UrlShortenerType.adfly:
|
||||
urlShortener = new AdflyURLShortener
|
||||
{
|
||||
APIKEY = Program.UploadersConfig.adflyAPIKEY,
|
||||
APIUID = Program.UploadersConfig.adflyAPIUID
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
if (urlShortener != null)
|
||||
|
|
|
@ -136,7 +136,9 @@ public enum UrlShortenerType
|
|||
[Description("nl.cm")]
|
||||
NLCM,
|
||||
[Description("Custom URL shortener")]
|
||||
CustomURLShortener
|
||||
CustomURLShortener,
|
||||
[Description("adf.ly")]
|
||||
adfly
|
||||
}
|
||||
|
||||
[Description("URL sharing services"), DefaultValue(URLSharingServices.Twitter)]
|
||||
|
|
62
UploadersLib/Forms/UploadersConfigForm.Designer.cs
generated
62
UploadersLib/Forms/UploadersConfigForm.Designer.cs
generated
|
@ -373,6 +373,11 @@ private void InitializeComponent()
|
|||
this.ttlvMain = new HelpersLib.TabToListView();
|
||||
this.lblWidthHint = new System.Windows.Forms.Label();
|
||||
this.actRapidShareAccountType = new UploadersLib.AccountTypeControl();
|
||||
this.tpAdfly = new System.Windows.Forms.TabPage();
|
||||
this.txtAdflyAPIUID = new System.Windows.Forms.TextBox();
|
||||
this.lblAdflyAPIUID = new System.Windows.Forms.Label();
|
||||
this.txtAdflyAPIKEY = new System.Windows.Forms.TextBox();
|
||||
this.lblAdflyAPIKEY = new System.Windows.Forms.Label();
|
||||
this.tpOtherUploaders.SuspendLayout();
|
||||
this.tcOtherUploaders.SuspendLayout();
|
||||
this.tpCustomUploaders.SuspendLayout();
|
||||
|
@ -428,6 +433,7 @@ private void InitializeComponent()
|
|||
this.gbPhotobucketUserAccount.SuspendLayout();
|
||||
this.tpPicasa.SuspendLayout();
|
||||
this.tcUploaders.SuspendLayout();
|
||||
this.tpAdfly.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtRapidSharePremiumUserName
|
||||
|
@ -1110,6 +1116,7 @@ private void InitializeComponent()
|
|||
this.tcURLShorteners.Controls.Add(this.tpBitly);
|
||||
this.tcURLShorteners.Controls.Add(this.tpGoogleURLShortener);
|
||||
this.tcURLShorteners.Controls.Add(this.tpYourls);
|
||||
this.tcURLShorteners.Controls.Add(this.tpAdfly);
|
||||
this.tcURLShorteners.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tcURLShorteners.Location = new System.Drawing.Point(3, 3);
|
||||
this.tcURLShorteners.Name = "tcURLShorteners";
|
||||
|
@ -3993,6 +4000,55 @@ private void InitializeComponent()
|
|||
this.actRapidShareAccountType.Size = new System.Drawing.Size(214, 29);
|
||||
this.actRapidShareAccountType.TabIndex = 16;
|
||||
//
|
||||
// tpAdfly
|
||||
//
|
||||
this.tpAdfly.Controls.Add(this.txtAdflyAPIUID);
|
||||
this.tpAdfly.Controls.Add(this.lblAdflyAPIUID);
|
||||
this.tpAdfly.Controls.Add(this.txtAdflyAPIKEY);
|
||||
this.tpAdfly.Controls.Add(this.lblAdflyAPIKEY);
|
||||
this.tpAdfly.Location = new System.Drawing.Point(4, 22);
|
||||
this.tpAdfly.Name = "tpAdfly";
|
||||
this.tpAdfly.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tpAdfly.Size = new System.Drawing.Size(972, 493);
|
||||
this.tpAdfly.TabIndex = 3;
|
||||
this.tpAdfly.Text = "adf.ly";
|
||||
this.tpAdfly.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// txtAdflyAPIUID
|
||||
//
|
||||
this.txtAdflyAPIUID.Location = new System.Drawing.Point(70, 58);
|
||||
this.txtAdflyAPIUID.Name = "txtAdflyAPIUID";
|
||||
this.txtAdflyAPIUID.Size = new System.Drawing.Size(224, 20);
|
||||
this.txtAdflyAPIUID.TabIndex = 7;
|
||||
this.txtAdflyAPIUID.UseSystemPasswordChar = true;
|
||||
this.txtAdflyAPIUID.TextChanged += new System.EventHandler(this.txtAdflyAPIUID_TextChanged);
|
||||
//
|
||||
// lblAdflyAPIUID
|
||||
//
|
||||
this.lblAdflyAPIUID.AutoSize = true;
|
||||
this.lblAdflyAPIUID.Location = new System.Drawing.Point(6, 62);
|
||||
this.lblAdflyAPIUID.Name = "lblAdflyAPIUID";
|
||||
this.lblAdflyAPIUID.Size = new System.Drawing.Size(49, 13);
|
||||
this.lblAdflyAPIUID.TabIndex = 6;
|
||||
this.lblAdflyAPIUID.Text = "API UID:";
|
||||
//
|
||||
// txtAdflyAPIKEY
|
||||
//
|
||||
this.txtAdflyAPIKEY.Location = new System.Drawing.Point(70, 26);
|
||||
this.txtAdflyAPIKEY.Name = "txtAdflyAPIKEY";
|
||||
this.txtAdflyAPIKEY.Size = new System.Drawing.Size(224, 20);
|
||||
this.txtAdflyAPIKEY.TabIndex = 5;
|
||||
this.txtAdflyAPIKEY.TextChanged += new System.EventHandler(this.txtAdflyAPIKEY_TextChanged);
|
||||
//
|
||||
// lblAdflyAPIKEY
|
||||
//
|
||||
this.lblAdflyAPIKEY.AutoSize = true;
|
||||
this.lblAdflyAPIKEY.Location = new System.Drawing.Point(6, 30);
|
||||
this.lblAdflyAPIKEY.Name = "lblAdflyAPIKEY";
|
||||
this.lblAdflyAPIKEY.Size = new System.Drawing.Size(51, 13);
|
||||
this.lblAdflyAPIKEY.TabIndex = 4;
|
||||
this.lblAdflyAPIKEY.Text = "API KEY:";
|
||||
//
|
||||
// UploadersConfigForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -4101,6 +4157,7 @@ private void InitializeComponent()
|
|||
this.tpPicasa.ResumeLayout(false);
|
||||
this.tpPicasa.PerformLayout();
|
||||
this.tcUploaders.ResumeLayout(false);
|
||||
this.tpAdfly.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
@ -4452,5 +4509,10 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.Label lblOwnCloudHost;
|
||||
private System.Windows.Forms.CheckBox cbOwnCloudCreateShare;
|
||||
private System.Windows.Forms.CheckBox cbOwnCloudDirectLink;
|
||||
private System.Windows.Forms.TabPage tpAdfly;
|
||||
private System.Windows.Forms.TextBox txtAdflyAPIUID;
|
||||
private System.Windows.Forms.Label lblAdflyAPIUID;
|
||||
private System.Windows.Forms.TextBox txtAdflyAPIKEY;
|
||||
private System.Windows.Forms.Label lblAdflyAPIKEY;
|
||||
}
|
||||
}
|
|
@ -515,6 +515,7 @@ public void LoadSettings(UploadersConfig uploadersConfig)
|
|||
txtYourlsUsername.Text = Config.YourlsUsername;
|
||||
txtYourlsPassword.Text = Config.YourlsPassword;
|
||||
|
||||
|
||||
#endregion URL Shorteners
|
||||
|
||||
#region Other Services
|
||||
|
@ -1847,6 +1848,20 @@ private void txtYourlsPassword_TextChanged(object sender, EventArgs e)
|
|||
|
||||
#endregion yourls.org
|
||||
|
||||
#region adf.ly
|
||||
|
||||
private void txtAdflyAPIKEY_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
Config.adflyAPIKEY = txtAdflyAPIKEY.Text;
|
||||
}
|
||||
|
||||
private void txtAdflyAPIUID_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
Config.adflyAPIUID = txtAdflyAPIUID.Text;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion URL Shorteners
|
||||
|
||||
#region Other Services
|
||||
|
|
24
UploadersLib/URLShorteners/AdflyURLShortener.cs
Normal file
24
UploadersLib/URLShorteners/AdflyURLShortener.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace UploadersLib.URLShorteners
|
||||
{
|
||||
public class AdflyURLShortener : URLShortener
|
||||
{
|
||||
public string APIKEY { get; set; }
|
||||
public string APIUID { get; set; }
|
||||
|
||||
private string URL = "http://api.adf.ly/api.php?key={0}&uid={1}&advert_type=int&domain=adf.ly&url={2}";
|
||||
|
||||
public override UploadResult ShortenURL(string url)
|
||||
{
|
||||
UploadResult result = new UploadResult { URL = url };
|
||||
var response = SendRequest(HttpMethod.GET, String.Format(URL, APIKEY, APIUID, url));
|
||||
|
||||
if (response != "error")
|
||||
result.ShortenedURL = response;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -234,6 +234,10 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
|
|||
public string YourlsUsername = string.Empty;
|
||||
public string YourlsPassword = string.Empty;
|
||||
|
||||
// adf.ly
|
||||
public string adflyAPIKEY = String.Empty;
|
||||
public string adflyAPIUID = String.Empty;
|
||||
|
||||
#endregion URL shorteners
|
||||
|
||||
#region URL sharing services
|
||||
|
@ -383,6 +387,8 @@ public bool IsValid(UrlShortenerType destination)
|
|||
return !string.IsNullOrEmpty(YourlsAPIURL) && (!string.IsNullOrEmpty(YourlsSignature) || (!string.IsNullOrEmpty(YourlsUsername) && !string.IsNullOrEmpty(YourlsPassword)));
|
||||
case UrlShortenerType.CustomURLShortener:
|
||||
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomURLShortenerSelected);
|
||||
case UrlShortenerType.adfly:
|
||||
return !string.IsNullOrEmpty(adflyAPIKEY) && !string.IsNullOrEmpty(adflyAPIUID);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -278,6 +278,7 @@
|
|||
<Compile Include="TextUploaders\Slexy.cs" />
|
||||
<Compile Include="Uploader.cs" />
|
||||
<Compile Include="URLShortener.cs" />
|
||||
<Compile Include="URLShorteners\AdflyURLShortener.cs" />
|
||||
<Compile Include="URLShorteners\BitlyURLShortener.cs" />
|
||||
<Compile Include="URLShorteners\CustomURLShortener.cs" />
|
||||
<Compile Include="URLShorteners\GoogleURLShortener.cs" />
|
||||
|
|
Loading…
Reference in a new issue