Check-in [8337ec35af]

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

Overview
Comment:Provide tags to the hdf
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8337ec35af283a8890c0445b269bbd39143faa7f
User & Date: bapt 2013-07-22 14:53:35
Context
2014-06-16
14:21
Convert build system to autotools check-in: 91d28f951a user: bapt tags: trunk
12:49
Preliminary autoconf bits check-in: d1bb46ffbf user: bapt tags: autoconf
2013-07-22
14:53
Provide tags to the hdf check-in: 8337ec35af user: bapt tags: trunk
13:55
With the forgotten utarray.h :) check-in: aea3cb6063 user: bapt tags: trunk
Changes

Changes to cplanet.c.

358
359
360
361
362
363
364

365
366
367
368
369
370
371
...
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
...
743
744
745
746
747
748
749
750

751
752
753
754
755
756
757
...
772
773
774
775
776
777
778















779
780
781
782
783
784
785
...
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
			warnx("sqlite3: grr: %s", sqlite3_errmsg(db));
		sqlite3_reset(feed->stmt);

		p = NULL;
		while (( p = (char **)utarray_next(feed->tag, p)) != NULL) {
			sqlite3_bind_text(feed->tags, 2, *p, -1, SQLITE_STATIC);
			sqlite3_step(feed->tags);

		}
		utarray_clear(feed->tag);
		feed->has_author = false;
	}
	feed->xmlpath->size -= strlen(elt);
	feed->xmlpath->data[feed->xmlpath->size] = '\0';
	if (feed->xmlpath->data[feed->xmlpath->size - 1] != '/')
................................................................................

	return (EXIT_SUCCESS);
}

static int
exec_update(int argc, char **argv)
{
	sqlite3_stmt *stmt;
	int pos = 0;
	NEOERR *neoerr;
	HDF *hdf;
	char *val;

	sql_exec("BEGIN;");
	if (sqlite3_prepare_v2(db, "SELECT name, url from feed;",
	    -1, &stmt, 0) != SQLITE_OK) {
................................................................................
	    "author, "
	    "link, "
	    "date, "
	    "strftime('%a, %d %b %Y %H:%M:%S %z', date, 'unixepoch') as rfc822, "
	    "strftime('%Y-%m-%dT%H:%M:%SZ', date, 'unixepoch') as iso8601, "
	    "strftime((select value from config where key='date_format'), date, 'unixepoch'), "
	    "description, "
	    "content "

	    "from posts config order by date DESC LIMIT (SELECT value from config where key='max_post');",
	    -1, &stmt, 0) != SQLITE_OK) {
		warnx("sqlite: %s", sqlite3_errmsg(db));
		return (EXIT_FAILURE);
	}

	string_init(&neoerr_str);
................................................................................
		cp_set_date_rfc822(hdf, pos, sqlite3_column_text(stmt, 6));
		cp_set_date_iso8601(hdf, pos, sqlite3_column_text(stmt, 7));
		cp_set_formated_date(hdf, pos, sqlite3_column_text(stmt, 8));
		if (sqlite3_column_text(stmt, 10) != NULL && sqlite3_column_text(stmt, 10)[0] != '\0')
			cp_set_description(hdf, pos, sqlite3_column_text(stmt, 10));
		else if (sqlite3_column_text(stmt, 9) != NULL)
			cp_set_description(hdf, pos, sqlite3_column_text(stmt, 9));















		pos++;
	}

	sqlite3_finalize(stmt);

	sql_text(&val, "SELECT value FROM config WHERE key='title';");
	hdf_set_valuef(hdf, "CPlanet.Name=%s", val);
................................................................................
	    "CREATE TABLE IF NOT EXISTS output "
	      "(path UNIQUE, template);"
	    "CREATE TABLE IF NOT EXISTS posts "
	      "(uid UNIQUE, name, blog_title, title, "
	      "author, link, content, "
	      "description, date, updated, tags);"
	    "CREATE TABLE IF NOT EXISTS tags "
	      "(uid, tag);"

/* Popupate with default data */
	    "INSERT OR IGNORE INTO config values "
	      "('title', 'default');"
	    "INSERT OR IGNORE INTO config values "
	      "('description', 'default');"
	    "INSERT OR IGNORE INTO config values "







