Updated settings.ts and README
This commit is contained in:
1 parent
300faba252
commit
0dcdd10334
2 files changed
+94
-17
No files matched your search
@@ -40,6 +40,72 @@ docker run -p 8080:3000 -it photon:latest
|
||||
|
||||
There you go, you now have an instance of Photon running.
|
||||
|
||||
|
||||
### Configuring default settings
|
||||
The following environment variables can be set to override the default settings:
|
||||
|
||||
Variable | Values | Default Value
|
||||
---|---|---
|
||||
PUBLIC_INSTANCE_URL | URL | `lemmy.ml`
|
||||
PUBLIC_EXPANDABLE_IMAGES | `bool` | true
|
||||
PUBLIC_MARK_READ_POSTS | `bool` | true
|
||||
PUBLIC_REVERT_VOTE_COLORS | `bool` | false
|
||||
PUBLIC_SHOW_INSTANCES_USER | `bool` | false
|
||||
PUBLIC_SHOW_INSTANCES_COMMUNITY | `bool` | true
|
||||
PUBLIC_SHOW_INSTANCES_COMMENT | `bool` | false
|
||||
PUBLIC_SHOW_COMPACT_POSTS | `bool` | false
|
||||
PUBLIC_DEFAULT_FEED_SORT | `SortType` | Active
|
||||
PUBLIC_DEFAULT_FEED | `ListingType`| Local
|
||||
PUBLIC_DEFAULT_COMMENT_SORT | `CommentSortType` | Hot
|
||||
PUBLIC_HIDE_DELETED | `bool` | true
|
||||
PUBLIC_HIDE_REMOVED | `bool` | false
|
||||
PUBLIC_FULL_WIDTH_LAYOUT | `bool` | false
|
||||
PUBLIC_EXPAND_SIDEBAR | `bool` | true
|
||||
PUBLIC_DISPLAY_NAMES | `bool` | true
|
||||
PUBLIC_NSFW_BLUR | `bool` | true
|
||||
PUBLIC_NEW_VOTE_BUTTONS | `bool` | false
|
||||
|
||||
The values for `SortType`, `ListingType`, and `CommentSortType` are defined by the lemmy-js-client library.
|
||||
|
||||
#### Listing Type
|
||||
https://github.com/LemmyNet/lemmy-js-client/blob/main/src/types/ListingType.ts
|
||||
- All
|
||||
- Local
|
||||
- Subscribed
|
||||
- Moderator View (not implemented in Photon)
|
||||
|
||||
#### Sort Type
|
||||
https://github.com/LemmyNet/lemmy-js-client/blob/main/src/types/SortType.ts
|
||||
- Active
|
||||
- Hot
|
||||
- New
|
||||
- Old
|
||||
- TopDay
|
||||
- TopWeek
|
||||
- TopMonth
|
||||
- TopAll
|
||||
- MostComments
|
||||
- NewComments
|
||||
- TopHour
|
||||
- TopSixHour
|
||||
- TopTwelveHour (Not implemented in Photon)
|
||||
- TopThreeMonths (Not implemented in Photon)
|
||||
- TopSixMonths (Not implemented in Photon)
|
||||
- TopNineMonths (Not implemented in Photon)
|
||||
- TopYear (Not implemented in Photon)
|
||||
- Controversial (Not implemented in Photon)
|
||||
|
||||
#### Comment Sort Type
|
||||
https://github.com/LemmyNet/lemmy-js-client/blob/main/src/types/CommentSortType.ts
|
||||
values:
|
||||
- Hot
|
||||
- Top
|
||||
- New
|
||||
- Old (not implemented in Photon)
|
||||
- Controversial (not implemented in Photon)
|
||||
|
||||
|
||||
|
||||
### Donate
|
||||
|
||||
You can donate at [Buy me a Coffee](https://buymeacoffee.com/xylight)
|
||||
|
||||
+28
-17
@@ -1,5 +1,15 @@
|
||||
import type { CommentSortType, SortType } from 'lemmy-js-client'
|
||||
import { writable } from 'svelte/store'
|
||||
import { env } from '$env/dynamic/public'
|
||||
|
||||
console.log("Using the following default settings from the environment:");
|
||||
console.log(env);
|
||||
|
||||
// Returns a proper boolean or null. Used to set boolean values from env var strings while allowing nullish coalescing to set default values.
|
||||
const toBool = (str) => {
|
||||
if (typeof str === "undefined") { return null; }
|
||||
return str === "true";
|
||||
}
|
||||
|
||||
interface Settings {
|
||||
newComments: boolean
|
||||
@@ -39,38 +49,39 @@ interface Settings {
|
||||
}
|
||||
|
||||
export const defaultSettings: Settings = {
|
||||
|
||||
newComments: true,
|
||||
expandableImages: true,
|
||||
markReadPosts: true,
|
||||
revertColors: false,
|
||||
expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true,
|
||||
markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true,
|
||||
revertColors: toBool(env.PUBLIC_REVERT_VOTE_COLORS) ?? false,
|
||||
showInstances: {
|
||||
user: false,
|
||||
community: true,
|
||||
comments: false,
|
||||
user: toBool(env.PUBLIC_SHOW_INSTANCES_USER) ?? false,
|
||||
community: toBool(env.PUBLIC_SHOW_INSTANCES_COMMUNITY) ?? true,
|
||||
comments: toBool(env.PUBLIC_SHOW_INSTANCES_COMMENTS) ?? false,
|
||||
},
|
||||
showCompactPosts: false,
|
||||
showCompactPosts: toBool(env.PUBLIC_SHOW_COMPACT_POSTS) ?? false,
|
||||
defaultSort: {
|
||||
sort: 'Active',
|
||||
feed: 'Local',
|
||||
comments: 'Hot',
|
||||
sort: env.PUBLIC_DEFAULT_FEED_SORT ?? 'Active',
|
||||
feed: env.PUBLIC_DEFAULT_FEED ?? 'Local',
|
||||
comments: env.PUBLIC_DEFAULT_COMMENT_SORT ?? 'Hot',
|
||||
},
|
||||
hidePosts: {
|
||||
deleted: true,
|
||||
removed: false,
|
||||
deleted: toBool(env.PUBLIC_HIDE_DELETED) ?? true,
|
||||
removed: toBool(env.PUBLIC_HIDE_REMOVED) ?? false,
|
||||
},
|
||||
fullWidthLayout: false,
|
||||
expandSidebar: true,
|
||||
fullWidthLayout: toBool(env.PUBLIC_FULL_WIDTH_LAYOUT) ?? false,
|
||||
expandSidebar: toBool(env.PUBLIC_EXPAND_SIDEBAR) ?? true,
|
||||
notifications: {
|
||||
enabled: false,
|
||||
pollRate: 60 * 1000,
|
||||
notifRate: 10 * 60 * 1000,
|
||||
},
|
||||
displayNames: true,
|
||||
nsfwBlur: true,
|
||||
displayNames: toBool(env.PUBLIC_DISPLAY_NAMES) ?? true,
|
||||
nsfwBlur: toBool(env.PUBLIC_NSFW_BLUR) ?? true,
|
||||
moderation: {
|
||||
removalReasonPreset: `Your submission in *"{{post}}"* was removed for {{reason}}.`,
|
||||
},
|
||||
newVote: false,
|
||||
newVote: toBool(env.PUBLIC_NEW_VOTE_BUTTONS) ?? false,
|
||||
}
|
||||
|
||||
export const userSettings = writable(defaultSettings)
|
||||
|
||||
Reference in new issue
Block a user