Fossil SCM

Update src/rss.c with latest version from dg-misc branch (original at [01e85ec4]).

dg 2013-02-12 16:57 timeline-rss-ticket
Commit a10282407c3013153c670e4276e3a1aabe3d93ce
1 file changed +35 -25
+35 -25
--- src/rss.c
+++ src/rss.c
@@ -20,35 +20,25 @@
2020
#include "config.h"
2121
#include <time.h>
2222
#include "rss.h"
2323
#include <assert.h>
2424
25
-static int append_tag_filter(Blob* bSQL, const char* zName, const char* zType)
26
-{
27
- if ( zName ){
28
- int nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB '%s-%q*'",
29
- zType, zName);
30
- if ( nTagId == 0 ){
31
- return 0;
32
- }
33
- blob_appendf(bSQL, " AND objid IN (SELECT rid FROM tagxref WHERE tagid=%d)", nTagId);
34
- }
35
- return 1;
36
-}
37
-
3825
/*
3926
** WEBPAGE: timeline.rss
40
-** URL: /timeline.rss/y=TYPE&n=LIMIT&tkt=UUID&tag=TAG&name=FILENAME&wiki=NAME
27
+** URL: /timeline.rss/y=TYPE&n=LIMIT&tkt=UUID&tag=TAG&wiki=NAME&name=FILENAME
4128
**
4229
** Produce an RSS feed of the timeline.
4330
**
4431
** TYPE may be: all, ci (show checkins only), t (show tickets only),
4532
** w (show wiki only). LIMIT is the number of items to show.
4633
**
4734
** tkt=UUID filters for only those events for the specified ticket. tag=TAG
48
-** filters for a tag, and name=FILENAME for a file. Some combinations may be
49
-** used.
35
+** filters for a tag, and wiki=NAME for a wiki page. Only one may be used.
36
+**
37
+** In addition, name=FILENAME filters for a specific file. This may be
38
+** combined with one of the other filters (useful for looking at a specific
39
+** branch).
5040
*/
5141
5242
void page_timeline_rss(void){
5343
Stmt q;
5444
int nLine=0;
@@ -58,10 +48,11 @@
5848
const char *zTicketUuid = PD("tkt",NULL);
5949
const char *zTag = PD("tag",NULL);
6050
const char *zFilename = PD("name",NULL);
6151
const char *zWiki = PD("wiki",NULL);
6252
int nLimit = atoi(PD("n","20"));
53
+ int nTagId;
6354
const char zSQL1[] =
6455
@ SELECT
6556
@ blob.rid,
6657
@ uuid,
6758
@ event.mtime,
@@ -106,21 +97,40 @@
10697
assert( !g.perm.RdTkt &&& g.perm.Read && g.perm.RdWiki );
10798
blob_append(&bSQL, " AND event.type!='t'", -1);
10899
}
109100
}
110101
111
- if( !append_tag_filter(&bSQL, zTicketUuid, "tkt") ){
112
- return;
113
- }
114
- if( !append_tag_filter(&bSQL, zTag, "sym") ){
115
- return;
116
- }
117
- if( !append_tag_filter(&bSQL, zWiki, "wiki") ){
118
- return;
102
+ if( zTicketUuid ){
103
+ nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",
104
+ zTicketUuid);
105
+ if ( nTagId==0 ){
106
+ nTagId = -1;
107
+ }
108
+ }else if( zTag ){
109
+ nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'sym-%q*'",
110
+ zTag);
111
+ if ( nTagId==0 ){
112
+ nTagId = -1;
113
+ }
114
+ }else if( zWiki ){
115
+ nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'wiki-%q*'",
116
+ zWiki);
117
+ if ( nTagId==0 ){
118
+ nTagId = -1;
119
+ }
120
+ }else{
121
+ nTagId = 0;
122
+ }
123
+
124
+ if( nTagId==-1 ){
125
+ blob_appendf(&bSQL, " AND 0");
126
+ }else if( nTagId!=0 ){
127
+ blob_appendf(&bSQL, " AND (EXISTS(SELECT 1 FROM tagxref"
128
+ " WHERE tagid=%d AND tagtype>0 AND rid=blob.rid))", nTagId);
119129
}
120130
121
- if ( zFilename ){
131
+ if( zFilename ){
122132
blob_appendf(&bSQL,
123133
" AND (SELECT mlink.fnid FROM mlink WHERE event.objid=mlink.mid) IN (SELECT fnid FROM filename WHERE name=%Q %s)",
124134
zFilename, filename_collation()
125135
);
126136
}
127137
--- src/rss.c
+++ src/rss.c
@@ -20,35 +20,25 @@
20 #include "config.h"
21 #include <time.h>
22 #include "rss.h"
23 #include <assert.h>
24
25 static int append_tag_filter(Blob* bSQL, const char* zName, const char* zType)
26 {
27 if ( zName ){
28 int nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB '%s-%q*'",
29 zType, zName);
30 if ( nTagId == 0 ){
31 return 0;
32 }
33 blob_appendf(bSQL, " AND objid IN (SELECT rid FROM tagxref WHERE tagid=%d)", nTagId);
34 }
35 return 1;
36 }
37
38 /*
39 ** WEBPAGE: timeline.rss
40 ** URL: /timeline.rss/y=TYPE&n=LIMIT&tkt=UUID&tag=TAG&name=FILENAME&wiki=NAME
41 **
42 ** Produce an RSS feed of the timeline.
43 **
44 ** TYPE may be: all, ci (show checkins only), t (show tickets only),
45 ** w (show wiki only). LIMIT is the number of items to show.
46 **
47 ** tkt=UUID filters for only those events for the specified ticket. tag=TAG
48 ** filters for a tag, and name=FILENAME for a file. Some combinations may be
49 ** used.
 
 
 
50 */
51
52 void page_timeline_rss(void){
53 Stmt q;
54 int nLine=0;
@@ -58,10 +48,11 @@
58 const char *zTicketUuid = PD("tkt",NULL);
59 const char *zTag = PD("tag",NULL);
60 const char *zFilename = PD("name",NULL);
61 const char *zWiki = PD("wiki",NULL);
62 int nLimit = atoi(PD("n","20"));
 
63 const char zSQL1[] =
64 @ SELECT
65 @ blob.rid,
66 @ uuid,
67 @ event.mtime,
@@ -106,21 +97,40 @@
106 assert( !g.perm.RdTkt &&& g.perm.Read && g.perm.RdWiki );
107 blob_append(&bSQL, " AND event.type!='t'", -1);
108 }
109 }
110
111 if( !append_tag_filter(&bSQL, zTicketUuid, "tkt") ){
112 return;
113 }
114 if( !append_tag_filter(&bSQL, zTag, "sym") ){
115 return;
116 }
117 if( !append_tag_filter(&bSQL, zWiki, "wiki") ){
118 return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119 }
120
121 if ( zFilename ){
122 blob_appendf(&bSQL,
123 " AND (SELECT mlink.fnid FROM mlink WHERE event.objid=mlink.mid) IN (SELECT fnid FROM filename WHERE name=%Q %s)",
124 zFilename, filename_collation()
125 );
126 }
127
--- src/rss.c
+++ src/rss.c
@@ -20,35 +20,25 @@
20 #include "config.h"
21 #include <time.h>
22 #include "rss.h"
23 #include <assert.h>
24
 
 
 
 
 
 
 
 
 
 
 
 
 
