Fossil SCM

Wrap the list of attachments displayed on technotes/events, tickets and wiki pages in their own 'section' HTML element with CSS class name 'attachlist'. Inspired by [forum:8da5a5d868 | forum thread 8da5a5d868].

stephan 2024-12-04 17:00 trunk merge
Commit 4f9ecd0392368b70ee139fbc1a0ae701c6ea7009046ef2f3b40e7fbbda398aee
+8 -1
--- src/attach.c
+++ src/attach.c
@@ -634,11 +634,12 @@
634634
/*
635635
** Output HTML to show a list of attachments.
636636
*/
637637
void attachment_list(
638638
const char *zTarget, /* Object that things are attached to */
639
- const char *zHeader /* Header to display with attachments */
639
+ const char *zHeader, /* Header to display with attachments */
640
+ int fHorizontalRule /* Insert <hr> separator above header */
640641
){
641642
int cnt = 0;
642643
Stmt q;
643644
db_prepare(&q,
644645
"SELECT datetime(mtime,toLocal()), filename, user,"
@@ -654,11 +655,16 @@
654655
const char *zUser = db_column_text(&q, 2);
655656
const char *zUuid = db_column_text(&q, 3);
656657
const char *zSrc = db_column_text(&q, 4);
657658
const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
658659
if( cnt==0 ){
660
+ @ <section class='attachlist'>
661
+ if( fHorizontalRule ){
662
+ @ <hr>
663
+ }
659664
@ %s(zHeader)
665
+ @ <ul>
660666
}
661667
cnt++;
662668
@ <li>
663669
@ %z(href("%R/artifact/%!S",zSrc))%h(zFile)</a>
664670
@ [<a href="%R/attachdownload/%t(zFile)?page=%t(zTarget)&file=%t(zFile)">download</a>]
@@ -667,10 +673,11 @@
667673
@ [%z(href("%R/ainfo/%!S",zUuid))details</a>]
668674
@ </li>
669675
}
670676
if( cnt ){
671677
@ </ul>
678
+ @ </section>
672679
}
673680
db_finalize(&q);
674681
675682
}
676683
677684
--- src/attach.c
+++ src/attach.c
@@ -634,11 +634,12 @@
634 /*
635 ** Output HTML to show a list of attachments.
636 */
637 void attachment_list(
638 const char *zTarget, /* Object that things are attached to */
639 const char *zHeader /* Header to display with attachments */
 
640 ){
641 int cnt = 0;
642 Stmt q;
643 db_prepare(&q,
644 "SELECT datetime(mtime,toLocal()), filename, user,"
@@ -654,11 +655,16 @@
654 const char *zUser = db_column_text(&q, 2);
655 const char *zUuid = db_column_text(&q, 3);
656 const char *zSrc = db_column_text(&q, 4);
657 const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
658 if( cnt==0 ){
 
 
 
 
659 @ %s(zHeader)
 
660 }
661 cnt++;
662 @ <li>
663 @ %z(href("%R/artifact/%!S",zSrc))%h(zFile)</a>
664 @ [<a href="%R/attachdownload/%t(zFile)?page=%t(zTarget)&file=%t(zFile)">download</a>]
@@ -667,10 +673,11 @@
667 @ [%z(href("%R/ainfo/%!S",zUuid))details</a>]
668 @ </li>
669 }
670 if( cnt ){
671 @ </ul>
 
672 }
673 db_finalize(&q);
674
675 }
676
677
--- src/attach.c
+++ src/attach.c
@@ -634,11 +634,12 @@
634 /*
635 ** Output HTML to show a list of attachments.
636 */
637 void attachment_list(
638 const char *zTarget, /* Object that things are attached to */
639 const char *zHeader, /* Header to display with attachments */
640 int fHorizontalRule /* Insert <hr> separator above header */
641 ){
642 int cnt = 0;
643 Stmt q;
644 db_prepare(&q,
645 "SELECT datetime(mtime,toLocal()), filename, user,"
@@ -654,11 +655,16 @@
655 const char *zUser = db_column_text(&q, 2);
656 const char *zUuid = db_column_text(&q, 3);
657 const char *zSrc = db_column_text(&q, 4);
658 const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
659 if( cnt==0 ){
660 @ <section class='attachlist'>
661 if( fHorizontalRule ){
662 @ <hr>
663 }
664 @ %s(zHeader)
665 @ <ul>
666 }
667 cnt++;
668 @ <li>
669 @ %z(href("%R/artifact/%!S",zSrc))%h(zFile)</a>
670 @ [<a href="%R/attachdownload/%t(zFile)?page=%t(zTarget)&file=%t(zFile)">download</a>]
@@ -667,10 +673,11 @@
673 @ [%z(href("%R/ainfo/%!S",zUuid))details</a>]
674 @ </li>
675 }
676 if( cnt ){
677 @ </ul>
678 @ </section>
679 }
680 db_finalize(&q);
681
682 }
683
684
+1 -1
--- src/event.c
+++ src/event.c
@@ -229,11 +229,11 @@
229229
}
230230
zFullId = db_text(0, "SELECT SUBSTR(tagname,7)"
231231
" FROM tag"
232232
" WHERE tagname GLOB 'event-%q*'",
233233
zId);
234
- attachment_list(zFullId, "<hr><h2>Attachments:</h2><ul>");
234
+ attachment_list(zFullId, "<h2>Attachments:</h2>", 1);
235235
document_emit_js();
236236
style_finish_page();
237237
manifest_destroy(pTNote);
238238
}
239239
240240
--- src/event.c
+++ src/event.c
@@ -229,11 +229,11 @@
229 }
230 zFullId = db_text(0, "SELECT SUBSTR(tagname,7)"
231 " FROM tag"
232 " WHERE tagname GLOB 'event-%q*'",
233 zId);
234 attachment_list(zFullId, "<hr><h2>Attachments:</h2><ul>");
235 document_emit_js();
236 style_finish_page();
237 manifest_destroy(pTNote);
238 }
239
240
--- src/event.c
+++ src/event.c
@@ -229,11 +229,11 @@
229 }
230 zFullId = db_text(0, "SELECT SUBSTR(tagname,7)"
231 " FROM tag"
232 " WHERE tagname GLOB 'event-%q*'",
233 zId);
234 attachment_list(zFullId, "<h2>Attachments:</h2>", 1);
235 document_emit_js();
236 style_finish_page();
237 manifest_destroy(pTNote);
238 }
239
240
+1 -1
--- src/tkt.c
+++ src/tkt.c
@@ -781,11 +781,11 @@
781781
782782
zFullName = db_text(0,
783783
"SELECT tkt_uuid FROM ticket"
784784
" WHERE tkt_uuid GLOB '%q*'", zUuid);
785785
if( zFullName ){
786
- attachment_list(zFullName, "<hr><h2>Attachments:</h2><ul>");
786
+ attachment_list(zFullName, "<h2>Attachments:</h2>", 1);
787787
}
788788
789789
style_finish_page();
790790
}
791791
792792
--- src/tkt.c
+++ src/tkt.c
@@ -781,11 +781,11 @@
781
782 zFullName = db_text(0,
783 "SELECT tkt_uuid FROM ticket"
784 " WHERE tkt_uuid GLOB '%q*'", zUuid);
785 if( zFullName ){
786 attachment_list(zFullName, "<hr><h2>Attachments:</h2><ul>");
787 }
788
789 style_finish_page();
790 }
791
792
--- src/tkt.c
+++ src/tkt.c
@@ -781,11 +781,11 @@
781
782 zFullName = db_text(0,
783 "SELECT tkt_uuid FROM ticket"
784 " WHERE tkt_uuid GLOB '%q*'", zUuid);
785 if( zFullName ){
786 attachment_list(zFullName, "<h2>Attachments:</h2>", 1);
787 }
788
789 style_finish_page();
790 }
791
792
+3 -3
--- src/wiki.c
+++ src/wiki.c
@@ -622,14 +622,14 @@
622622
wiki_render_by_mimetype(&wiki, zMimetype);
623623
blob_reset(&wiki);
624624
}
625625
manifest_destroy(pWiki);
626626
if( !isPopup ){
627
- char * zLabel = mprintf("<hr><h2><a href='%R/attachlist?name=%T'>"
628
- "Attachments</a>:</h2><ul>",
627
+ char * zLabel = mprintf("<h2><a href='%R/attachlist?page=%T'>"
628
+ "Attachments</a>:</h2>",
629629
zPageName);
630
- attachment_list(zPageName, zLabel);
630
+ attachment_list(zPageName, zLabel, 1);
631631
fossil_free(zLabel);
632632
document_emit_js(/*for optional pikchr support*/);
633633
style_finish_page();
634634
}
635635
}
636636
--- src/wiki.c
+++ src/wiki.c
@@ -622,14 +622,14 @@
622 wiki_render_by_mimetype(&wiki, zMimetype);
623 blob_reset(&wiki);
624 }
625 manifest_destroy(pWiki);
626 if( !isPopup ){
627 char * zLabel = mprintf("<hr><h2><a href='%R/attachlist?name=%T'>"
628 "Attachments</a>:</h2><ul>",
629 zPageName);
630 attachment_list(zPageName, zLabel);
631 fossil_free(zLabel);
632 document_emit_js(/*for optional pikchr support*/);
633 style_finish_page();
634 }
635 }
636
--- src/wiki.c
+++ src/wiki.c
@@ -622,14 +622,14 @@
622 wiki_render_by_mimetype(&wiki, zMimetype);
623 blob_reset(&wiki);
624 }
625 manifest_destroy(pWiki);
626 if( !isPopup ){
627 char * zLabel = mprintf("<h2><a href='%R/attachlist?page=%T'>"
628 "Attachments</a>:</h2>",
629 zPageName);
630 attachment_list(zPageName, zLabel, 1);
631 fossil_free(zLabel);
632 document_emit_js(/*for optional pikchr support*/);
633 style_finish_page();
634 }
635 }
636
+3 -3
--- src/wiki.c
+++ src/wiki.c
@@ -622,14 +622,14 @@
622622
wiki_render_by_mimetype(&wiki, zMimetype);
623623
blob_reset(&wiki);
624624
}
625625
manifest_destroy(pWiki);
626626
if( !isPopup ){
627
- char * zLabel = mprintf("<hr><h2><a href='%R/attachlist?name=%T'>"
628
- "Attachments</a>:</h2><ul>",
627
+ char * zLabel = mprintf("<h2><a href='%R/attachlist?page=%T'>"
628
+ "Attachments</a>:</h2>",
629629
zPageName);
630
- attachment_list(zPageName, zLabel);
630
+ attachment_list(zPageName, zLabel, 1);
631631
fossil_free(zLabel);
632632
document_emit_js(/*for optional pikchr support*/);
633633
style_finish_page();
634634
}
635635
}
636636
--- src/wiki.c
+++ src/wiki.c
@@ -622,14 +622,14 @@
622 wiki_render_by_mimetype(&wiki, zMimetype);
623 blob_reset(&wiki);
624 }
625 manifest_destroy(pWiki);
626 if( !isPopup ){
627 char * zLabel = mprintf("<hr><h2><a href='%R/attachlist?name=%T'>"
628 "Attachments</a>:</h2><ul>",
629 zPageName);
630 attachment_list(zPageName, zLabel);
631 fossil_free(zLabel);
632 document_emit_js(/*for optional pikchr support*/);
633 style_finish_page();
634 }
635 }
636
--- src/wiki.c
+++ src/wiki.c
@@ -622,14 +622,14 @@
622 wiki_render_by_mimetype(&wiki, zMimetype);
623 blob_reset(&wiki);
624 }
625 manifest_destroy(pWiki);
626 if( !isPopup ){
627 char * zLabel = mprintf("<h2><a href='%R/attachlist?page=%T'>"
628 "Attachments</a>:</h2>",
629 zPageName);
630 attachment_list(zPageName, zLabel, 1);
631 fossil_free(zLabel);
632 document_emit_js(/*for optional pikchr support*/);
633 style_finish_page();
634 }
635 }
636

Keyboard Shortcuts

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