use separate pd client
This commit is contained in:
11
go.mod
11
go.mod
@@ -1,9 +1,16 @@
|
||||
module fornaxian.com/pixeldrain-web
|
||||
|
||||
go 1.13
|
||||
go 1.14
|
||||
|
||||
replace (
|
||||
fornaxian.com/pd_database => ../pd_database
|
||||
fornaxian.com/pixeldrain-api => ../pixeldrain-api
|
||||
fornaxian.com/pixeldrain-web => ../pixeldrain-web
|
||||
fornaxian.com/pixelstore => ../pixelstore
|
||||
)
|
||||
|
||||
require (
|
||||
fornaxian.com/pixeldrain-api v0.0.0-20191216095319-0533f903c681
|
||||
fornaxian.com/pixeldrain-api v0.0.0-20200224165550-54483c862cd0
|
||||
github.com/Fornaxian/config v0.0.0-20180915150834-ac41cf746a70
|
||||
github.com/Fornaxian/log v0.0.0-20190617093801-1c7ce9a7c9b3
|
||||
github.com/Fornaxian/pd_mime_type v0.0.0-20200204165508-2815edf3a145
|
||||
|
111
go.sum
111
go.sum
@@ -1,108 +1,63 @@
|
||||
fornaxian.com/pixeldrain-api v0.0.0-20191213180911-5823f7064801/go.mod h1:bhJgwXdFTFrZUdQ+vBXzUQiAhvuFnEgZgxeXBhWddLU=
|
||||
fornaxian.com/pixeldrain-api v0.0.0-20191216095319-0533f903c681 h1:tLIj6RhZHsJW1riDUZj7c4UQ3Gojl8Sh6CHj9cC4nzQ=
|
||||
fornaxian.com/pixeldrain-api v0.0.0-20191216095319-0533f903c681/go.mod h1:HooOANQfnTseH1XR/kJ2R8sKpPM68GdzHQyHiUlaZqI=
|
||||
fornaxian.com/pixeldrain-web v0.0.0-20191211101305-cc3c5d58e432/go.mod h1:UwobVC5YVBOtfTc6eBSBjD2tdLQ+xYYp7+web6nCjD0=
|
||||
fornaxian.com/pixelstore v0.0.0-20191212224440-0453456df082/go.mod h1:saC4IwAOpIip/M7fURYMTcUo5fhwp/m5GmvoQucSwLQ=
|
||||
fornaxian.com/pixelstore v0.0.0-20191213205107-7cc26c05cb69/go.mod h1:6cdebY9AhneUTQZQ+dyXnIZmMYxCAVgJ5lCeUTWPR8M=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Fornaxian/config v0.0.0-20180915150834-ac41cf746a70 h1:yRkXab8h+BAWEphLE0qexJVxIOdPgw+3T9VSLuyPXus=
|
||||
github.com/Fornaxian/config v0.0.0-20180915150834-ac41cf746a70/go.mod h1:Ig5am30IOP/eqsjogI1TuSlOTIeTPHoMOpYYM1bisww=
|
||||
github.com/Fornaxian/log v0.0.0-20190617093801-1c7ce9a7c9b3 h1:PfKr7anK3z4kLG9V6BbbKOVFhVaGEAJi4HxXCAa+QeU=
|
||||
github.com/Fornaxian/log v0.0.0-20190617093801-1c7ce9a7c9b3/go.mod h1:jdnyerqAlXJJpQmpyrdmSYMitRaRZ8RejEXuXz6n5QY=
|
||||
github.com/Fornaxian/pd_mime_type v0.0.0-20200204164318-fc5d8b4479f9 h1:8cg0suW9Ny88xGYnaFyfXG5CH7Vxu8jm8PAwnZM4JOk=
|
||||
github.com/Fornaxian/pd_mime_type v0.0.0-20200204164318-fc5d8b4479f9/go.mod h1:Ew6h8nlacK6H8aABMDUYN3uaO4Rpw2HLKQZ2ntEybqM=
|
||||
github.com/Fornaxian/pd_mime_type v0.0.0-20200204165508-2815edf3a145 h1:2a8cFtVwEvK7NeimwAEoSUdf4hC80cXpnj3s4pHga+c=
|
||||
github.com/Fornaxian/pd_mime_type v0.0.0-20200204165508-2815edf3a145/go.mod h1:Ew6h8nlacK6H8aABMDUYN3uaO4Rpw2HLKQZ2ntEybqM=
|
||||
github.com/Fornaxian/unifilter v0.0.0-20180623154047-e65e144d5942/go.mod h1:ofV5syadd2nI4gOc/rP1yPnXkARgm+E1D/U38mbUj44=
|
||||
github.com/Fornaxian/unifilter v0.0.0-20200428082710-29e3cf43485c h1:ule8gPLT5sJCcIqUpa0MJqOSNHJ/WRpOM0bsFktNHXU=
|
||||
github.com/Fornaxian/unifilter v0.0.0-20200428082710-29e3cf43485c/go.mod h1:ofV5syadd2nI4gOc/rP1yPnXkARgm+E1D/U38mbUj44=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dchest/threefish v0.0.0-20120919164726-3ecf4c494abf/go.mod h1:bXVurdTuvOiJu7NHALemFe0JMvC2UmwYHW+7fcZaZ2M=
|
||||
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gabriel-vasile/mimetype v1.0.2/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de h1:F7WD09S8QB4LrkEpka0dFPLSotH11HRpCsLIbIcJ7sU=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/h2non/filetype v1.1.0 h1:Or/gjocJrJRNK/Cri/TDEKFjAR+cfG6eK65NGYB6gBA=
|
||||
github.com/h2non/filetype v1.1.0/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/k0kubun/pp v3.0.1+incompatible h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40=
|
||||
github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg=
|
||||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
|
||||
github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
|
||||
github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/reedsolomon v1.9.2/go.mod h1:CwCi+NUr9pqSVktrkN+Ondf06rkhYZ/pcNv7fu+8Un4=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
|
||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/microcosm-cc/bluemonday v1.0.2 h1:5lPfLTTAvAbtS0VqT+94yOtFnGfUWYyx0+iToC3Os3s=
|
||||
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86 h1:D6paGObi5Wud7xg83MaEFyjxQB1W5bz5d0IFppr+ymk=
|
||||
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
|
||||
github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab h1:eFXv9Nu1lGbrNbj619aWwZfVF5HBrm9Plte8aNptuTI=
|
||||
github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI=
|
||||
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
|
||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk=
|
||||
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
|
||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.4 h1:S0tLZ3VOKl2Te0hpq8+ke0eSJPfCnNTPiDlsfwi1/NE=
|
||||
github.com/spf13/cobra v0.0.4/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/timakin/gonvert v0.0.0-20170112000238-5dce59dbd0d8 h1:gw/M1/pCu7oELGHZ6rvktNmMbdWhf9kHc7WYrbLeKdo=
|
||||
github.com/timakin/gonvert v0.0.0-20170112000238-5dce59dbd0d8/go.mod h1:oqLl90kSlp4+8wMQKql9ZdQGa4/5pVCxOOpTVWkoyV0=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/xtaci/smux v1.3.3/go.mod h1:f+nYm6SpuHMy/SH0zpbvAFHT1QoMcgLOsWcFip5KfPw=
|
||||
@@ -118,60 +73,22 @@ gitlab.com/NebulousLabs/threadgroup v0.0.0-20180716154133-88a11db9e46c/go.mod h1
|
||||
gitlab.com/NebulousLabs/writeaheadlog v0.0.0-20190703190009-cb822c37bc94/go.mod h1:Lhpa9AcbWcYKcc4amZsOHqJdQglnkWrGuUI68XC7U2Q=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g=
|
||||
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200109152110-61a87790db17 h1:nVJ3guKA9qdkEQ3TUdXI9QSINo2CUPM/cySEvw2w8I0=
|
||||
golang.org/x/crypto v0.0.0-20200109152110-61a87790db17/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM=
|
||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20191206065243-da761ea9ff43/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM=
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 h1:gSbV7h1NRL2G1xTg/owz62CST1oJBmxy4QpMMregXVQ=
|
||||
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1 h1:gZpLHxUX5BdYLA08Lj4YCJNN/jk7KtquiArPoeX0WvA=
|
||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e h1:FDhOuMEY4JVRztM/gsbk+IKUQ8kj74bxZrgw87eMMVc=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20200114052453-d31a08c2edf2 h1:FAGfnR+fyptW02iTeG8Lytc+6v8yqyQJIx/JMZhMA5M=
|
||||
golang.org/x/tools v0.0.0-20200114052453-d31a08c2edf2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200130224948-02f1738cbe39 h1:5ERHXLQfA0b8cHOwaOfWaaGekrA4+Ka/N74zilLnsIk=
|
||||
golang.org/x/tools v0.0.0-20200130224948-02f1738cbe39/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74 h1:KW20qMcLRWuIgjdCpHFJbVZA7zsDKtFXPNcm7/eI5ZA=
|
||||
golang.org/x/tools/gopls v0.3.0 h1:l9KKK1/n6CIbfgaUvHBWAvCfOxcl1N+KSOK79OlPIao=
|
||||
golang.org/x/tools/gopls v0.3.0/go.mod h1:vvBkm7WBjHNudDeK7Sg7HeR+sKt6yp5TD/4NQaTZzRs=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/russross/blackfriday.v2 v2.0.0 h1:+FlnIV8DSQnT7NZ43hcVKcdJdzZoeCmJj4Ql8gq5keA=
|
||||
gopkg.in/russross/blackfriday.v2 v2.0.0/go.mod h1:6sSBNz/GtOm/pJTuh5UmBK2ZHfmnxGbl2NZg1UliSOI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
mvdan.cc/xurls/v2 v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=
|
||||
mvdan.cc/xurls/v2 v2.1.0/go.mod h1:5GrSd9rOnKOpZaji1OZLYL/yeAAtGDlo/cFe+8K5n8E=
|
||||
|
@@ -1,46 +0,0 @@
|
||||
package pixelapi
|
||||
|
||||
import "net/url"
|
||||
|
||||
// IsAdmin is the response to the /admin/is_admin API
|
||||
type IsAdmin struct {
|
||||
Success bool `json:"success"`
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
}
|
||||
|
||||
// UserIsAdmin returns if the logged in user is an admin user
|
||||
func (p *PixelAPI) UserIsAdmin() (resp IsAdmin, err error) {
|
||||
err = p.jsonRequest("GET", p.apiEndpoint+"/admin/is_admin", &resp, false)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// AdminGlobal is a global setting in pixeldrain's back-end
|
||||
type AdminGlobal struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// AdminGlobals is an array of globals
|
||||
type AdminGlobals struct {
|
||||
Success bool `json:"success"`
|
||||
Globals []AdminGlobal `json:"globals"`
|
||||
}
|
||||
|
||||
// AdminGetGlobals returns if the logged in user is an admin user
|
||||
func (p *PixelAPI) AdminGetGlobals() (resp AdminGlobals, err error) {
|
||||
if err = p.jsonRequest("GET", p.apiEndpoint+"/admin/globals", &resp, false); err != nil {
|
||||
return resp, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// AdminSetGlobals returns if the logged in user is an admin user
|
||||
func (p *PixelAPI) AdminSetGlobals(key, value string) (err error) {
|
||||
var form = url.Values{}
|
||||
form.Add("key", key)
|
||||
form.Add("value", value)
|
||||
return p.form("POST", p.apiEndpoint+"/admin/globals", form, nil, true)
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
package pixelapi
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/url"
|
||||
"time"
|
||||
)
|
||||
|
||||
// GetFile makes a file download request and returns a readcloser. Don't forget
|
||||
// to close it!
|
||||
func (p *PixelAPI) GetFile(id string) (io.ReadCloser, error) {
|
||||
return p.getRaw(p.apiEndpoint + "/file/" + id)
|
||||
}
|
||||
|
||||
// FileInfo File information object from the pixeldrain API
|
||||
type FileInfo struct {
|
||||
Success bool `json:"success"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Size uint64 `json:"size"`
|
||||
Views int64 `json:"views"`
|
||||
BandwidthUsed uint64 `json:"bandwidth_used"`
|
||||
DateUpload time.Time `json:"date_upload"`
|
||||
DateLastView time.Time `json:"date_last_view"`
|
||||
MimeType string `json:"mime_type"`
|
||||
MimeImage string `json:"mime_image"`
|
||||
ThumbnailHREF string `json:"thumbnail_href"`
|
||||
|
||||
Availability string `json:"availability"`
|
||||
AvailabilityMessage string `json:"availability_message"`
|
||||
AvailabilityName string `json:"availability_name"`
|
||||
|
||||
CanEdit bool `json:"can_edit"`
|
||||
}
|
||||
|
||||
// GetFileInfo gets the FileInfo from the pixeldrain API
|
||||
func (p *PixelAPI) GetFileInfo(id string) (resp FileInfo, err error) {
|
||||
return resp, p.jsonRequest("GET", p.apiEndpoint+"/file/"+id+"/info", &resp, false)
|
||||
}
|
||||
|
||||
// PostFileView adds a view to a file
|
||||
func (p *PixelAPI) PostFileView(id, viewtoken string) (err error) {
|
||||
vals := url.Values{}
|
||||
vals.Set("token", viewtoken)
|
||||
return p.form("POST", p.apiEndpoint+"/file/"+id+"/view", vals, nil, true)
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
package pixelapi
|
||||
|
||||
import "time"
|
||||
|
||||
// API error constants
|
||||
const (
|
||||
ListNotFoundError = "list_not_found"
|
||||
)
|
||||
|
||||
// List information object from the pixeldrain API
|
||||
type List struct {
|
||||
Success bool `json:"success"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
DateCreated time.Time `json:"date_created"`
|
||||
FileCount int `json:"file_count"`
|
||||
Files []ListFile `json:"files"`
|
||||
}
|
||||
|
||||
// ListFile information object from the pixeldrain API
|
||||
type ListFile struct {
|
||||
DetailHREF string `json:"detail_href"`
|
||||
Description string `json:"description"`
|
||||
FileInfo `json:""`
|
||||
}
|
||||
|
||||
// GetList get a List from the pixeldrain API. Errors will be available through
|
||||
// List.Error. Standard error checks apply.
|
||||
func (p *PixelAPI) GetList(id string) (resp List, err error) {
|
||||
return resp, p.jsonRequest("GET", p.apiEndpoint+"/list/"+id, &resp, false)
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package pixelapi
|
||||
|
||||
// Recaptcha stores the reCaptcha site key
|
||||
type Recaptcha struct {
|
||||
SiteKey string `json:"site_key"`
|
||||
}
|
||||
|
||||
// GetRecaptcha gets the reCaptcha site key from the pixelapi server. If
|
||||
// reCaptcha is disabled the key will be empty
|
||||
func (p *PixelAPI) GetRecaptcha() (resp Recaptcha, err error) {
|
||||
return resp, p.jsonRequest("GET", p.apiEndpoint+"/misc/recaptcha", &resp, false)
|
||||
}
|
||||
|
||||
// GetMiscViewToken requests a viewtoken from the server. The viewtoken is valid
|
||||
// for a limited amount of time and can be used to add views to a file.
|
||||
// Viewtokens can only be requested from localhost
|
||||
func (p *PixelAPI) GetMiscViewToken() (resp string, err error) {
|
||||
return resp, p.jsonRequest("GET", p.apiEndpoint+"/misc/viewtoken", &resp, false)
|
||||
}
|
@@ -1,147 +0,0 @@
|
||||
package pixelapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Fornaxian/log"
|
||||
)
|
||||
|
||||
var client = &http.Client{Timeout: time.Minute * 5}
|
||||
|
||||
// PixelAPI is the Pixeldrain API client
|
||||
type PixelAPI struct {
|
||||
apiEndpoint string
|
||||
APIKey string
|
||||
RealIP string
|
||||
}
|
||||
|
||||
// New creates a new Pixeldrain API client to query the Pixeldrain API with
|
||||
func New(apiEndpoint string) *PixelAPI {
|
||||
return &PixelAPI{apiEndpoint: apiEndpoint}
|
||||
}
|
||||
|
||||
// Standard response types
|
||||
|
||||
// Error is an error returned by the pixeldrain API. If the request failed
|
||||
// before it could reach the API the error will be on a different type
|
||||
type Error struct {
|
||||
Status int `json:"-"` // One of the http.Status types
|
||||
Success bool `json:"success"`
|
||||
StatusCode string `json:"value"`
|
||||
Message string `json:"message"`
|
||||
|
||||
// In case of the multiple_errors code this array will be populated with
|
||||
// more errors
|
||||
Errors []Error `json:"errors,omitempty"`
|
||||
|
||||
// Metadata regarding the error
|
||||
Extra map[string]interface{} `json:"extra,omitempty"`
|
||||
}
|
||||
|
||||
func (e Error) Error() string { return e.StatusCode }
|
||||
|
||||
func (p *PixelAPI) do(r *http.Request) (*http.Response, error) {
|
||||
if p.APIKey != "" {
|
||||
r.SetBasicAuth("", p.APIKey)
|
||||
}
|
||||
if p.RealIP != "" {
|
||||
r.Header.Set("X-Real-IP", p.RealIP)
|
||||
}
|
||||
|
||||
return client.Do(r)
|
||||
}
|
||||
|
||||
func (p *PixelAPI) jsonRequest(method, url string, target interface{}, multiErr bool) error {
|
||||
req, err := http.NewRequest(method, url, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp, err := p.do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
return parseJSONResponse(resp, target, multiErr)
|
||||
}
|
||||
|
||||
func (p *PixelAPI) getString(url string) (string, error) {
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
resp, err := p.do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
bodyBytes, err := ioutil.ReadAll(resp.Body)
|
||||
|
||||
return string(bodyBytes), err
|
||||
}
|
||||
|
||||
func (p *PixelAPI) getRaw(url string) (io.ReadCloser, error) {
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := p.do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp.Body, err
|
||||
}
|
||||
|
||||
func (p *PixelAPI) form(
|
||||
method string,
|
||||
url string,
|
||||
vals url.Values,
|
||||
target interface{},
|
||||
multiErr bool,
|
||||
) error {
|
||||
req, err := http.NewRequest(method, url, strings.NewReader(vals.Encode()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
resp, err := p.do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
return parseJSONResponse(resp, target, multiErr)
|
||||
}
|
||||
|
||||
func parseJSONResponse(resp *http.Response, target interface{}, multiErr bool) (err error) {
|
||||
// Test for client side and server side errors
|
||||
if resp.StatusCode >= 400 {
|
||||
errResp := Error{Status: resp.StatusCode}
|
||||
if err = json.NewDecoder(resp.Body).Decode(&errResp); err != nil {
|
||||
return err
|
||||
}
|
||||
return errResp
|
||||
}
|
||||
|
||||
if target == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(resp.Body).Decode(target); err != nil {
|
||||
r, _ := ioutil.ReadAll(resp.Body)
|
||||
log.Error("Can't decode this: %v. %s", err, r)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
150
pixelapi/user.go
150
pixelapi/user.go
@@ -1,150 +0,0 @@
|
||||
package pixelapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// UserRegister registers a new user on the Pixeldrain server. username and
|
||||
// password are always required. email is optional, but without it you will not
|
||||
// be able to reset your password in case you forget it. captcha depends on
|
||||
// whether reCaptcha is enabled on the Pixeldrain server, this can be checked
|
||||
// through the GetRecaptcha function.
|
||||
//
|
||||
// The register API can return multiple errors, which will be stored in the
|
||||
// Errors array. Check for len(Errors) == 0 to see if an error occurred. If err
|
||||
// != nil it means a connection error occurred
|
||||
func (p *PixelAPI) UserRegister(username, email, password, captcha string) (err error) {
|
||||
return p.form(
|
||||
"POST", p.apiEndpoint+"/user/register",
|
||||
url.Values{
|
||||
"username": {username},
|
||||
"email": {email},
|
||||
"password": {password},
|
||||
"recaptcha_response": {captcha},
|
||||
},
|
||||
nil, true,
|
||||
)
|
||||
}
|
||||
|
||||
// Login is the success response to the `user/login` API
|
||||
type Login struct {
|
||||
Success bool `json:"success"`
|
||||
APIKey string `json:"api_key"`
|
||||
}
|
||||
|
||||
// UserLogin logs a user in with the provided credentials. The response will
|
||||
// contain the returned API key. If saveKey is true the API key will also be
|
||||
// saved in the client and following requests with this client will be
|
||||
// autenticated
|
||||
func (p *PixelAPI) UserLogin(username, password string, saveKey bool) (resp Login, err error) {
|
||||
var form = url.Values{}
|
||||
form.Add("username", username)
|
||||
form.Add("password", password)
|
||||
if err = p.form("POST", p.apiEndpoint+"/user/login", form, &resp, true); err != nil {
|
||||
return resp, err
|
||||
}
|
||||
if saveKey {
|
||||
p.APIKey = resp.APIKey
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// UserInfo contains information about the logged in user
|
||||
type UserInfo struct {
|
||||
Success bool `json:"success"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
// UserInfo returns information about the logged in user. Requires an API key
|
||||
func (p *PixelAPI) UserInfo() (resp UserInfo, err error) {
|
||||
return resp, p.jsonRequest("GET", p.apiEndpoint+"/user", &resp, false)
|
||||
}
|
||||
|
||||
// UserSessionDestroy destroys an API key so it can no longer be used to perform
|
||||
// actions
|
||||
func (p *PixelAPI) UserSessionDestroy(key string) (err error) {
|
||||
return p.jsonRequest("DELETE", p.apiEndpoint+"/user/session", nil, false)
|
||||
}
|
||||
|
||||
// UserFiles is a list of files uploaded by a user
|
||||
type UserFiles struct {
|
||||
Success bool `json:"success"`
|
||||
Files []FileInfo `json:"files"`
|
||||
}
|
||||
|
||||
// UserFiles gets files uploaded by a user
|
||||
func (p *PixelAPI) UserFiles(page, limit int) (resp UserFiles, err error) {
|
||||
return resp, p.jsonRequest(
|
||||
"GET", fmt.Sprintf("%s/user/files?page=%d&limit=%d", p.apiEndpoint, page, limit), &resp, false,
|
||||
)
|
||||
}
|
||||
|
||||
// UserLists is a list of lists created by a user
|
||||
type UserLists struct {
|
||||
Success bool `json:"success"`
|
||||
Lists []List `json:"lists"`
|
||||
}
|
||||
|
||||
// UserLists gets lists created by a user
|
||||
func (p *PixelAPI) UserLists(page, limit int) (resp UserLists, err error) {
|
||||
return resp, p.jsonRequest(
|
||||
"GET", fmt.Sprintf("%s/user/lists?page=%d&limit=%d", p.apiEndpoint, page, limit), &resp, false,
|
||||
)
|
||||
}
|
||||
|
||||
// UserPasswordSet changes the user's password
|
||||
func (p *PixelAPI) UserPasswordSet(oldPW, newPW string) (err error) {
|
||||
return p.form(
|
||||
"PUT", p.apiEndpoint+"/user/password",
|
||||
url.Values{"old_password": {oldPW}, "new_password": {newPW}}, nil, true,
|
||||
)
|
||||
}
|
||||
|
||||
// UserEmailReset starts the e-mail change process. An email will be sent to the
|
||||
// new address to verify that it's real. Once the link in the e-mail is clicked
|
||||
// the key it contains can be sent to the API with UserEmailResetConfirm and the
|
||||
// change will be applied
|
||||
func (p *PixelAPI) UserEmailReset(email string, delete bool) (err error) {
|
||||
var form = url.Values{}
|
||||
form.Add("new_email", email)
|
||||
form.Add("delete", strconv.FormatBool(delete))
|
||||
return p.form("PUT", p.apiEndpoint+"/user/email_reset", form, nil, true)
|
||||
}
|
||||
|
||||
// UserEmailResetConfirm finishes process of changing a user's e-mail address
|
||||
func (p *PixelAPI) UserEmailResetConfirm(key string) (err error) {
|
||||
return p.form(
|
||||
"PUT", p.apiEndpoint+"/user/email_reset_confirm",
|
||||
url.Values{"key": {key}}, nil, true,
|
||||
)
|
||||
}
|
||||
|
||||
// UserPasswordReset starts the password reset process. An email will be sent
|
||||
// the user to verify that it really wanted to reset the password. Once the link
|
||||
// in the e-mail is clicked the key it contains can be sent to the API with
|
||||
// UserPasswordResetConfirm and a new password can be set
|
||||
func (p *PixelAPI) UserPasswordReset(email string, recaptchaResponse string) (err error) {
|
||||
var form = url.Values{}
|
||||
form.Add("email", email)
|
||||
form.Add("recaptcha_response", recaptchaResponse)
|
||||
return p.form("PUT", p.apiEndpoint+"/user/password_reset", form, nil, true)
|
||||
}
|
||||
|
||||
// UserPasswordResetConfirm finishes process of resetting a user's password. If
|
||||
// the key is valid the new_password parameter will be saved as the new password
|
||||
func (p *PixelAPI) UserPasswordResetConfirm(key string, newPassword string) (err error) {
|
||||
var form = url.Values{}
|
||||
form.Add("key", key)
|
||||
form.Add("new_password", newPassword)
|
||||
return p.form("PUT", p.apiEndpoint+"/user/password_reset_confirm", form, nil, true)
|
||||
}
|
||||
|
||||
// UserSetUsername changes the user's username.
|
||||
func (p *PixelAPI) UserSetUsername(username string) (err error) {
|
||||
var form = url.Values{}
|
||||
form.Add("new_username", username)
|
||||
return p.form("PUT", p.apiEndpoint+"/user/username", form, nil, true)
|
||||
}
|
7
res/include/img/icons/medium.svg
Normal file
7
res/include/img/icons/medium.svg
Normal file
@@ -0,0 +1,7 @@
|
||||
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 126.66667" height="24" width="24" xml:space="preserve" version="1.1" id="svg2">
|
||||
<g transform="matrix(1.3333333,0,0,-1.3333333,0,126.66667)" id="g10">
|
||||
<g transform="scale(0.1)" id="g12">
|
||||
<path id="path14" fill="#{{.Style.InputTextColor.RGB}}" style="fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 1200,810 -47.46,0 C 1134.92,810 1110,784.582 1110,768.309 l 0,-589.809 c 0,-16.293 24.92,-38.5 42.54,-38.5 l 47.46,0 0,-140 -430,0 0,140 90,0 0,620 -4.41,0 L 645.422,0 482.707,0 275.25,760 270,760 270,140 360,140 360,0 0,0 0,140 46.0977,140 C 65.082,140 90,162.207 90,178.5 l 0,589.809 C 90,784.582 65.082,810 46.0977,810 L 0,810 l 0,140 450.164,0 147.797,-550 4.066,0 149.164,550 448.809,0 0,-140"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 823 B |
6
res/include/img/icons/patreon.svg
Normal file
6
res/include/img/icons/patreon.svg
Normal file
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 100 100">
|
||||
<g fill="#{{.Style.InputTextColor.RGB}}" fill-rule="evenodd">
|
||||
<path d="M64.1102,0.1004 C44.259,0.1004 28.1086,16.2486 28.1086,36.0986 C28.1086,55.8884 44.259,71.989 64.1102,71.989 C83.9,71.989 100,55.8884 100,36.0986 C100,16.2486 83.9,0.1004 64.1102,0.1004"/>
|
||||
<polygon points=".012 95.988 17.59 95.988 17.59 .1 .012 .1"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 432 B |
@@ -48,6 +48,9 @@
|
||||
.icon.small {
|
||||
font-size: 16px;
|
||||
}
|
||||
a > svg {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* Page rendering configuration */
|
||||
html, body {
|
||||
|
@@ -216,6 +216,7 @@
|
||||
top: 0;
|
||||
width: 8em;
|
||||
height: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.toolbar_button{
|
||||
|
@@ -22,7 +22,7 @@
|
||||
<div class="spacer"></div>
|
||||
<button id="btn_home">🏠</button> -->
|
||||
<div class="spacer"></div>
|
||||
<input class="breadcrumbs" type="text" value="/{{.Username}}"/>
|
||||
<input class="breadcrumbs" type="text" value="/{{.User.Username}}"/>
|
||||
<div class="spacer"></div>
|
||||
<input id="input_search" class="input_search" type="text" placeholder="Search..."/>
|
||||
<div class="spacer"></div>
|
||||
@@ -51,10 +51,10 @@
|
||||
|
||||
let hashChange = () => {
|
||||
if (window.location.hash === "#files") {
|
||||
breadcrumbs.value = "/{{.Username}}/Files"
|
||||
breadcrumbs.value = "/{{.User.Username}}/Files"
|
||||
fm.getUserFiles()
|
||||
} else if (window.location.hash === "#lists") {
|
||||
breadcrumbs.value = "/{{.Username}}/Lists"
|
||||
breadcrumbs.value = "/{{.User.Username}}/Lists"
|
||||
fm.getUserLists()
|
||||
} else {
|
||||
alert("invalid file manager type")
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{{define "user_home"}}<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{{template "meta_tags" .Username}}
|
||||
{{template "meta_tags" .User.Username}}
|
||||
{{template "user_style" .}}
|
||||
<script>var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
</head>
|
||||
@@ -9,47 +9,57 @@
|
||||
<body>
|
||||
{{template "page_top" .}}
|
||||
|
||||
<h1>Welcome home, {{.Username}}!</h1>
|
||||
<h1>Welcome home, {{.User.Username}}!</h1>
|
||||
|
||||
<div class="page_content"><div class="limit_width">
|
||||
<h2>Account information</h2>
|
||||
<ul>
|
||||
<li>Username: {{.Username}}</li>
|
||||
<li>E-mail address: {{.Email}}</li>
|
||||
</ul>
|
||||
<a href="/user/settings" class="button">Update account settings</a>
|
||||
|
||||
<h2>Your most recently uploaded files:</h2>
|
||||
<div class="highlight_dark">
|
||||
{{$files := .PixelAPI.UserFiles 0 15}}
|
||||
{{range $files.Files}}<!--
|
||||
--><a class="file_button" href="/u/{{.ID}}" target="_blank">
|
||||
<img src="{{$.APIEndpoint}}/file/{{.ID}}/thumbnail?width=80&height=80" alt="{{.Name}}" />
|
||||
<span class="file_button_title">{{.Name}}</span>
|
||||
<br/>
|
||||
{{.DateUpload.Format "2006-01-02 15:04:05"}}
|
||||
</a><!--
|
||||
-->{{end}}
|
||||
<br/>
|
||||
<a href="/user/files" class="button">...All my files</a>
|
||||
<div class="page_content">
|
||||
<div class="limit_width">
|
||||
<h2>Account information</h2>
|
||||
<ul>
|
||||
<li>Username: {{.User.Username}}</li>
|
||||
<li>E-mail address: {{.User.Email}}</li>
|
||||
<li>
|
||||
Supporter status:
|
||||
{{if eq .User.Subscription ""}}
|
||||
Not a pixeldrain supporter<br/>
|
||||
<a href="https://www.patreon.com/pixeldrain">Learn how to support pixeldrain</a>.
|
||||
{{else}}
|
||||
{{if eq .User.Subscription "patreon_1"}}
|
||||
Level 1 Patreon supporter. Benefits:
|
||||
<ul>
|
||||
<li>No ads when viewing files</li>
|
||||
</ul>
|
||||
{{else if eq .User.Subscription "patreon_2"}}
|
||||
Level 2 Patreon supporter. Benefits:
|
||||
<ul>
|
||||
<li>No ads when viewing files</li>
|
||||
<li>No ads on uploaded files</li>
|
||||
<li>2-month file expiry (Not implemented yet)</li>
|
||||
</ul>
|
||||
{{else if eq .User.Subscription "patreon_3"}}
|
||||
Level 3 Patreon supporter. Benefits:
|
||||
<ul>
|
||||
<li>No ads when viewing files</li>
|
||||
<li>No ads on uploaded files</li>
|
||||
<li>6-month file expiry (Not implemented yet)</li>
|
||||
</ul>
|
||||
{{else if eq .User.Subscription "patreon_4"}}
|
||||
Level 4 Patreon supporter. Benefits:
|
||||
<ul>
|
||||
<li>No ads when viewing files</li>
|
||||
<li>No ads on uploaded files</li>
|
||||
<li>No file expiry (Not implemented yet)</li>
|
||||
</ul>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</li>
|
||||
</ul>
|
||||
<a href="/user/settings" class="button button_highlight">Change account settings</a>
|
||||
<h2>Navigation</h2>
|
||||
<a href="/" class="button">Upload files</a>
|
||||
<a href="/user/filemanager#files" class="button">My files</a>
|
||||
<a href="/user/filemanager#lists" class="button">My lists</a>
|
||||
</div>
|
||||
<h2>Your most recently created lists:</h2>
|
||||
<div class="highlight_dark">
|
||||
{{$lists := .PixelAPI.UserLists 0 15}}
|
||||
{{range $lists.Lists}}<!--
|
||||
--><a class="file_button" href="/l/{{.ID}}" target="_blank">
|
||||
<img src="{{$.APIEndpoint}}/list/{{.ID}}/thumbnail?width=80&height=80" alt="{{.Title}}" />
|
||||
<span class="file_button_title">{{.Title}}</span>
|
||||
({{.FileCount}} Files)
|
||||
<br/>
|
||||
{{.DateCreated.Format "2006-01-02 15:04:05"}}
|
||||
</a><!--
|
||||
-->{{end}}
|
||||
<br/>
|
||||
<a href="/user/lists" class="button">...All my lists</a>
|
||||
</div>
|
||||
<br/><br/>
|
||||
</div></div>
|
||||
</div>
|
||||
|
||||
{{template "page_bottom" .}}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{{define "user_settings"}}<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{{template "meta_tags" .Username}}
|
||||
{{template "meta_tags" .User.Username}}
|
||||
{{template "user_style" .}}
|
||||
<script>var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
</head>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{{define "user_settings_vue_test"}}<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{{template "meta_tags" .Username}}
|
||||
{{template "meta_tags" .User.Username}}
|
||||
{{template "user_style" .}}
|
||||
<script>var apiEndpoint = '{{.APIEndpoint}}';</script>
|
||||
</head>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
{{$isAdmin := .PixelAPI.UserIsAdmin}}
|
||||
{{template "page_top" .}}
|
||||
<div class="page_content">
|
||||
{{if $isAdmin.IsAdmin}}
|
||||
{{if $isAdmin}}
|
||||
<h3>Bandwidth and views</h3>
|
||||
<div class="highlight_dark">
|
||||
<button onclick="setData(7, 60);">Week</button>
|
||||
|
@@ -12,7 +12,7 @@
|
||||
{{$success := .URLQuery.Get "success"}}
|
||||
{{if eq $success "true"}}
|
||||
{{if .Authenticated}}
|
||||
Dear {{.Username}},
|
||||
Dear {{.User.Username}},
|
||||
<br/><br/>
|
||||
Thank you for your donation. I really appreciate it!
|
||||
<br/><br/>
|
||||
|
@@ -69,7 +69,26 @@
|
||||
<i class="icon">edit</i>
|
||||
<span><u>E</u>dit</span>
|
||||
</button>
|
||||
{{template "advertisement" .}}
|
||||
<br/>
|
||||
|
||||
{{if .Other.ShowAds}}
|
||||
<hr/>
|
||||
<!-- <div id="brave_ref" style="text-align: center; padding: 2px;"> -->
|
||||
{{if ne (isBrave .UserAgent) true}}
|
||||
Use the Brave web browser for a faster and safer web!<br/>
|
||||
<a href="https://brave.com/pix009" id="btnBrave" class="button toolbar_button button_full_width button_highlight">
|
||||
<img src="{{template `brave_lion.png`}}" alt="Brave lion"/>
|
||||
<span>Get Brave</span>
|
||||
</a>
|
||||
<br/>
|
||||
or <a href="https://medium.com/pixeldrain/advertising-on-pixeldrain-a-more-honest-approach-d5e00e3f0c29">learn why pixeldrain supports Brave</a>
|
||||
{{else}}
|
||||
Thank you for using Brave! Please consider supporting pixeldrain with a tip
|
||||
<img src="{{template `bat_logo_color.png`}}" style="height: 1em; width: 1em;" />
|
||||
{{end}}
|
||||
<!-- </div> -->
|
||||
<br/>
|
||||
{{end}}
|
||||
|
||||
<!-- This frame will load the download URL when a download button is pressed -->
|
||||
<iframe id="download_frame" style="display: none; width: 1px; height: 1px;"></iframe>
|
||||
@@ -99,6 +118,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{if .Other.ShowAds}}
|
||||
<div id="sponsors" class="sponsors">
|
||||
{{if eq .Other.AdType 0}}
|
||||
<!-- scrolling="no" is not allowed by the W3C, but overflow: hidden doesn't work in chrome, so I have no choice -->
|
||||
@@ -114,6 +134,7 @@
|
||||
</a>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<template id="tpl_details_popup">
|
||||
|
@@ -1,18 +0,0 @@
|
||||
{{define "advertisement"}}
|
||||
<br/><hr/>
|
||||
<div id="brave_ref" style="text-align: center; padding: 2px;">
|
||||
{{if ne (isBrave .UserAgent) true}}
|
||||
Use the Brave web browser for a faster and safer web!<br/>
|
||||
<a href="https://brave.com/pix009" id="btnBrave" class="button toolbar_button button_full_width button_highlight">
|
||||
<img src="{{template `brave_lion.png`}}" alt="Brave lion"/>
|
||||
<span>Get Brave</span>
|
||||
</a>
|
||||
<br/>
|
||||
or <a href="https://medium.com/pixeldrain/advertising-on-pixeldrain-a-more-honest-approach-d5e00e3f0c29">learn why pixeldrain supports Brave</a>
|
||||
{{else}}
|
||||
Thank you for using Brave! Please consider supporting pixeldrain with a tip
|
||||
<img src="{{template `bat_logo_color.png`}}" style="height: 1em; width: 1em;" />
|
||||
{{end}}
|
||||
</div>
|
||||
<br/>
|
||||
{{end}}
|
@@ -3,7 +3,7 @@
|
||||
<div id="page_navigation" class="page_navigation">
|
||||
<a href="/">Home</a>
|
||||
<hr />
|
||||
{{if .Authenticated}}<a href="/user">{{.Username}}</a>
|
||||
{{if .Authenticated}}<a href="/user">{{.User.Username}}</a>
|
||||
<a href="/user/filemanager#files">My Files</a>
|
||||
<a href="/user/filemanager#lists">My Lists</a>
|
||||
<a href="/logout">Log out</a>
|
||||
@@ -42,10 +42,17 @@
|
||||
|
||||
{{define "page_bottom"}}
|
||||
<div class="highlight_dark">
|
||||
Pixeldrain is a product by <a href="//fornaxian.com" target="_blank">Fornaxian Technologies</a> |
|
||||
Twitter: <a href="https://twitter.com/Fornax96" target="_blank">@Fornax96</a>
|
||||
Reddit: <a href="https://reddit.com/r/pixeldrain" target="_blank">/r/pixeldrain</a>
|
||||
Medium: <a href="https://medium.com/pixeldrain" target="_blank">Pixeldrain</a>
|
||||
<div style="display: inline-block; margin: 0 8px 0 8px;">
|
||||
Pixeldrain is a product by <a href="//fornaxian.com" target="_blank">Fornaxian Technologies</a>
|
||||
</div>
|
||||
<div style="display: inline-block; margin: 0 8px 0 8px;">
|
||||
(
|
||||
<a href="https://www.patreon.com/pixeldrain" target="_blank">{{template `patreon.svg` .}} Patreon</a> |
|
||||
<a href="https://twitter.com/Fornax96" target="_blank">{{template `twitter.svg` .}} Twitter</a> |
|
||||
<a href="https://reddit.com/r/pixeldrain" target="_blank">{{template `reddit.svg` .}} Reddit</a> |
|
||||
<a href="https://medium.com/pixeldrain" target="_blank">{{template `medium.svg` .}} Medium</a>
|
||||
)
|
||||
</div>
|
||||
<br/>
|
||||
<span class="small_footer_text" style="font-size: .75em; line-height: .75em;">
|
||||
page rendered by {{.Hostname}}
|
||||
|
@@ -1,22 +0,0 @@
|
||||
{{define "hide_refer"}}<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>You are being redirected</title>
|
||||
<!-- <meta http-equiv="refresh" content="0; {{.}}" /> -->
|
||||
<style>html, body {background-color: #000000;}</style>
|
||||
</head>
|
||||
<body>
|
||||
You are being redirected.<br/>
|
||||
<br/>
|
||||
If it doesn't work. <a id="link" href="{{.}}">Click here</a>.
|
||||
|
||||
<script>
|
||||
var a = document.getElementById("link");
|
||||
if(!a.click) {
|
||||
window.location = "{{.}}";
|
||||
}
|
||||
a.click();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
{{end}}
|
@@ -56,7 +56,6 @@
|
||||
</a>
|
||||
<br/><br/>
|
||||
Tip: Save your file with extension '.md' to use markdown formatting<br/>
|
||||
{{template "advertisement" .}}
|
||||
</div>
|
||||
<div class="textarea_container">
|
||||
<textarea id="textarea" class="textarea" placeholder="Your text here..." autofocus="autofocus"></textarea>
|
||||
|
@@ -4,10 +4,8 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"fornaxian.com/pixeldrain-api/api/apiclient"
|
||||
"fornaxian.com/pixeldrain-api/util"
|
||||
|
||||
"fornaxian.com/pixeldrain-web/pixelapi"
|
||||
|
||||
"github.com/Fornaxian/log"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
@@ -17,9 +15,7 @@ func (wc *WebController) serveAdClick(w http.ResponseWriter, r *http.Request, p
|
||||
w.Header().Set("Referrer-Policy", "origin")
|
||||
http.Redirect(w, r, r.URL.Query().Get("target"), http.StatusTemporaryRedirect)
|
||||
|
||||
// wc.templates.Get().ExecuteTemplate(w, "hide_refer", r.URL.Query().Get("target"))
|
||||
|
||||
api := pixelapi.New(wc.apiURLInternal)
|
||||
api := apiclient.New(wc.apiURLInternal)
|
||||
|
||||
// The Real IP is used in the API server to determine that the view is not
|
||||
// fake
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"fornaxian.com/pixeldrain-web/pixelapi"
|
||||
"fornaxian.com/pixeldrain-api/api/apiclient"
|
||||
"github.com/Fornaxian/log"
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ func (wc *WebController) adminGlobalsForm(td *TemplateData, r *http.Request) (f
|
||||
if isAdmin, err := td.PixelAPI.UserIsAdmin(); err != nil {
|
||||
td.Title = err.Error()
|
||||
return Form{Title: td.Title}
|
||||
} else if !isAdmin.IsAdmin {
|
||||
} else if !isAdmin {
|
||||
td.Title = ";)"
|
||||
return Form{Title: td.Title}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (wc *WebController) adminGlobalsForm(td *TemplateData, r *http.Request) (f
|
||||
|
||||
// Value changed, try to update global setting
|
||||
if err = td.PixelAPI.AdminSetGlobals(v.Name, v.EnteredValue); err != nil {
|
||||
if apiErr, ok := err.(pixelapi.Error); ok {
|
||||
if apiErr, ok := err.(apiclient.Error); ok {
|
||||
f.SubmitMessages = append(f.SubmitMessages, template.HTML(apiErr.Message))
|
||||
} else {
|
||||
log.Error("%s", err)
|
||||
|
@@ -6,13 +6,11 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"fornaxian.com/pixeldrain-api/api/apiclient"
|
||||
"fornaxian.com/pixeldrain-api/util"
|
||||
"fornaxian.com/pixeldrain-web/pixelapi"
|
||||
"github.com/Fornaxian/log"
|
||||
"github.com/microcosm-cc/bluemonday"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
||||
"github.com/microcosm-cc/bluemonday"
|
||||
"gopkg.in/russross/blackfriday.v2"
|
||||
)
|
||||
|
||||
@@ -23,7 +21,7 @@ func (wc *WebController) serveFilePreview(w http.ResponseWriter, r *http.Request
|
||||
return
|
||||
}
|
||||
|
||||
api := pixelapi.New(wc.apiURLInternal)
|
||||
api := apiclient.New(wc.apiURLInternal)
|
||||
api.APIKey, _ = wc.getAPIKey(r)
|
||||
api.RealIP = util.RemoteAddress(r)
|
||||
|
||||
|
@@ -9,10 +9,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
pdmimetype "github.com/Fornaxian/pd_mime_type"
|
||||
|
||||
"fornaxian.com/pixeldrain-web/pixelapi"
|
||||
"fornaxian.com/pixeldrain-api/api/apiclient"
|
||||
"fornaxian.com/pixeldrain-api/api/apitype"
|
||||
"github.com/Fornaxian/log"
|
||||
pdmimetype "github.com/Fornaxian/pd_mime_type"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
@@ -47,6 +47,7 @@ type viewerData struct {
|
||||
CaptchaKey string
|
||||
ViewToken string
|
||||
AdType int
|
||||
ShowAds bool
|
||||
APIResponse interface{}
|
||||
}
|
||||
|
||||
@@ -62,13 +63,13 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
||||
|
||||
templateData := wc.newTemplateData(w, r)
|
||||
|
||||
var finfo []pixelapi.ListFile
|
||||
var finfo []apitype.ListFile
|
||||
for _, id := range ids {
|
||||
inf, err := templateData.PixelAPI.GetFileInfo(id)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
finfo = append(finfo, pixelapi.ListFile{FileInfo: inf})
|
||||
finfo = append(finfo, apitype.ListFile{FileInfo: inf})
|
||||
}
|
||||
|
||||
if len(finfo) == 0 {
|
||||
@@ -85,7 +86,8 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
||||
CaptchaKey: wc.captchaKey(),
|
||||
ViewToken: wc.viewTokenOrBust(),
|
||||
AdType: adType(),
|
||||
APIResponse: pixelapi.List{
|
||||
ShowAds: finfo[0].ShowAds,
|
||||
APIResponse: apitype.ListInfo{
|
||||
Success: true,
|
||||
Title: "Multiple files",
|
||||
DateCreated: time.Now(),
|
||||
@@ -99,6 +101,7 @@ func (wc *WebController) serveFileViewer(w http.ResponseWriter, r *http.Request,
|
||||
CaptchaKey: wc.captchaKey(),
|
||||
ViewToken: wc.viewTokenOrBust(),
|
||||
AdType: adType(),
|
||||
ShowAds: finfo[0].ShowAds,
|
||||
APIResponse: finfo[0].FileInfo,
|
||||
}
|
||||
}
|
||||
@@ -123,6 +126,7 @@ func (wc *WebController) serveFileViewerDemo(w http.ResponseWriter, r *http.Requ
|
||||
Type: "file",
|
||||
CaptchaKey: wc.captchaSiteKey,
|
||||
AdType: 0, // Always show a-ads on the demo page
|
||||
ShowAds: true,
|
||||
APIResponse: map[string]interface{}{
|
||||
"id": "demo",
|
||||
"name": "Demo file",
|
||||
@@ -148,7 +152,7 @@ func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request,
|
||||
var templateData = wc.newTemplateData(w, r)
|
||||
var list, err = templateData.PixelAPI.GetList(p.ByName("id"))
|
||||
if err != nil {
|
||||
if err, ok := err.(pixelapi.Error); ok && err.Status == http.StatusNotFound {
|
||||
if err, ok := err.(apiclient.Error); ok && err.Status == http.StatusNotFound {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
wc.templates.Get().ExecuteTemplate(w, "list_not_found", templateData)
|
||||
} else {
|
||||
@@ -158,6 +162,10 @@ func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request,
|
||||
}
|
||||
return
|
||||
}
|
||||
if len(list.Files) == 0 {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
wc.templates.Get().ExecuteTemplate(w, "list_not_found", templateData)
|
||||
}
|
||||
|
||||
templateData.Title = fmt.Sprintf("%s ~ pixeldrain", list.Title)
|
||||
templateData.OGData = metadataFromList(list)
|
||||
@@ -166,6 +174,7 @@ func (wc *WebController) serveListViewer(w http.ResponseWriter, r *http.Request,
|
||||
CaptchaKey: wc.captchaSiteKey,
|
||||
ViewToken: wc.viewTokenOrBust(),
|
||||
AdType: adType(),
|
||||
ShowAds: list.Files[0].ShowAds,
|
||||
APIResponse: list,
|
||||
}
|
||||
|
||||
@@ -238,7 +247,7 @@ func (wc *WebController) serveSkynetViewer(w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
contentRange = strings.TrimPrefix(contentRange, "bytes ")
|
||||
size, err := strconv.ParseUint(strings.Split(contentRange, "/")[1], 10, 64)
|
||||
size, err := strconv.ParseInt(strings.Split(contentRange, "/")[1], 10, 64)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -256,19 +265,14 @@ func (wc *WebController) serveSkynetViewer(w http.ResponseWriter, r *http.Reques
|
||||
templateData.Other = viewerData{
|
||||
Type: "skylink",
|
||||
AdType: adType(),
|
||||
APIResponse: pixelapi.FileInfo{
|
||||
Success: true,
|
||||
ID: p.ByName("id"),
|
||||
Name: name,
|
||||
Size: size,
|
||||
Views: 0,
|
||||
BandwidthUsed: 0,
|
||||
DateUpload: time.Now(),
|
||||
DateLastView: time.Now(),
|
||||
MimeType: fileType,
|
||||
MimeImage: "",
|
||||
ThumbnailHREF: "",
|
||||
Availability: "",
|
||||
APIResponse: apitype.FileInfo{
|
||||
Success: true,
|
||||
ID: p.ByName("id"),
|
||||
Name: name,
|
||||
Size: size,
|
||||
DateUpload: time.Now(),
|
||||
DateLastView: time.Now(),
|
||||
MimeType: fileType,
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import (
|
||||
"html/template"
|
||||
"strings"
|
||||
|
||||
"fornaxian.com/pixeldrain-web/pixelapi"
|
||||
"fornaxian.com/pixeldrain-api/api/apitype"
|
||||
)
|
||||
|
||||
type ogRule struct {
|
||||
@@ -34,7 +34,7 @@ func (o linkRule) HTML() template.HTML {
|
||||
return template.HTML(`<link rel="` + o.Rel + `" href="` + o.HREF + `"/>` + "\n")
|
||||
}
|
||||
|
||||
func metadataFromFile(f pixelapi.FileInfo) (meta template.HTML) {
|
||||
func metadataFromFile(f apitype.FileInfo) (meta template.HTML) {
|
||||
meta += ogRule{"og:title", f.Name}.HTML()
|
||||
meta += ogRule{"og:site_name", "pixeldrain"}.HTML()
|
||||
meta += ogRule{"og:description", "View '" + f.Name + "' on pixeldrain"}.HTML()
|
||||
@@ -79,7 +79,7 @@ func metadataFromFile(f pixelapi.FileInfo) (meta template.HTML) {
|
||||
}
|
||||
return meta
|
||||
}
|
||||
func metadataFromList(l pixelapi.List) (meta template.HTML) {
|
||||
func metadataFromList(l apitype.ListInfo) (meta template.HTML) {
|
||||
meta += ogRule{"og:type", "website"}.HTML()
|
||||
meta += ogRule{"og:title", l.Title}.HTML()
|
||||
meta += ogRule{"og:site_name", "pixeldrain"}.HTML()
|
||||
|
@@ -14,8 +14,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"fornaxian.com/pixeldrain-api/api/apiclient"
|
||||
"fornaxian.com/pixeldrain-api/api/apitype"
|
||||
"fornaxian.com/pixeldrain-api/util"
|
||||
"fornaxian.com/pixeldrain-web/pixelapi"
|
||||
"github.com/Fornaxian/log"
|
||||
)
|
||||
|
||||
@@ -23,13 +24,12 @@ import (
|
||||
// the field Other you can pass your own template-specific variables.
|
||||
type TemplateData struct {
|
||||
Authenticated bool
|
||||
Username string
|
||||
Email string
|
||||
User apitype.UserInfo
|
||||
UserAgent string
|
||||
Style pixeldrainStyleSheet
|
||||
UserStyle template.CSS
|
||||
APIEndpoint template.URL
|
||||
PixelAPI *pixelapi.PixelAPI
|
||||
PixelAPI *apiclient.PixelAPI
|
||||
Hostname template.HTML
|
||||
|
||||
// Only used on file viewer page
|
||||
@@ -46,12 +46,11 @@ type TemplateData struct {
|
||||
func (wc *WebController) newTemplateData(w http.ResponseWriter, r *http.Request) (t *TemplateData) {
|
||||
t = &TemplateData{
|
||||
Authenticated: false,
|
||||
Username: "",
|
||||
UserAgent: r.UserAgent(),
|
||||
Style: userStyle(r),
|
||||
UserStyle: template.CSS(userStyle(r).String()),
|
||||
APIEndpoint: template.URL(wc.apiURLExternal),
|
||||
PixelAPI: pixelapi.New(wc.apiURLInternal),
|
||||
PixelAPI: apiclient.New(wc.apiURLInternal),
|
||||
Hostname: template.HTML(wc.hostname),
|
||||
URLQuery: r.URL.Query(),
|
||||
}
|
||||
@@ -64,7 +63,7 @@ func (wc *WebController) newTemplateData(w http.ResponseWriter, r *http.Request)
|
||||
// and stuff like that
|
||||
if key, err := wc.getAPIKey(r); err == nil {
|
||||
t.PixelAPI.APIKey = key // Use the user's API key for all requests
|
||||
uinf, err := t.PixelAPI.UserInfo()
|
||||
t.User, err = t.PixelAPI.UserInfo()
|
||||
if err != nil {
|
||||
// This session key doesn't work, or the backend is down, user
|
||||
// cannot be authenticated
|
||||
@@ -96,8 +95,6 @@ func (wc *WebController) newTemplateData(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
// Authentication succeeded
|
||||
t.Authenticated = true
|
||||
t.Username = uinf.Username
|
||||
t.Email = uinf.Email
|
||||
}
|
||||
|
||||
return t
|
||||
@@ -245,7 +242,7 @@ func (tm *TemplateManager) sub(a, b interface{}) int {
|
||||
return detectInt(a) - detectInt(b)
|
||||
}
|
||||
func (tm *TemplateManager) formatData(i interface{}) string {
|
||||
return util.FormatData(uint64(detectInt(i)))
|
||||
return util.FormatData(int64(detectInt(i)))
|
||||
}
|
||||
|
||||
func detectInt(i interface{}) int {
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"fornaxian.com/pixeldrain-web/pixelapi"
|
||||
"fornaxian.com/pixeldrain-api/api/apiclient"
|
||||
"github.com/Fornaxian/log"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
@@ -16,7 +16,7 @@ func (wc *WebController) serveLogout(
|
||||
p httprouter.Params,
|
||||
) {
|
||||
if key, err := wc.getAPIKey(r); err == nil {
|
||||
var api = pixelapi.New(wc.apiURLInternal)
|
||||
var api = apiclient.New(wc.apiURLInternal)
|
||||
api.APIKey = key
|
||||
if err = api.UserSessionDestroy(key); err != nil {
|
||||
log.Warn("logout failed for session '%s': %s", key, err)
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"fornaxian.com/pixeldrain-web/pixelapi"
|
||||
"fornaxian.com/pixeldrain-api/api/apiclient"
|
||||
"github.com/Fornaxian/log"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
@@ -23,7 +23,7 @@ func formAPIError(err error, f *Form) {
|
||||
return name
|
||||
}
|
||||
|
||||
if err, ok := err.(pixelapi.Error); ok {
|
||||
if err, ok := err.(apiclient.Error); ok {
|
||||
if err.StatusCode == "multiple_errors" {
|
||||
for _, err := range err.Errors {
|
||||
// Modify the message to make it more user-friendly
|
||||
@@ -169,7 +169,7 @@ func (wc *WebController) serveEmailConfirm(
|
||||
var err error
|
||||
var status string
|
||||
|
||||
api := pixelapi.New(wc.apiURLInternal)
|
||||
api := apiclient.New(wc.apiURLInternal)
|
||||
err = api.UserEmailResetConfirm(r.FormValue("key"))
|
||||
if err != nil && err.Error() == "not_found" {
|
||||
status = "not_found"
|
||||
|
@@ -8,10 +8,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"fornaxian.com/pixeldrain-web/pixelapi"
|
||||
"fornaxian.com/pixeldrain-api/api/apiclient"
|
||||
"github.com/Fornaxian/log"
|
||||
"github.com/google/uuid"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
@@ -36,7 +35,7 @@ type WebController struct {
|
||||
|
||||
// This API client should only be used for system functions like getting
|
||||
// view tokens. It has no authentication and no IP forwarding
|
||||
systemPixelAPI *pixelapi.PixelAPI
|
||||
systemPixelAPI *apiclient.PixelAPI
|
||||
}
|
||||
|
||||
// New initializes a new WebController by registering all the request handlers
|
||||
@@ -58,7 +57,7 @@ func New(
|
||||
apiURLExternal: apiURLExternal,
|
||||
sessionCookieDomain: sessionCookieDomain,
|
||||
httpClient: &http.Client{Timeout: time.Minute * 10},
|
||||
systemPixelAPI: pixelapi.New(apiURLInternal),
|
||||
systemPixelAPI: apiclient.New(apiURLInternal),
|
||||
}
|
||||
wc.templates = NewTemplateManager(resourceDir, apiURLExternal, debugMode)
|
||||
wc.templates.ParseTemplates(false)
|
||||
@@ -188,7 +187,7 @@ func (wc *WebController) serveForm(
|
||||
// The handler retuns the form which will be rendered
|
||||
td.Form = handler(td, r)
|
||||
|
||||
td.Form.Username = td.Username
|
||||
td.Form.Username = td.User.Username
|
||||
|
||||
// Execute the extra actions if any
|
||||
if td.Form.Extra.SetCookie != nil {
|
||||
@@ -249,7 +248,7 @@ func (wc *WebController) getAPIKey(r *http.Request) (key string, err error) {
|
||||
func (wc *WebController) captchaKey() string {
|
||||
// This only runs on the first request
|
||||
if wc.captchaSiteKey == "" {
|
||||
var api = pixelapi.New(wc.apiURLInternal)
|
||||
var api = apiclient.New(wc.apiURLInternal)
|
||||
capt, err := api.GetRecaptcha()
|
||||
if err != nil {
|
||||
log.Error("Error getting recaptcha key: %s", err)
|
||||
|
Reference in New Issue
Block a user