From 1b347848e8ff02a1cb5d35a454ea01be067c42a5 Mon Sep 17 00:00:00 2001 From: nekobit Date: Mon, 22 Aug 2022 01:08:35 +0000 Subject: [PATCH] Quit FossilOrigin-Name: c62ed43b115d05ed5ceca3b258da63cbdd4081b3f034ff741f7b33e2d1f2daaa --- perl/emojis.pm | 5 +- src/emoji.c | 27 +++---- src/emoji_reaction.c | 4 - templates/emoji_picker.tt | 154 +++++++++++++++++++------------------- 4 files changed, 95 insertions(+), 95 deletions(-) diff --git a/perl/emojis.pm b/perl/emojis.pm index 73ca9c7..27acb38 100644 --- a/perl/emojis.pm +++ b/perl/emojis.pm @@ -24,8 +24,11 @@ sub generate_emoji sub emoji_picker { - my ($ssn, $data, $emojis) = @_; + my ($data, $emojis) = @_; + my %vars = ( + e => $emojis + ); to_template(\%vars, \$data->{'emoji_picker.tt'}); } diff --git a/src/emoji.c b/src/emoji.c index 76132c6..b92dcb2 100644 --- a/src/emoji.c +++ b/src/emoji.c @@ -103,22 +103,23 @@ char* construct_emoji_picker(char* status_id, size_t* size) emojis[EMO_CAT_OBJECTS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_OBJECTS, EMOJO_CAT_SYMBOLS - EMOJO_CAT_OBJECTS, len + 5); emojis[EMO_CAT_SYMBOLS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_SYMBOLS, EMOJO_CAT_FLAGS - EMOJO_CAT_SYMBOLS, len + 6); emojis[EMO_CAT_FLAGS] = construct_func_strings(construct_emoji_voidwrap, args + EMO_CAT_FLAGS, EMOJO_CAT_MAX - EMOJO_CAT_FLAGS, len + 6); - - struct emoji_picker_template data = { - .emojis_smileys = emojis[EMO_CAT_SMILEYS], - .emojis_animals = emojis[EMO_CAT_ANIMALS], - .emojis_food = emojis[EMO_CAT_FOOD], - .emojis_travel = emojis[EMO_CAT_TRAVEL], - .emojis_activities = emojis[EMO_CAT_ACTIVITIES], - .emojis_objects = emojis[EMO_CAT_OBJECTS], - .emojis_symbols = emojis[EMO_CAT_SYMBOLS], - .emojis_flags = emojis[EMO_CAT_FLAGS], - }; - emoji_picker_html = tmpl_gen_emoji_picker(&data, size); + PERL_STACK_INIT; + XPUSHs(newRV_noinc((SV*)template_files)); + AV* av = newAV(); + for (int i = 0; i < EMO_CAT_LEN; ++i) + { + av_store(av, i, newSVpv(emojis + i, len + i)); + } + XPUSHs(newRV_inc((SV*)av)); + PERL_STACK_SCALAR_CALL("emojis::emoji_picker"); + + char* dup = PERL_GET_STACK_EXIT; + + // Cleanup for (size_t i = 0; i < EMO_CAT_LEN; ++i) free(emojis[i]); - return emoji_picker_html; + return dup; } HV* perlify_emoji(struct mstdnt_emoji* const emoji) diff --git a/src/emoji_reaction.c b/src/emoji_reaction.c index 7e6bf65..62502ac 100644 --- a/src/emoji_reaction.c +++ b/src/emoji_reaction.c @@ -22,10 +22,6 @@ #include #include "easprintf.h" -// Templates -#include "../static/custom_emoji_reaction.ctmpl" -#include "../static/emoji_reaction.ctmpl" -#include "../static/emoji_reactions.ctmpl" struct construct_emoji_reactions_args { diff --git a/templates/emoji_picker.tt b/templates/emoji_picker.tt index 70cd38a..f386c10 100644 --- a/templates/emoji_picker.tt +++ b/templates/emoji_picker.tt @@ -1,81 +1,81 @@
- - - - - - - - - - - -
- - - - - - - - - - - - - - - -
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
-
- -
- {{%s:emojis_smileys}} +
+ +
+ [% e.0 %] +
+ +
+ [% e.1 %] +
+ +
+ [% e.2 %] +
+ +
+ [% e.3 %] +
+ +
+ [% e.4 %] +
+ +
+ [% e.5 %] +
+ +
+ [% e.6 %] +
+ +
+ [% e.7 %] +
- -
- {{%s:emojis_animals}} -
- -
- {{%s:emojis_food}} -
- -
- {{%s:emojis_travel}} -
- -
- {{%s:emojis_activities}} -
- -
- {{%s:emojis_objects}} -
- -
- {{%s:emojis_symbols}} -
- -
- {{%s:emojis_flags}} -
-