Compare commits
67 Commits
35ffc2b0f7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 885fe7c9e9 | |||
| 930cc52373 | |||
| 4636a213b3 | |||
| 469954f613 | |||
| 5bdcd65d42 | |||
| cb91cd4cc7 | |||
| e04ddaed9b | |||
| 605da5e46c | |||
| 360e8ece85 | |||
| 1543bf9d03 | |||
| 287932d9d7 | |||
| 7c4de31c12 | |||
| 497c6150f7 | |||
| 514f51f111 | |||
| 244dc4fff6 | |||
| 4b39f787c9 | |||
| fb92b9c973 | |||
| 181358db7d | |||
| 3790567d44 | |||
| b3af993236 | |||
| 7ae2bb7635 | |||
| a75f0662ad | |||
| ffd68d5037 | |||
| adf9e2334c | |||
| 4125811017 | |||
| 4e8356b072 | |||
| bad116cdc0 | |||
| 9eac6871a4 | |||
| 3b694689f3 | |||
| 1604ddaa78 | |||
| 16181923b6 | |||
| 62dcaba875 | |||
| f67c05f034 | |||
| 8fd792b85c | |||
| 2595fcc365 | |||
| 0af5b8d84c | |||
| d1e8ff48c5 | |||
| d7964f6fc2 | |||
| 0394093407 | |||
| adcd6abfc7 | |||
| 721eaa5d07 | |||
| 994908ef6a | |||
| dda76ac7b0 | |||
| e7eac26e66 | |||
| 15b61ed56f | |||
| f9a51ffdce | |||
| a47b9a86dc | |||
| 89ca64dd88 | |||
| e5e1c5f82b | |||
| ab1e642c36 | |||
| 1cae3ac092 | |||
| afe5876162 | |||
| 72129f69ee | |||
| a2e2704a05 | |||
| 65af850d68 | |||
| f7425cdc03 | |||
| d9f432ef73 | |||
| 3a86651891 | |||
| 20f304c9cd | |||
| 1f58f989f7 | |||
| 96b1a99e04 | |||
| 1bc7dd3a43 | |||
| a048970be6 | |||
| e3171e5693 | |||
| d463b3df5c | |||
| 1ae7befa4b | |||
| dc80e1e199 |
@@ -25,7 +25,8 @@
|
||||
.button {
|
||||
display: inline-flex;
|
||||
flex-shrink: 0;
|
||||
align-items: stretch;
|
||||
/* align-items: stretch; */
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
padding: .5rem;
|
||||
border: none;
|
||||
@@ -42,7 +43,7 @@
|
||||
fill: var(--glass);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
&:hover:not(:disabled) {
|
||||
cursor: pointer;
|
||||
background: var(--primary);
|
||||
color: var(--text-light);
|
||||
@@ -55,6 +56,10 @@
|
||||
&:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
background: var(--glass-weak-30);
|
||||
}
|
||||
}
|
||||
|
||||
.button-label {
|
||||
|
||||
4
assets/img/icons/at-sign.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M13.657 2.343c-1.511-1.511-3.52-2.343-5.657-2.343s-4.146 0.832-5.657 2.343c-1.511 1.511-2.343 3.52-2.343 5.657s0.832 4.146 2.343 5.657c1.511 1.511 3.52 2.343 5.657 2.343 1.199 0 2.353-0.259 3.429-0.77 0.499-0.237 0.711-0.834 0.474-1.332s-0.834-0.711-1.332-0.474c-0.806 0.383-1.671 0.577-2.571 0.577-3.308 0-6-2.692-6-6s2.692-6 6-6 6 2.692 6 6v1c0 0.551-0.449 1-1 1s-1-0.449-1-1v-4c0-0.552-0.448-1-1-1-0.406 0-0.755 0.242-0.912 0.59-0.608-0.374-1.323-0.59-2.088-0.59-2.206 0-4 1.794-4 4s1.794 4 4 4c1.045 0 1.998-0.403 2.712-1.062 0.551 0.649 1.372 1.062 2.288 1.062 1.654 0 3-1.346 3-3v-1c0-2.137-0.832-4.146-2.343-5.657zM8 10c-1.103 0-2-0.897-2-2s0.897-2 2-2c1.103 0 2 0.897 2 2s-0.897 2-2 2z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 850 B |
4
assets/img/icons/cancel.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M11.5 0h-7l-4.5 4.5v7l4.5 4.5h7l4.5-4.5v-7l-4.5-4.5zM12.5 11l-1.5 1.5-3-3-3 3-1.5-1.5 3-3-3-3 1.5-1.5 3 3 3-3 1.5 1.5-3 3 3 3z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 283 B |
5
assets/img/icons/checkbox-checked.svg
Executable file
@@ -0,0 +1,5 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M0 0v16h16v-16h-16zM15 15h-14v-14h14v14z"></path>
|
||||
<path d="M2.5 8l1.5-1.5 2.5 2.5 5.5-5.5 1.5 1.5-7 7z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 259 B |
4
assets/img/icons/checkbox-checked2.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M14 0h-12c-1.1 0-2 0.9-2 2v12c0 1.1 0.9 2 2 2h12c1.1 0 2-0.9 2-2v-12c0-1.1-0.9-2-2-2zM7 12.414l-3.707-3.707 1.414-1.414 2.293 2.293 4.793-4.793 1.414 1.414-6.207 6.207z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 325 B |
4
assets/img/icons/checkbox-partial.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M0 0v16h16v-16h-16zM15 15h-14v-14h14v14zM4 4h8v8h-8z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 209 B |
4
assets/img/icons/checkbox-partial2.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M14.5 0h-13c-0.825 0-1.5 0.675-1.5 1.5v13c0 0.825 0.675 1.5 1.5 1.5h13c0.825 0 1.5-0.675 1.5-1.5v-13c0-0.825-0.675-1.5-1.5-1.5zM14 14h-12v-12h12v12zM5 12h6c0.55 0 1-0.45 1-1v-6c0-0.55-0.45-1-1-1h-6c-0.55 0-1 0.45-1 1v6c0 0.55 0.45 1 1 1zM5 10.875h6v0.123c-0.001 0.001-0.001 0.001-0.002 0.002h-5.996c-0.001-0.001-0.001-0.001-0.002-0.002v-0.123zM5.002 5h5.996c0.001 0.001 0.001 0.001 0.002 0.002v0.123h-6v-0.123c0.001-0.001 0.001-0.001 0.002-0.002zM11 5.375v0.25h-6v-0.25h6zM11 5.875v0.25h-6v-0.25h6zM11 6.375v0.25h-6v-0.25h6zM11 6.875v0.25h-6v-0.25h6zM11 7.375v0.25h-6v-0.25h6zM11 7.875v0.25h-6v-0.25h6zM11 8.375v0.25h-6v-0.25h6zM11 8.875v0.25h-6v-0.25h6zM11 9.375v0.25h-6v-0.25h6zM11 9.875v0.25h-6v-0.25h6zM11 10.375v0.25h-6v-0.25h6z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 890 B |
4
assets/img/icons/checkbox-unchecked.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M0 0v16h16v-16h-16zM15 15h-14v-14h14v14z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 197 B |
4
assets/img/icons/checkbox-unchecked2.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M14 0h-12c-1.1 0-2 0.9-2 2v12c0 1.1 0.9 2 2 2h12c1.1 0 2-0.9 2-2v-12c0-1.1-0.9-2-2-2zM14 14h-12v-12h12v12z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 263 B |
12
assets/img/icons/collaboration.svg
Executable file
@@ -0,0 +1,12 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M4 3.5c0 0.828-0.672 1.5-1.5 1.5s-1.5-0.672-1.5-1.5c0-0.828 0.672-1.5 1.5-1.5s1.5 0.672 1.5 1.5z"></path>
|
||||
<path d="M2.5 5c-1.381 0-2.5 0.448-2.5 1v1h5v-1c0-0.552-1.119-1-2.5-1z"></path>
|
||||
<path d="M14 3.5c0 0.828-0.672 1.5-1.5 1.5s-1.5-0.672-1.5-1.5c0-0.828 0.672-1.5 1.5-1.5s1.5 0.672 1.5 1.5z"></path>
|
||||
<path d="M12.5 5c-1.381 0-2.5 0.448-2.5 1v1h5v-1c0-0.552-1.119-1-2.5-1z"></path>
|
||||
<path d="M9 11.5c0 0.828-0.672 1.5-1.5 1.5s-1.5-0.672-1.5-1.5c0-0.828 0.672-1.5 1.5-1.5s1.5 0.672 1.5 1.5z"></path>
|
||||
<path d="M7.5 13c-1.381 0-2.5 0.448-2.5 1v1h5v-1c0-0.552-1.119-1-2.5-1z"></path>
|
||||
<path d="M9.5 4h-4c-0.276 0-0.5-0.224-0.5-0.5s0.224-0.5 0.5-0.5h4c0.276 0 0.5 0.224 0.5 0.5s-0.224 0.5-0.5 0.5z"></path>
|
||||
<path d="M10.5 12c-0.095 0-0.192-0.027-0.277-0.084-0.23-0.153-0.292-0.464-0.139-0.693l2-3c0.153-0.23 0.464-0.292 0.693-0.139s0.292 0.464 0.139 0.693l-2 3c-0.096 0.145-0.255 0.223-0.416 0.223z"></path>
|
||||
<path d="M4.5 12c-0.162 0-0.32-0.078-0.417-0.223l-2-3c-0.153-0.23-0.091-0.54 0.139-0.693s0.54-0.091 0.693 0.139l2 3c0.153 0.23 0.091 0.54-0.139 0.693-0.085 0.057-0.182 0.084-0.277 0.084z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
4
assets/img/icons/exclude.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M11 4v-4h-11v11h4v5h12v-12h-5zM14 6.125h-3v-0.125h3v0.125zM6 14v-0.125h8v0.125h-8zM6 13.625v-0.25h8v0.25h-8zM6 13.125v-0.25h8v0.25h-8zM6 12.625v-0.25h8v0.25h-8zM6 12.125v-0.25h8v0.25h-8zM6 11.625v-0.25h8v0.25h-8zM6 11.125v-0.125h5v-0.125h3v0.25h-8zM11 10.625v-0.25h3v0.25h-3zM11 10.125v-0.25h3v0.25h-3zM11 9.625v-0.25h3v0.25h-3zM11 9.125v-0.25h3v0.25h-3zM11 8.625v-0.25h3v0.25h-3zM11 8.125v-0.25h3v0.25h-3zM11 7.625v-0.25h3v0.25h-3zM11 7.125v-0.25h3v0.25h-3zM11 6.625v-0.25h3v0.25h-3zM9 4h-5v0.125h-2v-0.25h7v0.125zM2 9v-0.125h2v0.125h-2zM2 8.625v-0.25h2v0.25h-2zM2 8.125v-0.25h2v0.25h-2zM2 7.625v-0.25h2v0.25h-2zM2 7.125v-0.25h2v0.25h-2zM2 6.625v-0.25h2v0.25h-2zM2 6.125v-0.25h2v0.25h-2zM2 5.625v-0.25h2v0.25h-2zM2 5.125v-0.25h2v0.25h-2zM2 4.625v-0.25h2v0.25h-2zM9 3.625h-7v-0.25h7v0.25zM9 3.125h-7v-0.25h7v0.25zM9 2.625h-7v-0.25h7v0.25zM9 2.125h-7v-0.125h7v0.125zM5 5h5v5h-5v-5z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
4
assets/img/icons/interset.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M11 4v-4h-11v11h4v5h12v-12h-5zM10 6.125h-4v-0.125h4v0.125zM10 10h-4v-0.125h4v0.125zM10 9.625h-4v-0.25h4v0.25zM10 9.125h-4v-0.25h4v0.25zM10 8.625h-4v-0.25h4v0.25zM10 8.125h-4v-0.25h4v0.25zM10 7.625h-4v-0.25h4v0.25zM10 7.125h-4v-0.25h4v0.25zM10 6.625h-4v-0.25h4v0.25zM4 10h-3v-9h9v3h-6v6zM15 15h-10v-3h7v-7h3v10z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 467 B |
5
assets/img/icons/merge.svg
Executable file
@@ -0,0 +1,5 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M9 5h3.5l-4.5-4.5-4.5 4.5h3.5v3.586l-5.957 5.957 1.414 1.414 6.543-6.543z"></path>
|
||||
<path d="M8.543 11.957l1.414-1.414 4 4-1.414 1.414-4-4z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 295 B |
4
assets/img/icons/popout.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M14.5 2h-9c-0.825 0-1.5 0.675-1.5 1.5v1.5h-2.5c-0.825 0-1.5 0.675-1.5 1.5v6c0 0.825 0.675 1.5 1.5 1.5h9c0.825 0 1.5-0.675 1.5-1.5v-1.5h2.5c0.825 0 1.5-0.675 1.5-1.5v-6c0-0.825-0.675-1.5-1.5-1.5zM11 12.5c0 0.271-0.229 0.5-0.5 0.5h-9c-0.271 0-0.5-0.229-0.5-0.5v-6c0-0.271 0.229-0.5 0.5-0.5h2.5v3.5c0 0.825 0.675 1.5 1.5 1.5h5.5v1.5zM15 9.5c0 0.271-0.229 0.5-0.5 0.5h-9c-0.271 0-0.5-0.229-0.5-0.5v-6c0-0.271 0.229-0.5 0.5-0.5h9c0.271 0 0.5 0.229 0.5 0.5v6z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 610 B |
4
assets/img/icons/stack-plus.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M5 1v1.155l-2.619 0.368 0.17 1.211-2.551 0.732 3.308 11.535 10.189-2.921 0.558-0.079h1.945v-12h-11zM3.929 14.879l-2.808-9.793 1.558-0.447 1.373 9.766 2.997-0.421-3.119 0.894zM4.822 13.382l-1.418-10.088 1.595-0.224v9.93h2.543l-2.721 0.382zM15 12h-9v-10h9v10zM13 8h-2v2h-1v-2h-2v-1h2v-2h1v2h2z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 448 B |
4
assets/img/icons/stack.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M13.75 4h-0.75v-0.75c0-0.689-0.561-1.25-1.25-1.25h-0.75v-0.75c0-0.689-0.561-1.25-1.25-1.25h-7.5c-0.689 0-1.25 0.561-1.25 1.25v9.5c0 0.689 0.561 1.25 1.25 1.25h0.75v0.75c0 0.689 0.561 1.25 1.25 1.25h0.75v0.75c0 0.689 0.561 1.25 1.25 1.25h7.5c0.689 0 1.25-0.561 1.25-1.25v-9.5c0-0.689-0.561-1.25-1.25-1.25zM2.25 11c-0.138 0-0.25-0.113-0.25-0.25v-9.5c0-0.137 0.112-0.25 0.25-0.25h7.5c0.137 0 0.25 0.113 0.25 0.25v0.75h-5.75c-0.689 0-1.25 0.561-1.25 1.25v7.75h-0.75zM4.25 13c-0.138 0-0.25-0.113-0.25-0.25v-9.5c0-0.138 0.112-0.25 0.25-0.25h7.5c0.137 0 0.25 0.112 0.25 0.25v0.75h-5.75c-0.689 0-1.25 0.561-1.25 1.25v7.75h-0.75zM14 14.75c0 0.137-0.113 0.25-0.25 0.25h-7.5c-0.138 0-0.25-0.113-0.25-0.25v-9.5c0-0.138 0.112-0.25 0.25-0.25h7.5c0.137 0 0.25 0.112 0.25 0.25v9.5z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 922 B |
4
assets/img/icons/stack2.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M16 5l-8-4-8 4 8 4 8-4zM8 2.328l5.345 2.672-5.345 2.672-5.345-2.672 5.345-2.672zM14.398 7.199l1.602 0.801-8 4-8-4 1.602-0.801 6.398 3.199zM14.398 10.199l1.602 0.801-8 4-8-4 1.602-0.801 6.398 3.199z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 354 B |
4
assets/img/icons/stack3.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M8 9l-8-4 8-4 8 4zM14.398 7.199l1.602 0.801-8 4-8-4 1.602-0.801 6.398 3.199zM14.398 10.199l1.602 0.801-8 4-8-4 1.602-0.801 6.398 3.199z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 292 B |
4
assets/img/icons/unite.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path d="M11 4v-4h-11v11h4v5h12v-12h-5zM10 5.125h-5v-0.125h5v0.125zM14 6.125h-3v-0.125h3v0.125zM5 9.875h5v0.125h-5v-0.125zM2 8.875h2v0.125h-2v-0.125zM4 5.875v0.25h-2v-0.25h2zM2 5.625v-0.25h2v0.25h-2zM4 6.375v0.25h-2v-0.25h2zM5 8.125v-0.25h5v0.25h-5zM10 8.375v0.25h-5v-0.25h5zM5 7.625v-0.25h5v0.25h-5zM5 7.125v-0.25h5v0.25h-5zM5 6.625v-0.25h5v0.25h-5zM4 6.875v0.25h-2v-0.25h2zM4 7.375v0.25h-2v-0.25h2zM4 7.875v0.25h-2v-0.25h2zM4 8.375v0.25h-2v-0.25h2zM5 8.875h5v0.25h-5v-0.25zM10 9.375v0.25h-5v-0.25h5zM6 14v-0.125h8v0.125h-8zM6 13.625v-0.25h8v0.25h-8zM6 13.125v-0.25h8v0.25h-8zM6 12.625v-0.25h8v0.25h-8zM6 12.125v-0.25h8v0.25h-8zM6 11.625v-0.25h8v0.25h-8zM6 11.125v-0.125h5v-0.125h3v0.25h-8zM11 10.625v-0.25h3v0.25h-3zM11 10.125v-0.25h3v0.25h-3zM11 9.625v-0.25h3v0.25h-3zM11 9.125v-0.25h3v0.25h-3zM11 8.625v-0.25h3v0.25h-3zM11 8.125v-0.25h3v0.25h-3zM11 7.625v-0.25h3v0.25h-3zM11 7.125v-0.25h3v0.25h-3zM11 6.625v-0.25h3v0.25h-3zM10 6.125h-5v-0.25h5v0.25zM5 5.625v-0.25h5v0.25h-5zM4 5.125h-2v-0.25h2v0.25zM9 2v0.125h-7v-0.125h7zM9 2.375v0.25h-7v-0.25h7zM9 2.875v0.25h-7v-0.25h7zM9 3.375v0.25h-7v-0.25h7zM9 3.875v0.125h-5v0.125h-2v-0.25h7zM4 4.375v0.25h-2v-0.25h2z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
11
assets/img/icons/unlink5.svg
Executable file
@@ -0,0 +1,11 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="17" height="16" viewBox="0 0 17 16">
|
||||
<path d="M7 12h-3c-2.206 0-4-1.794-4-4s1.794-4 4-4h3c0.552 0 1 0.448 1 1s-0.448 1-1 1h-3c-1.103 0-2 0.897-2 2s0.897 2 2 2h3c0.552 0 1 0.448 1 1s-0.448 1-1 1z"></path>
|
||||
<path d="M13 12h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1h3c1.103 0 2-0.897 2-2s-0.897-2-2-2h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1h3c2.206 0 4 1.794 4 4s-1.794 4-4 4z"></path>
|
||||
<path d="M8.5 3c-0.276 0-0.5-0.224-0.5-0.5v-2c0-0.276 0.224-0.5 0.5-0.5s0.5 0.224 0.5 0.5v2c0 0.276-0.224 0.5-0.5 0.5z"></path>
|
||||
<path d="M11.5 3c-0.128 0-0.256-0.049-0.354-0.146-0.195-0.195-0.195-0.512 0-0.707l2-2c0.195-0.195 0.512-0.195 0.707 0s0.195 0.512 0 0.707l-2 2c-0.098 0.098-0.226 0.146-0.354 0.146z"></path>
|
||||
<path d="M5.5 3c-0.128 0-0.256-0.049-0.354-0.146l-2-2c-0.195-0.195-0.195-0.512 0-0.707s0.512-0.195 0.707 0l2 2c0.195 0.195 0.195 0.512 0 0.707-0.098 0.098-0.226 0.146-0.354 0.146z"></path>
|
||||
<path d="M8.5 13c0.276 0 0.5 0.224 0.5 0.5v2c0 0.276-0.224 0.5-0.5 0.5s-0.5-0.224-0.5-0.5v-2c0-0.276 0.224-0.5 0.5-0.5z"></path>
|
||||
<path d="M5.5 13c0.128 0 0.256 0.049 0.354 0.146 0.195 0.195 0.195 0.512 0 0.707l-2 2c-0.195 0.195-0.512 0.195-0.707 0s-0.195-0.512 0-0.707l2-2c0.098-0.098 0.226-0.146 0.354-0.146z"></path>
|
||||
<path d="M11.5 13c0.128 0 0.256 0.049 0.354 0.146l2 2c0.195 0.195 0.195 0.512 0 0.707s-0.512 0.195-0.707 0l-2-2c-0.195-0.195-0.195-0.512 0-0.707 0.098-0.098 0.226-0.146 0.354-0.146z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
2
common
175
components/actors/add.vue
Normal file
@@ -0,0 +1,175 @@
|
||||
<template>
|
||||
<Dialog
|
||||
title="Add actor"
|
||||
@close="emit('close')"
|
||||
>
|
||||
<div
|
||||
v-if="isSubmitted && newActor"
|
||||
class="dialog-body"
|
||||
>
|
||||
<strong>Added '{{ newActor.name }}' (#{{ newActor.id }})</strong>
|
||||
|
||||
<ul
|
||||
v-if="isSubmitted && newActor"
|
||||
class="dialog-body options"
|
||||
>
|
||||
<li class="option">
|
||||
<a
|
||||
:href="`/actor/edit/${newActor.id}/${newActor.slug}`"
|
||||
target="_blank"
|
||||
class="link"
|
||||
>Edit bio</a>
|
||||
</li>
|
||||
|
||||
<li class="option">
|
||||
<a
|
||||
:href="`/actor/${newActor.id}/${newActor.slug}`"
|
||||
target="_blank"
|
||||
class="link"
|
||||
>Go to actor</a>
|
||||
</li>
|
||||
|
||||
<li class="option">
|
||||
<span
|
||||
class="link"
|
||||
@click="newActor = null; isSubmitted = false;"
|
||||
>Add another actor</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<form
|
||||
v-else
|
||||
class="dialog-body"
|
||||
@submit.prevent="addActor"
|
||||
>
|
||||
<input
|
||||
ref="nameInput"
|
||||
v-model="name"
|
||||
class="input"
|
||||
placeholder="Name"
|
||||
required
|
||||
>
|
||||
|
||||
<select
|
||||
v-model="gender"
|
||||
placeholder="Gender"
|
||||
class="input"
|
||||
>
|
||||
<option value="female">Female</option>
|
||||
<option value="male">Male</option>
|
||||
<option value="transsexual">Transsexual</option>
|
||||
<option value="other">Other</option>
|
||||
</select>
|
||||
|
||||
<Checkbox
|
||||
label="Allow global match"
|
||||
:checked="allowGlobalMatch"
|
||||
@change="(isChecked) => allowGlobalMatch = isChecked"
|
||||
/>
|
||||
|
||||
<div class="dialog-actions">
|
||||
<Ellipsis v-if="isSubmitting" />
|
||||
|
||||
<button
|
||||
v-else
|
||||
class="button button-primary"
|
||||
>Add actor</button>
|
||||
</div>
|
||||
</form>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
|
||||
import Dialog from '#/components/dialog/dialog.vue';
|
||||
import Ellipsis from '#/components/loading/ellipsis.vue';
|
||||
import Checkbox from '#/components/form/checkbox.vue';
|
||||
|
||||
import { post } from '#/src/api.js';
|
||||
import events from '#/src/events.js';
|
||||
|
||||
const emit = defineEmits(['close']);
|
||||
|
||||
const nameInput = ref(null);
|
||||
const isSubmitting = ref(false);
|
||||
const isSubmitted = ref(false);
|
||||
|
||||
const name = ref(null);
|
||||
const gender = ref('female');
|
||||
const allowGlobalMatch = ref(true);
|
||||
|
||||
const newActor = ref(null);
|
||||
|
||||
onMounted(() => {
|
||||
nameInput.value.focus();
|
||||
});
|
||||
|
||||
async function addActor() {
|
||||
isSubmitting.value = true;
|
||||
|
||||
try {
|
||||
const { actor } = await post('/actors', {
|
||||
actor: {
|
||||
name: name.value,
|
||||
gender: gender.value,
|
||||
allowGlobalMatch: allowGlobalMatch.value,
|
||||
},
|
||||
}, {
|
||||
successFeedback: 'Actor has been added.',
|
||||
appendErrorMessage: true,
|
||||
});
|
||||
|
||||
name.value = null;
|
||||
gender.value = null;
|
||||
allowGlobalMatch.value = true;
|
||||
|
||||
newActor.value = actor;
|
||||
} catch (error) {
|
||||
events.emit('feedback', {
|
||||
type: 'error',
|
||||
message: error.message,
|
||||
});
|
||||
}
|
||||
|
||||
isSubmitting.value = false;
|
||||
isSubmitted.value = true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dialog-body {
|
||||
width: 20rem;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 1rem;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.load-container {
|
||||
width: 100%;
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
height: 2rem;
|
||||
}
|
||||
|
||||
.options {
|
||||
padding: 0 1.5rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.option {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dialog-actions {
|
||||
margin-top: .5rem;
|
||||
}
|
||||
|
||||
.button-primary {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -20,6 +20,15 @@
|
||||
</div>
|
||||
|
||||
<ul class="bio nolist">
|
||||
<li
|
||||
v-if="aliases.length > 0"
|
||||
class="bio-item"
|
||||
>
|
||||
<dfn class="bio-label"><Icon icon="at-sign" />Aliases</dfn>
|
||||
|
||||
<span class="orientation">{{ aliases.join(', ') }}</span>
|
||||
</li>
|
||||
|
||||
<li
|
||||
v-if="actor.dateOfBirth"
|
||||
class="bio-item"
|
||||
@@ -80,10 +89,17 @@
|
||||
<span
|
||||
v-if="actor.origin.city"
|
||||
class="city"
|
||||
>{{ actor.origin.city }}</span><span
|
||||
>{{ actor.origin.city }}</span>
|
||||
|
||||
<span
|
||||
v-if="actor.origin.state && (!actor.origin.city || (actor.origin.country && actor.origin.country.alpha2 === 'US'))"
|
||||
class="state"
|
||||
>{{ actor.origin.city ? `, ${actor.origin.state}` : actor.origin.state }}</span>
|
||||
>
|
||||
{{ actor.origin.city
|
||||
? [',', actor.origin.state].join(' ')
|
||||
: actor.origin.state
|
||||
}}
|
||||
</span>
|
||||
|
||||
<span
|
||||
v-if="actor.origin.country"
|
||||
@@ -365,10 +381,22 @@
|
||||
target="_blank"
|
||||
class="link"
|
||||
>Revisions</a>
|
||||
|
||||
<span
|
||||
v-if="user && user.role !== 'user'"
|
||||
class="link"
|
||||
@click="showMergeDialog = true"
|
||||
>Merge</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<Merge
|
||||
v-if="showMergeDialog"
|
||||
:actors="[actor]"
|
||||
@close="showMergeDialog = false"
|
||||
/>
|
||||
|
||||
<div class="descriptions-container">
|
||||
<div
|
||||
v-if="descriptions.length > 0"
|
||||
@@ -429,6 +457,8 @@ import formatTemplate from 'template-format';
|
||||
import getPath from '#/src/get-path.js';
|
||||
import { formatDate } from '#/utils/format.js';
|
||||
|
||||
import Merge from '#/components/actors/merge.vue';
|
||||
|
||||
const expanded = ref(false);
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
@@ -506,6 +536,17 @@ const socials = props.actor.socials.slice(0, 10).map((social) => ({
|
||||
? new URL(social.url).hostname
|
||||
: social.handle,
|
||||
}));
|
||||
|
||||
const aliases = Object
|
||||
.entries(props.actor.aliases.reduce((acc, alias) => {
|
||||
acc[alias.name] = (props.actor[alias.name] || 0) + 1;
|
||||
return acc;
|
||||
}, {}))
|
||||
.toSorted(([, countA], [, countB]) => countB - countA)
|
||||
.map(([alias]) => alias)
|
||||
.filter((alias) => alias !== props.actor.name);
|
||||
|
||||
const showMergeDialog = ref(false);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -785,6 +826,7 @@ const socials = props.actor.socials.slice(0, 10).map((social) => ({
|
||||
.link {
|
||||
color: inherit;
|
||||
flex-shrink: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
285
components/actors/merge.vue
Normal file
@@ -0,0 +1,285 @@
|
||||
<template>
|
||||
<Dialog
|
||||
:title="`Merge ${actors.length === 1 ? `'${actors[0].name}'` : `${actors.length} actors`}`"
|
||||
@close="emit('close')"
|
||||
>
|
||||
<div
|
||||
v-if="merged"
|
||||
class="dialog-body"
|
||||
>
|
||||
Merge successful
|
||||
|
||||
<ul class="options">
|
||||
<li class="option">
|
||||
<a
|
||||
href=""
|
||||
class="link"
|
||||
>Reload page</a>
|
||||
</li>
|
||||
|
||||
<li class="option">
|
||||
<a
|
||||
:href="`/actor/${targetActor?.id}/${targetActor?.slug}`"
|
||||
class="link"
|
||||
>Go to #{{ targetActor?.id }} {{ targetActor?.name }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else
|
||||
class="dialog-body"
|
||||
>
|
||||
<ul class="actors nolist">
|
||||
<li
|
||||
v-for="actor in actors"
|
||||
:key="`actor-${actor.id}`"
|
||||
class="actor"
|
||||
>
|
||||
<span class="source">
|
||||
<strong class="source-name">{{ actor.name }}<template v-if="actor.entity"> ({{ actor.entity.name }})</template></strong>
|
||||
<span class="source-id">#{{ actor.id }}</span>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<span class="path">merging into</span>
|
||||
|
||||
<div
|
||||
v-if="targetActor"
|
||||
class="target"
|
||||
>
|
||||
<strong class="target-name">
|
||||
<span class="target-id">#{{ targetActor.id }}</span>
|
||||
{{ targetActor.name }}
|
||||
</strong>
|
||||
|
||||
<Icon
|
||||
icon="cross2"
|
||||
@click="targetActor = null"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<VDropdown
|
||||
:triggers="[]"
|
||||
:shown="actorResults.length > 0"
|
||||
:auto-hide="false"
|
||||
>
|
||||
<input
|
||||
ref="actorInput"
|
||||
v-model="actorQuery"
|
||||
class="input"
|
||||
placeholder="Search target actor"
|
||||
@input="searchActors"
|
||||
>
|
||||
|
||||
<template #popper>
|
||||
<ul
|
||||
class="results nolist"
|
||||
>
|
||||
<li
|
||||
v-for="actorResult in actorResults"
|
||||
:key="`actor-result-${actorResult.id}`"
|
||||
v-close-popper
|
||||
class="result-item"
|
||||
@click="selectActor(actorResult)"
|
||||
>
|
||||
<div class="result-label">
|
||||
<span class="result-id">#{{ actorResult.id }}</span> {{ actorResult.name }}
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
</VDropdown>
|
||||
</template>
|
||||
|
||||
<div class="dialog-actions">
|
||||
<Ellipsis v-if="submitted" />
|
||||
|
||||
<button
|
||||
v-else
|
||||
v-tooltip="sourceTargetConflict && 'Cannot merge actor profile into itself'"
|
||||
type="submit"
|
||||
class="button button-primary"
|
||||
:disabled="!targetActor || sourceTargetConflict"
|
||||
@click="merge"
|
||||
>Merge</button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
|
||||
import Dialog from '#/components/dialog/dialog.vue';
|
||||
import Ellipsis from '#/components/loading/ellipsis.vue';
|
||||
|
||||
import { get, post } from '#/src/api.js';
|
||||
|
||||
const props = defineProps({
|
||||
actors: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['close', 'merged']);
|
||||
|
||||
const targetActor = ref(null);
|
||||
const actorInput = ref(null);
|
||||
const actorQuery = ref('');
|
||||
const actorResults = ref([]);
|
||||
const submitted = ref(false);
|
||||
const merged = ref(false);
|
||||
|
||||
const sourceTargetConflict = computed(() => props.actors.some((actor) => actor.id === targetActor.value?.id));
|
||||
|
||||
async function searchActors() {
|
||||
const res = await get('/actors', {
|
||||
q: actorQuery.value, // return partial matches
|
||||
limit: 10,
|
||||
global: true,
|
||||
});
|
||||
|
||||
actorResults.value = res.actors;
|
||||
}
|
||||
|
||||
function getActorNames() {
|
||||
if (props.actors.length > 1) {
|
||||
return `${props.actors.length} actors`;
|
||||
}
|
||||
|
||||
if (props.actors[0].entity) {
|
||||
return `${props.actors[0].name} (${props.actors[0].entity.name})`;
|
||||
}
|
||||
|
||||
return props.actors[0].name;
|
||||
}
|
||||
|
||||
async function merge() {
|
||||
submitted.value = true;
|
||||
|
||||
await post(`/actors/${targetActor.value.id}/merge/${props.actors.map((actor) => actor.id).join(',')}`, null, {
|
||||
successFeedback: `Merged ${getActorNames()} into ${targetActor.value.name}`,
|
||||
errorFeedback: `Failed to merge ${getActorNames()} into ${targetActor.value.name}`,
|
||||
appendErrorMessage: true,
|
||||
});
|
||||
|
||||
submitted.value = false;
|
||||
merged.value = true;
|
||||
|
||||
emit('merged');
|
||||
|
||||
// emit('close');
|
||||
}
|
||||
|
||||
function selectActor(actor) {
|
||||
targetActor.value = actor;
|
||||
actorQuery.value = '';
|
||||
actorResults.value = [];
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
actorInput.value.focus();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dialog-body {
|
||||
width: 20rem;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 1rem;
|
||||
gap: 1rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dialog-actions {
|
||||
.button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.actors {
|
||||
max-height: 15rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.actor {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.path {
|
||||
color: var(--glass-strong-20);
|
||||
}
|
||||
|
||||
.target {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.icon {
|
||||
padding: .25rem .75rem;
|
||||
fill: var(--glass);
|
||||
|
||||
&:hover {
|
||||
fill: var(--error);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.source-id,
|
||||
.target-id {
|
||||
font-family: monospace;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.source {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.source-name {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.results {
|
||||
padding: .25rem 0;
|
||||
}
|
||||
|
||||
.result-item {
|
||||
display: flex;
|
||||
padding: .25rem .5rem;
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
color: var(--primary);
|
||||
}
|
||||
}
|
||||
|
||||
.result-id {
|
||||
font-family: monospace;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.load-container {
|
||||
height: 2rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.options {
|
||||
padding: 0 1.5rem;
|
||||
margin: 0;
|
||||
line-height: 1.75;
|
||||
}
|
||||
</style>
|
||||
@@ -74,7 +74,10 @@
|
||||
</div>
|
||||
|
||||
<span class="label">
|
||||
<span class="name ellipsis">{{ actor.name }}</span>
|
||||
<span
|
||||
class="name ellipsis"
|
||||
:style="{ 'font-size': `${Math.max(0.9 + Math.min((17 - actor.name.length), 0) * 0.06, 0.65)}rem` }"
|
||||
>{{ actor.name }}</span>
|
||||
|
||||
<img
|
||||
v-if="actor.entity"
|
||||
@@ -82,6 +85,13 @@
|
||||
:src="`/logos/${actor.entity.slug}/favicon_dark.png`"
|
||||
class="favicon"
|
||||
>
|
||||
|
||||
<Icon
|
||||
v-if="actor.alias && actor.alias.name !== actor.name"
|
||||
v-tooltip="`Credited as '${actor.alias.name}'`"
|
||||
icon="at-sign"
|
||||
class="alias"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -128,6 +138,10 @@ const favorited = ref(props.actor.stashes.some((actorStash) => actorStash.id ===
|
||||
:deep(.bookmarks) .icon:not(.favorited):not(:hover) {
|
||||
fill: var(--text-light);
|
||||
}
|
||||
|
||||
.menu {
|
||||
fill: var(--text-light);
|
||||
}
|
||||
}
|
||||
|
||||
&.unstashed {
|
||||
@@ -135,7 +149,16 @@ const favorited = ref(props.actor.stashes.some((actorStash) => actorStash.id ===
|
||||
}
|
||||
}
|
||||
|
||||
.menu {
|
||||
padding: .5rem .75rem;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
fill: var(--highlight-strong-20);
|
||||
}
|
||||
|
||||
.label {
|
||||
height: 1.75rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
@@ -149,7 +172,7 @@ const favorited = ref(props.actor.stashes.some((actorStash) => actorStash.id ===
|
||||
}
|
||||
|
||||
.name {
|
||||
padding: .35rem .25rem .35rem .5rem;
|
||||
padding: 0 .25rem 0 .5rem;
|
||||
}
|
||||
|
||||
.favicon {
|
||||
@@ -246,4 +269,11 @@ const favorited = ref(props.actor.stashes.some((actorStash) => actorStash.id ===
|
||||
height: .75rem;
|
||||
margin-left: .25rem;
|
||||
}
|
||||
|
||||
.alias {
|
||||
height: 100%;
|
||||
fill: var(--glass-weak-20);
|
||||
padding: 0 .25rem;
|
||||
cursor: help;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
<div class="page">
|
||||
<nav class="nav">
|
||||
<ul class="nav-items nolist">
|
||||
<li class="nav-item">
|
||||
<a
|
||||
href="/admin/actors"
|
||||
class="nav-link nolink"
|
||||
:class="{ active: pageContext.routeParams.section === 'actors' }"
|
||||
>Actors</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a
|
||||
href="/admin/revisions/scenes"
|
||||
|
||||
@@ -19,10 +19,16 @@
|
||||
>{{ avatar.sharpness.toFixed(2) }}</span>
|
||||
</span>
|
||||
|
||||
<span
|
||||
:title="`Added ${format(avatar.createdAt, 'yyyy-MM-dd')}, may not reflect photo age`"
|
||||
class="avatar-date"
|
||||
>{{ format(avatar.createdAt, '\'\'yy-MM') }}</span>
|
||||
|
||||
<a
|
||||
:href="getPath(avatar)"
|
||||
target="_blank"
|
||||
class="avatar-zoom"
|
||||
@click.stop
|
||||
>
|
||||
<Icon
|
||||
icon="search"
|
||||
@@ -32,6 +38,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { format } from 'date-fns';
|
||||
import getPath from '#/src/get-path.js';
|
||||
|
||||
defineProps({
|
||||
@@ -89,7 +96,8 @@ defineProps({
|
||||
}
|
||||
|
||||
.avatar-meta,
|
||||
.avatar-credit {
|
||||
.avatar-credit,
|
||||
.avatar-date {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
box-sizing: border-box;
|
||||
@@ -112,4 +120,10 @@ defineProps({
|
||||
bottom: .75rem;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.avatar-date {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -146,7 +146,6 @@ const { pageProps } = inject('pageContext');
|
||||
const {
|
||||
tag: pageTag,
|
||||
actor: pageActor,
|
||||
stash: pageStash,
|
||||
} = pageProps;
|
||||
|
||||
const search = ref('');
|
||||
@@ -177,7 +176,7 @@ const priorityTags = [
|
||||
'lesbian',
|
||||
];
|
||||
|
||||
const isActorTagsAvailable = computed(() => props.actorTags && (props.filters.actors.length > 0 || pageActor) && !pageStash);
|
||||
const isActorTagsAvailable = computed(() => props.actorTags && (props.filters.actors.length > 0 || pageActor));
|
||||
|
||||
const groupedTags = computed(() => {
|
||||
// can't show actor tags inside stash, because both require a join, and manticore currently only supports one
|
||||
@@ -225,6 +224,8 @@ const groupedTags = computed(() => {
|
||||
});
|
||||
|
||||
function toggleTag(tag, combine) {
|
||||
emit('update', 'onlyActorTags', showActorTags.value, false);
|
||||
|
||||
if (props.filters.tags.includes(tag.slug)) {
|
||||
emit('update', 'tags', props.filters.tags.filter((tagId) => tagId !== tag.slug));
|
||||
return;
|
||||
|
||||
@@ -287,6 +287,7 @@ const filters = ref({
|
||||
search: urlParsed.search.q,
|
||||
years: urlParsed.search.years?.split(',').filter(Boolean).map(Number) || [],
|
||||
tags: urlParsed.search.tags?.split(',').filter(Boolean) || [],
|
||||
onlyActorTags: Object.hasOwn(urlParsed.search, 'at'),
|
||||
entity: queryEntity,
|
||||
actors: queryActors,
|
||||
});
|
||||
@@ -346,6 +347,7 @@ async function search(options = {}) {
|
||||
years: filters.value.years.join(',') || undefined,
|
||||
actors: filters.value.actors.map((filterActor) => getActorIdentifier(filterActor)).join(',') || undefined, // don't include page actor ID in query, already a parameter
|
||||
tags: filters.value.tags.join(',') || undefined,
|
||||
at: (filters.value.tags.length > 0 && filters.value.onlyActorTags) || undefined,
|
||||
// e: filters.value.entity?.type === 'network' ? `_${filters.value.entity.slug}` : (filters.value.entity?.slug || undefined),
|
||||
e: filters.value.entity ? `${entityPrefixes[filters.value.entity.type]}${filters.value.entity.slug}` : undefined,
|
||||
}, { redirect: false });
|
||||
@@ -355,6 +357,7 @@ async function search(options = {}) {
|
||||
years: filters.value.years.filter(Boolean).join(','), // if we're on an actor page, that actor ID needs to be included
|
||||
actors: [pageActor, ...filters.value.actors].filter(Boolean).map((filterActor) => getActorIdentifier(filterActor)).join(','), // if we're on an actor page, that actor ID needs to be included
|
||||
tags: [pageTag?.slug, ...filters.value.tags].filter(Boolean).join(','),
|
||||
at: !!filters.value.onlyActorTags,
|
||||
stashId: pageStash?.id,
|
||||
e: entitySlug,
|
||||
scope: scope.value,
|
||||
|
||||
@@ -179,7 +179,7 @@ module.exports = {
|
||||
stashes: {
|
||||
nameLength: [2, 24],
|
||||
namePattern: /^[a-zA-Z0-9!?$&\s_-]+$/,
|
||||
viewRefreshCron: '* * * * *', // every minute
|
||||
viewRefreshCrontab: '* * * * *', // every minute
|
||||
viewRefreshCooldowns: {
|
||||
actors: 60, // minutes
|
||||
stashes: 1,
|
||||
@@ -192,4 +192,8 @@ module.exports = {
|
||||
s3Path: 'https://s3.wasabisys.com',
|
||||
videoRestrictions: [], // entity slugs, _ prefix for networks, hides trailer and teaser videos
|
||||
},
|
||||
sync: {
|
||||
enabled: true,
|
||||
crontab: '*/10 * * * *', // every 10 minutes
|
||||
},
|
||||
};
|
||||
|
||||
4
package-lock.json
generated
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "traxxx-web",
|
||||
"version": "0.49.7",
|
||||
"version": "0.51.4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "0.49.7",
|
||||
"version": "0.51.4",
|
||||
"dependencies": {
|
||||
"@brillout/json-serializer": "^0.5.8",
|
||||
"@dicebear/collection": "^7.0.5",
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
"overrides": {
|
||||
"vite": "$vite"
|
||||
},
|
||||
"version": "0.49.7",
|
||||
"version": "0.51.4",
|
||||
"imports": {
|
||||
"#/*": "./*.js"
|
||||
}
|
||||
|
||||
@@ -11,20 +11,6 @@
|
||||
/>
|
||||
</h2>
|
||||
|
||||
<li
|
||||
v-if="actor.aliases?.length"
|
||||
class="bio-item"
|
||||
>
|
||||
<dfn class="bio-label">Also known as</dfn>
|
||||
<span class="bio-value">
|
||||
<span
|
||||
v-for="alias in actor.aliases"
|
||||
:key="`alias-${alias.id}`"
|
||||
class="alias"
|
||||
>{{ alias.name }}</span>
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<Heart
|
||||
domain="actors"
|
||||
:item="actor"
|
||||
@@ -108,7 +94,7 @@ const photos = actor.photos.filter((photo) => photo.entropy > 5.5 && !badCredits
|
||||
.actor-header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export default '/actor/edit/@actorId/*';
|
||||
@@ -7,12 +7,12 @@
|
||||
<template v-if="apply">Your revision has been submitted. Thank you for your contribution!</template>
|
||||
<template v-else>Your revision has been submitted for review. Thank you for your contribution!</template>
|
||||
|
||||
<ul>
|
||||
<ul v-if="actor">
|
||||
<li>
|
||||
<a
|
||||
:href="`/actor/${actor.id}/${actor.slug}`"
|
||||
class="link"
|
||||
>Return to actor</a>
|
||||
>{{ creating ? 'Go' : 'Return' }} to actor</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
@@ -22,21 +22,21 @@
|
||||
>Make another edit</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<li v-if="!creating">
|
||||
<a
|
||||
:href="`/actor/revs/${actor.id}/${actor.slug}`"
|
||||
class="link"
|
||||
>Go to actor revisions</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<li v-if="!creating">
|
||||
<a
|
||||
:href="`/user/${user.username}/revisions/actors`"
|
||||
class="link"
|
||||
>Go to user revisions</a>
|
||||
</li>
|
||||
|
||||
<li v-if="user.role !== 'user'">
|
||||
<li v-if="user.role !== 'user' && !creating">
|
||||
<a
|
||||
href="/admin/revisions/actors"
|
||||
class="link"
|
||||
@@ -49,7 +49,10 @@
|
||||
v-else
|
||||
@submit.prevent
|
||||
>
|
||||
<div class="editor-header">
|
||||
<div
|
||||
v-if="actor"
|
||||
class="editor-header"
|
||||
>
|
||||
<h2 class="heading ellipsis">Edit actor #{{ actor.id }} - {{ actor.name }}</h2>
|
||||
|
||||
<a
|
||||
@@ -59,6 +62,13 @@
|
||||
>Go to actor</a>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else
|
||||
class="editor-header"
|
||||
>
|
||||
<h2 class="heading ellipsis">Add actor</h2>
|
||||
</div>
|
||||
|
||||
<ul class="nolist">
|
||||
<li
|
||||
v-for="item in fields"
|
||||
@@ -281,6 +291,7 @@
|
||||
</select>
|
||||
|
||||
<input
|
||||
v-if="item.hasDescription !== false"
|
||||
v-model="edits[item.key].description"
|
||||
class="description input"
|
||||
placeholder="Description"
|
||||
@@ -317,7 +328,7 @@
|
||||
|
||||
<div class="editor-actions">
|
||||
<Checkbox
|
||||
v-if="user.role !== 'user'"
|
||||
v-if="user.role !== 'user' && actor"
|
||||
label="Approve and apply immediately"
|
||||
:checked="apply"
|
||||
:disabled="editing.size === 0"
|
||||
@@ -346,6 +357,7 @@
|
||||
<script setup>
|
||||
import { ref, computed, inject } from 'vue';
|
||||
import { format } from 'date-fns';
|
||||
import omit from 'object.omit';
|
||||
|
||||
import EditSocials from '#/components/edit/socials.vue';
|
||||
import EditPlace from '#/components/edit/place.vue';
|
||||
@@ -364,10 +376,10 @@ import {
|
||||
const pageContext = inject('pageContext');
|
||||
|
||||
const user = pageContext.user;
|
||||
const actor = ref(pageContext.pageProps.actor);
|
||||
const actor = ref(pageContext.pageProps.actor || null);
|
||||
|
||||
const fields = computed(() => [
|
||||
...(actor.value.photos.length > 0 ? [{
|
||||
...(actor.value?.photos.length > 0 ? [{
|
||||
key: 'avatar',
|
||||
type: 'avatar',
|
||||
value: actor.value.avatar?.id,
|
||||
@@ -377,13 +389,13 @@ const fields = computed(() => [
|
||||
? [{
|
||||
key: 'name',
|
||||
type: 'string',
|
||||
value: actor.value.name,
|
||||
value: actor.value?.name,
|
||||
}]
|
||||
: []),
|
||||
{
|
||||
key: 'gender',
|
||||
type: 'select',
|
||||
value: actor.value.gender,
|
||||
value: actor.value?.gender || null,
|
||||
options: [null, 'female', 'male', 'transsexual', 'other'],
|
||||
inline: true,
|
||||
},
|
||||
@@ -391,7 +403,7 @@ const fields = computed(() => [
|
||||
key: 'dateOfBirth',
|
||||
label: 'date of birth',
|
||||
type: 'date',
|
||||
value: actor.value.dateOfBirth
|
||||
value: actor.value?.dateOfBirth
|
||||
? format(actor.value.dateOfBirth, 'yyyy-MM-dd')
|
||||
: null,
|
||||
inline: true,
|
||||
@@ -399,28 +411,28 @@ const fields = computed(() => [
|
||||
{
|
||||
key: 'socials',
|
||||
type: 'socials',
|
||||
value: actor.value.socials,
|
||||
value: actor.value?.socials || [],
|
||||
},
|
||||
{
|
||||
key: 'origin',
|
||||
type: 'place',
|
||||
value: {
|
||||
country: actor.value.origin?.country?.alpha2 || null,
|
||||
place: [actor.value.origin?.city, actor.value.origin?.state].filter(Boolean).join(', '),
|
||||
country: actor.value?.origin?.country?.alpha2 || null,
|
||||
place: [actor.value?.origin?.city, actor.value?.origin?.state].filter(Boolean).join(', '),
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'residence',
|
||||
type: 'place',
|
||||
value: {
|
||||
country: actor.value.residence?.country?.alpha2 || null,
|
||||
place: [actor.value.residence?.city, actor.value.residence?.state].filter(Boolean).join(', '),
|
||||
country: actor.value?.residence?.country?.alpha2 || null,
|
||||
place: [actor.value?.residence?.city, actor.value?.residence?.state].filter(Boolean).join(', '),
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'ethnicity',
|
||||
type: 'string',
|
||||
value: actor.value.ethnicity,
|
||||
value: actor.value?.ethnicity || null,
|
||||
suggestions: [
|
||||
'Asian',
|
||||
'Black',
|
||||
@@ -433,20 +445,20 @@ const fields = computed(() => [
|
||||
key: 'size',
|
||||
type: 'size',
|
||||
value: {
|
||||
metricHeight: actor.value.height?.metric,
|
||||
metricWeight: actor.value.weight?.metric,
|
||||
imperialHeight: actor.value.height?.imperial || [],
|
||||
imperialWeight: actor.value.weight?.imperial,
|
||||
metricHeight: actor.value?.height?.metric || null,
|
||||
metricWeight: actor.value?.weight?.metric || null,
|
||||
imperialHeight: actor.value?.height?.imperial || [],
|
||||
imperialWeight: actor.value?.weight?.imperial || null,
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'figure',
|
||||
type: 'figure',
|
||||
value: {
|
||||
bust: actor.value.bust,
|
||||
cup: actor.value.cup,
|
||||
waist: actor.value.waist,
|
||||
hip: actor.value.hip,
|
||||
bust: actor.value?.bust || null,
|
||||
cup: actor.value?.cup || null,
|
||||
waist: actor.value?.waist || null,
|
||||
hip: actor.value?.hip || null,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -454,25 +466,25 @@ const fields = computed(() => [
|
||||
type: 'augmentation',
|
||||
note: 'Provide explicit evidence, such as social media posts, visible scarring, or before/after. Avoid "it\'s obvious".',
|
||||
value: {
|
||||
naturalBoobs: actor.value.naturalBoobs,
|
||||
boobsVolume: actor.value.boobsVolume,
|
||||
boobsImplant: actor.value.boobsImplant,
|
||||
boobsPlacement: actor.value.boobsPlacement,
|
||||
boobsIncision: actor.value.boobsIncision,
|
||||
boobsSurgeon: actor.value.boobsSurgeon,
|
||||
naturalButt: actor.value.naturalButt,
|
||||
buttVolume: actor.value.buttVolume,
|
||||
buttImplant: actor.value.buttImplant,
|
||||
naturalLips: actor.value.naturalLips,
|
||||
lipsVolume: actor.value.lipsVolume,
|
||||
naturalLabia: actor.value.naturalLabia,
|
||||
naturalBoobs: actor.value?.naturalBoobs ?? null,
|
||||
boobsVolume: actor.value?.boobsVolume || null,
|
||||
boobsImplant: actor.value?.boobsImplant || null,
|
||||
boobsPlacement: actor.value?.boobsPlacement || null,
|
||||
boobsIncision: actor.value?.boobsIncision || null,
|
||||
boobsSurgeon: actor.value?.boobsSurgeon || null,
|
||||
naturalButt: actor.value?.naturalButt ?? null,
|
||||
buttVolume: actor.value?.buttVolume || null,
|
||||
buttImplant: actor.value?.buttImplant || null,
|
||||
naturalLips: actor.value?.naturalLips ?? null,
|
||||
lipsVolume: actor.value?.lipsVolume || null,
|
||||
naturalLabia: actor.value?.naturalLabia ?? null,
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'hairColor',
|
||||
label: 'hair color',
|
||||
type: 'select',
|
||||
value: actor.value.hairColor,
|
||||
value: actor.value?.hairColor || null,
|
||||
options: [
|
||||
null,
|
||||
'black',
|
||||
@@ -491,7 +503,7 @@ const fields = computed(() => [
|
||||
key: 'eyes',
|
||||
label: 'eye color',
|
||||
type: 'select',
|
||||
value: actor.value.eyes,
|
||||
value: actor.value?.eyes || null,
|
||||
options: [
|
||||
null,
|
||||
'blue',
|
||||
@@ -506,8 +518,8 @@ const fields = computed(() => [
|
||||
key: 'tattoos',
|
||||
type: 'has',
|
||||
value: {
|
||||
has: actor.value.hasTattoos,
|
||||
description: actor.value.tattoos,
|
||||
has: actor.value?.hasTattoos ?? null,
|
||||
description: actor.value?.tattoos || null,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -515,14 +527,14 @@ const fields = computed(() => [
|
||||
type: 'has',
|
||||
note: 'Excludes earrings',
|
||||
value: {
|
||||
has: actor.value.hasPiercings,
|
||||
description: actor.value.piercings,
|
||||
has: actor.value?.hasPiercings ?? null,
|
||||
description: actor.value?.piercings || null,
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'agency',
|
||||
type: 'string',
|
||||
value: actor.value.agency,
|
||||
value: actor.value?.agency || null,
|
||||
suggestions: [
|
||||
'101 Modeling',
|
||||
'Adult Talent Managers (ATMLA)',
|
||||
@@ -540,25 +552,41 @@ const fields = computed(() => [
|
||||
key: 'penis',
|
||||
type: 'penis',
|
||||
value: {
|
||||
metricLength: actor.value.penisLength?.metric,
|
||||
metricGirth: actor.value.penisGirth?.metric,
|
||||
imperialLength: actor.value.penisLength?.imperial,
|
||||
imperialGirth: actor.value.penisGirth?.imperial,
|
||||
isCircumcised: actor.value.isCircumcised,
|
||||
metricLength: actor.value?.penisLength?.metric || null,
|
||||
metricGirth: actor.value?.penisGirth?.metric || null,
|
||||
imperialLength: actor.value?.penisLength?.imperial || null,
|
||||
imperialGirth: actor.value?.penisGirth?.imperial || null,
|
||||
isCircumcised: actor.value?.isCircumcised || null,
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'dateOfDeath',
|
||||
label: 'date of death',
|
||||
type: 'date',
|
||||
value: actor.value.dateOfDeath
|
||||
value: actor.value?.dateOfDeath
|
||||
? format(actor.value.dateOfDeath, 'yyyy-MM-dd')
|
||||
: null,
|
||||
},
|
||||
]);
|
||||
{
|
||||
key: 'allowGlobalMatch',
|
||||
label: 'global match',
|
||||
type: 'has',
|
||||
note: 'Allow this actor to be assigned to scenes automatically, overriding single-name protections.',
|
||||
hasDescription: false,
|
||||
value: {
|
||||
has: actor.value?.allowGlobalMatch ?? null,
|
||||
},
|
||||
},
|
||||
]
|
||||
.filter((field) => (actor.value ? true : ['name', 'gender'].includes(field.key)))
|
||||
.map((field) => ({
|
||||
...field,
|
||||
forced: actor.value ? field.forced : true,
|
||||
})));
|
||||
|
||||
const editing = ref(new Set());
|
||||
const editing = ref(new Set(actor.value ? [] : ['name', 'gender']));
|
||||
const edits = ref(Object.fromEntries(fields.value.map((field) => [field.key, field.value])));
|
||||
const creating = !actor.value;
|
||||
const comment = ref(null);
|
||||
const apply = ref(user.role !== 'user');
|
||||
const submitting = ref(false);
|
||||
@@ -600,6 +628,9 @@ const keyMap = {
|
||||
has: 'hasPiercings',
|
||||
description: 'piercings',
|
||||
},
|
||||
allowGlobalMatch: {
|
||||
has: 'allowGlobalMatch',
|
||||
},
|
||||
};
|
||||
|
||||
const groupMap = {
|
||||
@@ -615,7 +646,7 @@ async function submit() {
|
||||
|
||||
await post('/revisions/actors', {
|
||||
actorId: actor.value.id,
|
||||
edits: {
|
||||
edits: omit({
|
||||
...Object.fromEntries(Array.from(editing.value).flatMap((key) => {
|
||||
if (edits.value[key] && typeof edits.value[key] === 'object' && !Array.isArray(edits.value[key])) {
|
||||
return Object.entries(edits.value[key]).map(([valueKey, value]) => [keyMap[key]?.[valueKey] || valueKey, value]);
|
||||
@@ -629,15 +660,16 @@ async function submit() {
|
||||
penisLength: penisUnits.value === 'imperial' ? edits.value.penis.imperialLength : edits.value.penis.metricLength,
|
||||
penisGirth: penisUnits.value === 'imperial' ? edits.value.penis.imperialGirth : edits.value.penis.metricGirth,
|
||||
}).filter(([key]) => editing.value.has(groupMap[key] || key))),
|
||||
metricHeight: undefined,
|
||||
metricWeight: undefined,
|
||||
imperialHeight: undefined,
|
||||
imperialWeight: undefined,
|
||||
metricLength: undefined,
|
||||
metricGirth: undefined,
|
||||
imperialLength: undefined,
|
||||
imperialGirth: undefined,
|
||||
},
|
||||
}, [
|
||||
'metricHeight',
|
||||
'metricWeight',
|
||||
'imperialHeight',
|
||||
'imperialWeight',
|
||||
'metricLength',
|
||||
'metricGirth',
|
||||
'imperialLength',
|
||||
'imperialGirth',
|
||||
]),
|
||||
sizeUnits: sizeUnits.value,
|
||||
figureUnits: figureUnits.value,
|
||||
penisUnits: penisUnits.value,
|
||||
34
pages/actors/edit/+onBeforeRender.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { redirect } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
||||
|
||||
import { fetchActorsById } from '#/src/actors.js';
|
||||
import { fetchCountries } from '#/src/countries.js';
|
||||
|
||||
export async function onBeforeRender(pageContext) {
|
||||
if (!pageContext.user) {
|
||||
throw redirect(`/login?r=${encodeURIComponent(pageContext.urlOriginal)}`);
|
||||
}
|
||||
|
||||
const [actor] = pageContext.routeParams.actorId
|
||||
? await fetchActorsById([Number(pageContext.routeParams.actorId)], {}, pageContext.user)
|
||||
: [];
|
||||
|
||||
const countries = await fetchCountries();
|
||||
|
||||
/*
|
||||
if (!actor) {
|
||||
throw render(404, `Cannot find actor '${pageContext.routeParams.actorId}'.`);
|
||||
}
|
||||
*/
|
||||
|
||||
return {
|
||||
pageContext: {
|
||||
title: actor
|
||||
? `Editing '${actor.name}'`
|
||||
: 'Adding actor',
|
||||
pageProps: {
|
||||
actor,
|
||||
countries,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
20
pages/actors/edit/+route.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// export default '/actor/edit/@actorId/*';
|
||||
// import { redirect } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
||||
import { match } from 'path-to-regexp';
|
||||
|
||||
const path = '/actor/edit/:actorId/:actorSlug?';
|
||||
const urlMatch = match(path, { decode: decodeURIComponent });
|
||||
|
||||
export default (pageContext) => {
|
||||
const matched = urlMatch(pageContext.urlPathname);
|
||||
|
||||
if (matched) {
|
||||
return {
|
||||
routeParams: matched.params.actorId ? {
|
||||
actorId: matched.params.actorId,
|
||||
} : {},
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
@@ -3,6 +3,13 @@
|
||||
<h2 class="heading">Admin Panel</h2>
|
||||
|
||||
<ul class="menu">
|
||||
<li>
|
||||
<a
|
||||
href="/admin/actors"
|
||||
class="link"
|
||||
>Actors</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a
|
||||
href="/admin/revisions/scenes"
|
||||
|
||||
337
pages/admin/actors/+Page.vue
Normal file
@@ -0,0 +1,337 @@
|
||||
<template>
|
||||
<Admin class="page">
|
||||
<div class="header">
|
||||
<input
|
||||
v-model="actorQuery"
|
||||
type="search"
|
||||
placeholder="Search actors"
|
||||
class="input search"
|
||||
@search="searchActors"
|
||||
>
|
||||
|
||||
<div class="header-actions">
|
||||
<button
|
||||
class="button"
|
||||
:disabled="selectedActors.size === 0"
|
||||
@click="selectedActors = new Set()"
|
||||
><Icon icon="cancel-square" />Deselect</button>
|
||||
|
||||
<button
|
||||
class="button"
|
||||
:disabled="selectedActors.size === 0"
|
||||
@click="showMergeDialog = true"
|
||||
><Icon icon="make-group" />Merge</button>
|
||||
|
||||
<button
|
||||
class="button"
|
||||
@click="showAddDialog = true"
|
||||
><Icon icon="plus3" />Add actor</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="actors">
|
||||
<thead class="actors-header">
|
||||
<tr>
|
||||
<th class="actor-id">ID</th>
|
||||
<th class="actor-name">Entity</th>
|
||||
<th class="actor-avatar">Avatar</th>
|
||||
<th class="actor-name">Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="actors-body">
|
||||
<tr
|
||||
v-for="(actor, index) in actors"
|
||||
:key="`actor-${actor.id}`"
|
||||
class="actor"
|
||||
>
|
||||
<td class="actor-id ellipsis">
|
||||
<a
|
||||
:href="`/actor/${actor.id}/${actor.slug}`"
|
||||
target="_blank"
|
||||
class="nolink"
|
||||
>{{ actor.id }}</a>
|
||||
</td>
|
||||
|
||||
<td
|
||||
v-tooltip="actor.entity?.name || 'Global'"
|
||||
class="actor-entity ellipsis"
|
||||
>
|
||||
<img
|
||||
v-if="actor.entity"
|
||||
:src="`/logos/${actor.entity.slug}/favicon_dark.png`"
|
||||
class="actor-favicon"
|
||||
>
|
||||
|
||||
<Icon
|
||||
v-else
|
||||
icon="device_hub"
|
||||
class="actor-global"
|
||||
/>
|
||||
</td>
|
||||
|
||||
<td class="actor-avatar">
|
||||
<img
|
||||
v-if="actor.avatar"
|
||||
:src="getPath(actor.avatar, 'lazy')"
|
||||
loading="lazy"
|
||||
class="avatar"
|
||||
>
|
||||
|
||||
<img
|
||||
v-if="actor.avatar"
|
||||
:src="getPath(actor.avatar)"
|
||||
loading="lazy"
|
||||
class="avatar-zoom"
|
||||
>
|
||||
</td>
|
||||
|
||||
<td class="actor-name ellipsis">{{ actor.name }}</td>
|
||||
|
||||
<td class="actor-actions">
|
||||
<div class="actions">
|
||||
<Checkbox
|
||||
:checked="selectedActors.has(actor.id)"
|
||||
@change="(isChecked) => selectActors(actor, isChecked, index)"
|
||||
/>
|
||||
|
||||
<a
|
||||
:href="`/actor/edit/${actor.id}/${actor.slug}`"
|
||||
target="_blank"
|
||||
>
|
||||
<Icon
|
||||
v-tooltip="'Edit bio'"
|
||||
icon="pencil5"
|
||||
class="actor-action action-merge"
|
||||
/>
|
||||
</a>
|
||||
|
||||
<Icon
|
||||
v-tooltip="'Merge'"
|
||||
icon="make-group"
|
||||
class="actor-action action-merge"
|
||||
@click="activeActor = actor; showMergeDialog = true;"
|
||||
/>
|
||||
|
||||
<!--
|
||||
<Icon
|
||||
v-tooltip="'Delete'"
|
||||
icon="bin"
|
||||
class="actor-action action-delete"
|
||||
/>
|
||||
-->
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<MergeActors
|
||||
v-if="showMergeDialog"
|
||||
:actors="activeActor ? [activeActor] : actors.filter((actor) => selectedActors.has(actor.id))"
|
||||
@close="showMergeDialog = false; activeActor = null;"
|
||||
/>
|
||||
|
||||
<AddActor
|
||||
v-if="showAddDialog"
|
||||
@close="showAddDialog = false"
|
||||
/>
|
||||
</Admin>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, inject, onMounted } from 'vue';
|
||||
|
||||
import Admin from '#/components/admin/admin.vue';
|
||||
import Checkbox from '#/components/form/checkbox.vue';
|
||||
import MergeActors from '#/components/actors/merge.vue';
|
||||
import AddActor from '#/components/actors/add.vue';
|
||||
|
||||
import getPath from '#/src/get-path.js';
|
||||
import navigate from '#/src/navigate.js';
|
||||
// import { get } from '#/src/api.js';
|
||||
|
||||
const { pageProps, urlParsed } = inject('pageContext');
|
||||
|
||||
const actors = ref(pageProps.actors);
|
||||
const selectedActors = ref(new Set([]));
|
||||
const activeActor = ref(null);
|
||||
const actorQuery = ref(urlParsed.search.q || null);
|
||||
|
||||
const lastSelectedIndex = ref(null);
|
||||
const holdingShift = ref(false);
|
||||
const showMergeDialog = ref(false);
|
||||
const showAddDialog = ref(false);
|
||||
|
||||
function selectActors(selectedActor, isChecked, index) {
|
||||
const [start, end] = holdingShift.value
|
||||
? [index, lastSelectedIndex.value].toSorted((indexA, indexB) => indexA - indexB)
|
||||
: [index, index];
|
||||
|
||||
const actorIds = actors.value
|
||||
.slice(start, end + 1)
|
||||
.map((actor) => actor.id);
|
||||
|
||||
actorIds.forEach((actorId) => {
|
||||
if (isChecked) {
|
||||
selectedActors.value.add(actorId);
|
||||
} else {
|
||||
selectedActors.value.delete(actorId);
|
||||
}
|
||||
});
|
||||
|
||||
lastSelectedIndex.value = index;
|
||||
}
|
||||
|
||||
async function searchActors() {
|
||||
navigate('/admin/actors', { q: actorQuery.value || undefined }, { redirect: true });
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Shift') {
|
||||
holdingShift.value = true;
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('keyup', (event) => {
|
||||
if (event.key === 'Shift') {
|
||||
holdingShift.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('blur', () => {
|
||||
holdingShift.value = false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.search {
|
||||
max-width: 20rem;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: .5rem;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.actors-header tr {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.actors, .actors th, .actors td {
|
||||
border-collapse: collapse;
|
||||
padding: .5rem;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.actor {
|
||||
&:nth-child(2n) {
|
||||
background: var(--glass-weak-50);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: var(--glass-weak-40);
|
||||
}
|
||||
}
|
||||
|
||||
.actor-id {
|
||||
width: 6rem;
|
||||
font-family: monospace;
|
||||
font-size: 1rem;
|
||||
user-select: all;
|
||||
}
|
||||
|
||||
.actor-entity {
|
||||
width: 2rem;
|
||||
}
|
||||
|
||||
.actor-favicon {
|
||||
width: 1rem;
|
||||
margin-left: .5rem;
|
||||
}
|
||||
|
||||
.actor-global {
|
||||
background: var(--primary);
|
||||
fill: var(--text-light);
|
||||
padding: .5rem;
|
||||
border-radius: 1rem;
|
||||
}
|
||||
|
||||
th.actor-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: .5rem;
|
||||
|
||||
.button:first-child {
|
||||
margin-left: .5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.actor-actions {
|
||||
width: 1%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.actor-action {
|
||||
padding: .5rem .75rem;
|
||||
fill: var(--glass);
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
fill: var(--primary);
|
||||
}
|
||||
|
||||
&:hover.action-delete {
|
||||
fill: var(--error);
|
||||
}
|
||||
}
|
||||
|
||||
.actor-avatar {
|
||||
width: 5rem;
|
||||
position: relative;
|
||||
line-height: 0;
|
||||
|
||||
&:hover .avatar-zoom,
|
||||
&:active .avatar-zoom {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
.avatar {
|
||||
height: 3.5rem;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.avatar-zoom {
|
||||
display: none;
|
||||
height: 50vh;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 10;
|
||||
box-shadow: 0 0 3px var(--shadow-weak-30);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.check-container {
|
||||
display: inline-flex;
|
||||
padding: .5rem .75rem;
|
||||
}
|
||||
</style>
|
||||
26
pages/admin/actors/+onBeforeRender.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
||||
|
||||
import { fetchActors } from '#/src/actors.js';
|
||||
import verifyAbility from '#/utils/verify-ability.js';
|
||||
|
||||
export default async function onBeforeRender(pageContext) {
|
||||
if (!pageContext.user || !verifyAbility(pageContext.user, 'actor', 'merge')) {
|
||||
throw render(404);
|
||||
}
|
||||
|
||||
const { actors } = await fetchActors({
|
||||
query: pageContext.urlParsed.search.q,
|
||||
}, {
|
||||
limit: 100,
|
||||
order: pageContext.urlParsed.search.order?.split('.') || ['likes', 'desc'],
|
||||
}, pageContext.user);
|
||||
|
||||
return {
|
||||
pageContext: {
|
||||
title: 'Actors',
|
||||
pageProps: {
|
||||
actors,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
||||
|
||||
import { fetchActorRevisions } from '#/src/actors.js';
|
||||
import verifyAbility from '#/utils/verify-ability.js';
|
||||
|
||||
export async function onBeforeRender(pageContext) {
|
||||
if (!pageContext.user || pageContext.user.role === 'user') {
|
||||
if (!pageContext.user || !verifyAbility(pageContext.user, 'actor', 'update')) {
|
||||
throw render(404);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
||||
|
||||
import { fetchSceneRevisions } from '#/src/scenes.js';
|
||||
import verifyAbility from '#/utils/verify-ability.js';
|
||||
|
||||
export async function onBeforeRender(pageContext) {
|
||||
if (!pageContext.user || pageContext.user.role === 'user') {
|
||||
if (!pageContext.user || !verifyAbility(pageContext.user, 'scene', 'update')) {
|
||||
throw render(404);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
</a>
|
||||
|
||||
<a
|
||||
v-if="user?.abilities?.some((ability) => ability.plainUrls)"
|
||||
v-if="user?.abilities?.some((ability) => ability.subject === 'plainUrls')"
|
||||
:href="entity.url"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
</div>
|
||||
|
||||
<Link
|
||||
:href="user?.abilities?.some((ability) => ability.plainUrls) ? scene.url : scene.watchUrl"
|
||||
:href="user?.abilities?.some((ability) => ability.subject === 'plainUrls') ? scene.url : scene.watchUrl"
|
||||
:title="scene.date ? formatDate(scene.date.toISOString(), 'y-MM-dd hh:mm') : `Release date unknown, added ${formatDate(scene.createdAt, 'y-MM-dd')}`"
|
||||
target="_blank"
|
||||
class="date nolink"
|
||||
@@ -140,30 +140,41 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tags">
|
||||
<div
|
||||
v-for="actorTags in tags"
|
||||
:key="`tags-${actorTags.actor?.slug || 'scene'}`"
|
||||
class="tags-section"
|
||||
<ul class="tags nolist">
|
||||
<li
|
||||
v-for="tag in tags"
|
||||
:key="`tag-${tag.id}`"
|
||||
class="tag"
|
||||
:class="{ 'has-actors': tag.actors.length > 0 }"
|
||||
>
|
||||
<ul class="nolist">
|
||||
<li
|
||||
v-if="actorTags.actor"
|
||||
class="tags-actor"
|
||||
>{{ actorTags.actor.name }}:</li>
|
||||
<Link
|
||||
:href="`/tag/${tag.slug}`"
|
||||
class="tag-name nolink"
|
||||
>{{ tag.name }}</Link>
|
||||
|
||||
<li
|
||||
v-for="tag in actorTags.tags"
|
||||
:key="`tag-${tag.id}`"
|
||||
<span
|
||||
v-for="tagActor in tag.actors"
|
||||
:key="`tagactor-${tagActor.id}`"
|
||||
v-tooltip="{
|
||||
content: `Performed by ${tagActor.name}`,
|
||||
triggers: ['hover', 'click'],
|
||||
}"
|
||||
class="tag-frame"
|
||||
>
|
||||
<img
|
||||
v-if="tagActor.avatar"
|
||||
class="tag-avatar"
|
||||
:src="getPath(tagActor.avatar, 'thumbnail')"
|
||||
>
|
||||
<Link
|
||||
:href="`/tag/${tag.slug}`"
|
||||
class="tag nolink"
|
||||
>{{ tag.name }}</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Icon
|
||||
v-else
|
||||
icon="star-full"
|
||||
class="tag-star"
|
||||
/>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div
|
||||
v-if="scene.movies.length > 0 || scene.series.length > 0"
|
||||
@@ -424,6 +435,7 @@ import Cookies from 'js-cookie';
|
||||
import { formatDate, formatDuration } from '#/utils/format.js';
|
||||
import events from '#/src/events.js';
|
||||
import processSummaryTemplate from '#/utils/process-summary-template.js';
|
||||
import getPath from '#/src/get-path.js';
|
||||
|
||||
import Banner from '#/components/media/banner.vue';
|
||||
import ActorTile from '#/components/actors/tile.vue';
|
||||
@@ -450,16 +462,44 @@ const {
|
||||
|
||||
const { scene } = pageProps;
|
||||
|
||||
const tags = [
|
||||
{
|
||||
tags: scene.tags.filter((tag) => tag.actorId === null),
|
||||
actor: null,
|
||||
},
|
||||
...scene.actors.map((actor) => ({
|
||||
actor,
|
||||
tags: scene.tags.filter((tag) => tag.actorId === actor.id),
|
||||
})),
|
||||
].filter((actorTags) => actorTags.tags.length > 0);
|
||||
/*
|
||||
const tags = scene.tags.map((tag) => ({
|
||||
...tag,
|
||||
actor: scene.actors.find((actor) => actor.id === tag.actorId) || null,
|
||||
}));
|
||||
*/
|
||||
|
||||
const actorsById = Object.fromEntries(scene.actors.map((actor) => [actor.id, actor]));
|
||||
|
||||
const tags = Array.from(scene.tags
|
||||
.reduce((acc, tag) => {
|
||||
const accTag = acc.get(tag.id);
|
||||
|
||||
if (accTag && tag.actorId) {
|
||||
return acc.set(tag.id, {
|
||||
...tag,
|
||||
actors: [...accTag.actors, actorsById[tag.actorId]].toSorted((actorA, actorB) => actorA.name.localeCompare(actorB.name)),
|
||||
});
|
||||
}
|
||||
|
||||
if (accTag) {
|
||||
// shouldn't happen, but account for it
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (tag.actorId) {
|
||||
return acc.set(tag.id, {
|
||||
...tag,
|
||||
actors: [actorsById[tag.actorId]],
|
||||
});
|
||||
}
|
||||
|
||||
return acc.set(tag.id, {
|
||||
...tag,
|
||||
actors: [],
|
||||
});
|
||||
}, new Map())
|
||||
.values());
|
||||
|
||||
const showSummaryDialog = ref(false);
|
||||
|
||||
@@ -664,7 +704,7 @@ function copySummary() {
|
||||
.tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: .25rem 1rem;
|
||||
gap: .35rem;
|
||||
}
|
||||
|
||||
.tags-section {
|
||||
@@ -684,25 +724,60 @@ function copySummary() {
|
||||
overflow-x: auto;
|
||||
|
||||
.actor {
|
||||
width: 10rem;
|
||||
width: 9rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.tag {
|
||||
padding: .5rem;
|
||||
display: flex;
|
||||
border-radius: .25rem;
|
||||
margin: 0 .25rem .25rem 0;
|
||||
background: var(--background);
|
||||
box-shadow: 0 0 3px var(--shadow-weak-30);
|
||||
overflow: hidden;
|
||||
|
||||
&:hover {
|
||||
box-shadow: 0 0 3px var(--shadow-weak-20);
|
||||
}
|
||||
}
|
||||
|
||||
.tag-name {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: .5rem;
|
||||
|
||||
&:hover {
|
||||
color: var(--primary);
|
||||
box-shadow: 0 0 3px var(--shadow-weak-20);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.tag-frame {
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
width: 2.25rem;
|
||||
height: 2.25rem;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
box-shadow: inset 0 0 3px var(--shadow-weak-20);
|
||||
pointer-events: none; /* so it doesn't block hover/click on the image */
|
||||
}
|
||||
}
|
||||
|
||||
.tag-avatar {
|
||||
height: 350%;
|
||||
}
|
||||
|
||||
.tag-star {
|
||||
height: 100%;
|
||||
fill: var(--primary);
|
||||
}
|
||||
|
||||
.movies,
|
||||
.series {
|
||||
display: grid;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="header">
|
||||
<h2 class="title">{{ tag.name }}</h2>
|
||||
<h2
|
||||
:title="`${tag.name} (#${tag.id})`"
|
||||
class="title"
|
||||
>{{ tag.name }}</h2>
|
||||
|
||||
<Heart
|
||||
domain="tags"
|
||||
|
||||
241
src/actors.js
@@ -3,6 +3,7 @@ import { differenceInYears } from 'date-fns';
|
||||
import { unit } from 'mathjs';
|
||||
import { MerkleJson } from 'merkle-json';
|
||||
import moment from 'moment';
|
||||
import { nanoid } from 'nanoid';
|
||||
import omit from 'object.omit';
|
||||
import convert from 'convert';
|
||||
import unprint from 'unprint';
|
||||
@@ -21,6 +22,8 @@ import slugify from '../utils/slugify.js';
|
||||
import { curateRevision } from './revisions.js';
|
||||
import { interpolateProfiles, platformsByHostname } from '../common/actors.mjs'; // eslint-disable-line import/namespace
|
||||
import { resolvePlace } from '../common/geo.mjs'; // eslint-disable-line import/namespace
|
||||
import { syncScenes, syncActors, syncStashes } from './sync.js';
|
||||
import verifyAbility from '../utils/verify-ability.js';
|
||||
|
||||
const logger = initLogger();
|
||||
const mj = new MerkleJson();
|
||||
@@ -53,15 +56,28 @@ const keyMap = {
|
||||
hasTattoos: 'has_tattoos',
|
||||
hasPiercings: 'has_piercings',
|
||||
isCircumcised: 'circumcised',
|
||||
allowGlobalMatch: 'allow_global_match',
|
||||
};
|
||||
|
||||
const socialsOrder = ['onlyfans', 'fansly', 'twitter', 'instagram', 'loyalfans', 'manyvids', 'pornhub', 'linktree', null];
|
||||
|
||||
export function curateActor(actor, context = {}) {
|
||||
if (!actor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
id: actor.id,
|
||||
slug: actor.slug,
|
||||
name: actor.name,
|
||||
aliases: actor.aliases || [], // used for profile pages
|
||||
alias: actor.alias
|
||||
? {
|
||||
id: actor.alias.id,
|
||||
slug: actor.alias.slug,
|
||||
name: actor.alias.name,
|
||||
}
|
||||
: null,
|
||||
gender: actor.gender,
|
||||
age: actor.age,
|
||||
ethnicity: actor.ethnicity,
|
||||
@@ -128,6 +144,7 @@ export function curateActor(actor, context = {}) {
|
||||
...actor.avatar,
|
||||
sfw_media: actor.sfw_avatar,
|
||||
}),
|
||||
allowGlobalMatch: actor.allow_global_match,
|
||||
socials: context.socials?.map((social) => ({
|
||||
id: social.id,
|
||||
url: social.url,
|
||||
@@ -228,8 +245,10 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
||||
knex.raw('COALESCE(residence_countries.alias, residence_countries.name) as residence_country_name'),
|
||||
knex.raw('row_to_json(entities) as entity'),
|
||||
knex.raw('row_to_json(sfw_media) as sfw_avatar'),
|
||||
knex.raw('json_agg(aliases) filter (where aliases.id is not null) as aliases'),
|
||||
)
|
||||
.leftJoin('actors_meta', 'actors_meta.actor_id', 'actors.id')
|
||||
.leftJoin('actors as aliases', 'aliases.alias_for', 'actors.id')
|
||||
.leftJoin('countries as birth_countries', 'birth_countries.alpha2', 'actors.birth_country_alpha2')
|
||||
.leftJoin('countries as residence_countries', 'residence_countries.alpha2', 'actors.residence_country_alpha2')
|
||||
.leftJoin('media as avatars', 'avatars.id', 'actors.avatar_media_id')
|
||||
@@ -255,14 +274,17 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
||||
knex('actors_avatars')
|
||||
.select(
|
||||
'media.*',
|
||||
'actors_avatars.actor_id',
|
||||
// 'actors_avatars.actor_id',
|
||||
'actors_profiles.actor_id',
|
||||
knex.raw('json_agg(actors_avatars.profile_id) as profile_ids'),
|
||||
knex.raw('row_to_json(sfw_media) as sfw_media'),
|
||||
)
|
||||
.whereIn('actor_id', actorIds)
|
||||
.whereIn('actors_profiles.actor_id', actorIds)
|
||||
.leftJoin('media', 'media.id', 'actors_avatars.media_id')
|
||||
.leftJoin('media as sfw_media', 'sfw_media.id', 'media.sfw_media_id')
|
||||
.groupBy('media.id', 'sfw_media.id', 'actors_avatars.actor_id')
|
||||
.leftJoin('actors_profiles', 'actors_profiles.id', 'actors_avatars.profile_id')
|
||||
// .groupBy('media.id', 'sfw_media.id', 'actors_avatars.actor_id')
|
||||
.groupBy('media.id', 'sfw_media.id', 'actors_profiles.actor_id')
|
||||
.orderBy(knex.raw('max(actors_avatars.created_at)'), 'desc'),
|
||||
knex('actors_socials')
|
||||
.whereIn('actor_id', actorIds),
|
||||
@@ -361,17 +383,23 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
.innerJoin('actors', 'actors.id', 'actors_stashed.actor_id')
|
||||
.where('stash_id', filters.stashId);
|
||||
} else {
|
||||
builder.select(knex.raw('*, weight() as _score'));
|
||||
builder
|
||||
.select(knex.raw('*, weight() as _score'))
|
||||
.where('alias_for', 0);
|
||||
}
|
||||
|
||||
if (filters.query) {
|
||||
if (filters.query.charAt(0) === '#') {
|
||||
builder.where('id', Number(escape(filters.query.slice(1))));
|
||||
} else {
|
||||
builder.whereRaw('match(\'@name :query:\', actors)', { query: escape(filters.query) });
|
||||
builder.whereRaw(`match('@(name,aliases) :query:${filters.query.charAt(0) === '=' ? '' : '*'}', actors)`, { query: escape(filters.query) });
|
||||
}
|
||||
}
|
||||
|
||||
if (filters.isGlobal) {
|
||||
builder.where('entity_id', 0);
|
||||
}
|
||||
|
||||
// attribute filters
|
||||
['country'].forEach((attribute) => {
|
||||
if (filters[attribute]) {
|
||||
@@ -434,7 +462,10 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
}
|
||||
|
||||
if (options.order?.[0] === 'name') {
|
||||
builder.orderBy('actors.slug', options.order[1]);
|
||||
builder.orderBy([
|
||||
{ column: 'actors.slug', order: options.order[1] },
|
||||
{ column: 'actors.entity_id', order: 'asc' },
|
||||
]);
|
||||
} else if (options.order?.[0] === 'likes') {
|
||||
builder.orderBy([
|
||||
{ column: 'actors.stashed', order: options.order[1] },
|
||||
@@ -463,6 +494,10 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
]);
|
||||
} else {
|
||||
builder.orderBy('actors.slug', 'asc');
|
||||
builder.orderBy([
|
||||
{ column: 'actors.slug', order: 'asc' },
|
||||
{ column: 'actors.entity_id', order: 'asc' },
|
||||
]);
|
||||
}
|
||||
})
|
||||
.limit(options.limit)
|
||||
@@ -521,6 +556,196 @@ export async function fetchActors(filters, rawOptions, reqUser) {
|
||||
};
|
||||
}
|
||||
|
||||
function curateActorEntry(actor, context) {
|
||||
return {
|
||||
name: actor.name,
|
||||
slug: slugify(actor.name),
|
||||
entry_id: nanoid(), // allows for manual creation of multiple actors with the same name
|
||||
gender: actor.gender,
|
||||
allow_global_match: actor.allowGlobalMatch,
|
||||
comment: context?.comment,
|
||||
};
|
||||
}
|
||||
|
||||
export async function createActor(newActor, context, reqUser) {
|
||||
if (!reqUser || reqUser.role === 'user') {
|
||||
throw new HttpError('You are not permitted to create actors', 403);
|
||||
}
|
||||
|
||||
const curatedActorEntry = curateActorEntry(newActor, context);
|
||||
const [actorEntry] = await knex('actors').insert(curatedActorEntry).returning('*');
|
||||
|
||||
await syncActors([actorEntry.id]);
|
||||
|
||||
return curateActor(actorEntry);
|
||||
}
|
||||
|
||||
export async function mergeActors(targetActorId, sourceActorIds, reqUser) {
|
||||
if (!verifyAbility(reqUser, 'actor', 'merge')) {
|
||||
throw new HttpError('You are not permitted to merge actors', 403);
|
||||
}
|
||||
|
||||
if (sourceActorIds.includes(targetActorId)) {
|
||||
throw new HttpError('Cannot merge actor profile into itself', 400);
|
||||
}
|
||||
|
||||
const [targetActor, sourceActors] = await Promise.all([
|
||||
knex('actors')
|
||||
.where('id', targetActorId)
|
||||
.whereNull('entity_id')
|
||||
.whereNull('alias_for')
|
||||
.first(),
|
||||
knex('actors')
|
||||
.whereIn('id', sourceActorIds),
|
||||
]);
|
||||
|
||||
if (!targetActor) {
|
||||
throw new HttpError('Target actor not found', 404);
|
||||
}
|
||||
|
||||
if (sourceActors.length < sourceActorIds.length) {
|
||||
throw new HttpError('Source actor not found', 404);
|
||||
}
|
||||
|
||||
const trx = await knex.transaction();
|
||||
|
||||
let mergedProfiles = [];
|
||||
let mergedSceneActors = [];
|
||||
let existingSceneActors = [];
|
||||
let duplicateSourceActors = [];
|
||||
let mergedActorStashes = [];
|
||||
|
||||
try {
|
||||
const [existingProfiles, sourceProfiles] = await Promise.all([
|
||||
trx('actors_profiles')
|
||||
.where('actor_id', targetActorId),
|
||||
trx('actors_profiles')
|
||||
.whereIn('actor_id', sourceActorIds),
|
||||
trx('actors')
|
||||
.update('alias_for', targetActorId)
|
||||
.whereIn('id', sourceActorIds)
|
||||
.returning(['id', 'alias_for']),
|
||||
// some avatars are not matched to a profile, need to investigate why this happens and the avatar table needs a dedicated actor field
|
||||
trx('actors_avatars')
|
||||
.update('actor_id', targetActorId)
|
||||
.whereIn('actor_id', sourceActorIds),
|
||||
]);
|
||||
|
||||
// multiple source actors may provide profiles for the same entity, but we can only assign one to the target actor; prefer the newest
|
||||
const newestSourceProfileMap = Object.fromEntries(sourceProfiles
|
||||
.toSorted((profileA, profileB) => profileA.updated_at - profileB.updated_at)
|
||||
.map((profile) => [profile.entity_id, profile.id]));
|
||||
|
||||
const duplicateSourceProfiles = sourceProfiles.filter((profile) => newestSourceProfileMap[profile.entity_id] && newestSourceProfileMap[profile.entity_id] !== profile.id);
|
||||
|
||||
// assign source actor profiles to target actor, unless a profile for that entity is already present
|
||||
mergedProfiles = await trx('actors_profiles')
|
||||
.update('actor_id', targetActorId)
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.whereNotIn('entity_id', existingProfiles.map((profile) => profile.entity_id))
|
||||
.whereNotIn('id', duplicateSourceProfiles.map((profile) => profile.id))
|
||||
.returning('id');
|
||||
|
||||
// find releases that have more than one source actor assigned
|
||||
duplicateSourceActors = await trx('releases_actors')
|
||||
.select('release_id', knex.raw('array_agg(actor_id) as actor_ids'))
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.groupBy('release_id')
|
||||
.having(trx.raw('COUNT(DISTINCT actor_id) > 1'));
|
||||
|
||||
if (duplicateSourceActors.length > 0) {
|
||||
// some scenes have multiple source actors assigned, which will cause a conflict after merging; we will need to remove all but one
|
||||
await trx('releases_actors')
|
||||
.whereIn('release_id', duplicateSourceActors.map((sceneActor) => sceneActor.release_id))
|
||||
.whereIn('actor_id', duplicateSourceActors.flatMap((sceneActor) => sceneActor.actor_ids.slice(1)))
|
||||
.delete();
|
||||
}
|
||||
|
||||
// find scenes that already have target actor assigned
|
||||
existingSceneActors = await trx('releases_actors')
|
||||
.where('actor_id', targetActorId);
|
||||
|
||||
// delete release source actors for scenes that already have the target actor assigned
|
||||
await trx('releases_actors')
|
||||
.whereIn('release_id', existingSceneActors.map((sceneActor) => sceneActor.release_id))
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.delete();
|
||||
|
||||
// alias release source actors to target actors
|
||||
mergedSceneActors = await trx('releases_actors')
|
||||
.update({
|
||||
actor_id: targetActorId,
|
||||
alias_id: knex.raw('actor_id'),
|
||||
})
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.returning('release_id');
|
||||
|
||||
const [targetActorStashes, sourceActorStashes] = await Promise.all([
|
||||
trx('stashes_actors')
|
||||
.where('actor_id', targetActorId),
|
||||
trx('stashes_actors')
|
||||
.whereIn('actor_id', sourceActorIds),
|
||||
]);
|
||||
|
||||
// remove source actors from stashes that already contain target actor
|
||||
await trx('stashes_actors')
|
||||
.whereIn('stash_id', targetActorStashes.map((stash) => stash.stash_id))
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.delete();
|
||||
|
||||
// find stashes that have more than one source actor assigned
|
||||
const duplicateStashActors = await trx('stashes_actors')
|
||||
.select('stash_id', knex.raw('array_agg(actor_id order by created_at) as actor_ids'))
|
||||
.whereIn('actor_id', sourceActorStashes.map((actorStash) => actorStash.actor_id))
|
||||
.groupBy('stash_id')
|
||||
.having(trx.raw('COUNT(DISTINCT actor_id) > 1'));
|
||||
|
||||
if (duplicateStashActors.length > 0) {
|
||||
// some stashes have multiple source actors assigned, which will cause a conflict after merging; we will need to remove all but one
|
||||
await trx('stashes_actors')
|
||||
.whereIn('stash_id', duplicateStashActors.map((actorStash) => actorStash.stash_id))
|
||||
.whereIn('actor_id', duplicateStashActors.flatMap((actorStash) => actorStash.actor_ids.slice(1)))
|
||||
.delete();
|
||||
}
|
||||
|
||||
// we update an existing entry instead of creating a new one, so the original stash date is preserved
|
||||
mergedActorStashes = await trx('stashes_actors')
|
||||
.update('actor_id', targetActorId)
|
||||
.whereIn('actor_id', sourceActorIds)
|
||||
.returning('stash_id');
|
||||
|
||||
await trx.commit();
|
||||
} catch (error) {
|
||||
await trx.rollback();
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
await interpolateProfiles([targetActorId, ...sourceActorIds], {
|
||||
knex,
|
||||
logger,
|
||||
moment,
|
||||
slugify,
|
||||
omit,
|
||||
}, { refreshView: false });
|
||||
|
||||
await Promise.all([
|
||||
syncScenes([
|
||||
...mergedSceneActors.map((sceneActor) => sceneActor.release_id),
|
||||
...existingSceneActors.map((sceneActor) => sceneActor.release_id),
|
||||
...duplicateSourceActors.map((sceneActor) => sceneActor.release_id),
|
||||
]),
|
||||
syncActors([targetActorId, ...sourceActorIds]),
|
||||
syncStashes('actor', [targetActorId, ...sourceActorIds]),
|
||||
]);
|
||||
|
||||
return {
|
||||
scenes: mergedSceneActors.length,
|
||||
profiles: mergedProfiles.length,
|
||||
stashes: mergedActorStashes.length,
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchActorRevisions(revisionId, filters = {}, reqUser) {
|
||||
const limit = filters.limit || 50;
|
||||
const page = filters.page || 1;
|
||||
@@ -698,7 +923,7 @@ async function applyActorRevision(revisionIds, reqUser) {
|
||||
return applyActorSocialsDelta(revision.actor_id, delta, trx);
|
||||
}
|
||||
|
||||
if (delta.key === 'name' && reqUser.role === 'admin') {
|
||||
if (['name', 'allowGlobalMatch'].includes(delta.key) && verifyAbility(reqUser, 'actor', 'update')) {
|
||||
return applyActorDirectDelta(revision.actor_id, delta, trx);
|
||||
}
|
||||
|
||||
@@ -725,6 +950,8 @@ async function applyActorRevision(revisionIds, reqUser) {
|
||||
slugify,
|
||||
omit,
|
||||
}, { refreshView: false });
|
||||
|
||||
await syncActors(actorIds);
|
||||
}
|
||||
|
||||
export async function reviewActorRevision(revisionId, isApproved, { feedback }, reqUser) {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import initServer from './web/server.js';
|
||||
import { initCaches } from './cache.js';
|
||||
import { initSyncCron } from './sync.js';
|
||||
|
||||
async function init() {
|
||||
await initCaches();
|
||||
|
||||
initServer();
|
||||
initSyncCron();
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
@@ -203,6 +203,8 @@ export async function verifyKey(userId, key, req) {
|
||||
.then(() => {
|
||||
// no need to wait for this
|
||||
});
|
||||
|
||||
return fetchUser(storedKey.user_id);
|
||||
}
|
||||
|
||||
export async function createKey(reqUser) {
|
||||
|
||||
@@ -32,5 +32,6 @@ export function curateMedia(media, context = {}) {
|
||||
type: context.type || null,
|
||||
sfw: curateMedia(media.sfw_media),
|
||||
isRestricted: context.isRestricted,
|
||||
createdAt: media.created_at,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import initLogger from './logger.js';
|
||||
import { curateRevision } from './revisions.js';
|
||||
import { getAffiliateSceneUrl } from './affiliates.js';
|
||||
import { censor } from './censor.js';
|
||||
import { syncScenes } from './sync.js';
|
||||
|
||||
const logger = initLogger();
|
||||
const mj = new MerkleJson();
|
||||
@@ -208,16 +209,19 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) {
|
||||
'actors.*',
|
||||
knex.raw('row_to_json(avatars) as avatar'),
|
||||
knex.raw('row_to_json(sfw_media) as sfw_avatar'),
|
||||
knex.raw('row_to_json(aliases) as alias'),
|
||||
knex.raw('case when aliases.id is not null then json_build_object(\'id\', aliases.id, \'name\', aliases.name, \'slug\', aliases.slug) end as alias'),
|
||||
'countries.name as birth_country_name',
|
||||
'countries.alias as birth_country_alias',
|
||||
'releases_actors.release_id',
|
||||
)
|
||||
.leftJoin('actors', 'actors.id', 'releases_actors.actor_id')
|
||||
.leftJoin('actors as aliases', 'aliases.id', 'releases_actors.alias_id')
|
||||
.leftJoin('media as avatars', 'avatars.id', 'actors.avatar_media_id')
|
||||
.leftJoin('media as sfw_media', 'sfw_media.id', 'avatars.sfw_media_id')
|
||||
.leftJoin('countries', 'countries.alpha2', 'actors.birth_country_alpha2')
|
||||
.whereIn('release_id', sceneIds)
|
||||
.groupBy('actors.id', 'releases_actors.release_id', 'avatars.id', 'countries.name', 'countries.alias', 'sfw_media.id'),
|
||||
.groupBy('actors.id', 'aliases.id', 'releases_actors.release_id', 'avatars.id', 'countries.name', 'countries.alias', 'sfw_media.id'),
|
||||
directors: knex('releases_directors')
|
||||
.whereIn('release_id', sceneIds)
|
||||
.leftJoin('actors as directors', 'directors.id', 'releases_directors.director_id'),
|
||||
@@ -414,6 +418,20 @@ function curateFacet(results, field) {
|
||||
|| [];
|
||||
}
|
||||
|
||||
const packN = 100_000;
|
||||
|
||||
function mergePackedTags(tags) {
|
||||
const mergedCounts = tags.reduce((merged, tag) => {
|
||||
const tagId = tag.key % packN;
|
||||
|
||||
merged.set(tagId, (merged.get(tagId) ?? 0) + tag.doc_count);
|
||||
|
||||
return merged;
|
||||
}, new Map());
|
||||
|
||||
return Array.from(mergedCounts.entries(), ([key, count]) => ({ key, doc_count: count }));
|
||||
}
|
||||
|
||||
async function queryManticoreSql(filters, options, _reqUser) {
|
||||
const aggSize = config.database.manticore.maxAggregateSize;
|
||||
|
||||
@@ -436,7 +454,6 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
:yearsFacet:
|
||||
:actorsFacet:
|
||||
:tagsFacet:
|
||||
:actorTagsFacet:
|
||||
:channelsFacet:
|
||||
:studiosFacet:;
|
||||
show meta;
|
||||
@@ -469,11 +486,6 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
year(scenes.effective_date) as effective_year,
|
||||
weight() as _score
|
||||
`));
|
||||
|
||||
// manticore only supports one joined table, so we can't use it inside stashes
|
||||
builder
|
||||
.leftJoin('scenes_tags', 'scenes_tags.scene_id', 'scenes_.id')
|
||||
.groupBy('scenes.id');
|
||||
}
|
||||
|
||||
if (filters.query) {
|
||||
@@ -486,7 +498,17 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
}
|
||||
|
||||
filters.tagIds?.forEach((tagId) => {
|
||||
builder.where('any(tag_ids)', tagId);
|
||||
if (filters.onlyActorTags) {
|
||||
builder.where((whereBuilder) => {
|
||||
whereBuilder.where('any(assigned_tag_ids)', tagId);
|
||||
|
||||
filters.actorIds?.forEach((actorId) => {
|
||||
whereBuilder.orWhere('any(assigned_tag_ids)', actorId * 1_000_00 + tagId);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
builder.where('any(tag_ids)', tagId);
|
||||
}
|
||||
});
|
||||
|
||||
if (filters.notTagIds) {
|
||||
@@ -529,12 +551,6 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
builder.where('scenes.is_showcased', filters.isShowcased);
|
||||
}
|
||||
|
||||
/*
|
||||
if (filters.isShowcased) {
|
||||
builder.where('scenes.date', '>', 0);
|
||||
}
|
||||
*/
|
||||
|
||||
if (options.dedupe) {
|
||||
builder.where('scenes.dupe_index', '<', 2);
|
||||
}
|
||||
@@ -579,11 +595,7 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
// option threads=1 fixes actors, but drastically slows down performance, wait for fix
|
||||
yearsFacet: options.aggregateYears ? knex.raw('facet effective_year as years_facet order by effective_year desc limit ?', [aggSize]) : null,
|
||||
actorsFacet: options.aggregateActors ? knex.raw('facet scenes.actor_ids as actors_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
|
||||
// don't facet tags associated to other actors, actor ID 0 means global
|
||||
tagsFacet: options.aggregateTags ? knex.raw('facet scenes.tag_ids as tags_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
|
||||
actorTagsFacet: options.aggregateTags && !filters.stashId // eslint-disable-line no-nested-ternary
|
||||
? knex.raw(`facet IF(IN(scenes_tags.actor_id, ${[0, ...filters?.actorIds || []]}), scenes_tags.tag_id, 0) as actor_tags_facet distinct id order by count(*) desc limit ?`, [aggSize])
|
||||
: null,
|
||||
tagsFacet: options.aggregateTags ? knex.raw('facet scenes.assigned_tag_ids as tags_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
|
||||
channelsFacet: options.aggregateChannels ? knex.raw('facet scenes.channel_id as channels_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
|
||||
studiosFacet: options.aggregateChannels ? knex.raw('facet scenes.studio_id as studios_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
|
||||
maxMatches: config.database.manticore.maxMatches,
|
||||
@@ -606,10 +618,26 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
const years = curateFacet(results, 'years_facet');
|
||||
const actorIds = curateFacet(results, 'actors_facet');
|
||||
const tagIds = curateFacet(results, 'tags_facet');
|
||||
const actorTagIds = curateFacet(results, 'actor_tags_facet');
|
||||
const channelIds = curateFacet(results, 'channels_facet');
|
||||
const studioIds = curateFacet(results, 'studios_facet');
|
||||
|
||||
const allTagIds = mergePackedTags(tagIds);
|
||||
|
||||
const actorTagIds = mergePackedTags(tagIds.filter((tag) => {
|
||||
if (tag.key < packN || !filters?.actorIds.length) {
|
||||
// global
|
||||
return true;
|
||||
}
|
||||
|
||||
const tagActorId = Math.floor(tag.key / packN);
|
||||
|
||||
if (filters.actorIds.includes(tagActorId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}));
|
||||
|
||||
const total = Number(results.at(-1).data.find((entry) => entry.Variable_name === 'total_found')?.Value) || 0;
|
||||
|
||||
return {
|
||||
@@ -618,7 +646,7 @@ async function queryManticoreSql(filters, options, _reqUser) {
|
||||
aggregations: {
|
||||
years,
|
||||
actorIds,
|
||||
tagIds,
|
||||
tagIds: allTagIds,
|
||||
actorTagIds,
|
||||
channelIds,
|
||||
studioIds,
|
||||
@@ -888,6 +916,10 @@ async function applySceneRevision(revisionIds, reqUser) {
|
||||
throw error;
|
||||
});
|
||||
}, Promise.resolve());
|
||||
|
||||
const sceneIds = Array.from(new Set(revisions.map((revision) => revision.scene_id)));
|
||||
|
||||
await syncScenes(sceneIds);
|
||||
}
|
||||
|
||||
export async function reviewSceneRevision(revisionId, isApproved, { feedback }, reqUser) {
|
||||
|
||||
@@ -200,6 +200,10 @@ export async function createStash(newStash, sessionUser) {
|
||||
throw new HttpError('You are not authenthicated', 401);
|
||||
}
|
||||
|
||||
if (!newStash) {
|
||||
throw new HttpError('Missing new stash', 400);
|
||||
}
|
||||
|
||||
verifyStashName(newStash);
|
||||
|
||||
try {
|
||||
@@ -224,6 +228,14 @@ export async function updateStash(stashIdOrSlug, updatedStash, sessionUser) {
|
||||
throw new HttpError('You are not authenthicated', 401);
|
||||
}
|
||||
|
||||
if (!stashIdOrSlug) {
|
||||
throw new HttpError('Missing stash ID or slug', 400);
|
||||
}
|
||||
|
||||
if (!updatedStash) {
|
||||
throw new HttpError('Missing updated stash', 400);
|
||||
}
|
||||
|
||||
if (updatedStash.name) {
|
||||
verifyStashName(updatedStash);
|
||||
}
|
||||
@@ -260,6 +272,10 @@ export async function removeStash(stashId, sessionUser) {
|
||||
throw new HttpError('You are not authenthicated', 401);
|
||||
}
|
||||
|
||||
if (!stashId) {
|
||||
throw new HttpError('Missing stash ID', 400);
|
||||
}
|
||||
|
||||
const stash = await fetchStashById(stashId, sessionUser);
|
||||
|
||||
if (!stash) {
|
||||
@@ -283,6 +299,14 @@ export async function removeStash(stashId, sessionUser) {
|
||||
}
|
||||
|
||||
export async function stashActor(actorId, stashId, sessionUser) {
|
||||
if (!actorId) {
|
||||
throw new HttpError('Missing actor ID', 400);
|
||||
}
|
||||
|
||||
if (!stashId) {
|
||||
throw new HttpError('Missing stash ID', 400);
|
||||
}
|
||||
|
||||
const stash = await fetchStashById(stashId, sessionUser);
|
||||
|
||||
if (!stash) {
|
||||
@@ -324,6 +348,14 @@ export async function stashActor(actorId, stashId, sessionUser) {
|
||||
}
|
||||
|
||||
export async function unstashActor(actorId, stashId, sessionUser) {
|
||||
if (!actorId) {
|
||||
throw new HttpError('Missing actor ID', 400);
|
||||
}
|
||||
|
||||
if (!stashId) {
|
||||
throw new HttpError('Missing stash ID', 400);
|
||||
}
|
||||
|
||||
const stash = await fetchStashById(stashId, sessionUser);
|
||||
|
||||
if (!stash) {
|
||||
@@ -367,6 +399,14 @@ export async function unstashActor(actorId, stashId, sessionUser) {
|
||||
}
|
||||
|
||||
export async function stashScene(sceneId, stashId, sessionUser) {
|
||||
if (!sceneId) {
|
||||
throw new HttpError('Missing scene ID', 400);
|
||||
}
|
||||
|
||||
if (!stashId) {
|
||||
throw new HttpError('Missing stash ID', 400);
|
||||
}
|
||||
|
||||
const stash = await fetchStashById(stashId, sessionUser);
|
||||
|
||||
if (!stash) {
|
||||
@@ -409,6 +449,14 @@ export async function stashScene(sceneId, stashId, sessionUser) {
|
||||
}
|
||||
|
||||
export async function unstashScene(sceneId, stashId, sessionUser) {
|
||||
if (!sceneId) {
|
||||
throw new HttpError('Missing scene ID', 400);
|
||||
}
|
||||
|
||||
if (!stashId) {
|
||||
throw new HttpError('Missing stash ID', 400);
|
||||
}
|
||||
|
||||
const stash = await fetchStashById(stashId, sessionUser);
|
||||
|
||||
if (!stash) {
|
||||
@@ -448,6 +496,14 @@ export async function unstashScene(sceneId, stashId, sessionUser) {
|
||||
}
|
||||
|
||||
export async function stashMovie(movieId, stashId, sessionUser) {
|
||||
if (!movieId) {
|
||||
throw new HttpError('Missing movie ID', 400);
|
||||
}
|
||||
|
||||
if (!stashId) {
|
||||
throw new HttpError('Missing stash ID', 400);
|
||||
}
|
||||
|
||||
const stash = await fetchStashById(stashId, sessionUser);
|
||||
|
||||
if (!stash) {
|
||||
@@ -489,6 +545,14 @@ export async function stashMovie(movieId, stashId, sessionUser) {
|
||||
}
|
||||
|
||||
export async function unstashMovie(movieId, stashId, sessionUser) {
|
||||
if (!movieId) {
|
||||
throw new HttpError('Missing movie ID', 400);
|
||||
}
|
||||
|
||||
if (!stashId) {
|
||||
throw new HttpError('Missing stash ID', 400);
|
||||
}
|
||||
|
||||
const stash = await fetchStashById(stashId, sessionUser);
|
||||
|
||||
if (!stash) {
|
||||
@@ -528,7 +592,7 @@ export async function unstashMovie(movieId, stashId, sessionUser) {
|
||||
}
|
||||
|
||||
CronJob.from({
|
||||
cronTime: config.stashes.viewRefreshCron,
|
||||
cronTime: config.stashes.viewRefreshCrontab,
|
||||
async onTick() {
|
||||
logger.verbose('Updating stash views');
|
||||
|
||||
|
||||
497
src/sync.js
Normal file
@@ -0,0 +1,497 @@
|
||||
import config from 'config';
|
||||
import { format } from 'date-fns';
|
||||
import { CronJob } from 'cron';
|
||||
|
||||
import initLogger from './logger.js';
|
||||
import { knexOwner as knex } from './knex.js';
|
||||
import { searchApi, indexApi } from './manticore.js';
|
||||
import chunk from '../utils/chunk.js';
|
||||
import filterTitle from '../utils/filter-title.js';
|
||||
|
||||
const logger = initLogger();
|
||||
|
||||
export async function syncStashes(domain = 'scene', ids) {
|
||||
const stashes = await knex(`stashes_${domain}s`)
|
||||
.select(
|
||||
`stashes_${domain}s.id as stashed_id`,
|
||||
`stashes_${domain}s.${domain}_id`,
|
||||
'stashes.id as stash_id',
|
||||
'stashes.user_id as user_id',
|
||||
`stashes_${domain}s.created_at as created_at`,
|
||||
)
|
||||
.modify((builder) => {
|
||||
if (ids) {
|
||||
builder.whereRaw(`stashes_${domain}s.${domain}_id = ANY(?)`, [ids]);
|
||||
}
|
||||
})
|
||||
.leftJoin('stashes', 'stashes.id', `stashes_${domain}s.stash_id`);
|
||||
|
||||
await chunk(stashes, 1000).reduce(async (chain, stashChunk, index) => {
|
||||
await chain;
|
||||
|
||||
const stashDocs = stashChunk.map((stash) => ({
|
||||
replace: {
|
||||
index: `${domain}s_stashed`,
|
||||
id: stash.stashed_id,
|
||||
doc: {
|
||||
[`${domain}_id`]: stash[`${domain}_id`],
|
||||
stash_id: stash.stash_id,
|
||||
user_id: stash.user_id,
|
||||
created_at: Math.round(stash.created_at.getTime() / 1000),
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
await indexApi.bulk(stashDocs.map((doc) => JSON.stringify(doc)).join('\n'));
|
||||
|
||||
logger.verbose(`Seeded ${index * 1000 + stashChunk.length}/${stashes.length} ${domain} stashes`);
|
||||
}, Promise.resolve());
|
||||
|
||||
// purge orphaned docs
|
||||
const itemIds = ids ?? [...new Set(stashes.map((s) => s[`${domain}_id`]))];
|
||||
|
||||
if (itemIds.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const validStashedIds = new Set(stashes.map((stash) => stash.stashed_id));
|
||||
|
||||
await chunk(itemIds, 1000).reduce(async (chain, itemIdChunk) => {
|
||||
await chain;
|
||||
|
||||
const searchResponse = await searchApi.search({
|
||||
index: `${domain}s_stashed`,
|
||||
query: {
|
||||
in: {
|
||||
[`${domain}_id`]: itemIdChunk,
|
||||
},
|
||||
},
|
||||
limit: 1000,
|
||||
});
|
||||
|
||||
const docs = searchResponse?.hits?.hits ?? [];
|
||||
|
||||
const orphanedIds = docs
|
||||
.map((hit) => hit._id)
|
||||
.filter((manticoreId) => !validStashedIds.has(manticoreId));
|
||||
|
||||
if (orphanedIds.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const deleteDocs = orphanedIds.map((orphanId) => ({
|
||||
delete: {
|
||||
index: `${domain}s_stashed`,
|
||||
id: orphanId,
|
||||
},
|
||||
}));
|
||||
|
||||
await indexApi.bulk(deleteDocs.map((doc) => JSON.stringify(doc)).join('\n'));
|
||||
|
||||
logger.verbose(`Purged ${orphanedIds.length} orphaned ${domain} stash documents`);
|
||||
}, Promise.resolve());
|
||||
}
|
||||
|
||||
export async function syncManticoreScenes(sceneIds) {
|
||||
logger.info(`Updating Manticore search documents for ${sceneIds ? sceneIds.length : 'all' } scenes`);
|
||||
|
||||
const scenes = await knex.raw(`
|
||||
SELECT
|
||||
releases.id AS id,
|
||||
releases.title,
|
||||
releases.created_at,
|
||||
releases.date,
|
||||
releases.shoot_id,
|
||||
scenes_meta.stashed,
|
||||
entities.id as channel_id,
|
||||
entities.slug as channel_slug,
|
||||
entities.name as channel_name,
|
||||
parents.id as network_id,
|
||||
parents.slug as network_slug,
|
||||
parents.name as network_name,
|
||||
studios.id as studio_id,
|
||||
studios.slug as studio_slug,
|
||||
studios.name as studio_name,
|
||||
grandparents.id as parent_network_id,
|
||||
COALESCE(JSON_AGG(DISTINCT (actors.id, actors.name)) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors,
|
||||
COALESCE(JSON_AGG(DISTINCT (actors_aliases.id, actors_aliases.name)) FILTER (WHERE actors_aliases.id IS NOT NULL), '[]') as actors_aliases,
|
||||
COALESCE(JSON_AGG(DISTINCT (tags.id, tags.name, tags.priority, tags_aliases.name, local_tags.actor_id)) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags,
|
||||
COALESCE(JSON_AGG(DISTINCT (movies.id, movies.title)) FILTER (WHERE movies.id IS NOT NULL), '[]') as movies,
|
||||
COALESCE(JSON_AGG(DISTINCT (series.id, series.title)) FILTER (WHERE series.id IS NOT NULL), '[]') as series,
|
||||
studios.showcased IS NOT false
|
||||
AND (entities.showcased IS NOT false OR COALESCE(studios.showcased, false) = true)
|
||||
AND (parents.showcased IS NOT false OR COALESCE(entities.showcased, false) = true OR COALESCE(studios.showcased, false) = true)
|
||||
AND (releases_summaries.batch_showcased IS NOT false)
|
||||
AS showcased,
|
||||
row_number() OVER (PARTITION BY releases.entry_id, parents.id ORDER BY releases.effective_date DESC) as dupe_index
|
||||
FROM releases
|
||||
LEFT JOIN releases_summaries ON releases_summaries.release_id = releases.id
|
||||
LEFT JOIN scenes_meta ON scenes_meta.scene_id = releases.id
|
||||
LEFT JOIN entities ON releases.entity_id = entities.id
|
||||
LEFT JOIN entities AS parents ON parents.id = entities.parent_id
|
||||
LEFT JOIN entities AS grandparents ON grandparents.id = parents.parent_id
|
||||
LEFT JOIN entities AS studios ON studios.id = releases.studio_id
|
||||
LEFT JOIN releases_actors AS local_actors ON local_actors.release_id = releases.id
|
||||
LEFT JOIN releases_directors AS local_directors ON local_directors.release_id = releases.id
|
||||
LEFT JOIN releases_tags AS local_tags ON local_tags.release_id = releases.id
|
||||
LEFT JOIN actors ON local_actors.actor_id = actors.id
|
||||
LEFT JOIN actors AS directors ON local_directors.director_id = directors.id
|
||||
LEFT JOIN actors AS actors_aliases ON actors_aliases.alias_for = actors.id
|
||||
LEFT JOIN tags ON local_tags.tag_id = tags.id
|
||||
LEFT JOIN tags as tags_aliases ON local_tags.tag_id = tags_aliases.alias_for AND tags_aliases.secondary = true
|
||||
LEFT JOIN movies_scenes ON movies_scenes.scene_id = releases.id
|
||||
LEFT JOIN movies ON movies.id = movies_scenes.movie_id
|
||||
LEFT JOIN series_scenes ON series_scenes.scene_id = releases.id
|
||||
LEFT JOIN series ON series.id = series_scenes.serie_id
|
||||
${sceneIds ? 'WHERE releases.id = ANY(?)' : ''}
|
||||
GROUP BY
|
||||
releases.id,
|
||||
releases.title,
|
||||
releases.created_at,
|
||||
releases.date,
|
||||
releases.shoot_id,
|
||||
scenes_meta.stashed,
|
||||
releases_summaries.batch_showcased,
|
||||
entities.id,
|
||||
entities.name,
|
||||
entities.slug,
|
||||
entities.alias,
|
||||
entities.showcased,
|
||||
parents.id,
|
||||
parents.name,
|
||||
parents.slug,
|
||||
parents.alias,
|
||||
grandparents.id,
|
||||
studios.id,
|
||||
studios.name,
|
||||
studios.slug,
|
||||
parents.showcased,
|
||||
studios.showcased
|
||||
`, sceneIds && [sceneIds]);
|
||||
|
||||
const scenesById = Object.fromEntries(scenes.rows.map((scene) => [scene.id, scene]));
|
||||
|
||||
const docs = (sceneIds || Object.keys(scenesById)).map((sceneId) => {
|
||||
const scene = scenesById[sceneId];
|
||||
|
||||
if (!scene) {
|
||||
return {
|
||||
delete: {
|
||||
index: 'scenes',
|
||||
id: sceneId,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const flatActors = scene.actors.flatMap((actor) => actor.f2.split(' '));
|
||||
const flatTags = scene.tags.filter((tag) => tag.f3 > 6).flatMap((tag) => [tag.f2].concat(tag.f4)).filter(Boolean); // only make top tags searchable to minimize cluttered results
|
||||
const filteredTitle = filterTitle(scene.title, [...flatActors, ...flatTags]);
|
||||
|
||||
// use decimal packing with 5-decimal pad to allow for actor-specific tags, i.e. actor 135 tag 5 = 13500005
|
||||
// all global tags are necessarily < 10,000, all tags for actor 135 are >= 13500000 and <= 13599999
|
||||
// f1 = tag ID, f5 = actor ID
|
||||
const assignedTagIds = scene.tags.map((tag) => (tag.f5 === null ? tag.f1 : tag.f5 * 1_000_00 + tag.f1));
|
||||
|
||||
/*
|
||||
if (sceneId === '187734') {
|
||||
console.log(scene, assignedTagIds);
|
||||
throw new Error('ABORT');
|
||||
}
|
||||
*/
|
||||
|
||||
return {
|
||||
replace: {
|
||||
index: 'scenes',
|
||||
id: scene.id,
|
||||
doc: {
|
||||
title: scene.title || undefined,
|
||||
title_filtered: filteredTitle || undefined,
|
||||
date: scene.date ? Math.round(scene.date.getTime() / 1000) : undefined,
|
||||
created_at: Math.round(scene.created_at.getTime() / 1000),
|
||||
effective_date: Math.round((scene.date || scene.created_at).getTime() / 1000),
|
||||
is_showcased: scene.showcased,
|
||||
shoot_id: scene.shoot_id || undefined,
|
||||
channel_id: scene.channel_id,
|
||||
channel_slug: scene.channel_slug,
|
||||
channel_name: scene.channel_name,
|
||||
network_id: scene.network_id || undefined,
|
||||
network_slug: scene.network_slug || undefined,
|
||||
network_name: scene.network_name || undefined,
|
||||
studio_id: scene.studio_id || undefined,
|
||||
studio_slug: scene.studio_slug || undefined,
|
||||
studio_name: scene.studio_name || undefined,
|
||||
entity_ids: [scene.channel_id, scene.network_id, scene.parent_network_id, scene.studio_id].filter(Boolean), // manticore does not support OR, this allows IN
|
||||
actor_ids: scene.actors.map((actor) => actor.f1), // don't include aliases in ID or they would show up in filters
|
||||
actors: Array.from(new Set([...scene.actors.map((actor) => actor.f2), ...scene.actors_aliases.map((actor) => actor.f2)])).join(),
|
||||
tag_ids: Array.from(new Set(scene.tags.map((tag) => tag.f1))),
|
||||
assigned_tag_ids: assignedTagIds,
|
||||
tags: flatTags.join(' '), // only make top tags searchable to minimize cluttered results
|
||||
movie_ids: scene.movies.map((movie) => movie.f1),
|
||||
movies: scene.movies.map((movie) => movie.f2).join(' '),
|
||||
serie_ids: scene.series.map((serie) => serie.f1),
|
||||
series: scene.series.map((serie) => serie.f2).join(' '),
|
||||
meta: scene.date ? format(scene.date, 'y yy M MMM MMMM d') : undefined,
|
||||
stashed: scene.stashed || 0,
|
||||
dupe_index: scene.dupe_index || 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
if (docs.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const [manticoreResult] = await Promise.all([
|
||||
chunk(docs, 10000).reduce(async (chain, docsChunk, index, array) => {
|
||||
const acc = await chain;
|
||||
const data = await indexApi.bulk(docsChunk.map((doc) => JSON.stringify(doc)).join('\n'));
|
||||
|
||||
logger.verbose(`Seeded ${index + 1}/${array.length}, errors: ${data.errors} ${data.error}`);
|
||||
|
||||
return acc.concat(data.items);
|
||||
}, Promise.resolve([])),
|
||||
syncStashes('scene', sceneIds),
|
||||
]);
|
||||
|
||||
return manticoreResult;
|
||||
}
|
||||
|
||||
export async function syncScenes(releaseIds) {
|
||||
await knex.raw('REFRESH MATERIALIZED VIEW scenes_meta;');
|
||||
|
||||
await syncManticoreScenes(releaseIds);
|
||||
}
|
||||
|
||||
export async function syncManticoreMovies(movieIds) {
|
||||
logger.info(`Updating Manticore search documents for ${movieIds ? movieIds.length : 'all' } movies`);
|
||||
|
||||
const movies = await knex.raw(`
|
||||
SELECT
|
||||
movies.id AS id,
|
||||
movies.title,
|
||||
movies.created_at,
|
||||
movies.date,
|
||||
movies_meta.stashed,
|
||||
entities.id as channel_id,
|
||||
entities.slug as channel_slug,
|
||||
entities.name as channel_name,
|
||||
parents.id as network_id,
|
||||
parents.slug as network_slug,
|
||||
parents.name as network_name,
|
||||
movies_covers IS NOT NULL as has_cover,
|
||||
COALESCE(JSON_AGG(DISTINCT (actors.id, actors.name)) FILTER (WHERE actors.id IS NOT NULL), '[]') as actors,
|
||||
COALESCE(JSON_AGG(DISTINCT (tags.id, tags.name, tags.priority, tags_aliases.name)) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags,
|
||||
COALESCE(JSON_AGG(DISTINCT (movie_tags.id, movie_tags.name, movie_tags.priority, movie_tags_aliases.name)) FILTER (WHERE movie_tags.id IS NOT NULL), '[]') as movie_tags,
|
||||
row_number() OVER (PARTITION BY movies.entry_id, parents.id ORDER BY movies.effective_date DESC) as dupe_index
|
||||
FROM movies
|
||||
LEFT JOIN movies_meta ON movies_meta.movie_id = movies.id
|
||||
LEFT JOIN movies_scenes ON movies_scenes.movie_id = movies.id
|
||||
LEFT JOIN movies_tags ON movies_tags.movie_id = movies.id
|
||||
LEFT JOIN entities ON movies.entity_id = entities.id
|
||||
LEFT JOIN entities AS parents ON parents.id = entities.parent_id
|
||||
LEFT JOIN releases_actors AS local_actors ON local_actors.release_id = movies_scenes.scene_id
|
||||
LEFT JOIN releases_directors AS local_directors ON local_directors.release_id = movies_scenes.scene_id
|
||||
LEFT JOIN releases_tags AS local_tags ON local_tags.release_id = movies_scenes.scene_id
|
||||
LEFT JOIN actors ON local_actors.actor_id = actors.id
|
||||
LEFT JOIN actors AS directors ON local_directors.director_id = directors.id
|
||||
LEFT JOIN tags ON local_tags.tag_id = tags.id
|
||||
LEFT JOIN tags as tags_aliases ON local_tags.tag_id = tags_aliases.alias_for AND tags_aliases.secondary = true
|
||||
LEFT JOIN tags as movie_tags ON movies_tags.tag_id = movie_tags.id
|
||||
LEFT JOIN tags as movie_tags_aliases ON movies_tags.tag_id = movie_tags_aliases.alias_for AND movie_tags_aliases.secondary = true
|
||||
LEFT JOIN movies_covers ON movies_covers.movie_id = movies.id
|
||||
${movieIds ? 'WHERE movies.id = ANY(?)' : ''}
|
||||
GROUP BY
|
||||
movies.id,
|
||||
movies.title,
|
||||
movies.created_at,
|
||||
movies.date,
|
||||
movies_meta.stashed,
|
||||
movies_meta.stashed_scenes,
|
||||
movies_meta.stashed_total,
|
||||
entities.id,
|
||||
entities.name,
|
||||
entities.slug,
|
||||
entities.alias,
|
||||
parents.id,
|
||||
parents.name,
|
||||
parents.slug,
|
||||
parents.alias,
|
||||
movies_covers.*
|
||||
`, movieIds && [movieIds]);
|
||||
|
||||
const moviesById = Object.fromEntries(movies.rows.map((movie) => [movie.id, movie]));
|
||||
|
||||
const docs = (movieIds || Object.keys(moviesById)).map((movieId) => {
|
||||
const movie = moviesById[movieId];
|
||||
|
||||
if (!movie) {
|
||||
return {
|
||||
delete: {
|
||||
index: 'movies',
|
||||
id: movieId,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const combinedTags = Object.values(Object.fromEntries(movie.tags.concat(movie.movie_tags).map((tag) => [tag.f1, {
|
||||
id: tag.f1,
|
||||
name: tag.f2,
|
||||
priority: tag.f3,
|
||||
alias: tag.f4,
|
||||
}])));
|
||||
|
||||
const flatActors = movie.actors.flatMap((actor) => actor.f2.match(/[\w']+/g)); // match word characters to filter out brackets etc.
|
||||
const flatTags = combinedTags.filter((tag) => tag.priority > 6).flatMap((tag) => (tag.alias ? `${tag.name} ${tag.alias}` : tag.name).match(/[\w']+/g)); // only make top tags searchable to minimize cluttered results
|
||||
const filteredTitle = movie.title && [...flatActors, ...flatTags].reduce((accTitle, tag) => accTitle.replace(new RegExp(tag.replace(/[^\w\s]+/g, ''), 'gi'), ''), movie.title).trim().replace(/\s{2,}/g, ' ');
|
||||
|
||||
return {
|
||||
replace: {
|
||||
index: 'movies',
|
||||
id: movie.id,
|
||||
doc: {
|
||||
title: movie.title || undefined,
|
||||
title_filtered: filteredTitle || undefined,
|
||||
date: movie.date ? Math.round(movie.date.getTime() / 1000) : undefined,
|
||||
created_at: Math.round(movie.created_at.getTime() / 1000),
|
||||
effective_date: Math.round((movie.date || movie.created_at).getTime() / 1000),
|
||||
channel_id: movie.channel_id,
|
||||
channel_slug: movie.channel_slug,
|
||||
channel_name: movie.channel_name,
|
||||
network_id: movie.network_id || undefined,
|
||||
network_slug: movie.network_slug || undefined,
|
||||
network_name: movie.network_name || undefined,
|
||||
entity_ids: [movie.channel_id, movie.network_id].filter(Boolean), // manticore does not support OR, this allows IN
|
||||
actor_ids: movie.actors.map((actor) => actor.f1),
|
||||
actors: movie.actors.map((actor) => actor.f2).join(),
|
||||
tag_ids: combinedTags.map((tag) => tag.id),
|
||||
tags: flatTags.join(' '),
|
||||
has_cover: movie.has_cover,
|
||||
meta: movie.date ? format(movie.date, 'y yy M MMM MMMM d') : undefined,
|
||||
stashed: movie.stashed || 0,
|
||||
stashed_scenes: movie.stashed_scenes || 0,
|
||||
stashed_total: movie.stashed_total || 0,
|
||||
dupe_index: movie.dupe_index || 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
if (docs.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return indexApi.bulk(docs.map((doc) => JSON.stringify(doc)).join('\n'));
|
||||
}
|
||||
|
||||
export async function syncMovies(releaseIds) {
|
||||
await knex.raw('REFRESH MATERIALIZED VIEW movies_meta;');
|
||||
|
||||
await syncManticoreMovies(releaseIds);
|
||||
}
|
||||
|
||||
export async function syncManticoreActors(actorIds) {
|
||||
logger.info(`Updating Manticore search documents for ${actorIds ? actorIds.length : 'all' } actors`);
|
||||
|
||||
// manually select date of birth, otherwise it is retrieved in local timezone but interpreted as UTC...
|
||||
const actors = await knex.raw(`
|
||||
SELECT
|
||||
actors.*,
|
||||
actors_meta.stashed, actors_meta.scenes,
|
||||
STRING_AGG(DISTINCT aliases.name, ',') FILTER (WHERE LOWER(aliases.name) != LOWER(actors.name)) as alias,
|
||||
actors.date_of_birth AT TIME ZONE 'Europe/Amsterdam' AT TIME ZONE 'UTC' as dob
|
||||
FROM actors
|
||||
LEFT JOIN actors_meta ON actors_meta.actor_id = actors.id
|
||||
LEFT JOIN actors AS aliases ON aliases.alias_for = actors.id
|
||||
${actorIds ? 'WHERE actors.id = ANY(?)' : ''}
|
||||
GROUP BY actors.id, actors_meta.stashed, actors_meta.scenes
|
||||
`, actorIds && [actorIds]);
|
||||
|
||||
const actorsById = Object.fromEntries(actors.rows.map((actor) => [actor.id, actor]));
|
||||
|
||||
const docs = (actorIds || Object.keys(actorsById)).map((actorId) => {
|
||||
const actor = actorsById[actorId];
|
||||
|
||||
if (!actor) {
|
||||
return {
|
||||
delete: {
|
||||
index: 'actors',
|
||||
id: actorId,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
replace: {
|
||||
index: 'actors',
|
||||
id: actor.id,
|
||||
doc: {
|
||||
entity_id: actor.entity_id || undefined,
|
||||
alias_for: actor.alias_for || undefined,
|
||||
aliases: actor.alias,
|
||||
name: actor.name,
|
||||
slug: actor.slug,
|
||||
gender: actor.gender || undefined,
|
||||
date_of_birth: actor.dob ? Math.round(actor.dob.getTime() / 1000) : undefined,
|
||||
has_avatar: !!actor.avatar_media_id,
|
||||
country: actor.birth_country_alpha2 || undefined,
|
||||
height: actor.height || undefined,
|
||||
mass: actor.weight || undefined, // weight is a reserved keyword in manticore
|
||||
cup: actor.cup || undefined,
|
||||
natural_boobs: actor.natural_boobs === null ? 0 : Number(actor.natural_boobs) + 1, // manticore bool does not seem to support null, and we need three states for natural_boobs: yes, no and unknown
|
||||
penis_length: actor.penis_length || undefined,
|
||||
penis_girth: actor.penis_girth || undefined,
|
||||
stashed: actor.stashed || 0,
|
||||
scenes: actor.scenes || 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
if (docs.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return indexApi.bulk(docs.map((doc) => JSON.stringify(doc)).join('\n'));
|
||||
}
|
||||
|
||||
export async function syncActors(actorIds) {
|
||||
await knex.raw('REFRESH MATERIALIZED VIEW actors_meta;');
|
||||
|
||||
await syncManticoreActors(actorIds);
|
||||
}
|
||||
|
||||
function getQueueItemIds(tasks, domain) {
|
||||
return Array.from(new Set(tasks.filter((task) => task.domain === domain).flatMap((task) => task.item_ids)));
|
||||
}
|
||||
|
||||
export async function syncQueue() {
|
||||
const tasks = await knex('sync');
|
||||
|
||||
const sceneIds = getQueueItemIds(tasks, 'scene');
|
||||
const movieIds = getQueueItemIds(tasks, 'movie');
|
||||
const actorIds = getQueueItemIds(tasks, 'actor');
|
||||
|
||||
await Promise.all([
|
||||
syncScenes(sceneIds),
|
||||
syncMovies(movieIds),
|
||||
syncActors(actorIds),
|
||||
]);
|
||||
|
||||
await knex('sync')
|
||||
.whereIn('id', tasks.map((task) => task.id))
|
||||
.delete();
|
||||
|
||||
logger[process.tasks > 0 ? 'info' : 'verbose'](`Processed ${tasks.length} sync items`);
|
||||
}
|
||||
|
||||
export function initSyncCron() {
|
||||
CronJob.from({
|
||||
cronTime: config.sync.crontab,
|
||||
async onTick() {
|
||||
syncQueue();
|
||||
},
|
||||
start: config.sync.enabled,
|
||||
runOnInit: true,
|
||||
});
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
import Router from 'express-promise-router';
|
||||
import omit from 'object.omit';
|
||||
|
||||
import {
|
||||
fetchActors,
|
||||
fetchActorsById,
|
||||
createActor,
|
||||
mergeActors,
|
||||
fetchActorRevisions,
|
||||
createActorRevision,
|
||||
reviewActorRevision,
|
||||
@@ -24,6 +27,7 @@ export function curateActorsQuery(query) {
|
||||
weight: query.weight?.split(',').map((weight) => Number(weight)),
|
||||
requireAvatar: query.avatar,
|
||||
stashId: Number(query.stashId) || null,
|
||||
isGlobal: !!query.global,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -169,6 +173,18 @@ export async function fetchActorsByIdGraphql(query, _req, _info) {
|
||||
return curatedActors[0];
|
||||
}
|
||||
|
||||
export async function createActorApi(req, res) {
|
||||
const actor = await createActor(req.body.actor, omit(req.body, ['actor']), req.user);
|
||||
|
||||
res.send({ actor });
|
||||
}
|
||||
|
||||
export async function mergeActorsApi(req, res) {
|
||||
const result = await mergeActors(Number(req.params.targetActorId), req.params.sourceActorIds.split(',').map((actorId) => Number(actorId)), req.user);
|
||||
|
||||
res.send(result);
|
||||
}
|
||||
|
||||
async function fetchActorRevisionsApi(req, res) {
|
||||
const revisions = await fetchActorRevisions(Number(req.params.revisionId) || null, req.query, req.user);
|
||||
|
||||
@@ -190,6 +206,9 @@ async function reviewActorRevisionApi(req, res) {
|
||||
export const actorsRouter = Router();
|
||||
|
||||
actorsRouter.get('/api/actors', fetchActorsApi);
|
||||
actorsRouter.post('/api/actors', createActorApi);
|
||||
|
||||
actorsRouter.post('/api/actors/:targetActorId/merge/:sourceActorIds', mergeActorsApi);
|
||||
|
||||
actorsRouter.get('/api/revisions/actors', fetchActorRevisionsApi);
|
||||
actorsRouter.get('/api/revisions/actors/:revisionId', fetchActorRevisionsApi);
|
||||
|
||||
@@ -44,6 +44,7 @@ export async function curateScenesQuery(query) {
|
||||
notActorIds: splitActors.filter((actor) => actor.charAt(0) === '!').map((identifier) => parseActorIdentifier(identifier.slice(1))?.id).filter(Boolean),
|
||||
tagIds,
|
||||
notTagIds: notTagIds.filter((tagId) => !tagIds.includes(tagId)), // included tags get priority over excluded tags
|
||||
onlyActorTags: !!query.at,
|
||||
entityId,
|
||||
notEntityIds,
|
||||
movieId: Number(query.movieId) || null,
|
||||
|
||||
@@ -16,6 +16,7 @@ import initRestrictionHandler from './restrictions.js';
|
||||
|
||||
import { scenesRouter } from './scenes.js';
|
||||
import { actorsRouter } from './actors.js';
|
||||
import { syncRouter } from './sync.js';
|
||||
|
||||
import { fetchMoviesApi } from './movies.js';
|
||||
import { fetchEntitiesApi } from './entities.js';
|
||||
@@ -122,11 +123,7 @@ export default async function initServer() {
|
||||
|
||||
router.use('/api/*', async (req, _res, next) => {
|
||||
if (req.headers['api-user']) {
|
||||
await verifyKey(req.headers['api-user'], req.headers['api-key'], req);
|
||||
|
||||
req.user = { // eslint-disable-line no-param-reassign
|
||||
id: Number(req.headers['api-user']),
|
||||
};
|
||||
req.user = await verifyKey(req.headers['api-user'], req.headers['api-key'], req);
|
||||
}
|
||||
|
||||
next();
|
||||
@@ -150,6 +147,7 @@ export default async function initServer() {
|
||||
router.use(alertsRouter);
|
||||
router.use(scenesRouter);
|
||||
router.use(actorsRouter);
|
||||
router.use(syncRouter);
|
||||
|
||||
// MOVIES
|
||||
router.get('/api/movies', fetchMoviesApi);
|
||||
|
||||
59
src/web/sync.js
Normal file
@@ -0,0 +1,59 @@
|
||||
import Router from 'express-promise-router';
|
||||
|
||||
import {
|
||||
syncScenes,
|
||||
syncMovies,
|
||||
syncActors,
|
||||
syncStashes,
|
||||
syncQueue,
|
||||
} from '../sync.js';
|
||||
|
||||
import verifyAbility from '../../utils/verify-ability.js';
|
||||
|
||||
export const syncRouter = Router();
|
||||
|
||||
async function syncScenesApi(req, res) {
|
||||
verifyAbility(req.user, 'sync', null, { throwError: true });
|
||||
|
||||
await syncScenes(req.body.sceneIds);
|
||||
|
||||
res.status(204).send();
|
||||
}
|
||||
|
||||
async function syncMoviesApi(req, res) {
|
||||
verifyAbility(req.user, 'sync', null, { throwError: true });
|
||||
|
||||
await syncMovies(req.body.movieIds);
|
||||
|
||||
res.status(204).send();
|
||||
}
|
||||
|
||||
async function syncActorsApi(req, res) {
|
||||
verifyAbility(req.user, 'sync', null, { throwError: true });
|
||||
|
||||
await syncActors(req.body.actorIds);
|
||||
|
||||
res.status(204).send();
|
||||
}
|
||||
|
||||
async function syncStashesApi(req, res) {
|
||||
verifyAbility(req.user, 'sync', null, { throwError: true });
|
||||
|
||||
await syncStashes(req.body.stashIds);
|
||||
|
||||
res.status(204).send();
|
||||
}
|
||||
|
||||
async function syncQueueApi(req, res) {
|
||||
verifyAbility(req.user, 'sync', null, { throwError: true });
|
||||
|
||||
await syncQueue();
|
||||
|
||||
res.status(204).send();
|
||||
}
|
||||
|
||||
syncRouter.post('/api/sync/scenes', syncScenesApi);
|
||||
syncRouter.post('/api/sync/movies', syncMoviesApi);
|
||||
syncRouter.post('/api/sync/actors', syncActorsApi);
|
||||
syncRouter.post('/api/sync/stashes', syncStashesApi);
|
||||
syncRouter.post('/api/sync', syncQueueApi);
|
||||
45
tools/manticore-actors.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import argv from '../src/argv.js';
|
||||
|
||||
import { knexOwner as knex } from '../src/knex.js';
|
||||
import { utilsApi } from '../src/manticore.js';
|
||||
import { syncManticoreActors } from '../src/sync.js';
|
||||
|
||||
async function init() {
|
||||
if (argv.update) {
|
||||
await utilsApi.sql('drop table if exists actors');
|
||||
await utilsApi.sql(`create table actors(
|
||||
id int,
|
||||
name text,
|
||||
aliases text,
|
||||
slug string,
|
||||
entity_id int,
|
||||
alias_for int,
|
||||
gender string,
|
||||
date_of_birth timestamp,
|
||||
country string,
|
||||
has_avatar bool,
|
||||
mass int,
|
||||
height int,
|
||||
cup string,
|
||||
natural_boobs int,
|
||||
penis_length int,
|
||||
penis_girth int,
|
||||
stashed int,
|
||||
scenes int
|
||||
) min_prefix_len = '3'`);
|
||||
|
||||
console.log('Recreated actors table, syncing actors...');
|
||||
|
||||
const data = await syncManticoreActors();
|
||||
|
||||
console.log('data', data);
|
||||
|
||||
knex.destroy();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
knex.destroy();
|
||||
}
|
||||
|
||||
init();
|
||||
45
tools/manticore-movies.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import argv from '../src/argv.js';
|
||||
import { knexOwner as knex } from '../src/knex.js';
|
||||
import { utilsApi } from '../src/manticore.js';
|
||||
import { syncManticoreMovies } from '../src/sync.js';
|
||||
|
||||
async function init() {
|
||||
if (argv.update) {
|
||||
await utilsApi.sql('drop table if exists movies');
|
||||
await utilsApi.sql(`create table movies (
|
||||
id int,
|
||||
title text,
|
||||
title_filtered text,
|
||||
channel_id int,
|
||||
channel_name text,
|
||||
channel_slug text,
|
||||
network_id int,
|
||||
network_name text,
|
||||
network_slug text,
|
||||
entity_ids multi,
|
||||
actor_ids multi,
|
||||
actors text,
|
||||
tag_ids multi,
|
||||
tags text,
|
||||
meta text,
|
||||
date timestamp,
|
||||
has_cover bool,
|
||||
created_at timestamp,
|
||||
effective_date timestamp,
|
||||
stashed int,
|
||||
stashed_scenes int,
|
||||
stashed_total int,
|
||||
dupe_index int
|
||||
)`);
|
||||
|
||||
console.log('Recreated movies tables, syncing movies...');
|
||||
|
||||
const data = await syncManticoreMovies();
|
||||
|
||||
console.log('data', data);
|
||||
}
|
||||
|
||||
knex.destroy();
|
||||
}
|
||||
|
||||
init();
|
||||
63
tools/manticore-scenes.js
Normal file
@@ -0,0 +1,63 @@
|
||||
import argv from '../src/argv.js';
|
||||
import { knexOwner as knex } from '../src/knex.js';
|
||||
import { utilsApi } from '../src/manticore.js';
|
||||
import { syncManticoreScenes } from '../src/sync.js';
|
||||
|
||||
async function init() {
|
||||
if (argv.update) {
|
||||
await utilsApi.sql('drop table if exists scenes');
|
||||
await utilsApi.sql(`create table scenes (
|
||||
id int,
|
||||
title text,
|
||||
title_filtered text,
|
||||
entry_id text,
|
||||
shoot_id text,
|
||||
channel_id int,
|
||||
channel_name text,
|
||||
channel_slug text,
|
||||
network_id int,
|
||||
network_name text,
|
||||
network_slug text,
|
||||
studio_id int,
|
||||
studio_name text,
|
||||
studio_slug text,
|
||||
entity_ids multi,
|
||||
actor_ids multi,
|
||||
actors text,
|
||||
tag_ids multi,
|
||||
assigned_tag_ids multi64,
|
||||
tags text,
|
||||
movie_ids multi,
|
||||
movies text,
|
||||
serie_ids multi,
|
||||
series text,
|
||||
meta text,
|
||||
date timestamp,
|
||||
fingerprints text,
|
||||
is_showcased bool,
|
||||
created_at timestamp,
|
||||
effective_date timestamp,
|
||||
stashed int,
|
||||
dupe_index int
|
||||
)`);
|
||||
|
||||
await utilsApi.sql('drop table if exists scenes_tags');
|
||||
|
||||
/* legacy, using packed decimal keys now
|
||||
await utilsApi.sql(`create table scenes_tags (
|
||||
id int,
|
||||
scene_id int,
|
||||
tag_id int,
|
||||
actor_id int
|
||||
)`);
|
||||
*/
|
||||
|
||||
console.log('Recreated scenes tables, syncing scenes...');
|
||||
|
||||
await syncManticoreScenes();
|
||||
}
|
||||
|
||||
knex.destroy();
|
||||
}
|
||||
|
||||
init();
|
||||
42
tools/manticore-stashes.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { knexOwner as knex } from '../src/knex.js';
|
||||
import { utilsApi } from '../src/manticore.js';
|
||||
import { syncStashes } from '../src/sync.js';
|
||||
|
||||
async function init() {
|
||||
await utilsApi.sql('drop table if exists scenes_stashed');
|
||||
|
||||
await utilsApi.sql(`create table if not exists scenes_stashed (
|
||||
scene_id int,
|
||||
stash_id int,
|
||||
user_id int,
|
||||
created_at timestamp
|
||||
)`);
|
||||
|
||||
await utilsApi.sql('drop table if exists movies_stashed');
|
||||
|
||||
await utilsApi.sql(`create table if not exists movies_stashed (
|
||||
movie_id int,
|
||||
stash_id int,
|
||||
user_id int,
|
||||
created_at timestamp
|
||||
)`);
|
||||
|
||||
await utilsApi.sql('drop table if exists actors_stashed');
|
||||
|
||||
await utilsApi.sql(`create table if not exists actors_stashed (
|
||||
actor_id int,
|
||||
stash_id int,
|
||||
user_id int,
|
||||
created_at timestamp
|
||||
)`);
|
||||
|
||||
console.log('Recreated stash tables, syncing stashes...');
|
||||
|
||||
await syncStashes('scene');
|
||||
await syncStashes('actor');
|
||||
await syncStashes('movie');
|
||||
|
||||
knex.destroy();
|
||||
}
|
||||
|
||||
init();
|
||||
7
utils/filter-title.js
Normal file
@@ -0,0 +1,7 @@
|
||||
export default function filterTitle(title, keys) {
|
||||
if (!title) {
|
||||
return title;
|
||||
}
|
||||
|
||||
return keys.reduce((accTitle, tag) => accTitle.replace(new RegExp(`\\b${tag.replace(/[^\w\s]+/g, '')}\\b`, 'gi'), ''), title).trim().replace(/\s{2,}/, ' ');
|
||||
}
|
||||
27
utils/verify-ability.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { HttpError } from '../src/errors.js';
|
||||
|
||||
function checkAbility(user, subject, action) {
|
||||
if (!user?.abilities) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (subject && action) {
|
||||
return user.abilities.some((ability) => ability.subject === subject && ability.action === action);
|
||||
}
|
||||
|
||||
if (subject) {
|
||||
return user.abilities.some((ability) => ability[subject] === true || (ability.subject === subject && !ability.action));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export default function verifyAbility(user, subject, action, options = {}) {
|
||||
const isAble = checkAbility(user, subject, action);
|
||||
|
||||
if (!isAble && options.throwError) {
|
||||
throw new HttpError(`Insufficient privileges for ${[subject, action].filter(Boolean).join()}`, 403);
|
||||
}
|
||||
|
||||
return isAble;
|
||||
}
|
||||