Add tagging to cgi_blerg (and stubs for everything else)
authorChip Black <bytex64@bytex64.net>
Thu, 30 Dec 2010 07:37:25 +0000 (01:37 -0600)
committerChip Black <bytex64@bytex64.net>
Thu, 30 Dec 2010 07:37:25 +0000 (01:37 -0600)
cgi/cgi_blerg.c

index db791a0..7eb875e 100644 (file)
@@ -135,6 +135,37 @@ int main(int argc, char *argv[]) {
                }
 
                blerg_close(b);
+       } else if (strncmp(path, "/tag", 4) == 0 && strlen(url) > 4) {
+               if (strcmp(request_method, "GET") != 0) {
+                       respond_405();
+                       exit(0);
+               }
+
+               if (path[4] != '/') {
+                       respond_404();
+                       exit(0);
+               }
+
+               ret = parse_url_info(path + 5, &info);
+               if ((ret & URL_INFO_AUTHOR) == 0) {
+                       respond_404();
+                       exit(0);
+               }
+
+               if (!tag_exists(info.author)) {
+                       respond_404();
+                       exit(0);
+               }
+
+               uint64_t recs = 50;
+               struct tag *taglist = tag_list(info.author, 0, &recs, -1);
+
+               if (recs == 0) {
+                       respond_simple_data("[]", 2);
+               } else {
+                       respond_taglist(taglist, recs);
+               }
+       } else if (strncmp(url, "/put", 4) == 0) {
        } else if (strncmp(path, "/info", 5) == 0) {
                if (strcmp(request_method, "GET") != 0) {
                        respond_405();
@@ -177,6 +208,7 @@ int main(int argc, char *argv[]) {
                write(0, ybuf, len);
 
                yajl_gen_free(g);
+       } else if (strncmp(url, "/create", 8) == 0) {
        } else {
                respond_404();
                exit(0);