Mercurial > blahgd
changeset 55:b58bc13b5192
allow post texts to have different formats
format 0 is what wordpress has, format 1 is what I currently prefer
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Wed, 25 Feb 2009 17:59:16 -0500 |
parents | 98fbe3cdb93f |
children | 901674ccbbe8 |
files | post.c post.h |
diffstat | 2 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/post.c Wed Feb 25 17:35:37 2009 -0500 +++ b/post.c Wed Feb 25 17:59:16 2009 -0500 @@ -88,6 +88,8 @@ if (tmp == '\n') { fwrite("</p>\n", 1, 5, post->out); state = CATP_SKIP; + } else if (post->fmt == 1) { + state = CATP_ECHO; } else { fwrite("<br/>\n", 1, 5, post->out); state = CATP_ECHO; @@ -242,26 +244,31 @@ int load_post(int postid, struct post *post) { char path[FILENAME_MAX]; - char *buf; + char *buf1,*buf2; snprintf(path, FILENAME_MAX, "data/posts/%d", postid); post->id = postid; post->title = safe_getxattr(path, XATTR_TITLE); post->cats = safe_getxattr(path, XATTR_CATS); - buf = safe_getxattr(path, XATTR_TIME); + buf1 = safe_getxattr(path, XATTR_TIME); + buf2 = safe_getxattr(path, XATTR_FMT); - if (post->title && buf && (strlen(buf) == 16)) { + if (post->title && buf1 && (strlen(buf1) == 16)) { /* "2005-01-02 03:03" */ - strptime(buf, "%Y-%m-%d %H:%M", &post->time); + strptime(buf1, "%Y-%m-%d %H:%M", &post->time); - free(buf); + post->fmt = buf2 ? atoi(buf2) : 0; + + free(buf1); + free(buf2); return 0; } destroy_post(post); - free(buf); + free(buf1); + free(buf2); return ENOMEM; }
--- a/post.h Wed Feb 25 17:35:37 2009 -0500 +++ b/post.h Wed Feb 25 17:59:16 2009 -0500 @@ -12,6 +12,7 @@ struct post { FILE *out; int id; + int fmt; char *title; char *cats; struct tm time; @@ -20,6 +21,7 @@ #define XATTR_TITLE "user.post_title" #define XATTR_CATS "user.post_cats" #define XATTR_TIME "user.post_time" +#define XATTR_FMT "user.post_fmt" #define XATTR_COMM_AUTHOR "user.author" extern int load_post(int postid, struct post *post);