Chevereto direct URL support

This commit is contained in:
Jaex 2014-09-17 22:33:11 +03:00
parent 4dcc9a31d3
commit a6a1a0e89e
5 changed files with 74 additions and 49 deletions

View file

@ -718,7 +718,10 @@ public UploadResult UploadImage(Stream stream, string fileName)
imageUploader = new Twitter(twitterOAuth); imageUploader = new Twitter(twitterOAuth);
break; break;
case ImageDestination.Chevereto: case ImageDestination.Chevereto:
imageUploader = new Chevereto(Program.UploadersConfig.CheveretoAPIKey, Program.UploadersConfig.CheveretoWebsite); imageUploader = new Chevereto(Program.UploadersConfig.CheveretoAPIKey, Program.UploadersConfig.CheveretoWebsite)
{
DirectURL = Program.UploadersConfig.CheveretoDirectURL
};
break; break;
case ImageDestination.CustomImageUploader: case ImageDestination.CustomImageUploader:
if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomImageUploaderSelected)) if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomImageUploaderSelected))

View file

@ -402,15 +402,16 @@ private void InitializeComponent()
this.btnPicasaRefreshAlbumList = new System.Windows.Forms.Button(); this.btnPicasaRefreshAlbumList = new System.Windows.Forms.Button();
this.oauth2Picasa = new UploadersLib.OAuthControl(); this.oauth2Picasa = new UploadersLib.OAuthControl();
this.tpChevereto = new System.Windows.Forms.TabPage(); this.tpChevereto = new System.Windows.Forms.TabPage();
this.lblCheveretoWebsiteTip = new System.Windows.Forms.Label();
this.lblCheveretoWebsite = new System.Windows.Forms.Label();
this.txtCheveretoWebsite = new System.Windows.Forms.TextBox();
this.txtCheveretoAPIKey = new System.Windows.Forms.TextBox();
this.lblCheveretoAPIKey = new System.Windows.Forms.Label();
this.tcUploaders = new System.Windows.Forms.TabControl(); this.tcUploaders = new System.Windows.Forms.TabControl();
this.lblWidthHint = new System.Windows.Forms.Label(); this.lblWidthHint = new System.Windows.Forms.Label();
this.ttlvMain = new HelpersLib.TabToListView(); this.ttlvMain = new HelpersLib.TabToListView();
this.actRapidShareAccountType = new UploadersLib.AccountTypeControl(); this.actRapidShareAccountType = new UploadersLib.AccountTypeControl();
this.lblCheveretoAPIKey = new System.Windows.Forms.Label(); this.cbCheveretoDirectURL = new System.Windows.Forms.CheckBox();
this.txtCheveretoAPIKey = new System.Windows.Forms.TextBox();
this.txtCheveretoWebsite = new System.Windows.Forms.TextBox();
this.lblCheveretoWebsite = new System.Windows.Forms.Label();
this.lblCheveretoWebsiteTip = new System.Windows.Forms.Label();
this.tpOtherUploaders.SuspendLayout(); this.tpOtherUploaders.SuspendLayout();
this.tcOtherUploaders.SuspendLayout(); this.tcOtherUploaders.SuspendLayout();
this.tpCustomUploaders.SuspendLayout(); this.tpCustomUploaders.SuspendLayout();
@ -4331,6 +4332,7 @@ private void InitializeComponent()
// //
// tpChevereto // tpChevereto
// //
this.tpChevereto.Controls.Add(this.cbCheveretoDirectURL);
this.tpChevereto.Controls.Add(this.lblCheveretoWebsiteTip); this.tpChevereto.Controls.Add(this.lblCheveretoWebsiteTip);
this.tpChevereto.Controls.Add(this.lblCheveretoWebsite); this.tpChevereto.Controls.Add(this.lblCheveretoWebsite);
this.tpChevereto.Controls.Add(this.txtCheveretoWebsite); this.tpChevereto.Controls.Add(this.txtCheveretoWebsite);
@ -4344,6 +4346,49 @@ private void InitializeComponent()
this.tpChevereto.Text = "Chevereto"; this.tpChevereto.Text = "Chevereto";
this.tpChevereto.UseVisualStyleBackColor = true; this.tpChevereto.UseVisualStyleBackColor = true;
// //
// lblCheveretoWebsiteTip
//
this.lblCheveretoWebsiteTip.AutoSize = true;
this.lblCheveretoWebsiteTip.Location = new System.Drawing.Point(314, 40);
this.lblCheveretoWebsiteTip.Name = "lblCheveretoWebsiteTip";
this.lblCheveretoWebsiteTip.Size = new System.Drawing.Size(74, 13);
this.lblCheveretoWebsiteTip.TabIndex = 4;
this.lblCheveretoWebsiteTip.Text = "/api/1/upload";
//
// lblCheveretoWebsite
//
this.lblCheveretoWebsite.AutoSize = true;
this.lblCheveretoWebsite.Location = new System.Drawing.Point(16, 40);
this.lblCheveretoWebsite.Name = "lblCheveretoWebsite";
this.lblCheveretoWebsite.Size = new System.Drawing.Size(49, 13);
this.lblCheveretoWebsite.TabIndex = 3;
this.lblCheveretoWebsite.Text = "Website:";
//
// txtCheveretoWebsite
//
this.txtCheveretoWebsite.Location = new System.Drawing.Point(72, 36);
this.txtCheveretoWebsite.Name = "txtCheveretoWebsite";
this.txtCheveretoWebsite.Size = new System.Drawing.Size(240, 20);
this.txtCheveretoWebsite.TabIndex = 2;
this.txtCheveretoWebsite.TextChanged += new System.EventHandler(this.txtCheveretoWebsite_TextChanged);
//
// txtCheveretoAPIKey
//
this.txtCheveretoAPIKey.Location = new System.Drawing.Point(72, 12);
this.txtCheveretoAPIKey.Name = "txtCheveretoAPIKey";
this.txtCheveretoAPIKey.Size = new System.Drawing.Size(240, 20);
this.txtCheveretoAPIKey.TabIndex = 1;
this.txtCheveretoAPIKey.TextChanged += new System.EventHandler(this.txtCheveretoAPIKey_TextChanged);
//
// lblCheveretoAPIKey
//
this.lblCheveretoAPIKey.AutoSize = true;
this.lblCheveretoAPIKey.Location = new System.Drawing.Point(16, 16);
this.lblCheveretoAPIKey.Name = "lblCheveretoAPIKey";
this.lblCheveretoAPIKey.Size = new System.Drawing.Size(47, 13);
this.lblCheveretoAPIKey.TabIndex = 0;
this.lblCheveretoAPIKey.Text = "API key:";
//
// tcUploaders // tcUploaders
// //
this.tcUploaders.Controls.Add(this.tpImageUploaders); this.tcUploaders.Controls.Add(this.tpImageUploaders);
@ -4388,48 +4433,16 @@ private void InitializeComponent()
this.actRapidShareAccountType.Size = new System.Drawing.Size(214, 29); this.actRapidShareAccountType.Size = new System.Drawing.Size(214, 29);
this.actRapidShareAccountType.TabIndex = 16; this.actRapidShareAccountType.TabIndex = 16;
// //
// lblCheveretoAPIKey // cbCheveretoDirectURL
// //
this.lblCheveretoAPIKey.AutoSize = true; this.cbCheveretoDirectURL.AutoSize = true;
this.lblCheveretoAPIKey.Location = new System.Drawing.Point(16, 16); this.cbCheveretoDirectURL.Location = new System.Drawing.Point(16, 64);
this.lblCheveretoAPIKey.Name = "lblCheveretoAPIKey"; this.cbCheveretoDirectURL.Name = "cbCheveretoDirectURL";
this.lblCheveretoAPIKey.Size = new System.Drawing.Size(47, 13); this.cbCheveretoDirectURL.Size = new System.Drawing.Size(79, 17);
this.lblCheveretoAPIKey.TabIndex = 0; this.cbCheveretoDirectURL.TabIndex = 5;
this.lblCheveretoAPIKey.Text = "API key:"; this.cbCheveretoDirectURL.Text = "Direct URL";
// this.cbCheveretoDirectURL.UseVisualStyleBackColor = true;
// txtCheveretoAPIKey this.cbCheveretoDirectURL.CheckedChanged += new System.EventHandler(this.cbCheveretoDirectURL_CheckedChanged);
//
this.txtCheveretoAPIKey.Location = new System.Drawing.Point(72, 12);
this.txtCheveretoAPIKey.Name = "txtCheveretoAPIKey";
this.txtCheveretoAPIKey.Size = new System.Drawing.Size(240, 20);
this.txtCheveretoAPIKey.TabIndex = 1;
this.txtCheveretoAPIKey.TextChanged += new System.EventHandler(this.txtCheveretoAPIKey_TextChanged);
//
// txtCheveretoWebsite
//
this.txtCheveretoWebsite.Location = new System.Drawing.Point(72, 36);
this.txtCheveretoWebsite.Name = "txtCheveretoWebsite";
this.txtCheveretoWebsite.Size = new System.Drawing.Size(240, 20);
this.txtCheveretoWebsite.TabIndex = 2;
this.txtCheveretoWebsite.TextChanged += new System.EventHandler(this.txtCheveretoWebsite_TextChanged);
//
// lblCheveretoWebsite
//
this.lblCheveretoWebsite.AutoSize = true;
this.lblCheveretoWebsite.Location = new System.Drawing.Point(16, 40);
this.lblCheveretoWebsite.Name = "lblCheveretoWebsite";
this.lblCheveretoWebsite.Size = new System.Drawing.Size(49, 13);
this.lblCheveretoWebsite.TabIndex = 3;
this.lblCheveretoWebsite.Text = "Website:";
//
// lblCheveretoWebsiteTip
//
this.lblCheveretoWebsiteTip.AutoSize = true;
this.lblCheveretoWebsiteTip.Location = new System.Drawing.Point(314, 40);
this.lblCheveretoWebsiteTip.Name = "lblCheveretoWebsiteTip";
this.lblCheveretoWebsiteTip.Size = new System.Drawing.Size(74, 13);
this.lblCheveretoWebsiteTip.TabIndex = 4;
this.lblCheveretoWebsiteTip.Text = "/api/1/upload";
// //
// UploadersConfigForm // UploadersConfigForm
// //
@ -4937,6 +4950,7 @@ private void InitializeComponent()
private System.Windows.Forms.Label lblCheveretoWebsite; private System.Windows.Forms.Label lblCheveretoWebsite;
private System.Windows.Forms.TextBox txtCheveretoWebsite; private System.Windows.Forms.TextBox txtCheveretoWebsite;
private System.Windows.Forms.TextBox txtCheveretoAPIKey; private System.Windows.Forms.TextBox txtCheveretoAPIKey;
private System.Windows.Forms.Label lblCheveretoAPIKey; private System.Windows.Forms.Label lblCheveretoAPIKey;
private System.Windows.Forms.CheckBox cbCheveretoDirectURL;
} }
} }

