Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
liamwhite committed Jun 11, 2024
2 parents d0fa29f + 45df8a8 commit 10f5756
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
6 changes: 2 additions & 4 deletions assets/js/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

import { $ } from './utils/dom';

interface ShortcutKeycodes {
[key: string]: () => void
}
type ShortcutKeyMap = Record<string, () => void>;

function getHover(): string | null {
const thumbBoxHover = $<HTMLDivElement>('.media-box:hover');
Expand Down Expand Up @@ -45,7 +43,7 @@ function isOK(event: KeyboardEvent): boolean {
document.activeElement.tagName !== 'TEXTAREA';
}

const keyCodes: ShortcutKeycodes = {
const keyCodes: ShortcutKeyMap = {
KeyJ() { click('.js-prev'); }, // J - go to previous image
KeyI() { click('.js-up'); }, // I - go to index page
KeyK() { click('.js-next'); }, // K - go to next image
Expand Down
4 changes: 4 additions & 0 deletions assets/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
return {
publicDir: 'static',
plugins: [],
server: {
host: '0.0.0.0',
port: 5173,
},
resolve: {
alias: {
common: path.resolve(__dirname, 'css/common/'),
Expand Down
2 changes: 1 addition & 1 deletion lib/philomena/images.ex
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ defmodule Philomena.Images do
(source.sources ++ target.sources)
|> Enum.map(fn s -> %Source{image_id: target.id, source: s.source} end)
|> Enum.uniq()
|> Enum.take(10)
|> Enum.take(15)

target
|> Image.sources_changeset(sources)
Expand Down
2 changes: 2 additions & 0 deletions lib/philomena/images/image.ex
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ defmodule Philomena.Images.Image do
image
|> cast(attrs, [])
|> SourceDiffer.diff_input(old_sources, new_sources)
|> validate_length(:sources, max: 15)
end

def sources_changeset(image, new_sources) do
change(image)
|> put_assoc(:sources, new_sources)
|> validate_length(:sources, max: 15)
end

def tag_changeset(image, attrs, old_tags, new_tags, excluded_tags \\ []) do
Expand Down
2 changes: 1 addition & 1 deletion lib/philomena_web/templates/image/_source.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

p
'The page(s) you found this image on. Images may have a maximum of
span.js-max-source-count> 10
span.js-max-source-count> 15
' source URLs. Leave any sources you don't want to use blank.

= inputs_for f, :sources, [as: "image[old_sources]", skip_hidden: true], fn fs ->
Expand Down
2 changes: 1 addition & 1 deletion lib/philomena_web/templates/image/new.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
h4 About this image
p
'The page(s) you found this image on. Images may have a maximum of
span.js-max-source-count> 10
span.js-max-source-count> 15
' source URLs. Leave any sources you don't want to use blank.

= inputs_for f, :sources, fn fs ->
Expand Down
4 changes: 2 additions & 2 deletions lib/philomena_web/templates/layout/app.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ html lang="en"
= csrf_meta_tag()

= vite_hmr? do
script type="module" src="http://localhost:5173/@vite/client"
script type="module" src="http://localhost:5173/js/app.ts"
script type="module" src="http://#{@conn.host}:5173/@vite/client"
script type="module" src="http://#{@conn.host}:5173/js/app.ts"
- else
script type="text/javascript" src=~p"/js/app.js" async="async"
= render PhilomenaWeb.LayoutView, "_opengraph.html", assigns
Expand Down

0 comments on commit 10f5756

Please sign in to comment.