1
0
This commit is contained in:
syui 2024-04-05 17:07:05 +09:00
parent af71ef3527
commit 16e92d9c1b
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56

View File

@ -8,7 +8,7 @@ $(function() {
if (did == null) { did = "did:plc:4hqjfn7m6n5hno3doamuhgef" }; if (did == null) { did = "did:plc:4hqjfn7m6n5hno3doamuhgef" };
if (user) { prompt = "[[b;#87cefa;]" + user + "][[b;#FFFF00;]@aios] ~$ " }; if (user) { prompt = "[[b;#87cefa;]" + user + "][[b;#FFFF00;]@aios] ~$ " };
var tab = "[[b;#87cefa;]<tab>]"; var tab = "[[b;#87cefa;]<tab>]";
var command_all = ["ai","timeline", "bsky_ver", "handle", "did", "plc"]; var command_all = ["ai", "timeline", "bsky_ver", "handle", "did", "plc"];
var handle = "yui.syui.ai"; var handle = "yui.syui.ai";
var ascii_logo = '\n\ \n\ \n⢠⣿⣧\ \n⣰⣿⣿⣿⣧⡀\ \n⣰⣿⣿⣿⣿⣿⣷⡀\ \n⣼⣿⣿⣿⣿⣿⣿⣿⣿⡄\ \n⢀⣀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⣀\ \n⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣀\ \n⣠⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀\ \n⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡀\ \n⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀\ \n⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠋⠉⠈⠉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡄\ \n⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠉⠈⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄\ \n⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀\ \n⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇\ \n⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⢹⣿⣿⣿⣿⣿⣿⣿⣿⣿\ \n⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠈⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇\ \n⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇\ \n⢹⣿⣿⣿⣿⣿⣿⣿⣿⣷⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁\ \n⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⡿\ \n⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀\ \n⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⡀⣠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷\ \n⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⡀⣀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧\ \n⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⣤⣤⣤⣤⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇\ \n⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆\ \n⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆\ \n⠘⠛⠛⠛⠛⠉⠉⠉⠉⠁⠈⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠋⠉⠉⠉⠉⠙⠛⠛⠛⠛\ \n⠈⠙⠛⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠟⠋⠉\ \n⠈⠉⠉⠉⠉\ \n\n'; var ascii_logo = '\n\ \n\ \n⢠⣿⣧\ \n⣰⣿⣿⣿⣧⡀\ \n⣰⣿⣿⣿⣿⣿⣷⡀\ \n⣼⣿⣿⣿⣿⣿⣿⣿⣿⡄\ \n⢀⣀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⣀\ \n⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣀\ \n⣠⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀\ \n⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡀\ \n⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀\ \n⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠋⠉⠈⠉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡄\ \n⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠉⠈⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄\ \n⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀\ \n⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇\ \n⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⢹⣿⣿⣿⣿⣿⣿⣿⣿⣿\ \n⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠈⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇\ \n⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇\ \n⢹⣿⣿⣿⣿⣿⣿⣿⣿⣷⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁\ \n⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⡿\ \n⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀\ \n⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⡀⣠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷\ \n⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⡀⣀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧\ \n⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⣤⣤⣤⣤⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇\ \n⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆\ \n⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆\ \n⠘⠛⠛⠛⠛⠉⠉⠉⠉⠁⠈⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠋⠉⠉⠉⠉⠙⠛⠛⠛⠛\ \n⠈⠙⠛⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠟⠋⠉\ \n⠈⠉⠉⠉⠉\ \n\n';
@ -60,32 +60,36 @@ $(function() {
"; ";
let list = 'https://bsky.social/xrpc/com.atproto.repo.listRecords?repo='; let list = 'https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=';
axios.get(list + handle + '&collection=app.bsky.feed.post&limit=1') axios.get(list + did + '&collection=app.bsky.feed.post&limit=1')
.then(function (response) { .then(function (response) {
timeline = JSON.stringify(response.data.records[0].value,null,"\t"); timeline = JSON.stringify(response.data.records[0].value,null,"\t");
}) })
axios.get('https://bsky.social/xrpc/_health') axios.get('https://bsky.social/xrpc/_health')
.then(function (response) { .then(function (response) {
bsky_ver = JSON.stringify(response.data,null,"\t"); bsky_ver = JSON.stringify(response.data,null,"\t");
}) })
let plc_server = "https://plc.directory/" let plc_server = "https://plc.directory/"
axios.get(plc_server + did + '/log') axios.get(plc_server + did + '/log')
.then(function (response) { .then(function (response) {
plc = JSON.stringify(response.data,null,"\t"); plc = JSON.stringify(response.data,null,"\t");
}) })
let desc = 'https://bsky.social/xrpc/com.atproto.repo.describeRepo?repo='; let desc = 'https://bsky.social/xrpc/com.atproto.repo.describeRepo?repo=';
axios.get(desc + did + '&collection=app.bsky.actor.profile') axios.get(desc + did + '&collection=app.bsky.actor.profile')
.then(function (response) {
bsky_did = JSON.stringify(response.data,null,"\t");
})
axios.get('/json/ai.json')
.then(function (response) { .then(function (response) {
user_profile = JSON.stringify(response.data,null,"\t"); bsky_did = JSON.stringify(response.data,null,"\t");
}) })
function test_json() {
var u;
u = axios.get('/json/ai.json')
.then(function (response) {
return JSON.stringify(response.data,null,"\t");
})
return u;
}
function print_slowly(term, paragraph, callback) { function print_slowly(term, paragraph, callback) {
var foo, i, lines; var foo, i, lines;
@ -123,96 +127,95 @@ $(function() {
command = inputs[0]; command = inputs[0];
if (inputs[0] === 'ai') { if (inputs[0] === 'ai') {
print_slowly(term, ascii_logo); print_slowly(term, ascii_logo);
term.echo(user_profile); term.echo(test_json());
} else if (inputs[0] === 'plc' && inputs[1] != undefined) { } else if (inputs[0] === 'plc' && inputs[1] != undefined) {
url = desc + inputs[1] + '&collection=app.bsky.actor.profile'; url = desc + inputs[1] + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false}); $.ajaxSetup({async: false});
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
did = JSON.stringify(data.did,null,"\t").replaceAll('"', '') did = JSON.stringify(data.did,null,"\t").replaceAll('"', '')
url = plc_server + did + '/log'; url = plc_server + did + '/log';
$.ajaxSetup({async: false}); $.ajaxSetup({async: false});
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
term.echo(JSON.stringify(data,null,"\t")); term.echo(JSON.stringify(data,null,"\t"));
});$.ajaxSetup({async: true});
});$.ajaxSetup({async: true}); });$.ajaxSetup({async: true});
});$.ajaxSetup({async: true});
} else if (inputs[0] === 'plc') { } else if (inputs[0] === 'plc') {
term.echo(plc); term.echo(plc);
term.echo("$ plc <handle>"); term.echo("$ plc <handle>");
} else if (inputs[0] === 'timeline' && inputs[1] != undefined) { } else if (inputs[0] === 'timeline' && inputs[1] != undefined) {
url = list + inputs[1] + '&collection=app.bsky.feed.post&limit=1'; url = list + inputs[1] + '&collection=app.bsky.feed.post&limit=1';
$.ajaxSetup({async: false}); $.ajaxSetup({async: false});
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
term.echo(JSON.stringify(data,null,"\t")); term.echo(JSON.stringify(data,null,"\t"));
});$.ajaxSetup({async: true}); });$.ajaxSetup({async: true});
} else if (inputs[0] === 'timeline') { } else if (inputs[0] === 'timeline') {
term.echo(timeline); term.echo(timeline);
term.echo("$ timeline <handle>"); term.echo("$ timeline <handle>");
} else if (inputs[0] === 'did' && inputs[1] != undefined) { } else if (inputs[0] === 'did' && inputs[1] != undefined) {
url = desc + inputs[1] + '&collection=app.bsky.actor.profile'; url = desc + inputs[1] + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false}); $.ajaxSetup({async: false});
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
term.echo(JSON.stringify(data.did,null,"\t")); term.echo(JSON.stringify(data.did,null,"\t"));
});$.ajaxSetup({async: true}); });$.ajaxSetup({async: true});
} else if (inputs[0] === 'did') { } else if (inputs[0] === 'did') {
url = desc + did + '&collection=app.bsky.actor.profile'; url = desc + did + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false}); $.ajaxSetup({async: false});
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
term.echo(JSON.stringify(data.did,null,"\t")); term.echo(JSON.stringify(data.did,null,"\t"));
});$.ajaxSetup({async: true}); });$.ajaxSetup({async: true});
term.echo("$ did <handle>"); term.echo("$ did <handle>");
} else if (inputs[0] === 'handle' && inputs[1] != undefined) { } else if (inputs[0] === 'handle' && inputs[1] != undefined) {
url = desc + inputs[1] + '&collection=app.bsky.actor.profile'; url = desc + inputs[1] + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false}); $.ajaxSetup({async: false});
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
term.echo(JSON.stringify(data,null,"\t")); term.echo(JSON.stringify(data,null,"\t"));
});$.ajaxSetup({async: true}); });$.ajaxSetup({async: true});
} else if (inputs[0] === 'handle') { } else if (inputs[0] === 'handle') {
term.echo(bsky_did); term.echo(bsky_did);
term.echo("$ handle <handle>"); term.echo("$ handle <handle>");
} else if (inputs[0] === 'bsky_ver') { } else if (inputs[0] === 'bsky_ver') {
term.echo(bsky_ver); term.echo(bsky_ver);
} else { } else {
term.error(command + " is not a valid command"); term.error(command + " is not a valid command");
term.echo(command_all); term.echo(command_all);
} }
} }
function bash(inputs, term) { function bash(inputs, term) {
var argument, echo, insert; var argument, echo, insert;
echo = term.echo; echo = term.echo;
insert = term.insert; insert = term.insert;
if (!inputs[1]) { if (!inputs[1]) {
//return console.log("none"); //return console.log("none");
} else {
argument = inputs[1];
if (/^\.\./.test(argument)) {
return echo("-bash: cd: " + argument + ": Permission denied");
} else { } else {
return echo("-bash: cd: " + argument + ": No such file or directory"); argument = inputs[1];
if (/^\.\./.test(argument)) {
return echo("-bash: cd: " + argument + ": Permission denied");
} else {
return echo("-bash: cd: " + argument + ": No such file or directory");
}
} }
} }
}
$('#terminal').terminal(interpreter, { $('#terminal').terminal(interpreter, {
prompt: prompt, prompt: prompt,
name: 'test', name: 'test',
greetings: "", greetings: "",
exit: false, exit: false,
height: 450, height: 450,
onInit: function(term) { onInit: function(term) {
//term.insert("ai"); //term.insert("ai");
//print_slowly(term, ascii_ai); //print_slowly(term, ascii_ai);
}, },
completion: function(term, string, callback) { completion: function(term, string, callback) {
var t = $(term[0]).text(); var t = $(term[0]).text();
if (t.match(/none/)) { if (t.match(/none/)) {
term.clear(); term.clear();
} else { } else {
callback(command_all); callback(command_all);
term.history().clear(); term.history().clear();
} }
}, },
tabcompletion: true tabcompletion: true
}); });
}); });