feat: add option to disable random placeholders, close #107

This commit is contained in:
Xyphyn committed 2023-08-16 15:49:06 -07:00
1 parent 61a8344fd7
commit dbbd460597
4 files changed
+44 -25

No files matched your search

+29 -24
View File
@@ -40,43 +40,48 @@ docker run -p 8080:3000 -it photon:latest
There you go, you now have an instance of Photon running. There you go, you now have an instance of Photon running.
### Configuring default settings ### Configuring default settings
The following environment variables can be set to override the default settings: The following environment variables can be set to override the default settings:
Variable | Values | Default Value | Variable | Values | Default Value |
---|---|--- | ------------------------------- | ------------------- | ------------- |
PUBLIC_INSTANCE_URL | URL | `lemmy.ml` | PUBLIC_INSTANCE_URL | URL | `lemmy.ml` |
PUBLIC_THEME | system\|dark\|light | system | PUBLIC_THEME | system\|dark\|light | system |
PUBLIC_EXPANDABLE_IMAGES | `bool` | true | PUBLIC_EXPANDABLE_IMAGES | `bool` | true |
PUBLIC_MARK_READ_POSTS | `bool` | true | PUBLIC_MARK_READ_POSTS | `bool` | true |
PUBLIC_REVERT_VOTE_COLORS | `bool` | false | PUBLIC_REVERT_VOTE_COLORS | `bool` | false |
PUBLIC_SHOW_INSTANCES_USER | `bool` | false | PUBLIC_SHOW_INSTANCES_USER | `bool` | false |
PUBLIC_SHOW_INSTANCES_COMMUNITY | `bool` | true | PUBLIC_SHOW_INSTANCES_COMMUNITY | `bool` | true |
PUBLIC_SHOW_INSTANCES_COMMENT | `bool` | false | PUBLIC_SHOW_INSTANCES_COMMENT | `bool` | false |
PUBLIC_SHOW_COMPACT_POSTS | `bool` | false | PUBLIC_SHOW_COMPACT_POSTS | `bool` | false |
PUBLIC_DEFAULT_FEED_SORT | `SortType` | Active | PUBLIC_DEFAULT_FEED_SORT | `SortType` | Active |
PUBLIC_DEFAULT_FEED | `ListingType`| Local | PUBLIC_DEFAULT_FEED | `ListingType` | Local |
PUBLIC_DEFAULT_COMMENT_SORT | `CommentSortType` | Hot | PUBLIC_DEFAULT_COMMENT_SORT | `CommentSortType` | Hot |
PUBLIC_HIDE_DELETED | `bool` | true | PUBLIC_HIDE_DELETED | `bool` | true |
PUBLIC_HIDE_REMOVED | `bool` | false | PUBLIC_HIDE_REMOVED | `bool` | false |
PUBLIC_FULL_WIDTH_LAYOUT | `bool` | false | PUBLIC_FULL_WIDTH_LAYOUT | `bool` | false |
PUBLIC_EXPAND_SIDEBAR | `bool` | true | PUBLIC_EXPAND_SIDEBAR | `bool` | true |
PUBLIC_DISPLAY_NAMES | `bool` | true | PUBLIC_DISPLAY_NAMES | `bool` | true |
PUBLIC_NSFW_BLUR | `bool` | true | PUBLIC_NSFW_BLUR | `bool` | true |
PUBLIC_NEW_VOTE_BUTTONS | `bool` | false | PUBLIC_NEW_VOTE_BUTTONS | `bool` | false |
| PUBLIC_RANDOM_PLACEHOLDERS | `bool` | true |
The values for `SortType`, `ListingType`, and `CommentSortType` are defined by the lemmy-js-client library. The values for `SortType`, `ListingType`, and `CommentSortType` are defined by the lemmy-js-client library.
#### Listing Type #### Listing Type
https://github.com/LemmyNet/lemmy-js-client/blob/main/src/types/ListingType.ts https://github.com/LemmyNet/lemmy-js-client/blob/main/src/types/ListingType.ts
- All - All
- Local - Local
- Subscribed - Subscribed
- Moderator View (not implemented in Photon) - Moderator View (not implemented in Photon)
#### Sort Type #### Sort Type
https://github.com/LemmyNet/lemmy-js-client/blob/main/src/types/SortType.ts https://github.com/LemmyNet/lemmy-js-client/blob/main/src/types/SortType.ts
- Active - Active
- Hot - Hot
- New - New
@@ -97,16 +102,16 @@ https://github.com/LemmyNet/lemmy-js-client/blob/main/src/types/SortType.ts
- Controversial (Not implemented in Photon) - Controversial (Not implemented in Photon)
#### Comment Sort Type #### Comment Sort Type
https://github.com/LemmyNet/lemmy-js-client/blob/main/src/types/CommentSortType.ts https://github.com/LemmyNet/lemmy-js-client/blob/main/src/types/CommentSortType.ts
values: values:
- Hot - Hot
- Top - Top
- New - New
- Old (not implemented in Photon) - Old (not implemented in Photon)
- Controversial (not implemented in Photon) - Controversial (not implemented in Photon)
### Donate ### Donate
You can donate at [Buy me a Coffee](https://buymeacoffee.com/xylight) You can donate at [Buy me a Coffee](https://buymeacoffee.com/xylight)
+2
View File
@@ -48,6 +48,7 @@ interface Settings {
removalReasonPreset: string removalReasonPreset: string
} }
newVote: boolean newVote: boolean
randomPlaceholders: boolean
} }
export const defaultSettings: Settings = { export const defaultSettings: Settings = {
@@ -83,6 +84,7 @@ export const defaultSettings: Settings = {
removalReasonPreset: `Your submission in *"{{post}}"* was removed for {{reason}}.`, removalReasonPreset: `Your submission in *"{{post}}"* was removed for {{reason}}.`,
}, },
newVote: toBool(env.PUBLIC_NEW_VOTE_BUTTONS) ?? false, newVote: toBool(env.PUBLIC_NEW_VOTE_BUTTONS) ?? false,
randomPlaceholders: toBool(env.PUBLIC_RANDOM_PLACEHOLDERS) ?? true,
} }
export const userSettings = writable(defaultSettings) export const userSettings = writable(defaultSettings)
+5 -1
View File
@@ -1,4 +1,6 @@
import { goto } from '$app/navigation' import { goto } from '$app/navigation'
import { userSettings } from '$lib/settings.js'
import { get } from 'svelte/store'
export const findClosestNumber = (numbers: number[], target: number): number => export const findClosestNumber = (numbers: number[], target: number): number =>
numbers.reduce((prev, curr) => numbers.reduce((prev, curr) =>
@@ -47,8 +49,10 @@ export const placeholders = {
'existential crisis in progress', 'existential crisis in progress',
], ],
get: (type: 'url' | 'post' | 'comment') => { get: (type: 'url' | 'post' | 'comment') => {
return placeholders[type][ return get(userSettings)?.randomPlaceholders
? placeholders[type][
Math.floor(Math.random() * placeholders[type].length) Math.floor(Math.random() * placeholders[type].length)
] ]
: ''
}, },
} }
+8
View File
@@ -95,6 +95,14 @@
Show a user's display name instead of their account username. Show a user's display name instead of their account username.
</span> </span>
</Setting> </Setting>
<Setting>
<Checkbox slot="title" bind:checked={$userSettings.randomPlaceholders}>
Random placeholders
</Checkbox>
<span slot="description">
Show a random placeholder for forms for comments, posts, etc.
</span>
</Setting>
<SectionTitle class="mt-4">UI</SectionTitle> <SectionTitle class="mt-4">UI</SectionTitle>
<Setting> <Setting>