reformat function

FossilOrigin-Name: e0392f4bb8addee5cf5d40b5240bb35a23aab54ee73a3b85cfc37c33d8072f3f
This commit is contained in:
me@ow.nekobit.net 2022-04-04 14:34:25 +00:00
parent c59deb55ba
commit e04191ff9f
3 changed files with 16 additions and 2 deletions

View file

@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include <pcre.h>
#include "http.h"
#include "base_page.h"
#include "status.h"
@ -142,6 +143,16 @@ char* construct_in_reply_to(mastodont_t* api, struct mstdnt_status* status, size
return irt_html;
}
#define REGEX_GREENTEXT "((?:^|\\s)>.*)$"
char* reformat_status(char* content)
{
const char* error;
int erroffset;
pcre* re = pcre_compile(REGEX_GREENTEXT, 0, &error, &erroffset, NULL);
return "";
}
char* construct_status(mastodont_t* api,
struct mstdnt_status* status,
int* size,
@ -158,6 +169,7 @@ char* construct_status(mastodont_t* api,
char* emoji_reactions = NULL;
char* notif_info = NULL;
char* in_reply_to_str = NULL;
char* parse_content = status->content;
if (status->replies_count)
easprintf(&reply_count, NUM_STR, status->replies_count);
if (status->reblogs_count)
@ -202,7 +214,7 @@ char* construct_status(mastodont_t* api,
status->bookmarked ? "un" : "",
status->bookmarked ? "Remove Bookmark" : "Bookmark",
in_reply_to_str ? in_reply_to_str : "",
status->content,
parse_content,
attachments ? attachments : "",
emoji_reactions ? emoji_reactions : "",
config_url_prefix,
@ -231,6 +243,7 @@ char* construct_status(mastodont_t* api,
if (attachments) free(attachments);
if (emoji_reactions) free(emoji_reactions);
if (notif) free(notif_info);
if (parse_content) free(parse_content);
return stat_html;
}

View file

@ -36,6 +36,7 @@ void content_status_create(struct session* ssn, mastodont_t* api, char** data);
char* construct_post_box(char* reply_id,
char* default_content,
int* size);
char* reformat_status(char* content);
char* construct_status(mastodont_t* api, struct mstdnt_status* status, int* size, struct mstdnt_notification* notif, uint8_t flags);
char* construct_statuses(mastodont_t* api, struct mstdnt_status* statuses, size_t size, size_t* ret_size);

View file

@ -1,3 +1,3 @@
<span class="in-reply-to">
<a class="in-reply-to-id" href="%s/status/%s"><span class="in-reply-to-text">%s</span> <span class="acct">%s</span></a>
<svg class="in-reply-to-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9l6 6-6 6"/><path d="M4 4v7a4 4 0 0 0 4 4h11"/></svg> <a class="in-reply-to-id" href="%s/status/%s"><span class="in-reply-to-text">%s</span> <span class="acct">%s</span></a>
</span>