Fossil SCM

Improve RSS performance for forum and technote content rendering.

vor0nwe 2026-03-06 23:16 rss-content
Commit a24637996d9edc69371eeae7bef1d2f2cfb46c3bbcb9c1d89cae7063b91aad3e
2 files changed +9 -25 +8 -4
+9 -25
--- src/rss.c
+++ src/rss.c
@@ -21,25 +21,11 @@
2121
#include <time.h>
2222
#include "rss.h"
2323
#include <assert.h>
2424
2525
void forum_render_to_html(struct Blob*, const char*, const char*);
26
-void technote_render_to_html(struct Blob*, int);
27
-
28
-/*
29
-** Return the technote id (event- tag suffix) for rid, or NULL.
30
-** Caller must free the returned string.
31
-*/
32
-static char *rss_technote_id(int rid){
33
- return db_text(0,
34
- "SELECT substr(tagname,7) FROM tag, tagxref"
35
- " WHERE tag.tagid=tagxref.tagid"
36
- " AND tagxref.rid=%d"
37
- " AND tagname GLOB 'event-*'",
38
- rid
39
- );
40
-}
26
+char *technote_render_to_html(struct Blob*, int);
4127
4228
/*
4329
** Append text to pOut, escaping any CDATA terminators.
4430
*/
4531
static void rss_cdata_append(Blob *pOut, const char *zIn, int nIn){
@@ -282,13 +268,13 @@
282268
blob_zero(&bSQL);
283269
blob_append_sql( &bSQL, "%s", zSQL1/*safe-for-%s*/ );
284270
if( bHasForum ){
285271
blob_append_sql(&bSQL,
286272
" AND (event.type!='f' OR event.objid IN ("
287
- "SELECT fpid FROM forumpost AS f "
288
- "WHERE NOT EXISTS(SELECT 1 FROM forumpost AS nx "
289
- "WHERE nx.fprev=f.fpid)))"
273
+ "SELECT fpid FROM forumpost "
274
+ "WHERE fpid NOT IN (SELECT fprev FROM forumpost WHERE fprev IS NOT NULL)"
275
+ "))"
290276
);
291277
}else{
292278
blob_append_sql(&bSQL, " AND event.type!='f'");
293279
}
294280
@@ -446,12 +432,11 @@
446432
blob_reset(&normalized);
447433
bForumContent = 1;
448434
}
449435
}
450436
}else if( zEType[0]=='e' ){
451
- zTechnoteId = rss_technote_id(rid);
452
- technote_render_to_html(&contentHtml, rid);
437
+ zTechnoteId = technote_render_to_html(&contentHtml, rid);
453438
if( blob_size(&contentHtml)>0 ){
454439
Blob normalized = BLOB_INITIALIZER;
455440
rss_make_abs_links(&normalized, blob_str(&base),
456441
blob_str(&top), blob_str(&contentHtml),
457442
blob_size(&contentHtml));
@@ -582,13 +567,13 @@
582567
blob_append( &bSQL, zSQL1, -1 );
583568
bHasForum = db_table_exists("repository","forumpost");
584569
if( bHasForum ){
585570
blob_append_sql(&bSQL,
586571
" AND (event.type!='f' OR event.objid IN ("
587
- "SELECT fpid FROM forumpost AS f "
588
- "WHERE NOT EXISTS(SELECT 1 FROM forumpost AS nx "
589
- "WHERE nx.fprev=f.fpid)))"
572
+ "SELECT fpid FROM forumpost "
573
+ "WHERE fpid NOT IN (SELECT fprev FROM forumpost WHERE fprev IS NOT NULL)"
574
+ "))"
590575
);
591576
}else{
592577
blob_append_sql(&bSQL, " AND event.type!='f'");
593578
}
594579
@@ -721,12 +706,11 @@
721706
blob_reset(&normalized);
722707
bForumContent = 1;
723708
}
724709
}
725710
}else if( zEType[0]=='e' ){
726
- zTechnoteId = rss_technote_id(rid);
727
- technote_render_to_html(&contentHtml, rid);
711
+ zTechnoteId = technote_render_to_html(&contentHtml, rid);
728712
if( blob_size(&contentHtml)>0 ){
729713
Blob normalized = BLOB_INITIALIZER;
730714
rss_make_abs_links(&normalized, blob_str(&base),
731715
blob_str(&top), blob_str(&contentHtml),
732716
blob_size(&contentHtml));
733717
--- src/rss.c
+++ src/rss.c
@@ -21,25 +21,11 @@
21 #include <time.h>
22 #include "rss.h"
23 #include <assert.h>
24
25 void forum_render_to_html(struct Blob*, const char*, const char*);
26 void technote_render_to_html(struct Blob*, int);
27
28 /*
29 ** Return the technote id (event- tag suffix) for rid, or NULL.
30 ** Caller must free the returned string.
31 */
32 static char *rss_technote_id(int rid){
33 return db_text(0,
34 "SELECT substr(tagname,7) FROM tag, tagxref"
35 " WHERE tag.tagid=tagxref.tagid"
36 " AND tagxref.rid=%d"
37 " AND tagname GLOB 'event-*'",
38 rid
39 );
40 }
41
42 /*
43 ** Append text to pOut, escaping any CDATA terminators.
44 */
45 static void rss_cdata_append(Blob *pOut, const char *zIn, int nIn){
@@ -282,13 +268,13 @@
282 blob_zero(&bSQL);
283 blob_append_sql( &bSQL, "%s", zSQL1/*safe-for-%s*/ );
284 if( bHasForum ){
285 blob_append_sql(&bSQL,
286 " AND (event.type!='f' OR event.objid IN ("
287 "SELECT fpid FROM forumpost AS f "
288 "WHERE NOT EXISTS(SELECT 1 FROM forumpost AS nx "
289 "WHERE nx.fprev=f.fpid)))"
290 );
291 }else{
292 blob_append_sql(&bSQL, " AND event.type!='f'");
293 }
294
@@ -446,12 +432,11 @@
446 blob_reset(&normalized);
447 bForumContent = 1;
448 }
449 }
450 }else if( zEType[0]=='e' ){
451 zTechnoteId = rss_technote_id(rid);
452 technote_render_to_html(&contentHtml, rid);
453 if( blob_size(&contentHtml)>0 ){
454 Blob normalized = BLOB_INITIALIZER;
455 rss_make_abs_links(&normalized, blob_str(&base),
456 blob_str(&top), blob_str(&contentHtml),
457 blob_size(&contentHtml));
@@ -582,13 +567,13 @@
582 blob_append( &bSQL, zSQL1, -1 );
583 bHasForum = db_table_exists("repository","forumpost");
584 if( bHasForum ){
585 blob_append_sql(&bSQL,
586 " AND (event.type!='f' OR event.objid IN ("
587 "SELECT fpid FROM forumpost AS f "
588 "WHERE NOT EXISTS(SELECT 1 FROM forumpost AS nx "
589 "WHERE nx.fprev=f.fpid)))"
590 );
591 }else{
592 blob_append_sql(&bSQL, " AND event.type!='f'");
593 }
594
@@ -721,12 +706,11 @@
721 blob_reset(&normalized);
722 bForumContent = 1;
723 }
724 }
725 }else if( zEType[0]=='e' ){
726 zTechnoteId = rss_technote_id(rid);
727 technote_render_to_html(&contentHtml, rid);
728 if( blob_size(&contentHtml)>0 ){
729 Blob normalized = BLOB_INITIALIZER;
730 rss_make_abs_links(&normalized, blob_str(&base),
731 blob_str(&top), blob_str(&contentHtml),
732 blob_size(&contentHtml));
733
--- src/rss.c
+++ src/rss.c
@@ -21,25 +21,11 @@
21 #include <time.h>
22 #include "rss.h"
23 #include <assert.h>
24
25 void forum_render_to_html(struct Blob*, const char*, const char*);
26 char *technote_render_to_html(struct Blob*, int);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
28 /*
29 ** Append text to pOut, escaping any CDATA terminators.
30 */
31 static void rss_cdata_append(Blob *pOut, const char *zIn, int nIn){
@@ -282,13 +268,13 @@
268 blob_zero(&bSQL);
269 blob_append_sql( &bSQL, "%s", zSQL1/*safe-for-%s*/ );
270 if( bHasForum ){
271 blob_append_sql(&bSQL,
272 " AND (event.type!='f' OR event.objid IN ("
273 "SELECT fpid FROM forumpost "
274 "WHERE fpid NOT IN (SELECT fprev FROM forumpost WHERE fprev IS NOT NULL)"
275 "))"
276 );
277 }else{
278 blob_append_sql(&bSQL, " AND event.type!='f'");
279 }
280
@@ -446,12 +432,11 @@
432 blob_reset(&normalized);
433 bForumContent = 1;
434 }
435 }
436 }else if( zEType[0]=='e' ){
437 zTechnoteId = technote_render_to_html(&contentHtml, rid);
 
438 if( blob_size(&contentHtml)>0 ){
439 Blob normalized = BLOB_INITIALIZER;
440 rss_make_abs_links(&normalized, blob_str(&base),
441 blob_str(&top), blob_str(&contentHtml),
442 blob_size(&contentHtml));
@@ -582,13 +567,13 @@
567 blob_append( &bSQL, zSQL1, -1 );
568 bHasForum = db_table_exists("repository","forumpost");
569 if( bHasForum ){
570 blob_append_sql(&bSQL,
571 " AND (event.type!='f' OR event.objid IN ("
572 "SELECT fpid FROM forumpost "
573 "WHERE fpid NOT IN (SELECT fprev FROM forumpost WHERE fprev IS NOT NULL)"
574 "))"
575 );
576 }else{
577 blob_append_sql(&bSQL, " AND event.type!='f'");
578 }
579
@@ -721,12 +706,11 @@
706 blob_reset(&normalized);
707 bForumContent = 1;
708 }
709 }
710 }else if( zEType[0]=='e' ){
711 zTechnoteId = technote_render_to_html(&contentHtml, rid);
 
712 if( blob_size(&contentHtml)>0 ){
713 Blob normalized = BLOB_INITIALIZER;
714 rss_make_abs_links(&normalized, blob_str(&base),
715 blob_str(&top), blob_str(&contentHtml),
716 blob_size(&contentHtml));
717
+8 -4
--- src/wiki.c
+++ src/wiki.c
@@ -2566,11 +2566,11 @@
25662566
const char *zContent,
25672567
int eDocSrc
25682568
);
25692569
25702570
/* Render a technote's content (rid) to HTML in an output blob. */
2571
-void technote_render_to_html(Blob *pOut, int rid);
2571
+char *technote_render_to_html(Blob *pOut, int rid);
25722572
#endif
25732573
25742574
/*
25752575
** Show the default Section label for an associated wiki page.
25762576
*/
@@ -2668,18 +2668,22 @@
26682668
blob_reset(&in);
26692669
}
26702670
26712671
/*
26722672
** Render technote content into an output blob as HTML.
2673
+** Return the technote id. The caller must free the result.
26732674
*/
2674
-void technote_render_to_html(Blob *pOut, int rid){
2675
+char *technote_render_to_html(Blob *pOut, int rid){
26752676
Manifest *pNote;
2676
- if( pOut==0 ) return;
2677
+ char *zEventId = 0;
2678
+ if( pOut==0 ) return 0;
26772679
pNote = manifest_get(rid, CFTYPE_EVENT, 0);
2678
- if( pNote==0 ) return;
2680
+ if( pNote==0 ) return 0;
2681
+ if( pNote->zEventId ) zEventId = mprintf("%s", pNote->zEventId);
26792682
wiki_convert_to_html(pOut, pNote->zMimetype, pNote->zWiki, DOCSRC_WIKI);
26802683
manifest_destroy(pNote);
2684
+ return zEventId;
26812685
}
26822686
26832687
/*
26842688
** Check to see if there exists a wiki page with a name zPrefix/zName.
26852689
** If there is, then render a <div class='section'>..</div> and
26862690
--- src/wiki.c
+++ src/wiki.c
@@ -2566,11 +2566,11 @@
2566 const char *zContent,
2567 int eDocSrc
2568 );
2569
2570 /* Render a technote's content (rid) to HTML in an output blob. */
2571 void technote_render_to_html(Blob *pOut, int rid);
2572 #endif
2573
2574 /*
2575 ** Show the default Section label for an associated wiki page.
2576 */
@@ -2668,18 +2668,22 @@
2668 blob_reset(&in);
2669 }
2670
2671 /*
2672 ** Render technote content into an output blob as HTML.
 
2673 */
2674 void technote_render_to_html(Blob *pOut, int rid){
2675 Manifest *pNote;
2676 if( pOut==0 ) return;
 
2677 pNote = manifest_get(rid, CFTYPE_EVENT, 0);
2678 if( pNote==0 ) return;
 
2679 wiki_convert_to_html(pOut, pNote->zMimetype, pNote->zWiki, DOCSRC_WIKI);
2680 manifest_destroy(pNote);
 
2681 }
2682
2683 /*
2684 ** Check to see if there exists a wiki page with a name zPrefix/zName.
2685 ** If there is, then render a <div class='section'>..</div> and
2686
--- src/wiki.c
+++ src/wiki.c
@@ -2566,11 +2566,11 @@
2566 const char *zContent,
2567 int eDocSrc
2568 );
2569
2570 /* Render a technote's content (rid) to HTML in an output blob. */
2571 char *technote_render_to_html(Blob *pOut, int rid);
2572 #endif
2573
2574 /*
2575 ** Show the default Section label for an associated wiki page.
2576 */
@@ -2668,18 +2668,22 @@
2668 blob_reset(&in);
2669 }
2670
2671 /*
2672 ** Render technote content into an output blob as HTML.
2673 ** Return the technote id. The caller must free the result.
2674 */
2675 char *technote_render_to_html(Blob *pOut, int rid){
2676 Manifest *pNote;
2677 char *zEventId = 0;
2678 if( pOut==0 ) return 0;
2679 pNote = manifest_get(rid, CFTYPE_EVENT, 0);
2680 if( pNote==0 ) return 0;
2681 if( pNote->zEventId ) zEventId = mprintf("%s", pNote->zEventId);
2682 wiki_convert_to_html(pOut, pNote->zMimetype, pNote->zWiki, DOCSRC_WIKI);
2683 manifest_destroy(pNote);
2684 return zEventId;
2685 }
2686
2687 /*
2688 ** Check to see if there exists a wiki page with a name zPrefix/zName.
2689 ** If there is, then render a <div class='section'>..</div> and
2690

Keyboard Shortcuts

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