diff --git a/Makefile b/Makefile index eef0ec5..53bff45 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,8 @@ CC ?= cc GIT ?= git MASTODONT_DIR = mastodont-c/ MASTODONT = $(MASTODONT_DIR)libmastodont.a -CFLAGS += -Wall -I $(MASTODONT_DIR)include/ -Wno-unused-variable -Wno-ignored-qualifiers -I/usr/include/ -I $(MASTODONT_DIR)/libs $(shell pkg-config --cflags libcurl libpcre) -LDFLAGS = -L$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcurl libpcre) -lfcgi +CFLAGS += -Wall -I $(MASTODONT_DIR)include/ -Wno-unused-variable -Wno-ignored-qualifiers -I/usr/include/ -I $(MASTODONT_DIR)/libs $(shell pkg-config --cflags libcurl libpcre2-8) +LDFLAGS = -L$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcurl libpcre2-8) -lfcgi SRC = $(wildcard src/*.c) OBJ = $(patsubst %.c,%.o,$(SRC)) HEADERS = $(wildcard src/*.h) diff --git a/dist/js/main.js b/dist/js/main.js index 811d0f7..319a9df 100644 --- a/dist/js/main.js +++ b/dist/js/main.js @@ -131,11 +131,19 @@ function interact_action(status, type) that.classList.toggle("active"); - // Flip itype value - if (type.value.substr(0, 2) === "un") + + if (is_active) + { + // Animation + that.classList.remove("active-anim"); + + // Flip itype value type.value = type.value.replace("un", ""); - else + } + else { + that.classList.add("active-anim"); type.value = "un" + type.value; + } counter.innerHTML = change_count_text(counter.innerHTML, is_active ? -1 : 1); }); diff --git a/dist/treebird20.css b/dist/treebird20.css index f353aa7..5235a3c 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -1179,17 +1179,6 @@ p} float: right; } -.statusbox-ani -{ - animation: expand-reply .3s 1; -} - -@keyframes expand-reply -{ - 0% { padding-top: 0px; height: 0px; overflow: hidden; } - 100% { padding-top: 10px; height: 150px; overflow: hidden; } -} - .status-interact .statbtn { display: block; @@ -1202,6 +1191,16 @@ p} min-width: 25px !important; } +.active-anim +{ + animation: interact .7s 1; +} + +@keyframes interact +{ + 0% { transform: rotateZ(0deg); } + 100% { transform: rotateZ(360deg); } +} .status-interact svg.repeat.active { diff --git a/src/reply.c b/src/reply.c index 78c85bc..df68654 100644 --- a/src/reply.c +++ b/src/reply.c @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -#include +#define PCRE2_CODE_UNIT_WIDTH 8 + +#include #include #include #include "reply.h" @@ -55,7 +57,6 @@ char* construct_post_box(char* reply_id, * - Misskey/Mastodon adds an @ symbol in the href param, while pleroma adds /users */ #define REGEX_REPLY "@(?:)?.*?(?:<\\/span>)?" -#define REGEX_RESULTS_LEN 9 char* reply_status(char* id, struct mstdnt_status* status) { @@ -63,11 +64,13 @@ char* reply_status(char* id, struct mstdnt_status* status) size_t content_len = strlen(status->content); char* stat_reply; // Regex - pcre* re; - int re_results[REGEX_RESULTS_LEN]; + pcre2_code* re; + PCRE2_SIZE* re_results; + pcre2_match_data* re_data; + // Regex data int rc; - const char* error; - int erroffset; + int error; + PCRE2_SIZE erroffset; int url_off, url_len, name_off, name_len; // Replies size_t replies_size, replies_size_orig; @@ -79,20 +82,24 @@ char* reply_status(char* id, struct mstdnt_status* status) replies[replies_size-1] = ' '; // Compile regex - re = pcre_compile(REGEX_REPLY, 0, &error, &erroffset, NULL); + re = pcre2_compile((PCRE2_SPTR)REGEX_REPLY, PCRE2_ZERO_TERMINATED, 0, &error, &erroffset, NULL); if (re == NULL) { - fprintf(stderr, "Couldn't parse regex at offset %d: %s\n", erroffset, error); + fprintf(stderr, "Couldn't parse regex at offset %ld: %d\n", erroffset, error); free(replies); - pcre_free(re); + pcre2_code_free(re); } + re_data = pcre2_match_data_create_from_pattern(re, NULL); + for (int ind = 0;;) { - rc = pcre_exec(re, NULL, content, content_len, ind, 0, re_results, REGEX_RESULTS_LEN); + rc = pcre2_match(re, (PCRE2_SPTR)content, content_len, ind, 0, re_data, NULL); if (rc < 0) break; + re_results = pcre2_get_ovector_pointer(re_data); + // Store to last result ind = re_results[5]; @@ -115,12 +122,14 @@ char* reply_status(char* id, struct mstdnt_status* status) replies[replies_size_orig+1+name_len] = '@'; memcpy(replies + replies_size_orig + 1 + name_len + 1, content + url_off, url_len); replies[replies_size-1] = ' '; + + pcre2_match_data_free(re_data); } replies[replies_size-1] = '\0'; stat_reply = construct_post_box(id, replies, NULL); if (replies) free(replies); - pcre_free(re); + pcre2_code_free(re); return stat_reply; } diff --git a/src/status.c b/src/status.c index 177c8be..6fef7da 100644 --- a/src/status.c +++ b/src/status.c @@ -18,7 +18,8 @@ #include #include -#include +#define PCRE2_CODE_UNIT_WIDTH 8 +#include #include "http.h" #include "base_page.h" #include "status.h" @@ -386,7 +387,6 @@ char* construct_in_reply_to(struct mstdnt_status* status, } #define REGEX_GREENTEXT "((?:^|
|\\s)>.*?)(?:
|$)" -#define REGEX_GREENTEXT_LEN 6 char* reformat_status(struct session* ssn, char* content, @@ -414,8 +414,8 @@ char* greentextify(char* content) { if (!content) return NULL; - const char* error; - int erroffset; + int error; + PCRE2_SIZE erroffset; int rc; int gt_off; int gt_len; @@ -426,21 +426,26 @@ char* greentextify(char* content) char* gt_string; char* oldres = NULL; - int re_results[REGEX_GREENTEXT_LEN]; - pcre* re = pcre_compile(REGEX_GREENTEXT, 0, &error, &erroffset, NULL); + PCRE2_SIZE* re_results; + pcre2_code* re = pcre2_compile((PCRE2_SPTR)REGEX_GREENTEXT, PCRE2_ZERO_TERMINATED, 0, &error, &erroffset, NULL); + pcre2_match_data* re_data; if (re == NULL) { - fprintf(stderr, "Couldn't parse regex at offset %d: %s\n", erroffset, error); - pcre_free(re); + fprintf(stderr, "Couldn't parse regex at offset %ld: %d\n", erroffset, error); + pcre2_code_free(re); return res; } + re_data = pcre2_match_data_create_from_pattern(re, NULL); + for (int ind = 0;;) { - rc = pcre_exec(re, NULL, res, strlen(res), ind, 0, re_results, REGEX_GREENTEXT_LEN); + rc = pcre2_match(re, (PCRE2_SPTR)res, strlen(res), ind, 0, re_data, NULL); if (rc < 0) break; + re_results = pcre2_get_ovector_pointer(re_data); + // Store to last result gt_off = re_results[2]; gt_len = re_results[3] - gt_off; @@ -458,9 +463,10 @@ char* greentextify(char* content) ind = re_results[2] + strlen(gt_string); free(reg_string); free(gt_string); + pcre2_match_data_free(re_data); } - pcre_free(re); + pcre2_code_free(re); return res; }