Added support for text upload to pastie.org

This commit is contained in:
QDT 2016-12-07 15:58:45 -08:00
parent 55fa228516
commit 9315a054ca
10 changed files with 1592 additions and 7143 deletions

View file

@ -79,6 +79,8 @@ public enum TextDestination
Hastebin,
[Description("OneTimeSecret")]
OneTimeSecret,
[Description("Pastie")]
Pastie,
CustomTextUploader, // Localized
FileUploader // Localized
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -467,6 +467,8 @@ private void InitializeComponent()
this.lblOneTimeSecretEmail = new System.Windows.Forms.Label();
this.txtOneTimeSecretAPIKey = new System.Windows.Forms.TextBox();
this.txtOneTimeSecretEmail = new System.Windows.Forms.TextBox();
this.tpPastie = new System.Windows.Forms.TabPage();
this.cbPastieIsPublic = new System.Windows.Forms.CheckBox();
this.tpImageUploaders = new System.Windows.Forms.TabPage();
this.tcImageUploaders = new System.Windows.Forms.TabControl();
this.tpImgur = new System.Windows.Forms.TabPage();
@ -625,6 +627,7 @@ private void InitializeComponent()
this.tpUpaste.SuspendLayout();
this.tpHastebin.SuspendLayout();
this.tpOneTimeSecret.SuspendLayout();
this.tpPastie.SuspendLayout();
this.tpImageUploaders.SuspendLayout();
this.tcImageUploaders.SuspendLayout();
this.tpImgur.SuspendLayout();
@ -3529,6 +3532,7 @@ private void InitializeComponent()
this.tcTextUploaders.Controls.Add(this.tpUpaste);
this.tcTextUploaders.Controls.Add(this.tpHastebin);
this.tcTextUploaders.Controls.Add(this.tpOneTimeSecret);
this.tcTextUploaders.Controls.Add(this.tpPastie);
resources.ApplyResources(this.tcTextUploaders, "tcTextUploaders");
this.tcTextUploaders.Name = "tcTextUploaders";
this.tcTextUploaders.SelectedIndex = 0;
@ -3730,6 +3734,13 @@ private void InitializeComponent()
this.cbUpasteIsPublic.UseVisualStyleBackColor = true;
this.cbUpasteIsPublic.CheckedChanged += new System.EventHandler(this.cbUpasteIsPublic_CheckedChanged);
//
// cbPastieIsPublic
//
resources.ApplyResources(this.cbPastieIsPublic, "cbPastieIsPublic");
this.cbPastieIsPublic.Name = "cbPastieIsPublic";
this.cbPastieIsPublic.UseVisualStyleBackColor = true;
this.cbPastieIsPublic.CheckedChanged += new System.EventHandler(this.cbPastieIsPublic_CheckedChanged);
//
// lblUpasteUserKey
//
resources.ApplyResources(this.lblUpasteUserKey, "lblUpasteUserKey");
@ -3815,6 +3826,19 @@ private void InitializeComponent()
this.txtOneTimeSecretEmail.Name = "txtOneTimeSecretEmail";
this.txtOneTimeSecretEmail.TextChanged += new System.EventHandler(this.txtOneTimeSecretEmail_TextChanged);
//
// tpPastie
//
this.tpPastie.Controls.Add(this.cbPastieIsPublic);
resources.ApplyResources(this.tpPastie, "tpPastie");
this.tpPastie.Name = "tpPastie";
this.tpPastie.UseVisualStyleBackColor = true;
//
// cbPastieIsPublic
//
resources.ApplyResources(this.cbPastieIsPublic, "cbPastieIsPublic");
this.cbPastieIsPublic.Name = "cbPastieIsPublic";
this.cbPastieIsPublic.UseVisualStyleBackColor = true;
//
// tpImageUploaders
//
this.tpImageUploaders.Controls.Add(this.tcImageUploaders);
@ -4611,6 +4635,8 @@ private void InitializeComponent()
this.tpHastebin.PerformLayout();
this.tpOneTimeSecret.ResumeLayout(false);
this.tpOneTimeSecret.PerformLayout();
this.tpPastie.ResumeLayout(false);
this.tpPastie.PerformLayout();
this.tpImageUploaders.ResumeLayout(false);
this.tcImageUploaders.ResumeLayout(false);
this.tpImgur.ResumeLayout(false);
@ -5170,5 +5196,7 @@ private void InitializeComponent()
private System.Windows.Forms.TextBox txtUpleaEmailAddress;
public System.Windows.Forms.TabPage tpUplea;
private System.Windows.Forms.CheckBox cbImgurUseHTTPS;
public System.Windows.Forms.TabPage tpPastie;
private System.Windows.Forms.CheckBox cbPastieIsPublic;
}
}

