Mercurial > blahgd > fmt4
changeset 1169:4f4615ebed2b
category: return a 404 for all category requests
This is a temporary change.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Fri, 01 Feb 2019 15:55:40 -0500 |
parents | db996b483b4a |
children | b8ae9126c176 |
files | daemon.c req.h tag.c |
diffstat | 3 files changed, 3 insertions(+), 111 deletions(-) [+] |
line wrap: on
line diff
--- a/daemon.c Fri Apr 13 22:26:46 2018 -0400 +++ b/daemon.c Fri Feb 01 15:55:40 2019 -0500 @@ -131,10 +131,6 @@ init_post_subsys(); init_file_cache(); - ret = init_wordpress_categories(); - if (ret) - goto err; - ret = load_all_posts(); if (ret) goto err;
--- a/req.h Fri Apr 13 22:26:46 2018 -0400 +++ b/req.h Fri Feb 01 15:55:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2017 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2014-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -74,6 +74,4 @@ extern int blahg_story(struct req *req); extern int blahg_admin(struct req *req); -extern int init_wordpress_categories(void); - #endif
--- a/tag.c Fri Apr 13 22:26:46 2018 -0400 +++ b/tag.c Fri Feb 01 15:55:40 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2017 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2011-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -38,15 +38,6 @@ #include "sidebar.h" #include "post.h" -/* - * Wordpress uses category numbers. We need to map them to the string based - * category names we use and generate a redirect. - * - * The list of number to string mappings is in the config file and we stuff - * them into these variables on startup. See init_wordpress_categories(). - */ -static struct str **wordpress_cats; - static void __store_title(struct vars *vars, struct str *title) { char twittertitle[1024]; @@ -110,98 +101,5 @@ int blahg_category(struct req *req, int page) { - struct str *cat; - uint32_t catn; - - cat = nvl_lookup_str(req->scgi->request.query, "cat"); - if (IS_ERR(cat)) - goto out; - - /* - * If we fail to parse the category number or it refers to a - * non-mapped category, we just use it as is. - */ - - if (wordpress_cats && !str2u32(str_cstr(cat), &catn)) { - char url[256]; - - if (catn >= array_size(wordpress_cats)) - goto out; - - if (!wordpress_cats[catn]) - goto out; - - str_putref(cat); - - snprintf(url, sizeof(url), "%s/?cat=%s", - str_cstr(config.base_url), - str_cstr(wordpress_cats[catn])); - - return R301(req, url); - } - -out: - return __tagcat(req, cat, page, "{catindex}", false); + return R404(req, NULL); } - -/* - * Each entry should be of the form: (int . str) - */ -static int store_wordpress_category(struct val *cur) -{ - struct val *idx, *name; - int ret; - - if (cur->type != VT_CONS) { - val_putref(cur); - return -EINVAL; - } - - idx = sexpr_car(val_getref(cur)); - name = sexpr_cdr(cur); - - if ((idx->type != VT_INT) || (name->type != VT_STR)) { - cmn_err(CE_ERROR, "wordpress category entry type error - " - "expecting: (int . string)"); - ret = -EINVAL; - goto out; - } - - if (idx->i >= array_size(wordpress_cats)) { - ret = array_truncate(&wordpress_cats, idx->i + 1); - if (ret) - goto out; - } - - wordpress_cats[idx->i] = val_getref_str(name); - - ret = 0; - -out: - val_putref(idx); - val_putref(name); - - return ret; -} - -int init_wordpress_categories(void) -{ - struct val *cur, *tmp; - int ret = 0; - - wordpress_cats = array_alloc(sizeof(struct str *), 0); - - sexpr_for_each_noref(cur, tmp, config.wordpress_categories) { - ret = store_wordpress_category(val_getref(cur)); - if (ret) - break; - } - - /* if there is nothing, free it */ - if (!array_size(wordpress_cats)) { - array_free(wordpress_cats); - wordpress_cats = NULL; - } - - return ret; -}