mirror of
https://github.com/smolgrrr/TAO.git
synced 2024-09-20 01:11:25 +00:00
emote picker init
This commit is contained in:
parent
3ef19272dc
commit
665b9f33c2
@ -8,6 +8,7 @@ import { UnsignedEvent, Event as NostrEvent, nip19 } from "nostr-tools";
|
||||
import { renderMedia } from "../../utils/FileUpload";
|
||||
import { useSubmitForm } from "./handleSubmit";
|
||||
import "../../styles/Form.css";
|
||||
import EmotePicker from "../modals/EmotePicker/EmotePicker";
|
||||
|
||||
interface FormProps {
|
||||
refEvent?: NostrEvent;
|
||||
@ -133,6 +134,7 @@ const NewNoteCard = ({
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex items-center gap-4">
|
||||
<EmotePicker />
|
||||
<button
|
||||
type="submit"
|
||||
className={`bg-black border h-9 inline-flex items-center justify-center px-4 rounded-lg text-white font-medium text-sm ${doingWorkProp || uploadingFile ? 'cursor-not-allowed' : ''}`}
|
||||
|
28
client/src/components/modals/EmotePicker/EmotePicker.tsx
Normal file
28
client/src/components/modals/EmotePicker/EmotePicker.tsx
Normal file
@ -0,0 +1,28 @@
|
||||
import React, { useState } from 'react';
|
||||
import emotes from './custom_emojis.json';
|
||||
import { PlusCircleIcon } from '@heroicons/react/24/outline';
|
||||
|
||||
const EmotePicker = () => {
|
||||
const [showEmotes, setShowEmotes] = useState(false);
|
||||
|
||||
const toggleEmotes = () => {
|
||||
setShowEmotes(!showEmotes);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<PlusCircleIcon className="h-4 w-4 text-neutral-400 cursor-pointer" onClick={toggleEmotes} />
|
||||
{showEmotes && (
|
||||
<div className="flex flex-wrap mt-2 border">
|
||||
{emotes.slice(0, 20).map((emote, index) => (
|
||||
<div key={index} className="w-1/5 p-1 text-center">
|
||||
<img src={emote.static_url} alt={emote.shortcode} className="w-5 h-5" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default EmotePicker;
|
@ -1,8 +1,3 @@
|
||||
[
|
||||
{
|
||||
"id": "poast",
|
||||
"name": "poast",
|
||||
"emojis":
|
||||
[
|
||||
{
|
||||
"category": "",
|
||||
@ -133775,4 +133770,4 @@
|
||||
"url": "https://poa.st/emoji/stolen/🍆_shake.gif",
|
||||
"visible_in_picker": true
|
||||
}
|
||||
]}]
|
||||
]
|
45
client/src/components/modals/EmotePicker/filter_emojis.sh
Executable file
45
client/src/components/modals/EmotePicker/filter_emojis.sh
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Read the JSON file
|
||||
json=$(cat custom_emojis.json)
|
||||
|
||||
# Create a temporary file to store the filtered JSON
|
||||
tmp_file=$(mktemp)
|
||||
|
||||
# Initialize a counter for successful URLs
|
||||
success_count=0
|
||||
|
||||
echo "Filtering emojis..."
|
||||
|
||||
# Loop through each object in the JSON array
|
||||
echo "$json" | jq -c '.[]' | while read obj; do
|
||||
# Extract the url from the object
|
||||
url=$(echo "$obj" | jq -r '.url')
|
||||
|
||||
# Check the response headers of the URL using curl
|
||||
response=$(curl --silent --head "$url")
|
||||
status_code=$(echo "$response" | grep -o 'HTTP/[0-9.]* [0-9]*' | awk '{print $2}')
|
||||
|
||||
# Check if the response status code is 200 (OK)
|
||||
if [ "$status_code" -eq 200 ]; then
|
||||
# Check if the response headers contain the desired content type
|
||||
if echo "$response" | grep -q "Content-Type: image/"; then
|
||||
echo "$obj" >> "$tmp_file"
|
||||
((success_count++))
|
||||
echo "Successful URL: $url"
|
||||
else
|
||||
echo "Failed URL: $url (Incorrect content type)"
|
||||
fi
|
||||
else
|
||||
echo "Failed URL: $url (Status code: $status_code)"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$success_count emojis with successful URLs"
|
||||
|
||||
# Replace the original JSON file with the filtered version
|
||||
echo "Updating custom_emojis.json..."
|
||||
cat "$tmp_file" | jq -c '. | {shortcode, url}' > custom_emojis.json
|
||||
rm "$tmp_file"
|
||||
|
||||
echo "Done!"
|
Loading…
Reference in New Issue
Block a user