>







 







|
|







 







|
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
...
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
...
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
...
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
...
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
			warnx("sqlite3: grr: %s", sqlite3_errmsg(db));
		sqlite3_reset(feed->stmt);

		p = NULL;
		while (( p = (char **)utarray_next(feed->tag, p)) != NULL) {
			sqlite3_bind_text(feed->tags, 2, *p, -1, SQLITE_STATIC);
			sqlite3_step(feed->tags);
			sqlite3_reset(feed->tags);
		}
		utarray_clear(feed->tag);
		feed->has_author = false;
	}
	feed->xmlpath->size -= strlen(elt);
	feed->xmlpath->data[feed->xmlpath->size] = '\0';
	if (feed->xmlpath->data[feed->xmlpath->size - 1] != '/')
................................................................................

	return (EXIT_SUCCESS);
}

static int
exec_update(int argc, char **argv)
{
	sqlite3_stmt *stmt, *stmt2;
	int pos = 0, tpos = 0;
	NEOERR *neoerr;
	HDF *hdf;
	char *val;

	sql_exec("BEGIN;");
	if (sqlite3_prepare_v2(db, "SELECT name, url from feed;",
	    -1, &stmt, 0) != SQLITE_OK) {
................................................................................
	    "author, "
	    "link, "
	    "date, "
	    "strftime('%a, %d %b %Y %H:%M:%S %z', date, 'unixepoch') as rfc822, "
	    "strftime('%Y-%m-%dT%H:%M:%SZ', date, 'unixepoch') as iso8601, "
	    "strftime((select value from config where key='date_format'), date, 'unixepoch'), "
	    "description, "
	    "content, "
	    "uid "
	    "from posts config order by date DESC LIMIT (SELECT value from config where key='max_post');",
	    -1, &stmt, 0) != SQLITE_OK) {
		warnx("sqlite: %s", sqlite3_errmsg(db));
		return (EXIT_FAILURE);
	}

	string_init(&neoerr_str);
................................................................................
		cp_set_date_rfc822(hdf, pos, sqlite3_column_text(stmt, 6));
		cp_set_date_iso8601(hdf, pos, sqlite3_column_text(stmt, 7));
		cp_set_formated_date(hdf, pos, sqlite3_column_text(stmt, 8));
		if (sqlite3_column_text(stmt, 10) != NULL && sqlite3_column_text(stmt, 10)[0] != '\0')
			cp_set_description(hdf, pos, sqlite3_column_text(stmt, 10));
		else if (sqlite3_column_text(stmt, 9) != NULL)
			cp_set_description(hdf, pos, sqlite3_column_text(stmt, 9));

		tpos = 0;
		if (sqlite3_prepare_v2(db, "SELECT tag FROM tags WHERE uid=?1;",
		    -1, &stmt2, 0) != SQLITE_OK) {
			warnx("sqlite: %s", sqlite3_errmsg(db));
			return (EXIT_FAILURE);
		}

		sqlite3_bind_text(stmt2, 1, (char *)sqlite3_column_text(stmt, 11), -1, SQLITE_STATIC);
		while (sqlite3_step(stmt2) == SQLITE_ROW) {
			cp_set_tag(hdf, pos, tpos, sqlite3_column_text(stmt2, 0));
			tpos++;
		}

		sqlite3_finalize(stmt2);
		pos++;
	}

	sqlite3_finalize(stmt);

	sql_text(&val, "SELECT value FROM config WHERE key='title';");
	hdf_set_valuef(hdf, "CPlanet.Name=%s", val);
................................................................................
	    "CREATE TABLE IF NOT EXISTS output "
	      "(path UNIQUE, template);"
	    "CREATE TABLE IF NOT EXISTS posts "
	      "(uid UNIQUE, name, blog_title, title, "
	      "author, link, content, "
	      "description, date, updated, tags);"
	    "CREATE TABLE IF NOT EXISTS tags "
	      "(uid, tag, UNIQUE(uid, tag));"

/* Popupate with default data */
	    "INSERT OR IGNORE INTO config values "
	      "('title', 'default');"
	    "INSERT OR IGNORE INTO config values "
	      "('description', 'default');"
	    "INSERT OR IGNORE INTO config values "