View file

@ -315,6 +315,10 @@ public void LoadSettings()
txtOneTimeSecretEmail.Text = Config.OneTimeSecretAPIUsername;
txtOneTimeSecretAPIKey.Text = Config.OneTimeSecretAPIKey;
// Pastie
cbPastieIsPublic.Checked = Config.PastieIsPublic;
#endregion Text uploaders
#region File uploaders
@ -1229,6 +1233,15 @@ private void txtOneTimeSecretAPIKey_TextChanged(object sender, EventArgs e)
#endregion OneTimeSecret
#region Pastie
private void cbPastieIsPublic_CheckedChanged(object sender, EventArgs e)
{
Config.PastieIsPublic = cbPastieIsPublic.Checked;
}
#endregion Pastie
#endregion Text Uploaders
#region File Uploaders

File diff suppressed because it is too large Load diff

View file

@ -468,6 +468,16 @@ internal class Resources {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Pastie {
get {
object obj = ResourceManager.GetObject("Pastie", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>

View file

@ -395,4 +395,7 @@ Created folders:</value>
<data name="Uplea" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Favicons\Uplea.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Pastie" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Favicons\Pastie.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View file

@ -242,6 +242,7 @@
<Compile Include="SharingServices\VkSharingService.cs" />
<Compile Include="Helpers\TaskReferenceHelper.cs" />
<Compile Include="BaseServices\TextUploaderService.cs" />
<Compile Include="TextUploaders\Pastie.cs" />
<Compile Include="UploaderFactory.cs" />
<Compile Include="ImageUploaders\Chevereto.cs" />
<Compile Include="ImageUploaders\CheveretoUploader.cs" />
@ -880,6 +881,7 @@
<None Include="Resources\document.png" />
</ItemGroup>
<ItemGroup>
<None Include="Favicons\Pastie.png" />
<Content Include="Favicons\Uplea.ico" />
</ItemGroup>
<ItemGroup>

View file

@ -0,0 +1,57 @@
using ShareX.UploadersLib.Properties;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ShareX.UploadersLib.TextUploaders
{
class PastieTextUploaderService : TextUploaderService
{
public override TextDestination EnumValue { get; } = TextDestination.Pastie;
public override bool CheckConfig(UploadersConfig config) => true;
public override Image ServiceImage => Resources.Pastie;
public override GenericUploader CreateUploader(UploadersConfig config, TaskReferenceHelper taskInfo)
{
return new Pastie()
{
IsPublic = config.PastieIsPublic
};
}
public override TabPage GetUploadersConfigTabPage(UploadersConfigForm form) => form.tpPastie;
}
public sealed class Pastie : TextUploader
{
public bool IsPublic { get; set; }
public override UploadResult UploadText(string text, string fileName)
{
UploadResult ur = new UploadResult();
if (!string.IsNullOrEmpty(text))
{
Dictionary<string, string> arguments = new Dictionary<string, string>();
arguments.Add("&paste[body]", text);
arguments.Add("&paste[restricted]", IsPublic ? "0" : "1");
arguments.Add("&paste[authorization]", "burger");
ur.Response = SendRequestURLEncoded("http://pastie.org/pastes", arguments, responseType: ResponseType.RedirectionURL);
if (!string.IsNullOrEmpty(ur.Response))
{
ur.URL = ur.Response;
}
}
return ur;
}
}
}

View file

@ -124,6 +124,10 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
public string OneTimeSecretAPIKey = "";
public string OneTimeSecretAPIUsername = "";
// Pastie
public bool PastieIsPublic = false;
#endregion Text uploaders
#region File uploaders