mirror of https://codeberg.org/grunfink/snac2.git
Compare commits
4 Commits
ad4199de75
...
86f1d74214
Author | SHA1 | Date |
---|---|---|
default | 86f1d74214 | |
default | 0275658a36 | |
default | 81cf1e21a6 | |
default | c9df6707ab |
|
@ -4,6 +4,8 @@
|
|||
|
||||
Posts that were liked or boosted can now be unliked and unboosted.
|
||||
|
||||
Added a header to avoid over-zealous caching in some browsers (contributed by louis77).
|
||||
|
||||
## 2.51
|
||||
|
||||
Support for custom Emojis has been added; they are no longer hardcoded, but read from the `emojis.json` file at the server base directory. Also, they are no longer limited to string substitutions, but images as external URLs are also supported (see `snac(8)` for more information).
|
||||
|
|
10
mastoapi.c
10
mastoapi.c
|
@ -289,7 +289,11 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
|
|||
*body = xs_dup(code);
|
||||
}
|
||||
else {
|
||||
*body = xs_fmt("%s?code=%s", redir, code);
|
||||
if (xs_str_in(redir, "?"))
|
||||
*body = xs_fmt("%s&code=%s", redir, code);
|
||||
else
|
||||
*body = xs_fmt("%s?code=%s", redir, code);
|
||||
|
||||
status = 303;
|
||||
}
|
||||
|
||||
|
@ -2119,8 +2123,6 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
|
|||
if (!xs_startswith(q_path, "/api/v1/") && !xs_startswith(q_path, "/api/v2/"))
|
||||
return 0;
|
||||
|
||||
srv_debug(1, xs_fmt("mastoapi_post_handler %s", q_path));
|
||||
|
||||
int status = 404;
|
||||
xs *args = NULL;
|
||||
char *i_ctype = xs_dict_get(req, "content-type");
|
||||
|
@ -2626,6 +2628,8 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
|
|||
if (logged_in)
|
||||
user_free(&snac);
|
||||
|
||||
srv_debug(1, xs_fmt("mastoapi_post_handler %s %d", q_path, status));
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
4
xs.h
4
xs.h
|
@ -45,6 +45,10 @@ typedef char xs_data;
|
|||
/* not really all, just very much */
|
||||
#define XS_ALL 0xfffffff
|
||||
|
||||
#ifndef xs_countof
|
||||
#define xs_countof(a) (sizeof((a)) / sizeof((*a)))
|
||||
#endif
|
||||
|
||||
void *xs_free(void *ptr);
|
||||
void *_xs_realloc(void *ptr, size_t size, const char *file, int line, const char *func);
|
||||
#define xs_realloc(ptr, size) _xs_realloc(ptr, size, __FILE__, __LINE__, __FUNCTION__)
|
||||
|
|
10
xs_json.h
10
xs_json.h
|
@ -328,7 +328,7 @@ static xs_val *_xs_json_load_lexer(FILE *f, js_type *t)
|
|||
|
||||
int xs_json_load_array_iter(FILE *f, xs_val **value, xstype *pt, int *c)
|
||||
/* loads the next scalar value from the JSON stream */
|
||||
/* if the value ahead is complex, value is NULL and pt is filled */
|
||||
/* if the value ahead is compound, value is NULL and pt is set */
|
||||
{
|
||||
js_type t;
|
||||
|
||||
|
@ -348,7 +348,7 @@ int xs_json_load_array_iter(FILE *f, xs_val **value, xstype *pt, int *c)
|
|||
}
|
||||
|
||||
if (*value == NULL) {
|
||||
/* possible complex type ahead */
|
||||
/* possible compound type ahead */
|
||||
if (t == JS_OBRACK)
|
||||
*pt = XSTYPE_LIST;
|
||||
else
|
||||
|
@ -365,7 +365,7 @@ int xs_json_load_array_iter(FILE *f, xs_val **value, xstype *pt, int *c)
|
|||
|
||||
|
||||
xs_list *xs_json_load_array(FILE *f)
|
||||
/* loads a JSON array (after the initial OBRACK) */
|
||||
/* loads a full JSON array (after the initial OBRACK) */
|
||||
{
|
||||
xstype t;
|
||||
xs_list *l = xs_list_new();
|
||||
|
@ -406,7 +406,7 @@ xs_list *xs_json_load_array(FILE *f)
|
|||
|
||||
int xs_json_load_object_iter(FILE *f, xs_str **key, xs_val **value, xstype *pt, int *c)
|
||||
/* loads the next key and scalar value from the JSON stream */
|
||||
/* if the value ahead is complex, value is NULL and pt is filled */
|
||||
/* if the value ahead is compound, value is NULL and pt is set */
|
||||
{
|
||||
js_type t;
|
||||
|
||||
|
@ -453,7 +453,7 @@ int xs_json_load_object_iter(FILE *f, xs_str **key, xs_val **value, xstype *pt,
|
|||
|
||||
|
||||
xs_dict *xs_json_load_object(FILE *f)
|
||||
/* loads a JSON object (after the initial OCURLY) */
|
||||
/* loads a full JSON object (after the initial OCURLY) */
|
||||
{
|
||||
xstype t;
|
||||
xs_dict *d = xs_dict_new();
|
||||
|
|
22
xs_mime.h
22
xs_mime.h
|
@ -55,19 +55,23 @@ const char *xs_mime_by_ext(const char *file)
|
|||
const char *ext = strrchr(file, '.');
|
||||
|
||||
if (ext) {
|
||||
const char **p = xs_mime_types;
|
||||
xs *uext = xs_tolower_i(xs_dup(ext + 1));
|
||||
xs *uext = xs_tolower_i(xs_dup(ext + 1));
|
||||
int b = 0;
|
||||
int t = xs_countof(xs_mime_types) / 2 - 2;
|
||||
|
||||
while (*p) {
|
||||
int c;
|
||||
while (t >= b) {
|
||||
int n = (b + t) / 2;
|
||||
const char *p = xs_mime_types[n * 2];
|
||||
|
||||
if ((c = strcmp(*p, uext)) == 0)
|
||||
return p[1];
|
||||
int c = strcmp(uext, p);
|
||||
|
||||
if (c < 0)
|
||||
t = n - 1;
|
||||
else
|
||||
if (c > 0)
|
||||
break;
|
||||
|
||||
p += 2;
|
||||
b = n + 1;
|
||||
else
|
||||
return xs_mime_types[(n * 2) + 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
16
xs_unicode.h
16
xs_unicode.h
|
@ -27,8 +27,8 @@
|
|||
|
||||
#ifdef XS_IMPLEMENTATION
|
||||
|
||||
#ifndef countof
|
||||
#define countof(a) (sizeof((a)) / sizeof((*a)))
|
||||
#ifndef xs_countof
|
||||
#define xs_countof(a) (sizeof((a)) / sizeof((*a)))
|
||||
#endif
|
||||
|
||||
int _xs_utf8_enc(char buf[4], unsigned int cpoint)
|
||||
|
@ -125,7 +125,7 @@ int xs_unicode_width(unsigned int cpoint)
|
|||
/* returns the width in columns of a Unicode codepoint (somewhat simplified) */
|
||||
{
|
||||
int b = 0;
|
||||
int t = countof(xs_unicode_width_table) / 3 - 1;
|
||||
int t = xs_countof(xs_unicode_width_table) / 3 - 1;
|
||||
|
||||
while (t >= b) {
|
||||
int n = (b + t) / 2;
|
||||
|
@ -193,7 +193,7 @@ unsigned int *_xs_unicode_upper_search(unsigned int cpoint)
|
|||
/* searches for an uppercase codepoint in the case fold table */
|
||||
{
|
||||
int b = 0;
|
||||
int t = countof(xs_unicode_case_fold_table) / 2 + 1;
|
||||
int t = xs_countof(xs_unicode_case_fold_table) / 2 + 1;
|
||||
|
||||
while (t >= b) {
|
||||
int n = (b + t) / 2;
|
||||
|
@ -216,7 +216,7 @@ unsigned int *_xs_unicode_lower_search(unsigned int cpoint)
|
|||
/* searches for a lowercase codepoint in the case fold table */
|
||||
{
|
||||
unsigned int *p = xs_unicode_case_fold_table;
|
||||
unsigned int *e = p + countof(xs_unicode_case_fold_table);
|
||||
unsigned int *e = p + xs_countof(xs_unicode_case_fold_table);
|
||||
|
||||
while (p < e) {
|
||||
if (cpoint == p[1])
|
||||
|
@ -251,7 +251,7 @@ int xs_unicode_nfd(unsigned int cpoint, unsigned int *base, unsigned int *diac)
|
|||
/* applies unicode Normalization Form D */
|
||||
{
|
||||
int b = 0;
|
||||
int t = countof(xs_unicode_nfd_table) / 3 - 1;
|
||||
int t = xs_countof(xs_unicode_nfd_table) / 3 - 1;
|
||||
|
||||
while (t >= b) {
|
||||
int n = (b + t) / 2;
|
||||
|
@ -279,7 +279,7 @@ int xs_unicode_nfc(unsigned int base, unsigned int diac, unsigned int *cpoint)
|
|||
/* applies unicode Normalization Form C */
|
||||
{
|
||||
unsigned int *p = xs_unicode_nfd_table;
|
||||
unsigned int *e = p + countof(xs_unicode_nfd_table);
|
||||
unsigned int *e = p + xs_countof(xs_unicode_nfd_table);
|
||||
|
||||
while (p < e) {
|
||||
if (p[1] == base && p[2] == diac) {
|
||||
|
@ -298,7 +298,7 @@ int xs_unicode_is_alpha(unsigned int cpoint)
|
|||
/* checks if a codepoint is an alpha (i.e. a letter) */
|
||||
{
|
||||
int b = 0;
|
||||
int t = countof(xs_unicode_alpha_table) / 2 - 1;
|
||||
int t = xs_countof(xs_unicode_alpha_table) / 2 - 1;
|
||||
|
||||
while (t >= b) {
|
||||
int n = (b + t) / 2;
|
||||
|
|
2
xs_url.h
2
xs_url.h
|
@ -56,7 +56,7 @@ xs_dict *xs_url_vars(const char *str)
|
|||
|
||||
l = args;
|
||||
while (xs_list_iter(&l, &v)) {
|
||||
xs *kv = xs_split_n(v, "=", 2);
|
||||
xs *kv = xs_split_n(v, "=", 1);
|
||||
|
||||
if (xs_list_len(kv) == 2) {
|
||||
const char *key = xs_list_get(kv, 0);
|
||||
|
|
|
@ -1 +1 @@
|
|||
/* 0df383371d207b0adfda40912ee54b37e5b01152 2024-03-15T03:45:39+01:00 */
|
||||
/* f712d1336ef427c3b56305364b2687578537543f 2024-04-14T19:11:53+02:00 */
|
||||
|
|
Loading…
Reference in New Issue