Get emote list for rendering. Still figuring out how it should all work together.

This commit is contained in:
grumbulon 2022-04-14 00:23:07 -04:00
parent c222b50cbd
commit 8906b82751
4 changed files with 21 additions and 4 deletions

View file

@ -12,7 +12,6 @@ const hour = 3600000;
// note: rejects on HTTP 4xx or 5xx
async function apGet(url) {
return new Promise(function(resolve,reject){
// fail early

15
lib/emoji.js Normal file
View file

@ -0,0 +1,15 @@
import axios from "axios";
import fs from "fs";
//Grab emote list so when rendering
export default function getEmojiJson(url) {
let emojiUrl = "https://" + url + "/api/v1/custom_emojis";
axios
.get(emojiUrl)
.then(res => {
console.log(`statusCode: ${res.status}`);
const emojiJson = res.data;
console.log(emojiJson);
});
}
getEmojiJson("freecumextremist.com");

View file

@ -79,9 +79,9 @@
-->
<% let regexp = /s*(?<=:).+?(?=:)s*/;
let postWithEmoji = item.content;
let emoteName = postWithEmoji.match(regexp);
<!--If a post with matching regex for :whatever: is found replace with img tag for the instance's emoji packs-->
item.content = postWithEmoji.replace(regexp, "<img src=https://freecumextremist.com/emoji/emojos/hapy.jpg width='30' height='30'/>")
console.log(item.content);
item.content = postWithEmoji.replace(regexp, `<img src=https://freecumextremist.com/emoji/emojos/${emoteName}.jpg width='30' height='30'/>`)
%>
<div class="item-content">
<%- item.content %>

View file

@ -1,8 +1,11 @@
import getEmojiJson from "./emojis.js";
window.genUrl = function genUrl() {
function val(id) {
return document.getElementById(id).value;
}
//download emoji pack
getEmojiJson(val("urlin"));
let user = val("usernamein");
let instance = "https://" + val("urlin");