mirror of
https://github.com/stashapp/stash.git
synced 2026-06-11 07:41:08 -05:00
Compare commits
35 Commits
stashappde
...
v0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6578cfb843 | ||
|
|
acc8a126d0 | ||
|
|
71ca30e8f4 | ||
|
|
691a8c23c0 | ||
|
|
8d57629af3 | ||
|
|
bf49a23df8 | ||
|
|
776727140f | ||
|
|
df3d3d24f5 | ||
|
|
aa8bfaf407 | ||
|
|
df890dca79 | ||
|
|
ae5aa6a6ec | ||
|
|
c99ba68181 | ||
|
|
1d9913d268 | ||
|
|
40de2caa95 | ||
|
|
254d6978d0 | ||
|
|
3c1eeb3d47 | ||
|
|
f87117b0d6 | ||
|
|
066295f0c9 | ||
|
|
077b257316 | ||
|
|
cd9c6e998e | ||
|
|
6a6e8d8875 | ||
|
|
03c07a429d | ||
|
|
2632f9e971 | ||
|
|
78eb527ec4 | ||
|
|
2dc1b42a0a | ||
|
|
3d3f8877de | ||
|
|
c83eb098bc | ||
|
|
5a5f42f061 | ||
|
|
fed7311d9c | ||
|
|
d2e67fdb31 | ||
|
|
80027b91c0 | ||
|
|
66b4f6db4f | ||
|
|
cf96cae4c8 | ||
|
|
600862c0bb | ||
|
|
87f0b667b5 |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -6,7 +6,7 @@ open_collective: stashapp
|
||||
# ko_fi: # Replace with a single Ko-fi username
|
||||
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: StashApp
|
||||
# liberapay: StashApp
|
||||
# issuehunt: # Replace with a single IssueHunt username
|
||||
# otechie: # Replace with a single Otechie username
|
||||
# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
|
||||
18
.github/PULL_REQUEST_TEMPLATE/BugFix.md
vendored
Normal file
18
.github/PULL_REQUEST_TEMPLATE/BugFix.md
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
name: Bug Fix
|
||||
about: Add a bug fix this project!
|
||||
title: "[Bug Fix] Short Form Title (50 chars or less.)"
|
||||
labels: bug
|
||||
assignees: 'WithoutPants, bnkai, Leopere'
|
||||
|
||||
---
|
||||
<!-- Please make sure to read https://github.com/stashapp/stash/docs/CONTRIBUTING.md and check that you understand and have followed it as best as possible -->
|
||||
<!-- Explain what your bugfix seeks to remedy in a short paragraph. -->
|
||||
# Scope
|
||||
|
||||
<!-- Declare any issues by typing `fixes #1` or `closes #1` for example so that the automation can kick in when this is merged -->
|
||||
## Closes/Fixes Issues
|
||||
|
||||
<!-- What have you tested specifically and what possible impacts/areas there are that may need retesting by others. -->
|
||||
## Other testing QA Notes
|
||||
|
||||
17
.github/PULL_REQUEST_TEMPLATE/Feature.md
vendored
Normal file
17
.github/PULL_REQUEST_TEMPLATE/Feature.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
name: Feature Addition
|
||||
about: Add a feature to this project!
|
||||
title: "[Feature] Short Form Title (50 chars or less.)"
|
||||
labels: enhancement
|
||||
assignees: 'WithoutPants, bnkai, Leopere'
|
||||
|
||||
---
|
||||
<!-- Please make sure to read https://github.com/stashapp/stash/docs/CONTRIBUTING.md and check that you understand and have followed it as best as possible
|
||||
Explain what your feature does in a short paragraph. -->
|
||||
# Scope
|
||||
|
||||
<!-- Declare any issues by typing `fixes #1` or `closes #1` for example so that the automation can kick in when this is merged -->
|
||||
## Closes/Fixes Issues
|
||||
|
||||
<!-- What have you tested specifically and what possible impacts/areas there are that may need retesting by others. -->
|
||||
## Other testing QA Notes
|
||||
71
.travis.yml
71
.travis.yml
@@ -9,7 +9,7 @@ env:
|
||||
- GO111MODULE=on
|
||||
before_install:
|
||||
- echo -e "machine github.com\n login $CI_USER_TOKEN" > ~/.netrc
|
||||
- travis_retry yarn --cwd ui/v2 install
|
||||
- travis_retry yarn --cwd ui/v2 install --frozen-lockfile
|
||||
- make generate
|
||||
- CI=false yarn --cwd ui/v2 build # TODO: Fix warnings
|
||||
#- go get -v github.com/mgechev/revive
|
||||
@@ -18,33 +18,52 @@ script:
|
||||
#- make vet
|
||||
- make it
|
||||
after_success:
|
||||
- if [ "$TRAVIS_BRANCH" = "develop" ]; then export TAG_SUFFIX="_dev"; elif [ "$TRAVIS_BRANCH" != "master" ]; then export TAG_SUFFIX="_$TRAVIS_BRANCH"; fi
|
||||
- export STASH_VERSION="v0.0.0-alpha${TAG_SUFFIX}"
|
||||
- docker pull stashapp/compiler:develop
|
||||
- sh ./scripts/cross-compile.sh ${STASH_VERSION}
|
||||
- sh ./scripts/cross-compile.sh
|
||||
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then sh ./scripts/upload-pull-request.sh; fi'
|
||||
before_deploy:
|
||||
- if [ "$TRAVIS_BRANCH" = "develop" ]; then export TAG_SUFFIX="_dev"; fi
|
||||
- git tag -f ${STASH_VERSION}
|
||||
- git push -f --tags
|
||||
# push the latest tag when on the develop branch
|
||||
- if [ "$TRAVIS_BRANCH" = "develop" ]; then git tag -f latest_develop; git push -f --tags; fi
|
||||
- export RELEASE_DATE=$(date +'%Y-%m-%d %H:%M:%S %Z')
|
||||
- export STASH_VERSION=$(git describe --tags --exclude latest_develop)
|
||||
# set TRAVIS_TAG explcitly to the version so that it doesn't pick up latest_develop
|
||||
- if [ "$TRAVIS_BRANCH" = "master"]; then export TRAVIS_TAG=${STASH_VERSION}; fi
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: tGJ2q62CfPdayid2qEtW2aGRhMgCl3lBXYYQqp3eH0vFgIIf6cs7IDX7YC/x3XKMEQ/iMLZmtCXZvSTqNrD6Sk7MSnt30GIs+4uxIZDnnd8mV5X3K4n4gjD+NAORc4DrQBvUGrYMKJsR5gtkH0nu6diWb1o1If7OiJEuCPRhrmQYcza7NUdABnA9Z2wn2RNUV9Ga33WUCqLMEU5GtNBlfQPiP/khCQrqn/ocR6wUjYut3J6YagzqH4wsfJi3glHyWtowcNIw1LZi5zFxHD/bRBT4Tln7yypkjWNq9eQILA6i6kRUGf7ggyTx26/k8n4tnu+QD0vVh4EcjlThpU/LGyUXzKrrxjRwaDZnM0oYxg5AfHcBuAiAdo0eWnV3lEWRfTJMIVb9MPf4qDmzR4RREfB5OXOxwq3ODeCcJE8sTIMD/wBPZrlqS/QrRpND2gn2X4snkVukN9t9F4CMTFMtVSzFV7TDJW5E5Lq6VEExulteQhs6kcK9NRPNAaLgRQAw7X9kVWfDtiGUP+fE2i8F9Bo8bm7sOT5O5VPMPykx3EgeNg1IqIgMTCsMlhMJT4xBJoQUgmd2wWyf3Ryw+P+sFgdb5Sd7+lFgJBjMUUoOxMxAOiEgdFvCXcr+/Udyz2RdtetU1/6VzXzLPcKOw0wubZeBkISqu7o9gpfdMP9Eq00=
|
||||
file:
|
||||
- dist/stash-osx
|
||||
- dist/stash-win.exe
|
||||
- dist/stash-linux
|
||||
- dist/stash-pi
|
||||
skip_cleanup: true
|
||||
overwrite: true
|
||||
body: ${RELEASE_DATE}
|
||||
on:
|
||||
repo: stashapp/stash
|
||||
all_branches: true
|
||||
condition: $TRAVIS_BRANCH =~ ^(master|develop)$
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
# latest develop release
|
||||
- provider: releases
|
||||
api_key:
|
||||
secure: tGJ2q62CfPdayid2qEtW2aGRhMgCl3lBXYYQqp3eH0vFgIIf6cs7IDX7YC/x3XKMEQ/iMLZmtCXZvSTqNrD6Sk7MSnt30GIs+4uxIZDnnd8mV5X3K4n4gjD+NAORc4DrQBvUGrYMKJsR5gtkH0nu6diWb1o1If7OiJEuCPRhrmQYcza7NUdABnA9Z2wn2RNUV9Ga33WUCqLMEU5GtNBlfQPiP/khCQrqn/ocR6wUjYut3J6YagzqH4wsfJi3glHyWtowcNIw1LZi5zFxHD/bRBT4Tln7yypkjWNq9eQILA6i6kRUGf7ggyTx26/k8n4tnu+QD0vVh4EcjlThpU/LGyUXzKrrxjRwaDZnM0oYxg5AfHcBuAiAdo0eWnV3lEWRfTJMIVb9MPf4qDmzR4RREfB5OXOxwq3ODeCcJE8sTIMD/wBPZrlqS/QrRpND2gn2X4snkVukN9t9F4CMTFMtVSzFV7TDJW5E5Lq6VEExulteQhs6kcK9NRPNAaLgRQAw7X9kVWfDtiGUP+fE2i8F9Bo8bm7sOT5O5VPMPykx3EgeNg1IqIgMTCsMlhMJT4xBJoQUgmd2wWyf3Ryw+P+sFgdb5Sd7+lFgJBjMUUoOxMxAOiEgdFvCXcr+/Udyz2RdtetU1/6VzXzLPcKOw0wubZeBkISqu7o9gpfdMP9Eq00=
|
||||
file:
|
||||
- dist/stash-osx
|
||||
- dist/stash-win.exe
|
||||
- dist/stash-linux
|
||||
- dist/stash-pi
|
||||
skip_cleanup: true
|
||||
overwrite: true
|
||||
name: "${STASH_VERSION}: Latest development build"
|
||||
body: ${RELEASE_DATE}\n This is always the latest committed version on the develop branch. Use as your own risk!
|
||||
prerelease: true
|
||||
on:
|
||||
repo: stashapp/stash
|
||||
branch: develop
|
||||
# official master release - only build when tagged
|
||||
- provider: releases
|
||||
api_key:
|
||||
secure: tGJ2q62CfPdayid2qEtW2aGRhMgCl3lBXYYQqp3eH0vFgIIf6cs7IDX7YC/x3XKMEQ/iMLZmtCXZvSTqNrD6Sk7MSnt30GIs+4uxIZDnnd8mV5X3K4n4gjD+NAORc4DrQBvUGrYMKJsR5gtkH0nu6diWb1o1If7OiJEuCPRhrmQYcza7NUdABnA9Z2wn2RNUV9Ga33WUCqLMEU5GtNBlfQPiP/khCQrqn/ocR6wUjYut3J6YagzqH4wsfJi3glHyWtowcNIw1LZi5zFxHD/bRBT4Tln7yypkjWNq9eQILA6i6kRUGf7ggyTx26/k8n4tnu+QD0vVh4EcjlThpU/LGyUXzKrrxjRwaDZnM0oYxg5AfHcBuAiAdo0eWnV3lEWRfTJMIVb9MPf4qDmzR4RREfB5OXOxwq3ODeCcJE8sTIMD/wBPZrlqS/QrRpND2gn2X4snkVukN9t9F4CMTFMtVSzFV7TDJW5E5Lq6VEExulteQhs6kcK9NRPNAaLgRQAw7X9kVWfDtiGUP+fE2i8F9Bo8bm7sOT5O5VPMPykx3EgeNg1IqIgMTCsMlhMJT4xBJoQUgmd2wWyf3Ryw+P+sFgdb5Sd7+lFgJBjMUUoOxMxAOiEgdFvCXcr+/Udyz2RdtetU1/6VzXzLPcKOw0wubZeBkISqu7o9gpfdMP9Eq00=
|
||||
file:
|
||||
- dist/stash-osx
|
||||
- dist/stash-win.exe
|
||||
- dist/stash-linux
|
||||
- dist/stash-pi
|
||||
# make the release a draft so the maintainers can confirm before releasing
|
||||
draft: true
|
||||
skip_cleanup: true
|
||||
overwrite: true
|
||||
# don't write the body. To be done manually for now. In future we might
|
||||
# want to generate the changelog or get it from a file
|
||||
name: ${STASH_VERSION}
|
||||
on:
|
||||
repo: stashapp/stash
|
||||
tags: true
|
||||
# make sure we don't release using the latest_develop tag
|
||||
condition: $TRAVIS_TAG != latest_develop
|
||||
|
||||
674
LICENSE
674
LICENSE
@@ -1,21 +1,661 @@
|
||||
MIT License
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (c) 2019 StashApp
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Preamble
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
3
Makefile
3
Makefile
@@ -8,7 +8,8 @@ release: generate ui build
|
||||
build:
|
||||
$(eval DATE := $(shell go run scripts/getDate.go))
|
||||
$(eval GITHASH := $(shell git rev-parse --short HEAD))
|
||||
$(SET) CGO_ENABLED=1 $(SEPARATOR) go build -mod=vendor -v -ldflags "-X 'github.com/stashapp/stash/pkg/api.buildstamp=$(DATE)' -X 'github.com/stashapp/stash/pkg/api.githash=$(GITHASH)'"
|
||||
$(eval STASH_VERSION := $(shell git describe --tags --exclude latest_develop))
|
||||
$(SET) CGO_ENABLED=1 $(SEPARATOR) go build -mod=vendor -v -ldflags "-X 'github.com/stashapp/stash/pkg/api.version=$(STASH_VERSION)' -X 'github.com/stashapp/stash/pkg/api.buildstamp=$(DATE)' -X 'github.com/stashapp/stash/pkg/api.githash=$(GITHASH)'"
|
||||
|
||||
install:
|
||||
packr2 install
|
||||
|
||||
@@ -16,7 +16,7 @@ Follow [this README.md in the docker directory.](docker/production/README.md)
|
||||
|
||||
Stash supports macOS, Windows, and Linux. Download the [latest release here](https://github.com/stashapp/stash/releases).
|
||||
|
||||
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:9998 to get started.
|
||||
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 signed yet. Just click more info and then the "run anyway" button.
|
||||
|
||||
@@ -69,7 +69,7 @@ Join the [Discord server](https://discord.gg/2TsNFKt).
|
||||
* Go Install: `go get github.com/gobuffalo/packr/v2/packr2@v2.0.2`
|
||||
* [Binary Download](https://github.com/gobuffalo/packr/releases)
|
||||
* [Yarn](https://yarnpkg.com/en/docs/install) - Yarn package manager
|
||||
* Run `yarn install` in the `stash/ui/v2` folder (before running make generate for first time).
|
||||
* Run `yarn install --frozen-lockfile` in the `stash/ui/v2` 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.
|
||||
|
||||
|
||||
55
docker/build/x86_64/Dockerfile
Normal file
55
docker/build/x86_64/Dockerfile
Normal file
@@ -0,0 +1,55 @@
|
||||
# this dockerfile must be built from the top-level stash directory
|
||||
# ie from top=level stash:
|
||||
# docker build -t stash/build -f docker/build/x86_64/Dockerfile .
|
||||
|
||||
FROM golang:1.11.13 as compiler
|
||||
|
||||
RUN apt-get update && apt-get install -y apt-transport-https
|
||||
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
|
||||
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
|
||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y nodejs yarn xz-utils --no-install-recommends || exit 1; \
|
||||
rm -rf /var/lib/apt/lists/*;
|
||||
|
||||
ENV PACKR2_VERSION=2.0.2
|
||||
ENV PACKR2_SHA=f95ff4c96d7a28813220df030ad91700b8464fe292ab3e1dc9582305c2a338d2
|
||||
ENV PACKR2_DOWNLOAD_FILE=packr_${PACKR2_VERSION}_linux_amd64.tar.gz
|
||||
ENV PACKR2_DOWNLOAD_URL=https://github.com/gobuffalo/packr/releases/download/v${PACKR2_VERSION}/${PACKR2_DOWNLOAD_FILE}
|
||||
|
||||
WORKDIR /
|
||||
RUN wget ${PACKR2_DOWNLOAD_URL}; \
|
||||
echo "$PACKR2_SHA $PACKR2_DOWNLOAD_FILE" | sha256sum -c - || exit 1; \
|
||||
tar -xzf $PACKR2_DOWNLOAD_FILE -C /usr/bin/ packr2; \
|
||||
rm $PACKR2_DOWNLOAD_FILE;
|
||||
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
RUN wget -O /ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
|
||||
tar xf /ffmpeg.tar.xz && \
|
||||
rm ffmpeg.tar.xz && \
|
||||
mv /ffmpeg*/ /ffmpeg/
|
||||
|
||||
# copy the ui yarn stuff so that it doesn't get rebuilt every time
|
||||
COPY ./ui/v2/package.json ./ui/v2/yarn.lock /stash/ui/v2/
|
||||
|
||||
WORKDIR /stash
|
||||
RUN yarn --cwd ui/v2 install --frozen-lockfile
|
||||
|
||||
COPY . /stash/
|
||||
ENV GO111MODULE=on
|
||||
|
||||
RUN make generate
|
||||
RUN make ui
|
||||
RUN make build
|
||||
|
||||
FROM ubuntu:19.10 as app
|
||||
|
||||
RUN apt-get update && apt-get -y install ca-certificates
|
||||
COPY --from=compiler /stash/stash /ffmpeg/ffmpeg /ffmpeg/ffprobe /usr/bin/
|
||||
|
||||
EXPOSE 9999
|
||||
CMD ["stash"]
|
||||
|
||||
|
||||
67
docker/build/x86_64/README.md
Normal file
67
docker/build/x86_64/README.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# Introduction
|
||||
|
||||
This dockerfile is used to build a stash docker container using the current source code.
|
||||
|
||||
# Building the docker container
|
||||
|
||||
From the top-level directory (should contain `main.go` file):
|
||||
|
||||
```
|
||||
docker build -t stash/build -f ./docker/build/x86_64/Dockerfile .
|
||||
|
||||
```
|
||||
|
||||
# Running the docker container
|
||||
|
||||
## Using docker-compose
|
||||
|
||||
See the `README.md` file in `docker/production` for instructions on how to get docker-compose if needed.
|
||||
|
||||
The `stash/build` container can be run with the `docker-compose.yml` file in `docker/production` by changing the `image` value to be `stash/build`. See the instructions in `docker/production` for how to run docker-compose.
|
||||
|
||||
## Using `docker run`
|
||||
|
||||
After building the container:
|
||||
|
||||
```
|
||||
docker run \
|
||||
-e STASH_STASH=/data/ \
|
||||
-e STASH_METADATA=/metadata/ \
|
||||
-e STASH_CACHE=/cache/ \
|
||||
-e STASH_GENERATED=/generated/ \
|
||||
-v <path to config dir>:/root/.stash \
|
||||
-v <path to media>:/data \
|
||||
-v <path to metadata>:/metadata \
|
||||
-v <path to cache>:/cache \
|
||||
-v <path to generated>:/generated \
|
||||
-p 9999:9999 \
|
||||
stash/build:latest
|
||||
```
|
||||
|
||||
Change the `<xxx>` to the appropriate paths. Note that the `<path to media>` directory should be separate from the cache, generated and metadata directories. It is recommended to have the cache, generated and metadata directories in the same parent directory, for example:
|
||||
|
||||
```
|
||||
/stash
|
||||
/config
|
||||
/metadata
|
||||
/generated
|
||||
/cache
|
||||
/media
|
||||
```
|
||||
|
||||
Using this example directory structure, the above command would be:
|
||||
|
||||
```
|
||||
docker run \
|
||||
-e STASH_STASH=/data/ \
|
||||
-e STASH_METADATA=/metadata/ \
|
||||
-e STASH_CACHE=/cache/ \
|
||||
-e STASH_GENERATED=/generated/ \
|
||||
-v /stash/config:/root/.stash \
|
||||
-v /media:/data \
|
||||
-v /stash/metadata:/metadata \
|
||||
-v /stash/cache:/cache \
|
||||
-v /stash/generated:/generated \
|
||||
-p 9999:9999 \
|
||||
stash/build:latest
|
||||
```
|
||||
21
docker/develop/x86_64/Dockerfile
Normal file
21
docker/develop/x86_64/Dockerfile
Normal file
@@ -0,0 +1,21 @@
|
||||
FROM ubuntu:18.04 as prep
|
||||
LABEL MAINTAINER="https://discord.gg/Uz29ny"
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get -y install curl xz-utils && \
|
||||
apt-get autoclean -y && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
RUN curl -L -o /stash $(curl -s https://api.github.com/repos/stashapp/stash/releases/tags/latest_develop | awk '/browser_download_url/ && /stash-linux/' | sed -e 's/.*: "\(.*\)"/\1/') && \
|
||||
chmod +x /stash && \
|
||||
curl --http1.1 -o /ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
|
||||
tar xf /ffmpeg.tar.xz && \
|
||||
rm ffmpeg.tar.xz && \
|
||||
mv /ffmpeg*/ /ffmpeg/
|
||||
|
||||
FROM ubuntu:18.04 as app
|
||||
RUN apt-get update && apt-get -y install ca-certificates
|
||||
COPY --from=prep /stash /ffmpeg/ffmpeg /ffmpeg/ffprobe /usr/bin/
|
||||
EXPOSE 9999
|
||||
CMD ["stash"]
|
||||
@@ -11,7 +11,7 @@ services:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-file: "10"
|
||||
max-size: "200k"
|
||||
max-size: "2m"
|
||||
environment:
|
||||
- STASH_STASH=/data/
|
||||
- STASH_GENERATED=/generated/
|
||||
@@ -19,13 +19,16 @@ services:
|
||||
- STASH_CACHE=/cache/
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
## Adjust below paths (the left part) to your liking.
|
||||
## E.g. you can change ./config:/root/.stash to ./stash:/root/.stash
|
||||
|
||||
## Keep configs here.
|
||||
- ./config:/root/.stash
|
||||
## Point this at your collection.
|
||||
- ./data:/data
|
||||
## This is where pre-generated transcodes live.
|
||||
- ./transcodes:/transcodes
|
||||
## This is where your stash's metadata lives
|
||||
- ./metadata:/metadata
|
||||
## Any other cache content.
|
||||
- ./cache:/cache
|
||||
## Where to store generated content (screenshots,previews,transcodes,sprites)
|
||||
- ./generated:/generated
|
||||
|
||||
@@ -7,17 +7,15 @@ RUN apt-get update && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
RUN curl -L -o /stash $(curl -s https://api.github.com/repos/stashapp/stash/releases | grep -F 'stash-linux' | grep download | head -n 1 | cut -d'"' -f4) && \
|
||||
RUN curl -L -o /stash $(curl -s https://api.github.com/repos/stashapp/stash/releases/latest | awk '/browser_download_url/ && /stash-linux/' | sed -e 's/.*: "\(.*\)"/\1/') && \
|
||||
chmod +x /stash && \
|
||||
curl -o /ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
|
||||
curl --http1.1 -o /ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
|
||||
tar xf /ffmpeg.tar.xz && \
|
||||
rm ffmpeg.tar.xz && \
|
||||
mv /ffmpeg*/ /ffmpeg/
|
||||
|
||||
FROM ubuntu:18.04 as app
|
||||
RUN apt-get update && \
|
||||
apt-get -y install ca-certificates && \
|
||||
adduser stash --gecos GECOS --shell /bin/bash --disabled-password --home /home/stash
|
||||
RUN apt-get update && apt-get -y install ca-certificates
|
||||
COPY --from=prep /stash /ffmpeg/ffmpeg /ffmpeg/ffprobe /usr/bin/
|
||||
EXPOSE 9999
|
||||
CMD ["stash"]
|
||||
|
||||
14
docs/CONTRIBUTING.md
Normal file
14
docs/CONTRIBUTING.md
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
## Technical Debt
|
||||
Please be sure to consider how heavily your contribution impacts the maintainability of the project long term, sometimes less is more. We don't want to merge collossal pull requests with hundreds of dependencies by a driveby contributor.
|
||||
|
||||
## Contributor Checklist
|
||||
Please make sure that you've considered the following before you submit your Pull Requests as ready for merging.
|
||||
* I've run Code linters and [gofmt](https://golang.org/cmd/gofmt/) to make sure that my code is readable.
|
||||
* I have read through formerly submitted [pull requests](https://github.com/stashapp/stash/pulls) and [git issues](https://github.com/stashapp/stash/issues) to make sure that this contribution is required and isn't a duplicate. Also, so that I can manage to close any git Issues needing closed relating to this feature submission.
|
||||
* I commented adequately on my code with the expectation in mind that anyone else should be able to look at this code I've submitted and know exactly what's happening and what the expectations are.
|
||||
|
||||
### Legal Agreements
|
||||
* I acknowledge that if applicable to me, submitting and subsequent acceptance of this Pull Request I, the code contributor of this Pull Request, agree and acknowledge my understanding that the new code license has now been updated to [AGPL](/LICENSE.md). I agree that all code before this Pull Request, which I've previously submitted, is now to be re-licensed under the new license AGPL and no longer the former MIT license.
|
||||
|
||||
**In case you were unable to follow any of the above include an explanation as to why not in your Pull Request.**
|
||||
3
go.mod
3
go.mod
@@ -12,6 +12,7 @@ require (
|
||||
github.com/golang-migrate/migrate/v4 v4.3.1
|
||||
github.com/gorilla/websocket v1.4.0
|
||||
github.com/h2non/filetype v1.0.8
|
||||
// this is required for generate
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/jmoiron/sqlx v1.2.0
|
||||
github.com/mattn/go-sqlite3 v1.10.0
|
||||
@@ -28,3 +29,5 @@ require (
|
||||
)
|
||||
|
||||
replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999
|
||||
|
||||
go 1.11
|
||||
|
||||
1
go.sum
1
go.sum
@@ -258,6 +258,7 @@ github.com/gobuffalo/packr v1.15.0/go.mod h1:t5gXzEhIviQwVlNx/+3SfS07GS+cZ2hn76W
|
||||
github.com/gobuffalo/packr v1.15.1/go.mod h1:IeqicJ7jm8182yrVmNbM6PR4g79SjN9tZLH8KduZZwE=
|
||||
github.com/gobuffalo/packr v1.19.0/go.mod h1:MstrNkfCQhd5o+Ct4IJ0skWlxN8emOq8DsoT1G98VIU=
|
||||
github.com/gobuffalo/packr v1.20.0/go.mod h1:JDytk1t2gP+my1ig7iI4NcVaXr886+N0ecUga6884zw=
|
||||
github.com/gobuffalo/packr v1.21.0 h1:p2ujcDJQp2QTiYWcI0ByHbr/gMoCouok6M0vXs/yTYQ=
|
||||
github.com/gobuffalo/packr v1.21.0/go.mod h1:H00jGfj1qFKxscFJSw8wcL4hpQtPe1PfU2wa6sg/SR0=
|
||||
github.com/gobuffalo/packr/v2 v2.0.0-rc.8/go.mod h1:y60QCdzwuMwO2R49fdQhsjCPv7tLQFR0ayzxxla9zes=
|
||||
github.com/gobuffalo/packr/v2 v2.0.0-rc.9/go.mod h1:fQqADRfZpEsgkc7c/K7aMew3n4aF1Kji7+lIZeR98Fc=
|
||||
|
||||
@@ -6,6 +6,7 @@ fragment SlimSceneData on Scene {
|
||||
url
|
||||
date
|
||||
rating
|
||||
o_counter
|
||||
path
|
||||
|
||||
file {
|
||||
|
||||
@@ -6,6 +6,7 @@ fragment SceneData on Scene {
|
||||
url
|
||||
date
|
||||
rating
|
||||
o_counter
|
||||
path
|
||||
|
||||
file {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
fragment ScrapedPerformerData on ScrapedPerformer {
|
||||
name
|
||||
url
|
||||
twitter
|
||||
instagram
|
||||
birthdate
|
||||
ethnicity
|
||||
country
|
||||
|
||||
@@ -62,6 +62,18 @@ mutation ScenesUpdate($input : [SceneUpdateInput!]!) {
|
||||
}
|
||||
}
|
||||
|
||||
mutation SceneIncrementO($id: ID!) {
|
||||
sceneIncrementO(id: $id)
|
||||
}
|
||||
|
||||
mutation SceneDecrementO($id: ID!) {
|
||||
sceneDecrementO(id: $id)
|
||||
}
|
||||
|
||||
mutation SceneResetO($id: ID!) {
|
||||
sceneResetO(id: $id)
|
||||
}
|
||||
|
||||
mutation SceneDestroy($id: ID!, $delete_file: Boolean, $delete_generated : Boolean) {
|
||||
sceneDestroy(input: {id: $id, delete_file: $delete_file, delete_generated: $delete_generated})
|
||||
}
|
||||
@@ -66,3 +66,10 @@ query Version {
|
||||
build_time
|
||||
}
|
||||
}
|
||||
|
||||
query LatestVersion {
|
||||
latestversion {
|
||||
shorthash
|
||||
url
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,9 @@ type Query {
|
||||
|
||||
# Version
|
||||
version: Version!
|
||||
|
||||
# LatestVersion
|
||||
latestversion: ShortVersion!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
@@ -104,6 +107,13 @@ type Mutation {
|
||||
sceneDestroy(input: SceneDestroyInput!): Boolean!
|
||||
scenesUpdate(input: [SceneUpdateInput!]!): [Scene]
|
||||
|
||||
"""Increments the o-counter for a scene. Returns the new value"""
|
||||
sceneIncrementO(id: ID!): Int!
|
||||
"""Decrements the o-counter for a scene. Returns the new value"""
|
||||
sceneDecrementO(id: ID!): Int!
|
||||
"""Resets the o-counter for a scene to 0. Returns the new value"""
|
||||
sceneResetO(id: ID!): Int!
|
||||
|
||||
sceneMarkerCreate(input: SceneMarkerCreateInput!): SceneMarker
|
||||
sceneMarkerUpdate(input: SceneMarkerUpdateInput!): SceneMarker
|
||||
sceneMarkerDestroy(id: ID!): Boolean!
|
||||
@@ -136,4 +146,4 @@ schema {
|
||||
query: Query
|
||||
mutation: Mutation
|
||||
subscription: Subscription
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +62,12 @@ input SceneMarkerFilterType {
|
||||
input SceneFilterType {
|
||||
"""Filter by rating"""
|
||||
rating: IntCriterionInput
|
||||
"""Filter by o-counter"""
|
||||
o_counter: IntCriterionInput
|
||||
"""Filter by resolution"""
|
||||
resolution: ResolutionEnum
|
||||
"""Filter by duration (in seconds)"""
|
||||
duration: IntCriterionInput
|
||||
"""Filter to only include scenes which have markers. `true` or `false`"""
|
||||
has_markers: String
|
||||
"""Filter to only include scenes missing this property"""
|
||||
|
||||
@@ -26,6 +26,7 @@ type Scene {
|
||||
url: String
|
||||
date: String
|
||||
rating: Int
|
||||
o_counter: Int
|
||||
path: String!
|
||||
|
||||
file: SceneFileType! # Resolver
|
||||
|
||||
@@ -2,4 +2,9 @@ type Version {
|
||||
version: String
|
||||
hash: String!
|
||||
build_time: String!
|
||||
}
|
||||
}
|
||||
|
||||
type ShortVersion {
|
||||
shorthash: String!
|
||||
url: String!
|
||||
}
|
||||
|
||||
242
pkg/api/check_version.go
Normal file
242
pkg/api/check_version.go
Normal file
@@ -0,0 +1,242 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
)
|
||||
|
||||
//we use the github REST V3 API as no login is required
|
||||
const apiReleases string = "https://api.github.com/repos/stashapp/stash/releases"
|
||||
const apiTags string = "https://api.github.com/repos/stashapp/stash/tags"
|
||||
const apiAcceptHeader string = "application/vnd.github.v3+json"
|
||||
const developmentTag string = "latest_develop"
|
||||
|
||||
var stashReleases = func() map[string]string {
|
||||
return map[string]string{
|
||||
"windows/amd64": "stash-win.exe",
|
||||
"linux/amd64": "stash-linux",
|
||||
"darwin/amd64": "stash-osx",
|
||||
"linux/arm": "stash-pi",
|
||||
}
|
||||
}
|
||||
|
||||
type githubReleasesResponse struct {
|
||||
Url string
|
||||
Assets_url string
|
||||
Upload_url string
|
||||
Html_url string
|
||||
Id int64
|
||||
Node_id string
|
||||
Tag_name string
|
||||
Target_commitish string
|
||||
Name string
|
||||
Draft bool
|
||||
Author githubAuthor
|
||||
Prerelease bool
|
||||
Created_at string
|
||||
Published_at string
|
||||
Assets []githubAsset
|
||||
Tarball_url string
|
||||
Zipball_url string
|
||||
Body string
|
||||
}
|
||||
|
||||
type githubAuthor struct {
|
||||
Login string
|
||||
Id int64
|
||||
Node_id string
|
||||
Avatar_url string
|
||||
Gravatar_id string
|
||||
Url string
|
||||
Html_url string
|
||||
Followers_url string
|
||||
Following_url string
|
||||
Gists_url string
|
||||
Starred_url string
|
||||
Subscriptions_url string
|
||||
Organizations_url string
|
||||
Repos_url string
|
||||
Events_url string
|
||||
Received_events_url string
|
||||
Type string
|
||||
Site_admin bool
|
||||
}
|
||||
|
||||
type githubAsset struct {
|
||||
Url string
|
||||
Id int64
|
||||
Node_id string
|
||||
Name string
|
||||
Label string
|
||||
Uploader githubAuthor
|
||||
Content_type string
|
||||
State string
|
||||
Size int64
|
||||
Download_count int64
|
||||
Created_at string
|
||||
Updated_at string
|
||||
Browser_download_url string
|
||||
}
|
||||
|
||||
type githubTagResponse struct {
|
||||
Name string
|
||||
Zipball_url string
|
||||
Tarball_url string
|
||||
Commit struct {
|
||||
Sha string
|
||||
Url string
|
||||
}
|
||||
Node_id string
|
||||
}
|
||||
|
||||
func makeGithubRequest(url string, output interface{}) error {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
|
||||
req, _ := http.NewRequest("GET", url, nil)
|
||||
|
||||
req.Header.Add("Accept", apiAcceptHeader) // gh api recommendation , send header with api version
|
||||
response, err := client.Do(req)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Github API request failed: %s", err)
|
||||
}
|
||||
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("Github API request failed: %s", response.Status)
|
||||
}
|
||||
|
||||
defer response.Body.Close()
|
||||
|
||||
data, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Github API read response failed: %s", err)
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, output)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unmarshalling Github API response failed: %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetLatestVersion gets latest version (git commit hash) from github API
|
||||
// If running a build from the "master" branch, then the latest full release
|
||||
// is used, otherwise it uses the release that is tagged with "latest_develop"
|
||||
// which is the latest pre-release build.
|
||||
func GetLatestVersion(shortHash bool) (latestVersion string, latestRelease string, err error) {
|
||||
|
||||
platform := fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)
|
||||
wantedRelease := stashReleases()[platform]
|
||||
|
||||
version, _, _ := GetVersion()
|
||||
if version == "" {
|
||||
return "", "", fmt.Errorf("Stash doesn't have a version. Version check not supported.")
|
||||
}
|
||||
|
||||
// if the version is suffixed with -x-xxxx, then we are running a development build
|
||||
usePreRelease := false
|
||||
re := regexp.MustCompile(`-\d+-g\w+$`)
|
||||
if re.MatchString(version) {
|
||||
usePreRelease = true
|
||||
}
|
||||
|
||||
url := apiReleases
|
||||
if !usePreRelease {
|
||||
// just get the latest full release
|
||||
url += "/latest"
|
||||
} else {
|
||||
// get the release tagged with the development tag
|
||||
url += "/tags/" + developmentTag
|
||||
}
|
||||
|
||||
release := githubReleasesResponse{}
|
||||
err = makeGithubRequest(url, &release)
|
||||
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
if release.Prerelease == usePreRelease {
|
||||
latestVersion = getReleaseHash(release, shortHash, usePreRelease)
|
||||
|
||||
if wantedRelease != "" {
|
||||
for _, asset := range release.Assets {
|
||||
if asset.Name == wantedRelease {
|
||||
latestRelease = asset.Browser_download_url
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if latestVersion == "" {
|
||||
return "", "", fmt.Errorf("No version found for \"%s\"", version)
|
||||
}
|
||||
return latestVersion, latestRelease, nil
|
||||
}
|
||||
|
||||
func getReleaseHash(release githubReleasesResponse, shortHash bool, usePreRelease bool) string {
|
||||
// the /latest API call doesn't return the hash in target_commitish
|
||||
// also add sanity check in case Target_commitish is not 40 characters
|
||||
if !usePreRelease || len(release.Target_commitish) != 40 {
|
||||
return getShaFromTags(shortHash, release.Tag_name)
|
||||
}
|
||||
|
||||
if shortHash {
|
||||
return release.Target_commitish[0:7] //shorthash is first 7 digits of git commit hash
|
||||
}
|
||||
|
||||
return release.Target_commitish
|
||||
}
|
||||
|
||||
func printLatestVersion() {
|
||||
_, githash, _ = GetVersion()
|
||||
latest, _, err := GetLatestVersion(true)
|
||||
if err != nil {
|
||||
logger.Errorf("Couldn't find latest version: %s", err)
|
||||
} else {
|
||||
if githash == latest {
|
||||
logger.Infof("Version: (%s) is already the latest released.", latest)
|
||||
} else {
|
||||
logger.Infof("New version: (%s) available.", latest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get sha from the github api tags endpoint
|
||||
// returns the sha1 hash/shorthash or "" if something's wrong
|
||||
func getShaFromTags(shortHash bool, name string) string {
|
||||
url := apiTags
|
||||
tags := []githubTagResponse{}
|
||||
err := makeGithubRequest(url, &tags)
|
||||
|
||||
if err != nil {
|
||||
logger.Errorf("Github Tags Api %v", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
for _, tag := range tags {
|
||||
if tag.Name == name {
|
||||
if len(tag.Commit.Sha) != 40 {
|
||||
return ""
|
||||
}
|
||||
if shortHash {
|
||||
return tag.Commit.Sha[0:7] //shorthash is first 7 digits of git commit hash
|
||||
}
|
||||
|
||||
return tag.Commit.Sha
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/99designs/gqlgen/graphql"
|
||||
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
@@ -116,6 +116,21 @@ func (r *queryResolver) Version(ctx context.Context) (*models.Version, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
//Gets latest version (git shorthash commit for now)
|
||||
func (r *queryResolver) Latestversion(ctx context.Context) (*models.ShortVersion, error) {
|
||||
ver, url, err := GetLatestVersion(true)
|
||||
if err == nil {
|
||||
logger.Infof("Retrieved latest hash: %s", ver)
|
||||
} else {
|
||||
logger.Errorf("Error while retrieving latest hash: %s", err)
|
||||
}
|
||||
|
||||
return &models.ShortVersion{
|
||||
Shorthash: ver,
|
||||
URL: url,
|
||||
}, err
|
||||
}
|
||||
|
||||
// Get scene marker tags which show up under the video.
|
||||
func (r *queryResolver) SceneMarkerTags(ctx context.Context, scene_id string) ([]*models.SceneMarkerTag, error) {
|
||||
sceneID, _ := strconv.Atoi(scene_id)
|
||||
|
||||
@@ -163,10 +163,6 @@ func (r *mutationResolver) sceneUpdate(input models.SceneUpdateInput, tx *sqlx.T
|
||||
|
||||
// only update the cover image if provided and everything else was successful
|
||||
if coverImageData != nil {
|
||||
scene, err := qb.Find(sceneID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = manager.SetSceneScreenshot(scene.Checksum, coverImageData)
|
||||
if err != nil {
|
||||
@@ -422,3 +418,63 @@ func changeMarker(ctx context.Context, changeType int, changedMarker models.Scen
|
||||
|
||||
return sceneMarker, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) SceneIncrementO(ctx context.Context, id string) (int, error) {
|
||||
sceneID, _ := strconv.Atoi(id)
|
||||
|
||||
tx := database.DB.MustBeginTx(ctx, nil)
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
|
||||
newVal, err := qb.IncrementOCounter(sceneID, tx)
|
||||
if err != nil {
|
||||
_ = tx.Rollback()
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Commit
|
||||
if err := tx.Commit(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return newVal, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) SceneDecrementO(ctx context.Context, id string) (int, error) {
|
||||
sceneID, _ := strconv.Atoi(id)
|
||||
|
||||
tx := database.DB.MustBeginTx(ctx, nil)
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
|
||||
newVal, err := qb.DecrementOCounter(sceneID, tx)
|
||||
if err != nil {
|
||||
_ = tx.Rollback()
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Commit
|
||||
if err := tx.Commit(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return newVal, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) SceneResetO(ctx context.Context, id string) (int, error) {
|
||||
sceneID, _ := strconv.Atoi(id)
|
||||
|
||||
tx := database.DB.MustBeginTx(ctx, nil)
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
|
||||
newVal, err := qb.ResetOCounter(sceneID, tx)
|
||||
if err != nil {
|
||||
_ = tx.Rollback()
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Commit
|
||||
if err := tx.Commit(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return newVal, nil
|
||||
}
|
||||
|
||||
@@ -20,4 +20,4 @@ func (r *queryResolver) Logs(ctx context.Context) ([]*models.LogEntry, error) {
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,16 @@ func (rs galleryRoutes) File(w http.ResponseWriter, r *http.Request) {
|
||||
thumb := r.URL.Query().Get("thumb")
|
||||
w.Header().Add("Cache-Control", "max-age=604800000") // 1 Week
|
||||
if thumb == "true" {
|
||||
_, _ = w.Write(gallery.GetThumbnail(fileIndex))
|
||||
} else {
|
||||
_, _ = w.Write(gallery.GetThumbnail(fileIndex, 200))
|
||||
} else if thumb == "" {
|
||||
_, _ = w.Write(gallery.GetImage(fileIndex))
|
||||
} else {
|
||||
width, err := strconv.ParseInt(thumb, 0, 64)
|
||||
if err != nil {
|
||||
http.Error(w, http.StatusText(400), 400)
|
||||
return
|
||||
}
|
||||
_, _ = w.Write(gallery.GetThumbnail(fileIndex, int(width)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,13 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type performerRoutes struct{}
|
||||
@@ -23,6 +26,16 @@ func (rs performerRoutes) Routes() chi.Router {
|
||||
|
||||
func (rs performerRoutes) Image(w http.ResponseWriter, r *http.Request) {
|
||||
performer := r.Context().Value(performerKey).(*models.Performer)
|
||||
etag := fmt.Sprintf("%x", md5.Sum(performer.Image))
|
||||
|
||||
if match := r.Header.Get("If-None-Match"); match != "" {
|
||||
if strings.Contains(match, etag) {
|
||||
w.WriteHeader(http.StatusNotModified)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Add("Etag", etag)
|
||||
_, _ = w.Write(performer.Image)
|
||||
}
|
||||
|
||||
|
||||
@@ -196,6 +196,10 @@ func Start() {
|
||||
data, _ := uiBox.Find("index.html")
|
||||
_, _ = w.Write(data)
|
||||
} else {
|
||||
isStatic, _ := path.Match("/static/*/*", r.URL.Path)
|
||||
if isStatic {
|
||||
w.Header().Add("Cache-Control", "max-age=604800000")
|
||||
}
|
||||
http.FileServer(uiBox).ServeHTTP(w, r)
|
||||
}
|
||||
})
|
||||
@@ -216,6 +220,7 @@ func Start() {
|
||||
|
||||
go func() {
|
||||
printVersion()
|
||||
printLatestVersion()
|
||||
logger.Infof("stash is listening on " + address)
|
||||
logger.Infof("stash is running at https://" + displayAddress + "/")
|
||||
logger.Fatal(httpsServer.ListenAndServeTLS("", ""))
|
||||
@@ -228,6 +233,7 @@ func Start() {
|
||||
|
||||
go func() {
|
||||
printVersion()
|
||||
printLatestVersion()
|
||||
logger.Infof("stash is listening on " + address)
|
||||
logger.Infof("stash is running at http://" + displayAddress + "/")
|
||||
logger.Fatal(server.ListenAndServe())
|
||||
@@ -290,6 +296,11 @@ func BaseURLMiddleware(next http.Handler) http.Handler {
|
||||
}
|
||||
baseURL := scheme + "://" + r.Host
|
||||
|
||||
externalHost := config.GetExternalHost()
|
||||
if externalHost != "" {
|
||||
baseURL = externalHost
|
||||
}
|
||||
|
||||
r = r.WithContext(context.WithValue(ctx, BaseURLCtxKey, baseURL))
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
var DB *sqlx.DB
|
||||
var appSchemaVersion uint = 2
|
||||
var appSchemaVersion uint = 3
|
||||
|
||||
const sqlite3Driver = "sqlite3_regexp"
|
||||
|
||||
|
||||
1
pkg/database/migrations/3_o_counter.up.sql
Normal file
1
pkg/database/migrations/3_o_counter.up.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE `scenes` ADD COLUMN `o_counter` tinyint not null default 0;
|
||||
@@ -30,6 +30,7 @@ const MaxStreamingTranscodeSize = "max_streaming_transcode_size"
|
||||
|
||||
const Host = "host"
|
||||
const Port = "port"
|
||||
const ExternalHost = "external_host"
|
||||
|
||||
// Interface options
|
||||
const SoundOnPreview = "sound_on_preview"
|
||||
@@ -108,6 +109,10 @@ func GetPort() int {
|
||||
return viper.GetInt(Port)
|
||||
}
|
||||
|
||||
func GetExternalHost() string {
|
||||
return viper.GetString(ExternalHost)
|
||||
}
|
||||
|
||||
func GetMaxTranscodeSize() models.StreamingResolutionEnum {
|
||||
ret := viper.GetString(MaxTranscodeSize)
|
||||
|
||||
|
||||
@@ -335,9 +335,15 @@ func (h *sceneHolder) postParse() {
|
||||
}
|
||||
|
||||
func (m parseMapper) parse(scene *models.Scene) *sceneHolder {
|
||||
// perform matching on basename
|
||||
// TODO - may want to handle full path at some point
|
||||
|
||||
// #302 - if the pattern includes a path separator, then include the entire
|
||||
// scene path in the match. Otherwise, use the default behaviour of just
|
||||
// the file's basename
|
||||
// must be double \ because of the regex escaping
|
||||
filename := filepath.Base(scene.Path)
|
||||
if strings.Contains(m.regexString, `\\`) || strings.Contains(m.regexString, "/") {
|
||||
filename = scene.Path
|
||||
}
|
||||
|
||||
result := m.regex.FindStringSubmatch(filename)
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ var once sync.Once
|
||||
type flagStruct struct {
|
||||
configFilePath string
|
||||
}
|
||||
|
||||
var flags = flagStruct{}
|
||||
|
||||
func GetInstance() *singleton {
|
||||
@@ -109,13 +110,14 @@ func initFlags() {
|
||||
}
|
||||
|
||||
func initEnvs() {
|
||||
viper.SetEnvPrefix("stash") // will be uppercased automatically
|
||||
viper.BindEnv("host") // STASH_HOST
|
||||
viper.BindEnv("port") // STASH_PORT
|
||||
viper.BindEnv("stash") // STASH_STASH
|
||||
viper.BindEnv("generated") // STASH_GENERATED
|
||||
viper.BindEnv("metadata") // STASH_METADATA
|
||||
viper.BindEnv("cache") // STASH_CACHE
|
||||
viper.SetEnvPrefix("stash") // will be uppercased automatically
|
||||
viper.BindEnv("host") // STASH_HOST
|
||||
viper.BindEnv("port") // STASH_PORT
|
||||
viper.BindEnv("external_host") // STASH_EXTERNAL_HOST
|
||||
viper.BindEnv("stash") // STASH_STASH
|
||||
viper.BindEnv("generated") // STASH_GENERATED
|
||||
viper.BindEnv("metadata") // STASH_METADATA
|
||||
viper.BindEnv("cache") // STASH_CACHE
|
||||
}
|
||||
|
||||
func initFFMPEG() {
|
||||
|
||||
@@ -165,8 +165,12 @@ func (s *singleton) Generate(sprites bool, previews bool, markers bool, transcod
|
||||
return
|
||||
}
|
||||
totalsNeeded := s.neededGenerate(scenes, sprites, previews, markers, transcodes)
|
||||
logger.Infof("Generating %d sprites %d previews %d markers %d transcodes", totalsNeeded.sprites, totalsNeeded.previews, totalsNeeded.markers, totalsNeeded.transcodes)
|
||||
|
||||
if totalsNeeded == nil {
|
||||
logger.Infof("Taking too long to count content. Skipping...")
|
||||
logger.Infof("Generating content")
|
||||
} else {
|
||||
logger.Infof("Generating %d sprites %d previews %d markers %d transcodes", totalsNeeded.sprites, totalsNeeded.previews, totalsNeeded.markers, totalsNeeded.transcodes)
|
||||
}
|
||||
for i, scene := range scenes {
|
||||
s.Status.setProgress(i, total)
|
||||
if s.Status.stopping {
|
||||
@@ -208,6 +212,7 @@ func (s *singleton) Generate(sprites bool, previews bool, markers bool, transcod
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
logger.Infof("Generate finished")
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -461,6 +466,18 @@ type totalsGenerate struct {
|
||||
func (s *singleton) neededGenerate(scenes []*models.Scene, sprites, previews, markers, transcodes bool) *totalsGenerate {
|
||||
|
||||
var totals totalsGenerate
|
||||
const timeoutSecs = 90 * time.Second
|
||||
|
||||
// create a control channel through which to signal the counting loop when the timeout is reached
|
||||
chTimeout := make(chan struct{})
|
||||
|
||||
//run the timeout function in a separate thread
|
||||
go func() {
|
||||
time.Sleep(timeoutSecs)
|
||||
chTimeout <- struct{}{}
|
||||
}()
|
||||
|
||||
logger.Infof("Counting content to generate...")
|
||||
for _, scene := range scenes {
|
||||
if scene != nil {
|
||||
if sprites {
|
||||
@@ -489,6 +506,13 @@ func (s *singleton) neededGenerate(scenes []*models.Scene, sprites, previews, ma
|
||||
}
|
||||
}
|
||||
}
|
||||
//check for timeout
|
||||
select {
|
||||
case <-chTimeout:
|
||||
return nil
|
||||
default:
|
||||
}
|
||||
|
||||
}
|
||||
return &totals
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
streamingFiles = make(map[string][]*http.ResponseWriter)
|
||||
streamingFiles = make(map[string][]*http.ResponseWriter)
|
||||
streamingFilesMutex = sync.RWMutex{}
|
||||
)
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
|
||||
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
)
|
||||
|
||||
func DestroyScene(sceneID int, tx *sqlx.Tx) (error) {
|
||||
func DestroyScene(sceneID int, tx *sqlx.Tx) error {
|
||||
qb := models.NewSceneQueryBuilder()
|
||||
jqb := models.NewJoinsQueryBuilder()
|
||||
|
||||
|
||||
_, err := qb.Find(sceneID)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -40,7 +40,7 @@ func DestroyScene(sceneID int, tx *sqlx.Tx) (error) {
|
||||
if err := qb.Destroy(strconv.Itoa(sceneID), tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -130,4 +130,4 @@ func DeleteSceneFile(scene *models.Scene) {
|
||||
if err != nil {
|
||||
logger.Warnf("Could not delete file %s: %s", scene.Path, err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,8 @@ func (t *AutoTagStudioTask) autoTagStudio() {
|
||||
tx := database.DB.MustBeginTx(ctx, nil)
|
||||
|
||||
for _, scene := range scenes {
|
||||
if scene.StudioID.Int64 == int64(t.studio.ID) {
|
||||
// #306 - don't overwrite studio if already present
|
||||
if scene.StudioID.Valid {
|
||||
// don't modify
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -23,6 +23,11 @@ import (
|
||||
|
||||
const testName = "Foo's Bar"
|
||||
const testExtension = ".mp4"
|
||||
const existingStudioName = "ExistingStudio"
|
||||
|
||||
const existingStudioSceneName = testName + ".dontChangeStudio" + testExtension
|
||||
|
||||
var existingStudioID int
|
||||
|
||||
var testSeparators = []string{
|
||||
".",
|
||||
@@ -112,22 +117,17 @@ func createPerformer(tx *sqlx.Tx) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func createStudio(tx *sqlx.Tx) error {
|
||||
func createStudio(tx *sqlx.Tx, name string) (*models.Studio, error) {
|
||||
// create the studio
|
||||
qb := models.NewStudioQueryBuilder()
|
||||
|
||||
studio := models.Studio{
|
||||
Image: []byte{0, 1, 2},
|
||||
Checksum: testName,
|
||||
Checksum: name,
|
||||
Name: sql.NullString{Valid: true, String: testName},
|
||||
}
|
||||
|
||||
_, err := qb.Create(studio, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return qb.Create(studio, tx)
|
||||
}
|
||||
|
||||
func createTag(tx *sqlx.Tx) error {
|
||||
@@ -162,23 +162,31 @@ func createScenes(tx *sqlx.Tx) error {
|
||||
}
|
||||
|
||||
for _, fn := range scenePatterns {
|
||||
err := createScene(sqb, tx, fn, true)
|
||||
err := createScene(sqb, tx, makeScene(fn, true))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for _, fn := range falseScenePatterns {
|
||||
err := createScene(sqb, tx, fn, false)
|
||||
err := createScene(sqb, tx, makeScene(fn, false))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// create scene with existing studio io
|
||||
studioScene := makeScene(existingStudioSceneName, true)
|
||||
studioScene.StudioID = sql.NullInt64{Valid: true, Int64: int64(existingStudioID)}
|
||||
err := createScene(sqb, tx, studioScene)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func createScene(sqb models.SceneQueryBuilder, tx *sqlx.Tx, name string, expectedResult bool) error {
|
||||
scene := models.Scene{
|
||||
func makeScene(name string, expectedResult bool) *models.Scene {
|
||||
scene := &models.Scene{
|
||||
Checksum: utils.MD5FromString(name),
|
||||
Path: name,
|
||||
}
|
||||
@@ -188,10 +196,14 @@ func createScene(sqb models.SceneQueryBuilder, tx *sqlx.Tx, name string, expecte
|
||||
scene.Title = sql.NullString{Valid: true, String: name}
|
||||
}
|
||||
|
||||
_, err := sqb.Create(scene, tx)
|
||||
return scene
|
||||
}
|
||||
|
||||
func createScene(sqb models.SceneQueryBuilder, tx *sqlx.Tx, scene *models.Scene) error {
|
||||
_, err := sqb.Create(*scene, tx)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to create scene with name '%s': %s", name, err.Error())
|
||||
return fmt.Errorf("Failed to create scene with name '%s': %s", scene.Path, err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -206,11 +218,19 @@ func populateDB() error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = createStudio(tx)
|
||||
_, err = createStudio(tx, testName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// create existing studio
|
||||
existingStudio, err := createStudio(tx, existingStudioName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
existingStudioID = existingStudio.ID
|
||||
|
||||
err = createTag(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -290,11 +310,18 @@ func TestParseStudios(t *testing.T) {
|
||||
scenes, err := sqb.All()
|
||||
|
||||
for _, scene := range scenes {
|
||||
// title is only set on scenes where we expect studio to be set
|
||||
if scene.Title.String == scene.Path && scene.StudioID.Int64 != int64(studios[0].ID) {
|
||||
t.Errorf("Did not set studio '%s' for path '%s'", testName, scene.Path)
|
||||
} else if scene.Title.String != scene.Path && scene.StudioID.Int64 == int64(studios[0].ID) {
|
||||
t.Errorf("Incorrectly set studio '%s' for path '%s'", testName, scene.Path)
|
||||
// check for existing studio id scene first
|
||||
if scene.Path == existingStudioSceneName {
|
||||
if scene.StudioID.Int64 != int64(existingStudioID) {
|
||||
t.Error("Incorrectly overwrote studio ID for scene with existing studio ID")
|
||||
}
|
||||
} else {
|
||||
// title is only set on scenes where we expect studio to be set
|
||||
if scene.Title.String == scene.Path && scene.StudioID.Int64 != int64(studios[0].ID) {
|
||||
t.Errorf("Did not set studio '%s' for path '%s'", testName, scene.Path)
|
||||
} else if scene.Title.String != scene.Path && scene.StudioID.Int64 == int64(studios[0].ID) {
|
||||
t.Errorf("Incorrectly set studio '%s' for path '%s'", testName, scene.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ func (g *Gallery) GetImage(index int) []byte {
|
||||
return data
|
||||
}
|
||||
|
||||
func (g *Gallery) GetThumbnail(index int) []byte {
|
||||
func (g *Gallery) GetThumbnail(index int, width int) []byte {
|
||||
data, _ := g.readZipFile(index)
|
||||
srcImage, _, err := image.Decode(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
return data
|
||||
}
|
||||
resizedImage := imaging.Resize(srcImage, 100, 0, imaging.NearestNeighbor)
|
||||
resizedImage := imaging.Resize(srcImage, width, 0, imaging.Box)
|
||||
buf := new(bytes.Buffer)
|
||||
err = jpeg.Encode(buf, resizedImage, nil)
|
||||
if err != nil {
|
||||
|
||||
@@ -15,6 +15,7 @@ type Scene struct {
|
||||
URL sql.NullString `db:"url" json:"url"`
|
||||
Date SQLiteDate `db:"date" json:"date"`
|
||||
Rating sql.NullInt64 `db:"rating" json:"rating"`
|
||||
OCounter int `db:"o_counter" json:"o_counter"`
|
||||
Size sql.NullString `db:"size" json:"size"`
|
||||
Duration sql.NullFloat64 `db:"duration" json:"duration"`
|
||||
VideoCodec sql.NullString `db:"video_codec" json:"video_codec"`
|
||||
|
||||
@@ -76,6 +76,60 @@ func (qb *SceneQueryBuilder) Update(updatedScene ScenePartial, tx *sqlx.Tx) (*Sc
|
||||
return qb.find(updatedScene.ID, tx)
|
||||
}
|
||||
|
||||
func (qb *SceneQueryBuilder) IncrementOCounter(id int, tx *sqlx.Tx) (int, error) {
|
||||
ensureTx(tx)
|
||||
_, err := tx.Exec(
|
||||
`UPDATE scenes SET o_counter = o_counter + 1 WHERE scenes.id = ?`,
|
||||
id,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
scene, err := qb.find(id, tx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return scene.OCounter, nil
|
||||
}
|
||||
|
||||
func (qb *SceneQueryBuilder) DecrementOCounter(id int, tx *sqlx.Tx) (int, error) {
|
||||
ensureTx(tx)
|
||||
_, err := tx.Exec(
|
||||
`UPDATE scenes SET o_counter = o_counter - 1 WHERE scenes.id = ? and scenes.o_counter > 0`,
|
||||
id,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
scene, err := qb.find(id, tx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return scene.OCounter, nil
|
||||
}
|
||||
|
||||
func (qb *SceneQueryBuilder) ResetOCounter(id int, tx *sqlx.Tx) (int, error) {
|
||||
ensureTx(tx)
|
||||
_, err := tx.Exec(
|
||||
`UPDATE scenes SET o_counter = 0 WHERE scenes.id = ?`,
|
||||
id,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
scene, err := qb.find(id, tx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return scene.OCounter, nil
|
||||
}
|
||||
|
||||
func (qb *SceneQueryBuilder) Destroy(id string, tx *sqlx.Tx) error {
|
||||
return executeDeleteQuery("scenes", id, tx)
|
||||
}
|
||||
@@ -171,13 +225,27 @@ func (qb *SceneQueryBuilder) Query(sceneFilter *SceneFilterType, findFilter *Fin
|
||||
}
|
||||
|
||||
if rating := sceneFilter.Rating; rating != nil {
|
||||
clause, count := getIntCriterionWhereClause("rating", *sceneFilter.Rating)
|
||||
clause, count := getIntCriterionWhereClause("scenes.rating", *sceneFilter.Rating)
|
||||
whereClauses = append(whereClauses, clause)
|
||||
if count == 1 {
|
||||
args = append(args, sceneFilter.Rating.Value)
|
||||
}
|
||||
}
|
||||
|
||||
if oCounter := sceneFilter.OCounter; oCounter != nil {
|
||||
clause, count := getIntCriterionWhereClause("scenes.o_counter", *sceneFilter.OCounter)
|
||||
whereClauses = append(whereClauses, clause)
|
||||
if count == 1 {
|
||||
args = append(args, sceneFilter.OCounter.Value)
|
||||
}
|
||||
}
|
||||
|
||||
if durationFilter := sceneFilter.Duration; durationFilter != nil {
|
||||
clause, thisArgs := getDurationWhereClause(*durationFilter)
|
||||
whereClauses = append(whereClauses, clause)
|
||||
args = append(args, thisArgs...)
|
||||
}
|
||||
|
||||
if resolutionFilter := sceneFilter.Resolution; resolutionFilter != nil {
|
||||
if resolution := resolutionFilter.String(); resolutionFilter.IsValid() {
|
||||
switch resolution {
|
||||
@@ -270,6 +338,34 @@ func appendClause(clauses []string, clause string) []string {
|
||||
return clauses
|
||||
}
|
||||
|
||||
func getDurationWhereClause(durationFilter IntCriterionInput) (string, []interface{}) {
|
||||
// special case for duration. We accept duration as seconds as int but the
|
||||
// field is floating point. Change the equals filter to return a range
|
||||
// between x and x + 1
|
||||
// likewise, not equals needs to be duration < x OR duration >= x
|
||||
var clause string
|
||||
args := []interface{}{}
|
||||
|
||||
value := durationFilter.Value
|
||||
if durationFilter.Modifier == CriterionModifierEquals {
|
||||
clause = "scenes.duration >= ? AND scenes.duration < ?"
|
||||
args = append(args, value)
|
||||
args = append(args, value+1)
|
||||
} else if durationFilter.Modifier == CriterionModifierNotEquals {
|
||||
clause = "(scenes.duration < ? OR scenes.duration >= ?)"
|
||||
args = append(args, value)
|
||||
args = append(args, value+1)
|
||||
} else {
|
||||
var count int
|
||||
clause, count = getIntCriterionWhereClause("scenes.duration", durationFilter)
|
||||
if count == 1 {
|
||||
args = append(args, value)
|
||||
}
|
||||
}
|
||||
|
||||
return clause, args
|
||||
}
|
||||
|
||||
// returns where clause and having clause
|
||||
func getMultiCriterionClause(table string, joinTable string, joinTableField string, criterion *MultiCriterionInput) (string, string) {
|
||||
whereClause := ""
|
||||
|
||||
@@ -162,8 +162,8 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp
|
||||
havingClauses = append(havingClauses, "((COUNT(DISTINCT ptj.id) + COUNT(DISTINCT tj.tag_id)) >= "+strconv.Itoa(requiredCount)+")")
|
||||
} else if tagsFilter.Modifier == CriterionModifierExcludes {
|
||||
// excludes all of the provided ids
|
||||
whereClauses = append(whereClauses, "scene_markers.primary_tag_id not in " + getInBinding(length))
|
||||
whereClauses = append(whereClauses, "not exists (select smt.scene_marker_id from scene_markers_tags as smt where smt.scene_marker_id = scene_markers.id and smt.tag_id in " + getInBinding(length) + ")")
|
||||
whereClauses = append(whereClauses, "scene_markers.primary_tag_id not in "+getInBinding(length))
|
||||
whereClauses = append(whereClauses, "not exists (select smt.scene_marker_id from scene_markers_tags as smt where smt.scene_marker_id = scene_markers.id and smt.tag_id in "+getInBinding(length)+")")
|
||||
}
|
||||
|
||||
for _, tagID := range tagsFilter.Value {
|
||||
@@ -176,7 +176,7 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp
|
||||
|
||||
if sceneTagsFilter := sceneMarkerFilter.SceneTags; sceneTagsFilter != nil && len(sceneTagsFilter.Value) > 0 {
|
||||
length := len(sceneTagsFilter.Value)
|
||||
|
||||
|
||||
if sceneTagsFilter.Modifier == CriterionModifierIncludes || sceneTagsFilter.Modifier == CriterionModifierIncludesAll {
|
||||
body += " LEFT JOIN scenes_tags AS scene_tags_join ON scene_tags_join.scene_id = scene.id AND scene_tags_join.tag_id IN " + getInBinding(length)
|
||||
|
||||
@@ -191,9 +191,9 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp
|
||||
havingClauses = append(havingClauses, "COUNT(DISTINCT scene_tags_join.tag_id) >= "+strconv.Itoa(requiredCount))
|
||||
} else if sceneTagsFilter.Modifier == CriterionModifierExcludes {
|
||||
// excludes all of the provided ids
|
||||
whereClauses = append(whereClauses, "not exists (select st.scene_id from scenes_tags as st where st.scene_id = scene.id AND st.tag_id IN " + getInBinding(length) + ")")
|
||||
whereClauses = append(whereClauses, "not exists (select st.scene_id from scenes_tags as st where st.scene_id = scene.id AND st.tag_id IN "+getInBinding(length)+")")
|
||||
}
|
||||
|
||||
|
||||
for _, tagID := range sceneTagsFilter.Value {
|
||||
args = append(args, tagID)
|
||||
}
|
||||
@@ -213,13 +213,13 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp
|
||||
if performersFilter.Modifier == CriterionModifierIncludesAll {
|
||||
requiredCount = length
|
||||
}
|
||||
|
||||
|
||||
havingClauses = append(havingClauses, "COUNT(DISTINCT scene_performers.performer_id) >= "+strconv.Itoa(requiredCount))
|
||||
} else if performersFilter.Modifier == CriterionModifierExcludes {
|
||||
// excludes all of the provided ids
|
||||
whereClauses = append(whereClauses, "not exists (select sp.scene_id from performers_scenes as sp where sp.scene_id = scene.id AND sp.performer_id IN " + getInBinding(length) + ")")
|
||||
whereClauses = append(whereClauses, "not exists (select sp.scene_id from performers_scenes as sp where sp.scene_id = scene.id AND sp.performer_id IN "+getInBinding(length)+")")
|
||||
}
|
||||
|
||||
|
||||
for _, performerID := range performersFilter.Value {
|
||||
args = append(args, performerID)
|
||||
}
|
||||
|
||||
@@ -93,19 +93,27 @@ func getSort(sort string, direction string, tableName string) string {
|
||||
direction = "ASC"
|
||||
}
|
||||
|
||||
if strings.Contains(sort, "_count") {
|
||||
const randomSeedPrefix = "random_"
|
||||
|
||||
if strings.HasSuffix(sort, "_count") {
|
||||
var relationTableName = strings.Split(sort, "_")[0] // TODO: pluralize?
|
||||
colName := getColumn(relationTableName, "id")
|
||||
return " ORDER BY COUNT(distinct " + colName + ") " + direction
|
||||
} else if strings.Compare(sort, "filesize") == 0 {
|
||||
colName := getColumn(tableName, "size")
|
||||
return " ORDER BY cast(" + colName + " as integer) " + direction
|
||||
} else if strings.HasPrefix(sort, randomSeedPrefix) {
|
||||
// seed as a parameter from the UI
|
||||
// turn the provided seed into a float
|
||||
seedStr := "0." + sort[len(randomSeedPrefix):]
|
||||
seed, err := strconv.ParseFloat(seedStr, 32)
|
||||
if err != nil {
|
||||
// fallback to default seed
|
||||
seed = randomSortFloat
|
||||
}
|
||||
return getRandomSort(tableName, direction, seed)
|
||||
} else if strings.Compare(sort, "random") == 0 {
|
||||
// https://stackoverflow.com/a/24511461
|
||||
// TODO seed as a parameter from the UI
|
||||
colName := getColumn(tableName, "id")
|
||||
randomSortString := strconv.FormatFloat(randomSortFloat, 'f', 16, 32)
|
||||
return " ORDER BY " + "(substr(" + colName + " * " + randomSortString + ", length(" + colName + ") + 2))" + " " + direction
|
||||
return getRandomSort(tableName, direction, randomSortFloat)
|
||||
} else {
|
||||
colName := getColumn(tableName, sort)
|
||||
var additional string
|
||||
@@ -122,6 +130,13 @@ func getSort(sort string, direction string, tableName string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func getRandomSort(tableName string, direction string, seed float64) string {
|
||||
// https://stackoverflow.com/a/24511461
|
||||
colName := getColumn(tableName, "id")
|
||||
randomSortString := strconv.FormatFloat(seed, 'f', 16, 32)
|
||||
return " ORDER BY " + "(substr(" + colName + " * " + randomSortString + ", length(" + colName + ") + 2))" + " " + direction
|
||||
}
|
||||
|
||||
func getSearch(columns []string, q string) string {
|
||||
// TODO - susceptible to SQL injection
|
||||
var likeClauses []string
|
||||
|
||||
@@ -41,6 +41,9 @@ type scraperTypeConfig struct {
|
||||
Script []string `yaml:"script,flow"`
|
||||
Scraper string `yaml:"scraper"`
|
||||
|
||||
// for xpath name scraper only
|
||||
QueryURL string `yaml:"queryURL"`
|
||||
|
||||
scraperConfig *scraperConfig
|
||||
}
|
||||
|
||||
@@ -56,6 +59,8 @@ func (c *performerByNameConfig) resolveFn() {
|
||||
c.performScrape = scrapePerformerNamesScript
|
||||
} else if c.Action == scraperActionStash {
|
||||
c.performScrape = scrapePerformerNamesStash
|
||||
} else if c.Action == scraperActionXPath {
|
||||
c.performScrape = scrapePerformerNamesXPath
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,6 +271,11 @@ func (c scraperConfig) ScrapePerformer(scrapedPerformer models.ScrapedPerformerI
|
||||
return c.PerformerByFragment.performScrape(c.PerformerByFragment.scraperTypeConfig, scrapedPerformer)
|
||||
}
|
||||
|
||||
// try to match against URL if present
|
||||
if scrapedPerformer.URL != nil && *scrapedPerformer.URL != "" {
|
||||
return c.ScrapePerformerURL(*scrapedPerformer.URL)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@ package scraper
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/antchfx/htmlquery"
|
||||
"golang.org/x/net/html"
|
||||
@@ -43,30 +45,209 @@ func createXPathScraperConfig(src map[interface{}]interface{}) xpathScraperConfi
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s xpathScraperConfig) process(doc *html.Node, common commonXPathConfig) []xPathResult {
|
||||
var ret []xPathResult
|
||||
type xpathRegexConfig map[interface{}]interface{}
|
||||
type xpathRegexConfigs []xpathRegexConfig
|
||||
|
||||
for k, v := range s {
|
||||
asStr, isStr := v.(string)
|
||||
func (c xpathRegexConfig) apply(value string) string {
|
||||
regex := ""
|
||||
with := ""
|
||||
|
||||
if isStr {
|
||||
// apply common
|
||||
if common != nil {
|
||||
asStr = common.applyCommon(asStr)
|
||||
}
|
||||
if regexI, _ := c["regex"]; regexI != nil {
|
||||
regex, _ = regexI.(string)
|
||||
}
|
||||
if withI, _ := c["with"]; withI != nil {
|
||||
with, _ = withI.(string)
|
||||
}
|
||||
|
||||
if regex != "" {
|
||||
re, err := regexp.Compile(regex)
|
||||
if err != nil {
|
||||
logger.Warnf("Error compiling regex '%s': %s", regex, err.Error())
|
||||
return value
|
||||
}
|
||||
|
||||
return re.ReplaceAllString(value, with)
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func (c xpathRegexConfigs) apply(value string) string {
|
||||
// apply regex in order
|
||||
for _, config := range c {
|
||||
value = config.apply(value)
|
||||
}
|
||||
|
||||
// remove whitespace again
|
||||
value = commonPostProcess(value)
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
type xpathScraperAttrConfig map[interface{}]interface{}
|
||||
|
||||
func (c xpathScraperAttrConfig) getString(key string) string {
|
||||
ret, _ := c[key]
|
||||
|
||||
if ret == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
asStr, _ := ret.(string)
|
||||
return asStr
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) getSelector() string {
|
||||
const selectorKey = "selector"
|
||||
return c.getString(selectorKey)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) getConcat() string {
|
||||
const concatKey = "concat"
|
||||
return c.getString(concatKey)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) hasConcat() bool {
|
||||
return c.getConcat() != ""
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) getParseDate() string {
|
||||
const parseDateKey = "parseDate"
|
||||
return c.getString(parseDateKey)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) getReplace() xpathRegexConfigs {
|
||||
const replaceKey = "replace"
|
||||
val, _ := c[replaceKey]
|
||||
|
||||
var ret xpathRegexConfigs
|
||||
if val == nil {
|
||||
return ret
|
||||
}
|
||||
|
||||
asSlice, _ := val.([]interface{})
|
||||
|
||||
for _, v := range asSlice {
|
||||
asMap, _ := v.(map[interface{}]interface{})
|
||||
ret = append(ret, xpathRegexConfig(asMap))
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) concatenateResults(nodes []*html.Node) string {
|
||||
separator := c.getConcat()
|
||||
result := []string{}
|
||||
|
||||
for _, elem := range nodes {
|
||||
text := htmlquery.InnerText(elem)
|
||||
text = commonPostProcess(text)
|
||||
|
||||
result = append(result, text)
|
||||
}
|
||||
|
||||
return strings.Join(result, separator)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) parseDate(value string) string {
|
||||
parseDate := c.getParseDate()
|
||||
|
||||
if parseDate == "" {
|
||||
return value
|
||||
}
|
||||
|
||||
// try to parse the date using the pattern
|
||||
// if it fails, then just fall back to the original value
|
||||
parsedValue, err := time.Parse(parseDate, value)
|
||||
if err != nil {
|
||||
logger.Warnf("Error parsing date string '%s' using format '%s': %s", value, parseDate, err.Error())
|
||||
return value
|
||||
}
|
||||
|
||||
// convert it into our date format
|
||||
const internalDateFormat = "2006-01-02"
|
||||
return parsedValue.Format(internalDateFormat)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) replaceRegex(value string) string {
|
||||
replace := c.getReplace()
|
||||
return replace.apply(value)
|
||||
}
|
||||
|
||||
func (c xpathScraperAttrConfig) postProcess(value string) string {
|
||||
// perform regex replacements first
|
||||
value = c.replaceRegex(value)
|
||||
value = c.parseDate(value)
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func commonPostProcess(value string) string {
|
||||
value = strings.TrimSpace(value)
|
||||
|
||||
// remove multiple whitespace and end lines
|
||||
re := regexp.MustCompile("\n")
|
||||
value = re.ReplaceAllString(value, "")
|
||||
re = regexp.MustCompile(" +")
|
||||
value = re.ReplaceAllString(value, " ")
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
func runXPathQuery(doc *html.Node, xpath string, common commonXPathConfig) []*html.Node {
|
||||
// apply common
|
||||
if common != nil {
|
||||
xpath = common.applyCommon(xpath)
|
||||
}
|
||||
|
||||
found, err := htmlquery.QueryAll(doc, xpath)
|
||||
if err != nil {
|
||||
logger.Warnf("Error parsing xpath expression '%s': %s", xpath, err.Error())
|
||||
return nil
|
||||
}
|
||||
|
||||
return found
|
||||
}
|
||||
|
||||
func (s xpathScraperConfig) process(doc *html.Node, common commonXPathConfig) xPathResults {
|
||||
var ret xPathResults
|
||||
|
||||
for k, value := range s {
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
found := runXPathQuery(doc, v, common)
|
||||
|
||||
found := htmlquery.Find(doc, asStr)
|
||||
if len(found) > 0 {
|
||||
for i, elem := range found {
|
||||
if i >= len(ret) {
|
||||
ret = append(ret, make(xPathResult))
|
||||
}
|
||||
text := htmlquery.InnerText(elem)
|
||||
text = commonPostProcess(text)
|
||||
|
||||
ret[i][k] = elem
|
||||
ret = ret.setKey(i, k, text)
|
||||
}
|
||||
}
|
||||
case map[interface{}]interface{}:
|
||||
attrConfig := xpathScraperAttrConfig(v)
|
||||
|
||||
found := runXPathQuery(doc, attrConfig.getSelector(), common)
|
||||
|
||||
if len(found) > 0 {
|
||||
// check if we're concatenating the results into a single result
|
||||
if attrConfig.hasConcat() {
|
||||
result := attrConfig.concatenateResults(found)
|
||||
result = attrConfig.postProcess(result)
|
||||
const i = 0
|
||||
ret = ret.setKey(i, k, result)
|
||||
} else {
|
||||
for i, elem := range found {
|
||||
text := htmlquery.InnerText(elem)
|
||||
text = commonPostProcess(text)
|
||||
text = attrConfig.postProcess(text)
|
||||
|
||||
ret = ret.setKey(i, k, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO - handle map type
|
||||
}
|
||||
|
||||
return ret
|
||||
@@ -148,6 +329,24 @@ func (s xpathScraper) scrapePerformer(doc *html.Node) (*models.ScrapedPerformer,
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s xpathScraper) scrapePerformers(doc *html.Node) ([]*models.ScrapedPerformer, error) {
|
||||
var ret []*models.ScrapedPerformer
|
||||
|
||||
performerMap := s.Performer
|
||||
if performerMap == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
results := performerMap.process(doc, s.Common)
|
||||
for _, r := range results {
|
||||
var p models.ScrapedPerformer
|
||||
r.apply(&p)
|
||||
ret = append(ret, &p)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (s xpathScraper) scrapeScene(doc *html.Node) (*models.ScrapedScene, error) {
|
||||
var ret models.ScrapedScene
|
||||
|
||||
@@ -199,7 +398,8 @@ func (s xpathScraper) scrapeScene(doc *html.Node) (*models.ScrapedScene, error)
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
type xPathResult map[string]*html.Node
|
||||
type xPathResult map[string]string
|
||||
type xPathResults []xPathResult
|
||||
|
||||
func (r xPathResult) apply(dest interface{}) {
|
||||
destVal := reflect.ValueOf(dest)
|
||||
@@ -207,22 +407,16 @@ func (r xPathResult) apply(dest interface{}) {
|
||||
// dest should be a pointer
|
||||
destVal = destVal.Elem()
|
||||
|
||||
for key, v := range r {
|
||||
for key, value := range r {
|
||||
field := destVal.FieldByName(key)
|
||||
|
||||
if field.IsValid() {
|
||||
value := htmlquery.InnerText(v)
|
||||
value = strings.TrimSpace(value)
|
||||
|
||||
// remove multiple whitespace and end lines
|
||||
re := regexp.MustCompile("\n")
|
||||
value = re.ReplaceAllString(value, "")
|
||||
re = regexp.MustCompile(" +")
|
||||
value = re.ReplaceAllString(value, " ")
|
||||
|
||||
var reflectValue reflect.Value
|
||||
if field.Kind() == reflect.Ptr {
|
||||
reflectValue = reflect.ValueOf(&value)
|
||||
// need to copy the value, otherwise everything is set to the
|
||||
// same pointer
|
||||
localValue := value
|
||||
reflectValue = reflect.ValueOf(&localValue)
|
||||
} else {
|
||||
reflectValue = reflect.ValueOf(value)
|
||||
}
|
||||
@@ -234,6 +428,15 @@ func (r xPathResult) apply(dest interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (r xPathResults) setKey(index int, key string, value string) xPathResults {
|
||||
if index >= len(r) {
|
||||
r = append(r, make(xPathResult))
|
||||
}
|
||||
|
||||
r[index][key] = value
|
||||
return r
|
||||
}
|
||||
|
||||
func scrapePerformerURLXpath(c scraperTypeConfig, url string) (*models.ScrapedPerformer, error) {
|
||||
scraper := c.scraperConfig.XPathScrapers[c.Scraper]
|
||||
|
||||
@@ -265,3 +468,27 @@ func scrapeSceneURLXPath(c scraperTypeConfig, url string) (*models.ScrapedScene,
|
||||
|
||||
return scraper.scrapeScene(doc)
|
||||
}
|
||||
|
||||
func scrapePerformerNamesXPath(c scraperTypeConfig, name string) ([]*models.ScrapedPerformer, error) {
|
||||
scraper := c.scraperConfig.XPathScrapers[c.Scraper]
|
||||
|
||||
if scraper == nil {
|
||||
return nil, errors.New("xpath scraper with name " + c.Scraper + " not found in config")
|
||||
}
|
||||
|
||||
const placeholder = "{}"
|
||||
|
||||
// replace the placeholder string with the URL-escaped name
|
||||
escapedName := url.QueryEscape(name)
|
||||
|
||||
u := c.QueryURL
|
||||
u = strings.Replace(u, placeholder, escapedName, -1)
|
||||
|
||||
doc, err := htmlquery.LoadURL(u)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return scraper.scrapePerformers(doc)
|
||||
}
|
||||
|
||||
@@ -183,23 +183,50 @@ func makeCommonXPath(attr string) string {
|
||||
return `//table[@id="biographyTable"]//tr/td[@class="paramname"]//b[text() = '` + attr + `']/ancestor::tr/td[@class="paramvalue"]`
|
||||
}
|
||||
|
||||
func makeReplaceRegex(regex string, with string) map[interface{}]interface{} {
|
||||
ret := make(map[interface{}]interface{})
|
||||
|
||||
ret["regex"] = regex
|
||||
ret["with"] = with
|
||||
return ret
|
||||
}
|
||||
|
||||
func makeXPathConfig() xpathScraperConfig {
|
||||
config := make(xpathScraperConfig)
|
||||
|
||||
config["Name"] = makeCommonXPath("Babe Name:") + `/a`
|
||||
config["Ethnicity"] = makeCommonXPath("Ethnicity:")
|
||||
config["Country"] = makeCommonXPath("Country of Origin:")
|
||||
config["Birthdate"] = makeCommonXPath("Date of Birth:")
|
||||
config["Aliases"] = makeCommonXPath("Aliases:")
|
||||
config["EyeColor"] = makeCommonXPath("Eye Color:")
|
||||
config["Measurements"] = makeCommonXPath("Measurements:")
|
||||
config["FakeTits"] = makeCommonXPath("Fake boobs:")
|
||||
config["Height"] = makeCommonXPath("Height:")
|
||||
// no colon in attribute header
|
||||
config["CareerLength"] = makeCommonXPath("Career Start And End")
|
||||
config["Tattoos"] = makeCommonXPath("Tattoos:")
|
||||
config["Piercings"] = makeCommonXPath("Piercings:")
|
||||
|
||||
// special handling for birthdate
|
||||
birthdateAttrConfig := make(map[interface{}]interface{})
|
||||
birthdateAttrConfig["selector"] = makeCommonXPath("Date of Birth:")
|
||||
|
||||
var birthdateReplace []interface{}
|
||||
birthdateReplace = append(birthdateReplace, makeReplaceRegex(` \(.* years old\)`, ""))
|
||||
|
||||
birthdateAttrConfig["replace"] = birthdateReplace
|
||||
birthdateAttrConfig["parseDate"] = "January 2, 2006" // "July 1, 1992 (27 years old) "
|
||||
config["Birthdate"] = birthdateAttrConfig
|
||||
|
||||
// special handling for career length
|
||||
careerLengthAttrConfig := make(map[interface{}]interface{})
|
||||
// no colon in attribute header
|
||||
careerLengthAttrConfig["selector"] = makeCommonXPath("Career Start And End")
|
||||
|
||||
var careerLengthReplace []interface{}
|
||||
careerLengthReplace = append(careerLengthReplace, makeReplaceRegex(`\s+\(.*\)`, ""))
|
||||
careerLengthAttrConfig["replace"] = careerLengthReplace
|
||||
|
||||
config["CareerLength"] = careerLengthAttrConfig
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
@@ -240,7 +267,7 @@ func TestScrapePerformerXPath(t *testing.T) {
|
||||
const performerName = "Mia Malkova"
|
||||
const ethnicity = "Caucasian"
|
||||
const country = "United States"
|
||||
const birthdate = "July 1, 1992 (27 years old)"
|
||||
const birthdate = "1992-07-01"
|
||||
const aliases = "Mia Bliss, Madison Clover, Madison Swan, Mia Mountain, Jessica"
|
||||
const eyeColor = "Hazel"
|
||||
const measurements = "34C-26-36"
|
||||
@@ -251,19 +278,65 @@ func TestScrapePerformerXPath(t *testing.T) {
|
||||
verifyField(t, performerName, performer.Name, "Name")
|
||||
verifyField(t, ethnicity, performer.Ethnicity, "Ethnicity")
|
||||
verifyField(t, country, performer.Country, "Country")
|
||||
|
||||
verifyField(t, birthdate, performer.Birthdate, "Birthdate")
|
||||
|
||||
verifyField(t, aliases, performer.Aliases, "Aliases")
|
||||
verifyField(t, eyeColor, performer.EyeColor, "EyeColor")
|
||||
verifyField(t, measurements, performer.Measurements, "Measurements")
|
||||
verifyField(t, fakeTits, performer.FakeTits, "FakeTits")
|
||||
|
||||
// TODO - this needs post-processing
|
||||
//verifyField(t, careerLength, performer.CareerLength, "CareerLength")
|
||||
verifyField(t, careerLength, performer.CareerLength, "CareerLength")
|
||||
|
||||
verifyField(t, tattoosPiercings, performer.Tattoos, "Tattoos")
|
||||
verifyField(t, tattoosPiercings, performer.Piercings, "Piercings")
|
||||
}
|
||||
|
||||
func TestConcatXPath(t *testing.T) {
|
||||
const firstName = "FirstName"
|
||||
const lastName = "LastName"
|
||||
const eyeColor = "EyeColor"
|
||||
const separator = " "
|
||||
const testDoc = `
|
||||
<html>
|
||||
<div>` + firstName + `</div>
|
||||
<div>` + lastName + `</div>
|
||||
<span>` + eyeColor + `</span>
|
||||
</html>
|
||||
`
|
||||
|
||||
reader := strings.NewReader(testDoc)
|
||||
doc, err := htmlquery.Parse(reader)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error loading document: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
xpathConfig := make(xpathScraperConfig)
|
||||
nameAttrConfig := make(map[interface{}]interface{})
|
||||
nameAttrConfig["selector"] = "//div"
|
||||
nameAttrConfig["concat"] = separator
|
||||
xpathConfig["Name"] = nameAttrConfig
|
||||
xpathConfig["EyeColor"] = "//span"
|
||||
|
||||
scraper := xpathScraper{
|
||||
Performer: xpathConfig,
|
||||
}
|
||||
|
||||
performer, err := scraper.scrapePerformer(doc)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error scraping performer: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
const performerName = firstName + separator + lastName
|
||||
|
||||
verifyField(t, performerName, performer.Name, "Name")
|
||||
verifyField(t, eyeColor, performer.EyeColor, "EyeColor")
|
||||
}
|
||||
|
||||
const sceneHTML = `
|
||||
<!DOCTYPE html>
|
||||
|
||||
@@ -730,3 +803,20 @@ xPathScrapers:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadInvalidXPath(t *testing.T) {
|
||||
config := make(xpathScraperConfig)
|
||||
|
||||
config["Name"] = `//a[id=']/span`
|
||||
|
||||
reader := strings.NewReader(htmlDoc1)
|
||||
doc, err := htmlquery.Parse(reader)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error loading document: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
common := make(commonXPathConfig)
|
||||
config.process(doc, common)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package utils
|
||||
|
||||
var PendingGenerateResource, _ = GetDataFromBase64String("iVBORw0KGgoAAAANSUhEUgAAAfQAAADwBAMAAAAEHosbAAAAG1BMVEUAAADMzMyZmZkzMzNmZmZ/f38ZGRmysrJMTEwh+DPkAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEOklEQVR4nO3YzW/bNhjHcfpN9jGP8iIfI2xrdrQLrLs67Zpdo21pelTWdbnGSTPvaBdosT+7z8OXxAFkIDu0Vrfv59AmpEjoJ1IkFecAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMC/JCqfNNV0Dja1GR0Vv36+O/piLLrsNdVo9EyaKnpzbfLkMZ1vfnptIGdnZ6XUDTUbo0+lOJKiqUlDFy1mqbP5aUPNpujZfK92b6WpSUMXLeYHfHXVULPpvvtiS0P1mFRfQfSLnYaaTffd8SvDsHF9eGQX7eCj2y2+n79z9hCeFq/0/7fzJ2HCp4LsPJ+EJWHln1P/1vmlfqZV0itvrSp0IX9WS9c/yk9cV2Q3lbaQjzPdcQNdtQ81+lhsBevpbxcheihwlyIHIXp1/5ZXujFa9JXIXy51Ib/L0s2tlY8eS1vIx6mu3HHxU7mv0eWbni56Q/mtLEP0UODK/GUeopez1LYv757rcpfpweBHbRu7kEqWA3n9QU570/GzVNpCFucHmWUycyP9+aLwM3q6q7+F6KEg05FchejzZWp7oe/7yq660qtd6kLy2g3H+iSuwiYRSlvIH2mk7uvEdeXSp9GZXto4h+ihYKD13ZDAFvjS2rjjQy0c+3TZfRf6IKyFvUUaPZW2kE8+dl1bsI9n7mLXL3rzSRzPVKAJ0+DdR7ep39/TqyY2e1IXOj9cVvu5Yg1jaQvJYrH4TmeofwSnfrj0hi3kNEQPBcNdW85qa2ET/nyx0F/sQCv7oVzq1IXf9t2bD+Kjp9IWiq9hx9/hod/hOwf+FBdXeF/gOg+jh4a+TR7OfFKnLvz58Fx/9NFTaQul6IWO/uJB9M56dBv1eG01s3/tOdiMWVzfRY9d2FWXkr8O73oqbaEYvRsPZzGplT4YdXvX46iHU+8ovuvOpeipC7uquvFdpXe9nWL0gW29b+qU1Ja56Xr0gSbohWtt4QvLvR1usmcpeurCrrKXIox6Km2hGL2v27eNYkxqk/p4PbrVD8K1A/+9apu87tw2qjF66sIvevrojndSw7VTUJvE6OHkMUlJp3ouna9Ht/ppuDaTGzvI2fnHjjS7KXrqwo/6TOfIji2OqbSF0kGrysNBNr7a+eSprEfX+pcSr13J7S8yLmudBt+Gg2zoJ3bh3/X9fyr9rB/mH1NpC6Xo3fj5EgdZt+wHE97q9+K1I9uullXtTzb53TKXuggrvBSXMhvo50u3rXvbXXT3vvje3UXXj9a/H2xuzv1cfEzX/jEvTtxKfxmV18v76LGLsK8Xs95imZU3qfTr1vyXuv+83gsd42Lbd7EVI/tyy7d9F1uRyateOd72XWyHfaY2/d32f8C2q1YeTD6/7Pn1ybbvAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAL+ITrOa6fKadMcEAAAAASUVORK5CYII=")
|
||||
var PendingGenerateResource, _ = GetDataFromBase64String("iVBORw0KGgoAAAANSUhEUgAAAfQAAADwBAMAAAAEHosbAAAAG1BMVEUAAADMzMyZmZkzMzNmZmZ/f38ZGRmysrJMTEwh+DPkAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEOklEQVR4nO3YzW/bNhjHcfpN9jGP8iIfI2xrdrQLrLs67Zpdo21pelTWdbnGSTPvaBdosT+7z8OXxAFkIDu0Vrfv59AmpEjoJ1IkFecAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMC/JCqfNNV0Dja1GR0Vv36+O/piLLrsNdVo9EyaKnpzbfLkMZ1vfnptIGdnZ6XUDTUbo0+lOJKiqUlDFy1mqbP5aUPNpujZfK92b6WpSUMXLeYHfHXVULPpvvtiS0P1mFRfQfSLnYaaTffd8SvDsHF9eGQX7eCj2y2+n79z9hCeFq/0/7fzJ2HCp4LsPJ+EJWHln1P/1vmlfqZV0itvrSp0IX9WS9c/yk9cV2Q3lbaQjzPdcQNdtQ81+lhsBevpbxcheihwlyIHIXp1/5ZXujFa9JXIXy51Ib/L0s2tlY8eS1vIx6mu3HHxU7mv0eWbni56Q/mtLEP0UODK/GUeopez1LYv757rcpfpweBHbRu7kEqWA3n9QU570/GzVNpCFucHmWUycyP9+aLwM3q6q7+F6KEg05FchejzZWp7oe/7yq660qtd6kLy2g3H+iSuwiYRSlvIH2mk7uvEdeXSp9GZXto4h+ihYKD13ZDAFvjS2rjjQy0c+3TZfRf6IKyFvUUaPZW2kE8+dl1bsI9n7mLXL3rzSRzPVKAJ0+DdR7ep39/TqyY2e1IXOj9cVvu5Yg1jaQvJYrH4TmeofwSnfrj0hi3kNEQPBcNdW85qa2ET/nyx0F/sQCv7oVzq1IXf9t2bD+Kjp9IWiq9hx9/hod/hOwf+FBdXeF/gOg+jh4a+TR7OfFKnLvz58Fx/9NFTaQul6IWO/uJB9M56dBv1eG01s3/tOdiMWVzfRY9d2FWXkr8O73oqbaEYvRsPZzGplT4YdXvX46iHU+8ovuvOpeipC7uquvFdpXe9nWL0gW29b+qU1Ja56Xr0gSbohWtt4QvLvR1usmcpeurCrrKXIox6Km2hGL2v27eNYkxqk/p4PbrVD8K1A/+9apu87tw2qjF66sIvevrojndSw7VTUJvE6OHkMUlJp3ouna9Ht/ppuDaTGzvI2fnHjjS7KXrqwo/6TOfIji2OqbSF0kGrysNBNr7a+eSprEfX+pcSr13J7S8yLmudBt+Gg2zoJ3bh3/X9fyr9rB/mH1NpC6Xo3fj5EgdZt+wHE97q9+K1I9uullXtTzb53TKXuggrvBSXMhvo50u3rXvbXXT3vvje3UXXj9a/H2xuzv1cfEzX/jEvTtxKfxmV18v76LGLsK8Xs95imZU3qfTr1vyXuv+83gsd42Lbd7EVI/tyy7d9F1uRyateOd72XWyHfaY2/d32f8C2q1YeTD6/7Pn1ybbvAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAL+ITrOa6fKadMcEAAAAASUVORK5CYII=")
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
STASH_VERSION="$1"
|
||||
|
||||
DATE=`go run -mod=vendor scripts/getDate.go`
|
||||
GITHASH=`git rev-parse --short HEAD`
|
||||
STASH_VERSION=`git describe --tags --exclude latest_develop`
|
||||
VERSION_FLAGS="-X 'github.com/stashapp/stash/pkg/api.version=$STASH_VERSION' -X 'github.com/stashapp/stash/pkg/api.buildstamp=$DATE' -X 'github.com/stashapp/stash/pkg/api.githash=$GITHASH'"
|
||||
SETUP="export GO111MODULE=on; export CGO_ENABLED=1;"
|
||||
WINDOWS="GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ packr2 build -o dist/stash-win.exe -ldflags \"-extldflags '-static' $VERSION_FLAGS\" -tags extended -v -mod=vendor;"
|
||||
|
||||
@@ -5,10 +5,11 @@ uploadFile()
|
||||
{
|
||||
FILE=$1
|
||||
BASENAME="$(basename "${FILE}")"
|
||||
uploadedTo=`curl --upload-file $FILE "https://transfer.sh/$BASENAME"`
|
||||
# abort if it takes more than two minutes to upload
|
||||
uploadedTo=`curl -m 120 --upload-file $FILE "https://transfer.sh/$BASENAME"`
|
||||
echo "$BASENAME uploaded to url: $uploadedTo"
|
||||
}
|
||||
|
||||
uploadFile "dist/stash-osx"
|
||||
uploadFile "dist/stash-win.exe"
|
||||
uploadFile "dist/stash-linux"
|
||||
uploadFile "dist/stash-linux"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
Spinner,
|
||||
} from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent, useEffect, useState } from "react";
|
||||
import * as GQL from "../../core/generated-graphql";
|
||||
import { StashService } from "../../core/StashService";
|
||||
@@ -20,7 +19,7 @@ export const Gallery: FunctionComponent<IProps> = (props: IProps) => {
|
||||
setIsLoading(loading);
|
||||
if (!data || !data.findGallery || !!error) { return; }
|
||||
setGallery(data.findGallery);
|
||||
}, [data]);
|
||||
}, [data, loading, error]);
|
||||
|
||||
if (!data || !data.findGallery || isLoading) { return <Spinner size={Spinner.SIZE_LARGE} />; }
|
||||
if (!!error) { return <>{error.message}</>; }
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { HTMLTable } from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import { QueryHookResult } from "react-apollo-hooks";
|
||||
import { Link } from "react-router-dom";
|
||||
@@ -36,7 +35,7 @@ export const GalleryList: FunctionComponent<IProps> = (props: IProps) => {
|
||||
<tr key={gallery.id}>
|
||||
<td>
|
||||
<Link to={`/galleries/${gallery.id}`}>
|
||||
{gallery.files.length > 0 ? <img src={`${gallery.files[0].path}?thumb=true`} /> : undefined}
|
||||
{gallery.files.length > 0 ? <img alt={gallery.title} src={`${gallery.files[0].path}?thumb=true`} /> : undefined}
|
||||
</Link>
|
||||
</td>
|
||||
<td><Link to={`/galleries/${gallery.id}`}>{gallery.path}</Link></td>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent, useState } from "react";
|
||||
import Lightbox from "react-images";
|
||||
import Gallery from "react-photo-gallery";
|
||||
|
||||
@@ -23,7 +23,7 @@ export const Settings: FunctionComponent<IProps> = (props: IProps) => {
|
||||
const location = Object.assign({}, props.history.location);
|
||||
location.search = queryString.stringify({tab: tabId}, {encode: false});
|
||||
props.history.replace(location);
|
||||
}, [tabId]);
|
||||
}, [tabId, props.history]);
|
||||
|
||||
function getTabId(): TabId {
|
||||
const queryParams = queryString.parse(props.location.search);
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
import {
|
||||
H1,
|
||||
Button,
|
||||
H4,
|
||||
H6,
|
||||
HTMLTable,
|
||||
Spinner,
|
||||
Tag,
|
||||
} from "@blueprintjs/core";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import * as GQL from "../../core/generated-graphql";
|
||||
import { TextUtils } from "../../utils/text";
|
||||
import { StashService } from "../../core/StashService";
|
||||
|
||||
interface IProps {}
|
||||
interface IProps { }
|
||||
|
||||
export const SettingsAboutPanel: FunctionComponent<IProps> = (props: IProps) => {
|
||||
const { data, error, loading } = StashService.useVersion();
|
||||
const { data: dataLatest, error: errorLatest, loading: loadingLatest, refetch, networkStatus } = StashService.useLatestVersion();
|
||||
|
||||
function maybeRenderTag() {
|
||||
if (!data || !data.version || !data.version.version) { return; }
|
||||
@@ -26,32 +23,88 @@ export const SettingsAboutPanel: FunctionComponent<IProps> = (props: IProps) =>
|
||||
);
|
||||
}
|
||||
|
||||
function maybeRenderLatestVersion() {
|
||||
if (!dataLatest || !dataLatest.latestversion || !dataLatest.latestversion.shorthash || !dataLatest.latestversion.url) { return; }
|
||||
if (!data || !data.version || !data.version.hash) {
|
||||
return (
|
||||
<>{dataLatest.latestversion.shorthash}</>
|
||||
);
|
||||
}
|
||||
|
||||
if (data.version.hash !== dataLatest.latestversion.shorthash) {
|
||||
return (
|
||||
<>
|
||||
<strong>{dataLatest.latestversion.shorthash} [NEW] </strong><a href={dataLatest.latestversion.url}>Download</a>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>{dataLatest.latestversion.shorthash}</>
|
||||
);
|
||||
}
|
||||
|
||||
function renderLatestVersion() {
|
||||
if (!data || !data.version || !data.version.version) { return; } //if there is no "version" latest version check is obviously not supported
|
||||
return (
|
||||
<HTMLTable>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Latest Version Build Hash: </td>
|
||||
<td>{maybeRenderLatestVersion()} </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><Button onClick={() => refetch()} text="Check for new version" /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</HTMLTable>
|
||||
);
|
||||
}
|
||||
|
||||
function renderVersion() {
|
||||
if (!data || !data.version) { return; }
|
||||
return (
|
||||
<>
|
||||
<HTMLTable>
|
||||
<tbody>
|
||||
{maybeRenderTag()}
|
||||
<tr>
|
||||
<td>Build hash:</td>
|
||||
<td>{data.version.hash}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Build time:</td>
|
||||
<td>{data.version.build_time}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</HTMLTable>
|
||||
<HTMLTable>
|
||||
<tbody>
|
||||
{maybeRenderTag()}
|
||||
<tr>
|
||||
<td>Build hash:</td>
|
||||
<td>{data.version.hash}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Build time:</td>
|
||||
<td>{data.version.build_time}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</HTMLTable>
|
||||
</>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<H4>About</H4>
|
||||
<HTMLTable>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Stash home at <a href="https://github.com/stashapp/stash" target="_blank">Github</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Stash <a href="https://github.com/stashapp/stash/wiki" target="_blank">Wiki</a> page</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Join our <a href="https://discord.gg/2TsNFKt" target="_blank">Discord</a> channel</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Support us through <a href="https://opencollective.com/stashapp" target="_blank">Open Collective</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</HTMLTable>
|
||||
{!data || loading ? <Spinner size={Spinner.SIZE_LARGE} /> : undefined}
|
||||
{!!error ? <span>error.message</span> : undefined}
|
||||
{!!error ? <span>{error.message}</span> : undefined}
|
||||
{!!errorLatest ? <span>{errorLatest.message}</span> : undefined}
|
||||
{renderVersion()}
|
||||
{!dataLatest || loadingLatest || networkStatus === 4 ? <Spinner size={Spinner.SIZE_SMALL} /> : <>{renderLatestVersion()}</>}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -3,12 +3,9 @@ import {
|
||||
Button,
|
||||
Divider,
|
||||
FormGroup,
|
||||
H1,
|
||||
H4,
|
||||
H6,
|
||||
InputGroup,
|
||||
Spinner,
|
||||
Tag,
|
||||
Checkbox,
|
||||
HTMLSelect,
|
||||
} from "@blueprintjs/core";
|
||||
@@ -71,7 +68,7 @@ export const SettingsConfigurationPanel: FunctionComponent<IProps> = (props: IPr
|
||||
setLogAccess(conf.general.logAccess);
|
||||
setExcludes(conf.general.excludes);
|
||||
}
|
||||
}, [data]);
|
||||
}, [data, error]);
|
||||
|
||||
function onStashesChanged(directories: string[]) {
|
||||
setStashes(directories);
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
TextArea,
|
||||
NumericInput
|
||||
} from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent, useEffect, useState } from "react";
|
||||
import { StashService } from "../../core/StashService";
|
||||
import { ErrorUtils } from "../../utils/errors";
|
||||
@@ -48,7 +47,7 @@ export const SettingsInterfacePanel: FunctionComponent<IProps> = () => {
|
||||
setCSS(config.data.configuration.interface.css || "");
|
||||
setCSSEnabled(config.data.configuration.interface.cssEnabled || false);
|
||||
}
|
||||
}, [config.data]);
|
||||
}, [config.data, config.error]);
|
||||
|
||||
async function onSave() {
|
||||
try {
|
||||
|
||||
@@ -155,7 +155,7 @@ export const SettingsLogsPanel: FunctionComponent<IProps> = (props: IProps) => {
|
||||
const logLevels = ["Debug", "Info", "Warning", "Error"];
|
||||
|
||||
function filterByLogLevel(logEntry : LogEntry) {
|
||||
if (logLevel == "Debug") {
|
||||
if (logLevel === "Debug") {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
Divider,
|
||||
FormGroup,
|
||||
H4,
|
||||
AnchorButton,
|
||||
ProgressBar,
|
||||
H5,
|
||||
} from "@blueprintjs/core";
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
NavbarDivider,
|
||||
Popover,
|
||||
} from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import * as GQL from "../../core/generated-graphql";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { FunctionComponent, useState, useEffect } from "react";
|
||||
import { InputGroup, ButtonGroup, Button, IInputGroupProps, HTMLInputProps, ControlGroup } from "@blueprintjs/core";
|
||||
import { TextUtils } from "../../utils/text";
|
||||
import { InputGroup, ButtonGroup, Button, HTMLInputProps, ControlGroup } from "@blueprintjs/core";
|
||||
import { DurationUtils } from "../../utils/duration";
|
||||
import { FIXED, NUMERIC_INPUT } from "@blueprintjs/core/lib/esm/common/classes";
|
||||
|
||||
interface IProps {
|
||||
@@ -11,65 +11,20 @@ interface IProps {
|
||||
}
|
||||
|
||||
export const DurationInput: FunctionComponent<HTMLInputProps & IProps> = (props: IProps) => {
|
||||
const [value, setValue] = useState<string>(secondsToString(props.numericValue));
|
||||
const [value, setValue] = useState<string>(DurationUtils.secondsToString(props.numericValue));
|
||||
|
||||
useEffect(() => {
|
||||
setValue(secondsToString(props.numericValue));
|
||||
setValue(DurationUtils.secondsToString(props.numericValue));
|
||||
}, [props.numericValue]);
|
||||
|
||||
function secondsToString(seconds : number) {
|
||||
let ret = TextUtils.secondsToTimestamp(seconds);
|
||||
|
||||
if (ret.startsWith("00:")) {
|
||||
ret = ret.substr(3);
|
||||
|
||||
if (ret.startsWith("0")) {
|
||||
ret = ret.substr(1);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function stringToSeconds(v : string) {
|
||||
if (!v) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let splits = v.split(":");
|
||||
|
||||
if (splits.length > 3) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let seconds = 0;
|
||||
let factor = 1;
|
||||
while(splits.length > 0) {
|
||||
let thisSplit = splits.pop();
|
||||
if (thisSplit == undefined) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let thisInt = parseInt(thisSplit, 10);
|
||||
if (isNaN(thisInt)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
seconds += factor * thisInt;
|
||||
factor *= 60;
|
||||
}
|
||||
|
||||
return seconds;
|
||||
}
|
||||
|
||||
function increment() {
|
||||
let seconds = stringToSeconds(value);
|
||||
let seconds = DurationUtils.stringToSeconds(value);
|
||||
seconds += 1;
|
||||
props.onValueChange(seconds);
|
||||
}
|
||||
|
||||
function decrement() {
|
||||
let seconds = stringToSeconds(value);
|
||||
let seconds = DurationUtils.stringToSeconds(value);
|
||||
seconds -= 1;
|
||||
props.onValueChange(seconds);
|
||||
}
|
||||
@@ -117,7 +72,7 @@ export const DurationInput: FunctionComponent<HTMLInputProps & IProps> = (props:
|
||||
disabled={props.disabled}
|
||||
value={value}
|
||||
onChange={(e : any) => setValue(e.target.value)}
|
||||
onBlur={() => props.onValueChange(stringToSeconds(value))}
|
||||
onBlur={() => props.onValueChange(DurationUtils.stringToSeconds(value))}
|
||||
placeholder="hh:mm:ss"
|
||||
rightElement={maybeRenderReset()}
|
||||
/>
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
Spinner,
|
||||
FormGroup,
|
||||
} from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent, useEffect, useState } from "react";
|
||||
import { StashService } from "../../../core/StashService";
|
||||
|
||||
@@ -29,7 +28,7 @@ export const FolderSelect: FunctionComponent<IProps> = (props: IProps) => {
|
||||
useEffect(() => {
|
||||
if (!data || !data.directories || !!error) { return; }
|
||||
setSelectableDirectories(StashService.nullToUndefined(data.directories));
|
||||
}, [data]);
|
||||
}, [data, error]);
|
||||
|
||||
function onSelectDirectory() {
|
||||
selectedDirectories.push(currentDirectory);
|
||||
@@ -79,7 +78,7 @@ export const FolderSelect: FunctionComponent<IProps> = (props: IProps) => {
|
||||
{renderDialog()}
|
||||
<FormGroup>
|
||||
{selectedDirectories.map((path) => {
|
||||
return <div key={path}>{path} <a onClick={() => onRemoveDirectory(path)}>Remove</a></div>;
|
||||
return <div key={path}>{path} <button className="button-link" onClick={() => onRemoveDirectory(path)}>Remove</button></div>;
|
||||
})}
|
||||
</FormGroup>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import {
|
||||
ITagProps,
|
||||
Tag,
|
||||
} from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { PerformerDataFragment, SceneMarkerDataFragment, TagDataFragment } from "../../core/generated-graphql";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
MenuItem,
|
||||
Menu,
|
||||
IconName,
|
||||
} from "@blueprintjs/core";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import { IMenuItem } from "../App";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { H1, Spinner } from "@blueprintjs/core";
|
||||
import { Spinner } from "@blueprintjs/core";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import { StashService } from "../core/StashService";
|
||||
|
||||
@@ -8,35 +8,35 @@ export const Stats: FunctionComponent = () => {
|
||||
function renderStats() {
|
||||
if (!data || !data.stats) { return; }
|
||||
return (
|
||||
<nav id="details-container" className="level">
|
||||
<nav id="details-container" className="level stats">
|
||||
<div className="level-item has-text-centered">
|
||||
<div>
|
||||
<p className="heading">Scenes</p>
|
||||
<p className="title">{data.stats.scene_count}</p>
|
||||
<p className="heading">Scenes</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="level-item has-text-centered">
|
||||
<div>
|
||||
<p className="heading">Galleries</p>
|
||||
<p className="title">{data.stats.gallery_count}</p>
|
||||
<p className="heading">Galleries</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="level-item has-text-centered">
|
||||
<div>
|
||||
<p className="heading">Performers</p>
|
||||
<p className="title">{data.stats.performer_count}</p>
|
||||
<p className="heading">Performers</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="level-item has-text-centered">
|
||||
<div>
|
||||
<p className="heading">Studios</p>
|
||||
<p className="title">{data.stats.studio_count}</p>
|
||||
<p className="heading">Studios</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="level-item has-text-centered">
|
||||
<div>
|
||||
<p className="heading">Tags</p>
|
||||
<p className="title">{data.stats.tag_count}</p>
|
||||
<p className="heading">Tags</p>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -48,13 +48,6 @@ export const Stats: FunctionComponent = () => {
|
||||
{!data || loading ? <Spinner size={Spinner.SIZE_LARGE} /> : undefined}
|
||||
{!!error ? <span>error.message</span> : undefined}
|
||||
{renderStats()}
|
||||
|
||||
<h3>Notes</h3>
|
||||
<pre>
|
||||
{`
|
||||
This is still an early version, some things are still a work in progress.
|
||||
`}
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
import {
|
||||
Button,
|
||||
Classes,
|
||||
Dialog,
|
||||
EditableText,
|
||||
HTMLSelect,
|
||||
HTMLTable,
|
||||
Spinner,
|
||||
} from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent, useEffect, useState } from "react";
|
||||
import * as GQL from "../../../core/generated-graphql";
|
||||
import { StashService } from "../../../core/StashService";
|
||||
@@ -52,7 +47,7 @@ export const Studio: FunctionComponent<IProps> = (props: IProps) => {
|
||||
setIsLoading(loading);
|
||||
if (!data || !data.findStudio || !!error) { return; }
|
||||
setStudio(data.findStudio);
|
||||
}, [data]);
|
||||
}, [data, loading, error]);
|
||||
|
||||
useEffect(() => {
|
||||
setImagePreview(studio.image_path);
|
||||
@@ -61,7 +56,7 @@ export const Studio: FunctionComponent<IProps> = (props: IProps) => {
|
||||
if (!isNew) {
|
||||
setIsEditing(false);
|
||||
}
|
||||
}, [studio]);
|
||||
}, [studio, isNew]);
|
||||
|
||||
function onImageLoad(this: FileReader) {
|
||||
setImagePreview(this.result as string);
|
||||
@@ -120,7 +115,7 @@ export const Studio: FunctionComponent<IProps> = (props: IProps) => {
|
||||
async function onDelete() {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const result = await deleteStudio();
|
||||
await deleteStudio();
|
||||
} catch (e) {
|
||||
ErrorUtils.handle(e);
|
||||
}
|
||||
@@ -139,7 +134,7 @@ export const Studio: FunctionComponent<IProps> = (props: IProps) => {
|
||||
<>
|
||||
<div className="columns is-multiline no-spacing">
|
||||
<div className="column is-half details-image-container">
|
||||
<img className="studio" src={imagePreview} />
|
||||
<img alt={name} className="studio" src={imagePreview} />
|
||||
</div>
|
||||
<div className="column is-half details-detail-container">
|
||||
<DetailsEditNavbar
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import { QueryHookResult } from "react-apollo-hooks";
|
||||
import { FindStudiosQuery, FindStudiosVariables } from "../../core/generated-graphql";
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { Alert, Button, Classes, Dialog, EditableText, FormGroup, HTMLTable, InputGroup, Spinner, Tag } from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import { Alert, Button, Classes, Dialog, FormGroup, InputGroup, Spinner } from "@blueprintjs/core";
|
||||
import React, { FunctionComponent, useEffect, useState } from "react";
|
||||
import { QueryHookResult } from "react-apollo-hooks";
|
||||
import { Link } from "react-router-dom";
|
||||
import { FindGalleriesQuery, FindGalleriesVariables } from "../../core/generated-graphql";
|
||||
import * as GQL from "../../core/generated-graphql";
|
||||
import { StashService } from "../../core/StashService";
|
||||
import { ListHook } from "../../hooks/ListHook";
|
||||
import { IBaseProps } from "../../models/base-props";
|
||||
import { ListFilterModel } from "../../models/list-filter/filter";
|
||||
import { DisplayMode, FilterMode } from "../../models/list-filter/types";
|
||||
import { ErrorUtils } from "../../utils/errors";
|
||||
import { NavigationUtils } from "../../utils/navigation";
|
||||
import { ToastUtils } from "../../utils/toasts";
|
||||
@@ -36,7 +30,7 @@ export const TagList: FunctionComponent<IProps> = (props: IProps) => {
|
||||
setIsLoading(loading);
|
||||
if (!data || !data.allTags || !!error) { return; }
|
||||
setTags(data.allTags);
|
||||
}, [data]);
|
||||
}, [data, loading, error]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!!editingTag) {
|
||||
|
||||
@@ -116,7 +116,7 @@ export const WallItem: FunctionComponent<IWallItemProps> = (props: IWallItemProp
|
||||
loop={true}
|
||||
ref={videoHoverHook.videoEl}
|
||||
/>
|
||||
<img src={previewPath || screenshotPath} onError={() => previewNotFound()} />
|
||||
<img alt={title} src={previewPath || screenshotPath} onError={() => previewNotFound()} />
|
||||
{showTextContainer ?
|
||||
<div className="scene-wall-item-text-container">
|
||||
<div style={{lineHeight: 1}}>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent, useState } from "react";
|
||||
import * as GQL from "../../core/generated-graphql";
|
||||
import "./Wall.scss";
|
||||
|
||||
@@ -11,7 +11,7 @@ import _ from "lodash";
|
||||
import React, { FunctionComponent, useEffect, useRef, useState } from "react";
|
||||
import { isArray } from "util";
|
||||
import { CriterionModifier } from "../../core/generated-graphql";
|
||||
import { Criterion, CriterionType } from "../../models/list-filter/criteria/criterion";
|
||||
import { Criterion, CriterionType, DurationCriterion } from "../../models/list-filter/criteria/criterion";
|
||||
import { NoneCriterion } from "../../models/list-filter/criteria/none";
|
||||
import { PerformersCriterion } from "../../models/list-filter/criteria/performers";
|
||||
import { StudiosCriterion } from "../../models/list-filter/criteria/studios";
|
||||
@@ -19,6 +19,7 @@ import { TagsCriterion } from "../../models/list-filter/criteria/tags";
|
||||
import { makeCriteria } from "../../models/list-filter/criteria/utils";
|
||||
import { ListFilterModel } from "../../models/list-filter/filter";
|
||||
import { FilterMultiSelect } from "../select/FilterMultiSelect";
|
||||
import { DurationInput } from "../Shared/DurationInput";
|
||||
|
||||
interface IAddFilterProps {
|
||||
onAddCriterion: (criterion: Criterion, oldId?: string) => void;
|
||||
@@ -64,6 +65,11 @@ export const AddFilter: FunctionComponent<IAddFilterProps> = (props: IAddFilterP
|
||||
valueStage.current = event.target.value;
|
||||
}
|
||||
|
||||
function onChangedDuration(valueAsNumber: number) {
|
||||
valueStage.current = valueAsNumber;
|
||||
onBlurInput();
|
||||
}
|
||||
|
||||
function onBlurInput() {
|
||||
const newCriterion = _.cloneDeep(criterion);
|
||||
newCriterion.value = valueStage.current;
|
||||
@@ -148,6 +154,14 @@ export const AddFilter: FunctionComponent<IAddFilterProps> = (props: IAddFilterP
|
||||
defaultValue={criterion.value}
|
||||
/>
|
||||
);
|
||||
} else if (criterion instanceof DurationCriterion) {
|
||||
// render duration control
|
||||
return (
|
||||
<DurationInput
|
||||
numericValue={criterion.value ? criterion.value : 0}
|
||||
onValueChange={onChangedDuration}
|
||||
/>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<InputGroup
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
Slider,
|
||||
} from "@blueprintjs/core";
|
||||
import { debounce } from "lodash";
|
||||
import React, { FunctionComponent, SyntheticEvent, useEffect, useState } from "react";
|
||||
import React, { FunctionComponent, SyntheticEvent, useState } from "react";
|
||||
import { Criterion } from "../../models/list-filter/criteria/criterion";
|
||||
import { ListFilterModel } from "../../models/list-filter/filter";
|
||||
import { DisplayMode } from "../../models/list-filter/types";
|
||||
@@ -41,22 +41,18 @@ interface IListFilterProps {
|
||||
const PAGE_SIZE_OPTIONS = ["20", "40", "60", "120"];
|
||||
|
||||
export const ListFilter: FunctionComponent<IListFilterProps> = (props: IListFilterProps) => {
|
||||
let searchCallback: any;
|
||||
|
||||
const [editingCriterion, setEditingCriterion] = useState<Criterion | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
searchCallback = debounce((event: any) => {
|
||||
props.onChangeQuery(event.target.value);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
function onChangePageSize(event: SyntheticEvent<HTMLSelectElement>) {
|
||||
const val = event!.currentTarget!.value;
|
||||
props.onChangePageSize(parseInt(val, 10));
|
||||
}
|
||||
|
||||
function onChangeQuery(event: SyntheticEvent<HTMLInputElement>) {
|
||||
let searchCallback = debounce((event: any) => {
|
||||
props.onChangeQuery(event.target.value);
|
||||
}, 500);
|
||||
|
||||
event.persist();
|
||||
searchCallback(event);
|
||||
}
|
||||
|
||||
@@ -78,8 +78,9 @@ export class Pagination extends React.Component<IPaginationProps, IPaginationSta
|
||||
|
||||
const pagerState = this.getPagerState(this.props.totalItems, page, this.props.itemsPerPage);
|
||||
|
||||
if (page < 1) { page = 1; }
|
||||
// rearranged this so that the minimum page number is 1, not 0
|
||||
if (page > pagerState.totalPages) { page = pagerState.totalPages; }
|
||||
if (page < 1) { page = 1; }
|
||||
|
||||
this.setState(pagerState);
|
||||
if (propagate) { this.props.onChangePage(page); }
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
AnchorButton,
|
||||
IconName,
|
||||
} from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent, useEffect, useState } from "react";
|
||||
import * as GQL from "../../../core/generated-graphql";
|
||||
import { StashService } from "../../../core/StashService";
|
||||
@@ -40,7 +39,7 @@ export const Performer: FunctionComponent<IPerformerProps> = (props: IPerformerP
|
||||
setIsLoading(loading);
|
||||
if (!data || !data.findPerformer || !!error) { return; }
|
||||
setPerformer(data.findPerformer);
|
||||
}, [data]);
|
||||
}, [data, error, loading]);
|
||||
|
||||
useEffect(() => {
|
||||
setImagePreview(performer.image_path);
|
||||
@@ -191,7 +190,7 @@ export const Performer: FunctionComponent<IPerformerProps> = (props: IPerformerP
|
||||
return (
|
||||
<div className="columns is-multiline no-spacing">
|
||||
<div className="column is-half details-image-container">
|
||||
<img className="performer" src={imagePreview} />
|
||||
{!imagePreview ? undefined : <img alt="Performer" className="performer" src={imagePreview} />}
|
||||
</div>
|
||||
<div className="column is-half details-detail-container">
|
||||
{renderTabs()}
|
||||
@@ -218,7 +217,7 @@ export const Performer: FunctionComponent<IPerformerProps> = (props: IPerformerP
|
||||
<>
|
||||
<div id="performer-page">
|
||||
<div className="details-image-container">
|
||||
<img className="performer" src={imagePreview} onClick={openLightbox} />
|
||||
<img alt={performer.name} className="performer" src={imagePreview} onClick={openLightbox} />
|
||||
</div>
|
||||
<div className="performer-head">
|
||||
<h1 className="bp3-heading">
|
||||
|
||||
@@ -2,10 +2,8 @@ import {
|
||||
Button,
|
||||
Classes,
|
||||
Dialog,
|
||||
EditableText,
|
||||
HTMLTable,
|
||||
Spinner,
|
||||
FormGroup,
|
||||
Menu,
|
||||
MenuItem,
|
||||
Popover,
|
||||
@@ -19,7 +17,6 @@ import { StashService } from "../../../core/StashService";
|
||||
import { ErrorUtils } from "../../../utils/errors";
|
||||
import { TableUtils } from "../../../utils/table";
|
||||
import { ScrapePerformerSuggest } from "../../select/ScrapePerformerSuggest";
|
||||
import { ToastUtils } from "../../../utils/toasts";
|
||||
import { EditableTextUtils } from "../../../utils/editabletext";
|
||||
import { ImageUtils } from "../../../utils/image";
|
||||
|
||||
@@ -177,16 +174,17 @@ export const PerformerDetailsPanel: FunctionComponent<IPerformerDetailsProps> =
|
||||
|
||||
async function onScrapePerformer() {
|
||||
setIsDisplayingScraperDialog(undefined);
|
||||
setIsLoading(true);
|
||||
try {
|
||||
if (!scrapePerformerDetails || !isDisplayingScraperDialog) { return; }
|
||||
setIsLoading(true);
|
||||
const result = await StashService.queryScrapePerformer(isDisplayingScraperDialog.id, getQueryScraperPerformerInput());
|
||||
if (!result.data || !result.data.scrapePerformer) { return; }
|
||||
updatePerformerEditState(result.data.scrapePerformer);
|
||||
} catch (e) {
|
||||
ErrorUtils.handle(e);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
async function onScrapePerformerURL() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
Button,
|
||||
} from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import * as GQL from "../../../core/generated-graphql";
|
||||
import { StashService } from "../../../core/StashService";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import * as GQL from "../../../core/generated-graphql";
|
||||
import { IBaseProps } from "../../../models";
|
||||
|
||||
50
ui/v2/src/components/scenes/OCounterButton.tsx
Normal file
50
ui/v2/src/components/scenes/OCounterButton.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import React, { FunctionComponent } from "react";
|
||||
import { Button, Popover, Menu, MenuItem } from "@blueprintjs/core";
|
||||
import { Icons } from "../../utils/icons";
|
||||
|
||||
export interface IOCounterButtonProps {
|
||||
loading: boolean
|
||||
value: number
|
||||
onIncrement: () => void
|
||||
onDecrement: () => void
|
||||
onReset: () => void
|
||||
onMenuOpened?: () => void
|
||||
onMenuClosed?: () => void
|
||||
}
|
||||
|
||||
export const OCounterButton: FunctionComponent<IOCounterButtonProps> = (props: IOCounterButtonProps) => {
|
||||
function renderButton() {
|
||||
return (
|
||||
<Button
|
||||
loading={props.loading}
|
||||
icon={Icons.sweatDrops()}
|
||||
text={props.value}
|
||||
minimal={true}
|
||||
onClick={props.onIncrement}
|
||||
disabled={props.loading}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (props.value) {
|
||||
// just render the button by itself
|
||||
return (
|
||||
<Popover
|
||||
interactionKind={"hover"}
|
||||
hoverOpenDelay={1000}
|
||||
position="bottom"
|
||||
disabled={props.loading}
|
||||
onOpening={props.onMenuOpened}
|
||||
onClosing={props.onMenuClosed}
|
||||
>
|
||||
{renderButton()}
|
||||
<Menu>
|
||||
<MenuItem text="Decrement" icon="minus" onClick={props.onDecrement}/>
|
||||
<MenuItem text="Reset" icon="disable" onClick={props.onReset}/>
|
||||
</Menu>
|
||||
</Popover>
|
||||
);
|
||||
} else {
|
||||
return renderButton();
|
||||
}
|
||||
}
|
||||
@@ -7,18 +7,17 @@ import {
|
||||
Elevation,
|
||||
H4,
|
||||
Popover,
|
||||
Tag,
|
||||
} from "@blueprintjs/core";
|
||||
import React, { FunctionComponent, RefObject, useEffect, useRef, useState } from "react";
|
||||
import React, { FunctionComponent, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import * as GQL from "../../core/generated-graphql";
|
||||
import { VideoHoverHook } from "../../hooks/VideoHover";
|
||||
import { ColorUtils } from "../../utils/color";
|
||||
import { TextUtils } from "../../utils/text";
|
||||
import { TagLink } from "../Shared/TagLink";
|
||||
import { SceneHelpers } from "./helpers";
|
||||
import { ZoomUtils } from "../../utils/zoom";
|
||||
import { StashService } from "../../core/StashService";
|
||||
import { Icons } from "../../utils/icons";
|
||||
|
||||
interface ISceneCardProps {
|
||||
scene: GQL.SlimSceneDataFragment;
|
||||
@@ -144,10 +143,22 @@ export const SceneCard: FunctionComponent<ISceneCardProps> = (props: ISceneCardP
|
||||
);
|
||||
}
|
||||
|
||||
function maybeRenderOCounter() {
|
||||
if (props.scene.o_counter) {
|
||||
return (
|
||||
<Button
|
||||
icon={Icons.sweatDrops()}
|
||||
text={props.scene.o_counter}
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function maybeRenderPopoverButtonGroup() {
|
||||
if (props.scene.tags.length > 0 ||
|
||||
props.scene.performers.length > 0 ||
|
||||
props.scene.scene_markers.length > 0) {
|
||||
props.scene.scene_markers.length > 0 ||
|
||||
props.scene.o_counter) {
|
||||
return (
|
||||
<>
|
||||
<Divider />
|
||||
@@ -155,6 +166,7 @@ export const SceneCard: FunctionComponent<ISceneCardProps> = (props: ISceneCardP
|
||||
{maybeRenderTagPopoverButton()}
|
||||
{maybeRenderPerformerPopoverButton()}
|
||||
{maybeRenderSceneMarkerPopoverButton()}
|
||||
{maybeRenderOCounter()}
|
||||
</ButtonGroup>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -16,6 +16,8 @@ import { SceneEditPanel } from "./SceneEditPanel";
|
||||
import { SceneFileInfoPanel } from "./SceneFileInfoPanel";
|
||||
import { SceneMarkersPanel } from "./SceneMarkersPanel";
|
||||
import { ScenePerformerPanel } from "./ScenePerformerPanel";
|
||||
import { ErrorUtils } from "../../../utils/errors";
|
||||
import { IOCounterButtonProps, OCounterButton } from "../OCounterButton";
|
||||
|
||||
interface ISceneProps extends IBaseProps {}
|
||||
|
||||
@@ -24,13 +26,19 @@ export const Scene: FunctionComponent<ISceneProps> = (props: ISceneProps) => {
|
||||
const [autoplay, setAutoplay] = useState<boolean>(false);
|
||||
const [scene, setScene] = useState<Partial<GQL.SceneDataFragment>>({});
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const { data, error, loading } = StashService.useFindScene(props.match.params.id);
|
||||
const { data, error, loading, refetch } = StashService.useFindScene(props.match.params.id);
|
||||
|
||||
const [oLoading, setOLoading] = useState(false);
|
||||
|
||||
const incrementO = StashService.useSceneIncrementO(scene.id || "0");
|
||||
const decrementO = StashService.useSceneDecrementO(scene.id || "0");
|
||||
const resetO = StashService.useSceneResetO(scene.id || "0");
|
||||
|
||||
useEffect(() => {
|
||||
setIsLoading(loading);
|
||||
if (!data || !data.findScene || !!error) { return; }
|
||||
setScene(StashService.nullToUndefined(data.findScene));
|
||||
}, [data]);
|
||||
}, [data, loading, error]);
|
||||
|
||||
useEffect(() => {
|
||||
const queryParams = queryString.parse(props.location.search);
|
||||
@@ -41,7 +49,7 @@ export const Scene: FunctionComponent<ISceneProps> = (props: ISceneProps) => {
|
||||
if (queryParams.autoplay && typeof queryParams.autoplay === "string") {
|
||||
setAutoplay(queryParams.autoplay === "true");
|
||||
}
|
||||
});
|
||||
}, [props.location.search, timestamp]);
|
||||
|
||||
function onClickMarker(marker: GQL.SceneMarkerDataFragment) {
|
||||
setTimestamp(marker.seconds);
|
||||
@@ -54,6 +62,56 @@ export const Scene: FunctionComponent<ISceneProps> = (props: ISceneProps) => {
|
||||
Object.assign({scene_marker_tags: data.sceneMarkerTags}, scene) as GQL.SceneDataFragment; // TODO Hack from angular
|
||||
if (!!error) { return <>error...</>; }
|
||||
|
||||
function updateOCounter(newValue: number) {
|
||||
const modifiedScene = Object.assign({}, scene);
|
||||
modifiedScene.o_counter = newValue;
|
||||
setScene(modifiedScene);
|
||||
}
|
||||
|
||||
async function onIncrementClick() {
|
||||
try {
|
||||
setOLoading(true);
|
||||
const result = await incrementO();
|
||||
updateOCounter(result.data.sceneIncrementO);
|
||||
} catch (e) {
|
||||
ErrorUtils.handle(e);
|
||||
} finally {
|
||||
setOLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function onDecrementClick() {
|
||||
try {
|
||||
setOLoading(true);
|
||||
const result = await decrementO();
|
||||
updateOCounter(result.data.sceneDecrementO);
|
||||
} catch (e) {
|
||||
ErrorUtils.handle(e);
|
||||
} finally {
|
||||
setOLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function onResetClick() {
|
||||
try {
|
||||
setOLoading(true);
|
||||
const result = await resetO();
|
||||
updateOCounter(result.data.sceneResetO);
|
||||
} catch (e) {
|
||||
ErrorUtils.handle(e);
|
||||
} finally {
|
||||
setOLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
const oCounterProps : IOCounterButtonProps = {
|
||||
loading: oLoading,
|
||||
value: scene.o_counter || 0,
|
||||
onIncrement: onIncrementClick,
|
||||
onDecrement: onDecrementClick,
|
||||
onReset: onResetClick
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<ScenePlayer scene={modifiedScene} timestamp={timestamp} autoplay={autoplay}/>
|
||||
@@ -93,6 +151,11 @@ export const Scene: FunctionComponent<ISceneProps> = (props: ISceneProps) => {
|
||||
onDelete={() => props.history.push("/scenes")}
|
||||
/>}
|
||||
/>
|
||||
|
||||
<Tabs.Expander />
|
||||
<OCounterButton
|
||||
{...oCounterProps}
|
||||
/>
|
||||
</Tabs>
|
||||
</Card>
|
||||
</>
|
||||
|
||||
@@ -2,12 +2,9 @@ import {
|
||||
H1,
|
||||
H4,
|
||||
H6,
|
||||
Tag,
|
||||
} from "@blueprintjs/core";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import * as GQL from "../../../core/generated-graphql";
|
||||
import { NavigationUtils } from "../../../utils/navigation";
|
||||
import { TextUtils } from "../../../utils/text";
|
||||
import { TagLink } from "../../Shared/TagLink";
|
||||
import { SceneHelpers } from "../helpers";
|
||||
@@ -46,6 +43,7 @@ export const SceneDetailPanel: FunctionComponent<ISceneDetailProps> = (props: IS
|
||||
<H1 className="bp3-heading">
|
||||
{!!props.scene.title ? props.scene.title : TextUtils.fileNameFromPath(props.scene.path)}
|
||||
</H1>
|
||||
|
||||
{!!props.scene.date ? <H4>{props.scene.date}</H4> : undefined}
|
||||
{!!props.scene.rating ? <H6>Rating: {props.scene.rating}</H6> : undefined}
|
||||
{!!props.scene.file.height ? <H6>Resolution: {TextUtils.resolution(props.scene.file.height)}</H6> : undefined}
|
||||
|
||||
@@ -15,7 +15,6 @@ import {
|
||||
Popover,
|
||||
MenuItem,
|
||||
} from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent, useEffect, useState } from "react";
|
||||
import * as GQL from "../../../core/generated-graphql";
|
||||
import { StashService } from "../../../core/StashService";
|
||||
@@ -229,7 +228,7 @@ export const SceneEditPanel: FunctionComponent<IProps> = (props: IProps) => {
|
||||
}
|
||||
|
||||
function renderScraperMenu() {
|
||||
if (!queryableScrapers || queryableScrapers.length == 0) {
|
||||
if (!queryableScrapers || queryableScrapers.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -272,7 +271,7 @@ export const SceneEditPanel: FunctionComponent<IProps> = (props: IProps) => {
|
||||
setStudioId(scene.studio.id);
|
||||
}
|
||||
|
||||
if ((!performerIds || performerIds.length == 0) && scene.performers && scene.performers.length > 0) {
|
||||
if ((!performerIds || performerIds.length === 0) && scene.performers && scene.performers.length > 0) {
|
||||
let idPerfs = scene.performers.filter((p) => {
|
||||
return p.id !== undefined && p.id !== null;
|
||||
});
|
||||
@@ -283,7 +282,7 @@ export const SceneEditPanel: FunctionComponent<IProps> = (props: IProps) => {
|
||||
}
|
||||
}
|
||||
|
||||
if ((!tagIds || tagIds.length == 0) && scene.tags && scene.tags.length > 0) {
|
||||
if ((!tagIds || tagIds.length === 0) && scene.tags && scene.tags.length > 0) {
|
||||
let idTags = scene.tags.filter((p) => {
|
||||
return p.id !== undefined && p.id !== null;
|
||||
});
|
||||
@@ -395,7 +394,7 @@ export const SceneEditPanel: FunctionComponent<IProps> = (props: IProps) => {
|
||||
<span>Cover Image</span>
|
||||
</label>
|
||||
<Collapse isOpen={isCoverImageOpen}>
|
||||
<img className="scene-cover" src={coverImagePreview} />
|
||||
<img alt="Scene cover" className="scene-cover" src={coverImagePreview} />
|
||||
<FileInput text="Choose image..." onInputChange={onCoverImageChange} inputProps={{accept: ".jpg,.jpeg,.png"}} />
|
||||
</Collapse>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
Divider,
|
||||
FormGroup,
|
||||
H3,
|
||||
NumericInput,
|
||||
Tag,
|
||||
} from "@blueprintjs/core";
|
||||
import { Field, FieldProps, Form, Formik, FormikActions, FormikProps } from "formik";
|
||||
@@ -63,8 +62,8 @@ export const SceneMarkersPanel: FunctionComponent<ISceneMarkersPanelProps> = (pr
|
||||
<div key={marker.id}>
|
||||
<Divider />
|
||||
<div>
|
||||
<a onClick={() => onClickMarker(marker)}>{marker.title}</a>
|
||||
{!isEditorOpen ? <a style={{float: "right"}} onClick={() => onOpenEditor(marker)}>Edit</a> : undefined}
|
||||
<button className="button-link" onClick={() => onClickMarker(marker)}>{marker.title}</button>
|
||||
{!isEditorOpen ? <button className="button-link" style={{float: "right"}} onClick={() => onOpenEditor(marker)}>Edit</button> : undefined}
|
||||
</div>
|
||||
<div>
|
||||
{TextUtils.secondsToTimestamp(marker.seconds)}
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
Tree,
|
||||
ITreeNode,
|
||||
} from "@blueprintjs/core";
|
||||
import React, { FunctionComponent, useEffect, useState, useRef } from "react";
|
||||
import React, { FunctionComponent, useEffect, useState } from "react";
|
||||
import { IBaseProps } from "../../models";
|
||||
import { StashService } from "../../core/StashService";
|
||||
import * as GQL from "../../core/generated-graphql";
|
||||
@@ -449,19 +449,19 @@ export const SceneFilenameParser: FunctionComponent<IProps> = (props: IProps) =>
|
||||
return !r.studioId.set;
|
||||
});
|
||||
|
||||
if (newAllTitleSet != allTitleSet) {
|
||||
if (newAllTitleSet !== allTitleSet) {
|
||||
setAllTitleSet(newAllTitleSet);
|
||||
}
|
||||
if (newAllDateSet != allDateSet) {
|
||||
if (newAllDateSet !== allDateSet) {
|
||||
setAllDateSet(newAllDateSet);
|
||||
}
|
||||
if (newAllPerformerSet != allPerformerSet) {
|
||||
if (newAllPerformerSet !== allPerformerSet) {
|
||||
setAllTagSet(newAllPerformerSet);
|
||||
}
|
||||
if (newAllTagSet != allTagSet) {
|
||||
if (newAllTagSet !== allTagSet) {
|
||||
setAllTagSet(newAllTagSet);
|
||||
}
|
||||
if (newAllStudioSet != allStudioSet) {
|
||||
if (newAllStudioSet !== allStudioSet) {
|
||||
setAllStudioSet(newAllStudioSet);
|
||||
}
|
||||
}, [parserResult]);
|
||||
@@ -694,7 +694,7 @@ export const SceneFilenameParser: FunctionComponent<IProps> = (props: IProps) =>
|
||||
<FormGroup
|
||||
label="Filename pattern:"
|
||||
inline={true}
|
||||
helperText="Use '\\' to escape literal {} characters"
|
||||
helperText="Use '\' to escape literal {} characters"
|
||||
>
|
||||
<InputGroup
|
||||
onChange={(newValue: any) => setPattern(newValue.target.value)}
|
||||
@@ -1071,7 +1071,7 @@ export const SceneFilenameParser: FunctionComponent<IProps> = (props: IProps) =>
|
||||
}
|
||||
|
||||
function renderTable() {
|
||||
if (parserResult.length == 0) { return undefined; }
|
||||
if (parserResult.length === 0) { return undefined; }
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import _ from "lodash";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import { IBaseProps } from "../../models/base-props";
|
||||
import { SceneList } from "./SceneList";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Hotkey, Hotkeys, HotkeysTarget } from "@blueprintjs/core";
|
||||
import React, { Component, FunctionComponent } from "react";
|
||||
import React, { FunctionComponent } from "react";
|
||||
import ReactJWPlayer from "react-jw-player";
|
||||
import * as GQL from "../../../core/generated-graphql";
|
||||
import { SceneHelpers } from "../helpers";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import axios from "axios";
|
||||
import React, { CSSProperties, FunctionComponent, RefObject, useEffect, useRef, useState } from "react";
|
||||
import React, { CSSProperties, FunctionComponent, useEffect, useRef, useState } from "react";
|
||||
import * as GQL from "../../../core/generated-graphql";
|
||||
import { TextUtils } from "../../../utils/text";
|
||||
import "./ScenePlayerScrubber.scss";
|
||||
@@ -55,7 +55,6 @@ export const ScenePlayerScrubber: FunctionComponent<IScenePlayerScrubberProps> =
|
||||
}
|
||||
|
||||
const [spriteItems, setSpriteItems] = useState<ISceneSpriteItem[]>([]);
|
||||
const [delayedRender, setDelayedRender] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!scrubberSliderEl.current) { return; }
|
||||
@@ -63,6 +62,47 @@ export const ScenePlayerScrubber: FunctionComponent<IScenePlayerScrubberProps> =
|
||||
}, [scrubberSliderEl]);
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchSpriteInfo() {
|
||||
if (!props.scene || !props.scene.paths.vtt) { return; }
|
||||
|
||||
const response = await axios.get<string>(props.scene.paths.vtt, {responseType: "text"});
|
||||
if (response.status !== 200) {
|
||||
console.log(response.statusText);
|
||||
}
|
||||
|
||||
// TODO: This is gnarly
|
||||
const lines = response.data.split("\n");
|
||||
if (lines.shift() !== "WEBVTT") { return; }
|
||||
if (lines.shift() !== "") { return; }
|
||||
let item: ISceneSpriteItem = {start: 0, end: 0, x: 0, y: 0, w: 0, h: 0};
|
||||
const newSpriteItems: ISceneSpriteItem[] = [];
|
||||
while (lines.length) {
|
||||
const line = lines.shift();
|
||||
if (line === undefined) { continue; }
|
||||
|
||||
if (line.includes("#") && line.includes("=") && line.includes(",")) {
|
||||
const size = line.split("#")[1].split("=")[1].split(",");
|
||||
item.x = Number(size[0]);
|
||||
item.y = Number(size[1]);
|
||||
item.w = Number(size[2]);
|
||||
item.h = Number(size[3]);
|
||||
|
||||
newSpriteItems.push(item);
|
||||
item = {start: 0, end: 0, x: 0, y: 0, w: 0, h: 0};
|
||||
} else if (line.includes(" --> ")) {
|
||||
const times = line.split(" --> ");
|
||||
|
||||
const start = times[0].split(":");
|
||||
item.start = (+start[0]) * 60 * 60 + (+start[1]) * 60 + (+start[2]);
|
||||
|
||||
const end = times[1].split(":");
|
||||
item.end = (+end[0]) * 60 * 60 + (+end[1]) * 60 + (+end[2]);
|
||||
}
|
||||
}
|
||||
|
||||
setSpriteItems(newSpriteItems);
|
||||
}
|
||||
|
||||
fetchSpriteInfo();
|
||||
}, [props.scene]);
|
||||
|
||||
@@ -77,30 +117,20 @@ export const ScenePlayerScrubber: FunctionComponent<IScenePlayerScrubberProps> =
|
||||
}, [props.position]);
|
||||
|
||||
useEffect(() => {
|
||||
let element = contentEl.current;
|
||||
if (!element) { return; }
|
||||
element.addEventListener("mousedown", onMouseDown, false);
|
||||
element.addEventListener("mousemove", onMouseMove, false);
|
||||
window.addEventListener("mouseup", onMouseUp, false);
|
||||
|
||||
return () => {
|
||||
if (!element) { return; }
|
||||
element.removeEventListener("mousedown", onMouseDown);
|
||||
element.removeEventListener("mousemove", onMouseMove);
|
||||
window.removeEventListener("mouseup", onMouseUp);
|
||||
};
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!contentEl.current) { return; }
|
||||
contentEl.current.addEventListener("mousedown", onMouseDown, false);
|
||||
return () => {
|
||||
if (!contentEl.current) { return; }
|
||||
contentEl.current.removeEventListener("mousedown", onMouseDown);
|
||||
};
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!contentEl.current) { return; }
|
||||
contentEl.current.addEventListener("mousemove", onMouseMove, false);
|
||||
return () => {
|
||||
if (!contentEl.current) { return; }
|
||||
contentEl.current.removeEventListener("mousemove", onMouseMove);
|
||||
};
|
||||
});
|
||||
|
||||
function onMouseUp(this: Window, event: MouseEvent) {
|
||||
if (!startMouseEvent.current || !scrubberSliderEl.current) { return; }
|
||||
mouseDown.current = false;
|
||||
@@ -170,51 +200,6 @@ export const ScenePlayerScrubber: FunctionComponent<IScenePlayerScrubberProps> =
|
||||
setPosition(newPosition);
|
||||
}
|
||||
|
||||
async function fetchSpriteInfo() {
|
||||
if (!props.scene || !props.scene.paths.vtt) { return; }
|
||||
|
||||
const response = await axios.get<string>(props.scene.paths.vtt, {responseType: "text"});
|
||||
if (response.status !== 200) {
|
||||
console.log(response.statusText);
|
||||
}
|
||||
|
||||
// TODO: This is gnarly
|
||||
const lines = response.data.split("\n");
|
||||
if (lines.shift() !== "WEBVTT") { return; }
|
||||
if (lines.shift() !== "") { return; }
|
||||
let item: ISceneSpriteItem = {start: 0, end: 0, x: 0, y: 0, w: 0, h: 0};
|
||||
const newSpriteItems: ISceneSpriteItem[] = [];
|
||||
while (lines.length) {
|
||||
const line = lines.shift();
|
||||
if (line === undefined) { continue; }
|
||||
|
||||
if (line.includes("#") && line.includes("=") && line.includes(",")) {
|
||||
const size = line.split("#")[1].split("=")[1].split(",");
|
||||
item.x = Number(size[0]);
|
||||
item.y = Number(size[1]);
|
||||
item.w = Number(size[2]);
|
||||
item.h = Number(size[3]);
|
||||
|
||||
newSpriteItems.push(item);
|
||||
item = {start: 0, end: 0, x: 0, y: 0, w: 0, h: 0};
|
||||
} else if (line.includes(" --> ")) {
|
||||
const times = line.split(" --> ");
|
||||
|
||||
const start = times[0].split(":");
|
||||
item.start = (+start[0]) * 60 * 60 + (+start[1]) * 60 + (+start[2]);
|
||||
|
||||
const end = times[1].split(":");
|
||||
item.end = (+end[0]) * 60 * 60 + (+end[1]) * 60 + (+end[2]);
|
||||
}
|
||||
}
|
||||
|
||||
setSpriteItems(newSpriteItems);
|
||||
// TODO: Very hacky. Need to wait for the scroll width to update from the image loading.
|
||||
setTimeout(() => {
|
||||
setDelayedRender(true);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function renderTags() {
|
||||
function getTagStyle(i: number): CSSProperties {
|
||||
if (!scrubberSliderEl.current ||
|
||||
@@ -296,7 +281,7 @@ export const ScenePlayerScrubber: FunctionComponent<IScenePlayerScrubberProps> =
|
||||
|
||||
return (
|
||||
<div className="scrubber-wrapper">
|
||||
<a className="scrubber-button" id="scrubber-back" onClick={() => goBack()}><</a>
|
||||
<button className="scrubber-button" id="scrubber-back" onClick={() => goBack()}><</button>
|
||||
<div ref={contentEl} className="scrubber-content">
|
||||
<div className="scrubber-tags-background" />
|
||||
<div ref={positionIndicatorEl} id="scrubber-position-indicator" />
|
||||
@@ -310,7 +295,7 @@ export const ScenePlayerScrubber: FunctionComponent<IScenePlayerScrubberProps> =
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a className="scrubber-button" id="scrubber-forward" onClick={() => goForward()}>></a>
|
||||
<button className="scrubber-button" id="scrubber-forward" onClick={() => goForward()}>></button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
import _ from "lodash";
|
||||
import {
|
||||
AnchorButton,
|
||||
Button,
|
||||
ButtonGroup,
|
||||
ControlGroup,
|
||||
FormGroup,
|
||||
HTMLSelect,
|
||||
InputGroup,
|
||||
Menu,
|
||||
MenuItem,
|
||||
Popover,
|
||||
Spinner,
|
||||
Tag,
|
||||
} from "@blueprintjs/core";
|
||||
import React, { FunctionComponent, SyntheticEvent, useEffect, useRef, useState } from "react";
|
||||
import React, { FunctionComponent, useEffect, useState } from "react";
|
||||
import { FilterSelect } from "../select/FilterSelect";
|
||||
import { FilterMultiSelect } from "../select/FilterMultiSelect";
|
||||
import { StashService } from "../../core/StashService";
|
||||
@@ -106,7 +99,7 @@ export const SceneSelectedOptions: FunctionComponent<IListOperationProps> = (pro
|
||||
async function onSave() {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const result = await updateScenes();
|
||||
await updateScenes();
|
||||
ToastUtils.success("Updated scenes");
|
||||
} catch (e) {
|
||||
ErrorUtils.handle(e);
|
||||
@@ -143,7 +136,7 @@ export const SceneSelectedOptions: FunctionComponent<IListOperationProps> = (pro
|
||||
first = false;
|
||||
} else {
|
||||
var studioId = scene.studio ? scene.studio.id : undefined;
|
||||
if (ret != studioId) {
|
||||
if (ret !== studioId) {
|
||||
ret = undefined;
|
||||
}
|
||||
}
|
||||
@@ -221,7 +214,7 @@ export const SceneSelectedOptions: FunctionComponent<IListOperationProps> = (pro
|
||||
if (rating !== thisRating) {
|
||||
rating = "";
|
||||
}
|
||||
if (studioId != thisStudio) {
|
||||
if (studioId !== thisStudio) {
|
||||
studioId = undefined;
|
||||
}
|
||||
const perfIds = !!scene.performers ? scene.performers.map(toId).sort() : [];
|
||||
|
||||
@@ -120,7 +120,7 @@ export const FilterMultiSelect: React.FunctionComponent<IProps> = (props: IProps
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw "Unhandled case in FilterMultiSelect";
|
||||
throw new Error("Unhandled case in FilterMultiSelect");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ export const FilterSelect: React.FunctionComponent<IProps> = (props: IProps) =>
|
||||
};
|
||||
|
||||
function onItemSelect(item: ValidTypes | undefined) {
|
||||
if (item && item.id == "0") {
|
||||
if (item && item.id === "0") {
|
||||
item = undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from "react";
|
||||
|
||||
import { MenuItem } from "@blueprintjs/core";
|
||||
import { ItemPredicate, ItemRenderer, Suggest } from "@blueprintjs/select";
|
||||
import { ItemRenderer, Suggest } from "@blueprintjs/select";
|
||||
import * as GQL from "../../core/generated-graphql";
|
||||
import { StashService } from "../../core/StashService";
|
||||
import { HTMLInputProps } from "../../models";
|
||||
|
||||
@@ -50,7 +50,7 @@ export const ValidGalleriesSelect: React.FunctionComponent<IProps> = (props: IPr
|
||||
};
|
||||
|
||||
function onItemSelect(item: GQL.ValidGalleriesForSceneValidGalleriesForScene | undefined) {
|
||||
if (item && item.id == "0") {
|
||||
if (item && item.id === "0") {
|
||||
item = undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -195,15 +195,15 @@ export class StashService {
|
||||
});
|
||||
}
|
||||
|
||||
public static useFindGallery(id: string) { return GQL.useFindGallery({variables: {id}}); }
|
||||
public static useFindScene(id: string) { return GQL.useFindScene({variables: {id}}); }
|
||||
public static useFindGallery(id: string) { return GQL.useFindGallery({ variables: { id } }); }
|
||||
public static useFindScene(id: string) { return GQL.useFindScene({ variables: { id } }); }
|
||||
public static useFindPerformer(id: string) {
|
||||
const skip = id === "new" ? true : false;
|
||||
return GQL.useFindPerformer({variables: {id}, skip});
|
||||
return GQL.useFindPerformer({ variables: { id }, skip });
|
||||
}
|
||||
public static useFindStudio(id: string) {
|
||||
const skip = id === "new" ? true : false;
|
||||
return GQL.useFindStudio({variables: {id}, skip});
|
||||
return GQL.useFindStudio({ variables: { id }, skip });
|
||||
}
|
||||
|
||||
// TODO - scene marker manipulation functions are handled differently
|
||||
@@ -215,27 +215,27 @@ export class StashService {
|
||||
];
|
||||
|
||||
public static useSceneMarkerCreate() {
|
||||
return GQL.useSceneMarkerCreate({ refetchQueries: ["FindScene"] });
|
||||
return GQL.useSceneMarkerCreate({ refetchQueries: ["FindScene"] });
|
||||
}
|
||||
public static useSceneMarkerUpdate() {
|
||||
return GQL.useSceneMarkerUpdate({ refetchQueries: ["FindScene"] });
|
||||
public static useSceneMarkerUpdate() {
|
||||
return GQL.useSceneMarkerUpdate({ refetchQueries: ["FindScene"] });
|
||||
}
|
||||
public static useSceneMarkerDestroy() {
|
||||
return GQL.useSceneMarkerDestroy({ refetchQueries: ["FindScene"] });
|
||||
return GQL.useSceneMarkerDestroy({ refetchQueries: ["FindScene"] });
|
||||
}
|
||||
|
||||
public static useListPerformerScrapers() {
|
||||
return GQL.useListPerformerScrapers();
|
||||
public static useListPerformerScrapers() {
|
||||
return GQL.useListPerformerScrapers();
|
||||
}
|
||||
public static useScrapePerformerList(scraperId: string, q : string) {
|
||||
return GQL.useScrapePerformerList({ variables: { scraper_id: scraperId, query: q }});
|
||||
public static useScrapePerformerList(scraperId: string, q: string) {
|
||||
return GQL.useScrapePerformerList({ variables: { scraper_id: scraperId, query: q } });
|
||||
}
|
||||
public static useScrapePerformer(scraperId: string, scrapedPerformer : GQL.ScrapedPerformerInput) {
|
||||
return GQL.useScrapePerformer({ variables: { scraper_id: scraperId, scraped_performer: scrapedPerformer }});
|
||||
public static useScrapePerformer(scraperId: string, scrapedPerformer: GQL.ScrapedPerformerInput) {
|
||||
return GQL.useScrapePerformer({ variables: { scraper_id: scraperId, scraped_performer: scrapedPerformer } });
|
||||
}
|
||||
|
||||
public static useListSceneScrapers() {
|
||||
return GQL.useListSceneScrapers();
|
||||
public static useListSceneScrapers() {
|
||||
return GQL.useListSceneScrapers();
|
||||
}
|
||||
|
||||
public static useScrapeFreeonesPerformers(q: string) { return GQL.useScrapeFreeonesPerformers({ variables: { q } }); }
|
||||
@@ -245,13 +245,14 @@ export class StashService {
|
||||
public static useAllPerformersForFilter() { return GQL.useAllPerformersForFilter(); }
|
||||
public static useAllStudiosForFilter() { return GQL.useAllStudiosForFilter(); }
|
||||
public static useValidGalleriesForScene(sceneId: string) {
|
||||
return GQL.useValidGalleriesForScene({variables: {scene_id: sceneId}});
|
||||
return GQL.useValidGalleriesForScene({ variables: { scene_id: sceneId } });
|
||||
}
|
||||
public static useStats() { return GQL.useStats(); }
|
||||
public static useVersion() { return GQL.useVersion(); }
|
||||
public static useLatestVersion() { return GQL.useLatestVersion({ notifyOnNetworkStatusChange: true, errorPolicy: 'ignore' }); }
|
||||
|
||||
public static useConfiguration() { return GQL.useConfiguration(); }
|
||||
public static useDirectories(path?: string) { return GQL.useDirectories({ variables: { path }}); }
|
||||
public static useDirectories(path?: string) { return GQL.useDirectories({ variables: { path } }); }
|
||||
|
||||
private static performerMutationImpactedQueries = [
|
||||
"findPerformers",
|
||||
@@ -260,6 +261,7 @@ export class StashService {
|
||||
"allPerformers"
|
||||
];
|
||||
|
||||
|
||||
public static usePerformerCreate() {
|
||||
return GQL.usePerformerCreate({
|
||||
update: () => StashService.invalidateQueries(StashService.performerMutationImpactedQueries)
|
||||
@@ -286,7 +288,7 @@ export class StashService {
|
||||
];
|
||||
|
||||
public static useSceneUpdate(input: GQL.SceneUpdateInput) {
|
||||
return GQL.useSceneUpdate({
|
||||
return GQL.useSceneUpdate({
|
||||
variables: input,
|
||||
update: () => StashService.invalidateQueries(StashService.sceneMutationImpactedQueries),
|
||||
refetchQueries: ["AllTagsForFilter"]
|
||||
@@ -303,18 +305,36 @@ export class StashService {
|
||||
];
|
||||
|
||||
public static useBulkSceneUpdate(input: GQL.BulkSceneUpdateInput) {
|
||||
return GQL.useBulkSceneUpdate({
|
||||
variables: input,
|
||||
return GQL.useBulkSceneUpdate({
|
||||
variables: input,
|
||||
update: () => StashService.invalidateQueries(StashService.sceneBulkMutationImpactedQueries)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static useScenesUpdate(input: GQL.SceneUpdateInput[]) {
|
||||
return GQL.useScenesUpdate({ variables: { input : input }});
|
||||
return GQL.useScenesUpdate({ variables: { input: input } });
|
||||
}
|
||||
|
||||
public static useSceneIncrementO(id: string) {
|
||||
return GQL.useSceneIncrementO({
|
||||
variables: {id: id}
|
||||
});
|
||||
}
|
||||
|
||||
public static useSceneDecrementO(id: string) {
|
||||
return GQL.useSceneDecrementO({
|
||||
variables: {id: id}
|
||||
});
|
||||
}
|
||||
|
||||
public static useSceneResetO(id: string) {
|
||||
return GQL.useSceneResetO({
|
||||
variables: {id: id}
|
||||
});
|
||||
}
|
||||
|
||||
public static useSceneDestroy(input: GQL.SceneDestroyInput) {
|
||||
return GQL.useSceneDestroy({
|
||||
return GQL.useSceneDestroy({
|
||||
variables: input,
|
||||
update: () => StashService.invalidateQueries(StashService.sceneMutationImpactedQueries)
|
||||
});
|
||||
@@ -327,22 +347,22 @@ export class StashService {
|
||||
];
|
||||
|
||||
public static useStudioCreate(input: GQL.StudioCreateInput) {
|
||||
return GQL.useStudioCreate({
|
||||
return GQL.useStudioCreate({
|
||||
variables: input,
|
||||
update: () => StashService.invalidateQueries(StashService.studioMutationImpactedQueries)
|
||||
});
|
||||
}
|
||||
|
||||
public static useStudioUpdate(input: GQL.StudioUpdateInput) {
|
||||
return GQL.useStudioUpdate({
|
||||
return GQL.useStudioUpdate({
|
||||
variables: input,
|
||||
update: () => StashService.invalidateQueries(StashService.studioMutationImpactedQueries)
|
||||
});
|
||||
}
|
||||
|
||||
public static useStudioDestroy(input: GQL.StudioDestroyInput) {
|
||||
return GQL.useStudioDestroy({
|
||||
variables: input,
|
||||
return GQL.useStudioDestroy({
|
||||
variables: input,
|
||||
update: () => StashService.invalidateQueries(StashService.studioMutationImpactedQueries)
|
||||
});
|
||||
}
|
||||
@@ -355,22 +375,22 @@ export class StashService {
|
||||
];
|
||||
|
||||
public static useTagCreate(input: GQL.TagCreateInput) {
|
||||
return GQL.useTagCreate({
|
||||
variables: input,
|
||||
return GQL.useTagCreate({
|
||||
variables: input,
|
||||
refetchQueries: ["AllTags"],
|
||||
update: () => StashService.invalidateQueries(StashService.tagMutationImpactedQueries)
|
||||
});
|
||||
}
|
||||
public static useTagUpdate(input: GQL.TagUpdateInput) {
|
||||
return GQL.useTagUpdate({
|
||||
variables: input,
|
||||
return GQL.useTagUpdate({
|
||||
variables: input,
|
||||
refetchQueries: ["AllTags"],
|
||||
update: () => StashService.invalidateQueries(StashService.tagMutationImpactedQueries)
|
||||
});
|
||||
}
|
||||
public static useTagDestroy(input: GQL.TagDestroyInput) {
|
||||
return GQL.useTagDestroy({
|
||||
variables: input,
|
||||
return GQL.useTagDestroy({
|
||||
variables: input,
|
||||
refetchQueries: ["AllTags"],
|
||||
update: () => StashService.invalidateQueries(StashService.tagMutationImpactedQueries)
|
||||
});
|
||||
@@ -506,14 +526,14 @@ export class StashService {
|
||||
public static querySceneByPathRegex(filter: GQL.FindFilterType) {
|
||||
return StashService.client.query<GQL.FindScenesByPathRegexQuery>({
|
||||
query: GQL.FindScenesByPathRegexDocument,
|
||||
variables: {filter: filter},
|
||||
variables: { filter: filter },
|
||||
});
|
||||
}
|
||||
|
||||
public static queryParseSceneFilenames(filter: GQL.FindFilterType, config: GQL.SceneParserInput) {
|
||||
return StashService.client.query<GQL.ParseSceneFilenamesQuery>({
|
||||
query: GQL.ParseSceneFilenamesDocument,
|
||||
variables: {filter: filter, config: config},
|
||||
variables: { filter: filter, config: config },
|
||||
fetchPolicy: "network-only",
|
||||
});
|
||||
}
|
||||
@@ -531,5 +551,5 @@ export class StashService {
|
||||
return value;
|
||||
}
|
||||
|
||||
private constructor() {}
|
||||
private constructor() { }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Spinner } from "@blueprintjs/core";
|
||||
import _ from "lodash";
|
||||
import queryString from "query-string";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState, useRef } from "react";
|
||||
import { QueryHookResult } from "react-apollo-hooks";
|
||||
import { ListFilter } from "../components/list/ListFilter";
|
||||
import { Pagination } from "../components/list/Pagination";
|
||||
@@ -10,6 +10,7 @@ import { IBaseProps } from "../models";
|
||||
import { Criterion } from "../models/list-filter/criteria/criterion";
|
||||
import { ListFilterModel } from "../models/list-filter/filter";
|
||||
import { DisplayMode, FilterMode } from "../models/list-filter/types";
|
||||
import { useInterfaceLocalForage } from "./LocalForage";
|
||||
|
||||
export interface IListHookData {
|
||||
filter: ListFilterModel;
|
||||
@@ -23,6 +24,66 @@ interface IListHookOperation {
|
||||
onClick: (result: QueryHookResult<any, any>, filter: ListFilterModel, selectedIds: Set<string>) => void;
|
||||
}
|
||||
|
||||
export interface IFilterListImpl {
|
||||
getData: (filter : ListFilterModel) => QueryHookResult<any, any>;
|
||||
getItems: (data: any) => any[];
|
||||
getCount: (data: any) => number;
|
||||
}
|
||||
|
||||
const SceneFilterListImpl: IFilterListImpl = {
|
||||
getData: (filter : ListFilterModel) => { return StashService.useFindScenes(filter); },
|
||||
getItems: (data: any) => { return !!data && !!data.findScenes ? data.findScenes.scenes : []; },
|
||||
getCount: (data: any) => { return !!data && !!data.findScenes ? data.findScenes.count : 0; }
|
||||
}
|
||||
|
||||
const SceneMarkerFilterListImpl: IFilterListImpl = {
|
||||
getData: (filter : ListFilterModel) => { return StashService.useFindSceneMarkers(filter); },
|
||||
getItems: (data: any) => { return !!data && !!data.findSceneMarkers ? data.findSceneMarkers.scene_markers : []; },
|
||||
getCount: (data: any) => { return !!data && !!data.findSceneMarkers ? data.findSceneMarkers.count : 0; }
|
||||
}
|
||||
|
||||
const GalleryFilterListImpl: IFilterListImpl = {
|
||||
getData: (filter : ListFilterModel) => { return StashService.useFindGalleries(filter); },
|
||||
getItems: (data: any) => { return !!data && !!data.findGalleries ? data.findGalleries.galleries : []; },
|
||||
getCount: (data: any) => { return !!data && !!data.findGalleries ? data.findGalleries.count : 0; }
|
||||
}
|
||||
|
||||
const StudioFilterListImpl: IFilterListImpl = {
|
||||
getData: (filter : ListFilterModel) => { return StashService.useFindStudios(filter); },
|
||||
getItems: (data: any) => { return !!data && !!data.findStudios ? data.findStudios.studios : []; },
|
||||
getCount: (data: any) => { return !!data && !!data.findStudios ? data.findStudios.count : 0; }
|
||||
}
|
||||
|
||||
const PerformerFilterListImpl: IFilterListImpl = {
|
||||
getData: (filter : ListFilterModel) => { return StashService.useFindPerformers(filter); },
|
||||
getItems: (data: any) => { return !!data && !!data.findPerformers ? data.findPerformers.performers : []; },
|
||||
getCount: (data: any) => { return !!data && !!data.findPerformers ? data.findPerformers.count : 0; }
|
||||
}
|
||||
|
||||
function getFilterListImpl(filterMode: FilterMode) {
|
||||
switch (filterMode) {
|
||||
case FilterMode.Scenes: {
|
||||
return SceneFilterListImpl;
|
||||
}
|
||||
case FilterMode.SceneMarkers: {
|
||||
return SceneMarkerFilterListImpl;
|
||||
}
|
||||
case FilterMode.Galleries: {
|
||||
return GalleryFilterListImpl;
|
||||
}
|
||||
case FilterMode.Studios: {
|
||||
return StudioFilterListImpl;
|
||||
}
|
||||
case FilterMode.Performers: {
|
||||
return PerformerFilterListImpl;
|
||||
}
|
||||
default: {
|
||||
console.error("REMOVE DEFAULT IN LIST HOOK");
|
||||
return SceneFilterListImpl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface IListHookOptions {
|
||||
filterMode: FilterMode;
|
||||
subComponent?: boolean;
|
||||
@@ -34,6 +95,21 @@ export interface IListHookOptions {
|
||||
renderSelectedOptions?: (result: QueryHookResult<any, any>, selectedIds: Set<string>) => JSX.Element | undefined;
|
||||
}
|
||||
|
||||
function updateFromQueryString(queryStr: string, setFilter: (value: React.SetStateAction<ListFilterModel>) => void, forageData?: any) {
|
||||
const queryParams = queryString.parse(queryStr);
|
||||
setFilter((f) => {
|
||||
const newFilter = _.cloneDeep(f);
|
||||
newFilter.configureFromQueryParameters(queryParams);
|
||||
|
||||
if (forageData) {
|
||||
const forageParams = queryString.parse(forageData.filter);
|
||||
newFilter.overridePrefs(queryParams, forageParams);
|
||||
}
|
||||
|
||||
return newFilter;
|
||||
});
|
||||
}
|
||||
|
||||
export class ListHook {
|
||||
public static useList(options: IListHookOptions): IListHookData {
|
||||
const [filter, setFilter] = useState<ListFilterModel>(new ListFilterModel(options.filterMode));
|
||||
@@ -42,19 +118,64 @@ export class ListHook {
|
||||
const [totalCount, setTotalCount] = useState<number>(0);
|
||||
const [zoomIndex, setZoomIndex] = useState<number>(1);
|
||||
|
||||
// Update the filter when the query parameters change
|
||||
// don't use query parameters for sub-components
|
||||
if (!options.subComponent) {
|
||||
useEffect(() => {
|
||||
const queryParams = queryString.parse(options.props!.location.search);
|
||||
const newFilter = _.cloneDeep(filter);
|
||||
newFilter.configureFromQueryParameters(queryParams);
|
||||
setFilter(newFilter);
|
||||
const [interfaceForage, setInterfaceForage] = useInterfaceLocalForage();
|
||||
const forageInitialised = useRef<boolean>(false);
|
||||
|
||||
// TODO: Need this side effect to update the query params properly
|
||||
filter.configureFromQueryParameters(queryParams);
|
||||
}, [options.props.location.search]);
|
||||
}
|
||||
const filterListImpl = getFilterListImpl(options.filterMode);
|
||||
|
||||
// Initialise from interface forage when loaded
|
||||
useEffect(() => {
|
||||
function updateFromLocalForage(queryData: any) {
|
||||
const queryParams = queryString.parse(queryData.filter);
|
||||
|
||||
setFilter((f) => {
|
||||
const newFilter = _.cloneDeep(f);
|
||||
newFilter.configureFromQueryParameters(queryParams);
|
||||
newFilter.currentPage = queryData.currentPage;
|
||||
newFilter.itemsPerPage = queryData.itemsPerPage;
|
||||
return newFilter;
|
||||
});
|
||||
}
|
||||
|
||||
function initialise() {
|
||||
forageInitialised.current = true;
|
||||
|
||||
let forageData: any;
|
||||
|
||||
if (interfaceForage.data && interfaceForage.data.queries[options.filterMode]) {
|
||||
forageData = interfaceForage.data.queries[options.filterMode];
|
||||
}
|
||||
|
||||
if (!options.props!.location.search && forageData) {
|
||||
// we have some data, try to load it
|
||||
updateFromLocalForage(forageData);
|
||||
} else {
|
||||
// use query string instead - include the forageData to include the following
|
||||
// preferences if not specified: displayMode, itemsPerPage, sortBy and sortDir
|
||||
updateFromQueryString(options.props!.location.search, setFilter, forageData);
|
||||
}
|
||||
}
|
||||
|
||||
// don't use query parameters for sub-components
|
||||
if (!options.subComponent) {
|
||||
// initialise once when the forage is loaded
|
||||
if (!forageInitialised.current && !interfaceForage.loading) {
|
||||
initialise();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, [interfaceForage.data, interfaceForage.loading, options.props, options.filterMode, options.subComponent]);
|
||||
|
||||
// Update the filter when the query parameters change
|
||||
useEffect(() => {
|
||||
// don't use query parameters for sub-components
|
||||
if (!options.subComponent) {
|
||||
// only update from the URL if the forage is initialised
|
||||
if (forageInitialised.current) {
|
||||
updateFromQueryString(options.props!.location.search, setFilter);
|
||||
}
|
||||
}
|
||||
}, [options.props, options.filterMode, options.subComponent]);
|
||||
|
||||
function getFilter() {
|
||||
if (!options.filterHook) {
|
||||
@@ -66,78 +187,43 @@ export class ListHook {
|
||||
return options.filterHook(newFilter);
|
||||
}
|
||||
|
||||
let result: QueryHookResult<any, any>;
|
||||
|
||||
let getData: (filter : ListFilterModel) => QueryHookResult<any, any>;
|
||||
let getItems: () => any[];
|
||||
let getCount: () => number;
|
||||
|
||||
switch (options.filterMode) {
|
||||
case FilterMode.Scenes: {
|
||||
getData = (filter : ListFilterModel) => { return StashService.useFindScenes(filter); }
|
||||
getItems = () => { return !!result.data && !!result.data.findScenes ? result.data.findScenes.scenes : []; }
|
||||
getCount = () => { return !!result.data && !!result.data.findScenes ? result.data.findScenes.count : 0; }
|
||||
break;
|
||||
}
|
||||
case FilterMode.SceneMarkers: {
|
||||
getData = (filter : ListFilterModel) => { return StashService.useFindSceneMarkers(filter); }
|
||||
getItems = () => { return !!result.data && !!result.data.findSceneMarkers ? result.data.findSceneMarkers.scene_markers : []; }
|
||||
getCount = () => { return !!result.data && !!result.data.findSceneMarkers ? result.data.findSceneMarkers.count : 0; }
|
||||
break;
|
||||
}
|
||||
case FilterMode.Galleries: {
|
||||
getData = (filter : ListFilterModel) => { return StashService.useFindGalleries(filter); }
|
||||
getItems = () => { return !!result.data && !!result.data.findGalleries ? result.data.findGalleries.galleries : []; }
|
||||
getCount = () => { return !!result.data && !!result.data.findGalleries ? result.data.findGalleries.count : 0; }
|
||||
break;
|
||||
}
|
||||
case FilterMode.Studios: {
|
||||
getData = (filter : ListFilterModel) => { return StashService.useFindStudios(filter); }
|
||||
getItems = () => { return !!result.data && !!result.data.findStudios ? result.data.findStudios.studios : []; }
|
||||
getCount = () => { return !!result.data && !!result.data.findStudios ? result.data.findStudios.count : 0; }
|
||||
break;
|
||||
}
|
||||
case FilterMode.Performers: {
|
||||
getData = (filter : ListFilterModel) => { return StashService.useFindPerformers(filter); }
|
||||
getItems = () => { return !!result.data && !!result.data.findPerformers ? result.data.findPerformers.performers : []; }
|
||||
getCount = () => { return !!result.data && !!result.data.findPerformers ? result.data.findPerformers.count : 0; }
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
console.error("REMOVE DEFAULT IN LIST HOOK");
|
||||
getData = (filter : ListFilterModel) => { return StashService.useFindScenes(filter); }
|
||||
getItems = () => { return !!result.data && !!result.data.findScenes ? result.data.findScenes.scenes : []; }
|
||||
getCount = () => { return !!result.data && !!result.data.findScenes ? result.data.findScenes.count : 0; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
result = getData(getFilter());
|
||||
const result = filterListImpl.getData(getFilter());
|
||||
|
||||
useEffect(() => {
|
||||
setTotalCount(getCount());
|
||||
setTotalCount(filterListImpl.getCount(result.data));
|
||||
|
||||
// select none when data changes
|
||||
onSelectNone();
|
||||
setLastClickedId(undefined);
|
||||
}, [result.data])
|
||||
}, [result.data, filterListImpl])
|
||||
|
||||
// Update the query parameters when the data changes
|
||||
// don't use query parameters for sub-components
|
||||
if (!options.subComponent) {
|
||||
useEffect(() => {
|
||||
const location = Object.assign({}, options.props.history.location);
|
||||
location.search = filter.makeQueryParameters();
|
||||
options.props.history.replace(location);
|
||||
}, [result.data, filter.displayMode]);
|
||||
}
|
||||
|
||||
// Update the total count
|
||||
|
||||
useEffect(() => {
|
||||
const newFilter = _.cloneDeep(filter);
|
||||
newFilter.totalCount = totalCount;
|
||||
setFilter(newFilter);
|
||||
}, [totalCount]);
|
||||
// don't use query parameters for sub-components
|
||||
if (!options.subComponent) {
|
||||
// don't update this until local forage is loaded
|
||||
if (forageInitialised.current) {
|
||||
const location = Object.assign({}, options.props.history.location);
|
||||
const includePrefs = true;
|
||||
location.search = "?" + filter.makeQueryParameters(includePrefs);
|
||||
|
||||
if (location.search !== options.props.history.location.search) {
|
||||
options.props.history.replace(location);
|
||||
}
|
||||
|
||||
setInterfaceForage((d) => {
|
||||
const dataClone = _.cloneDeep(d);
|
||||
dataClone!.queries[options.filterMode] = {
|
||||
filter: location.search,
|
||||
itemsPerPage: filter.itemsPerPage,
|
||||
currentPage: filter.currentPage
|
||||
};
|
||||
return dataClone;
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [result.data, filter, options.subComponent, options.filterMode, options.props.history, setInterfaceForage]);
|
||||
|
||||
function onChangePageSize(pageSize: number) {
|
||||
const newFilter = _.cloneDeep(filter);
|
||||
@@ -235,12 +321,12 @@ export class ListHook {
|
||||
let thisIndex = -1;
|
||||
|
||||
if (!!lastClickedId) {
|
||||
startIndex = getItems().findIndex((item) => {
|
||||
startIndex = filterListImpl.getItems(result.data).findIndex((item) => {
|
||||
return item.id === lastClickedId;
|
||||
});
|
||||
}
|
||||
|
||||
thisIndex = getItems().findIndex((item) => {
|
||||
thisIndex = filterListImpl.getItems(result.data).findIndex((item) => {
|
||||
return item.id === id;
|
||||
});
|
||||
|
||||
@@ -254,7 +340,7 @@ export class ListHook {
|
||||
endIndex = tmp;
|
||||
}
|
||||
|
||||
const subset = getItems().slice(startIndex, endIndex + 1);
|
||||
const subset = filterListImpl.getItems(result.data).slice(startIndex, endIndex + 1);
|
||||
const newSelectedIds : Set<string> = new Set();
|
||||
|
||||
subset.forEach((item) => {
|
||||
@@ -266,7 +352,7 @@ export class ListHook {
|
||||
|
||||
function onSelectAll() {
|
||||
const newSelectedIds : Set<string> = new Set();
|
||||
getItems().forEach((item) => {
|
||||
filterListImpl.getItems(result.data).forEach((item) => {
|
||||
newSelectedIds.add(item.id);
|
||||
});
|
||||
|
||||
@@ -293,36 +379,61 @@ export class ListHook {
|
||||
}
|
||||
}) : undefined;
|
||||
|
||||
const template = (
|
||||
<div>
|
||||
<ListFilter
|
||||
onChangePageSize={onChangePageSize}
|
||||
onChangeQuery={onChangeQuery}
|
||||
onChangeSortDirection={onChangeSortDirection}
|
||||
onChangeSortBy={onChangeSortBy}
|
||||
onChangeDisplayMode={onChangeDisplayMode}
|
||||
onAddCriterion={onAddCriterion}
|
||||
onRemoveCriterion={onRemoveCriterion}
|
||||
onSelectAll={onSelectAll}
|
||||
onSelectNone={onSelectNone}
|
||||
zoomIndex={options.zoomable ? zoomIndex : undefined}
|
||||
onChangeZoom={options.zoomable ? onChangeZoom : undefined}
|
||||
otherOperations={otherOperations}
|
||||
filter={filter}
|
||||
/>
|
||||
{options.renderSelectedOptions && selectedIds.size > 0 ? options.renderSelectedOptions(result, selectedIds) : undefined}
|
||||
{result.loading ? <Spinner size={Spinner.SIZE_LARGE} /> : undefined}
|
||||
{result.error ? <h1>{result.error.message}</h1> : undefined}
|
||||
{options.renderContent(result, filter, selectedIds, zoomIndex)}
|
||||
<Pagination
|
||||
itemsPerPage={filter.itemsPerPage}
|
||||
currentPage={filter.currentPage}
|
||||
totalItems={totalCount}
|
||||
onChangePage={onChangePage}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
function maybeRenderContent() {
|
||||
if (!result.loading && !result.error) {
|
||||
return options.renderContent(result, filter, selectedIds, zoomIndex);
|
||||
}
|
||||
}
|
||||
|
||||
return { filter, template, options, onSelectChange };
|
||||
function maybeRenderPagination() {
|
||||
if (!result.loading && !result.error) {
|
||||
return (
|
||||
<Pagination
|
||||
itemsPerPage={filter.itemsPerPage}
|
||||
currentPage={filter.currentPage}
|
||||
totalItems={totalCount}
|
||||
onChangePage={onChangePage}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function getTemplate() {
|
||||
if (!options.subComponent && !forageInitialised.current) {
|
||||
return (
|
||||
<div>
|
||||
{!result.error ? <Spinner size={Spinner.SIZE_LARGE} /> : undefined}
|
||||
{result.error ? <h1>{result.error.message}</h1> : undefined}
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<div>
|
||||
<ListFilter
|
||||
onChangePageSize={onChangePageSize}
|
||||
onChangeQuery={onChangeQuery}
|
||||
onChangeSortDirection={onChangeSortDirection}
|
||||
onChangeSortBy={onChangeSortBy}
|
||||
onChangeDisplayMode={onChangeDisplayMode}
|
||||
onAddCriterion={onAddCriterion}
|
||||
onRemoveCriterion={onRemoveCriterion}
|
||||
onSelectAll={onSelectAll}
|
||||
onSelectNone={onSelectNone}
|
||||
zoomIndex={options.zoomable ? zoomIndex : undefined}
|
||||
onChangeZoom={options.zoomable ? onChangeZoom : undefined}
|
||||
otherOperations={otherOperations}
|
||||
filter={filter}
|
||||
/>
|
||||
{options.renderSelectedOptions && selectedIds.size > 0 ? options.renderSelectedOptions(result, selectedIds) : undefined}
|
||||
{result.loading || (!options.subComponent && !forageInitialised.current) ? <Spinner size={Spinner.SIZE_LARGE} /> : undefined}
|
||||
{result.error ? <h1>{result.error.message}</h1> : undefined}
|
||||
{maybeRenderContent()}
|
||||
{maybeRenderPagination()}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return { filter, template: getTemplate(), options, onSelectChange };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import localForage from "localforage";
|
||||
import _ from "lodash";
|
||||
import React from "react";
|
||||
import React, { Dispatch, SetStateAction } from "react";
|
||||
|
||||
interface IInterfaceWallConfig {
|
||||
}
|
||||
export interface IInterfaceConfig {
|
||||
wall: IInterfaceWallConfig;
|
||||
queries: any;
|
||||
}
|
||||
|
||||
type ValidTypes = IInterfaceConfig | undefined;
|
||||
@@ -14,25 +15,33 @@ interface ILocalForage<T> {
|
||||
data: T;
|
||||
setData: React.Dispatch<React.SetStateAction<T>>;
|
||||
error: Error | null;
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
export function useInterfaceLocalForage(): ILocalForage<IInterfaceConfig | undefined> {
|
||||
export function useInterfaceLocalForage(): [ILocalForage<IInterfaceConfig | undefined>, React.Dispatch<React.SetStateAction<IInterfaceConfig | undefined>>] {
|
||||
const result = useLocalForage("interface");
|
||||
// Set defaults
|
||||
React.useEffect(() => {
|
||||
if (result.data === undefined) {
|
||||
if (!result.data) {
|
||||
result.setData({
|
||||
wall: {
|
||||
// nothing here currently
|
||||
},
|
||||
queries: {}
|
||||
});
|
||||
} else if (!result.data.queries) {
|
||||
let newData = Object.assign({}, result.data);
|
||||
newData.queries = {};
|
||||
result.setData(newData);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
return [result, result.setData];
|
||||
}
|
||||
|
||||
function useLocalForage(item: string): ILocalForage<ValidTypes> {
|
||||
const [json, setJson] = React.useState<ValidTypes>(undefined);
|
||||
const [err, setErr] = React.useState(null);
|
||||
const [loaded, setLoaded] = React.useState<boolean>(false);
|
||||
|
||||
const prevJson = React.useRef<ValidTypes>(undefined);
|
||||
React.useEffect(() => {
|
||||
@@ -45,7 +54,6 @@ function useLocalForage(item: string): ILocalForage<ValidTypes> {
|
||||
runAsync();
|
||||
});
|
||||
|
||||
const [err, setErr] = React.useState(null);
|
||||
React.useEffect(() => {
|
||||
async function runAsync() {
|
||||
try {
|
||||
@@ -58,9 +66,10 @@ function useLocalForage(item: string): ILocalForage<ValidTypes> {
|
||||
} catch (error) {
|
||||
setErr(error);
|
||||
}
|
||||
setLoaded(true);
|
||||
}
|
||||
runAsync();
|
||||
});
|
||||
|
||||
return {data: json, setData: setJson, error: err};
|
||||
return {data: json, setData: setJson, error: err, loading: !loaded};
|
||||
}
|
||||
|
||||
@@ -280,6 +280,28 @@ video.preview.portrait {
|
||||
}
|
||||
}
|
||||
|
||||
.button-link {
|
||||
background-color: transparent;
|
||||
color: #48aff0;
|
||||
border-width: 0;
|
||||
cursor: pointer;
|
||||
display: inline;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.button-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.scrubber-button {
|
||||
background-color: transparent;
|
||||
color: #48aff0;
|
||||
}
|
||||
|
||||
.scrubber-button:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#jwplayer-container {
|
||||
margin: 10px auto;
|
||||
width: 75%;
|
||||
@@ -338,7 +360,7 @@ span.block {
|
||||
height: 50vh;
|
||||
min-height: 400px;
|
||||
background-size: cover !important;
|
||||
background-position: center !important;
|
||||
background-position: top !important;
|
||||
background-repeat: no-repeat !important;
|
||||
}
|
||||
|
||||
@@ -463,7 +485,7 @@ span.block {
|
||||
|
||||
& .name-icons {
|
||||
margin-left: 10px;
|
||||
|
||||
|
||||
& .not-favorite .bp3-icon {
|
||||
color: rgba(191, 204, 214, 0.5) !important;
|
||||
}
|
||||
@@ -576,3 +598,15 @@ span.block {
|
||||
transition: margin-left 0.5s;
|
||||
}
|
||||
}
|
||||
|
||||
.stats {
|
||||
& p.title {
|
||||
font-size: 3vw;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
& p.heading {
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { isArray } from "util";
|
||||
import { CriterionModifier } from "../../../core/generated-graphql";
|
||||
import { ILabeledId, ILabeledValue } from "../types";
|
||||
import { DurationUtils } from "../../../utils/duration";
|
||||
|
||||
export type CriterionType =
|
||||
"none" |
|
||||
"rating" |
|
||||
"o_counter" |
|
||||
"resolution" |
|
||||
"duration" |
|
||||
"favorite" |
|
||||
"hasMarkers" |
|
||||
"isMissing" |
|
||||
@@ -31,7 +34,9 @@ export abstract class Criterion<Option = any, Value = any> {
|
||||
switch (type) {
|
||||
case "none": return "None";
|
||||
case "rating": return "Rating";
|
||||
case "o_counter": return "O-Counter";
|
||||
case "resolution": return "Resolution";
|
||||
case "duration": return "Duration";
|
||||
case "favorite": return "Favorite";
|
||||
case "hasMarkers": return "Has Markers";
|
||||
case "isMissing": return "Is Missing";
|
||||
@@ -91,10 +96,18 @@ export abstract class Criterion<Option = any, Value = any> {
|
||||
default: modifierString = "";
|
||||
}
|
||||
|
||||
let valueString = "";
|
||||
|
||||
if (this.modifier !== CriterionModifier.IsNull && this.modifier !== CriterionModifier.NotNull) {
|
||||
valueString = this.getLabelValue();
|
||||
}
|
||||
|
||||
return `${Criterion.getLabel(this.type)} ${modifierString} ${valueString}`;
|
||||
}
|
||||
|
||||
public getLabelValue() {
|
||||
let valueString: string;
|
||||
if (this.modifier === CriterionModifier.IsNull || this.modifier === CriterionModifier.NotNull) {
|
||||
valueString = "";
|
||||
} else if (isArray(this.value) && this.value.length > 0) {
|
||||
if (isArray(this.value) && this.value.length > 0) {
|
||||
let items = this.value;
|
||||
if ((this.value as ILabeledId[])[0].label) {
|
||||
items = this.value.map((item) => item.label) as any;
|
||||
@@ -106,7 +119,7 @@ export abstract class Criterion<Option = any, Value = any> {
|
||||
valueString = this.value.toString();
|
||||
}
|
||||
|
||||
return `${Criterion.getLabel(this.type)} ${modifierString} ${valueString}`;
|
||||
return valueString;
|
||||
}
|
||||
|
||||
public getId(): string {
|
||||
@@ -195,3 +208,34 @@ export class NumberCriterion extends Criterion<number, number> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class DurationCriterion extends Criterion<number, number> {
|
||||
public type: CriterionType;
|
||||
public parameterName: string;
|
||||
public modifier = CriterionModifier.Equals;
|
||||
public modifierOptions = [
|
||||
Criterion.getModifierOption(CriterionModifier.Equals),
|
||||
Criterion.getModifierOption(CriterionModifier.NotEquals),
|
||||
Criterion.getModifierOption(CriterionModifier.GreaterThan),
|
||||
Criterion.getModifierOption(CriterionModifier.LessThan),
|
||||
];
|
||||
public options: number[] | undefined;
|
||||
public value: number = 0;
|
||||
|
||||
constructor(type : CriterionType, parameterName?: string, options? : number[]) {
|
||||
super();
|
||||
|
||||
this.type = type;
|
||||
this.options = options;
|
||||
|
||||
if (!!parameterName) {
|
||||
this.parameterName = parameterName;
|
||||
} else {
|
||||
this.parameterName = type;
|
||||
}
|
||||
}
|
||||
|
||||
public getLabelValue() {
|
||||
return DurationUtils.secondsToString(this.value);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user