Skip to content

Commit 130b39b

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents cfeae5b + c0fb61b commit 130b39b

File tree

18 files changed

+555
-166
lines changed

18 files changed

+555
-166
lines changed

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,20 @@ insert_final_newline = true
77
indent_style = space
88
indent_size = 2
99
trim_trailing_whitespace = true
10+
11+
# These configurations are recognized by `shfmt`:
12+
# https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd
13+
#
14+
# If you are using this VSCode extension https://github.com/foxundermoon/vs-shell-format/tree/master,
15+
# then add this to your settings.json, because it doesn't use the .editorconfig file by default:
16+
# ```json
17+
# {
18+
# "shellformat.useEditorConfig": true
19+
# }
20+
# ```
21+
# That's really annoying, but it is what it is.
22+
#
23+
# The default for `shfmt` is not to indent the match arms of case statements, that is
24+
# exremely ugly. The issue about that in the VSCode extension repo:
25+
# https://github.com/foxundermoon/vs-shell-format/issues/371
26+
switch_case_indent = true

README.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,40 @@
44

55
## Getting Started
66

7-
On systems with `docker` and `docker compose` installed, the process should be as simple as:
7+
Make sure you have [Docker](https://docs.docker.com/engine/install/) and [Docker Compose plugin](https://docs.docker.com/compose/install/#scenario-two-install-the-docker-compose-plugin) installed.
88

9-
```
10-
docker compose build
11-
docker compose up
9+
Add the directory `scripts/path` to your `PATH` to get the `philomena` dev CLI globally available in your terminal. For example you can add the following to your shell's `.*rc` file, but adjust the path to philomena repo accordingly.
10+
11+
```bash
12+
export PATH="$PATH:$HOME/dev/philomena/scripts/path"
1213
```
1314

14-
If you use `podman` and `podman-compose` instead, the process for constructing a rootless container is nearly identical:
15+
Use the following commands to bring up or shut down a dev server.
1516

16-
```
17-
podman-compose build
18-
podman-compose up
17+
```bash
18+
philomena up
19+
philomena down
1920
```
2021

21-
Once the application has started, navigate to http://localhost:8080 and login with admin@example.com / philomena123
22+
Once the application has started, navigate to http://localhost:8080 and login with
2223

23-
## Development
24+
| Credential | Value |
25+
| ---------- | ------------------- |
26+
| Email | `admin@example.com` |
27+
| Password | `philomena123` |
2428

25-
Install NodeJS, Rust and Elixir toolchains. Then, run the following command to install other dependencies and configure the git pre-commit hook that will auto-format the code and run lightweight checks on each commit:
29+
> [!TIP]
30+
> See the source code of `scripts/philomena.sh` for details on the additional parameters and other subcommands.
2631
32+
## Pre-commit hook
33+
34+
Run the following command to configure the git pre-commit hook that will auto-format the code and run lightweight checks on each commit.
35+
36+
```bash
37+
philomena init
2738
```
28-
./scripts/init.sh
29-
```
39+
40+
## IDE Setup
3041

3142
If you are using VSCode, you are encouraged to install the recommended extensions that VSCode should automatically suggest to you based on `.vscode/extensions.json` file in this repo.
3243

assets/css/elements/forms.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,39 @@ textarea {
9292
margin-bottom: 6px;
9393
}
9494

95+
.field-help-button,
96+
.field-help-button * {
97+
font-style: italic;
98+
cursor: pointer;
99+
}
100+
101+
.field-help-button {
102+
margin-left: 6px;
103+
font-size: 0.8em;
104+
color: var(--foreground-half-color);
105+
border-color: var(--foreground-half-color);
106+
border-style: dashed;
107+
border-width: 1px;
108+
border-radius: 10px;
109+
padding: 4px;
110+
111+
/*
112+
We want this to behave like a button, so double clicking on it
113+
shouldn't trigger a selection
114+
*/
115+
user-select: none;
116+
}
117+
118+
.field-help-button:hover {
119+
background-color: var(--primary-light-color);
120+
}
121+
122+
.field-help-content {
123+
color: var(--foreground-half-color);
124+
margin: 10px auto;
125+
font-style: italic;
126+
}
127+
95128
.field_with_errors {
96129
background: var(--danger-color);
97130
}
@@ -107,6 +140,7 @@ span.help-block {
107140
max-width: 30em;
108141
width: 100%;
109142
}
143+
110144
/* text input - grow to container size */
111145
.hform__text {
112146
flex: 1 0 auto;

assets/js/settings.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ function setupAutocompleteSettings() {
4444
});
4545
}
4646

47+
function setupHelpExpansions() {
48+
document.addEventListener('click', event => {
49+
if (!(event.target instanceof HTMLElement)) {
50+
return;
51+
}
52+
53+
const helpButton = event.target.closest('.field-help-button');
54+
55+
if (!helpButton || !helpButton.nextElementSibling) {
56+
return;
57+
}
58+
59+
helpButton.nextElementSibling.classList.toggle('hidden');
60+
});
61+
}
62+
4763
export function setupSettings() {
4864
if (!$('#js-setting-table')) return;
4965

@@ -58,4 +74,5 @@ export function setupSettings() {
5874

5975
setupThemeSettings();
6076
setupAutocompleteSettings();
77+
setupHelpExpansions();
6178
}

assets/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"postcss-mixins": "^11.0.3",
2121
"postcss-simple-vars": "^7.0.1",
2222
"typescript": "^5.7.2",
23-
"vite": "^6.2.5"
23+
"vite": "^6.2.6"
2424
},
2525
"devDependencies": {
2626
"@testing-library/dom": "^10.4.0",

docker/app/Dockerfile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,8 @@ RUN git clone --depth 1 https://github.com/philomena-dev/mediatools /tmp/mediato
4040
&& cd /tmp/mediatools \
4141
&& make -j$(nproc) install
4242

43-
COPY scripts/lib.sh /var/philomena/scripts/
43+
# docker-compose configures a bind-mount of the repo root dir to /srv/philomena
44+
ENV PATH=$PATH:/root/.cargo/bin:/srv/philomena/docker/app
4445

45-
COPY \
46-
docker/app/run-development \
47-
docker/app/run-test \
48-
docker/app/safe-rsvg-convert \
49-
docker/app/purge-cache \
50-
/var/philomena/docker/app/
51-
52-
ENV PATH=$PATH:/root/.cargo/bin:/var/philomena/docker/app
5346
EXPOSE 5173
5447
CMD run-development

lib/philomena/images/image.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ defmodule Philomena.Images.Image do
344344

345345
def approve_changeset(image) do
346346
change(image)
347+
|> validate_not_approved()
348+
|> validate_not_hidden()
347349
|> put_change(:approved, true)
348350
|> put_change(:first_seen_at, DateTime.utc_now(:second))
349351
end
@@ -365,4 +367,11 @@ defmodule Philomena.Images.Image do
365367
false -> changeset
366368
end
367369
end
370+
371+
defp validate_not_approved(changeset) do
372+
case get_field(changeset, :approved) do
373+
true -> add_error(changeset, :approved, "must be false")
374+
false -> changeset
375+
end
376+
end
368377
end

lib/philomena/images/query.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
defmodule Philomena.Images.Query do
22
alias PhilomenaQuery.Parse.Parser
33
alias Philomena.Repo
4+
alias Philomena.Tags.Tag
45

56
defp gallery_id_transform(_ctx, value) do
67
case Integer.parse(value) do
@@ -99,7 +100,8 @@ defmodule Philomena.Images.Query do
99100
"faved_by" => "favourited_by_users",
100101
"faved_by_id" => "favourited_by_user_ids"
101102
},
102-
no_downcase_fields: ~W(file_name)
103+
no_downcase_fields: ~W(file_name),
104+
normalizations: %{"namespaced_tags.name" => &Tag.clean_tag_name/1}
103105
]
104106
end
105107

@@ -124,7 +126,7 @@ defmodule Philomena.Images.Query do
124126
~W(fingerprint upvoted_by downvoted_by true_uploader hidden_by deleted_by_user),
125127
ngram_fields: fields[:ngram_fields] ++ ~W(deletion_reason),
126128
ip_fields: ~W(ip),
127-
bool_fields: fields[:bool_fields] ++ ~W(deleted),
129+
bool_fields: fields[:bool_fields] ++ ~W(anonymous deleted),
128130
aliases:
129131
Map.merge(fields[:aliases], %{
130132
"upvoted_by" => "upvoters",

lib/philomena/tags/tag.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ defmodule Philomena.Tags.Tag do
1717
"blog",
1818
"colorist",
1919
"comic",
20+
"commissioner",
2021
"editor",
2122
"fanfic",
2223
"generator",
@@ -50,6 +51,7 @@ defmodule Philomena.Tags.Tag do
5051
@underscore_safe_namespaces [
5152
"artist:",
5253
"colorist:",
54+
"commissioner:",
5355
"editor:",
5456
"generator:",
5557
"oc:",
@@ -203,9 +205,10 @@ defmodule Philomena.Tags.Tag do
203205
)
204206
|> String.replace(~r/[\x{00b4}\x{2018}\x{2019}\x{201a}\x{201b}\x{2032}]/u, "'")
205207
|> String.replace(~r/[\x{201c}\x{201d}\x{201e}\x{201f}\x{2033}]/u, "\"")
206-
|> String.trim()
207208
|> clean_tag_namespace()
208209
|> ununderscore()
210+
|> String.trim()
211+
|> String.replace(~r/ +/, " ")
209212
end
210213

211214
defp clean_tag_namespace(name) do

0 commit comments

Comments
 (0)