From 217a332c41dec85a18af76edf46a6694f13bdf0d Mon Sep 17 00:00:00 2001 From: Axel Berardino Date: Mon, 12 Aug 2019 12:22:00 +0200 Subject: [PATCH] Write documentation, clean project, clone from gitlab to github for visibility --- .gitignore | 4 +- README | 13 --- README.md | 137 ++++++++++++++++++++++++++++ cmd/cli/main.go | 15 +-- cmd/server/main.go | 6 +- cmd/server/page/gen_account.go | 4 +- cmd/server/page/view_account.go | 2 +- data/template/error.tmpl | 2 +- data/template/main.tmpl | 2 +- data/template/parts/header.tmpl | 5 +- data/template/parts/helpers.js.tmpl | 18 ++-- data/template/parts/style.css.tmpl | 7 ++ data/template/profile.tmpl | 2 +- data/template/redirect.tmpl | 2 +- docs/_config.yml | 2 + docs/index.md | 83 +++++++++++++++++ gen_bin.sh | 14 +++ generate/generator.go | 4 +- scraper/characters.go | 2 +- scraper/scraper.go | 3 +- scraper/stash.go | 2 +- 21 files changed, 285 insertions(+), 44 deletions(-) delete mode 100644 README create mode 100644 README.md create mode 100644 docs/_config.yml create mode 100644 docs/index.md create mode 100755 gen_bin.sh diff --git a/.gitignore b/.gitignore index bedbebc..64d475c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -poe-stash +poe-stash-cli-* +poe-stash-server-* data/*.html data/cache/* pass.txt +.vscode diff --git a/README b/README deleted file mode 100644 index 5f6b055..0000000 --- a/README +++ /dev/null @@ -1,13 +0,0 @@ -## POE STASH - -Scrap stash from official website and display it publicly. - -### Dependencies - -gin-tonic: -go get -u github.com/gin-gonic/gin - -TODO - More rigourous item description generation - Shop id for the link after shop generation - Search bar? diff --git a/README.md b/README.md new file mode 100644 index 0000000..9e2aac0 --- /dev/null +++ b/README.md @@ -0,0 +1,137 @@ +## POE STASH + +Share your stuff with others! +Scrap stash from the official **Path of Exile** website +(http://pathofexile.com) and generate a sharable file. +Main website here: https://cptpingu.github.io/poe-stash + +### Goal + +Share a stash with a friend: + * Easily + * Nothing to install (if hosted) + * Portable (should be compatible with everything) + * Simple to use + +### Demo + +I put some files online, to show what the generated files look like: +http://0217021.free.fr/poe-stash/ + +### Project history + +This project has been created because I wanted to show what I got to a +friend. I was astonished there was no way to share stash and didn't +find any tool to do that. I needed a tool which was simple to use and +which generate a sharable portable file. That's why I choose a single +html file (css and javascript are embeded). + +The initial tool was a CLI which fetch the official API, and generated +this html file. Issue is, it's not easy for everyone to use the +command line. So, I created a simple http server to serve this file +and remember the poe sessid. By hosting this project, there is nothing +to install! A simple browser is enough. + +Then, I wanted to handle item selling. I didn't like existing tool +(even if there are more advanced). I wanted something like the +premium tab stash in game. I handled that using browser local storage +(keep in mind that file are not necessarily hosted online, so it has +to work as a single html file open on a device). + +I'm heavily using this tool and satisfied with that. I often read +online that people wanted to share what they got, but have no way to +do that. So I decided to clean this project, and share it online. + +### Generate a file with the CLI + +``` +go install cmd/cli +``` + +You can use `cli` or `go run cmd/cli/main.go`. I will use the later in +my example. + +``` +go run cmd/cli/main.go --account --poesessid --league +``` + +Account is your account name (not your character name) +Poesessid is the token id used after log in on the official website (in storage > cookie) +League, the league name (standard, legion, ...) + +Example: +``` +go run cmd/cli/main.go --account cptpingu --poesessid ef87f9320ba7428149fe562236e32 --league standard +``` +A file "cptpingu-standard.html" should be created. + +Type --help for a description of all other existing options. + +### Launch the server (graphical interface) + +If you don't like the command line, you can launch the server locally: +``` +go run cmd/server/main.go +``` + +Then, go to: `http://localhost:2121` with your browser. That's all! + +## Passwords + +Nothing is needed to view files, but a login/pass is required for +generation. You need to create a `pass.txt` file containing +`login:password` lines. +Example: +``` +mylogin:mypassword +malachai:immortality +user:35*rfs +``` + +### Note about the POE sessid + +Never ever share your POE sessid! This token is used to identify you +on the official website. This tool need it to fetch all information +about your account, but you should not share it. If a website ask your +poesessid (and it's not launched by you locally), you should not trust +it! + +### Using the generated file + +Viewing items should be pretty intuitive as it works exactly like in +the game. To price an item, left click on it. To remove a price, just +set an empty price. When all prices are set, just click on "generate +items shop", it will copy in your clipboard what you need to paste on +the trade forum. + +Note that every prices are store locally in your browser, and the +storage is associated with the exact url name. It means all prices +will be lost if you: + * Rename the file + * Use another browser + * Clear the browser cache + * Reinstall your browser + * Open the file on another device + +To avoid that, there are an `import shop` and an `export shop` buttons, +which allows you to save and reload the prices you set. + +### Dependencies + + * gin-tonic: https://github.com/gin-gonic/gin (`go get -u github.com/gin-gonic/gin`) + * tippy: https://atomiks.github.io/tippyjs/ + +### Not supported yet + + * Map stash tab (known issue: https://www.pathofexile.com/forum/view-thread/1733474#p13674912) + * Quad stash tab + * Essence stash tab + * Unique stash tab + * Divination stash tab + * Remove only stash tab + * Too much jewels on the character will overflow + +### TODO + * More rigourous item description generation + * Shop id for the link after shop generation + * Search bar? (lot of works) diff --git a/cmd/cli/main.go b/cmd/cli/main.go index e58c34e..0d72f58 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -6,8 +6,8 @@ import ( "fmt" "os" - "gitlab.perso/poe-stash/generate" - "gitlab.perso/poe-stash/scraper" + "github.com/poe-stash/generate" + "github.com/poe-stash/scraper" ) // mandatoryOption ensure an option is not empty. @@ -25,15 +25,14 @@ func main() { account := flag.String("account", "", "account name") poeSessID := flag.String("poesessid", "", "poesessid got after login on the official website") realm := flag.String("realm", "pc", "the realm (pc, ps4, xbox)") - league := flag.String("league", "Standard", "league name (anarchy, legion, synthesis, delve...)") - output := flag.String("output", "-", "where to genreate html file (put \"-\" for stdin") - cache := flag.Bool("cache", false, "do not call distant api, and use local cache if possible") + league := flag.String("league", "standard", "league name (anarchy, legion, synthesis, delve...)") + output := flag.String("output", "", "where to generate html file (put \"-\" for stdin), if empty, a generated name will be created (account-league.html)") + cache := flag.Bool("cache", false, "do not call distant api, and use local cache if possible, for debug purpose only") flag.Parse() mandatoryOption(*account, "account") mandatoryOption(*poeSessID, "poesessid") mandatoryOption(*realm, "realm") mandatoryOption(*league, "league") - mandatoryOption(*output, "output") scraper := scraper.NewScraper(*account, *poeSessID, *realm, *league, *cache) data, errScrap := scraper.ScrapEverything() @@ -44,6 +43,10 @@ func main() { var file *os.File var err error + if *output == "" { + *output = *account + "-" + *league + ".html" + } + if *output == "-" { file = os.Stdout } else { diff --git a/cmd/server/main.go b/cmd/server/main.go index 941a00a..3f651c1 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -11,9 +11,9 @@ import ( "github.com/gin-gonic/gin" - "gitlab.perso/poe-stash/cmd/server/page" - "gitlab.perso/poe-stash/generate" - "gitlab.perso/poe-stash/scraper" + "github.com/poe-stash/cmd/server/page" + "github.com/poe-stash/generate" + "github.com/poe-stash/scraper" ) // setupRouter setups the http server and all its pages. diff --git a/cmd/server/page/gen_account.go b/cmd/server/page/gen_account.go index 76b2df3..d6e87c9 100644 --- a/cmd/server/page/gen_account.go +++ b/cmd/server/page/gen_account.go @@ -9,8 +9,8 @@ import ( "github.com/gin-gonic/gin" - "gitlab.perso/poe-stash/generate" - "gitlab.perso/poe-stash/scraper" + "github.com/poe-stash/generate" + "github.com/poe-stash/scraper" ) // GenAccountHandler handles refresh of an account. diff --git a/cmd/server/page/view_account.go b/cmd/server/page/view_account.go index af0f1d6..87d6335 100644 --- a/cmd/server/page/view_account.go +++ b/cmd/server/page/view_account.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/gin-gonic/gin" - "gitlab.perso/poe-stash/scraper" + "github.com/poe-stash/scraper" ) // ViewAccountHandler handles viewing an account diff --git a/data/template/error.tmpl b/data/template/error.tmpl index 0c07166..53e5ecb 100644 --- a/data/template/error.tmpl +++ b/data/template/error.tmpl @@ -1,5 +1,5 @@ {{ define "error" }} - {{ template "header" }} + {{ template "header" . }}

An error occured :'(

diff --git a/data/template/main.tmpl b/data/template/main.tmpl index b824aca..3e4c317 100644 --- a/data/template/main.tmpl +++ b/data/template/main.tmpl @@ -1,5 +1,5 @@ {{ define "main" }} - {{ template "header" }} + {{ template "header" . }}
diff --git a/data/template/parts/header.tmpl b/data/template/parts/header.tmpl index 5c3a275..e8d54f0 100644 --- a/data/template/parts/header.tmpl +++ b/data/template/parts/header.tmpl @@ -21,5 +21,8 @@
- + {{ end }} diff --git a/data/template/parts/helpers.js.tmpl b/data/template/parts/helpers.js.tmpl index 625c8de..14851b4 100644 --- a/data/template/parts/helpers.js.tmpl +++ b/data/template/parts/helpers.js.tmpl @@ -359,14 +359,16 @@ shop.addEventListener('change', importShop, false); } var mergebox = document.getElementById('merge'); - var value = localStorage.getItem('merge'); - if (value == undefined) { - value = "true"; - } - if (value == "true") { - mergebox.checked = true; - } else { - mergebox.checked = false; + if (mergebox != undefined) { + var value = localStorage.getItem('merge'); + if (value == undefined) { + value = "true"; + } + if (value == "true") { + mergebox.checked = true; + } else { + mergebox.checked = false; + } } } diff --git a/data/template/parts/style.css.tmpl b/data/template/parts/style.css.tmpl index e990f65..e748185 100644 --- a/data/template/parts/style.css.tmpl +++ b/data/template/parts/style.css.tmpl @@ -1,5 +1,11 @@ {{ define "style.css" }}