Fossil SCM

Fix the annoying extra space in the attachment list. Minor doc update.

stephan 2026-05-23 08:59 UTC forum-attachments
Commit 0436eb5ce3961d6c9012e8dc5216bf9465cc4a7fed11e5a97cd28a6829895e14
2 files changed +5 -7 +1 -1
+5 -7
--- src/attach.c
+++ src/attach.c
@@ -757,13 +757,14 @@
757757
** Output HTML to show a list of attachments.
758758
*/
759759
void attachment_list(
760760
const char *zTarget, /* Object that things are attached to */
761761
const char *zHeader, /* Header to display with attachments */
762
- int flags /* ATTACHLIST_... flags */
762
+ const int flags /* ATTACHLIST_... flags */
763763
){
764764
int cnt = 0;
765
+ char szBuf[36] = {0}; /* scratchpad for attachment size value */
765766
const char * zLinkTgt = (ATTACHLIST_TARGET_BLANK & flags)
766767
? " target=\"_blank\"" : "";
767768
Stmt q;
768769
db_prepare(&q,
769770
"SELECT datetime(mtime,toLocal()), filename, user,"
@@ -798,19 +799,16 @@
798799
case CFTYPE_WIKI:
799800
default: zTypeArg = "page"; break;
800801
}
801802
@ <li>
802803
@ <a href="%R/artifact/%!S(zSrc)"%s(zLinkTgt)>%h(zFile)</a>
803
- @ [<a href="%R/attachdownload/%t(zFile)?%s(zTypeArg)=%t(zTarget)&file=%t(zFile)" \
804
- @ %s(zLinkTgt)>download</a>
805804
if( flags & ATTACHLIST_SIZE ){
806
- /* FIXME: this block causes us to interupt the @ lines and
807
- ** introduces an extra space before the closing ']'. */
808805
const int sz = db_int(0,"SELECT size FROM blob WHERE uuid=%Q", zSrc);
809
- @ %d(sz) bytes
806
+ sqlite3_snprintf(sizeof(szBuf), szBuf, " %d bytes", sz);
810807
}
811
- @ ]
808
+ @ [<a href="%R/attachdownload/%t(zFile)?%s(zTypeArg)=%t(zTarget)\
809
+ @&file=%t(zFile)%s(zLinkTgt)">download</a>%s(szBuf)]
812810
@ added by %h(zDispUser) on
813811
hyperlink_to_date(zDate, ".");
814812
@ [<a href="%R/ainfo/%!S(zUuid)"%s(zLinkTgt)>details</a>]
815813
@ </li>
816814
}
817815
--- src/attach.c
+++ src/attach.c
@@ -757,13 +757,14 @@
757 ** Output HTML to show a list of attachments.
758 */
759 void attachment_list(
760 const char *zTarget, /* Object that things are attached to */
761 const char *zHeader, /* Header to display with attachments */
762 int flags /* ATTACHLIST_... flags */
763 ){
764 int cnt = 0;
 
765 const char * zLinkTgt = (ATTACHLIST_TARGET_BLANK & flags)
766 ? " target=\"_blank\"" : "";
767 Stmt q;
768 db_prepare(&q,
769 "SELECT datetime(mtime,toLocal()), filename, user,"
@@ -798,19 +799,16 @@
798 case CFTYPE_WIKI:
799 default: zTypeArg = "page"; break;
800 }
801 @ <li>
802 @ <a href="%R/artifact/%!S(zSrc)"%s(zLinkTgt)>%h(zFile)</a>
803 @ [<a href="%R/attachdownload/%t(zFile)?%s(zTypeArg)=%t(zTarget)&file=%t(zFile)" \
804 @ %s(zLinkTgt)>download</a>
805 if( flags & ATTACHLIST_SIZE ){
806 /* FIXME: this block causes us to interupt the @ lines and
807 ** introduces an extra space before the closing ']'. */
808 const int sz = db_int(0,"SELECT size FROM blob WHERE uuid=%Q", zSrc);
809 @ %d(sz) bytes
810 }
811 @ ]
 
812 @ added by %h(zDispUser) on
813 hyperlink_to_date(zDate, ".");
814 @ [<a href="%R/ainfo/%!S(zUuid)"%s(zLinkTgt)>details</a>]
815 @ </li>
816 }
817
--- src/attach.c
+++ src/attach.c
@@ -757,13 +757,14 @@
757 ** Output HTML to show a list of attachments.
758 */
759 void attachment_list(
760 const char *zTarget, /* Object that things are attached to */
761 const char *zHeader, /* Header to display with attachments */
762 const int flags /* ATTACHLIST_... flags */
763 ){
764 int cnt = 0;
765 char szBuf[36] = {0}; /* scratchpad for attachment size value */
766 const char * zLinkTgt = (ATTACHLIST_TARGET_BLANK & flags)
767 ? " target=\"_blank\"" : "";
768 Stmt q;
769 db_prepare(&q,
770 "SELECT datetime(mtime,toLocal()), filename, user,"
@@ -798,19 +799,16 @@
799 case CFTYPE_WIKI:
800 default: zTypeArg = "page"; break;
801 }
802 @ <li>
803 @ <a href="%R/artifact/%!S(zSrc)"%s(zLinkTgt)>%h(zFile)</a>
 
 
804 if( flags & ATTACHLIST_SIZE ){
 
 
805 const int sz = db_int(0,"SELECT size FROM blob WHERE uuid=%Q", zSrc);
806 sqlite3_snprintf(sizeof(szBuf), szBuf, " %d bytes", sz);
807 }
808 @ [<a href="%R/attachdownload/%t(zFile)?%s(zTypeArg)=%t(zTarget)\
809 @&file=%t(zFile)%s(zLinkTgt)">download</a>%s(szBuf)]
810 @ added by %h(zDispUser) on
811 hyperlink_to_date(zDate, ".");
812 @ [<a href="%R/ainfo/%!S(zUuid)"%s(zLinkTgt)>details</a>]
813 @ </li>
814 }
815
+1 -1
--- src/schema.c
+++ src/schema.c
@@ -427,11 +427,11 @@
427427
@ CREATE TABLE attachment(
428428
@ attachid INTEGER PRIMARY KEY, -- Local id for this attachment
429429
@ isLatest BOOLEAN DEFAULT 0, -- True if this is the one to use
430430
@ mtime TIMESTAMP, -- Last changed. Julian day.
431431
@ src TEXT, -- Hash of the attachment. NULL to delete
432
-@ target TEXT, -- Object attached to. Wikiname or Tkt hash
432
+@ target TEXT, -- Object attached to. Wikiname or Tkt/Event/Forum post ID
433433
@ filename TEXT, -- Filename for the attachment
434434
@ comment TEXT, -- Comment associated with this attachment
435435
@ user TEXT -- Name of user adding attachment
436436
@ );
437437
@ CREATE INDEX attachment_idx1 ON attachment(target, filename, mtime);
438438
--- src/schema.c
+++ src/schema.c
@@ -427,11 +427,11 @@
427 @ CREATE TABLE attachment(
428 @ attachid INTEGER PRIMARY KEY, -- Local id for this attachment
429 @ isLatest BOOLEAN DEFAULT 0, -- True if this is the one to use
430 @ mtime TIMESTAMP, -- Last changed. Julian day.
431 @ src TEXT, -- Hash of the attachment. NULL to delete
432 @ target TEXT, -- Object attached to. Wikiname or Tkt hash
433 @ filename TEXT, -- Filename for the attachment
434 @ comment TEXT, -- Comment associated with this attachment
435 @ user TEXT -- Name of user adding attachment
436 @ );
437 @ CREATE INDEX attachment_idx1 ON attachment(target, filename, mtime);
438
--- src/schema.c
+++ src/schema.c
@@ -427,11 +427,11 @@
427 @ CREATE TABLE attachment(
428 @ attachid INTEGER PRIMARY KEY, -- Local id for this attachment
429 @ isLatest BOOLEAN DEFAULT 0, -- True if this is the one to use
430 @ mtime TIMESTAMP, -- Last changed. Julian day.
431 @ src TEXT, -- Hash of the attachment. NULL to delete
432 @ target TEXT, -- Object attached to. Wikiname or Tkt/Event/Forum post ID
433 @ filename TEXT, -- Filename for the attachment
434 @ comment TEXT, -- Comment associated with this attachment
435 @ user TEXT -- Name of user adding attachment
436 @ );
437 @ CREATE INDEX attachment_idx1 ON attachment(target, filename, mtime);
438

Keyboard Shortcuts

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