pastebin-js
Advanced tools
Comparing version 0.1.6 to 0.2.1
@@ -0,1 +1,10 @@ | ||
'use strict'; | ||
/* | ||
* pastebin-js | ||
* https://github.com/j3lte/pastebin-js | ||
* | ||
* Copyright (c) 2014 Jelte Lagendijk | ||
* Licensed under the MIT license. | ||
*/ | ||
var _ = require('underscore'), | ||
@@ -57,6 +66,7 @@ fs = require('fs'), | ||
formats = null, | ||
expirations = null; | ||
expirations = null, | ||
noKeyNeeded = true; | ||
if (typeof text !== 'string') { | ||
deferred.reject(new Error("Error! Paste can only be a text!")); | ||
deferred.reject(new Error('Error! Paste can only be a text!')); | ||
} | ||
@@ -77,3 +87,3 @@ | ||
} else { | ||
deferred.reject(new Error("Error! Paste format " + format + " is unknown.")); | ||
deferred.reject(new Error('Error! Paste format ' + format + ' is unknown.')); | ||
} | ||
@@ -89,2 +99,3 @@ } | ||
} else if (_this.config.api_user_name !== null && _this.config.api_user_password !== null) { | ||
noKeyNeeded = false; | ||
_this | ||
@@ -99,6 +110,6 @@ .createAPIuserKey() | ||
} else { | ||
deferred.reject(new Error("Error! For this privacy level you need to be logged in! Provide username and password!")); | ||
deferred.reject(new Error('Error! For this privacy level you need to be logged in! Provide username and password!')); | ||
} | ||
} else { | ||
deferred.reject(new Error("Error! Privacy level is unknown!")); | ||
deferred.reject(new Error('Error! Privacy level is unknown!')); | ||
} | ||
@@ -112,12 +123,12 @@ } | ||
} else { | ||
deferred.reject(new Error("Error! Paste expiration " + expiration + " is unknown.")); | ||
deferred.reject(new Error('Error! Paste expiration ' + expiration + ' is unknown.')); | ||
} | ||
} | ||
_this | ||
._postApi(conf.net.protocol + conf.net.base + conf.net.endpoint.post, p) | ||
.then(function (data) { | ||
deferred.resolve(data); | ||
}) | ||
.fail(deferred.reject); | ||
if (noKeyNeeded) { | ||
_this | ||
._postApi(conf.net.protocol + conf.net.base + conf.net.endpoint.post, p) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
} | ||
@@ -141,8 +152,8 @@ return deferred.promise; | ||
if (!filename) { | ||
deferred.reject(new Error("Filename not provided!")); | ||
deferred.reject(new Error('Filename not provided!')); | ||
} | ||
fs.readFile(filename, "UTF8", function (err, data) { | ||
fs.readFile(filename, 'UTF8', function (err, data) { | ||
if (err) { | ||
deferred.reject(new Error("Readfile error: " + err)); | ||
deferred.reject(new Error('Readfile error: ' + err)); | ||
} | ||
@@ -170,3 +181,3 @@ | ||
if (!pasteID) { | ||
deferred.reject(new Error("Please provide a paste ID to delete")); | ||
deferred.reject(new Error('Please provide a paste ID to delete')); | ||
} | ||
@@ -184,5 +195,3 @@ | ||
._postApi(conf.net.protocol + conf.net.base + conf.net.endpoint.post, p) | ||
.then(function (data) { | ||
deferred.resolve(data); | ||
}) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
@@ -200,3 +209,3 @@ | ||
} else { | ||
deferred.reject(new Error("Error! Deleting a paste created by the user needs username and password")); | ||
deferred.reject(new Error('Error! Deleting a paste created by the user needs username and password')); | ||
} | ||
@@ -221,3 +230,3 @@ | ||
if (data.length !== 32) { | ||
deferred.reject(new Error("Error in createAPIuserKey! " + data)); | ||
deferred.reject(new Error('Error in createAPIuserKey! ' + data)); | ||
} else { | ||
@@ -351,3 +360,3 @@ _this.config.api_user_key = data; | ||
if (data) { | ||
var rootObj = data["paste"], | ||
var rootObj = data.paste, | ||
normalize = _.map(rootObj, function (paste) { | ||
@@ -382,3 +391,3 @@ var obj = {}; | ||
if (data) { | ||
var rootObj = data["user"][0], | ||
var rootObj = data.user[0], | ||
normalize = {}; | ||
@@ -404,6 +413,6 @@ | ||
deferred = Q.defer(), | ||
xmlString = "", | ||
xmlString = '', | ||
parser = new xml2js.Parser({ | ||
"trim" : true, | ||
"explicitRoot" : false | ||
'trim' : true, | ||
'explicitRoot' : false | ||
}); | ||
@@ -415,6 +424,6 @@ | ||
xmlString = "<root>\n" + xml + "</root>\n"; | ||
xmlString = '<root>\n' + xml + '</root>\n'; | ||
parser.parseString(xmlString, function (err, data) { | ||
if (err) { | ||
deferred.reject(new Error("Error in parsing XML: " + err)); | ||
deferred.reject(new Error('Error in parsing XML: ' + err)); | ||
} else { | ||
@@ -430,4 +439,2 @@ deferred.resolve(data); | ||
* Returns a list with the required parameters from config | ||
* | ||
* TODO: Rewrite! Needs to make sure it is checking correctly | ||
*/ | ||
@@ -454,10 +461,3 @@ Pastebin.prototype._getRequired = function (paramlist) { | ||
Pastebin.prototype._getApi = function (path, params) { | ||
var deferred = Q.defer(); | ||
method | ||
.get(path, params) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
return deferred.promise; | ||
return method.get(path, params); | ||
}; | ||
@@ -469,12 +469,5 @@ | ||
Pastebin.prototype._postApi = function (path, params) { | ||
var deferred = Q.defer(); | ||
method | ||
.post(path, params) | ||
.then(deferred.resolve) | ||
.fail(deferred.reject); | ||
return deferred.promise; | ||
return method.post(path, params); | ||
}; | ||
module.exports = Pastebin; |
@@ -0,1 +1,2 @@ | ||
'use strict'; | ||
module.exports = function (grunt) { | ||
@@ -6,31 +7,11 @@ grunt.initConfig({ | ||
all: [ | ||
"Gruntfile.js", | ||
"index.js", | ||
"bin/*.js", | ||
"lib/*.js" | ||
'Gruntfile.js', | ||
'index.js', | ||
'bin/*.js', | ||
'lib/*.js' | ||
], | ||
options: { | ||
"node" : true, | ||
"browser" : false, | ||
"boss" : false, | ||
"curly" : true, | ||
"debug" : false, | ||
"devel" : false, | ||
"eqeqeq" : true, | ||
"eqnull" : true, | ||
"evil" : false, | ||
"forin" : false, | ||
"immed" : false, | ||
"laxbreak" : false, | ||
"newcap" : true, | ||
"noarg" : true, | ||
"noempty" : false, | ||
"nonew" : false, | ||
"onevar" : true, | ||
"plusplus" : false, | ||
"regexp" : false, | ||
"undef" : true, | ||
"sub" : true, | ||
"strict" : false, | ||
"white" : true | ||
jshintrc : '.jshintrc', | ||
reporter: require('jshint-stylish'), | ||
force: false | ||
} | ||
@@ -43,10 +24,18 @@ }, | ||
} | ||
}, | ||
simplemocha: { | ||
options: { | ||
globals: ['expect'], | ||
timeout: 3000, | ||
ignoreLeaks: false, | ||
ui: 'bdd', | ||
reporter: 'tap' | ||
}, | ||
all: { src: ['tests/*.js'] } | ||
} | ||
}); | ||
// grunt.loadTasks("tasks"); | ||
// These plugins provide necessary tasks. | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
grunt.loadNpmTasks('grunt-simple-mocha'); | ||
@@ -56,3 +45,5 @@ // Default task. | ||
grunt.registerTask('test', ['jshint', 'simplemocha']); | ||
grunt.registerTask('dev', ['jshint', 'watch']); | ||
}; | ||
}; |
@@ -0,2 +1,9 @@ | ||
0.2.0 / 2014-09-02 | ||
================== | ||
* Adding tests && Travis | ||
0.1.6 / 2014-07-03 | ||
================== | ||
@@ -3,0 +10,0 @@ * Change Q to lowercase, fixing error module not found |
@@ -0,1 +1,10 @@ | ||
'use strict'; | ||
/* | ||
* pastebin-js | ||
* https://github.com/j3lte/pastebin-js | ||
* | ||
* Copyright (c) 2014 Jelte Lagendijk | ||
* Licensed under the MIT license. | ||
*/ | ||
/** | ||
@@ -2,0 +11,0 @@ * Export Pastebin |
@@ -0,1 +1,9 @@ | ||
'use strict'; | ||
/* | ||
* pastebin-js | ||
* https://github.com/j3lte/pastebin-js | ||
* | ||
* Copyright (c) 2014 Jelte Lagendijk | ||
* Licensed under the MIT license. | ||
*/ | ||
var config = module.exports = { | ||
@@ -9,240 +17,240 @@ defaults : { | ||
net : { | ||
"protocol" : "http://", | ||
"base" : "pastebin.com/", | ||
"endpoint" : { | ||
"post" : "api/api_post.php", | ||
"login" : "api/api_login.php", | ||
"raw" : "raw.php?i=" | ||
'protocol' : 'http://', | ||
'base' : 'pastebin.com/', | ||
'endpoint' : { | ||
'post' : 'api/api_post.php', | ||
'login' : 'api/api_login.php', | ||
'raw' : 'raw.php?i=' | ||
} | ||
}, | ||
expiration : { | ||
"N" : "Never", | ||
"10M" : "10 Minutes", | ||
"1H" : "1 Hour", | ||
"1D" : "1 Day", | ||
"1W" : "1 Week", | ||
"2W" : "2 Weeks", | ||
"1M" : "1 Month" | ||
'N' : 'Never', | ||
'10M' : '10 Minutes', | ||
'1H' : '1 Hour', | ||
'1D' : '1 Day', | ||
'1W' : '1 Week', | ||
'2W' : '2 Weeks', | ||
'1M' : '1 Month' | ||
}, | ||
formats : { | ||
"4cs" : "4CS", | ||
"6502acme" : "6502 ACME Cross Assembler", | ||
"6502kickass" : "6502 Kick Assembler", | ||
"6502tasm" : "6502 TASM/64TASS", | ||
"abap" : "ABAP", | ||
"actionscript" : "ActionScript", | ||
"actionscript3" : "ActionScript 3", | ||
"ada" : "Ada", | ||
"algol68" : "ALGOL 68", | ||
"apache" : "Apache Log", | ||
"applescript" : "AppleScript", | ||
"apt_sources" : "APT Sources", | ||
"arm" : "ARM", | ||
"asm" : "ASM (NASM)", | ||
"asp" : "ASP", | ||
"asymptote" : "Asymptote", | ||
"autoconf" : "autoconf", | ||
"autohotkey" : "Autohotkey", | ||
"autoit" : "AutoIt", | ||
"avisynth" : "Avisynth", | ||
"awk" : "Awk", | ||
"bascomavr" : "BASCOM AVR", | ||
"bash" : "Bash", | ||
"basic4gl" : "Basic4GL", | ||
"bibtex" : "BibTeX", | ||
"blitzbasic" : "Blitz Basic", | ||
"bnf" : "BNF", | ||
"boo" : "BOO", | ||
"bf" : "BrainFuck", | ||
"c" : "C", | ||
"c_mac" : "C for Macs", | ||
"cil" : "C Intermediate Language", | ||
"csharp" : "C#", | ||
"cpp" : "C++", | ||
"cpp-qt" : "C++ (with QT extensions)", | ||
"c_loadrunner" : "C: Loadrunner", | ||
"caddcl" : "CAD DCL", | ||
"cadlisp" : "CAD Lisp", | ||
"cfdg" : "CFDG", | ||
"chaiscript" : "ChaiScript", | ||
"clojure" : "Clojure", | ||
"klonec" : "Clone C", | ||
"klonecpp" : "Clone C++", | ||
"cmake" : "CMake", | ||
"cobol" : "COBOL", | ||
"coffeescript" : "CoffeeScript", | ||
"cfm" : "ColdFusion", | ||
"css" : "CSS", | ||
"cuesheet" : "Cuesheet", | ||
"d" : "D", | ||
"dcl" : "DCL", | ||
"dcpu16" : "DCPU-16", | ||
"dcs" : "DCS", | ||
"delphi" : "Delphi", | ||
"oxygene" : "Delphi Prism (Oxygene)", | ||
"diff" : "Diff", | ||
"div" : "DIV", | ||
"dos" : "DOS", | ||
"dot" : "DOT", | ||
"e" : "E", | ||
"ecmascript" : "ECMAScript", | ||
"eiffel" : "Eiffel", | ||
"email" : "Email", | ||
"epc" : "EPC", | ||
"erlang" : "Erlang", | ||
"fsharp" : "F#", | ||
"falcon" : "Falcon", | ||
"fo" : "FO Language", | ||
"f1" : "Formula One", | ||
"fortran" : "Fortran", | ||
"freebasic" : "FreeBasic", | ||
"freeswitch" : "FreeSWITCH", | ||
"gambas" : "GAMBAS", | ||
"gml" : "Game Maker", | ||
"gdb" : "GDB", | ||
"genero" : "Genero", | ||
"genie" : "Genie", | ||
"gettext" : "GetText", | ||
"go" : "Go", | ||
"groovy" : "Groovy", | ||
"gwbasic" : "GwBasic", | ||
"haskell" : "Haskell", | ||
"haxe" : "Haxe", | ||
"hicest" : "HicEst", | ||
"hq9plus" : "HQ9 Plus", | ||
"html4strict" : "HTML", | ||
"html5" : "HTML 5", | ||
"icon" : "Icon", | ||
"idl" : "IDL", | ||
"ini" : "INI file", | ||
"inno" : "Inno Script", | ||
"intercal" : "INTERCAL", | ||
"io" : "IO", | ||
"j" : "J", | ||
"java" : "Java", | ||
"java5" : "Java 5", | ||
"javascript" : "JavaScript", | ||
"jquery" : "jQuery", | ||
"kixtart" : "KiXtart", | ||
"latex" : "Latex", | ||
"ldif" : "LDIF", | ||
"lb" : "Liberty BASIC", | ||
"lsl2" : "Linden Scripting", | ||
"lisp" : "Lisp", | ||
"llvm" : "LLVM", | ||
"locobasic" : "Loco Basic", | ||
"logtalk" : "Logtalk", | ||
"lolcode" : "LOL Code", | ||
"lotusformulas" : "Lotus Formulas", | ||
"lotusscript" : "Lotus Script", | ||
"lscript" : "LScript", | ||
"lua" : "Lua", | ||
"m68k" : "M68000 Assembler", | ||
"magiksf" : "MagikSF", | ||
"make" : "Make", | ||
"mapbasic" : "MapBasic", | ||
"matlab" : "MatLab", | ||
"mirc" : "mIRC", | ||
"mmix" : "MIX Assembler", | ||
"modula2" : "Modula 2", | ||
"modula3" : "Modula 3", | ||
"68000devpac" : "Motorola 68000 HiSoft Dev", | ||
"mpasm" : "MPASM", | ||
"mxml" : "MXML", | ||
"mysql" : "MySQL", | ||
"nagios" : "Nagios", | ||
"newlisp" : "newLISP", | ||
"text" : "None", | ||
"nsis" : "NullSoft Installer", | ||
"oberon2" : "Oberon 2", | ||
"objeck" : "Objeck Programming Langua", | ||
"objc" : "Objective C", | ||
"ocaml-brief" : "OCalm Brief", | ||
"ocaml" : "OCaml", | ||
"octave" : "Octave", | ||
"pf" : "OpenBSD PACKET FILTER", | ||
"glsl" : "OpenGL Shading", | ||
"oobas" : "Openoffice BASIC", | ||
"oracle11" : "Oracle 11", | ||
"oracle8" : "Oracle 8", | ||
"oz" : "Oz", | ||
"parasail" : "ParaSail", | ||
"parigp" : "PARI/GP", | ||
"pascal" : "Pascal", | ||
"pawn" : "PAWN", | ||
"pcre" : "PCRE", | ||
"per" : "Per", | ||
"perl" : "Perl", | ||
"perl6" : "Perl 6", | ||
"php" : "PHP", | ||
"php-brief" : "PHP Brief", | ||
"pic16" : "Pic 16", | ||
"pike" : "Pike", | ||
"pixelbender" : "Pixel Bender", | ||
"plsql" : "PL/SQL", | ||
"postgresql" : "PostgreSQL", | ||
"povray" : "POV-Ray", | ||
"powershell" : "Power Shell", | ||
"powerbuilder" : "PowerBuilder", | ||
"proftpd" : "ProFTPd", | ||
"progress" : "Progress", | ||
"prolog" : "Prolog", | ||
"properties" : "Properties", | ||
"providex" : "ProvideX", | ||
"purebasic" : "PureBasic", | ||
"pycon" : "PyCon", | ||
"python" : "Python", | ||
"pys60" : "Python for S60", | ||
"q" : "q/kdb+", | ||
"qbasic" : "QBasic", | ||
"rsplus" : "R", | ||
"rails" : "Rails", | ||
"rebol" : "REBOL", | ||
"reg" : "REG", | ||
"rexx" : "Rexx", | ||
"robots" : "Robots", | ||
"rpmspec" : "RPM Spec", | ||
"ruby" : "Ruby", | ||
"gnuplot" : "Ruby Gnuplot", | ||
"sas" : "SAS", | ||
"scala" : "Scala", | ||
"scheme" : "Scheme", | ||
"scilab" : "Scilab", | ||
"sdlbasic" : "SdlBasic", | ||
"smalltalk" : "Smalltalk", | ||
"smarty" : "Smarty", | ||
"spark" : "SPARK", | ||
"sparql" : "SPARQL", | ||
"sql" : "SQL", | ||
"stonescript" : "StoneScript", | ||
"systemverilog" : "SystemVerilog", | ||
"tsql" : "T-SQL", | ||
"tcl" : "TCL", | ||
"teraterm" : "Tera Term", | ||
"thinbasic" : "thinBasic", | ||
"typoscript" : "TypoScript", | ||
"unicon" : "Unicon", | ||
"uscript" : "UnrealScript", | ||
"ups" : "UPC", | ||
"urbi" : "Urbi", | ||
"vala" : "Vala", | ||
"vbnet" : "VB.NET", | ||
"vedit" : "Vedit", | ||
"verilog" : "VeriLog", | ||
"vhdl" : "VHDL", | ||
"vim" : "VIM", | ||
"visualprolog" : "Visual Pro Log", | ||
"vb" : "VisualBasic", | ||
"visualfoxpro" : "VisualFoxPro", | ||
"whitespace" : "WhiteSpace", | ||
"whois" : "WHOIS", | ||
"winbatch" : "Winbatch", | ||
"xbasic" : "XBasic", | ||
"xml" : "XML", | ||
"xorg_conf" : "Xorg Config", | ||
"xpp" : "XPP", | ||
"yaml" : "YAML", | ||
"z80" : "Z80 Assembler", | ||
"zxbasic" : "ZXBasic" | ||
'4cs' : '4CS', | ||
'6502acme' : '6502 ACME Cross Assembler', | ||
'6502kickass' : '6502 Kick Assembler', | ||
'6502tasm' : '6502 TASM/64TASS', | ||
'abap' : 'ABAP', | ||
'actionscript' : 'ActionScript', | ||
'actionscript3' : 'ActionScript 3', | ||
'ada' : 'Ada', | ||
'algol68' : 'ALGOL 68', | ||
'apache' : 'Apache Log', | ||
'applescript' : 'AppleScript', | ||
'apt_sources' : 'APT Sources', | ||
'arm' : 'ARM', | ||
'asm' : 'ASM (NASM)', | ||
'asp' : 'ASP', | ||
'asymptote' : 'Asymptote', | ||
'autoconf' : 'autoconf', | ||
'autohotkey' : 'Autohotkey', | ||
'autoit' : 'AutoIt', | ||
'avisynth' : 'Avisynth', | ||
'awk' : 'Awk', | ||
'bascomavr' : 'BASCOM AVR', | ||
'bash' : 'Bash', | ||
'basic4gl' : 'Basic4GL', | ||
'bibtex' : 'BibTeX', | ||
'blitzbasic' : 'Blitz Basic', | ||
'bnf' : 'BNF', | ||
'boo' : 'BOO', | ||
'bf' : 'BrainFuck', | ||
'c' : 'C', | ||
'c_mac' : 'C for Macs', | ||
'cil' : 'C Intermediate Language', | ||
'csharp' : 'C#', | ||
'cpp' : 'C++', | ||
'cpp-qt' : 'C++ (with QT extensions)', | ||
'c_loadrunner' : 'C: Loadrunner', | ||
'caddcl' : 'CAD DCL', | ||
'cadlisp' : 'CAD Lisp', | ||
'cfdg' : 'CFDG', | ||
'chaiscript' : 'ChaiScript', | ||
'clojure' : 'Clojure', | ||
'klonec' : 'Clone C', | ||
'klonecpp' : 'Clone C++', | ||
'cmake' : 'CMake', | ||
'cobol' : 'COBOL', | ||
'coffeescript' : 'CoffeeScript', | ||
'cfm' : 'ColdFusion', | ||
'css' : 'CSS', | ||
'cuesheet' : 'Cuesheet', | ||
'd' : 'D', | ||
'dcl' : 'DCL', | ||
'dcpu16' : 'DCPU-16', | ||
'dcs' : 'DCS', | ||
'delphi' : 'Delphi', | ||
'oxygene' : 'Delphi Prism (Oxygene)', | ||
'diff' : 'Diff', | ||
'div' : 'DIV', | ||
'dos' : 'DOS', | ||
'dot' : 'DOT', | ||
'e' : 'E', | ||
'ecmascript' : 'ECMAScript', | ||
'eiffel' : 'Eiffel', | ||
'email' : 'Email', | ||
'epc' : 'EPC', | ||
'erlang' : 'Erlang', | ||
'fsharp' : 'F#', | ||
'falcon' : 'Falcon', | ||
'fo' : 'FO Language', | ||
'f1' : 'Formula One', | ||
'fortran' : 'Fortran', | ||
'freebasic' : 'FreeBasic', | ||
'freeswitch' : 'FreeSWITCH', | ||
'gambas' : 'GAMBAS', | ||
'gml' : 'Game Maker', | ||
'gdb' : 'GDB', | ||
'genero' : 'Genero', | ||
'genie' : 'Genie', | ||
'gettext' : 'GetText', | ||
'go' : 'Go', | ||
'groovy' : 'Groovy', | ||
'gwbasic' : 'GwBasic', | ||
'haskell' : 'Haskell', | ||
'haxe' : 'Haxe', | ||
'hicest' : 'HicEst', | ||
'hq9plus' : 'HQ9 Plus', | ||
'html4strict' : 'HTML', | ||
'html5' : 'HTML 5', | ||
'icon' : 'Icon', | ||
'idl' : 'IDL', | ||
'ini' : 'INI file', | ||
'inno' : 'Inno Script', | ||
'intercal' : 'INTERCAL', | ||
'io' : 'IO', | ||
'j' : 'J', | ||
'java' : 'Java', | ||
'java5' : 'Java 5', | ||
'javascript' : 'JavaScript', | ||
'jquery' : 'jQuery', | ||
'kixtart' : 'KiXtart', | ||
'latex' : 'Latex', | ||
'ldif' : 'LDIF', | ||
'lb' : 'Liberty BASIC', | ||
'lsl2' : 'Linden Scripting', | ||
'lisp' : 'Lisp', | ||
'llvm' : 'LLVM', | ||
'locobasic' : 'Loco Basic', | ||
'logtalk' : 'Logtalk', | ||
'lolcode' : 'LOL Code', | ||
'lotusformulas' : 'Lotus Formulas', | ||
'lotusscript' : 'Lotus Script', | ||
'lscript' : 'LScript', | ||
'lua' : 'Lua', | ||
'm68k' : 'M68000 Assembler', | ||
'magiksf' : 'MagikSF', | ||
'make' : 'Make', | ||
'mapbasic' : 'MapBasic', | ||
'matlab' : 'MatLab', | ||
'mirc' : 'mIRC', | ||
'mmix' : 'MIX Assembler', | ||
'modula2' : 'Modula 2', | ||
'modula3' : 'Modula 3', | ||
'68000devpac' : 'Motorola 68000 HiSoft Dev', | ||
'mpasm' : 'MPASM', | ||
'mxml' : 'MXML', | ||
'mysql' : 'MySQL', | ||
'nagios' : 'Nagios', | ||
'newlisp' : 'newLISP', | ||
'text' : 'None', | ||
'nsis' : 'NullSoft Installer', | ||
'oberon2' : 'Oberon 2', | ||
'objeck' : 'Objeck Programming Langua', | ||
'objc' : 'Objective C', | ||
'ocaml-brief' : 'OCalm Brief', | ||
'ocaml' : 'OCaml', | ||
'octave' : 'Octave', | ||
'pf' : 'OpenBSD PACKET FILTER', | ||
'glsl' : 'OpenGL Shading', | ||
'oobas' : 'Openoffice BASIC', | ||
'oracle11' : 'Oracle 11', | ||
'oracle8' : 'Oracle 8', | ||
'oz' : 'Oz', | ||
'parasail' : 'ParaSail', | ||
'parigp' : 'PARI/GP', | ||
'pascal' : 'Pascal', | ||
'pawn' : 'PAWN', | ||
'pcre' : 'PCRE', | ||
'per' : 'Per', | ||
'perl' : 'Perl', | ||
'perl6' : 'Perl 6', | ||
'php' : 'PHP', | ||
'php-brief' : 'PHP Brief', | ||
'pic16' : 'Pic 16', | ||
'pike' : 'Pike', | ||
'pixelbender' : 'Pixel Bender', | ||
'plsql' : 'PL/SQL', | ||
'postgresql' : 'PostgreSQL', | ||
'povray' : 'POV-Ray', | ||
'powershell' : 'Power Shell', | ||
'powerbuilder' : 'PowerBuilder', | ||
'proftpd' : 'ProFTPd', | ||
'progress' : 'Progress', | ||
'prolog' : 'Prolog', | ||
'properties' : 'Properties', | ||
'providex' : 'ProvideX', | ||
'purebasic' : 'PureBasic', | ||
'pycon' : 'PyCon', | ||
'python' : 'Python', | ||
'pys60' : 'Python for S60', | ||
'q' : 'q/kdb+', | ||
'qbasic' : 'QBasic', | ||
'rsplus' : 'R', | ||
'rails' : 'Rails', | ||
'rebol' : 'REBOL', | ||
'reg' : 'REG', | ||
'rexx' : 'Rexx', | ||
'robots' : 'Robots', | ||
'rpmspec' : 'RPM Spec', | ||
'ruby' : 'Ruby', | ||
'gnuplot' : 'Ruby Gnuplot', | ||
'sas' : 'SAS', | ||
'scala' : 'Scala', | ||
'scheme' : 'Scheme', | ||
'scilab' : 'Scilab', | ||
'sdlbasic' : 'SdlBasic', | ||
'smalltalk' : 'Smalltalk', | ||
'smarty' : 'Smarty', | ||
'spark' : 'SPARK', | ||
'sparql' : 'SPARQL', | ||
'sql' : 'SQL', | ||
'stonescript' : 'StoneScript', | ||
'systemverilog' : 'SystemVerilog', | ||
'tsql' : 'T-SQL', | ||
'tcl' : 'TCL', | ||
'teraterm' : 'Tera Term', | ||
'thinbasic' : 'thinBasic', | ||
'typoscript' : 'TypoScript', | ||
'unicon' : 'Unicon', | ||
'uscript' : 'UnrealScript', | ||
'ups' : 'UPC', | ||
'urbi' : 'Urbi', | ||
'vala' : 'Vala', | ||
'vbnet' : 'VB.NET', | ||
'vedit' : 'Vedit', | ||
'verilog' : 'VeriLog', | ||
'vhdl' : 'VHDL', | ||
'vim' : 'VIM', | ||
'visualprolog' : 'Visual Pro Log', | ||
'vb' : 'VisualBasic', | ||
'visualfoxpro' : 'VisualFoxPro', | ||
'whitespace' : 'WhiteSpace', | ||
'whois' : 'WHOIS', | ||
'winbatch' : 'Winbatch', | ||
'xbasic' : 'XBasic', | ||
'xml' : 'XML', | ||
'xorg_conf' : 'Xorg Config', | ||
'xpp' : 'XPP', | ||
'yaml' : 'YAML', | ||
'z80' : 'Z80 Assembler', | ||
'zxbasic' : 'ZXBasic' | ||
} | ||
}; | ||
}; |
@@ -0,1 +1,9 @@ | ||
'use strict'; | ||
/* | ||
* pastebin-js | ||
* https://github.com/j3lte/pastebin-js | ||
* | ||
* Copyright (c) 2014 Jelte Lagendijk | ||
* Licensed under the MIT license. | ||
*/ | ||
var request = require('request'), | ||
@@ -25,3 +33,3 @@ config = require('./config'), | ||
qs : params, | ||
method : "GET", | ||
method : 'GET', | ||
headers : HEADERS, | ||
@@ -36,12 +44,12 @@ timeout : TIMEOUT, | ||
if (status === 404) { | ||
deferred.reject(new Error("Error 404, paste not found!")); | ||
deferred.reject(new Error('Error 404, paste not found!')); | ||
} | ||
if (status !== 200) { | ||
deferred.reject(new Error("Unknown error, status: " + status)); | ||
deferred.reject(new Error('Unknown error, status: ' + status)); | ||
} | ||
if (body.length === 0) { | ||
deferred.reject(new Error("Empty response")); | ||
deferred.reject(new Error('Empty response')); | ||
} | ||
if (body.indexOf("Bad API request") !== -1) { | ||
deferred.reject(new Error("Error: " + body)); | ||
if (body.indexOf('Bad API request') !== -1) { | ||
deferred.reject(new Error('Error: ' + body)); | ||
} | ||
@@ -66,3 +74,3 @@ deferred.resolve(body); | ||
uri : path, | ||
method : "POST", | ||
method : 'POST', | ||
form : params, | ||
@@ -78,10 +86,14 @@ headers : HEADERS, | ||
if (status !== 200) { | ||
deferred.reject(new Error("Unknown error, status: " + status)); | ||
deferred.reject(new Error('Unknown error, status: ' + status)); | ||
} | ||
if (body.length === 0) { | ||
deferred.reject(new Error("Empty response")); | ||
deferred.reject(new Error('Empty response')); | ||
} | ||
if (body.indexOf("Bad API request") !== -1) { | ||
deferred.reject(new Error("Error: " + body)); | ||
if (body.indexOf('Bad API request') !== -1) { | ||
deferred.reject(new Error('Error: ' + body)); | ||
} | ||
if (body.indexOf('http') === 0) { | ||
// return an ID instead of the url | ||
body = body.replace('http://pastebin.com/',''); | ||
} | ||
deferred.resolve(body); | ||
@@ -88,0 +100,0 @@ }); |
{ | ||
"name": "pastebin-js", | ||
"version": "0.1.5", | ||
"version": "0.2.1", | ||
"npm-shrinkwrap-version": "3.1.8", | ||
"dependencies": { | ||
"q": { | ||
"version": "0.9.7", | ||
"from": "q@~0.9.7" | ||
"version": "1.0.1", | ||
"resolved": "https://registry.npmjs.org/q/-/q-1.0.1.tgz" | ||
}, | ||
"request": { | ||
"version": "2.27.0", | ||
"from": "request@*", | ||
"version": "2.40.0", | ||
"resolved": "https://registry.npmjs.org/request/-/request-2.40.0.tgz", | ||
"dependencies": { | ||
"qs": { | ||
"version": "0.6.5", | ||
"from": "qs@~0.6.0" | ||
"aws-sign2": { | ||
"version": "0.5.0", | ||
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz" | ||
}, | ||
"json-stringify-safe": { | ||
"version": "5.0.0", | ||
"from": "json-stringify-safe@~5.0.0" | ||
}, | ||
"forever-agent": { | ||
"version": "0.5.0", | ||
"from": "forever-agent@~0.5.0" | ||
"version": "0.5.2", | ||
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.5.2.tgz" | ||
}, | ||
"tunnel-agent": { | ||
"version": "0.3.0", | ||
"from": "tunnel-agent@~0.3.0" | ||
}, | ||
"http-signature": { | ||
"version": "0.10.0", | ||
"from": "http-signature@~0.10.0", | ||
"form-data": { | ||
"version": "0.1.4", | ||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-0.1.4.tgz", | ||
"dependencies": { | ||
"assert-plus": { | ||
"version": "0.1.2", | ||
"from": "assert-plus@0.1.2" | ||
"async": { | ||
"version": "0.9.0", | ||
"resolved": "https://registry.npmjs.org/async/-/async-0.9.0.tgz" | ||
}, | ||
"asn1": { | ||
"version": "0.1.11", | ||
"from": "asn1@0.1.11" | ||
"combined-stream": { | ||
"version": "0.0.5", | ||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.5.tgz", | ||
"dependencies": { | ||
"delayed-stream": { | ||
"version": "0.0.5", | ||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz" | ||
} | ||
} | ||
}, | ||
"ctype": { | ||
"version": "0.5.2", | ||
"from": "ctype@0.5.2" | ||
"mime": { | ||
"version": "1.2.11", | ||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz" | ||
} | ||
@@ -48,62 +47,78 @@ } | ||
"hawk": { | ||
"version": "1.0.0", | ||
"from": "hawk@~1.0.0", | ||
"version": "1.1.1", | ||
"resolved": "https://registry.npmjs.org/hawk/-/hawk-1.1.1.tgz", | ||
"dependencies": { | ||
"hoek": { | ||
"version": "0.9.1", | ||
"from": "hoek@0.9.x" | ||
}, | ||
"boom": { | ||
"version": "0.4.2", | ||
"from": "boom@0.4.x" | ||
"resolved": "https://registry.npmjs.org/boom/-/boom-0.4.2.tgz" | ||
}, | ||
"cryptiles": { | ||
"version": "0.2.2", | ||
"from": "cryptiles@0.2.x" | ||
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-0.2.2.tgz" | ||
}, | ||
"hoek": { | ||
"version": "0.9.1", | ||
"resolved": "https://registry.npmjs.org/hoek/-/hoek-0.9.1.tgz" | ||
}, | ||
"sntp": { | ||
"version": "0.2.4", | ||
"from": "sntp@0.2.x" | ||
"resolved": "https://registry.npmjs.org/sntp/-/sntp-0.2.4.tgz" | ||
} | ||
} | ||
}, | ||
"aws-sign": { | ||
"version": "0.3.0", | ||
"from": "aws-sign@~0.3.0" | ||
"http-signature": { | ||
"version": "0.10.0", | ||
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-0.10.0.tgz", | ||
"dependencies": { | ||
"asn1": { | ||
"version": "0.1.11", | ||
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz" | ||
}, | ||
"assert-plus": { | ||
"version": "0.1.2", | ||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.2.tgz" | ||
}, | ||
"ctype": { | ||
"version": "0.5.2", | ||
"resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.2.tgz" | ||
} | ||
} | ||
}, | ||
"oauth-sign": { | ||
"version": "0.3.0", | ||
"from": "oauth-sign@~0.3.0" | ||
"json-stringify-safe": { | ||
"version": "5.0.0", | ||
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.0.tgz" | ||
}, | ||
"cookie-jar": { | ||
"version": "0.3.0", | ||
"from": "cookie-jar@~0.3.0" | ||
"mime-types": { | ||
"version": "1.0.2", | ||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-1.0.2.tgz" | ||
}, | ||
"node-uuid": { | ||
"version": "1.4.1", | ||
"from": "node-uuid@~1.4.0" | ||
"resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.1.tgz" | ||
}, | ||
"mime": { | ||
"version": "1.2.11", | ||
"from": "mime@~1.2.9" | ||
"oauth-sign": { | ||
"version": "0.3.0", | ||
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.3.0.tgz" | ||
}, | ||
"form-data": { | ||
"version": "0.1.2", | ||
"from": "form-data@~0.1.0", | ||
"qs": { | ||
"version": "1.0.2", | ||
"resolved": "https://registry.npmjs.org/qs/-/qs-1.0.2.tgz" | ||
}, | ||
"stringstream": { | ||
"version": "0.0.4", | ||
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.4.tgz" | ||
}, | ||
"tough-cookie": { | ||
"version": "0.12.1", | ||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-0.12.1.tgz", | ||
"dependencies": { | ||
"combined-stream": { | ||
"version": "0.0.4", | ||
"from": "combined-stream@~0.0.4", | ||
"dependencies": { | ||
"delayed-stream": { | ||
"version": "0.0.5", | ||
"from": "delayed-stream@0.0.5" | ||
} | ||
} | ||
}, | ||
"async": { | ||
"version": "0.2.9", | ||
"from": "async@~0.2.9" | ||
"punycode": { | ||
"version": "1.3.1", | ||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.1.tgz" | ||
} | ||
} | ||
}, | ||
"tunnel-agent": { | ||
"version": "0.4.0", | ||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.0.tgz" | ||
} | ||
@@ -113,16 +128,22 @@ } | ||
"underscore": { | ||
"version": "1.5.2", | ||
"from": "underscore@*" | ||
"version": "1.7.0", | ||
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz" | ||
}, | ||
"xml2js": { | ||
"version": "0.4.0", | ||
"from": "xml2js@*", | ||
"version": "0.4.4", | ||
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.4.tgz", | ||
"dependencies": { | ||
"sax": { | ||
"version": "0.5.5", | ||
"from": "sax@0.5.x" | ||
"version": "0.6.0", | ||
"resolved": "https://registry.npmjs.org/sax/-/sax-0.6.0.tgz" | ||
}, | ||
"xmlbuilder": { | ||
"version": "1.0.2", | ||
"from": "xmlbuilder@>=0.4.2" | ||
"version": "2.4.3", | ||
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-2.4.3.tgz", | ||
"dependencies": { | ||
"lodash-node": { | ||
"version": "2.4.1", | ||
"resolved": "https://registry.npmjs.org/lodash-node/-/lodash-node-2.4.1.tgz" | ||
} | ||
} | ||
} | ||
@@ -132,2 +153,2 @@ } | ||
} | ||
} | ||
} |
{ | ||
"name": "pastebin-js", | ||
"version": "0.1.6", | ||
"description": "NodeJS module for Pastebin API", | ||
"main": "index", | ||
"bin": { | ||
"pastebin": "./bin/pastebin.js" | ||
}, | ||
"scripts": { | ||
"test": "grunt" | ||
}, | ||
"keywords": [ | ||
"pastebin" | ||
], | ||
"dependencies": { | ||
"underscore": "*", | ||
"request": "*", | ||
"xml2js": "*", | ||
"q": "*" | ||
}, | ||
"devDependencies": { | ||
"grunt": "latest", | ||
"grunt-contrib-jshint": "latest", | ||
"grunt-contrib-watch": "latest" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/j3lte/pastebin-js" | ||
}, | ||
"engines": { | ||
"node": "*" | ||
}, | ||
"readmeFilename": "README.md", | ||
"author": { | ||
"name": "J.W. Lagendijk", | ||
"email": "jwlagendijk@gmail.com" | ||
}, | ||
"license": "MIT" | ||
"name": "pastebin-js", | ||
"version": "0.2.1", | ||
"description": "NodeJS module for Pastebin API", | ||
"main": "index", | ||
"bin": { | ||
"pastebin": "./bin/pastebin.js" | ||
}, | ||
"scripts": { | ||
"test": "./node_modules/.bin/mocha tests/*.js" | ||
}, | ||
"keywords": [ | ||
"pastebin" | ||
], | ||
"dependencies": { | ||
"q": "*", | ||
"request": "*", | ||
"underscore": "*", | ||
"xml2js": "*" | ||
}, | ||
"devDependencies": { | ||
"chai": "*", | ||
"grunt": "*", | ||
"grunt-contrib-jshint": "*", | ||
"grunt-contrib-watch": "*", | ||
"grunt-jsdoc-to-markdown": "*", | ||
"grunt-simple-mocha": "*", | ||
"jshint-stylish": "*", | ||
"mocha": "*", | ||
"nock": "*" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/j3lte/pastebin-js" | ||
}, | ||
"engines": { | ||
"node": "^0.10" | ||
}, | ||
"readmeFilename": "README.md", | ||
"author": { | ||
"name": "J.W. Lagendijk", | ||
"email": "jwlagendijk@gmail.com" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -1,2 +0,2 @@ | ||
pastebin-js | ||
pastebin-js [![Build Status](https://travis-ci.org/j3lte/pastebin-js.svg?branch=master)](https://travis-ci.org/j3lte/pastebin-js) | ||
=========== | ||
@@ -38,3 +38,3 @@ | ||
.then(function (data) { | ||
// we have succesfully pasted it. Data contains the url | ||
// we have succesfully pasted it. Data contains the id | ||
console.log(data); | ||
@@ -66,3 +66,3 @@ }) | ||
'api_user_password' : 'PastebinPassword' | ||
}); | ||
}); | ||
``` | ||
@@ -95,3 +95,3 @@ | ||
.then(function (data) { | ||
// paste succesfully created, data contains the paste url | ||
// paste succesfully created, data contains the id | ||
console.log(data); | ||
@@ -110,3 +110,3 @@ }) | ||
**pastebin.getUserInfo()** : gets the userinfo | ||
**pastebin.getUserInfo()** : gets the userinfo | ||
@@ -113,0 +113,0 @@ **pastebin.listUserPastes(limit)** : gets a list of pastes from the user. ``limit`` is optional, from 1 - 100 (default: 50) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40644
13
941
9