Skip to content

Commit

Permalink
Write documentation, clean project, clone from gitlab to github for v…
Browse files Browse the repository at this point in the history
…isibility
  • Loading branch information
axelberardino committed Aug 12, 2019
1 parent 56efbfa commit 217a332
Show file tree
Hide file tree
Showing 21 changed files with 285 additions and 44 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
poe-stash
poe-stash-cli-*
poe-stash-server-*
data/*.html
data/cache/*
pass.txt
.vscode
13 changes: 0 additions & 13 deletions README

This file was deleted.

137 changes: 137 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <YOUR_ACCOUNT> --poesessid <YOUR_POESESSID> --league <YOUR_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)
15 changes: 9 additions & 6 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions cmd/server/page/gen_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/page/view_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/template/error.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ define "error" }}
{{ template "header" }}
{{ template "header" . }}

<div id="main-page">
<h1>An error occured :'(</h1>
Expand Down
2 changes: 1 addition & 1 deletion data/template/main.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ define "main" }}
{{ template "header" }}
{{ template "header" . }}

<div id="main-page">
<div>
Expand Down
5 changes: 4 additions & 1 deletion data/template/parts/header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@
<body>
<!-- Start of main container -->
<div id="main-container" />
<div id="header"><a href="/">PoE Stash</a></div>
<div id="header">
<a href="/">PoE Stash</a>
<span class="version">{{ .Version }}</span>
</div>
{{ end }}
18 changes: 10 additions & 8 deletions data/template/parts/helpers.js.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions data/template/parts/style.css.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{{ define "style.css" }}
<style type="text/css">
.version {
font-size: 8px;
font-family: Verdana,Arial,Helvetica,sans-serif;
-webkit-text-stroke: 0px;
text-shadow: none;
}
.clear {
clear: both;
height: 15px;
Expand Down Expand Up @@ -80,6 +86,7 @@
text-decoration: none;
display: table-cell;
width: 100%;
vertical-align: middle;
}
.accounts li a:hover {
color: #eCcBa9;
Expand Down
2 changes: 1 addition & 1 deletion data/template/profile.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ define "profile" }}
{{ template "header" }}
{{ template "header" . }}

<div id="wealth">
<b>Estimated wealth:</b><img class="thumbnail" src="https://web.poecdn.com/image/Art/2DItems/Currency/CurrencyRerollRare.png?scale=1&amp;w=1&amp;h=1&amp;v=c60aa876dd6bab31174df91b1da1b4f9"><small>x</small>{{ .Wealth.EstimatedChaos }} (with
Expand Down
2 changes: 1 addition & 1 deletion data/template/redirect.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ define "redirect" }}
{{ template "header" }}
{{ template "header" . }}

<div id="main-page">
<h1>Generated!</h1>
Expand Down
2 changes: 2 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
theme: jekyll-theme-slate
show_downloads: true
Loading

0 comments on commit 217a332

Please sign in to comment.