Check-in [b97cc42edd]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fossil browsing by date
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | scgi
Files: files | file ages | folders
SHA1:b97cc42eddde88e6b76f857045b9b7ff7f89fad3
User & Date: bapt 2015-04-23 15:00:48
Context
2015-04-23
15:52
Fix boolean testing eating a char when true check-in: c0955e27e6 user: bapt tags: scgi
15:00
Fossil browsing by date check-in: b97cc42edd user: bapt tags: scgi
14:52
Fix redirect on tags check-in: a0cc2d2dda user: bapt tags: scgi
Changes

Changes to web/cblogweb.c.

407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
...
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
	else if (strcmp(r.pagename, "index.atom") == 0)
		type = CBLOG_ATOM;

	if (type == CBLOG_ATOM)
		criteria.timefmt = "%Y-%m-%dT%H:%M:%SZ";

	if (type == CBLOG_ROOT) {
		if (sscanf(r.path, "/%4d/%02d/%02d", &yyyy, &mm, &dd) == 3) {
			type = CBLOG_YYYY_MM_DD;
			criteria.type = CRITERIA_TIME_T;
		} else if (sscanf(r.path, "/%4d/%02d", &yyyy, &mm) == 2) {
			type = CBLOG_YYYY_MM;
			criteria.type = CRITERIA_TIME_T;
		} else if (sscanf(r.path, "/%4d", &yyyy) == 1) {
			type = CBLOG_YYYY;
			criteria.type = CRITERIA_TIME_T;
		}
	}

	sqlite3_open(ucl_get_string(conf,"db_path"), &sqlite);
	if (criteria.timefmt == NULL)
		criteria.timefmt = ucl_get_string(conf, "dateformat");

	reqpath = r.path;
	switch (type) {
		case CBLOG_POST:
			reqpath++;
			while (*reqpath && *reqpath != '/')
				reqpath++;
			if (*reqpath == '\0') {
				type = CBLOG_POST_REDIRECT;
				reqpath = "/";
				break;
			}
			reqpath++;

			if (comment == CBLOG_COMMENT_POST) {
				//set_comment(&h, reqpath, hdf_get_value(out, "antispamres", NULL), sqlite);
				type = CBLOG_POST_REDIRECT;
				break;
			}
			if (!build_post(conf, out, reqpath, sqlite)) {
				char *err_msg;
				asprintf(&err_msg, "Unknown post: %s", reqpath);
				ucl_object_insert_key(out, ucl_object_fromstring(err_msg), "err_msg", 0, false);
				type = CBLOG_ERR;
			}
			break;
		case CBLOG_TAG:
			if (*reqpath == '\0') {
				type = CBLOG_POST_REDIRECT;
				reqpath = "/";
				break;
			}
			criteria.type = CRITERIA_TAGNAME;
			criteria.tagname = reqpath;
			build_index(&r, conf, out, &criteria, sqlite);
			break;
		case CBLOG_ATOM:
			criteria.feed = true;
			build_index(&r, conf, out, &criteria, sqlite);
			break;
		case CBLOG_ROOT:
................................................................................
			snprintf(cspath, MAXPATHLEN, "%s/default.cs", tplpath);
			khttp_head(&r, kresps[KRESP_STATUS],
			    "%s", khttps[KHTTP_200]);
			break;
	}

	khttp_body(&r);
	warnx("%s", ucl_object_emit(out, UCL_EMIT_CONFIG));
	bzero(&tpl, sizeof(tpl));
	tpl.udata = &r;
	tpl.data = out;
	tpl.addchar = &cblog_putc;
	tpl.addstr = &cblog_puts;
	ucltpl_process_file(&tpl, cspath);

	sqlite3_close(sqlite);
	khttp_free(&r);
	exit(0);
}







|


|


|









<


<
<
<
|




<






|

|





|





|







 







<











407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429

430
431



432
433
434
435
436

437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
...
520
521
522
523
524
525
526

527
528
529
530
531
532
533
534
535
536
537
	else if (strcmp(r.pagename, "index.atom") == 0)
		type = CBLOG_ATOM;

	if (type == CBLOG_ATOM)
		criteria.timefmt = "%Y-%m-%dT%H:%M:%SZ";

	if (type == CBLOG_ROOT) {
		if (sscanf(r.fullpath, "/%4d/%02d/%02d", &yyyy, &mm, &dd) == 3) {
			type = CBLOG_YYYY_MM_DD;
			criteria.type = CRITERIA_TIME_T;
		} else if (sscanf(r.fullpath, "/%4d/%02d", &yyyy, &mm) == 2) {
			type = CBLOG_YYYY_MM;
			criteria.type = CRITERIA_TIME_T;
		} else if (sscanf(r.fullpath, "/%4d", &yyyy) == 1) {
			type = CBLOG_YYYY;
			criteria.type = CRITERIA_TIME_T;
		}
	}

	sqlite3_open(ucl_get_string(conf,"db_path"), &sqlite);
	if (criteria.timefmt == NULL)
		criteria.timefmt = ucl_get_string(conf, "dateformat");


	switch (type) {
		case CBLOG_POST:



			if (*r.path == '\0') {
				type = CBLOG_POST_REDIRECT;
				reqpath = "/";
				break;
			}


			if (comment == CBLOG_COMMENT_POST) {
				//set_comment(&h, reqpath, hdf_get_value(out, "antispamres", NULL), sqlite);
				type = CBLOG_POST_REDIRECT;
				break;
			}
			if (!build_post(conf, out, r.path, sqlite)) {
				char *err_msg;
				asprintf(&err_msg, "Unknown post: %s", r.path);
				ucl_object_insert_key(out, ucl_object_fromstring(err_msg), "err_msg", 0, false);
				type = CBLOG_ERR;
			}
			break;
		case CBLOG_TAG:
			if (*r.path == '\0') {
				type = CBLOG_POST_REDIRECT;
				reqpath = "/";
				break;
			}
			criteria.type = CRITERIA_TAGNAME;
			criteria.tagname = r.path;
			build_index(&r, conf, out, &criteria, sqlite);
			break;
		case CBLOG_ATOM:
			criteria.feed = true;
			build_index(&r, conf, out, &criteria, sqlite);
			break;
		case CBLOG_ROOT:
................................................................................
			snprintf(cspath, MAXPATHLEN, "%s/default.cs", tplpath);
			khttp_head(&r, kresps[KRESP_STATUS],
			    "%s", khttps[KHTTP_200]);
			break;
	}

	khttp_body(&r);

	bzero(&tpl, sizeof(tpl));
	tpl.udata = &r;
	tpl.data = out;
	tpl.addchar = &cblog_putc;
	tpl.addstr = &cblog_puts;
	ucltpl_process_file(&tpl, cspath);

	sqlite3_close(sqlite);
	khttp_free(&r);
	exit(0);
}