An organizer for your porn, written in Go
Go to file
gitgiggety c91ffe1e58
Tag hierarchy (#1519)
* Add migration script for tag relations table
* Expand hierarchical filter features

Expand the features of the hierarchical multi input filter with support
for using a relations table, which only has parent_id and child_id
columns, and support adding an additional intermediate table to join on,
for example for scenes and tags which are linked by the scenes_tags
table as well.

* Add hierarchical filtering for tags
* Add hierarchical tags support to scene markers

Refactor filtering of scene markers to filterBuilder and in the process
add support for hierarchical tags as well.

* List parent and child tags on tag details page
* Support setting parent and child tags

Add support for setting parent and child tags during tag creation and
tag updates.

* Validate no loops are created in tags hierarchy
* Update tag merging to support tag hierarcy
* Add unit tests for tags.EnsureUniqueHierarchy
* Fix applying recursive to with clause

The SQL `RECURSIVE` of a `WITH` clause only needs to be applied once,
imediately after the `WITH`. So this fixes the query building to do just
that, automatically applying the `RECURSIVE` keyword when any added with
clause is added as recursive.

* Rename hierarchical root id column
* Rewrite hierarchical filtering for performance

Completely rewrite the hierarchical filtering to optimize for
performance. Doing the recursive query in combination with a complex
query seems to break SQLite optimizing some things which means that the
recursive part might be 2,5 second slower than adding a static
`VALUES()` list. This is mostly noticable in case of the tag hierarchy
where setting an exclusion with any depth (or depth: all) being applied
has this performance impact of 2,5 second. "Include" also suffered this
issue, but some rewritten query by joining in the *_tags table in one
pass and applying a `WHERE x IS NOT NULL` filter did seem to optimize
that case. But that optimization isn't applied to the `IS NULL` filter
of "exclude". Running a simple query beforehand to get all (recursive)
items and then applying them to the query doesn't have this performance
penalty.

* Remove UI references to child studios and tags
* Add parents to tag export
* Support importing of parent relationship for tags
* Assign stable ids to parent / child badges
* Silence Apollo warning on parents/children fields on tags

Silence warning triggered by Apollo GraphQL by explicitly instructing it
to use the incoming parents/children values. By default it already does
this, but it triggers a warning as it might be unintended that it uses
the incoming values (instead of for example merging both arrays).
Setting merge to false still applies the same behaviour (use only
incoming values) but silences the warning as it's explicitly configured
to work like this.

* Rework detecting unique tag hierarchy

Completely rework the unique tag hierarchy to detect invalid hierarchies
for which a tag is "added in the middle". So when there are tags A <- B
and A <- C, you could previously edit tag B and add tag C as a sub tag
without it being noticed as parent A being applied twice (to tag C).
While afterwards saving tag C would fail as tag A was applied as parent
twice. The updated code correctly detects this scenario as well.

Furthermore the error messaging has been reworked a bit and the message
now mentions both the direct parent / sub tag as well as the tag which
would results in the error. So in aboves example it would now show the
message that tag C can't be applied because tag A already is a parent.

* Update relations on cached tags when needed

Update the relations on cached tags when a tag is created / updated /
deleted so these always reflect the correct state. Otherwise (re)opening
a tag might still show the old relations untill the page is fully
reloaded or the list is navigated. But this obviously is strange when
you for example have tag A, create or update tag B to have a relation to
tag A, and from tags B page click through to tag A and it doesn't show
that it is linked to tag B.
2021-09-09 14:58:43 +10:00
.github Apple Silicon Support, Bump Go to 1.17, refactor docker/build/x86_64/Dockerfile (#1646) 2021-09-08 15:30:15 +10:00
.idea Cut over to v2.5 UI (#433) 2020-04-03 08:46:23 +11:00
docker Apple Silicon Support, Bump Go to 1.17, refactor docker/build/x86_64/Dockerfile (#1646) 2021-09-08 15:30:15 +10:00
docs [Feature] Adding Feature.md/BugFix.md Pull Request Template. (#343) 2020-02-12 21:07:51 -05:00
graphql Tag hierarchy (#1519) 2021-09-09 14:58:43 +10:00
pkg Tag hierarchy (#1519) 2021-09-09 14:58:43 +10:00
scripts Apple Silicon Support, Bump Go to 1.17, refactor docker/build/x86_64/Dockerfile (#1646) 2021-09-08 15:30:15 +10:00
static Remove stripes and add background colour to default performer images (#1609) 2021-08-04 09:01:34 +10:00
ui Tag hierarchy (#1519) 2021-09-09 14:58:43 +10:00
vendor Apple Silicon Support, Bump Go to 1.17, refactor docker/build/x86_64/Dockerfile (#1646) 2021-09-08 15:30:15 +10:00
.dockerignore Cross compile for armv7/armv8, raise raspi variant to armv6 (only) (#737) 2020-08-20 09:27:54 +10:00
.gitattributes Refactor build (#493) 2020-04-29 12:13:08 +10:00
.gitignore Fix filter building with sub-filters (#1212) 2021-03-18 21:45:18 +11:00
.goreleaser.yml Apple Silicon Support, Bump Go to 1.17, refactor docker/build/x86_64/Dockerfile (#1646) 2021-09-08 15:30:15 +10:00
.gqlgenc.yml Stash box client interface (#751) 2020-09-17 19:57:18 +10:00
.travis.yml.disabled Apple Silicon Support, Bump Go to 1.17, refactor docker/build/x86_64/Dockerfile (#1646) 2021-09-08 15:30:15 +10:00
LICENSE Add LICENSE until we get all signers on the switch (#297) 2020-01-20 22:18:12 -05:00
Makefile Apple Silicon Support, Bump Go to 1.17, refactor docker/build/x86_64/Dockerfile (#1646) 2021-09-08 15:30:15 +10:00
README.md Apple Silicon Support, Bump Go to 1.17, refactor docker/build/x86_64/Dockerfile (#1646) 2021-09-08 15:30:15 +10:00
go.mod Apple Silicon Support, Bump Go to 1.17, refactor docker/build/x86_64/Dockerfile (#1646) 2021-09-08 15:30:15 +10:00
go.sum Changes to Default Performer Images (for Accessibility) (#1489) 2021-08-10 13:51:31 +10:00
gqlgen.yml Unify scrape refactor (#1630) 2021-09-07 11:54:22 +10:00
main.go When stopping, close the database (#1686) 2021-09-07 14:28:40 +10:00
main_test.go Ran formatter and fixed some lint issues 2019-02-14 14:53:32 -08:00
revive.toml Ran formatter and fixed some lint issues 2019-02-14 14:53:32 -08:00
tools.go Apple Silicon Support, Bump Go to 1.17, refactor docker/build/x86_64/Dockerfile (#1646) 2021-09-08 15:30:15 +10:00

README.md

Stash

Build Status Go Report Card Discord

https://stashapp.cc

Stash is a locally hosted web-based app written in Go which organizes and serves your porn.

  • It can gather information about videos in your collection from the internet, and is extensible through the use of community-built plugins for a large number of content producers.
  • It supports a wide variety of both video and image formats.
  • You can tag videos and find them later.
  • It provides statistics about performers, tags, studios and other things.

You can watch a SFW demo video to see it in action.

For further information you can read the in-app manual.

Installing stash

via Docker

Follow this README.md in the docker directory.

Pre-Compiled Binaries

The Stash server runs on macOS, Windows, and Linux. Download the latest release here.

Run the executable (double click the exe on windows or run ./stash-osx / ./stash-linux from the terminal on macOS / Linux) and navigate to either https://localhost:9999 or http://localhost:9999 to get started.

Note for Windows users: Running the app might present a security prompt since the binary isn't yet signed. Bypass this by clicking "more info" and then the "run anyway" button.

FFMPEG

If stash is unable to find or download FFMPEG then download it yourself from the link for your platform:

The ffmpeg(.exe) and ffprobe(.exe) files should be placed in ~/.stash on macOS / Linux or C:\Users\YourUsername\.stash on Windows.

Usage

Quickstart Guide

  1. Download and install Stash and its dependencies
  2. Run Stash. It will prompt you for some configuration options and a directory to index (you can also do this step afterward)
  3. After configuration, launch your web browser and navigate to the URL shown within the Stash app.

Note that Stash does not currently retrieve and organize information about your entire library automatically. You will need to help it along through the use of scrapers. The Stash community has developed scrapers for many popular data sources which can be downloaded and installed from this repository.

The simplest way to tag a large number of files is by using the Tagger which uses filename keywords to help identify the file and pull in scene and performer information from our stash-box database. Note that this data source is not comprehensive and you may need to use the scrapers to identify some of your media.

CLI

Stash runs as a command-line app and local web server. There are some command-line options available, which you can see by running stash --help.

For example, to run stash locally on port 80 run it like this (OSX / Linux) stash --host 127.0.0.1 --port 80

SSL (HTTPS)

Stash can run over HTTPS with some additional work. First you must generate a SSL certificate and key combo. Here is an example using openssl:

openssl req -x509 -newkey rsa:4096 -sha256 -days 7300 -nodes -keyout stash.key -out stash.crt -extensions san -config <(echo "[req]"; echo distinguished_name=req; echo "[san]"; echo subjectAltName=DNS:stash.server,IP:127.0.0.1) -subj /CN=stash.server

This command would need customizing for your environment. This link might be useful.

Once you have a certificate and key file name them stash.crt and stash.key and place them in the same directory as the config.yml file, or the ~/.stash directory. Stash detects these and starts up using HTTPS rather than HTTP.

Customization

Themes and CSS Customization

There is a directory of community-created themes on our Wiki, along with instructions on how to install them.

You can also make Stash interface fit your desired style with Custom CSS snippets and CSS Tweaks.

Support (FAQ)

Answers to other Frequently Asked Questions can be found on our Wiki

For issues not addressed there, there are a few options.

  • Read the Wiki
  • Check the in-app documentation (also available here
  • Join the Discord server, where the community can offer support.

Compiling From Source Code

Pre-requisites

  • Go
  • Revive - Configurable linter
    • Go Install: go get github.com/mgechev/revive
  • Packr2 - Static asset bundler
  • Yarn - Yarn package manager
    • Run yarn install --frozen-lockfile in the stash/ui/v2.5 folder (before running make generate for first time).

NOTE: You may need to run the go get commands outside the project directory to avoid modifying the projects module file.

Environment

macOS

TODO

Windows

  1. Download and install Go for Windows
  2. Download and install MingW
  3. Search for "advanced system settings" and open the system properties dialog.
    1. Click the Environment Variables button
    2. Under system variables find the Path. Edit and add C:\Program Files\mingw-w64\*\mingw64\bin (replace * with the correct path).

NOTE: The make command in Windows will be mingw32-make with MingW.

Commands

  • make generate - Generate Go and UI GraphQL files
  • make build - Builds the binary (make sure to build the UI as well... see below)
  • make docker-build - Locally builds and tags a complete 'stash/build' docker image
  • make pre-ui - Installs the UI dependencies. Only needs to be run once before building the UI for the first time, or if the dependencies are updated
  • make fmt-ui - Formats the UI source code.
  • make ui - Builds the frontend and the packr2 files
  • make packr - Generate packr2 files (sub-target of ui. Use to regenerate packr2 files without rebuilding UI)
  • make vet - Run go vet
  • make lint - Run the linter
  • make fmt - Run go fmt
  • make fmt-check - Ensure changed files are formatted correctly
  • make it - Run the unit and integration tests
  • make validate - Run all of the tests and checks required to submit a PR
  • make ui-start - Runs the UI in development mode. Requires a running stash server to connect to. Stash port can be changed from the default of 9999 with environment variable REACT_APP_PLATFORM_PORT.

Building a release

  1. Run make generate to create generated files
  2. Run make ui to compile the frontend
  3. Run make build to build the executable for your current platform

Cross compiling

This project uses a modification of the CI-GoReleaser docker container to create an environment where the app can be cross-compiled. This process is kicked off by CI via the scripts/cross-compile.sh script. Run the following command to open a bash shell to the container to poke around:

docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash -i -t stashappdev/compiler:latest /bin/bash

Profiling

Stash can be profiled using the --cpuprofile <output profile filename> command line flag.

The resulting file can then be used with pprof as follows:

go tool pprof <path to binary> <path to profile filename>

With graphviz installed and in the path, a call graph can be generated with:

go tool pprof -svg <path to binary> <path to profile filename> > <output svg file>