diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-02-03 21:56:27 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-02-03 21:56:38 -0400 |
commit | 80ef2108d9ce2ee5bb8c3cae562a7257710a7f23 (patch) | |
tree | f14daa07b516d4f9c9fd7f97cb80c1c1a689c22e /src/thing | |
parent | f8e4c8e3ffc6da224699db15d13a02ed8b4e49e5 (diff) |
wiki info
Diffstat (limited to 'src/thing')
-rw-r--r-- | src/thing/static-page.js | 2 | ||||
-rw-r--r-- | src/thing/validators.js | 9 | ||||
-rw-r--r-- | src/thing/wiki-info.js | 90 |
3 files changed, 100 insertions, 1 deletions
diff --git a/src/thing/static-page.js b/src/thing/static-page.js index 18e9d142..e2b51507 100644 --- a/src/thing/static-page.js +++ b/src/thing/static-page.js @@ -15,7 +15,7 @@ export default class StaticPage extends Thing { name: { flags: {update: true, expose: true}, - update: {validate: isName} + update: {validate: isName, default: 'Unnamed Static Page'} }, nameShort: { diff --git a/src/thing/validators.js b/src/thing/validators.js index 49463473..1bc7fd72 100644 --- a/src/thing/validators.js +++ b/src/thing/validators.js @@ -241,6 +241,15 @@ export function isFileExtension(string) { return true; } +export function isLanguageCode(string) { + // TODO: This is a stub function because really we don't need a detailed + // is-language-code parser right now. + + isString(string); + + return true; +} + export function isName(name) { return isString(name); } diff --git a/src/thing/wiki-info.js b/src/thing/wiki-info.js new file mode 100644 index 00000000..b805bf76 --- /dev/null +++ b/src/thing/wiki-info.js @@ -0,0 +1,90 @@ +import CacheableObject from './cacheable-object.js'; + +import { + isBoolean, + isColor, + isLanguageCode, + isName, + isString, + isURL, +} from './validators.js'; + +export default class WikiInfo extends CacheableObject { + static propertyDescriptors = { + // Update & expose + + name: { + flags: {update: true, expose: true}, + update: {validate: isName, default: 'Unnamed Wiki'} + }, + + // Displayed in nav bar. + shortName: { + flags: {update: true, expose: true}, + update: {validate: isName}, + + expose: { + dependencies: ['name'], + transform: (value, { name }) => value ?? name + } + }, + + color: { + flags: {update: true, expose: true}, + update: {validate: isColor} + }, + + // One-line description used for <meta rel="description"> tag. + description: { + flags: {update: true, expose: true}, + update: {validate: isString} + }, + + footerContent: { + flags: {update: true, expose: true}, + update: {validate: isString} + }, + + defaultLanguage: { + flags: {update: true, expose: true}, + update: {validate: isLanguageCode} + }, + + canonicalBase: { + flags: {update: true, expose: true}, + update: {validate: isURL} + }, + + // Feature toggles + + enableArtistAvatars: { + flags: {update: true, expose: true}, + update: {validate: isBoolean, default: false} + }, + + enableFlashesAndGames: { + flags: {update: true, expose: true}, + update: {validate: isBoolean, default: false} + }, + + enableListings: { + flags: {update: true, expose: true}, + update: {validate: isBoolean, default: false} + }, + + enableNews: { + flags: {update: true, expose: true}, + update: {validate: isBoolean, default: false} + }, + + enableArtTagUI: { + flags: {update: true, expose: true}, + update: {validate: isBoolean, default: false} + }, + + enableGroupUI: { + flags: {update: true, expose: true}, + update: {validate: isBoolean, default: false} + }, + }; +} |