~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to Pastebin/src/Providers/PastebinCA.cs

  • Committer: Chris Szikszoy
  • Date: 2008-11-21 05:09:06 UTC
  • Revision ID: chris@chris-laptop-ibex-20081121050906-y3rh3ni89a503kw2
changes to Pastebin UI

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
namespace Pastebin
27
27
{
28
 
   public class PastebinCA : IPastebinProvider
29
 
   {
30
 
       private const string urlRoot = "http://pastebin.ca";
31
 
 
32
 
       private NameValueCollection parameters;
33
 
       private List<TextSyntaxItem> supportedLanguages;
34
 
 
35
 
       public PastebinCA ()
36
 
       {
37
 
           parameters = new NameValueCollection();
38
 
           parameters["api"] = "4xPQUdtxHQ9wxlAJ9t/ztpv36MM/ZE9G";
39
 
           parameters["type"] = "1";
40
 
           parameters["description"] = "";
41
 
           parameters["content"] = "";
42
 
           parameters["name"] = "";
43
 
           parameters["expiry"] = "1 month";
44
 
 
45
 
           supportedLanguages = new List<TextSyntaxItem>();
46
 
           supportedLanguages.Add (new TextSyntaxItem ("Plain Text", "Plain Text", "file", "1"));
47
 
           supportedLanguages.Add (new TextSyntaxItem ("Actionscript", "Actionscript", "file", "18"));
48
 
           supportedLanguages.Add (new TextSyntaxItem ("Ada", "Ada", "file", "19"));
49
 
           supportedLanguages.Add (new TextSyntaxItem ("Apache Config", "Apache Config", "file", "20"));
50
 
           supportedLanguages.Add (new TextSyntaxItem ("ASP", "ASP", "file", "22"));
51
 
           supportedLanguages.Add (new TextSyntaxItem ("Bash", "Bash", "file", "23"));
52
 
           supportedLanguages.Add (new TextSyntaxItem ("C", "C", "file", "3"));
53
 
           supportedLanguages.Add (new TextSyntaxItem ("C++", "C++", "file", "4"));
54
 
           supportedLanguages.Add (new TextSyntaxItem ("C#", "C#", "file", "9"));
55
 
           supportedLanguages.Add (new TextSyntaxItem ("CSS", "CSS", "file", "24"));
56
 
           supportedLanguages.Add (new TextSyntaxItem ("Delphi", "Delphi", "file", "25"));
57
 
           supportedLanguages.Add (new TextSyntaxItem ("Diff / Patch", "Diff / Patch", "file", "34"));
58
 
           supportedLanguages.Add (new TextSyntaxItem ("HTML 4 Strict", "HTML 4 Strict", "file", "26"));
59
 
           supportedLanguages.Add (new TextSyntaxItem ("Java", "Java", "file", "7"));
60
 
           supportedLanguages.Add (new TextSyntaxItem ("Javascript", "Javascript", "file", "27"));
61
 
           supportedLanguages.Add (new TextSyntaxItem ("LISP", "LISP", "file", "28"));
62
 
           supportedLanguages.Add (new TextSyntaxItem ("Lua", "Lua", "file", "29"));
63
 
           supportedLanguages.Add (new TextSyntaxItem ("Microprocessor ASM", "Microprocessor ASM", "file", "30"));
64
 
           supportedLanguages.Add (new TextSyntaxItem ("mIRC Script", "mIRC SCript", "file", "13"));
65
 
           supportedLanguages.Add (new TextSyntaxItem ("Objective C", "Objective C", "file", "31"));
66
 
           supportedLanguages.Add (new TextSyntaxItem ("Perl", "Perl", "file", "6"));
67
 
           supportedLanguages.Add (new TextSyntaxItem ("PHP", "PHP", "file", "5"));
68
 
           supportedLanguages.Add (new TextSyntaxItem ("PL/I", "PL/I", "file", "14"));
69
 
           supportedLanguages.Add (new TextSyntaxItem ("Python", "Python", "file", "11"));
70
 
           supportedLanguages.Add (new TextSyntaxItem ("Ruby", "Ruby", "file", "10"));
71
 
           supportedLanguages.Add (new TextSyntaxItem ("SQL", "SQL", "file", "16"));
72
 
           supportedLanguages.Add (new TextSyntaxItem ("Scheme", "Scheme", "file", "17"));
73
 
           supportedLanguages.Add (new TextSyntaxItem ("Script Log", "Script Log", "file", "33"));
74
 
           supportedLanguages.Add (new TextSyntaxItem ("Visual BASIC", "Visual BASIC", "file", "8"));
75
 
           supportedLanguages.Add (new TextSyntaxItem ("VB.NET", "VB.NET", "file", "32"));
76
 
           supportedLanguages.Add (new TextSyntaxItem ("XML", "XML", "file", "15"));
77
 
       }
78
 
 
79
 
       public PastebinCA(string content, string syntax)
80
 
           : this()
81
 
       {
82
 
           parameters["type"] = syntax;
83
 
           parameters["content"] = content;
84
 
       }
85
 
 
86
 
       public PastebinCA(string content)
87
 
           : this()
88
 
       {
89
 
           parameters["content"] = content;
90
 
       }
91
 
 
92
 
       public bool ShouldAllowAutoRedirect
93
 
       {
94
 
           get { return true; }
95
 
       }
96
 
 
97
 
       public string BaseUrl
98
 
       {
99
 
           get { return urlRoot + "/quiet-paste.php"; }
100
 
       }
101
 
 
102
 
       public NameValueCollection Parameters
103
 
       {
104
 
           get { return parameters; }
105
 
       }
106
 
 
107
 
       public string GetPasteUrlFromResponse(HttpWebResponse response)
108
 
       {
109
 
           string responseText;
110
 
           using (Stream responseStream = response.GetResponseStream ()) {
111
 
               using (StreamReader reader = new StreamReader (responseStream)) {
112
 
                   responseText = reader.ReadToEnd ();
113
 
               }
114
 
           }
115
 
 
116
 
           string url = String.Empty;
117
 
           if (responseText.Contains ("SUCCESS")) {
118
 
               url = urlRoot + "/" + responseText.Split (new string[]{":"}, StringSplitOptions.RemoveEmptyEntries)[1];
119
 
           }
120
 
 
121
 
           return url;
122
 
       }
123
 
 
124
 
       public List<TextSyntaxItem> SupportedLanguages
125
 
       {
126
 
           get { return supportedLanguages; }
127
 
       }
128
 
   }
 
28
        public class PastebinCA : IPastebinProvider
 
29
        {
 
30
                private const string urlRoot = "http://pastebin.ca";
 
31
                
 
32
                private NameValueCollection parameters;
 
33
                private List<TextSyntaxItem> supportedLanguages;
 
34
                
 
35
                public PastebinCA ()
 
36
                {
 
37
                        parameters = new NameValueCollection();
 
38
                        parameters["api"] = "4xPQUdtxHQ9wxlAJ9t/ztpv36MM/ZE9G";
 
39
                        parameters["type"] = "1";
 
40
                        parameters["description"] = "";
 
41
                        parameters["content"] = "";
 
42
                        parameters["name"] = "";
 
43
                        parameters["expiry"] = "1 month";
 
44
                        
 
45
                        supportedLanguages = new List<TextSyntaxItem>();
 
46
                        supportedLanguages.Add (new TextSyntaxItem ("Plain Text", "Plain Text", "file", "1"));
 
47
                        supportedLanguages.Add (new TextSyntaxItem ("Actionscript", "Actionscript", "file", "18"));
 
48
                        supportedLanguages.Add (new TextSyntaxItem ("Ada", "Ada", "file", "19"));
 
49
                        supportedLanguages.Add (new TextSyntaxItem ("Apache Config", "Apache Config", "file", "20"));
 
50
                        supportedLanguages.Add (new TextSyntaxItem ("ASP", "ASP", "file", "22"));
 
51
                        supportedLanguages.Add (new TextSyntaxItem ("Bash", "Bash", "file", "23"));
 
52
                        supportedLanguages.Add (new TextSyntaxItem ("C", "C", "file", "3"));
 
53
                        supportedLanguages.Add (new TextSyntaxItem ("C++", "C++", "file", "4"));
 
54
                        supportedLanguages.Add (new TextSyntaxItem ("C#", "C#", "file", "9"));
 
55
                        supportedLanguages.Add (new TextSyntaxItem ("CSS", "CSS", "file", "24"));
 
56
                        supportedLanguages.Add (new TextSyntaxItem ("Delphi", "Delphi", "file", "25"));
 
57
                        supportedLanguages.Add (new TextSyntaxItem ("Diff / Patch", "Diff / Patch", "file", "34"));
 
58
                        supportedLanguages.Add (new TextSyntaxItem ("HTML 4 Strict", "HTML 4 Strict", "file", "26"));
 
59
                        supportedLanguages.Add (new TextSyntaxItem ("Java", "Java", "file", "7"));
 
60
                        supportedLanguages.Add (new TextSyntaxItem ("Javascript", "Javascript", "file", "27"));
 
61
                        supportedLanguages.Add (new TextSyntaxItem ("LISP", "LISP", "file", "28"));
 
62
                        supportedLanguages.Add (new TextSyntaxItem ("Lua", "Lua", "file", "29"));
 
63
                        supportedLanguages.Add (new TextSyntaxItem ("Microprocessor ASM", "Microprocessor ASM", "file", "30"));
 
64
                        supportedLanguages.Add (new TextSyntaxItem ("mIRC Script", "mIRC SCript", "file", "13"));
 
65
                        supportedLanguages.Add (new TextSyntaxItem ("Objective C", "Objective C", "file", "31"));
 
66
                        supportedLanguages.Add (new TextSyntaxItem ("Perl", "Perl", "file", "6"));
 
67
                        supportedLanguages.Add (new TextSyntaxItem ("PHP", "PHP", "file", "5"));
 
68
                        supportedLanguages.Add (new TextSyntaxItem ("PL/I", "PL/I", "file", "14"));
 
69
                        supportedLanguages.Add (new TextSyntaxItem ("Python", "Python", "file", "11"));
 
70
                        supportedLanguages.Add (new TextSyntaxItem ("Ruby", "Ruby", "file", "10"));
 
71
                        supportedLanguages.Add (new TextSyntaxItem ("SQL", "SQL", "file", "16"));
 
72
                        supportedLanguages.Add (new TextSyntaxItem ("Scheme", "Scheme", "file", "17"));
 
73
                        supportedLanguages.Add (new TextSyntaxItem ("Script Log", "Script Log", "file", "33"));
 
74
                        supportedLanguages.Add (new TextSyntaxItem ("Visual BASIC", "Visual BASIC", "file", "8"));
 
75
                        supportedLanguages.Add (new TextSyntaxItem ("VB.NET", "VB.NET", "file", "32"));
 
76
                        supportedLanguages.Add (new TextSyntaxItem ("XML", "XML", "file", "15"));
 
77
                }
 
78
                
 
79
                public PastebinCA(string content, string syntax)
 
80
                        : this()
 
81
                {
 
82
                        parameters["type"] = syntax;
 
83
                        parameters["content"] = content;
 
84
                }
 
85
                
 
86
                public PastebinCA(string content)
 
87
                        : this()
 
88
                {
 
89
                        parameters["content"] = content;
 
90
                }
 
91
                
 
92
                public bool ShouldAllowAutoRedirect
 
93
                {
 
94
                        get { return true; }
 
95
                }
 
96
                
 
97
                public string Name 
 
98
                {
 
99
                        get { return "pastebin.ca"; }
 
100
                }
 
101
 
 
102
                public string BaseUrl
 
103
                {
 
104
                        get { return urlRoot + "/quiet-paste.php"; }
 
105
                }
 
106
                
 
107
                public NameValueCollection Parameters
 
108
                {
 
109
                        get { return parameters; }
 
110
                }
 
111
                
 
112
                public string GetPasteUrlFromResponse(HttpWebResponse response)
 
113
                {
 
114
                        string responseText;
 
115
                        using (Stream responseStream = response.GetResponseStream ()) {
 
116
                                using (StreamReader reader = new StreamReader (responseStream)) {
 
117
                                        responseText = reader.ReadToEnd ();
 
118
                                }
 
119
                        }
 
120
                        
 
121
                        string url = String.Empty;
 
122
                        if (responseText.Contains ("SUCCESS")) {
 
123
                                url = urlRoot + "/" + responseText.Split (new string[]{":"}, StringSplitOptions.RemoveEmptyEntries)[1];
 
124
                        }
 
125
                        
 
126
                        return url;
 
127
                }
 
128
                
 
129
                public List<TextSyntaxItem> SupportedLanguages
 
130
                {
 
131
                        get { return supportedLanguages; }
 
132
                }
 
133
        }
129
134
}
 
 
b'\\ No newline at end of file'