View file

@ -235,6 +235,7 @@ public void LoadSettings(UploadersConfig uploadersConfig)
txtCheveretoAPIKey.Text = Config.CheveretoAPIKey; txtCheveretoAPIKey.Text = Config.CheveretoAPIKey;
txtCheveretoWebsite.Text = Config.CheveretoWebsite; txtCheveretoWebsite.Text = Config.CheveretoWebsite;
cbCheveretoDirectURL.Checked = Config.CheveretoDirectURL;
#endregion Image uploaders #endregion Image uploaders
@ -873,6 +874,11 @@ private void txtCheveretoWebsite_TextChanged(object sender, EventArgs e)
Config.CheveretoWebsite = txtCheveretoWebsite.Text; Config.CheveretoWebsite = txtCheveretoWebsite.Text;
} }
private void cbCheveretoDirectURL_CheckedChanged(object sender, EventArgs e)
{
Config.CheveretoDirectURL = cbCheveretoDirectURL.Checked;
}
#endregion Chevereto #endregion Chevereto
#endregion Image Uploaders #endregion Image Uploaders

View file

@ -37,6 +37,7 @@ public sealed class Chevereto : ImageUploader
{ {
public string APIKey { get; set; } public string APIKey { get; set; }
public string Website { get; set; } public string Website { get; set; }
public bool DirectURL { get; set; }
public Chevereto(string apiKey, string website) public Chevereto(string apiKey, string website)
{ {
@ -61,7 +62,7 @@ public override UploadResult Upload(Stream stream, string fileName)
if (response != null && response.Image != null) if (response != null && response.Image != null)
{ {
result.URL = response.Image.URL; result.URL = DirectURL ? response.Image.URL : response.Image.URL_Viewer;
if (response.Image.Thumb != null) if (response.Image.Thumb != null)
{ {

View file

@ -80,6 +80,7 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
public string CheveretoAPIKey = string.Empty; public string CheveretoAPIKey = string.Empty;
public string CheveretoWebsite = string.Empty; public string CheveretoWebsite = string.Empty;
public bool CheveretoDirectURL = true;
#endregion Image uploaders #endregion Image uploaders