From 2615eb85322b571ede6cb81da6afc064f4cad2cc Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 22 Aug 2023 10:37:18 +0300 Subject: [PATCH] Extract system message templates to template files --- public/index.html | 38 +- public/script.js | 325 ++++++++---------- public/scripts/RossAscends-mods.js | 9 +- .../scripts/extensions/quick-reply/index.js | 4 +- public/scripts/i18n.js | 75 ++++ public/scripts/power-user.js | 34 -- public/scripts/templates/formatting.html | 21 ++ public/scripts/templates/help.html | 11 + public/scripts/templates/hotkeys.html | 13 + public/scripts/templates/macros.html | 11 + public/scripts/templates/welcome.html | 72 ++++ 11 files changed, 349 insertions(+), 264 deletions(-) create mode 100644 public/scripts/i18n.js create mode 100644 public/scripts/templates/formatting.html create mode 100644 public/scripts/templates/help.html create mode 100644 public/scripts/templates/hotkeys.html create mode 100644 public/scripts/templates/macros.html create mode 100644 public/scripts/templates/welcome.html diff --git a/public/index.html b/public/index.html index 59ea701aa..63ab8f9ce 100644 --- a/public/index.html +++ b/public/index.html @@ -63,42 +63,8 @@ - - + + diff --git a/public/script.js b/public/script.js index 8ba7ecf54..819847b05 100644 --- a/public/script.js +++ b/public/script.js @@ -170,6 +170,7 @@ import { getInstructStoppingSequences, autoSelectInstructPreset, } from "./scripts/instruct-mode.js"; +import { applyLocale } from "./scripts/i18n.js"; //exporting functions and vars for mods export { @@ -241,6 +242,14 @@ export { printCharacters, } +// Allow target="_blank" in links +DOMPurify.addHook('afterSanitizeAttributes', function (node) { + if ('target' in node) { + node.setAttribute('target', '_blank'); + node.setAttribute('rel', 'noopener'); + } +}); + // API OBJECT FOR EXTERNAL WIRING window["SillyTavern"] = {}; @@ -357,186 +366,102 @@ const extension_prompt_types = { IN_CHAT: 1 }; -const system_messages = { - help: { - name: systemUserName, - force_avatar: system_avatar, - is_user: false, - is_system: true, - is_name: true, - mes: - `Hello there! Please select the help topic you would like to learn more about: - -
Still got questions left? The Official SillyTavern Documentation Website has much more information!` - }, - slash_commands: { - name: systemUserName, - force_avatar: system_avatar, - is_user: false, - is_system: true, - is_name: true, - mes: '', - }, - hotkeys: { - name: systemUserName, - force_avatar: system_avatar, - is_user: false, - is_system: true, - is_name: true, - mes: - `Hotkeys/Keybinds: - ` - }, - formatting: { - name: systemUserName, - force_avatar: system_avatar, - is_user: false, - is_system: true, - is_name: true, - mes: - `Text formatting commands: - ` - }, - macros: { - name: systemUserName, - force_avatar: system_avatar, - is_user: false, - is_system: true, - is_name: true, - mes: - `System-wide Replacement Macros: - ` - }, - welcome: - { - name: systemUserName, - force_avatar: system_avatar, - is_user: false, - is_system: true, - is_name: true, - mes: [ - '

SillyTavern

', - "Want to update?", - '
', - '

How to start chatting?

', - '
    ', - '
  1. Click and select a Chat API.
  2. ', - '
  3. Click and pick a character
  4. ', - '
', - '
', - '

Want more characters?

', - 'Not controlled by SillyTavern team.', - '', - '
', - '

Confused or lost?

', - '', - - '
', - '

Still have questions?

', - '