add debian building. add asset compile and embedding. other fixes.

This commit is contained in:
xuu
2017-04-24 09:20:46 -06:00
parent 8e6da6cd30
commit db6d5afb09
33 changed files with 610 additions and 2244 deletions

View File

@@ -1,9 +1,9 @@
var app = angular.module('souris-app', ['souris-common', 'hljs']).
config(function ($routeProvider) {
$routeProvider.
when('/', {controller: CreateCtrl, templateUrl: 'create.html'}).
when('/:id!:key', {controller: ViewCtrl, templateUrl: 'view.html'}).
when('/:id', {controller: ViewCtrl, templateUrl: 'view.html'}).
when('/', {controller: CreateCtrl, templateUrl: 'ui/create.html'}).
when('/:id!:key', {controller: ViewCtrl, templateUrl: 'ui/view.html'}).
when('/:id', {controller: ViewCtrl, templateUrl: 'ui/view.html'}).
otherwise({redirectTo: '/'});
});
@@ -14,8 +14,7 @@
$scope.reload = $route.reload;
$scope.o = {text: TEXT};
var base_url = $location.absUrl();
base_url = base_url.slice(0, base_url.indexOf('#'));
var base_url = window.location.origin;
$scope.$base_url = base_url;
// Add Randomness to RNG
@@ -53,7 +52,7 @@
if (o.text.length > 512) {o.zip = true; $scope.o.zip = true; }
var e = encrypt(o);
console.log("Sending:\n" + json(e));
console.log("Sending:\n" + e.txt);
$remoteService('/paste')
.post({}, e.txt)
@@ -70,8 +69,7 @@
function ViewCtrl($scope, $params, $remoteService, $location) {
"use strict";
var base_url = $location.absUrl();
base_url = base_url.slice(0, base_url.indexOf('#'));
var base_url = window.location.origin;
$scope.$base_url = base_url;
var id = $params.id,
@@ -86,7 +84,7 @@
$scope.copy = function(t) {
TEXT = t;
$location.path('/');
}
};
$remoteService('/paste/:id')
.get({id: id})
.success(decrypt(key, store))
@@ -111,11 +109,11 @@
enc: function (t, p) { return CryptoJS.AES.encrypt(t, p).toString(); },
dec: function (c, p) { return CryptoJS.AES.decrypt(c, p); },
b64: function (s) {
if (s == undefined) return;
if (s === undefined) return;
return CryptoJS.enc.Base64.stringify(s).replace(/[=]+/, '').replace(/\//g, '_').replace(/\+/g, '-');
},
d64: function (s) {
if (s == undefined) return;
if (s === undefined) return;
switch (s.length % 3) {
case 2:
s += '=';
@@ -148,16 +146,16 @@
str8: function (ua) {
var s = '';
for (var i = 0; i < ua.byteLength; i++) {
if ((ua[i]&0x80) == 0) s += String.fromCharCode(ua[i]);
else if ((ua[i]&0xe0) == 0xc0 && (ua[i+1]&0xc0) == 0x80) {
if ((ua[i]&0x80) === 0) s += String.fromCharCode(ua[i]);
else if ((ua[i]&0xe0) === 0xc0 && (ua[i+1]&0xc0) === 0x80) {
s += String.fromCharCode(((ua[i]&0x1f)<<6) + (ua[i+1]&0x3f));
i += 1;
}
else if ((ua[i]&0xf0) == 0xe0 && (ua[i+1]&0xc0) == 0x80 && (ua[i+2]&0xc0) == 0x80){
else if ((ua[i]&0xf0) === 0xe0 && (ua[i+1]&0xc0) === 0x80 && (ua[i+2]&0xc0) === 0x80){
s += String.fromCharCode(((ua[i]&0x0f)<<12) + ((ua[i+1]&0x3f)<<6) + (ua[i+2]&0x3f));
i += 2;
}
else if ((ua[i]&0xf8) == 0xf0 && (ua[i+1]&0xc0) == 0x80 && (ua[i+2]&0xc0) == 0x80 && (ua[i+3]&0xc0) == 0x80) {
else if ((ua[i]&0xf8) === 0xf0 && (ua[i+1]&0xc0) === 0x80 && (ua[i+2]&0xc0) === 0x80 && (ua[i+3]&0xc0) === 0x80) {
s += String.fromCharCode(((ua[i]&0x0f)<<18) + ((ua[i+1]&0x3f)<<12) + ((ua[i+2]&0x3f)<<6) + (ua[i+3]&0x3f));
i += 3;
}
@@ -184,7 +182,7 @@
var i = 0;
while (true) {
if (s[i] == "") break;
if (s[i] === "") break;
var l = s[i].trim().split(':\t');
d[l[0]] = l[1];
@@ -194,7 +192,7 @@
d.tx = s.splice(i).join('');
if (key === undefined) tgt({err: "Missing Key", code: 'no_key'});
else if (d.chk != fn.rmd(fn.d64(key))) tgt({err: "Invalid Key", code: "bad_key"});
else if (d.chk !== fn.rmd(fn.d64(key))) tgt({err: "Invalid Key", code: "bad_key"});
else {
var tx;
if (d.zip) {
@@ -207,7 +205,7 @@
var lang = 'text';
for (i = 0; i < HighliteLang.length; i++)
if (d.lang == HighliteLang[i][0])
if (d.lang === HighliteLang[i][0])
lang = HighliteLang[i][0];
tgt({code: 'ok', tx: tx, lang: lang, exp: d.exp, zip: d.zip});
@@ -264,7 +262,7 @@
m.filter('blength', function () {
return function (o) {
if (!(typeof o == 'string' || o instanceof String)) return;
if (!(typeof o === 'string' || o instanceof String)) return;
if (o === undefined || o.length === undefined) return;
var utf8length = 0;
for (var n = 0; n < o.length; n++) {

5
assets/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

3
assets/highlightjs.min.css vendored Normal file
View File

@@ -0,0 +1,3 @@
/* highlight.js 8.4 */
.hljs{display:block;overflow-x:auto;padding:0.5em;background:#f0f0f0;-webkit-text-size-adjust:none}.hljs,.hljs-subst,.hljs-tag .hljs-title,.nginx .hljs-title{color:black}.hljs-string,.hljs-title,.hljs-constant,.hljs-parent,.hljs-tag .hljs-value,.hljs-rules .hljs-value,.hljs-preprocessor,.hljs-pragma,.haml .hljs-symbol,.ruby .hljs-symbol,.ruby .hljs-symbol .hljs-string,.hljs-template_tag,.django .hljs-variable,.smalltalk .hljs-class,.hljs-addition,.hljs-flow,.hljs-stream,.bash .hljs-variable,.apache .hljs-tag,.apache .hljs-cbracket,.tex .hljs-command,.tex .hljs-special,.erlang_repl .hljs-function_or_atom,.asciidoc .hljs-header,.markdown .hljs-header,.coffeescript .hljs-attribute{color:#800}.smartquote,.hljs-comment,.hljs-annotation,.diff .hljs-header,.hljs-chunk,.asciidoc .hljs-blockquote,.markdown .hljs-blockquote{color:#888}.hljs-number,.hljs-date,.hljs-regexp,.hljs-literal,.hljs-hexcolor,.smalltalk .hljs-symbol,.smalltalk .hljs-char,.go .hljs-constant,.hljs-change,.lasso .hljs-variable,.makefile .hljs-variable,.asciidoc .hljs-bullet,.markdown .hljs-bullet,.asciidoc .hljs-link_url,.markdown .hljs-link_url{color:#080}.hljs-label,.hljs-javadoc,.ruby .hljs-string,.hljs-decorator,.hljs-filter .hljs-argument,.hljs-localvars,.hljs-array,.hljs-attr_selector,.hljs-important,.hljs-pseudo,.hljs-pi,.haml .hljs-bullet,.hljs-doctype,.hljs-deletion,.hljs-envvar,.hljs-shebang,.apache .hljs-sqbracket,.nginx .hljs-built_in,.tex .hljs-formula,.erlang_repl .hljs-reserved,.hljs-prompt,.asciidoc .hljs-link_label,.markdown .hljs-link_label,.vhdl .hljs-attribute,.clojure .hljs-attribute,.asciidoc .hljs-attribute,.lasso .hljs-attribute,.coffeescript .hljs-property,.hljs-phony{color:#88f}.hljs-keyword,.hljs-id,.hljs-title,.hljs-built_in,.css .hljs-tag,.hljs-javadoctag,.hljs-phpdoc,.hljs-dartdoc,.hljs-yardoctag,.smalltalk .hljs-class,.hljs-winutils,.bash .hljs-variable,.apache .hljs-tag,.hljs-type,.hljs-typename,.tex .hljs-command,.asciidoc .hljs-strong,.markdown .hljs-strong,.hljs-request,.hljs-status{font-weight:bold}.asciidoc .hljs-emphasis,.markdown .hljs-emphasis{font-style:italic}.nginx .hljs-built_in{font-weight:normal}.coffeescript .javascript,.javascript .xml,.lasso .markup,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:0.5}
.hljs{display:block;overflow-x:auto;padding:0.5em;background:#ffffff}.hljs,.hljs-subst{color:#444}.hljs-keyword,.hljs-attribute,.hljs-selector-tag,.hljs-meta-keyword,.hljs-doctag,.hljs-name{font-weight:bold}.hljs-built_in,.hljs-literal,.hljs-bullet,.hljs-code,.hljs-addition{color:#1F811F}.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr,.hljs-selector-pseudo{color:#BC6060}.hljs-type,.hljs-string,.hljs-number,.hljs-selector-id,.hljs-selector-class,.hljs-quote,.hljs-template-tag,.hljs-deletion{color:#880000}.hljs-title,.hljs-section{color:#880000;font-weight:bold}.hljs-comment{color:#888888}.hljs-meta{color:#2B6EA1}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold}

View File

@@ -1,28 +1,35 @@
<?doctype html?>
<html ng-app='souris-app'>
<head>
<base href="/" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PasteBox</title>
<!--INSERT_TEMPLATES-->
</head>
<body>
<div id="wrapper">
<div class="container-responsive">
<article ng-view></article>
<a onclick='var elm = document.getElementById("debug"); elm.parentNode.style.display="block"; window.scrollTop = window.scrollHeight;' style="margin:3px;cursor:context-menu;font-family:monospace;position:fixed;bottom:0;right:0">&pi;</a>
<div class='panel panel-default' style='height:13em;margin-bottom:0;margin-top:2em;;display:none;position:relative;bottom:0'><b>Debug Log</b>
<div style='float:right'>
<a class="btn" onclick='document.getElementById("debug").parentNode.style.display="none";'><i class='glyphicon glyphicon-remove'></i></a><br/>
<a class="btn" onclick='var elm=document.getElementById("debug");while (elm.firstChild) {elm.removeChild(elm.firstChild);}'><i class='glyphicon glyphicon-ban-circle'></i></a>
<div class="container-responsive">
<article ng-view></article>
<a onclick='var elm = document.getElementById("debug"); elm.parentNode.style.display="block"; window.scrollTop = window.scrollHeight;' style="margin:3px;cursor:context-menu;font-family:monospace;position:fixed;bottom:0;right:0">&pi;</a>
<div class='panel panel-default' style='height:13em;margin-bottom:0;margin-top:2em;;display:none;position:relative;bottom:0'><b>Debug Log</b>
<div style='float:right'>
<a class="btn" onclick='document.getElementById("debug").parentNode.style.display="none";'><i class='glyphicon glyphicon-remove'></i></a><br/>
<a class="btn" onclick='var elm=document.getElementById("debug");while (elm.firstChild) {elm.removeChild(elm.firstChild);}'><i class='glyphicon glyphicon-ban-circle'></i></a>
</div>
<pre id=debug style='height:12em; overflow:scroll;'></pre>
<footer></footer></div>
</div>
<pre id=debug style='height:12em; overflow:x-scroll;'></pre>
<footer></footer></div>
</div>
</div>
<link rel="stylesheet" href="style.css" integrity='sha384-2g6CT1TMuzCclIAqYC+AkSkfA21njEedIBVs+k3tcZ6gHhCU7s17aGJMLvYsF0fK'>
<!--REMOVE_ASSET_START-->
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="highlightjs.min.css">
<script src='lib.js'></script>
<!--REMOVE_ASSET_END-->
<link rel="stylesheet" href="style.css" />
<script src='app.js'></script>
<noscript>
<div class=container-responsive>
@@ -53,5 +60,4 @@
</div>
</noscript>
</body>
</html>
</html>

View File

@@ -455,4 +455,4 @@ angular.module("hljs",[]).provider("hljsService",function(){var a={};return{setO
*/
var AppConfig = {aspect: null};
!function(a,b){m=a.module("souris-common",["ngRoute","ngCookies"]),m.factory("$remoteService",["$http","$cookies","$location",function(a,c,d){var e=function(e,f,g,h){var i={cache:!1,headers:{"If-Modified-Since":"0"},withCredentials:!0};void 0!==c.get("XSRF-TOKEN-DEV")&&(i.headers={"X-XSRF-TOKEN-DEV":c.get("XSRF-TOKEN-DEV")}),i.method=e,void 0===g&&(g={}),void 0===g.aspect&&(g.aspect=d.absUrl().split("#")[0].replace(/\/$/,"").split(d.host()+"/",2),1==g.aspect.length?g.aspect="/":g.aspect=g.aspect[1].split("/",2)[0],void 0!==b.aspect&&(g.aspect=b.aspect));for(var j in g)if(g.hasOwnProperty(j)){var k=":"+j;f.search(k)>0&&(f=f.replace(k,g[j]),delete g[j])}return i.params=g,i.url=f,void 0!==h&&(i.data=h),a("DELETE"==e||"JSONP"==e?i:i)};return function(a){return{get:function(b){return e("GET",a,b)},put:function(b,c){return e("PUT",a,b,c)},post:function(b,c){return e("POST",a,b,c)},patch:function(b,c){return e("PATCH",a,b,c)},del:function(b){return e("DELETE",a,b)},delete:function(b){return e("DELETE",a,b)},jsonp:function(b){return e("JSONP",a,b)}}}}]),m.directive("selectOnClick",function(){"use strict";return{restrict:"A",link:function(a,b){b.on("click",function(){this.select()})}}}),m.filter("default",function(){return function(a,b){return void 0===a?b:a}})}(angular,AppConfig);
!function(a,b){m=a.module("souris-common",["ngRoute","ngCookies"]),m.config(['$locationProvider', function(l){l.html5Mode(false);}]),m.factory("$remoteService",["$http","$cookies","$location",function(a,c,d){var e=function(e,f,g,h){var i={cache:!1,headers:{"If-Modified-Since":"0"},withCredentials:!0};void 0!==c.get("XSRF-TOKEN-DEV")&&(i.headers={"X-XSRF-TOKEN-DEV":c.get("XSRF-TOKEN-DEV")}),i.method=e,void 0===g&&(g={}),void 0===g.aspect&&(g.aspect=window.location.origin,1==g.aspect.length?g.aspect="/":g.aspect=g.aspect[1].split("/",2)[0],void 0!==b.aspect&&(g.aspect=b.aspect));for(var j in g)if(g.hasOwnProperty(j)){var k=":"+j;f.search(k)>0&&(f=f.replace(k,g[j]),delete g[j])}return i.params=g,i.url=f,void 0!==h&&(i.data=h),a("DELETE"==e||"JSONP"==e?i:i)};return function(a){return{get:function(b){return e("GET",a,b)},put:function(b,c){return e("PUT",a,b,c)},post:function(b,c){return e("POST",a,b,c)},patch:function(b,c){return e("PATCH",a,b,c)},del:function(b){return e("DELETE",a,b)},delete:function(b){return e("DELETE",a,b)},jsonp:function(b){return e("JSONP",a,b)}}}}]),m.directive("selectOnClick",function(){"use strict";return{restrict:"A",link:function(a,b){b.on("click",function(){this.select()})}}}),m.filter("default",function(){return function(a,b){return void 0===a?b:a}})}(angular,AppConfig);

View File

@@ -5,7 +5,7 @@ if [ "$1" = "-h" ]; then
usage: echo /etc/passwd | ./paste.sh
env options:
PASTE_URL - Set the url base for paste operations (default: HTTPS://sour.is/paste)
PASTE_URL - Set the url base for paste operations (default: HTTPS://paste.dn42.us)
PASTE_GZIP - 0 = No Compression, 1 = Use gzip compression (default: 0)
PASTE_BURN - 0 = No Burn on Read, 1 = Burn on read (default: 0)
PASTE_DATE - Value to be used when setting expire date. (default: next-week)
@@ -13,7 +13,7 @@ EOL
exit
fi
PASTE_URL=${PASTE_URL-"https://sour.is/paste"}
PASTE_URL=${PASTE_URL-"https://paste.dn42.us"}
PASTE_BURN=${PASTE_BURN-0}
PASTE_DATE=${PASTE_DATE-"next-week"}
PASTE_GZIP=${PASTE_GZIP-0}
@@ -29,7 +29,7 @@ HASH=$((echo -e "exp:\t$(date +%s -d ${PASTE_DATE})"; \
[ "$PASTE_GZIP" -eq "1" ] && echo -e "zip:\ttrue"; \
echo; \
cat /dev/stdin | $GZBIN | openssl aes-256-cbc -e -a -k $PASS) | \
curl -s -X POST ${PASTE_URL}/api/ --data-binary @-)
curl -s -X POST ${PASTE_URL}/paste --data-binary @-)
HASH_OK=$(echo $HASH | cut -c1-2)

File diff suppressed because one or more lines are too long

View File

@@ -4,14 +4,14 @@
<span class="input-group-btn">
<a class="btn btn-default" ng-click='reload()' type="button">New</a>
</span>
<input type=text readonly class=form-control select-on-click value="{{$base_url}}#/{{result.id}}!{{result.key}}">
<input type=text readonly class=form-control select-on-click value="{{$base_url}}/#/{{result.id}}!{{result.key}}">
<span class="input-group-btn">
<a class='btn btn-default' ng-href='#/{{result.id}}!{{result.key}}'>Open</a>
<a class='btn btn-default' ng-href='/#/{{result.id}}!{{result.key}}'>Open</a>
</span>
</div>
</div>
<pre class=col-xs-12> # Command Line: curl -s {{$base_url}}api/get/{{result.id}} | sed "1,/^\$/d" | openssl aes-256-cbc -d -a -k {{result.key}} <span ng-if='o.zip == true''>| gzip -dc</span>
<pre class=col-xs-12> # Command Line: curl -s {{$base_url}}/api/get/{{result.id}} | sed "1,/^\$/d" | openssl aes-256-cbc -d -a -k {{result.key}} <span ng-if='o.zip == true'>| gzip -dc</span>
{{result.text}}</pre>
</div>
@@ -47,7 +47,7 @@
$ echo /etc/passwd | ./paste.sh
env options:
PASTE_URL - Set the url base for paste operations (default: HTTPS://sour.is/paste)
PASTE_URL - Set the url base for paste operations (default: HTTPS://paste.dn42.us)
PASTE_GZIP - 0 = No Compression, 1 = Use gzip compression (default: 0)
PASTE_BURN - 0 = No Burn on Read, 1 = Burn on read (default: 0)
PASTE_DATE - Value to be used when setting expire date. (default: next-week)

View File

@@ -2,9 +2,9 @@
<div class=col-xs-12>
<div class="input-group">
<span class="input-group-btn">
<a class="btn btn-default" ng-href='#/' type="button">New</a>
<a class="btn btn-default" ng-href='/#/' type="button">New</a>
</span>
<input type=text readonly class=form-control select-on-click value="{{$base_url}}#/{{id}}!{{key}}">
<input type=text readonly class=form-control select-on-click value="{{$base_url}}/#/{{id}}!{{key}}">
<span class="input-group-btn">
<a class='btn btn-default' ng-click='copy(store.tx)'>Copy</a>
</span>
@@ -16,6 +16,6 @@
<b>Lang:</b> {{store.lang}}, <b>Expires:</b> <span ng-if='store.exp != "burn_on_read"'>{{store.exp*1000|date}}</span><span ng-if='store.exp == "burn_on_read"'>Burn on Read</span>
</div>
<div hljs language="{{store.lang}}" source="store.tx"></div>
<pre class=col-xs-12> # Command Line: curl -s {{$base_url}}api/get/{{id}} | sed "1,/^\$/d" | openssl aes-256-cbc -d -a -k {{key}} <span ng-if='store.zip != undefined'>| gzip -dc</span>
<pre class=col-xs-12> # Command Line: curl -s {{$base_url}}/api/get/{{id}} | sed "1,/^\$/d" | openssl aes-256-cbc -d -a -k {{key}} <span ng-if='store.zip != undefined'>| gzip -dc</span>
</div>
<div ng-if="store.err != undefined"><h3>Error: {{store.err}}</h3></div>