Fossil SCM

Clean up the RSS code slightly.

drh 2009-12-08 18:43 trunk
Commit 484c8f9f860a0e1f9bf5feedbdb682dfb7a37d2c
1 file changed +6 -17
+6 -17
--- src/rss.c
+++ src/rss.c
@@ -26,27 +26,13 @@
2626
#include "config.h"
2727
#include "rss.h"
2828
#include <assert.h>
2929
#include <time.h>
3030
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
-
4431
/*
4532
** WEBPAGE: timeline.rss
4633
*/
47
-
4834
void page_timeline_rss(void){
4935
Stmt q;
5036
int nLine=0;
5137
char *zPubDate, *zProjectName, *zProjectDescr, *zFreeProjectName=0;
5238
Blob bSQL;
@@ -53,11 +39,11 @@
5339
const char *zType = PD("y","all"); /* Type of events. All if NULL */
5440
const char zSQL1[] =
5541
@ SELECT
5642
@ blob.rid,
5743
@ uuid,
58
- @ datetime(event.mtime),
44
+ @ event.mtime,
5945
@ coalesce(ecomment,comment),
6046
@ coalesce(euser,user),
6147
@ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim),
6248
@ (SELECT count(*) FROM plink WHERE cid=blob.rid)
6349
@ FROM event, blob
@@ -96,18 +82,20 @@
9682
@ <generator>Fossil version %s(MANIFEST_VERSION) %s(MANIFEST_DATE)</generator>
9783
db_prepare(&q, blob_buffer(&bSQL));
9884
blob_reset( &bSQL );
9985
while( db_step(&q)==SQLITE_ROW && nLine<=20 ){
10086
const char *zId = db_column_text(&q, 1);
101
- const char *zDate = db_column_text(&q, 2);
10287
const char *zCom = db_column_text(&q, 3);
10388
const char *zAuthor = db_column_text(&q, 4);
10489
char *zPrefix = "";
90
+ char *zDate;
10591
int nChild = db_column_int(&q, 5);
10692
int nParent = db_column_int(&q, 6);
93
+ time_t ts;
10794
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);
10997
11098
if( nParent>1 && nChild>1 ){
11199
zPrefix = "*MERGE/FORK* ";
112100
}else if( nParent>1 ){
113101
zPrefix = "*MERGE* ";
@@ -121,10 +109,11 @@
121109
@ <description>%s(zPrefix)%s(zCom)</description>
122110
@ <pubDate>%s(zDate)</pubDate>
123111
@ <author>%s(zAuthor)</author>
124112
@ <guid>%s(g.zBaseURL)/ci/%s(zId)</guid>
125113
@ </item>
114
+ free(zDate);
126115
nLine++;
127116
}
128117
129118
db_finalize(&q);
130119
@ </channel>
131120
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button