Fossil SCM

Add the "Links from other repositories" section on the /urllist page.

drh 2021-12-21 20:20 trunk
Commit 6916a058abd2645c9f628340bcfbe9114b4527d2976f6f5edd548e554ba6886a
1 file changed +43
+43
--- src/stat.c
+++ src/stat.c
@@ -505,10 +505,11 @@
505505
Stmt q;
506506
int cnt;
507507
int showAll = P("all")!=0;
508508
int nOmitted;
509509
sqlite3_int64 iNow;
510
+ char *zPriorRepo = 0;
510511
511512
login_check_credentials();
512513
if( !g.perm.Admin ){ login_needed(0); return; }
513514
514515
style_set_current_feature("stat");
@@ -590,10 +591,52 @@
590591
}
591592
db_finalize(&q);
592593
if( cnt ){
593594
@ </table>
594595
}
596
+
597
+ cnt = 0;
598
+ db_prepare(&q,
599
+ "SELECT"
600
+ " substr(name,6),"
601
+ " datetime(mtime,'unixepoch'),"
602
+ " json_extract(value,'$.type'),"
603
+ " json_extract(value,'$.src')\n"
604
+ "FROM config\n"
605
+ "WHERE name GLOB 'link:*'\n"
606
+ "AND json_valid(value)\n"
607
+ "ORDER BY 4, 2 DESC"
608
+ );
609
+ while( db_step(&q)==SQLITE_ROW ){
610
+ const char *zUrl = db_column_text(&q, 0);
611
+ const char *zType = db_column_text(&q, 2);
612
+ const char *zSrc = db_column_text(&q, 3);
613
+ if( zUrl==0 || zSrc==0 ) continue;
614
+ if( cnt++==0 ){
615
+ @ <div class="section">Links from other repositories</div>
616
+ @ <table border='0' width='100%%'>
617
+ }
618
+ if( zPriorRepo==0 || strcmp(zUrl,zSrc)!=0 ){
619
+ fossil_free(zPriorRepo);
620
+ zPriorRepo = fossil_strdup(zSrc);
621
+ @ <tr><td colspan="4">\
622
+ @ From <a href='%T(zSrc)'>%h(zSrc)</a>...</td></tr>
623
+ }
624
+ @ <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
625
+ @ <td width='90%%'><a href='%h(zUrl)'>%h(zUrl)</a></td>
626
+ if( zType ){
627
+ @ <td>&nbsp;(%h(zType))&nbsp;</td>
628
+ }else{
629
+ @ <td>&nbsp;</td>
630
+ }
631
+ @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
632
+ }
633
+ db_finalize(&q);
634
+ fossil_free(zPriorRepo);
635
+ if( cnt ){
636
+ @ </table>
637
+ }
595638
style_finish_page();
596639
}
597640
598641
/*
599642
** WEBPAGE: repo_schema
600643
--- src/stat.c
+++ src/stat.c
@@ -505,10 +505,11 @@
505 Stmt q;
506 int cnt;
507 int showAll = P("all")!=0;
508 int nOmitted;
509 sqlite3_int64 iNow;
 
510
511 login_check_credentials();
512 if( !g.perm.Admin ){ login_needed(0); return; }
513
514 style_set_current_feature("stat");
@@ -590,10 +591,52 @@
590 }
591 db_finalize(&q);
592 if( cnt ){
593 @ </table>
594 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
595 style_finish_page();
596 }
597
598 /*
599 ** WEBPAGE: repo_schema
600
--- src/stat.c
+++ src/stat.c
@@ -505,10 +505,11 @@
505 Stmt q;
506 int cnt;
507 int showAll = P("all")!=0;
508 int nOmitted;
509 sqlite3_int64 iNow;
510 char *zPriorRepo = 0;
511
512 login_check_credentials();
513 if( !g.perm.Admin ){ login_needed(0); return; }
514
515 style_set_current_feature("stat");
@@ -590,10 +591,52 @@
591 }
592 db_finalize(&q);
593 if( cnt ){
594 @ </table>
595 }
596
597 cnt = 0;
598 db_prepare(&q,
599 "SELECT"
600 " substr(name,6),"
601 " datetime(mtime,'unixepoch'),"
602 " json_extract(value,'$.type'),"
603 " json_extract(value,'$.src')\n"
604 "FROM config\n"
605 "WHERE name GLOB 'link:*'\n"
606 "AND json_valid(value)\n"
607 "ORDER BY 4, 2 DESC"
608 );
609 while( db_step(&q)==SQLITE_ROW ){
610 const char *zUrl = db_column_text(&q, 0);
611 const char *zType = db_column_text(&q, 2);
612 const char *zSrc = db_column_text(&q, 3);
613 if( zUrl==0 || zSrc==0 ) continue;
614 if( cnt++==0 ){
615 @ <div class="section">Links from other repositories</div>
616 @ <table border='0' width='100%%'>
617 }
618 if( zPriorRepo==0 || strcmp(zUrl,zSrc)!=0 ){
619 fossil_free(zPriorRepo);
620 zPriorRepo = fossil_strdup(zSrc);
621 @ <tr><td colspan="4">\
622 @ From <a href='%T(zSrc)'>%h(zSrc)</a>...</td></tr>
623 }
624 @ <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
625 @ <td width='90%%'><a href='%h(zUrl)'>%h(zUrl)</a></td>
626 if( zType ){
627 @ <td>&nbsp;(%h(zType))&nbsp;</td>
628 }else{
629 @ <td>&nbsp;</td>
630 }
631 @ <td><nobr>%h(db_column_text(&q,1))</nobr></td></tr>
632 }
633 db_finalize(&q);
634 fossil_free(zPriorRepo);
635 if( cnt ){
636 @ </table>
637 }
638 style_finish_page();
639 }
640
641 /*
642 ** WEBPAGE: repo_schema
643

Keyboard Shortcuts

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