Fossil SCM
Update src/rss.c with latest version from dg-misc branch (original at [01e85ec4]).
Commit
a10282407c3013153c670e4276e3a1aabe3d93ce
Parent
1bc09124bd80b0e…
1 file changed
+35
-25
+35
-25
| --- src/rss.c | ||
| +++ src/rss.c | ||
| @@ -20,35 +20,25 @@ | ||
| 20 | 20 | #include "config.h" |
| 21 | 21 | #include <time.h> |
| 22 | 22 | #include "rss.h" |
| 23 | 23 | #include <assert.h> |
| 24 | 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 | 25 | /* |
| 39 | 26 | ** 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 | |
| 41 | 28 | ** |
| 42 | 29 | ** Produce an RSS feed of the timeline. |
| 43 | 30 | ** |
| 44 | 31 | ** TYPE may be: all, ci (show checkins only), t (show tickets only), |
| 45 | 32 | ** w (show wiki only). LIMIT is the number of items to show. |
| 46 | 33 | ** |
| 47 | 34 | ** 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). | |
| 50 | 40 | */ |
| 51 | 41 | |
| 52 | 42 | void page_timeline_rss(void){ |
| 53 | 43 | Stmt q; |
| 54 | 44 | int nLine=0; |
| @@ -58,10 +48,11 @@ | ||
| 58 | 48 | const char *zTicketUuid = PD("tkt",NULL); |
| 59 | 49 | const char *zTag = PD("tag",NULL); |
| 60 | 50 | const char *zFilename = PD("name",NULL); |
| 61 | 51 | const char *zWiki = PD("wiki",NULL); |
| 62 | 52 | int nLimit = atoi(PD("n","20")); |
| 53 | + int nTagId; | |
| 63 | 54 | const char zSQL1[] = |
| 64 | 55 | @ SELECT |
| 65 | 56 | @ blob.rid, |
| 66 | 57 | @ uuid, |
| 67 | 58 | @ event.mtime, |
| @@ -106,21 +97,40 @@ | ||
| 106 | 97 | assert( !g.perm.RdTkt &&& g.perm.Read && g.perm.RdWiki ); |
| 107 | 98 | blob_append(&bSQL, " AND event.type!='t'", -1); |
| 108 | 99 | } |
| 109 | 100 | } |
| 110 | 101 | |
| 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); | |
| 119 | 129 | } |
| 120 | 130 | |
| 121 | - if ( zFilename ){ | |
| 131 | + if( zFilename ){ | |
| 122 | 132 | blob_appendf(&bSQL, |
| 123 | 133 | " AND (SELECT mlink.fnid FROM mlink WHERE event.objid=mlink.mid) IN (SELECT fnid FROM filename WHERE name=%Q %s)", |
| 124 | 134 | zFilename, filename_collation() |
| 125 | 135 | ); |
| 126 | 136 | } |
| 127 | 137 |
| --- 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 |