Fossil

Check-in [4f9ecd03]
Login

Check-in [4f9ecd03]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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 thread 8da5a5d868.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4f9ecd0392368b70ee139fbc1a0ae701c6ea7009046ef2f3b40e7fbbda398aee
User & Date: stephan 2024-12-04 17:00:55
Context
2024-12-04
18:49
Improved controls at the top of the --tk merge information GUI. ... (check-in: f8932be5 user: drh tags: trunk)
17:00
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 thread 8da5a5d868. ... (check-in: 4f9ecd03 user: stephan tags: trunk)
15:59
Fix a mis-quoted DOM element attribute, as reported in forum post 5bdbb8b949. ... (check-in: f96a3ba7 user: stephan tags: trunk)
2024-11-27
17:07
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 thread 8da5a5d868. ... (Closed-Leaf check-in: b111adbe user: florian tags: attachlist-html-section)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/attach.c.
632
633
634
635
636
637
638
639

640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658




659

660
661
662
663
664
665
666
667
668
669
670
671

672
673
674
675
676
677
678
}

/*
** Output HTML to show a list of attachments.
*/
void attachment_list(
  const char *zTarget,   /* Object that things are attached to */
  const char *zHeader    /* Header to display with attachments */

){
  int cnt = 0;
  Stmt q;
  db_prepare(&q,
     "SELECT datetime(mtime,toLocal()), filename, user,"
     "       (SELECT uuid FROM blob WHERE rid=attachid), src"
     "  FROM attachment"
     " WHERE isLatest AND src!='' AND target=%Q"
     " ORDER BY mtime DESC",
     zTarget
  );
  while( db_step(&q)==SQLITE_ROW ){
    const char *zDate = db_column_text(&q, 0);
    const char *zFile = db_column_text(&q, 1);
    const char *zUser = db_column_text(&q, 2);
    const char *zUuid = db_column_text(&q, 3);
    const char *zSrc = db_column_text(&q, 4);
    const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
    if( cnt==0 ){




      @ %s(zHeader)

    }
    cnt++;
    @ <li>
    @ %z(href("%R/artifact/%!S",zSrc))%h(zFile)</a>
    @ [<a href="%R/attachdownload/%t(zFile)?page=%t(zTarget)&file=%t(zFile)">download</a>]
    @ added by %h(zDispUser) on
    hyperlink_to_date(zDate, ".");
    @ [%z(href("%R/ainfo/%!S",zUuid))details</a>]
    @ </li>
  }
  if( cnt ){
    @ </ul>

  }
  db_finalize(&q);

}

/*
** COMMAND: attachment*







|
>



















>
>
>
>

>












>







632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
}

/*
** Output HTML to show a list of attachments.
*/
void attachment_list(
  const char *zTarget,   /* Object that things are attached to */
  const char *zHeader,   /* Header to display with attachments */
  int fHorizontalRule    /* Insert <hr> separator above header */
){
  int cnt = 0;
  Stmt q;
  db_prepare(&q,
     "SELECT datetime(mtime,toLocal()), filename, user,"
     "       (SELECT uuid FROM blob WHERE rid=attachid), src"
     "  FROM attachment"
     " WHERE isLatest AND src!='' AND target=%Q"
     " ORDER BY mtime DESC",
     zTarget
  );
  while( db_step(&q)==SQLITE_ROW ){
    const char *zDate = db_column_text(&q, 0);
    const char *zFile = db_column_text(&q, 1);
    const char *zUser = db_column_text(&q, 2);
    const char *zUuid = db_column_text(&q, 3);
    const char *zSrc = db_column_text(&q, 4);
    const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
    if( cnt==0 ){
      @ <section class='attachlist'>
      if( fHorizontalRule ){
        @ <hr>
      }
      @ %s(zHeader)
      @ <ul>
    }
    cnt++;
    @ <li>
    @ %z(href("%R/artifact/%!S",zSrc))%h(zFile)</a>
    @ [<a href="%R/attachdownload/%t(zFile)?page=%t(zTarget)&file=%t(zFile)">download</a>]
    @ added by %h(zDispUser) on
    hyperlink_to_date(zDate, ".");
    @ [%z(href("%R/ainfo/%!S",zUuid))details</a>]
    @ </li>
  }
  if( cnt ){
    @ </ul>
    @ </section>
  }
  db_finalize(&q);

}

/*
** COMMAND: attachment*
Changes to src/event.c.
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
    @ %h(blob_str(&fullbody))
    @ </pre>
  }
  zFullId = db_text(0, "SELECT SUBSTR(tagname,7)"
                       "  FROM tag"
                       " WHERE tagname GLOB 'event-%q*'",
                    zId);
  attachment_list(zFullId, "<hr><h2>Attachments:</h2><ul>");
  document_emit_js();
  style_finish_page();
  manifest_destroy(pTNote);
}

/*
** Add or update a new tech note to the repository.  rid is id of







|







227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
    @ %h(blob_str(&fullbody))
    @ </pre>
  }
  zFullId = db_text(0, "SELECT SUBSTR(tagname,7)"
                       "  FROM tag"
                       " WHERE tagname GLOB 'event-%q*'",
                    zId);
  attachment_list(zFullId, "<h2>Attachments:</h2>", 1);
  document_emit_js();
  style_finish_page();
  manifest_destroy(pTNote);
}

/*
** Add or update a new tech note to the repository.  rid is id of
Changes to src/tkt.c.
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
  Th_Render(zScript);
  if( g.thTrace ) Th_Trace("END_TKTVIEW<br>\n", -1);

  zFullName = db_text(0,
       "SELECT tkt_uuid FROM ticket"
       " WHERE tkt_uuid GLOB '%q*'", zUuid);
  if( zFullName ){
    attachment_list(zFullName, "<hr><h2>Attachments:</h2><ul>");
  }

  style_finish_page();
}

/*
** TH1 command: append_field FIELD STRING







|







779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
  Th_Render(zScript);
  if( g.thTrace ) Th_Trace("END_TKTVIEW<br>\n", -1);

  zFullName = db_text(0,
       "SELECT tkt_uuid FROM ticket"
       " WHERE tkt_uuid GLOB '%q*'", zUuid);
  if( zFullName ){
    attachment_list(zFullName, "<h2>Attachments:</h2>", 1);
  }

  style_finish_page();
}

/*
** TH1 command: append_field FIELD STRING
Changes to src/wiki.c.
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
    blob_init(&wiki, zBody, -1);
    safe_html_context(DOCSRC_WIKI);
    wiki_render_by_mimetype(&wiki, zMimetype);
    blob_reset(&wiki);
  }
  manifest_destroy(pWiki);
  if( !isPopup ){
    char * zLabel = mprintf("<hr><h2><a href='%R/attachlist?name=%T'>"
                            "Attachments</a>:</h2><ul>",
                            zPageName);
    attachment_list(zPageName, zLabel);
    fossil_free(zLabel);
    document_emit_js(/*for optional pikchr support*/);
    style_finish_page();
  }
}

/*







|
|

|







620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
    blob_init(&wiki, zBody, -1);
    safe_html_context(DOCSRC_WIKI);
    wiki_render_by_mimetype(&wiki, zMimetype);
    blob_reset(&wiki);
  }
  manifest_destroy(pWiki);
  if( !isPopup ){
    char * zLabel = mprintf("<h2><a href='%R/attachlist?page=%T'>"
                            "Attachments</a>:</h2>",
                            zPageName);
    attachment_list(zPageName, zLabel, 1);
    fossil_free(zLabel);
    document_emit_js(/*for optional pikchr support*/);
    style_finish_page();
  }
}

/*