From 80ef2108d9ce2ee5bb8c3cae562a7257710a7f23 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 3 Feb 2022 21:56:27 -0400 Subject: wiki info --- src/thing/static-page.js | 2 +- src/thing/validators.js | 9 +++++ src/thing/wiki-info.js | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 src/thing/wiki-info.js (limited to 'src/thing') 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 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} + }, + }; +} -- cgit 1.3.0-6-gf8a5