Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Provide an "Expand" or "Collapse" button on long forum posts. The default threshold is 50em. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
cd9cb4d24ad6cfc12a0198ac46ba50f4 |
| User & Date: | drh 2020-07-09 19:09:16.566 |
Context
|
2020-07-09
| ||
| 20:39 | Added a tiny margin above the forum expand/collapse button. Docs and minor cleanups to the new forum JS code. Added a disabled, but potentially interesting, long-press handler in the forum code to toggle expand/collapse. ... (check-in: 8de6b9084a user: stephan tags: trunk) | |
| 19:09 | Provide an "Expand" or "Collapse" button on long forum posts. The default threshold is 50em. ... (check-in: cd9cb4d24a user: drh tags: trunk) | |
| 18:31 | Moved expand/collapse toggle to the bottom of the post, per forum feedback. That required changing it to a button because of CSS limitations. Fixed a few mis-used P tags in the FORM part of each post (P cannot hold a FORM). ... (Closed-Leaf check-in: eb392f9719 user: stephan tags: forum-expand-poc) | |
| 17:42 | Enhance the /timeline "bisect" and "bid" views so that they shows all unresolved checkins in between the innermost good and bad checkins. ... (check-in: 8a0fd6fb5c user: drh tags: trunk) | |
Changes
Changes to src/default.css.
| ︙ | ︙ | |||
762 763 764 765 766 767 768 |
}
div.forumHier, div.forumTime {
border: 1px solid black;
padding-left: 1ex;
padding-right: 1ex;
margin-top: 1ex;
}
| > > > > > > > > > > > > | | > > > > | 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
}
div.forumHier, div.forumTime {
border: 1px solid black;
padding-left: 1ex;
padding-right: 1ex;
margin-top: 1ex;
}
div.forumHier, div.forumTime, div.forumHierRoot {
display: flex;
flex-direction: column;
}
div.forumHier > div > form,
div.forumTime > div > form,
div.forumHierRoot > div > form {
margin: 0.5em 0;
}
button.forum-post-collapser {
align-self: flex-start;
}
div.forumPostBody{
max-height: 50em;
overflow: auto;
}
div.forumPostBody.expanded {
max-height: initial;
}
div.forumSel {
background-color: #cef;
}
div.forumObs {
color: #bbb;
}
#capabilitySummary {
text-align: center;
}
#capabilitySummary td {
padding-left: 3ex;
padding-right: 3ex;
}
|
| ︙ | ︙ |
Changes to src/forum.c.
| ︙ | ︙ | |||
400 401 402 403 404 405 406 |
}else{
zResult = fossil_strdup(zLogin);
}
db_reset(&q);
return zResult;
}
| < | 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
}else{
zResult = fossil_strdup(zLogin);
}
db_reset(&q);
return zResult;
}
/*
** Display all posts in a forum thread in chronological order
*/
static void forum_display_chronological(int froot, int target, int bRawMode){
ForumThread *pThread = forumthread_create(froot, 0);
ForumEntry *p;
int notAnon = login_is_individual();
|
| ︙ | ︙ | |||
483 484 485 486 487 488 489 |
zMimetype = pPost->zMimetype;
}
forum_render(0, zMimetype, pPost->zWiki, 0, 1);
}
if( g.perm.WrForum && p->pLeaf==0 ){
int sameUser = login_is_individual()
&& fossil_strcmp(pPost->zUser, g.zLogin)==0;
| | | | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
zMimetype = pPost->zMimetype;
}
forum_render(0, zMimetype, pPost->zWiki, 0, 1);
}
if( g.perm.WrForum && p->pLeaf==0 ){
int sameUser = login_is_individual()
&& fossil_strcmp(pPost->zUser, g.zLogin)==0;
@ <div><form action="%R/forumedit" method="POST">
@ <input type="hidden" name="fpid" value="%s(p->zUuid)">
if( !isPrivate ){
/* Reply and Edit are only available if the post has already
** been approved */
@ <input type="submit" name="reply" value="Reply">
if( g.perm.Admin || sameUser ){
@ <input type="submit" name="edit" value="Edit">
@ <input type="submit" name="nullout" value="Delete">
}
}else if( g.perm.ModForum ){
/* Provide moderators with moderation buttons for posts that
** are pending moderation */
@ <input type="submit" name="approve" value="Approve">
@ <input type="submit" name="reject" value="Reject">
generateTrustControls(pPost);
}else if( sameUser ){
/* A post that is pending moderation can be deleted by the
** person who originally submitted the post */
@ <input type="submit" name="reject" value="Delete">
}
@ </form></div>
}
manifest_destroy(pPost);
@ </div>
}
/* Undocumented "threadtable" query parameter causes thread table
** to be displayed for debugging purposes.
|
| ︙ | ︙ | |||
591 592 593 594 595 596 597 |
}else{
forum_render(0, bRawMode?"text/plain":pPost->zMimetype, pPost->zWiki,
0, 1);
}
if( g.perm.WrForum && p->pLeaf==0 ){
int sameUser = login_is_individual()
&& fossil_strcmp(pPost->zUser, g.zLogin)==0;
| | | | 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
}else{
forum_render(0, bRawMode?"text/plain":pPost->zMimetype, pPost->zWiki,
0, 1);
}
if( g.perm.WrForum && p->pLeaf==0 ){
int sameUser = login_is_individual()
&& fossil_strcmp(pPost->zUser, g.zLogin)==0;
@ <div><form action="%R/forumedit" method="POST">
@ <input type="hidden" name="fpid" value="%s(p->zUuid)">
if( !isPrivate ){
/* Reply and Edit are only available if the post has already
** been approved */
@ <input type="submit" name="reply" value="Reply">
if( g.perm.Admin || sameUser ){
@ <input type="submit" name="edit" value="Edit">
@ <input type="submit" name="nullout" value="Delete">
}
}else if( g.perm.ModForum ){
/* Provide moderators with moderation buttons for posts that
** are pending moderation */
@ <input type="submit" name="approve" value="Approve">
@ <input type="submit" name="reject" value="Reject">
generateTrustControls(pPost);
}else if( sameUser ){
/* A post that is pending moderation can be deleted by the
** person who originally submitted the post */
@ <input type="submit" name="reject" value="Delete">
}
@ </form></div>
}
manifest_destroy(pPost);
@ </div>
}
forumthread_delete(pThread);
}
|
| ︙ | ︙ | |||
717 718 719 720 721 722 723 |
sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0;
if( isPrivate && !g.perm.ModForum && !sameUser ){
@ <p><span class="modpending">Awaiting Moderator Approval</span></p>
}else{
forum_render(0, pPost->zMimetype, pPost->zWiki, 0, 1);
}
if( g.perm.WrForum ){
| | | > > > > > > > > > > > > > > > > > > | 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 |
sameUser = notAnon && fossil_strcmp(pPost->zUser, g.zLogin)==0;
if( isPrivate && !g.perm.ModForum && !sameUser ){
@ <p><span class="modpending">Awaiting Moderator Approval</span></p>
}else{
forum_render(0, pPost->zMimetype, pPost->zWiki, 0, 1);
}
if( g.perm.WrForum ){
@ <div><form action="%R/forumedit" method="POST">
@ <input type="hidden" name="fpid" value="%s(zUuid)">
if( !isPrivate ){
/* Reply and Edit are only available if the post has already
** been approved */
@ <input type="submit" name="reply" value="Reply">
if( g.perm.Admin || sameUser ){
@ <input type="submit" name="edit" value="Edit">
@ <input type="submit" name="nullout" value="Delete">
}
}else if( g.perm.ModForum ){
/* Provide moderators with moderation buttons for posts that
** are pending moderation */
@ <input type="submit" name="approve" value="Approve">
@ <input type="submit" name="reject" value="Reject">
generateTrustControls(pPost);
}else if( sameUser ){
/* A post that is pending moderation can be deleted by the
** person who originally submitted the post */
@ <input type="submit" name="reject" value="Delete">
}
@ </form></div>
}
manifest_destroy(pPost);
@ </div>
}
forumthread_delete(pThread);
return target;
}
/*
** The first time this is called, it emits SCRIPT tags to load various
** forum-related JavaScript. Ideally it should be called near the end
** of the page, immediately before the call to style_footer() (which
** closes the document's <BODY> and <HTML> tags). Calls after the first
** are a no-op.
*/
static void forum_emit_page_js(){
static int once = 0;
if(0==once){
once = 1;
style_load_js("forum.js");
style_emit_script_fossil_bootstrap(0);
style_emit_script_dom(0);
style_emit_script_builtin(0, "fossil.page.forumpost.js");
}
}
/*
** WEBPAGE: forumpost
**
** Show a single forum posting. The posting is shown in context with
** it's entire thread. The selected posting is enclosed within
** <div class='forumSel'>...</div>. Javascript is used to move the
|
| ︙ | ︙ | |||
875 876 877 878 879 880 881 |
style_submenu_element("Complete Thread", "%R/%s/%s?t=a", g.zPath, zName);
forum_display_history(froot, fpid, 1);
}else{
style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
style_submenu_element("Unformatted", "%R/%s/%s?t=r", g.zPath, zName);
forum_display_hierarchical(froot, fpid);
}
| | | 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 |
style_submenu_element("Complete Thread", "%R/%s/%s?t=a", g.zPath, zName);
forum_display_history(froot, fpid, 1);
}else{
style_submenu_element("Chronological", "%R/%s/%s?t=c", g.zPath, zName);
style_submenu_element("Unformatted", "%R/%s/%s?t=r", g.zPath, zName);
forum_display_hierarchical(froot, fpid);
}
forum_emit_page_js();
style_footer();
}
/*
** Return true if a forum post should be moderated.
*/
static int forum_need_moderation(void){
|
| ︙ | ︙ |
Changes to src/fossil.dom.js.
| ︙ | ︙ | |||
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
dom.pre = dom.createElemFactory('pre');
dom.header = dom.createElemFactory('header');
dom.footer = dom.createElemFactory('footer');
dom.section = dom.createElemFactory('section');
dom.span = dom.createElemFactory('span');
dom.strong = dom.createElemFactory('strong');
dom.em = dom.createElemFactory('em');
dom.img = function(src){
const e = dom.create('img');
if(src) e.setAttribute('src',src);
return e;
};
/**
Creates and returns a new anchor element with the given
| > | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
dom.pre = dom.createElemFactory('pre');
dom.header = dom.createElemFactory('header');
dom.footer = dom.createElemFactory('footer');
dom.section = dom.createElemFactory('section');
dom.span = dom.createElemFactory('span');
dom.strong = dom.createElemFactory('strong');
dom.em = dom.createElemFactory('em');
dom.label = dom.createElemFactory('label');
dom.img = function(src){
const e = dom.create('img');
if(src) e.setAttribute('src',src);
return e;
};
/**
Creates and returns a new anchor element with the given
|
| ︙ | ︙ |
Added src/fossil.page.forumpost.js.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
(function(F/*the fossil object*/){
"use strict";
/* JS code for /forumpage and friends. Requires fossil.dom. */
const P = fossil.page, D = fossil.dom;
F.onPageLoad(function(){
const scrollbarIsVisible = (e)=>e.scrollHeight > e.clientHeight;
const getButtonHandler = function(contentElem){
return function(ev){
const btn = ev.target;
const isExpanded = D.hasClass(contentElem,'expanded');
btn.innerText = isExpanded ? 'Expand...' : 'Collapse';
contentElem.classList.toggle('expanded');
};
};
const doCollapser = function(forumPostWrapper){
const content = forumPostWrapper.querySelector('div.forumPostBody');
if(!scrollbarIsVisible(content)) return;
const button = D.button('Expand...');
button.classList.add('forum-post-collapser');
button.addEventListener('click', getButtonHandler(content), false);
forumPostWrapper.insertBefore(button, content.nextSibling);
};
document.querySelectorAll(
'div.forumHier, div.forumTime, div.forumHierRoot'
).forEach(doCollapser)
});
})(window.fossil);
|
Changes to src/main.mk.
| ︙ | ︙ | |||
224 225 226 227 228 229 230 231 232 233 234 235 236 237 | $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/fossil.bootstrap.js \ $(SRCDIR)/fossil.confirmer.js \ $(SRCDIR)/fossil.dom.js \ $(SRCDIR)/fossil.fetch.js \ $(SRCDIR)/fossil.page.fileedit.js \ $(SRCDIR)/fossil.storage.js \ $(SRCDIR)/fossil.tabs.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ | > | 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/fossil.bootstrap.js \ $(SRCDIR)/fossil.confirmer.js \ $(SRCDIR)/fossil.dom.js \ $(SRCDIR)/fossil.fetch.js \ $(SRCDIR)/fossil.page.fileedit.js \ $(SRCDIR)/fossil.page.forumpost.js \ $(SRCDIR)/fossil.storage.js \ $(SRCDIR)/fossil.tabs.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ |
| ︙ | ︙ |
Changes to win/Makefile.mingw.
| ︙ | ︙ | |||
636 637 638 639 640 641 642 643 644 645 646 647 648 649 | $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/fossil.bootstrap.js \ $(SRCDIR)/fossil.confirmer.js \ $(SRCDIR)/fossil.dom.js \ $(SRCDIR)/fossil.fetch.js \ $(SRCDIR)/fossil.page.fileedit.js \ $(SRCDIR)/fossil.storage.js \ $(SRCDIR)/fossil.tabs.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ | > | 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/fossil.bootstrap.js \ $(SRCDIR)/fossil.confirmer.js \ $(SRCDIR)/fossil.dom.js \ $(SRCDIR)/fossil.fetch.js \ $(SRCDIR)/fossil.page.fileedit.js \ $(SRCDIR)/fossil.page.forumpost.js \ $(SRCDIR)/fossil.storage.js \ $(SRCDIR)/fossil.tabs.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ |
| ︙ | ︙ |
Changes to win/Makefile.msc.
| ︙ | ︙ | |||
557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
"$(SRCDIR)\diff.tcl" \
"$(SRCDIR)\forum.js" \
"$(SRCDIR)\fossil.bootstrap.js" \
"$(SRCDIR)\fossil.confirmer.js" \
"$(SRCDIR)\fossil.dom.js" \
"$(SRCDIR)\fossil.fetch.js" \
"$(SRCDIR)\fossil.page.fileedit.js" \
"$(SRCDIR)\fossil.storage.js" \
"$(SRCDIR)\fossil.tabs.js" \
"$(SRCDIR)\graph.js" \
"$(SRCDIR)\href.js" \
"$(SRCDIR)\login.js" \
"$(SRCDIR)\markdown.md" \
"$(SRCDIR)\menu.js" \
| > | 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
"$(SRCDIR)\diff.tcl" \
"$(SRCDIR)\forum.js" \
"$(SRCDIR)\fossil.bootstrap.js" \
"$(SRCDIR)\fossil.confirmer.js" \
"$(SRCDIR)\fossil.dom.js" \
"$(SRCDIR)\fossil.fetch.js" \
"$(SRCDIR)\fossil.page.fileedit.js" \
"$(SRCDIR)\fossil.page.forumpost.js" \
"$(SRCDIR)\fossil.storage.js" \
"$(SRCDIR)\fossil.tabs.js" \
"$(SRCDIR)\graph.js" \
"$(SRCDIR)\href.js" \
"$(SRCDIR)\login.js" \
"$(SRCDIR)\markdown.md" \
"$(SRCDIR)\menu.js" \
|
| ︙ | ︙ | |||
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 | echo "$(SRCDIR)\diff.tcl" >> $@ echo "$(SRCDIR)\forum.js" >> $@ echo "$(SRCDIR)\fossil.bootstrap.js" >> $@ echo "$(SRCDIR)\fossil.confirmer.js" >> $@ echo "$(SRCDIR)\fossil.dom.js" >> $@ echo "$(SRCDIR)\fossil.fetch.js" >> $@ echo "$(SRCDIR)\fossil.page.fileedit.js" >> $@ echo "$(SRCDIR)\fossil.storage.js" >> $@ echo "$(SRCDIR)\fossil.tabs.js" >> $@ echo "$(SRCDIR)\graph.js" >> $@ echo "$(SRCDIR)\href.js" >> $@ echo "$(SRCDIR)\login.js" >> $@ echo "$(SRCDIR)\markdown.md" >> $@ echo "$(SRCDIR)\menu.js" >> $@ | > | 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 | echo "$(SRCDIR)\diff.tcl" >> $@ echo "$(SRCDIR)\forum.js" >> $@ echo "$(SRCDIR)\fossil.bootstrap.js" >> $@ echo "$(SRCDIR)\fossil.confirmer.js" >> $@ echo "$(SRCDIR)\fossil.dom.js" >> $@ echo "$(SRCDIR)\fossil.fetch.js" >> $@ echo "$(SRCDIR)\fossil.page.fileedit.js" >> $@ echo "$(SRCDIR)\fossil.page.forumpost.js" >> $@ echo "$(SRCDIR)\fossil.storage.js" >> $@ echo "$(SRCDIR)\fossil.tabs.js" >> $@ echo "$(SRCDIR)\graph.js" >> $@ echo "$(SRCDIR)\href.js" >> $@ echo "$(SRCDIR)\login.js" >> $@ echo "$(SRCDIR)\markdown.md" >> $@ echo "$(SRCDIR)\menu.js" >> $@ |
| ︙ | ︙ |