|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
#include "model/status.h"
|
|
|
|
|
|
|
|
|
|
#include "collections/array.h"
|
|
|
|
|
|
|
|
|
|
#include "model/account.h"
|
|
|
|
|
#include "model/emoji.h"
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
@ -52,6 +55,28 @@ char* status_render_source( struct status* s )
|
|
|
|
|
fprintf( f, "%s", handle );
|
|
|
|
|
}
|
|
|
|
|
free(handle);
|
|
|
|
|
} else if( *i == ':' ) {
|
|
|
|
|
// Emoji
|
|
|
|
|
++i;
|
|
|
|
|
char* start = i;
|
|
|
|
|
while( *i && !index(" ,:",*i) ) ++i;
|
|
|
|
|
|
|
|
|
|
char* shortcode = strndup( start, i - start );
|
|
|
|
|
|
|
|
|
|
// Check if shortcode is already present in status
|
|
|
|
|
for( int i = 0; i < s->emoji.count; ++i ) {
|
|
|
|
|
struct emoji* e = s->emoji.items[i];
|
|
|
|
|
if( 0 == strcmp( e->shortcode, shortcode ) ) { goto already_has_emoji; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct emoji* e = emoji_from_shortcode( shortcode );
|
|
|
|
|
if( e ) {
|
|
|
|
|
array_append( &s->emoji, sizeof(e), &e );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
already_has_emoji:
|
|
|
|
|
fprintf( f, ":%s", shortcode );
|
|
|
|
|
free(shortcode);
|
|
|
|
|
} else if( *i == '\n' ) {
|
|
|
|
|
fprintf( f, "<br/>" );
|
|
|
|
|
continue;
|
|
|
|
|