25 /*
26 ** WEBPAGE: timeline.rss
27 ** URL: /timeline.rss/y=TYPE&n=LIMIT&tkt=UUID&tag=TAG&wiki=NAME&name=FILENAME
28 **
29 ** Produce an RSS feed of the timeline.
30 **
31 ** TYPE may be: all, ci (show checkins only), t (show tickets only),
32 ** w (show wiki only). LIMIT is the number of items to show.
33 **
34 ** tkt=UUID filters for only those events for the specified ticket. tag=TAG
35 ** filters for a tag, and wiki=NAME for a wiki page. Only one may be used.
36 **
37 ** In addition, name=FILENAME filters for a specific file. This may be
38 ** combined with one of the other filters (useful for looking at a specific
39 ** branch).
40 */
41
42 void page_timeline_rss(void){
43 Stmt q;
44 int nLine=0;
@@ -58,10 +48,11 @@
48 const char *zTicketUuid = PD("tkt",NULL);
49 const char *zTag = PD("tag",NULL);
50 const char *zFilename = PD("name",NULL);
51 const char *zWiki = PD("wiki",NULL);
52 int nLimit = atoi(PD("n","20"));
53 int nTagId;
54 const char zSQL1[] =
55 @ SELECT
56 @ blob.rid,
57 @ uuid,
58 @ event.mtime,
@@ -106,21 +97,40 @@
97 assert( !g.perm.RdTkt &&& g.perm.Read && g.perm.RdWiki );
98 blob_append(&bSQL, " AND event.type!='t'", -1);
99 }
100 }
101
102 if( zTicketUuid ){
103 nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",
104 zTicketUuid);
105 if ( nTagId==0 ){
106 nTagId = -1;
107 }
108 }else if( zTag ){
109 nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'sym-%q*'",
110 zTag);
111 if ( nTagId==0 ){
112 nTagId = -1;
113 }
114 }else if( zWiki ){
115 nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'wiki-%q*'",
116 zWiki);
117 if ( nTagId==0 ){
118 nTagId = -1;
119 }
120 }else{
121 nTagId = 0;
122 }
123
124 if( nTagId==-1 ){
125 blob_appendf(&bSQL, " AND 0");
126 }else if( nTagId!=0 ){
127 blob_appendf(&bSQL, " AND (EXISTS(SELECT 1 FROM tagxref"
128 " WHERE tagid=%d AND tagtype>0 AND rid=blob.rid))", nTagId);
129 }
130
131 if( zFilename ){
132 blob_appendf(&bSQL,
133 " AND (SELECT mlink.fnid FROM mlink WHERE event.objid=mlink.mid) IN (SELECT fnid FROM filename WHERE name=%Q %s)",
134 zFilename, filename_collation()
135 );
136 }
137

Keyboard Shortcuts

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