Fossil SCM
Add tags to the title and description for RSS feed items.
Commit
66c3bc159d4caa9f97121bc9bd363e9c4f3bd027
Parent
6cd7087a35cb844…
1 file changed
+28
-6
+28
-6
| --- src/rss.c | ||
| +++ src/rss.c | ||
| @@ -59,11 +59,14 @@ | ||
| 59 | 59 | @ uuid, |
| 60 | 60 | @ event.mtime, |
| 61 | 61 | @ coalesce(ecomment,comment), |
| 62 | 62 | @ coalesce(euser,user), |
| 63 | 63 | @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim), |
| 64 | - @ (SELECT count(*) FROM plink WHERE cid=blob.rid) | |
| 64 | + @ (SELECT count(*) FROM plink WHERE cid=blob.rid), | |
| 65 | + @ (SELECT group_concat(substr(tagname,5), ', ') FROM tag, tagxref | |
| 66 | + @ WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid | |
| 67 | + @ AND tagxref.rid=blob.rid AND tagxref.tagtype>0) AS tags | |
| 65 | 68 | @ FROM event, blob |
| 66 | 69 | @ WHERE blob.rid=event.objid |
| 67 | 70 | ; |
| 68 | 71 | |
| 69 | 72 | login_check_credentials(); |
| @@ -167,15 +170,18 @@ | ||
| 167 | 170 | while( db_step(&q)==SQLITE_ROW && nLine<nLimit ){ |
| 168 | 171 | const char *zId = db_column_text(&q, 1); |
| 169 | 172 | const char *zCom = db_column_text(&q, 3); |
| 170 | 173 | const char *zAuthor = db_column_text(&q, 4); |
| 171 | 174 | char *zPrefix = ""; |
| 175 | + char *zSuffix = 0; | |
| 172 | 176 | char *zDate; |
| 173 | 177 | int nChild = db_column_int(&q, 5); |
| 174 | 178 | int nParent = db_column_int(&q, 6); |
| 179 | + const char *zTagList = db_column_text(&q, 7); | |
| 175 | 180 | time_t ts; |
| 176 | 181 | |
| 182 | + if( zTagList && zTagList[0]==0 ) zTagList = 0; | |
| 177 | 183 | ts = (time_t)((db_column_double(&q,2) - 2440587.5)*86400.0); |
| 178 | 184 | zDate = cgi_rfc822_datestamp(ts); |
| 179 | 185 | |
| 180 | 186 | if( nParent>1 && nChild>1 ){ |
| 181 | 187 | zPrefix = "*MERGE/FORK* "; |
| @@ -182,20 +188,25 @@ | ||
| 182 | 188 | }else if( nParent>1 ){ |
| 183 | 189 | zPrefix = "*MERGE* "; |
| 184 | 190 | }else if( nChild>1 ){ |
| 185 | 191 | zPrefix = "*FORK* "; |
| 186 | 192 | } |
| 193 | + | |
| 194 | + if( zTagList ){ | |
| 195 | + zSuffix = mprintf(" (tags: %s)", zTagList); | |
| 196 | + } | |
| 187 | 197 | |
| 188 | 198 | @ <item> |
| 189 | - @ <title>%s(zPrefix)%h(zCom)</title> | |
| 199 | + @ <title>%s(zPrefix)%h(zCom)%h(zSuffix)</title> | |
| 190 | 200 | @ <link>%s(g.zBaseURL)/info/%s(zId)</link> |
| 191 | - @ <description>%s(zPrefix)%h(zCom)</description> | |
| 201 | + @ <description>%s(zPrefix)%h(zCom)%h(zSuffix)</description> | |
| 192 | 202 | @ <pubDate>%s(zDate)</pubDate> |
| 193 | 203 | @ <dc:creator>%h(zAuthor)</dc:creator> |
| 194 | 204 | @ <guid>%s(g.zBaseURL)/info/%s(zId)</guid> |
| 195 | 205 | @ </item> |
| 196 | 206 | free(zDate); |
| 207 | + free(zSuffix); | |
| 197 | 208 | nLine++; |
| 198 | 209 | } |
| 199 | 210 | |
| 200 | 211 | db_finalize(&q); |
| 201 | 212 | @ </channel> |
| @@ -260,11 +271,14 @@ | ||
| 260 | 271 | @ uuid, |
| 261 | 272 | @ event.mtime, |
| 262 | 273 | @ coalesce(ecomment,comment), |
| 263 | 274 | @ coalesce(euser,user), |
| 264 | 275 | @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim), |
| 265 | - @ (SELECT count(*) FROM plink WHERE cid=blob.rid) | |
| 276 | + @ (SELECT count(*) FROM plink WHERE cid=blob.rid), | |
| 277 | + @ (SELECT group_concat(substr(tagname,5), ', ') FROM tag, tagxref | |
| 278 | + @ WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid | |
| 279 | + @ AND tagxref.rid=blob.rid AND tagxref.tagtype>0) AS tags | |
| 266 | 280 | @ FROM event, blob |
| 267 | 281 | @ WHERE blob.rid=event.objid |
| 268 | 282 | ; |
| 269 | 283 | if(!zType || !*zType){ |
| 270 | 284 | zType = "all"; |
| @@ -350,15 +364,18 @@ | ||
| 350 | 364 | while( db_step(&q)==SQLITE_ROW && nLine<nLimit ){ |
| 351 | 365 | const char *zId = db_column_text(&q, 1); |
| 352 | 366 | const char *zCom = db_column_text(&q, 3); |
| 353 | 367 | const char *zAuthor = db_column_text(&q, 4); |
| 354 | 368 | char *zPrefix = ""; |
| 369 | + char *zSuffix = 0; | |
| 355 | 370 | char *zDate; |
| 356 | 371 | int nChild = db_column_int(&q, 5); |
| 357 | 372 | int nParent = db_column_int(&q, 6); |
| 373 | + const char *zTagList = db_column_text(&q, 7); | |
| 358 | 374 | time_t ts; |
| 359 | 375 | |
| 376 | + if( zTagList && zTagList[0]==0 ) zTagList = 0; | |
| 360 | 377 | ts = (time_t)((db_column_double(&q,2) - 2440587.5)*86400.0); |
| 361 | 378 | zDate = cgi_rfc822_datestamp(ts); |
| 362 | 379 | |
| 363 | 380 | if( nParent>1 && nChild>1 ){ |
| 364 | 381 | zPrefix = "*MERGE/FORK* "; |
| @@ -365,20 +382,25 @@ | ||
| 365 | 382 | }else if( nParent>1 ){ |
| 366 | 383 | zPrefix = "*MERGE* "; |
| 367 | 384 | }else if( nChild>1 ){ |
| 368 | 385 | zPrefix = "*FORK* "; |
| 369 | 386 | } |
| 387 | + | |
| 388 | + if( zTagList ){ | |
| 389 | + zSuffix = mprintf(" (tags: %s)", zTagList); | |
| 390 | + } | |
| 370 | 391 | |
| 371 | 392 | fossil_print("<item>"); |
| 372 | - fossil_print("<title>%s%h</title>\n", zPrefix, zCom); | |
| 393 | + fossil_print("<title>%s%h%h</title>\n", zPrefix, zCom, zSuffix); | |
| 373 | 394 | fossil_print("<link>%s/info/%s</link>\n", zBaseURL, zId); |
| 374 | - fossil_print("<description>%s%h</description>\n", zPrefix, zCom); | |
| 395 | + fossil_print("<description>%s%h%h</description>\n", zPrefix, zCom, zSuffix); | |
| 375 | 396 | fossil_print("<pubDate>%s</pubDate>\n", zDate); |
| 376 | 397 | fossil_print("<dc:creator>%h</dc:creator>\n", zAuthor); |
| 377 | 398 | fossil_print("<guid>%s/info/%s</guid>\n", g.zBaseURL, zId); |
| 378 | 399 | fossil_print("</item>\n"); |
| 379 | 400 | free(zDate); |
| 401 | + free(zSuffix); | |
| 380 | 402 | nLine++; |
| 381 | 403 | } |
| 382 | 404 | |
| 383 | 405 | db_finalize(&q); |
| 384 | 406 | fossil_print("</channel>\n"); |
| 385 | 407 |
| --- src/rss.c | |
| +++ src/rss.c | |
| @@ -59,11 +59,14 @@ | |
| 59 | @ uuid, |
| 60 | @ event.mtime, |
| 61 | @ coalesce(ecomment,comment), |
| 62 | @ coalesce(euser,user), |
| 63 | @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim), |
| 64 | @ (SELECT count(*) FROM plink WHERE cid=blob.rid) |
| 65 | @ FROM event, blob |
| 66 | @ WHERE blob.rid=event.objid |
| 67 | ; |
| 68 | |
| 69 | login_check_credentials(); |
| @@ -167,15 +170,18 @@ | |
| 167 | while( db_step(&q)==SQLITE_ROW && nLine<nLimit ){ |
| 168 | const char *zId = db_column_text(&q, 1); |
| 169 | const char *zCom = db_column_text(&q, 3); |
| 170 | const char *zAuthor = db_column_text(&q, 4); |
| 171 | char *zPrefix = ""; |
| 172 | char *zDate; |
| 173 | int nChild = db_column_int(&q, 5); |
| 174 | int nParent = db_column_int(&q, 6); |
| 175 | time_t ts; |
| 176 | |
| 177 | ts = (time_t)((db_column_double(&q,2) - 2440587.5)*86400.0); |
| 178 | zDate = cgi_rfc822_datestamp(ts); |
| 179 | |
| 180 | if( nParent>1 && nChild>1 ){ |
| 181 | zPrefix = "*MERGE/FORK* "; |
| @@ -182,20 +188,25 @@ | |
| 182 | }else if( nParent>1 ){ |
| 183 | zPrefix = "*MERGE* "; |
| 184 | }else if( nChild>1 ){ |
| 185 | zPrefix = "*FORK* "; |
| 186 | } |
| 187 | |
| 188 | @ <item> |
| 189 | @ <title>%s(zPrefix)%h(zCom)</title> |
| 190 | @ <link>%s(g.zBaseURL)/info/%s(zId)</link> |
| 191 | @ <description>%s(zPrefix)%h(zCom)</description> |
| 192 | @ <pubDate>%s(zDate)</pubDate> |
| 193 | @ <dc:creator>%h(zAuthor)</dc:creator> |
| 194 | @ <guid>%s(g.zBaseURL)/info/%s(zId)</guid> |
| 195 | @ </item> |
| 196 | free(zDate); |
| 197 | nLine++; |
| 198 | } |
| 199 | |
| 200 | db_finalize(&q); |
| 201 | @ </channel> |
| @@ -260,11 +271,14 @@ | |
| 260 | @ uuid, |
| 261 | @ event.mtime, |
| 262 | @ coalesce(ecomment,comment), |
| 263 | @ coalesce(euser,user), |
| 264 | @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim), |
| 265 | @ (SELECT count(*) FROM plink WHERE cid=blob.rid) |
| 266 | @ FROM event, blob |
| 267 | @ WHERE blob.rid=event.objid |
| 268 | ; |
| 269 | if(!zType || !*zType){ |
| 270 | zType = "all"; |
| @@ -350,15 +364,18 @@ | |
| 350 | while( db_step(&q)==SQLITE_ROW && nLine<nLimit ){ |
| 351 | const char *zId = db_column_text(&q, 1); |
| 352 | const char *zCom = db_column_text(&q, 3); |
| 353 | const char *zAuthor = db_column_text(&q, 4); |
| 354 | char *zPrefix = ""; |
| 355 | char *zDate; |
| 356 | int nChild = db_column_int(&q, 5); |
| 357 | int nParent = db_column_int(&q, 6); |
| 358 | time_t ts; |
| 359 | |
| 360 | ts = (time_t)((db_column_double(&q,2) - 2440587.5)*86400.0); |
| 361 | zDate = cgi_rfc822_datestamp(ts); |
| 362 | |
| 363 | if( nParent>1 && nChild>1 ){ |
| 364 | zPrefix = "*MERGE/FORK* "; |
| @@ -365,20 +382,25 @@ | |
| 365 | }else if( nParent>1 ){ |
| 366 | zPrefix = "*MERGE* "; |
| 367 | }else if( nChild>1 ){ |
| 368 | zPrefix = "*FORK* "; |
| 369 | } |
| 370 | |
| 371 | fossil_print("<item>"); |
| 372 | fossil_print("<title>%s%h</title>\n", zPrefix, zCom); |
| 373 | fossil_print("<link>%s/info/%s</link>\n", zBaseURL, zId); |
| 374 | fossil_print("<description>%s%h</description>\n", zPrefix, zCom); |
| 375 | fossil_print("<pubDate>%s</pubDate>\n", zDate); |
| 376 | fossil_print("<dc:creator>%h</dc:creator>\n", zAuthor); |
| 377 | fossil_print("<guid>%s/info/%s</guid>\n", g.zBaseURL, zId); |
| 378 | fossil_print("</item>\n"); |
| 379 | free(zDate); |
| 380 | nLine++; |
| 381 | } |
| 382 | |
| 383 | db_finalize(&q); |
| 384 | fossil_print("</channel>\n"); |
| 385 |
| --- src/rss.c | |
| +++ src/rss.c | |
| @@ -59,11 +59,14 @@ | |
| 59 | @ uuid, |
| 60 | @ event.mtime, |
| 61 | @ coalesce(ecomment,comment), |
| 62 | @ coalesce(euser,user), |
| 63 | @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim), |
| 64 | @ (SELECT count(*) FROM plink WHERE cid=blob.rid), |
| 65 | @ (SELECT group_concat(substr(tagname,5), ', ') FROM tag, tagxref |
| 66 | @ WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid |
| 67 | @ AND tagxref.rid=blob.rid AND tagxref.tagtype>0) AS tags |
| 68 | @ FROM event, blob |
| 69 | @ WHERE blob.rid=event.objid |
| 70 | ; |
| 71 | |
| 72 | login_check_credentials(); |
| @@ -167,15 +170,18 @@ | |
| 170 | while( db_step(&q)==SQLITE_ROW && nLine<nLimit ){ |
| 171 | const char *zId = db_column_text(&q, 1); |
| 172 | const char *zCom = db_column_text(&q, 3); |
| 173 | const char *zAuthor = db_column_text(&q, 4); |
| 174 | char *zPrefix = ""; |
| 175 | char *zSuffix = 0; |
| 176 | char *zDate; |
| 177 | int nChild = db_column_int(&q, 5); |
| 178 | int nParent = db_column_int(&q, 6); |
| 179 | const char *zTagList = db_column_text(&q, 7); |
| 180 | time_t ts; |
| 181 | |
| 182 | if( zTagList && zTagList[0]==0 ) zTagList = 0; |
| 183 | ts = (time_t)((db_column_double(&q,2) - 2440587.5)*86400.0); |
| 184 | zDate = cgi_rfc822_datestamp(ts); |
| 185 | |
| 186 | if( nParent>1 && nChild>1 ){ |
| 187 | zPrefix = "*MERGE/FORK* "; |
| @@ -182,20 +188,25 @@ | |
| 188 | }else if( nParent>1 ){ |
| 189 | zPrefix = "*MERGE* "; |
| 190 | }else if( nChild>1 ){ |
| 191 | zPrefix = "*FORK* "; |
| 192 | } |
| 193 | |
| 194 | if( zTagList ){ |
| 195 | zSuffix = mprintf(" (tags: %s)", zTagList); |
| 196 | } |
| 197 | |
| 198 | @ <item> |
| 199 | @ <title>%s(zPrefix)%h(zCom)%h(zSuffix)</title> |
| 200 | @ <link>%s(g.zBaseURL)/info/%s(zId)</link> |
| 201 | @ <description>%s(zPrefix)%h(zCom)%h(zSuffix)</description> |
| 202 | @ <pubDate>%s(zDate)</pubDate> |
| 203 | @ <dc:creator>%h(zAuthor)</dc:creator> |
| 204 | @ <guid>%s(g.zBaseURL)/info/%s(zId)</guid> |
| 205 | @ </item> |
| 206 | free(zDate); |
| 207 | free(zSuffix); |
| 208 | nLine++; |
| 209 | } |
| 210 | |
| 211 | db_finalize(&q); |
| 212 | @ </channel> |
| @@ -260,11 +271,14 @@ | |
| 271 | @ uuid, |
| 272 | @ event.mtime, |
| 273 | @ coalesce(ecomment,comment), |
| 274 | @ coalesce(euser,user), |
| 275 | @ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim), |
| 276 | @ (SELECT count(*) FROM plink WHERE cid=blob.rid), |
| 277 | @ (SELECT group_concat(substr(tagname,5), ', ') FROM tag, tagxref |
| 278 | @ WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid |
| 279 | @ AND tagxref.rid=blob.rid AND tagxref.tagtype>0) AS tags |
| 280 | @ FROM event, blob |
| 281 | @ WHERE blob.rid=event.objid |
| 282 | ; |
| 283 | if(!zType || !*zType){ |
| 284 | zType = "all"; |
| @@ -350,15 +364,18 @@ | |
| 364 | while( db_step(&q)==SQLITE_ROW && nLine<nLimit ){ |
| 365 | const char *zId = db_column_text(&q, 1); |
| 366 | const char *zCom = db_column_text(&q, 3); |
| 367 | const char *zAuthor = db_column_text(&q, 4); |
| 368 | char *zPrefix = ""; |
| 369 | char *zSuffix = 0; |
| 370 | char *zDate; |
| 371 | int nChild = db_column_int(&q, 5); |
| 372 | int nParent = db_column_int(&q, 6); |
| 373 | const char *zTagList = db_column_text(&q, 7); |
| 374 | time_t ts; |
| 375 | |
| 376 | if( zTagList && zTagList[0]==0 ) zTagList = 0; |
| 377 | ts = (time_t)((db_column_double(&q,2) - 2440587.5)*86400.0); |
| 378 | zDate = cgi_rfc822_datestamp(ts); |
| 379 | |
| 380 | if( nParent>1 && nChild>1 ){ |
| 381 | zPrefix = "*MERGE/FORK* "; |
| @@ -365,20 +382,25 @@ | |
| 382 | }else if( nParent>1 ){ |
| 383 | zPrefix = "*MERGE* "; |
| 384 | }else if( nChild>1 ){ |
| 385 | zPrefix = "*FORK* "; |
| 386 | } |
| 387 | |
| 388 | if( zTagList ){ |
| 389 | zSuffix = mprintf(" (tags: %s)", zTagList); |
| 390 | } |
| 391 | |
| 392 | fossil_print("<item>"); |
| 393 | fossil_print("<title>%s%h%h</title>\n", zPrefix, zCom, zSuffix); |
| 394 | fossil_print("<link>%s/info/%s</link>\n", zBaseURL, zId); |
| 395 | fossil_print("<description>%s%h%h</description>\n", zPrefix, zCom, zSuffix); |
| 396 | fossil_print("<pubDate>%s</pubDate>\n", zDate); |
| 397 | fossil_print("<dc:creator>%h</dc:creator>\n", zAuthor); |
| 398 | fossil_print("<guid>%s/info/%s</guid>\n", g.zBaseURL, zId); |
| 399 | fossil_print("</item>\n"); |
| 400 | free(zDate); |
| 401 | free(zSuffix); |
| 402 | nLine++; |
| 403 | } |
| 404 | |
| 405 | db_finalize(&q); |
| 406 | fossil_print("</channel>\n"); |
| 407 |