mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add git disclaimer to asset downloader
This commit is contained in:
@ -733,8 +733,9 @@ export async function installExtension(url) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!request.ok) {
|
if (!request.ok) {
|
||||||
toastr.info(request.statusText, 'Extension installation failed');
|
const text = await request.text();
|
||||||
console.error('Extension installation failed', request.status, request.statusText);
|
toastr.warning(text || request.statusText, 'Extension installation failed', { timeOut: 5000 });
|
||||||
|
console.error('Extension installation failed', request.status, request.statusText, text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,14 @@ function downloadAssetsList(url) {
|
|||||||
for (const assetType of assetTypes) {
|
for (const assetType of assetTypes) {
|
||||||
let assetTypeMenu = $('<div />', { id: "assets_audio_ambient_div", class: "assets-list-div" });
|
let assetTypeMenu = $('<div />', { id: "assets_audio_ambient_div", class: "assets-list-div" });
|
||||||
assetTypeMenu.append(`<h3>${assetType}</h3>`)
|
assetTypeMenu.append(`<h3>${assetType}</h3>`)
|
||||||
|
|
||||||
|
if (assetType == 'extension') {
|
||||||
|
assetTypeMenu.append(`
|
||||||
|
<div class="assets-list-git">
|
||||||
|
To download extensions from this page, you need to have <a href="https://git-scm.com/downloads" target="_blank">Git</a> installed.
|
||||||
|
</div>`);
|
||||||
|
}
|
||||||
|
|
||||||
for (const i in availableAssets[assetType]) {
|
for (const i in availableAssets[assetType]) {
|
||||||
const asset = availableAssets[assetType][i];
|
const asset = availableAssets[assetType][i];
|
||||||
const elemId = `assets_install_${assetType}_${i}`;
|
const elemId = `assets_install_${assetType}_${i}`;
|
||||||
|
@ -13,11 +13,17 @@
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.assets-list-git {
|
||||||
|
font-size: calc(var(--mainFontSize) * 0.8);
|
||||||
|
opacity: 0.8;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
.assets-list-div h3 {
|
.assets-list-div h3 {
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
.assets-list-div a {
|
.assets-list-div i a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ const path = require('path');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { default: simpleGit } = require('simple-git');
|
const { default: simpleGit } = require('simple-git');
|
||||||
const sanitize = require('sanitize-filename');
|
const sanitize = require('sanitize-filename');
|
||||||
|
const commandExistsSync = require('command-exists').sync;
|
||||||
const { DIRECTORIES } = require('./constants');
|
const { DIRECTORIES } = require('./constants');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,12 +62,19 @@ function registerEndpoints(app, jsonParser) {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
app.post('/api/extensions/install', jsonParser, async (request, response) => {
|
app.post('/api/extensions/install', jsonParser, async (request, response) => {
|
||||||
const git = simpleGit();
|
const gitExists = commandExistsSync('git');
|
||||||
|
|
||||||
|
if (!gitExists) {
|
||||||
|
return response.status(400).send('Server Error: git is not installed on the system.');
|
||||||
|
}
|
||||||
|
|
||||||
if (!request.body.url) {
|
if (!request.body.url) {
|
||||||
return response.status(400).send('Bad Request: URL is required in the request body.');
|
return response.status(400).send('Bad Request: URL is required in the request body.');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const git = simpleGit();
|
||||||
|
|
||||||
// make sure the third-party directory exists
|
// make sure the third-party directory exists
|
||||||
if (!fs.existsSync(path.join(DIRECTORIES.extensions, 'third-party'))) {
|
if (!fs.existsSync(path.join(DIRECTORIES.extensions, 'third-party'))) {
|
||||||
fs.mkdirSync(path.join(DIRECTORIES.extensions, 'third-party'));
|
fs.mkdirSync(path.join(DIRECTORIES.extensions, 'third-party'));
|
||||||
@ -87,7 +95,6 @@ function registerEndpoints(app, jsonParser) {
|
|||||||
|
|
||||||
|
|
||||||
return response.send({ version, author, display_name, extensionPath });
|
return response.send({ version, author, display_name, extensionPath });
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('Importing custom content failed', error);
|
console.log('Importing custom content failed', error);
|
||||||
return response.status(500).send(`Server Error: ${error.message}`);
|
return response.status(500).send(`Server Error: ${error.message}`);
|
||||||
|
Reference in New Issue
Block a user