diff --git a/Gopkg.lock b/Gopkg.lock index 40888b3..4b568fb 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -7,12 +7,6 @@ revision = "784ddc588536785e7299f7272f39101f7faccc3f" version = "0.6.2" -[[projects]] - name = "github.com/elazarl/go-bindata-assetfs" - packages = ["."] - revision = "30f82fa23fd844bd5bb1e5f216db87fd77b5eb43" - version = "v1.0.0" - [[projects]] name = "github.com/fsnotify/fsnotify" packages = ["."] @@ -143,6 +137,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "f0136e5899d85670e4bb91c85db638b8d50d74cac1d00e96c714c7ec61513d5f" + inputs-digest = "dda0f77480b1bdc7057ae5b9a5a2e4c69d745c50200eac736cc41ba9d76e67ce" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Makefile b/Makefile index 5c788e0..370ad69 100644 --- a/Makefile +++ b/Makefile @@ -1,40 +1,51 @@ -ROUTE_ASSET=routes/bindata.go +ROUTE_ASSET=src/routes/bindata.go ROUTE_FILES=$(wildcard assets/src/*) $(wildcard assets/public/*) +DOCS_ASSET=src/docs/bindata.go +DOCS_FILES=$(wildcard src/docs/ui/*) + VENDOR_FILES=$(wildcard vendor/*) -SOURCE=./*.go routes/*.go +SOURCE=$(wildcard cmd/*/*.go) $(filter-out src/routes/bindata.go, $(wildcard src/routes/*.go)) BINARY=paste +define DUMMY_BINDATA +package docs +import "net/http" +func assetFS() (fs http.FileSystem) { return } +endef +export DUMMY_BINDATA + all: $(BINARY) clean: - rm -f $(BINARY) $(ROUTE_ASSET) $(ROUTE_FILES) + rm -rf $(BINARY) $(ROUTE_ASSET) public/ setup: dep ensure go get github.com/jteeuwen/go-bindata/... go get github.com/elazarl/go-bindata-assetfs/... + git submodule update + cd assets; npm i run: $(BINARY) ./$(BINARY) -vv serve -$(BINARY): $(SOURCE) $(ROUTE_ASSET) $(VENDOR_FILES) - go build +$(BINARY): $(SOURCE) $(ROUTE_ASSET) $(VENDOR_FILES) $(DOCS_ASSET) + go build "sour.is/x/paste/cmd/paste" $(ROUTE_ASSET): $(ROUTE_FILES) cd assets; \ 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/ + cp -r build ../public + + export PATH=$$GOPATH/bin:$$PATH; go generate "sour.is/x/paste/src/routes" + +$(DOCS_ASSET): $(DOCS_FILES) $(SOURCE) + echo "$$DUMMY_BINDATA" > src/docs/bindata.go + export PATH=$$GOPATH/bin:$$PATH; go generate "sour.is/x/paste/cmd/paste" + export PATH=$$GOPATH/bin:$$PATH; go generate "sour.is/x/paste/src/docs" deploy: $(SOURCE) $(ROUTE_ASSET) diff --git a/config.go b/cmd/paste/config.go similarity index 100% rename from config.go rename to cmd/paste/config.go diff --git a/main.go b/cmd/paste/main.go similarity index 79% rename from main.go rename to cmd/paste/main.go index c60b2fc..1b771ce 100644 --- a/main.go +++ b/cmd/paste/main.go @@ -24,11 +24,12 @@ // // // swagger:meta -package main // import "sour.is/x/paste" +package main // import "sour.is/x/paste/cmd/paste" import ( "sour.is/x/toolbox/httpsrv" - _ "sour.is/x/paste/routes" + _ "sour.is/x/paste/src/routes" + _ "sour.is/x/paste/src/docs" ) func main() { @@ -36,3 +37,5 @@ func main() { httpsrv.Run() } } + +//go:generate swagger generate spec -o ../../src/docs/public/swagger.json diff --git a/src/docs/.gitignore b/src/docs/.gitignore new file mode 100644 index 0000000..9e55647 --- /dev/null +++ b/src/docs/.gitignore @@ -0,0 +1 @@ +public/swagger.json diff --git a/src/docs/public.go b/src/docs/public.go new file mode 100644 index 0000000..658396b --- /dev/null +++ b/src/docs/public.go @@ -0,0 +1,11 @@ +package docs + +import "sour.is/x/toolbox/httpsrv" + +func init() { + httpsrv.AssetRegister("docs", httpsrv.AssetRoutes{ + {"Assets", "/docs/", httpsrv.FsHtml5(assetFS())}, + }) +} + +//go:generate go-bindata-assetfs -pkg docs public/ diff --git a/src/docs/public/favicon-16x16.png b/src/docs/public/favicon-16x16.png new file mode 100644 index 0000000..0f7e13b Binary files /dev/null and b/src/docs/public/favicon-16x16.png differ diff --git a/src/docs/public/favicon-32x32.png b/src/docs/public/favicon-32x32.png new file mode 100644 index 0000000..b0a3352 Binary files /dev/null and b/src/docs/public/favicon-32x32.png differ diff --git a/src/docs/public/index.html b/src/docs/public/index.html new file mode 100644 index 0000000..9bec19d --- /dev/null +++ b/src/docs/public/index.html @@ -0,0 +1,95 @@ + + + +
+ +>>u&mn;if(_!==h>>>u&mn)break;_&&(c+=(1<i&&(l=l.removeBefore(r,u,a-c)),l&&h
a&&(a=l.size),o(u)||(l=l.map(function(e){return H(e)})),i.push(l)}return a>e.size&&(e=e.setSize(a)),Ie(e,t,i)}function $e(e){return es)return k();var e=i.next();return r||t===bn?e:t===_n?w(t,u-1,void 0,e):w(t,u-1,e.value[1],e)})},l}function dt(e,t,n){var r=Dt(e);return r.__iterateUncached=function(r,i){var o=this;if(i)return this.cacheResult().__iterate(r,i);var a=0;return e.__iterate(function(e,i,s){return t.call(n,e,i,s)&&++a&&r(e,i,o)}),a},r.__iteratorUncached=function(r,i){var o=this;if(i)return this.cacheResult().__iterator(r,i);var a=e.__iterator(xn,i),s=!0;return new x(function(){if(!s)return k();var e=a.next();if(e.done)return e;var i=e.value,u=i[0],l=i[1];return t.call(n,l,u,o)?r===xn?e:w(r,u,l,e):(s=!1,k())})},r}function mt(e,t,n,r){var i=Dt(e);return i.__iterateUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,u=0;return e.__iterate(function(e,o,l){if(!s||!(s=t.call(n,e,o,l)))return u++,i(e,r?o:u-1,a)}),u},i.__iteratorUncached=function(i,o){var a=this;if(o)return this.cacheResult().__iterator(i,o);var s=e.__iterator(xn,o),u=!0,l=0;return new x(function(){var e,o,c;do{if(e=s.next(),e.done)return r||i===bn?e:i===_n?w(i,l++,void 0,e):w(i,l++,e.value[1],e);var p=e.value;o=p[0],c=p[1],u&&(u=t.call(n,c,o,a))}while(u);return i===xn?e:w(i,o,c,e)})},i}function vt(e,t){var r=a(e),i=[e].concat(t).map(function(e){return o(e)?r&&(e=n(e)):e=r?L(e):q(Array.isArray(e)?e:[e]),e}).filter(function(e){return 0!==e.size});if(0===i.length)return e;if(1===i.length){var u=i[0];if(u===e||r&&a(u)||s(e)&&s(u))return u}var l=new I(i);return r?l=l.toKeyedSeq():s(e)||(l=l.toSetSeq()),l=l.flatten(!0),l.size=i.reduce(function(e,t){if(void 0!==e){var n=t.size;if(void 0!==n)return e+n}},0),l}function gt(e,t,n){var r=Dt(e);return r.__iterateUncached=function(r,i){function a(e,l){var c=this;e.__iterate(function(e,i){return(!t||l=Vn)return Oe(e,f,l,s,d);if(c&&!d&&2===f.length&&Se(f[1^p]))return f[1^p];if(c&&d&&1===f.length&&Se(d))return d;var m=e&&e===this.ownerID,v=c?d?l:l^u:l|u,g=c?d?Ne(f,p,d,m):Be(f,p,m):Fe(f,p,d,m);return m?(this.bitmap=v,this.nodes=g,this):new de(e,v,g)},me.prototype.get=function(e,t,n,r){void 0===t&&(t=oe(n));var i=(0===e?t:t>>>e)&mn,o=this.nodes[i];return o?o.get(e+hn,t,n,r):r},me.prototype.update=function(e,t,n,r,i,o,a){void 0===n&&(n=oe(r));var s=(0===t?n:n>>>t)&mn,u=i===vn,l=this.nodes,c=l[s];if(u&&!c)return this;var p=Ee(c,e,t+hn,n,r,i,o,a);if(p===c)return this;var f=this.count;if(c){if(!p&&--f5?l-5:0),p=5;p5?l-5:0),p=5;ps&&(n=s-u),l=n;l>=0;l--){for(var p=!0,f=0;fi&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a