Merge lp:~cyphermox/pastebinit/dev-arbitrary-dest into lp:pastebinit
- dev-arbitrary-dest
- Merge into trunk
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~cyphermox/pastebinit/dev-arbitrary-dest | ||||
Merge into: | lp:pastebinit | ||||
Diff against target: | None lines | ||||
To merge this branch: | bzr merge lp:~cyphermox/pastebinit/dev-arbitrary-dest | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mathieu Trudel-Lapierre (community) | Needs Resubmitting | ||
Stéphane Graber | Needs Fixing | ||
Review via email: mp+10081@code.launchpad.net |
This proposal has been superseded by a proposal from 2009-10-22.
Commit message
Description of the change
Mathieu Trudel-Lapierre (cyphermox) wrote : | # |
Stéphane Graber (stgraber) wrote : | # |
Hi,
Thanks a lot for your patch.
Before merging it, may I suggest you improve the README file a bit ?
I found it quite confusing (though then reading the actual configuration of a pastebin, makes it a lot easier to understand) and contains a few typos (psatebin instead of pastebin for example).
Also, in the code, I'd suggest getting rid of the old code instead of commenting it as soon as it's converted to the new format. We have bzr if we need to retrieve older revisions.
Again, thanks for all the work, it's really appreciated.
Mathieu Trudel-Lapierre (cyphermox) wrote : | # |
Fixed the spelling and removed the commented stuff.
I've also reworked the README file and hopefully made it much clearer. If not, please let me know where things are messy or confusing, so that I can fix it :)
Thanks,
/ Matt
Unmerged revisions
Preview Diff
1 | === added file 'README' |
2 | --- README 1970-01-01 00:00:00 +0000 |
3 | +++ README 2009-08-13 02:56:14 +0000 |
4 | @@ -0,0 +1,113 @@ |
5 | + |
6 | +USING PASTEBIN.D FILES |
7 | + |
8 | +To enable support for private pastebins, first you will need to know the |
9 | +fields that are in use by the pastebin when posting data. |
10 | + |
11 | +Add a file in the /etc/pastebin.d directory with the following format: |
12 | + |
13 | +[psatebin] |
14 | +basename = (the domain name of the pastebin site, without subdomains) |
15 | +regexp = (a regular expression that identifies the base site, and any |
16 | + subdomains that may be used) |
17 | + |
18 | +[format] |
19 | +pastebinit_field0 = site_field0 |
20 | +pastebinit_fieldN = site_fieldN |
21 | +custom_field0 = site_fieldN |
22 | +custom_fieldN = site_fieldN |
23 | + |
24 | +[defaults] |
25 | +custom_field0 = value |
26 | +custom_fieldN = value |
27 | + |
28 | + |
29 | +THE PASTEBIN SECTION |
30 | + |
31 | +Under "[pastebin]", you will want to keep the very basic information to |
32 | +identify the pastebin. Only two fields are used in that section: |
33 | + |
34 | + basename - the generic domain name for the pastebin. |
35 | + this domain name should not contain |
36 | + possible subdomains in use. |
37 | + |
38 | + regexp - a regular expression that matches the |
39 | + basename, as well as any subdomains that |
40 | + may be in use. |
41 | + |
42 | + |
43 | +THE FORMAT SECTION |
44 | + |
45 | +Under "[format]", identify the various fields in use in the pastebin you |
46 | +are trying to add support for. Identify any fields used to publish data |
47 | +on the pastebin, and add them to the configuration file. |
48 | + |
49 | +The [format] section expects keywords from the pastebinit utility, for |
50 | +which the values will be the actual name of the field in which to put the |
51 | +data for that pastebin. |
52 | + |
53 | +A number of reserved keywords can be used, but are optional: |
54 | + |
55 | + user - contains the username for the user |
56 | + calling the pastebinit utility. |
57 | + |
58 | + content - contains the data that will be posted. |
59 | + |
60 | + title - contains the title if set at the command |
61 | + line. |
62 | + |
63 | + version - contains the version as set at the |
64 | + command line. |
65 | + |
66 | + format - contains the format setting: |
67 | + usually used for syntax highlighting. |
68 | + |
69 | + parentpid - contains the parent post ID for |
70 | + pastebins that use it. |
71 | + |
72 | + permatag - contains permatag as set at the command |
73 | + line. |
74 | + |
75 | + username - contains the pastebin username if |
76 | + required. |
77 | + |
78 | + password - contains the pastebin user's password |
79 | + if required. |
80 | + |
81 | + jabberid - contains the jabberid for the poster |
82 | + as set at the command line. |
83 | + |
84 | +Two additional special parameters are available for use: |
85 | + |
86 | + page - used to specify a page from which to |
87 | + post data. It is the actual URL of |
88 | + the pastebin's form. |
89 | + |
90 | + regexp - used to specify a regexp to execute |
91 | + on the resulting page after posting. |
92 | + This is useful to deal with special |
93 | + pastebins that don't redirect you |
94 | + to the new post's URL. |
95 | + |
96 | +Any other fields in use for the specific pastebin you are trying to enable |
97 | +may be added to the section using a similar syntax. An easy way to deal with |
98 | +such a requirement is to repeat the same keyword, such as: |
99 | + |
100 | +[format] |
101 | +expire = expire |
102 | + |
103 | +Where 'page' can then be reused as the keyword to retrieve a static value, |
104 | +as set in the '[defaults]' section. |
105 | + |
106 | + |
107 | +THE DEFAULTS SECTION |
108 | + |
109 | +The '[defaults]' section is used to set static values for custom fields to |
110 | +retrieve. Some pastebins require setting fields such as expiry time for |
111 | +posts, or whether to use cookies. Such values would be set using a custom |
112 | +field if they are deemed necessary. In the above example, to statically |
113 | +set a page to be used in the 'page' field: |
114 | + |
115 | +[defaults] |
116 | +expire = 3600 |
117 | + |
118 | |
119 | === added directory 'pastebin.d' |
120 | === added file 'pastebin.d/fpaste.org.conf' |
121 | --- pastebin.d/fpaste.org.conf 1970-01-01 00:00:00 +0000 |
122 | +++ pastebin.d/fpaste.org.conf 2009-08-11 02:26:03 +0000 |
123 | @@ -0,0 +1,17 @@ |
124 | +# Another website that doesn't work due to unusual changes. |
125 | +# this is the Fedora Pastebin, sadly. |
126 | + |
127 | +[pastebin] |
128 | +basename = fpaste.org |
129 | +regexp = "http://fpaste.org" |
130 | + |
131 | +[format] |
132 | +user = author |
133 | +content = content |
134 | +format = lang |
135 | +submit = submit |
136 | +expire_options = expire_options |
137 | + |
138 | +[defaults] |
139 | +submit = "paste it!" |
140 | +expire_options = 3600 |
141 | |
142 | === added file 'pastebin.d/gist.github.com.conf' |
143 | --- pastebin.d/gist.github.com.conf 1970-01-01 00:00:00 +0000 |
144 | +++ pastebin.d/gist.github.com.conf 2009-08-13 02:16:18 +0000 |
145 | @@ -0,0 +1,13 @@ |
146 | +[pastebin] |
147 | +basename = gist.github.com |
148 | +regexp = "http://gist.github.com" |
149 | + |
150 | +[format] |
151 | +page = page |
152 | +user = poster |
153 | +format = file_ext[gistfile1] |
154 | +content = file_contents[gistfile1] |
155 | +title = file_name[gistfile1] |
156 | + |
157 | +[defaults] |
158 | +page = '/gists' |
159 | |
160 | === added file 'pastebin.d/paste.debian.net.conf' |
161 | --- pastebin.d/paste.debian.net.conf 1970-01-01 00:00:00 +0000 |
162 | +++ pastebin.d/paste.debian.net.conf 2009-08-13 02:16:18 +0000 |
163 | @@ -0,0 +1,16 @@ |
164 | +[pastebin] |
165 | +basename = paste.debian.net |
166 | +regexp = "http://paste.debian.net" |
167 | + |
168 | +[format] |
169 | +user = poster |
170 | +content = code |
171 | +format = syntax |
172 | +lang = lang |
173 | +remember = remember |
174 | +expire = expire |
175 | + |
176 | +[defaults] |
177 | +lang = -1 |
178 | +remember = 0 |
179 | +expire = 259200 |
180 | |
181 | === added file 'pastebin.d/paste.ubuntu.com.conf' |
182 | --- pastebin.d/paste.ubuntu.com.conf 1970-01-01 00:00:00 +0000 |
183 | +++ pastebin.d/paste.ubuntu.com.conf 2009-05-03 15:06:09 +0000 |
184 | @@ -0,0 +1,10 @@ |
185 | +[pastebin] |
186 | +basename = paste.ubuntu.com |
187 | +regexp = "http://paste.ubuntu.com" |
188 | + |
189 | +[format] |
190 | +user = poster |
191 | +content = content |
192 | +format = syntax |
193 | + |
194 | +[defaults] |
195 | |
196 | === added file 'pastebin.d/paste2.org.conf' |
197 | --- pastebin.d/paste2.org.conf 1970-01-01 00:00:00 +0000 |
198 | +++ pastebin.d/paste2.org.conf 2009-08-13 02:16:18 +0000 |
199 | @@ -0,0 +1,14 @@ |
200 | +[pastebin] |
201 | +basename = paste2.org |
202 | +regexp = "http://paste2.org" |
203 | + |
204 | +[format] |
205 | +title = description |
206 | +content = code |
207 | +format = lang |
208 | +page = page |
209 | +parent = parent |
210 | + |
211 | +[defaults] |
212 | +page = '/new-paste' |
213 | +parent = 0 |
214 | |
215 | === added file 'pastebin.d/pastebin.ca.conf' |
216 | --- pastebin.d/pastebin.ca.conf 1970-01-01 00:00:00 +0000 |
217 | +++ pastebin.d/pastebin.ca.conf 2009-05-03 15:06:09 +0000 |
218 | @@ -0,0 +1,17 @@ |
219 | +[pastebin] |
220 | +basename = pastebin.ca |
221 | +regexp = "http://((([a-zA-Z0-9\-_\.]*)(pastebin\.ca)))" |
222 | + |
223 | +[format] |
224 | +user = name |
225 | +content = content |
226 | +type = type |
227 | +save = save |
228 | +submit = submit |
229 | +regexp = regexp |
230 | + |
231 | +[defaults] |
232 | +type = 1 |
233 | +save = 0 |
234 | +submit = s |
235 | +regexp = '">http://.*pastebin.ca/(.*)</a></p><p>' |
236 | |
237 | === added file 'pastebin.d/pastebin.com.conf' |
238 | --- pastebin.d/pastebin.com.conf 1970-01-01 00:00:00 +0000 |
239 | +++ pastebin.d/pastebin.com.conf 2009-05-03 15:06:09 +0000 |
240 | @@ -0,0 +1,19 @@ |
241 | +[pastebin] |
242 | +basename = pastebin.com |
243 | +regexp = "http://((([a-zA-Z0-9\-_\.]*)(pastebin\.com)))" |
244 | +#FIXME: not website == "http://www.pastebin.com") or website == "http://pastebin.mozilla.org": |
245 | + |
246 | +[format] |
247 | +user = poster |
248 | +content = code2 |
249 | +version = version |
250 | +parentpid = parent_pid |
251 | +format = format |
252 | +submit = paste |
253 | +remember = remember |
254 | +expiry = expiry |
255 | + |
256 | +[defaults] |
257 | +remember = f |
258 | +expiry = 1 |
259 | +paste = Send |
260 | |
261 | === added file 'pastebin.d/pastey.net.conf' |
262 | --- pastebin.d/pastey.net.conf 1970-01-01 00:00:00 +0000 |
263 | +++ pastebin.d/pastey.net.conf 2009-05-08 01:40:02 +0000 |
264 | @@ -0,0 +1,18 @@ |
265 | +[pastebin] |
266 | +basename = pastey.net |
267 | +regexp = "http://((([a-zA-Z0-9\-_\.]*)(pastey\.net)))" |
268 | + |
269 | +[format] |
270 | +user = author |
271 | +title = subject |
272 | +parentpid = parent |
273 | +content = text |
274 | +format = language |
275 | +paste = paste |
276 | +page = page |
277 | +regexp = regexp |
278 | + |
279 | +[defaults] |
280 | +paste = "Paste" |
281 | +page = '/submit.php' |
282 | +regexp = '">http://(?:(?:[a-zA-Z0-9\-_\.]*)(?:pastey\.net))/(.*)</a>' |
283 | |
284 | === added file 'pastebin.d/rafb.net.conf' |
285 | --- pastebin.d/rafb.net.conf 1970-01-01 00:00:00 +0000 |
286 | +++ pastebin.d/rafb.net.conf 2009-08-11 02:26:03 +0000 |
287 | @@ -0,0 +1,15 @@ |
288 | +[pastebin] |
289 | +basename = rafb.net |
290 | +regexp = "http://rafb.net" |
291 | + |
292 | +[format] |
293 | +user = nick |
294 | +content = text |
295 | +page = page |
296 | +lang = lang |
297 | +cvt_tabs = cvt_tabs |
298 | + |
299 | +[defaults] |
300 | +page = "/paste/paste.php" |
301 | +lang = "Plain Text" |
302 | +cvt_tabs = "No" |
303 | |
304 | === added file 'pastebin.d/slexy.org.conf' |
305 | --- pastebin.d/slexy.org.conf 1970-01-01 00:00:00 +0000 |
306 | +++ pastebin.d/slexy.org.conf 2009-08-11 02:26:03 +0000 |
307 | @@ -0,0 +1,24 @@ |
308 | +[pastebin] |
309 | +basename = slexy.org |
310 | +regexp = "http://slexy.org" |
311 | + |
312 | +[format] |
313 | +user = author |
314 | +content = raw_paste |
315 | +title = desc |
316 | +page = page |
317 | +language = language |
318 | +permissions = permissions |
319 | +linenumbers = linenumbers |
320 | +comment = comment |
321 | +submit = submit |
322 | +expire = expire |
323 | + |
324 | +[defaults] |
325 | +submit = "Submit Paste" |
326 | +page = "/index.php/submit" |
327 | +language = "text" |
328 | +permissions = 0 |
329 | +comment = "" |
330 | +linenumbers = 0 |
331 | +expire = 0 |
332 | |
333 | === added file 'pastebin.d/stikked.com.conf' |
334 | --- pastebin.d/stikked.com.conf 1970-01-01 00:00:00 +0000 |
335 | +++ pastebin.d/stikked.com.conf 2009-08-13 02:16:18 +0000 |
336 | @@ -0,0 +1,18 @@ |
337 | +[pastebin] |
338 | +basename = stikked.com |
339 | +regexp = "http://stikked.com" |
340 | + |
341 | +[format] |
342 | +user = name |
343 | +content = code |
344 | +title = title |
345 | +email = email |
346 | +lang = lang |
347 | +website = website |
348 | +submit = submit |
349 | + |
350 | +[defaults] |
351 | +email = "" |
352 | +lang = "text" |
353 | +website = "" |
354 | +submit = "submit" |
355 | |
356 | === added file 'pastebin.d/yourpaste.net.conf' |
357 | --- pastebin.d/yourpaste.net.conf 1970-01-01 00:00:00 +0000 |
358 | +++ pastebin.d/yourpaste.net.conf 2009-08-13 02:16:18 +0000 |
359 | @@ -0,0 +1,21 @@ |
360 | +[pastebin] |
361 | +basename = yourpaste.net |
362 | +regexp = "http://yourpaste.net" |
363 | + |
364 | +[format] |
365 | +format = syntax |
366 | +user = name |
367 | +title = desc |
368 | +expire = expire |
369 | +content = code |
370 | +private = private |
371 | +remember = remember |
372 | +page = page |
373 | +regexp = regexp |
374 | + |
375 | +[defaults] |
376 | +expire = 0 |
377 | +private = 0 |
378 | +remember = 0 |
379 | +page = '/paste' |
380 | +regexp = '">http://yourpaste.net(.*)</a>' |
381 | |
382 | === modified file 'pastebinit' |
383 | --- pastebinit 2009-03-10 05:23:09 +0000 |
384 | +++ pastebinit 2009-08-13 02:11:21 +0000 |
385 | @@ -20,6 +20,7 @@ |
386 | try: |
387 | import urllib, os, sys, re, getopt, select, xml.dom.minidom, gettext |
388 | from gettext import gettext as _ |
389 | + from configobj import ConfigObj |
390 | |
391 | gettext.textdomain("pastebinit") |
392 | |
393 | @@ -32,16 +33,26 @@ |
394 | def http_error_401(self, url, fp, errcode, errmsg, headers, data=None): |
395 | return None |
396 | |
397 | + def preloadPastebins(): |
398 | + confdir = '/etc/pastebin.d/' |
399 | + confdirlist = os.listdir(confdir) |
400 | + pastebind = {} |
401 | + for fileitem in confdirlist: |
402 | + bininstance = ConfigObj(confdir + fileitem) |
403 | + basename = bininstance['pastebin']['basename'] |
404 | + pastebind[basename] = bininstance |
405 | + return pastebind |
406 | + |
407 | # pastey.net obfuscates parent ids for replies. Rather than taking the |
408 | # post ID given as the parent ID, we must handle this by going to that |
409 | # post page and looking up what the invisible parent ID field will be |
410 | # set to for children. |
411 | - def pasteyParentFixup(website, parentid): |
412 | + def doParentFixup(website, paramname, parentid): |
413 | if parentid == "": |
414 | return "" |
415 | url_opener = pasteURLopener() |
416 | page = url_opener.open(website + '/' + parentid, None) |
417 | - matches = re.split('<input.*?name="parent".*?value="(.*?)"', page.read()) |
418 | + matches = re.split('<input.*?name="' + paramname + '".*?value="(.*?)"', page.read()) |
419 | if len(matches) <= 1 or re.match(parentid, matches[1]) == None: |
420 | # The obfuscated version didn't begin with the partial version, |
421 | # or unable to find the obfuscated version for some reason! |
422 | @@ -50,7 +61,7 @@ |
423 | return matches[1] |
424 | |
425 | #Return the parameters depending of the pastebin used |
426 | - def getParameters(website, content, user, jabberid, version, format, parentpid, permatag, title, username, password): |
427 | + def getParameters(website, pastebind, content, user, jabberid, version, format, parentpid, permatag, title, username, password): |
428 | "Return the parameters array for the selected pastebin" |
429 | params={} |
430 | # pastebin.com v0.50 |
431 | @@ -84,81 +95,113 @@ |
432 | # params['username'] = username |
433 | # params['password'] = password |
434 | # params['version'] = version |
435 | - elif website == "http://rafb.net": |
436 | - params['page'] = "/paste/paste.php" |
437 | - params['nick'] = user |
438 | - params['text'] = content |
439 | - params['lang'] = "Plain Text" #The format, for syntax hilighting |
440 | - params['cvt_tabs'] = "No" |
441 | - elif website == "http://stikked.com": |
442 | - params['name'] = user |
443 | - params['title'] = title |
444 | - params['email'] = "" |
445 | - params['lang'] = "text" #The format, for syntax hilighting |
446 | - params['code'] = content |
447 | - params['website'] = "" |
448 | - params['submit'] = "submit" |
449 | - elif website == "http://slexy.org": |
450 | - params['page'] = "/index.php/submit" |
451 | - params['raw_paste'] = content |
452 | - params['comment'] = "" |
453 | - params['author'] = user |
454 | - params['language'] = "text" #The format, for syntax hilighting |
455 | - params['permissions'] = "0" |
456 | - params['desc'] = title |
457 | - params['linenumbers'] = "0" |
458 | - params['expire'] = "0" |
459 | - params['submit'] = "Submit Paste" |
460 | - elif website == "http://fpaste.org": |
461 | - params['lang'] = format #The format, for syntax hilighting |
462 | - params['page'] = "/paste/save" |
463 | - params['content'] = content |
464 | - params['submit'] = "pastebinit" |
465 | - elif website == "http://paste2.org": |
466 | - params['page'] = "/new-paste" |
467 | - params['description'] = title |
468 | - params['lang'] = format |
469 | - params['code'] = content |
470 | - params['parent'] = "0" |
471 | - elif re.search("http://((([a-zA-Z0-9\-_\.]*)(pastey\.net)))", website): |
472 | - params['author'] = user |
473 | - params['subject'] = title |
474 | - params['parent'] = pasteyParentFixup(website, parentpid) |
475 | - params['text'] = content |
476 | - params['language'] = format # File format, as a string like "cpp" or "lua" |
477 | - params['paste'] = "Paste" |
478 | - params['page'] = '/submit.php' |
479 | - params['regexp'] = '">http://(?:(?:[a-zA-Z0-9\-_\.]*)(?:pastey\.net))(/.*)</a>' |
480 | - elif website == "http://yourpaste.net": |
481 | - params['syntax'] = format |
482 | - params['name'] = user |
483 | - params['desc'] = title |
484 | - params['expire'] = "0" # Forever |
485 | - params['code'] = content |
486 | - params['private'] = "0" # It's not a private post |
487 | - params['remember'] = "0" # Cookies? ;) |
488 | - params['page'] = "/paste" |
489 | - params['regexp'] = '">http://yourpaste.net(.*)/</a>' |
490 | - elif website == "http://gist.github.com": |
491 | - params['page'] = "/gists" |
492 | - params['poster'] = user |
493 | - params['file_ext[gistfile1]'] = format #The format, for syntax hilighting |
494 | - params['file_contents[gistfile1]'] = content |
495 | - params['file_name[gistfile1]'] = title |
496 | - elif website == "http://paste.ubuntu.com": |
497 | - params['poster'] = user |
498 | - params['syntax'] = format #The format, for syntax hilighting |
499 | - params['content'] = content |
500 | - elif website == "http://paste.debian.net": |
501 | - params['poster'] = user |
502 | - params['lang'] = "-1" #The format, for syntax hilighting, default to plain text |
503 | - params['syntax'] = format #The format, for syntax hilighting |
504 | - params['code'] = content |
505 | - params['remember'] = "0" #Do you want a cookie ? |
506 | - params['expire'] = "259200" # expire in 72h |
507 | +# elif website == "http://rafb.net": |
508 | +# if website == "http://rafb.net": |
509 | +# params['page'] = "/paste/paste.php" |
510 | +# params['nick'] = user |
511 | +# params['text'] = content |
512 | +# params['lang'] = "Plain Text" #The format, for syntax hilighting |
513 | +# params['cvt_tabs'] = "No" |
514 | +# elif website == "http://stikked.com": |
515 | +# params['name'] = user |
516 | +# params['title'] = title |
517 | +# params['email'] = "" |
518 | +# params['lang'] = "text" #The format, for syntax hilighting |
519 | +# params['code'] = content |
520 | +# params['website'] = "" |
521 | +# params['submit'] = "submit" |
522 | +# elif website == "http://slexy.org": |
523 | +# if website == "http://slexy.org": |
524 | +# params['page'] = "/index.php/submit" |
525 | +# params['raw_paste'] = content |
526 | +# params['comment'] = "" |
527 | +# params['author'] = user |
528 | +# params['language'] = "text" #The format, for syntax hilighting |
529 | +# params['permissions'] = "0" |
530 | +# params['desc'] = title |
531 | +# params['linenumbers'] = "0" |
532 | +# params['expire'] = "0" |
533 | +# params['submit'] = "Submit Paste" |
534 | +# elif website == "http://fpaste.org": |
535 | +# params['lang'] = format #The format, for syntax hilighting |
536 | +# params['page'] = "/paste/save" |
537 | +# params['content'] = content |
538 | +# params['submit'] = "pastebinit" |
539 | +# elif website == "http://paste2.org": |
540 | +# params['page'] = "/new-paste" |
541 | +# params['description'] = title |
542 | +# params['lang'] = format |
543 | +# params['code'] = content |
544 | +# params['parent'] = "0" |
545 | +# elif re.search("http://((([a-zA-Z0-9\-_\.]*)(pastey\.net)))", website): |
546 | +# params['author'] = user |
547 | +# params['subject'] = title |
548 | +# params['parent'] = pasteyParentFixup(website, parentpid) |
549 | +# params['text'] = content |
550 | +# params['language'] = format # File format, as a string like "cpp" or "lua" |
551 | +# params['paste'] = "Paste" |
552 | +# params['page'] = '/submit.php' |
553 | +# params['regexp'] = '">http://(?:(?:[a-zA-Z0-9\-_\.]*)(?:pastey\.net))(/.*)</a>' |
554 | +# elif website == "http://yourpaste.net": |
555 | +# params['syntax'] = format |
556 | +# params['name'] = user |
557 | +# params['desc'] = title |
558 | +# params['expire'] = "0" # Forever |
559 | +# params['code'] = content |
560 | +# params['private'] = "0" # It's not a private post |
561 | +# params['remember'] = "0" # Cookies? ;) |
562 | +# params['page'] = "/paste" |
563 | +# params['regexp'] = '">http://yourpaste.net(.*)/</a>' |
564 | +# elif website == "http://gist.github.com": |
565 | +# params['page'] = "/gists" |
566 | +# params['poster'] = user |
567 | +# params['file_ext[gistfile1]'] = format #The format, for syntax hilighting |
568 | +# params['file_contents[gistfile1]'] = content |
569 | +# params['file_name[gistfile1]'] = title |
570 | +# elif website == "http://paste.ubuntu.com": |
571 | +# params['poster'] = user |
572 | +# params['syntax'] = format #The format, for syntax hilighting |
573 | +# params['content'] = content |
574 | +# elif website == "http://paste.debian.net": |
575 | +# params['poster'] = user |
576 | +# params['lang'] = "-1" #The format, for syntax hilighting, default to plain text |
577 | +# params['syntax'] = format #The format, for syntax hilighting |
578 | +# params['code'] = content |
579 | +# params['remember'] = "0" #Do you want a cookie ? |
580 | +# params['expire'] = "259200" # expire in 72h |
581 | else: |
582 | - sys.exit(_("Unknown website, please post a bugreport to request this pastebin to be added (%s)") % website) |
583 | - return params |
584 | + for pastebin in pastebind: |
585 | + if re.search( pastebind[pastebin]['pastebin']['regexp'], website ): |
586 | + for param in pastebind[pastebin]['format'].keys(): |
587 | + paramname = pastebind[pastebin]['format'][param] |
588 | + if param == 'user': |
589 | + params[paramname] = user |
590 | + elif param == 'content': |
591 | + params[paramname] = content |
592 | + elif param == 'title': |
593 | + params[paramname] = title |
594 | + elif param == 'version': |
595 | + params[paramname] = version |
596 | + elif param == 'format': |
597 | + params[paramname] = format |
598 | + elif param == 'parentpid': |
599 | + #params[paramname] = parentpid |
600 | + params[paramname] = doParentFixup(website, paramname, parentpid) |
601 | + elif param == 'permatag': |
602 | + params[paramname] = parmatag |
603 | + elif param == 'username': |
604 | + params[paramname] = username |
605 | + elif param == 'password': |
606 | + params[paramname] = password |
607 | + elif param == 'jabberid': |
608 | + params[paramname] = jabberid |
609 | + else: |
610 | + params[paramname] = pastebind[pastebin]['defaults'][paramname] |
611 | + #print params |
612 | + if params: |
613 | + return params |
614 | + else: |
615 | + sys.exit(_("Unknown website, please post a bugreport to request this pastebin to be added (%s)") % website) |
616 | |
617 | #XML Handling methods |
618 | def getText(nodelist): |
619 | @@ -297,7 +340,8 @@ |
620 | sys.exit(_("Unable to read from: %s") % filename) |
621 | if not content: |
622 | sys.exit(_("You are trying to send an empty document, exiting.")) |
623 | - params = getParameters(website, content, user, jabberid, version, format, parentpid, permatag, title, username, password) #Get the parameters array |
624 | + pastebind = preloadPastebins() #get the config from /etc/pastebin.d/ |
625 | + params = getParameters(website, pastebind, content, user, jabberid, version, format, parentpid, permatag, title, username, password) #Get the parameters array |
626 | |
627 | if not re.search(".*/", website): |
628 | website += "/" |
Fixes bug #369795 by proposing a format for configuration files that define new personal/public pastebins.
Most pastebins already supported in the script have been factored out to config files in this branch, and commented out in the main script. The only ones kept in the main script (but also available as config files), are pastebin.com and pastebin.ca.