Check-in [180f34b6f9]

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

Overview
SHA1 Hash:180f34b6f9d8dced98f9040cd332c9d3be79164b
Date: 2009-11-20 13:34:24
User: dmitry
Comment:Display last-sync-url (without username and password)
Tags And Properties
Changes

Changes to TimelineGenerator.m

Old (a00cff8377cb079d) New (1d7dbd67907f3b1d)
1 #import <Foundation/Foundation.h> 1 #import <Foundation/Foundation.h>
2 #import <sqlite3.h> 2 #import <sqlite3.h>
3 3
4 NSMutableString *HTMLTimelineForDatabase(const char *database, int limit) 4 NSMutableString *HTMLTimelineForDatabase(const char *database, int limit)
5 { 5 {
34 hidden lines
40 40
41 sql = "SELECT name, value from config"; 41 sql = "SELECT name, value from config";
42 42
43 rc = sqlite3_prepare_v2(db, sql, -1, &st, 0); 43 rc = sqlite3_prepare_v2(db, sql, -1, &st, 0);
44 if (rc != SQLITE_OK) { 44 if (rc != SQLITE_OK) {
45 fprintf(stderr, "QLFossil: SQL error"); | 45 fprintf(stderr, "QLFossil: SQL error (1)");
46 goto out; |
47 } |
48 |
49 if (rc != SQLITE_OK) { |
50 fprintf(stderr, "QLFossil: SQL error"); |
51 goto out; 46 goto out;
52 } 47 }
53 48
54 [html appendString:@"<div class=info>"]; 49 [html appendString:@"<div class=info>"];
55 50
> 51 NSString *projectName = @"",
> 52 *projectDescription = @"",
> 53 *lastSyncURL = @"";
> 54
56 while (sqlite3_step(st) == SQLITE_ROW) { 55 while (sqlite3_step(st) == SQLITE_ROW) {
57 key = (char *)sqlite3_column_text(st, 0); 56 key = (char *)sqlite3_column_text(st, 0);
58 value = (char *)sqlite3_column_text(st, 1); 57 value = (char *)sqlite3_column_text(st, 1);
59 if (key && value && | 58 if (key && value) {
60 (strcmp(key, "project-name") == 0 || | 59 if (strcmp(key, "project-name") == 0) {
61 strcmp(key, "project-description") == 0 /*|| | 60 projectName = [NSString stringWithUTF8String:value];
62 strcmp(key, "last-sync-url") == 0*/)) { | 61 } else if (strcmp(key, "project-description") == 0) {
63 [html appendFormat:@"<div class='%s'>%s</div>", key, value]; | 62 projectDescription = [NSString stringWithUTF8String:value];
| 63 } else if (strcmp(key, "last-sync-url") == 0) {
| 64 // remove username/password http://username:password@example.com
| 65 NSMutableString *url = [NSMutableString stringWithUTF8String:value];
| 66 NSString *protocol = @"";
| 67 if ([url hasPrefix:@"https://"]) {
| 68 protocol = @"https://";
| 69 } else if ([url hasPrefix:@"http://"]) {
| 70 protocol = @"http://";
| 71 }
| 72 if ([protocol length] > 0) {
| 73 NSRange r = [url rangeOfString:@"@"];
| 74 if (r.location != NSNotFound) {
| 75 [url deleteCharactersInRange:NSMakeRange(0, r.location+r.length)];
| 76 }
| 77 }
| 78 lastSyncURL = [NSString stringWithFormat:@"%@%@", protocol, url];
| 79 }
64 } 80 }
65 } 81 }
66 sqlite3_finalize(st); 82 sqlite3_finalize(st);
67 83
> 84 [html appendFormat:@"<div class='project-name'>%@</div>\n"
> 85 "<div class='project-description'>%@</div>\n"
> 86 "<div class='last-sync-url'><a href='%@'>%@</a></div>\n",
> 87 projectName,
> 88 projectDescription,
> 89 lastSyncURL, lastSyncURL];
68 [html appendString:@"</div>"]; 90 [html appendString:@"</div>"];
69 91
70 sql = [[NSString stringWithFormat: 92 sql = [[NSString stringWithFormat:
71 @"SELECT bgcolor, type, datetime(mtime,'localtime') AS timestamp, " 93 @"SELECT bgcolor, type, datetime(mtime,'localtime') AS timestamp, "
72 "substr(uuid,0,10) AS uuid, comment, user FROM event " 94 "substr(uuid,0,10) AS uuid, comment, user FROM event "
73 "JOIN blob where blob.rid = event.objid " 95 "JOIN blob where blob.rid = event.objid "
74 "ORDER BY mtime DESC limit %d", limit] UTF8String]; 96 "ORDER BY mtime DESC limit %d", limit] UTF8String];
75 97
76 rc = sqlite3_prepare_v2(db, sql, -1, &st, 0); 98 rc = sqlite3_prepare_v2(db, sql, -1, &st, 0);
> 99 if (rc != SQLITE_OK) {
> 100 fprintf(stderr, "QLFossil: SQL error (2)");
> 101 goto out;
> 102 }
77 103
78 BOOL isOdd = NO; 104 BOOL isOdd = NO;
79 while (sqlite3_step(st) == SQLITE_ROW) { 105 while (sqlite3_step(st) == SQLITE_ROW) {
80 // 0 - bgcolor 106 // 0 - bgcolor
81 [html appendString:@"<div "]; 107 [html appendString:@"<div "];
32 hidden lines
114 140
115 out: 141 out:
116 sqlite3_close(db); 142 sqlite3_close(db);
117 return html; 143 return html;
118 } 144 }