<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "post.h"
#include "main.h"
#include "render.h"
#include "sidebar.h"
#include "error.h"
#include "utils.h"

static int __render_page(struct req *req, char *tmpl)
{
	printf("Content-type: text/html\n\n");
	printf("%s\n", render_page(req, tmpl));

	return 0;
}

static void __store_title(struct vars *vars, const char *title)
{
	struct var_val vv;

	memset(&vv, 0, sizeof(vv));

        vv.type = VT_STR;
        vv.str  = xstrdup(title);
        ASSERT(vv.str);

        ASSERT(!var_append(vars, "title", &vv));
}

static int __load_post(struct req *req, int p)
{
	int ret;

	ret = load_post(req, p);

	if (ret) {
		LOG("failed to load post #%d", p);
		__store_title(&req->vars, "not found");<commit_msg>story: if we can't load the post, let's log the return code<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <errno.h>

#include "post.h"
#include "main.h"
#include "render.h"
#include "sidebar.h"
#include "error.h"
#include "utils.h"

static int __render_page(struct req *req, char *tmpl)
{
	printf("Content-type: text/html\n\n");
	printf("%s\n", render_page(req, tmpl));

	return 0;
}

static void __store_title(struct vars *vars, const char *title)
{
	struct var_val vv;

	memset(&vv, 0, sizeof(vv));

        vv.type = VT_STR;
        vv.str  = xstrdup(title);
        ASSERT(vv.str);

        ASSERT(!var_append(vars, "title", &vv));
}

static int __load_post(struct req *req, int p)
{
	int ret;

	ret = load_post(req, p);

	if (ret) {
		LOG("failed to load post #%d: %s (%d)", p, strerror(ret),
		    ret);
		__store_title(&req->vars, "not found");
{'fraction_non_alphanumeric': 0.1762295081967213, 'fraction_numerical': 0.00234192037470726, 'mean_word_length': 3.92507204610951, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3236334', 'n_tokens_mistral': 694, 'n_tokens_neox': 663, 'n_words': 174}