Emoji picker categories and generator
FossilOrigin-Name: fa2704e8ed5cb1d0a4cf95330caea0b447832ef0d61256243828212c50a209b6
This commit is contained in:
parent
e232ca36a8
commit
ebbccc83f0
12 changed files with 4838 additions and 184 deletions
|
@ -1,8 +1,10 @@
|
|||
filec
|
||||
emojitoc
|
||||
**/*.cgi
|
||||
**/*.o
|
||||
**/*.chtml
|
||||
mastodont-c
|
||||
config.h
|
||||
treebird
|
||||
test/tests
|
||||
test/tests
|
||||
scripts/*.o
|
4
Makefile
4
Makefile
|
@ -25,6 +25,10 @@ $(TARGET): filec $(PAGES_CMP) $(OBJ) $(HEADERS)
|
|||
filec: src/file-to-c/main.o
|
||||
$(CC) -o filec $<
|
||||
|
||||
emojitoc: scripts/emoji-to.o
|
||||
$(CC) -o emojitoc $< $(LDFLAGS)
|
||||
./emojitoc meta/emoji.json > src/emoji_codes.h
|
||||
|
||||
# PAGES
|
||||
$(PAGES_DIR)/index.chtml: $(PAGES_DIR)/index.html
|
||||
./filec $< data_index_html > $@
|
||||
|
|
38
dist/treebird20.css
vendored
38
dist/treebird20.css
vendored
|
@ -319,6 +319,19 @@ table.present th, table.present td
|
|||
text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
|
||||
.btn-alt.active,
|
||||
.btn-alt:active
|
||||
{
|
||||
background: linear-gradient(#ee0000, #aa0000);
|
||||
border-color: #800000;
|
||||
}
|
||||
|
||||
.btn-alt:hover
|
||||
{
|
||||
background: linear-gradient(#aa0000, #ee0000);
|
||||
}
|
||||
|
||||
.btn-disabled
|
||||
{
|
||||
color: #cacaca !important;
|
||||
|
@ -969,7 +982,7 @@ svg.in-reply-to-icon
|
|||
|
||||
.account-sidebar .acct-pfp,
|
||||
.account-sidebar .username
|
||||
{
|
||||
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
|
@ -1175,6 +1188,17 @@ svg.in-reply-to-icon
|
|||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.emoji-picker .emoji:hover
|
||||
{
|
||||
transform: scale(1.2);
|
||||
}
|
||||
|
||||
.emoji-picker .emoji:active
|
||||
{
|
||||
transition: 0.1s transform;
|
||||
transform: scale(1.0);
|
||||
}
|
||||
|
||||
.emoji-picker-emojos
|
||||
{
|
||||
display: grid;
|
||||
|
@ -1362,17 +1386,23 @@ ul.large-list li a
|
|||
{
|
||||
width: 100%;
|
||||
border: 0;
|
||||
transition: .1s box-shadow, .1s border-color;
|
||||
border-bottom: 2px solid #f7f7f7;
|
||||
}
|
||||
|
||||
.tabs .tab-btn.focused
|
||||
.tabs .tab-btn.active
|
||||
{
|
||||
border-bottom: 3px solid #aa0000;
|
||||
background: linear-gradient(#fff, #f7f7f7);
|
||||
box-shadow: inset 0px 2px 4px rgba(0, 0, 0, 0.15);
|
||||
border-color: #aa0000;
|
||||
}
|
||||
|
||||
.tabs .tab-btn:hover,
|
||||
.tabs .tab-btn:active
|
||||
{
|
||||
border-bottom: 3px solid #600000;
|
||||
background: linear-gradient(#fff, #f7f7f7);
|
||||
box-shadow: inset 0px 1px 4px rgba(0, 0, 0, 0.08);
|
||||
border-color: #aa0000;
|
||||
}
|
||||
|
||||
.navigation tr td:not(:last-child),
|
||||
|
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Treebird - Lightweight frontend for Pleroma
|
||||
* Copyright (C) 2022 Nekobit
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
long filesize(FILE* file)
|
||||
{
|
||||
long orig = ftell(file);
|
||||
fseek(file, 0, SEEK_END);
|
||||
long size = ftell(file);
|
||||
fseek(file, orig, SEEK_SET);
|
||||
return size;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
char* buf;
|
||||
|
||||
|
||||
if (argc <= 1)
|
||||
{
|
||||
fputs("Pass the file to parse!\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE* file = fopen(argv[1], "rb");
|
||||
|
||||
long size = filesize(file);
|
||||
|
||||
|
||||
// Open and read file into buffer
|
||||
if (!(buf = malloc(size)))
|
||||
{
|
||||
perror("malloc");
|
||||
return 1;
|
||||
}
|
||||
if (fread(buf, 1, size, file) != size)
|
||||
{
|
||||
fputs("Didn't read correctly!\n", stderr);
|
||||
free(buf);
|
||||
return 1;
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
// Parse json
|
||||
cJSON* json = cJSON_Parse(buf);
|
||||
// Cleanup regardless of error
|
||||
free(buf);
|
||||
if (!json)
|
||||
{
|
||||
const char* error = cJSON_GetErrorPtr();
|
||||
if (error)
|
||||
fprintf(stderr, "Error parsing: %s\n", error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
printf("#ifndef EMOJOS_H\n"
|
||||
"#define EMOJOS_H\n"
|
||||
"#include \"emoji_info.h\"\n"
|
||||
"#define emojos_size %d\n#define EMOJO_CAT_SMILEY 0\n", cJSON_GetArraySize(json));
|
||||
// Skip smileys & emotion, we already know that
|
||||
|
||||
int i = 0;
|
||||
unsigned cat = 0;
|
||||
for (cJSON* groupitem = json->child; groupitem; (groupitem = groupitem->next, ++i))
|
||||
{
|
||||
cJSON* group = cJSON_GetObjectItemCaseSensitive(groupitem, "group");
|
||||
if (strcmp(group->valuestring, "Animals & Nature") == 0 && cat == 0)
|
||||
{
|
||||
cat = 1;
|
||||
printf("#define EMOJO_CAT_ANIMALS %d\n", i);
|
||||
}
|
||||
else if (strcmp(group->valuestring, "Food & Drink") == 0 && cat == 1) {
|
||||
cat = 2;
|
||||
printf("#define EMOJO_CAT_FOOD %d\n", i);
|
||||
}
|
||||
else if (strcmp(group->valuestring, "Travel & Places") == 0 && cat == 2) {
|
||||
cat = 3;
|
||||
printf("#define EMOJO_CAT_TRAVEL %d\n", i);
|
||||
}
|
||||
else if (strcmp(group->valuestring, "Activities") == 0 && cat == 3) {
|
||||
cat = 4;
|
||||
printf("#define EMOJO_CAT_ACTIVITIES %d\n", i);
|
||||
}
|
||||
else if (strcmp(group->valuestring, "Objects") == 0 && cat == 4) {
|
||||
cat = 5;
|
||||
printf("#define EMOJO_CAT_OBJECTS %d\n", i);
|
||||
}
|
||||
else if (strcmp(group->valuestring, "Symbols") == 0 && cat == 5) {
|
||||
cat = 6;
|
||||
printf("#define EMOJO_CAT_SYMBOLS %d\n", i);
|
||||
}
|
||||
else if (strcmp(group->valuestring, "Flags") == 0 && cat == 6) {
|
||||
printf("#define EMOJO_CAT_FLAGS %d\n", i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("static struct emoji_info emojos[] = {");
|
||||
i = 0;
|
||||
for (cJSON* item = json->child; item; (item = item->next, ++i))
|
||||
{
|
||||
cJSON* chr = cJSON_GetObjectItemCaseSensitive(item, "char");
|
||||
cJSON* name = cJSON_GetObjectItemCaseSensitive(item, "name");
|
||||
cJSON* group = cJSON_GetObjectItemCaseSensitive(item, "group");
|
||||
|
||||
printf("{\"%s\",\"%s\" }, /*%d : %s*/\n",
|
||||
chr->valuestring,
|
||||
name->valuestring,
|
||||
i, group->valuestring);
|
||||
}
|
||||
puts("};\n#endif");
|
||||
|
||||
cJSON_Delete(json);
|
||||
return 0;
|
||||
}
|
||||
|
22
src/emoji.c
22
src/emoji.c
|
@ -68,6 +68,9 @@ char* construct_emoji(struct emoji_info* emoji, char* status_id, int* size)
|
|||
{
|
||||
char* emoji_html;
|
||||
|
||||
if (!emoji)
|
||||
return NULL;
|
||||
|
||||
size_t s = easprintf(&emoji_html, data_emoji_html,
|
||||
status_id, emoji->codes, emoji->codes);
|
||||
|
||||
|
@ -79,7 +82,7 @@ static char* construct_emoji_voidwrap(void* passed, size_t index, int* res)
|
|||
{
|
||||
struct construct_emoji_picker_args* args = passed;
|
||||
size_t calc_index = index + args->index;
|
||||
return calc_index < 0 || calc_index > emojos_size ? NULL :
|
||||
return calc_index < 0 || calc_index >= emojos_size ? NULL :
|
||||
construct_emoji(emojos + calc_index, args->status_id, res);
|
||||
}
|
||||
|
||||
|
@ -95,9 +98,24 @@ char* construct_emoji_picker(char* status_id, unsigned index, size_t* size)
|
|||
emojis = construct_func_strings(construct_emoji_voidwrap, &args, EMOJI_FACTOR_NUM, NULL);
|
||||
|
||||
size_t s = easprintf(&emoji_picker_html, data_emoji_picker_html,
|
||||
ACTIVE_CONDITION(index >= 0 && index < EMOJO_CAT_ANIMALS),
|
||||
EMOJO_CAT_ANIMALS,
|
||||
ACTIVE_CONDITION(index >= EMOJO_CAT_ANIMALS && index < EMOJO_CAT_FOOD),
|
||||
EMOJO_CAT_FOOD,
|
||||
ACTIVE_CONDITION(index >= EMOJO_CAT_FOOD && index < EMOJO_CAT_TRAVEL),
|
||||
EMOJO_CAT_TRAVEL,
|
||||
ACTIVE_CONDITION(index >= EMOJO_CAT_TRAVEL && index < EMOJO_CAT_ACTIVITIES),
|
||||
EMOJO_CAT_ACTIVITIES,
|
||||
ACTIVE_CONDITION(index >= EMOJO_CAT_ACTIVITIES && index < EMOJO_CAT_OBJECTS),
|
||||
EMOJO_CAT_OBJECTS,
|
||||
ACTIVE_CONDITION(index >= EMOJO_CAT_OBJECTS && index < EMOJO_CAT_SYMBOLS),
|
||||
EMOJO_CAT_SYMBOLS,
|
||||
ACTIVE_CONDITION(index >= EMOJO_CAT_SYMBOLS && index < EMOJO_CAT_FLAGS),
|
||||
EMOJO_CAT_FLAGS,
|
||||
ACTIVE_CONDITION(index >= EMOJO_CAT_FLAGS && index < emojos_size),
|
||||
emojis ? emojis : "",
|
||||
status_id,
|
||||
// Index movements
|
||||
status_id,
|
||||
index > 0 ? index - EMOJI_FACTOR_NUM : 0,
|
||||
0 > index - EMOJI_FACTOR_NUM ? "disabled" : "",
|
||||
status_id,
|
||||
|
|
4737
src/emoji_codes.h
4737
src/emoji_codes.h
File diff suppressed because it is too large
Load diff
|
@ -23,7 +23,6 @@ struct emoji_info
|
|||
{
|
||||
const char* codes;
|
||||
const char* name;
|
||||
const char* group;
|
||||
};
|
||||
|
||||
#endif /* EMOJI_INFO_H */
|
||||
|
|
22
src/status.c
22
src/status.c
|
@ -181,10 +181,12 @@ char* construct_interaction_buttons(struct session* ssn,
|
|||
uint8_t flags)
|
||||
{
|
||||
char* interaction_html;
|
||||
char* likeboost_html = NULL;
|
||||
char* reply_count = NULL;
|
||||
char* repeat_count = NULL;
|
||||
char* favourites_count = NULL;
|
||||
char* emoji_picker_html = NULL;
|
||||
char* reactions_btn_html = NULL;
|
||||
size_t s;
|
||||
|
||||
// Emojo picker
|
||||
|
@ -193,12 +195,22 @@ char* construct_interaction_buttons(struct session* ssn,
|
|||
emoji_picker_html = construct_emoji_picker(status->id, keyint(ssn->post.emojoindex), NULL);
|
||||
}
|
||||
|
||||
easprintf(&reactions_btn_html, data_reactions_btn_html,
|
||||
config_url_prefix,
|
||||
status->id,
|
||||
status->id,
|
||||
emoji_picker_html ? emoji_picker_html : "");
|
||||
|
||||
if (status->replies_count)
|
||||
easprintf(&reply_count, NUM_STR, status->replies_count);
|
||||
if (status->reblogs_count)
|
||||
easprintf(&repeat_count, NUM_STR, status->reblogs_count);
|
||||
if (status->favourites_count)
|
||||
easprintf(&favourites_count, NUM_STR, status->favourites_count);
|
||||
|
||||
easprintf(&likeboost_html, data_likeboost_html,
|
||||
config_url_prefix,
|
||||
status->id);
|
||||
|
||||
s = easprintf(&interaction_html, data_interaction_buttons_html,
|
||||
config_url_prefix,
|
||||
|
@ -215,12 +227,8 @@ char* construct_interaction_buttons(struct session* ssn,
|
|||
status->favourited ? "un" : "",
|
||||
status->favourited ? "active" : "",
|
||||
favourites_count ? favourites_count : "",
|
||||
config_url_prefix,
|
||||
status->id,
|
||||
config_url_prefix,
|
||||
status->id,
|
||||
status->id,
|
||||
emoji_picker_html ? emoji_picker_html : "",
|
||||
likeboost_html ? likeboost_html : "",
|
||||
reactions_btn_html ? reactions_btn_html : "",
|
||||
config_url_prefix,
|
||||
status->id,
|
||||
status->id);
|
||||
|
@ -231,6 +239,8 @@ char* construct_interaction_buttons(struct session* ssn,
|
|||
if (reply_count) free(reply_count);
|
||||
if (repeat_count) free(repeat_count);
|
||||
if (favourites_count) free(favourites_count);
|
||||
if (reactions_btn_html) free(reactions_btn_html);
|
||||
if (likeboost_html) free(likeboost_html);
|
||||
return interaction_html;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,10 @@ char* construct_statuses(struct session* ssn,
|
|||
size_t size,
|
||||
struct construct_statuses_args* args,
|
||||
size_t* ret_size);
|
||||
|
||||
char* construct_interaction_buttons(struct session* ssn,
|
||||
struct mstdnt_status* status,
|
||||
size_t* size,
|
||||
uint8_t flags);
|
||||
// Reply to
|
||||
char* get_in_reply_to(mastodont_t* api, struct mstdnt_status* status, size_t* size);
|
||||
char* construct_in_reply_to(struct mstdnt_status* status,
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
|
||||
/** Returns str. If NULL, returns empty string */
|
||||
#define STR_NULL_EMPTY(str) ((str) ? (str) : "")
|
||||
#define MAKE_FOCUSED_IF(tab, test_tab) ((tab) == test_tab ? "focused" : "")
|
||||
|
||||
#define CAT_TEXT(cat, cfg_cat) ((cat) == (cfg_cat)) ? "focused" : ""
|
||||
#define MAKE_FOCUSED_IF(tab, test_tab) ((tab) == (test_tab) ? "active" : "")
|
||||
#define ACTIVE_CONDITION(cond) ((cond) ? "active" : "")
|
||||
#define CAT_TEXT(cat, cfg_cat) (((cat) == (cfg_cat)) ? "active" : "")
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,62 +3,50 @@
|
|||
<tr>
|
||||
<td>
|
||||
<form action="#id" method="post">
|
||||
<input type="hidden" name="category" value="0">
|
||||
<input class="tab-btn btn" type="submit" value="S">
|
||||
<input type="hidden" name="emojoindex" value="0">
|
||||
<input class="tab-btn btn btn-alt %s" type="submit" value="😃">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="#id" method="post">
|
||||
<input type="hidden" name="category" value="0">
|
||||
<input class="tab-btn btn" type="submit" value="S">
|
||||
<input type="hidden" name="emojoindex" value="%d">
|
||||
<input class="tab-btn btn btn-alt %s" type="submit" value="🐻">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="#id" method="post">
|
||||
<input type="hidden" name="category" value="0">
|
||||
<input class="tab-btn btn" type="submit" value="S">
|
||||
<input type="hidden" name="emojoindex" value="%d">
|
||||
<input class="tab-btn btn btn-alt %s" type="submit" value="🍔">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="#id" method="post">
|
||||
<input type="hidden" name="category" value="0">
|
||||
<input class="tab-btn btn" type="submit" value="S">
|
||||
<input type="hidden" name="emojoindex" value="%d">
|
||||
<input class="tab-btn btn btn-alt %s" type="submit" value="🚀">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="#id" method="post">
|
||||
<input type="hidden" name="category" value="0">
|
||||
<input class="tab-btn btn" type="submit" value="S">
|
||||
<input type="hidden" name="emojoindex" value="%d">
|
||||
<input class="tab-btn btn btn-alt %s" type="submit" value="⚽">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="#id" method="post">
|
||||
<input type="hidden" name="category" value="0">
|
||||
<input class="tab-btn btn" type="submit" value="S">
|
||||
<input type="hidden" name="emojoindex" value="%d">
|
||||
<input class="tab-btn btn btn-alt %s" type="submit" value="🔧">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="#id" method="post">
|
||||
<input type="hidden" name="category" value="0">
|
||||
<input class="tab-btn btn" type="submit" value="S">
|
||||
<input type="hidden" name="emojoindex" value="%d">
|
||||
<input class="tab-btn btn btn-alt %s" type="submit" value="🔢">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="#id" method="post">
|
||||
<input type="hidden" name="category" value="0">
|
||||
<input class="tab-btn btn" type="submit" value="S">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="#id" method="post">
|
||||
<input type="hidden" name="category" value="0">
|
||||
<input class="tab-btn btn" type="submit" value="S">
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form action="#id" method="post">
|
||||
<input type="hidden" name="category" value="0">
|
||||
<input class="tab-btn btn" type="submit" value="S">
|
||||
<input type="hidden" name="emojoindex" value="%d">
|
||||
<input class="tab-btn btn btn-alt %s" type="submit" value="🎌">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<a href="%s/status/%s/react/%s" class="emoji-react-box btn %s"><span class="emoji">%s</span> <span class="emoji-num">%u<span></a>
|
||||
<a href="%s/status/%s/react/%s" class="emoji-react-box btn btn-alt %s"><span class="emoji">%s</span> <span class="emoji-num">%u<span></a>
|
||||
|
|
Loading…
Reference in a new issue