Compare commits

...
This repository has been archived on 2023-05-27. You can view files and clone it, but cannot push or open issues or pull requests.

5 commits

Author SHA1 Message Date
grumbulon 8906b82751 Get emote list for rendering. Still figuring out how it should all work together. 2022-04-14 00:23:07 -04:00
grumbulon c222b50cbd Commented this wacky shit 2022-04-13 23:41:40 -04:00
grumbulon 1b6346f1b3 Removed commented stuff from earlier testing 2022-04-13 23:38:25 -04:00
grumbulon e31eebc844 yeah 2022-04-13 23:33:46 -04:00
grumbulon 8063fd6680 started very poorly implementing emojis in posts 2022-04-13 23:23:18 -04:00
7 changed files with 9836 additions and 2023 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
@ -113,7 +112,6 @@ function metaForUser(user) {
async function itemsForFeed(opts,user,feed) {
let items = feed.orderedItems;
if (opts.boosts){
// yes, I have to fetch all the fucking boosts for this whole feed apparently >:/
let boostData = [];
@ -178,6 +176,7 @@ async function itemsForFeed(opts,user,feed) {
let op = item._userdata?item._userdata:user;
return {
isBoost:!!item._userdata,
title:item._userdata?user.preferredUsername+" shared a status by "+op.preferredUsername:"",

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

@ -72,7 +72,17 @@
<input type="checkbox" class="showmore" id="<%- cwId %>">
<label class="button" for="<%- cwId %>">Show</label>
<% } %>
<!--
Ok so this is so fucked but basically, this matches a status with the regex expression (to capture text between two colons) and
needs to take the matched text and search the instances emoji pack for the value and replace it in item content.
I tested this and it _does not_ alter posts without emojis.
-->
<% 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/${emoteName}.jpg width='30' height='30'/>`)
%>
<div class="item-content">
<%- item.content %>
</div>

7617
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -67,7 +67,7 @@
<h3>Live Preview:</h3>
<span class="iframe-contain">
<iframe id="frame" allowfullscreen sandbox="allow-top-navigation allow-scripts" width="400" height="800"
src="/api/v1/feed?userurl=https%3A%2F%2Fmastodon.social%2Fusers%2Fgargron&replies=false&boosts=true">></iframe>
src="/api/v1/feed?userurl=https%3A%2F%2Ffreecumextremist.com%2Fusers%2Fgrumbulon&replies=false&boosts=true">></iframe>
</span>
<br>
</div>

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");

4205
yarn.lock

File diff suppressed because it is too large Load diff