update to new react UI and various fixes

This commit is contained in:
Jon Lundy 2018-03-13 16:25:18 -06:00
parent 1dcd0f73cf
commit 0a6fa4bc53
14 changed files with 98 additions and 82 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
/paste
/vendor
/public
/routes/bindata.go

View File

@ -1,5 +1,5 @@
ROUTE_ASSET=routes/bindata_assetfs.go
ROUTE_FILES=public/index.html public/app.js public/paste.sh public/style.css
ROUTE_ASSET=routes/bindata.go
ROUTE_FILES=$(wildcard assets/src/*) $(wildcard assets/public/*)
VENDOR_FILES=$(wildcard vendor/*)
@ -11,6 +11,11 @@ all: $(BINARY)
clean:
rm -f $(BINARY) $(ROUTE_ASSET) $(ROUTE_FILES)
setup:
dep ensure
go get github.com/jteeuwen/go-bindata/...
go get github.com/elazarl/go-bindata-assetfs/...
run: $(BINARY)
./$(BINARY) -vv serve
@ -18,29 +23,21 @@ $(BINARY): $(SOURCE) $(ROUTE_ASSET) $(VENDOR_FILES)
go build
$(ROUTE_ASSET): $(ROUTE_FILES)
export PATH=$$GOPATH/bin:$$PATH; cd routes; go-bindata-assetfs -pkg routes -prefix ../ ../public/
public/index.html: assets/index.html assets/ui/*
cd assets; \
(sed '/INSERT_TEMPLATES/Q' index.html; \
for f in ui/*.html; \
do echo "<script id='$$f' type='text/ng-template'>"; \
html-minifier --minify-css --collapse-whitespace $$f; \
echo '</script>'; \
done; \
sed '1,/INSERT_TEMPLATES/d;/REMOVE_ASSET_START/,/REMOVE_ASSET_END/d' index.html) \
| html-minifier --minify-css --collapse-whitespace > ../public/index.html
rm -rf build ../public; \
npm run build; \
cp -r build ../public; \
export PATH=$$GOPATH/bin:$$PATH; \
cd ../routes; \
go-bindata-assetfs -pkg routes \
-prefix ../ \
../public/ \
../public/static/css/ \
../public/static/js/ \
../public/static/media/
public/app.js: assets/lib.js assets/app.js
cat assets/lib.js assets/app.js | uglifyjs > public/app.js
public/paste.sh: assets/paste.sh
cp assets/paste.sh public/paste.sh
public/style.css: assets/*.css
cleancss assets/*.css > public/style.css
deploy: $(SOURCE) $(ROUTE_ASSET)
cd debian && make && make deploy
cd debian && make
.PHONEY: clean deploy run
.PHONEY: all clean deploy run setup

View File

@ -9223,6 +9223,12 @@
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-4.0.0.tgz",
"integrity": "sha512-FlsPxavEyMuR6TjVbSSywovXSEyOg6ZDj5+Z8nbsRl9EkOzAhEIcS+GLoQDC5fz/t9suhUXWmUrOBrgeUvrMxw=="
},
"react-highlight": {
"version": "github:briancappello/react-highlight#ecf53ae1bb03deddb897515e7ed65b9e9f7af65b",
"requires": {
"highlight.js": "9.12.0"
}
},
"react-overlays": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-0.8.3.tgz",
@ -10202,7 +10208,7 @@
}
},
"sour-is": {
"version": "git+ssh://git@git.dn42.us:xuu/souris-react.git#3ca08bd7a65e967bb4e95969ba59130f25287331",
"version": "file:src/vendor/sour-is",
"requires": {
"bootstrap": "3.3.7",
"crypto-js": "3.1.9-1",
@ -10217,14 +10223,6 @@
"react-router-dom": "4.2.2",
"react-scripts": "1.1.1",
"seedrandom": "2.4.3"
},
"dependencies": {
"react-highlight": {
"version": "github:briancappello/react-highlight#ecf53ae1bb03deddb897515e7ed65b9e9f7af65b",
"requires": {
"highlight.js": "9.12.0"
}
}
}
},
"source-list-map": {

View File

@ -6,12 +6,13 @@
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-scripts": "1.1.1",
"sour-is": "git+ssh://git@git.dn42.us:xuu/souris-react.git"
"sour-is": "file:src/vendor/sour-is"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"postinstall": "npm install src/vendor/sour-is"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

45
assets/public/paste.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash
if [ "$1" = "-h" ]; then
cat 1>&2 <<EOL
usage: echo /etc/passwd | ./paste.sh
env options:
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)
EOL
exit
fi
PASTE_URL=${PASTE_URL-"https://paste.dn42.us"}
PASTE_BURN=${PASTE_BURN-0}
PASTE_DATE=${PASTE_DATE-"next-week"}
PASTE_GZIP=${PASTE_GZIP-0}
GZBIN="cat"
[ "$PASTE_GZIP" -eq "1" ] && GZBIN="gzip -c"
PASS=$(head -c 40 /dev/urandom);
CHK=$(echo -s $PASS | openssl dgst -sha256 -binary | openssl dgst -ripemd160 -binary | base64 | tr '/+' '_-' | tr -d '=')
PASS=$(echo -s $PASS | openssl dgst -sha256 -binary | base64 | tr '/+' '_-' | tr -d '=')
HASH=$((echo -e "exp:\t$(date +%s -d ${PASTE_DATE})"; \
echo -e "chk:\t$CHK"; \
[ "$PASTE_BURN" -eq "1" ] && echo -e "burn:\ttrue"; \
[ "$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}/paste --data-binary @-)
HASH_OK=$(echo $HASH | cut -c1-2)
if [ "$HASH_OK" = "OK" ]; then
HASH=$(echo $HASH | cut -f2 -d' ')
echo "url: ${PASTE_URL}/#/${HASH}!${PASS}"
echo -n "shell: curl -s ${PASTE_URL}/api/get/${HASH} | sed '1,/^\$/d' | openssl aes-256-cbc -d -a -k ${PASS}"
[ "$PASTE_GZIP" -eq "1" ] && echo " | gzip -dc" || echo;
exit
fi
echo $HASH

View File

@ -1,19 +1,22 @@
import React, { Component } from 'react';
import Paste from './vendor/src/paste/Paste';
import Framework from './vendor/src/sour-is/Framework';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import { remoteService } from "./vendor/src/sour-is/RemoteService";
import 'bootstrap/dist/css/bootstrap.css';
import 'sour-is/src/sour-is/Framework.css';
import Paste from './vendor/sour-is/src/paste/Paste';
import { remoteService } from "./vendor/sour-is/src/sour-is/RemoteService";
const req = remoteService();
const APP_NAME = "DN42 Paste UI";
class App extends Component {
constructor(){
super()
super();
this.state = {
name: APP_NAME,
api: "Paste API (Version Snapshot)"
api: "Paste API (Version Snapshot)",
}
}
@ -22,7 +25,7 @@ componentDidMount() {
.then((response) => {
if (response.ok) return response.text().catch(()=>"");
else return "Unknown API"; })
.then((text) => { this.setState({app:{name: APP_NAME, api: text}}); });
.then((text) => { this.setState({api: text}); });
}
render() {

@ -1 +1 @@
Subproject commit 3ca08bd7a65e967bb4e95969ba59130f25287331
Subproject commit bd43f3d484497b05773c546ccf90d112114bc0fa

12
debian/Makefile vendored
View File

@ -21,9 +21,13 @@ build:
export BUILD="BUILD/$(NAME)_$${VERSION}-$${RELEASE}"; \
rm -rf ./$${BUILD}; \
cp -r ROOT "$${BUILD}"; \
export SED="s_Version:.*_Version: $${VERSION}-$${RELEASE}_"; \
sed -i "$$SED" "$${BUILD}/DEBIAN/control"; \
go build -o $${BUILD}/opt/sour.is/bin/paste \
sed -i'.tmp' "s_Version:.*_Version: $${VERSION}-$${RELEASE}_" "$${BUILD}/DEBIAN/control"
export VERSION=`cat VERSION`; \
export RELEASE=`cat RELEASE`; \
export DATE=`date -u +%FT%TZ`; \
export BUILD="BUILD/$(NAME)_$${VERSION}-$${RELEASE}"; \
env GOOS=linux GOARCH=amd64 go build -v -o $${BUILD}/opt/sour.is/bin/paste \
-ldflags "-X main.AppVersion=$${VERSION}-$${RELEASE} -X main.AppBuild=$${DATE}"\
sour.is/x/paste; \
dpkg -b $${BUILD}; \
@ -37,3 +41,5 @@ copy:
deploy:
ansible $(REPO_HOST) -s -m apt -a "name=sour.is-paste update_cache=yes state=latest"
.PHONY: clean release build copy # deploy

2
debian/RELEASE vendored
View File

@ -1 +1 @@
12
5

2
debian/VERSION vendored
View File

@ -1 +1 @@
2.0.0
2.2.0

File diff suppressed because one or more lines are too long

View File

@ -1,22 +0,0 @@
<?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><script id="ui/create.html" type="text/ng-template"><div class="row" ng-show="result != undefined"><div class="col-xs-12"><div class="input-group"><span class="input-group-btn"><a class="btn btn-default" ng-click="reload()" type="button">New</a></span> <input type="text" readonly="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></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>
{{result.text}}</pre></div><div ng-hide="result != undefined"><form name="paste" ng-submit="Encrypt(o)"><div class="form form-inline"><ol class="breadcrumb"><li><label>Syntax</label><select class="form-control input-sm" ng-model="o.lang" ng-options="i.key as i.val for i in HighliteLang | orderBy:&quot;+val&quot;" ng-init="o.lang = &quot;text&quot;"></select></li><li><label>Expires</label><select class="form-control input-sm" ng-model="o.exp" ng-options="i.key as i.val for i in ExpireTimes | orderBy:&quot;+key&quot;" ng-init="o.exp = 604800"></select></li><li><label><input type="checkbox" ng-model="o.burn"> Burn on Read</label></li></ol></div><textarea style="font-family:hack,&quot" required class="form-control" rows="20" ng-model="o.text"></textarea><pre>Additional Entropy: {{entropy}} bytes / Content size: {{o.text|blength|default:0}} bytes</pre><button type="submit" class="btn btn-default btn-lg btn-block" ng-disabled="o.text == undefined || o.text.length == 0">Encrypt</button></form><p>Create pastes from the command line! <a href="./paste.sh">paste.sh</a><pre>
$ echo /etc/passwd | ./paste.sh
env options:
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)
</pre></p></div></script><script id="ui/view.html" type="text/ng-template"><div class="row"><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></span> <input type="text" readonly="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></div></div></div><div ng-if="store.err == undefined"><div class="well well-sm"><b>Lang:</b> {{store.lang}}, <b>Expires:</b> <span ng-if="store.exp != &quot;burn_on_read&quot;">{{store.exp*1000|date}}</span><span ng-if="store.exp == &quot;burn_on_read&quot;">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></div><div ng-if="store.err != undefined"><h3>Error: {{store.err}}</h3></div></script></head><body><div id="wrapper"><div class="container-responsive"><article ng-view></article><a onclick="var elm = document.getElementById(&quot;debug&quot;); elm.parentNode.style.display=&quot;block&quot;; 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(&quot;debug&quot;).parentNode.style.display=&quot;none&quot;"><i class="glyphicon glyphicon-remove"></i></a><br><a class="btn" onclick="var elm=document.getElementById(&quot;debug&quot;);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></div><link rel="stylesheet" href="style.css"><script src="app.js"></script><noscript><div class="container-responsive"><h1>PasteBox</h1><p>It looks like yo don't have javascript enabled for this site. But thats ok. You can still submit and read the content of pastes by using a few curl/openssl/gunzip commands.</p><h2>Get the paste</h2><p>Lets say you have the following link <code>https://domain.tld/#/FeLq42kIQV69hQCJA8m9lg!5EDDziaCjceHjeG5UQ9M7-6wgyq5YVfysAEZ0wUNy6w</code>. Query the REST endpoint for the ID or part before the ! in the url hash.</p><pre><code>$ curl -i https://domain.tld/api/FeLq42kIQV69hQCJA8m9lg</code></pre><h2>Decrypt</h2><p>Using Openssl you want to remove the header and pass the remaining base64 for decryption. The cypher used is aes-256-cbc. The key is the portion after the ! in the link.</p><pre><code>... | sed '1,/^$/d' | openssl aes-256-cbc -d -a -k 5EDDziaCjceHjeG5UQ9M7-6wgyq5YVfysAEZ0wUNy6w</code></pre><h2>Deflate</h2><p>If as in the provided example the paste has been compressed pass it through gunzip. The header will have "zip: true" if it has been compressed.</p><pre><code> ... | gzip -dc </code></pre><h2>Example Output</h2><pre><code>$ curl -s "https://domain.tld/api/FeLq42kIQV69hQCJA8m9lg" | sed "1,/^$/d" | openssl aes-256-cbc -d -a -k 5EDDziaCjceHjeG5UQ9M7-6wgyq5YVfysAEZ0wUNy6w | gzip -dc
. ____ .-.
.-"` `",( __\_
.-==:;-._ .' .-. `'.
.' `"-:'-/ ( \} -=a .)
/ \/ \,== `- __..-'`
'-' | | | .'\ `;
\ _/---'\ ( `"`
/.`._ ) \ `; Sour.is Paste
\`-/.' `"`
`"\`-.</code></pre></div></noscript></body></html>

File diff suppressed because one or more lines are too long