Fossil SCM
Clean up the RSS code slightly.
Commit
484c8f9f860a0e1f9bf5feedbdb682dfb7a37d2c
Parent
083cad82ff9cdfe…
1 file changed
+6
-17
+6
-17
| --- src/rss.c | ||
| +++ src/rss.c | ||
| @@ -26,27 +26,13 @@ | ||
| 26 | 26 | #include "config.h" |
| 27 | 27 | #include "rss.h" |
| 28 | 28 | #include <assert.h> |
| 29 | 29 | #include <time.h> |
| 30 | 30 | |
| 31 | -time_t rss_datetime_to_time_t(const char *dt){ | |
| 32 | - struct tm the_tm; | |
| 33 | - | |
| 34 | - the_tm.tm_year = atoi(dt)-1900; | |
| 35 | - the_tm.tm_mon = atoi(&dt[5])-1; | |
| 36 | - the_tm.tm_mday = atoi(&dt[8]); | |
| 37 | - the_tm.tm_hour = atoi(&dt[11]); | |
| 38 | - the_tm.tm_min = atoi(&dt[14]); | |
| 39 | - the_tm.tm_sec = atoi(&dt[17]); | |
| 40 | - | |
| 41 | - return mktime(&the_tm); | |
| 42 | -} | |
| 43 | - | |
| 44 | 31 | /* |
| 45 | 32 | ** WEBPAGE: timeline.rss |
| 46 | 33 | */ |
| 47 | - | |
| 48 | 34 | void page_timeline_rss(void){ |
| 49 | 35 | Stmt q; |
| 50 | 36 | int nLine=0; |
| 51 | 37 | char *zPubDate, *zProjectName, *zProjectDescr, *zFreeProjectName=0; |
| 52 | 38 | Blob bSQL; |
| @@ -53,11 +39,11 @@ | ||
| 53 | 39 | const char *zType = PD("y","all"); /* Type of events. All if NULL */ |
| 54 | 40 | const char zSQL1[] = |
| 55 | 41 | @ SELECT |
| 56 | 42 | @ blob.rid, |
| 57 | 43 | @ uuid, |
| 58 | - @ datetime(event.mtime), | |
| 44 | + @ event.mtime, | |
| 59 | 45 | @ coalesce(ecomment,comment), |
| 60 | 46 | @ coalesce(euser,user), |
| 61 | 47 | @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim), |
| 62 | 48 | @ (SELECT count(*) FROM plink WHERE cid=blob.rid) |
| 63 | 49 | @ FROM event, blob |
| @@ -96,18 +82,20 @@ | ||
| 96 | 82 | @ <generator>Fossil version %s(MANIFEST_VERSION) %s(MANIFEST_DATE)</generator> |
| 97 | 83 | db_prepare(&q, blob_buffer(&bSQL)); |
| 98 | 84 | blob_reset( &bSQL ); |
| 99 | 85 | while( db_step(&q)==SQLITE_ROW && nLine<=20 ){ |
| 100 | 86 | const char *zId = db_column_text(&q, 1); |
| 101 | - const char *zDate = db_column_text(&q, 2); | |
| 102 | 87 | const char *zCom = db_column_text(&q, 3); |
| 103 | 88 | const char *zAuthor = db_column_text(&q, 4); |
| 104 | 89 | char *zPrefix = ""; |
| 90 | + char *zDate; | |
| 105 | 91 | int nChild = db_column_int(&q, 5); |
| 106 | 92 | int nParent = db_column_int(&q, 6); |
| 93 | + time_t ts; | |
| 107 | 94 | |
| 108 | - zDate = cgi_rfc822_datestamp(rss_datetime_to_time_t(zDate)); | |
| 95 | + ts = (time_t)((db_column_double(&q,2) - 2440587.5)*86400.0); | |
| 96 | + zDate = cgi_rfc822_datestamp(ts); | |
| 109 | 97 | |
| 110 | 98 | if( nParent>1 && nChild>1 ){ |
| 111 | 99 | zPrefix = "*MERGE/FORK* "; |
| 112 | 100 | }else if( nParent>1 ){ |
| 113 | 101 | zPrefix = "*MERGE* "; |
| @@ -121,10 +109,11 @@ | ||
| 121 | 109 | @ <description>%s(zPrefix)%s(zCom)</description> |
| 122 | 110 | @ <pubDate>%s(zDate)</pubDate> |
| 123 | 111 | @ <author>%s(zAuthor)</author> |
| 124 | 112 | @ <guid>%s(g.zBaseURL)/ci/%s(zId)</guid> |
| 125 | 113 | @ </item> |
| 114 | + free(zDate); | |
| 126 | 115 | nLine++; |
| 127 | 116 | } |
| 128 | 117 | |
| 129 | 118 | db_finalize(&q); |
| 130 | 119 | @ </channel> |
| 131 | 120 |
| --- src/rss.c | |
| +++ src/rss.c | |
| @@ -26,27 +26,13 @@ | |
| 26 | #include "config.h" |
| 27 | #include "rss.h" |
| 28 | #include <assert.h> |
| 29 | #include <time.h> |
| 30 | |
| 31 | time_t rss_datetime_to_time_t(const char *dt){ |
| 32 | struct tm the_tm; |
| 33 | |
| 34 | the_tm.tm_year = atoi(dt)-1900; |
| 35 | the_tm.tm_mon = atoi(&dt[5])-1; |
| 36 | the_tm.tm_mday = atoi(&dt[8]); |
| 37 | the_tm.tm_hour = atoi(&dt[11]); |
| 38 | the_tm.tm_min = atoi(&dt[14]); |
| 39 | the_tm.tm_sec = atoi(&dt[17]); |
| 40 | |
| 41 | return mktime(&the_tm); |
| 42 | } |
| 43 | |
| 44 | /* |
| 45 | ** WEBPAGE: timeline.rss |
| 46 | */ |
| 47 | |
| 48 | void page_timeline_rss(void){ |
| 49 | Stmt q; |
| 50 | int nLine=0; |
| 51 | char *zPubDate, *zProjectName, *zProjectDescr, *zFreeProjectName=0; |
| 52 | Blob bSQL; |
| @@ -53,11 +39,11 @@ | |
| 53 | const char *zType = PD("y","all"); /* Type of events. All if NULL */ |
| 54 | const char zSQL1[] = |
| 55 | @ SELECT |
| 56 | @ blob.rid, |
| 57 | @ uuid, |
| 58 | @ datetime(event.mtime), |
| 59 | @ coalesce(ecomment,comment), |
| 60 | @ coalesce(euser,user), |
| 61 | @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim), |
| 62 | @ (SELECT count(*) FROM plink WHERE cid=blob.rid) |
| 63 | @ FROM event, blob |
| @@ -96,18 +82,20 @@ | |
| 96 | @ <generator>Fossil version %s(MANIFEST_VERSION) %s(MANIFEST_DATE)</generator> |
| 97 | db_prepare(&q, blob_buffer(&bSQL)); |
| 98 | blob_reset( &bSQL ); |
| 99 | while( db_step(&q)==SQLITE_ROW && nLine<=20 ){ |
| 100 | const char *zId = db_column_text(&q, 1); |
| 101 | const char *zDate = db_column_text(&q, 2); |
| 102 | const char *zCom = db_column_text(&q, 3); |
| 103 | const char *zAuthor = db_column_text(&q, 4); |
| 104 | char *zPrefix = ""; |
| 105 | int nChild = db_column_int(&q, 5); |
| 106 | int nParent = db_column_int(&q, 6); |
| 107 | |
| 108 | zDate = cgi_rfc822_datestamp(rss_datetime_to_time_t(zDate)); |
| 109 | |
| 110 | if( nParent>1 && nChild>1 ){ |
| 111 | zPrefix = "*MERGE/FORK* "; |
| 112 | }else if( nParent>1 ){ |
| 113 | zPrefix = "*MERGE* "; |
| @@ -121,10 +109,11 @@ | |
| 121 | @ <description>%s(zPrefix)%s(zCom)</description> |
| 122 | @ <pubDate>%s(zDate)</pubDate> |
| 123 | @ <author>%s(zAuthor)</author> |
| 124 | @ <guid>%s(g.zBaseURL)/ci/%s(zId)</guid> |
| 125 | @ </item> |
| 126 | nLine++; |
| 127 | } |
| 128 | |
| 129 | db_finalize(&q); |
| 130 | @ </channel> |
| 131 |
| --- src/rss.c | |
| +++ src/rss.c | |
| @@ -26,27 +26,13 @@ | |
| 26 | #include "config.h" |
| 27 | #include "rss.h" |
| 28 | #include <assert.h> |
| 29 | #include <time.h> |
| 30 | |
| 31 | /* |
| 32 | ** WEBPAGE: timeline.rss |
| 33 | */ |
| 34 | void page_timeline_rss(void){ |
| 35 | Stmt q; |
| 36 | int nLine=0; |
| 37 | char *zPubDate, *zProjectName, *zProjectDescr, *zFreeProjectName=0; |
| 38 | Blob bSQL; |
| @@ -53,11 +39,11 @@ | |
| 39 | const char *zType = PD("y","all"); /* Type of events. All if NULL */ |
| 40 | const char zSQL1[] = |
| 41 | @ SELECT |
| 42 | @ blob.rid, |
| 43 | @ uuid, |
| 44 | @ event.mtime, |
| 45 | @ coalesce(ecomment,comment), |
| 46 | @ coalesce(euser,user), |
| 47 | @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim), |
| 48 | @ (SELECT count(*) FROM plink WHERE cid=blob.rid) |
| 49 | @ FROM event, blob |
| @@ -96,18 +82,20 @@ | |
| 82 | @ <generator>Fossil version %s(MANIFEST_VERSION) %s(MANIFEST_DATE)</generator> |
| 83 | db_prepare(&q, blob_buffer(&bSQL)); |
| 84 | blob_reset( &bSQL ); |
| 85 | while( db_step(&q)==SQLITE_ROW && nLine<=20 ){ |
| 86 | const char *zId = db_column_text(&q, 1); |
| 87 | const char *zCom = db_column_text(&q, 3); |
| 88 | const char *zAuthor = db_column_text(&q, 4); |
| 89 | char *zPrefix = ""; |
| 90 | char *zDate; |
| 91 | int nChild = db_column_int(&q, 5); |
| 92 | int nParent = db_column_int(&q, 6); |
| 93 | time_t ts; |
| 94 | |
| 95 | ts = (time_t)((db_column_double(&q,2) - 2440587.5)*86400.0); |
| 96 | zDate = cgi_rfc822_datestamp(ts); |
| 97 | |
| 98 | if( nParent>1 && nChild>1 ){ |
| 99 | zPrefix = "*MERGE/FORK* "; |
| 100 | }else if( nParent>1 ){ |
| 101 | zPrefix = "*MERGE* "; |
| @@ -121,10 +109,11 @@ | |
| 109 | @ <description>%s(zPrefix)%s(zCom)</description> |
| 110 | @ <pubDate>%s(zDate)</pubDate> |
| 111 | @ <author>%s(zAuthor)</author> |
| 112 | @ <guid>%s(g.zBaseURL)/ci/%s(zId)</guid> |
| 113 | @ </item> |
| 114 | free(zDate); |
| 115 | nLine++; |
| 116 | } |
| 117 | |
| 118 | db_finalize(&q); |
| 119 | @ </channel> |
| 120 |