Merge pull request #1882 from berbant/staging

Link to character's source page
This commit is contained in:
Cohee 2024-03-03 20:24:51 +02:00 committed by GitHub
commit 2e002032b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 0 deletions

View File

@ -3998,6 +3998,9 @@
<option id="renameCharButton" data-i18n="Rename">
Rename
</option>
<option id="character_source" data-i18n="Link to Source">
Link to Source
</option>
<!--<option id="dupe_button">
Duplicate
</option>

View File

@ -6481,6 +6481,13 @@ export function select_selected_character(chid) {
setWorldInfoButtonClass(chid);
checkEmbeddedWorld(chid);
// Disable or enable Link to Source dropdown menu item depending on the presence of 'full_path' property
$('#character_source').prop( "disabled", true );
const chidSourceData = Object.values(characters[this_chid].data.extensions)
Object.entries(chidSourceData).forEach(function([key, value]) {
if (Object.keys(value).includes('full_path')) $('#character_source').prop( "disabled", false );
});
$('#form_create').attr('actiontype', 'editcharacter');
$('.form_create_bottom_buttons_block .chat_lorebook_button').show();
saveSettingsDebounced();
@ -9809,6 +9816,22 @@ jQuery(async function () {
await importEmbeddedWorldInfo();
saveCharacterDebounced();
break;
case 'character_source':
const chidSourceData = characters[this_chid].data.extensions
switch(true) {
case Object.hasOwn(chidSourceData, 'chub') :
window.open('https://chub.ai/characters/' + chidSourceData.chub.full_path, '_blank');
break;
case Object.hasOwn(chidSourceData, 'janitorai') : // not implemented yet
window.open('https://janitorai.com/characters/' + chidSourceData.janitorai.full_path, '_blank');
break;
case Object.hasOwn(chidSourceData, 'pygmalion') : // not implemented yet
window.open('https://pygmalion.chat/character/' + chidSourceData.pygmalion.full_path, '_blank');
break;
default: toastr.info("This character doesn't seem to have a source.");
}
break;
/*case 'delete_button':
popup_type = "del_ch";
callPopup(`