Fossil SCM

Separate /forumpost and /forumthread pages.

drh 2018-07-27 13:52 UTC forum-v2
Commit 2dfb887310cf6313bba6fd2c62694adabc0a2b9f3fbaf48fcc98c8fecc55787c
1 file changed +32 -12
+32 -12
--- src/forum.c
+++ src/forum.c
@@ -287,29 +287,29 @@
287287
}
288288
zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate);
289289
@ <p>By %h(pPost->zUser) on %h(zDate) (%d(p->fpid))
290290
fossil_free(zDate);
291291
if( p->pEdit ){
292
- @ edit of %z(href("%R/forumthread/%S?t",p->pEdit->zUuid))%d(p->fprev)</a>
292
+ @ edit of %z(href("%R/forumpost/%S?t",p->pEdit->zUuid))%d(p->fprev)</a>
293293
}
294294
if( p->firt ){
295295
ForumEntry *pIrt = p->pPrev;
296296
while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev;
297297
if( pIrt ){
298
- @ reply to %z(href("%R/forumthread/%S?t",pIrt->zUuid))%d(p->firt)</a>
298
+ @ reply to %z(href("%R/forumpost/%S?t",pIrt->zUuid))%d(p->firt)</a>
299299
}
300300
}
301301
if( p->pLeaf ){
302
- @ updated by %z(href("%R/forumthread/%S?t",p->pLeaf->zUuid))\
302
+ @ updated by %z(href("%R/forumpost/%S?t",p->pLeaf->zUuid))\
303303
@ %d(p->pLeaf->fpid)</a>
304304
}
305305
if( g.perm.Debug ){
306306
@ <span class="debug">\
307307
@ <a href="%R/artifact/%h(p->zUuid)">artifact</a></span>
308308
}
309309
if( p->fpid!=target ){
310
- @ %z(href("%R/forumthread/%S?t",p->zUuid))[link]</a>
310
+ @ %z(href("%R/forumpost/%S?t",p->zUuid))[link]</a>
311311
}
312312
forum_render(0, pPost->zMimetype, pPost->zWiki, 0);
313313
if( g.perm.WrForum && p->pLeaf==0 ){
314314
int sameUser = login_is_individual()
315315
&& fossil_strcmp(pPost->zUser, g.zLogin)==0;
@@ -405,11 +405,11 @@
405405
@ <a href="%R/artifact/%h(p->pLeaf->zUuid)">(%d(fpid))</a></span>
406406
}
407407
manifest_destroy(pOPost);
408408
}
409409
if( fpid!=target ){
410
- @ %z(href("%R/forumthread/%S",zUuid))[link]</a>
410
+ @ %z(href("%R/forumpost/%S",zUuid))[link]</a>
411411
}
412412
forum_render(0, pPost->zMimetype, pPost->zWiki, 0);
413413
if( g.perm.WrForum ){
414414
int sameUser = login_is_individual()
415415
&& fossil_strcmp(pPost->zUser, g.zLogin)==0;
@@ -440,19 +440,38 @@
440440
@ </div>
441441
}
442442
forumthread_delete(pThread);
443443
return target;
444444
}
445
+
446
+/*
447
+** WEBPAGE: forumpost
448
+**
449
+** Show a single forum posting. The posting is shown in context with
450
+** it's entire thread. The selected posting is enclosed within
451
+** <div class='forumSel'>...</div>. Javascript is used to move the
452
+** selected posting into view after the page loads.
453
+**
454
+** Query parameters:
455
+**
456
+** name=X REQUIRED. The hash of the post to display
457
+** t Show a chronologic listing instead of hierarchical
458
+*/
459
+void forumpost_page(void){
460
+ forumthread_page();
461
+}
445462
446463
/*
447464
** WEBPAGE: forumthread
448465
**
449466
** Show all forum messages associated with a particular message thread.
467
+** The result is basically the same as /forumpost except that none of
468
+** the postings in the thread are selected.
450469
**
451470
** Query parameters:
452471
**
453
-** name=X The hash of the first post of the thread. REQUIRED
472
+** name=X REQUIRED. The hash of any post of the thread.
454473
** t Show a chronologic listing instead of hierarchical
455474
*/
456475
void forumthread_page(void){
457476
int fpid;
458477
int froot;
@@ -472,18 +491,19 @@
472491
style_header("Forum");
473492
froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
474493
if( froot==0 ){
475494
webpage_error("Not a forum post: \"%s\"", zName);
476495
}
496
+ if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0;
477497
if( P("t") ){
478498
if( g.perm.Debug ){
479
- style_submenu_element("Hierarchical", "%R/forumthread/%s", zName);
499
+ style_submenu_element("Hierarchical", "%R/%s/%s", g.zPath, zName);
480500
}
481501
forum_display_chronological(froot, fpid);
482502
}else{
483503
if( g.perm.Debug ){
484
- style_submenu_element("Chronological", "%R/forumthread/%s?t", zName);
504
+ style_submenu_element("Chronological", "%R/%s/%s?t", g.zPath, zName);
485505
}
486506
forum_display_hierarchical(froot, fpid);
487507
}
488508
style_load_js("forum.js");
489509
style_footer();
@@ -587,11 +607,11 @@
587607
@ </div>
588608
blob_reset(&x);
589609
return 0;
590610
}else{
591611
int nrid = wiki_put(&x, 0, forum_need_moderation());
592
- cgi_redirectf("%R/forumthread/%S", rid_to_uuid(nrid));
612
+ cgi_redirectf("%R/forumpost/%S", rid_to_uuid(nrid));
593613
return 1;
594614
}
595615
}
596616
597617
/*
@@ -681,23 +701,23 @@
681701
fpid = symbolic_name_to_rid(PD("fpid",""), "f");
682702
if( fpid<=0 || (pPost = manifest_get(fpid, CFTYPE_FORUM, 0))==0 ){
683703
webpage_error("Missing or invalid fpid query parameter");
684704
}
685705
if( P("cancel") ){
686
- cgi_redirectf("%R/forumthread/%S",P("fpid"));
706
+ cgi_redirectf("%R/forumpost/%S",P("fpid"));
687707
return;
688708
}
689709
isCsrfSafe = cgi_csrf_safe(1);
690710
if( g.perm.ModForum && isCsrfSafe ){
691711
if( P("approve") ){
692712
moderation_approve(fpid);
693
- cgi_redirectf("%R/forumthread/%S",P("fpid"));
713
+ cgi_redirectf("%R/forumpost/%S",P("fpid"));
694714
return;
695715
}
696716
if( P("reject") ){
697717
moderation_disapprove(fpid);
698
- cgi_redirectf("%R/forumthread/%S",P("fpid"));
718
+ cgi_redirectf("%R/forumpost/%S",P("fpid"));
699719
return;
700720
}
701721
}
702722
isDelete = P("nullout")!=0;
703723
if( P("submit") && isCsrfSafe ){
704724
--- src/forum.c
+++ src/forum.c
@@ -287,29 +287,29 @@
287 }
288 zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate);
289 @ <p>By %h(pPost->zUser) on %h(zDate) (%d(p->fpid))
290 fossil_free(zDate);
291 if( p->pEdit ){
292 @ edit of %z(href("%R/forumthread/%S?t",p->pEdit->zUuid))%d(p->fprev)</a>
293 }
294 if( p->firt ){
295 ForumEntry *pIrt = p->pPrev;
296 while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev;
297 if( pIrt ){
298 @ reply to %z(href("%R/forumthread/%S?t",pIrt->zUuid))%d(p->firt)</a>
299 }
300 }
301 if( p->pLeaf ){
302 @ updated by %z(href("%R/forumthread/%S?t",p->pLeaf->zUuid))\
303 @ %d(p->pLeaf->fpid)</a>
304 }
305 if( g.perm.Debug ){
306 @ <span class="debug">\
307 @ <a href="%R/artifact/%h(p->zUuid)">artifact</a></span>
308 }
309 if( p->fpid!=target ){
310 @ %z(href("%R/forumthread/%S?t",p->zUuid))[link]</a>
311 }
312 forum_render(0, pPost->zMimetype, pPost->zWiki, 0);
313 if( g.perm.WrForum && p->pLeaf==0 ){
314 int sameUser = login_is_individual()
315 && fossil_strcmp(pPost->zUser, g.zLogin)==0;
@@ -405,11 +405,11 @@
405 @ <a href="%R/artifact/%h(p->pLeaf->zUuid)">(%d(fpid))</a></span>
406 }
407 manifest_destroy(pOPost);
408 }
409 if( fpid!=target ){
410 @ %z(href("%R/forumthread/%S",zUuid))[link]</a>
411 }
412 forum_render(0, pPost->zMimetype, pPost->zWiki, 0);
413 if( g.perm.WrForum ){
414 int sameUser = login_is_individual()
415 && fossil_strcmp(pPost->zUser, g.zLogin)==0;
@@ -440,19 +440,38 @@
440 @ </div>
441 }
442 forumthread_delete(pThread);
443 return target;
444 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
446 /*
447 ** WEBPAGE: forumthread
448 **
449 ** Show all forum messages associated with a particular message thread.
 
 
450 **
451 ** Query parameters:
452 **
453 ** name=X The hash of the first post of the thread. REQUIRED
454 ** t Show a chronologic listing instead of hierarchical
455 */
456 void forumthread_page(void){
457 int fpid;
458 int froot;
@@ -472,18 +491,19 @@
472 style_header("Forum");
473 froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
474 if( froot==0 ){
475 webpage_error("Not a forum post: \"%s\"", zName);
476 }
 
477 if( P("t") ){
478 if( g.perm.Debug ){
479 style_submenu_element("Hierarchical", "%R/forumthread/%s", zName);
480 }
481 forum_display_chronological(froot, fpid);
482 }else{
483 if( g.perm.Debug ){
484 style_submenu_element("Chronological", "%R/forumthread/%s?t", zName);
485 }
486 forum_display_hierarchical(froot, fpid);
487 }
488 style_load_js("forum.js");
489 style_footer();
@@ -587,11 +607,11 @@
587 @ </div>
588 blob_reset(&x);
589 return 0;
590 }else{
591 int nrid = wiki_put(&x, 0, forum_need_moderation());
592 cgi_redirectf("%R/forumthread/%S", rid_to_uuid(nrid));
593 return 1;
594 }
595 }
596
597 /*
@@ -681,23 +701,23 @@
681 fpid = symbolic_name_to_rid(PD("fpid",""), "f");
682 if( fpid<=0 || (pPost = manifest_get(fpid, CFTYPE_FORUM, 0))==0 ){
683 webpage_error("Missing or invalid fpid query parameter");
684 }
685 if( P("cancel") ){
686 cgi_redirectf("%R/forumthread/%S",P("fpid"));
687 return;
688 }
689 isCsrfSafe = cgi_csrf_safe(1);
690 if( g.perm.ModForum && isCsrfSafe ){
691 if( P("approve") ){
692 moderation_approve(fpid);
693 cgi_redirectf("%R/forumthread/%S",P("fpid"));
694 return;
695 }
696 if( P("reject") ){
697 moderation_disapprove(fpid);
698 cgi_redirectf("%R/forumthread/%S",P("fpid"));
699 return;
700 }
701 }
702 isDelete = P("nullout")!=0;
703 if( P("submit") && isCsrfSafe ){
704
--- src/forum.c
+++ src/forum.c
@@ -287,29 +287,29 @@
287 }
288 zDate = db_text(0, "SELECT datetime(%.17g)", pPost->rDate);
289 @ <p>By %h(pPost->zUser) on %h(zDate) (%d(p->fpid))
290 fossil_free(zDate);
291 if( p->pEdit ){
292 @ edit of %z(href("%R/forumpost/%S?t",p->pEdit->zUuid))%d(p->fprev)</a>
293 }
294 if( p->firt ){
295 ForumEntry *pIrt = p->pPrev;
296 while( pIrt && pIrt->fpid!=p->firt ) pIrt = pIrt->pPrev;
297 if( pIrt ){
298 @ reply to %z(href("%R/forumpost/%S?t",pIrt->zUuid))%d(p->firt)</a>
299 }
300 }
301 if( p->pLeaf ){
302 @ updated by %z(href("%R/forumpost/%S?t",p->pLeaf->zUuid))\
303 @ %d(p->pLeaf->fpid)</a>
304 }
305 if( g.perm.Debug ){
306 @ <span class="debug">\
307 @ <a href="%R/artifact/%h(p->zUuid)">artifact</a></span>
308 }
309 if( p->fpid!=target ){
310 @ %z(href("%R/forumpost/%S?t",p->zUuid))[link]</a>
311 }
312 forum_render(0, pPost->zMimetype, pPost->zWiki, 0);
313 if( g.perm.WrForum && p->pLeaf==0 ){
314 int sameUser = login_is_individual()
315 && fossil_strcmp(pPost->zUser, g.zLogin)==0;
@@ -405,11 +405,11 @@
405 @ <a href="%R/artifact/%h(p->pLeaf->zUuid)">(%d(fpid))</a></span>
406 }
407 manifest_destroy(pOPost);
408 }
409 if( fpid!=target ){
410 @ %z(href("%R/forumpost/%S",zUuid))[link]</a>
411 }
412 forum_render(0, pPost->zMimetype, pPost->zWiki, 0);
413 if( g.perm.WrForum ){
414 int sameUser = login_is_individual()
415 && fossil_strcmp(pPost->zUser, g.zLogin)==0;
@@ -440,19 +440,38 @@
440 @ </div>
441 }
442 forumthread_delete(pThread);
443 return target;
444 }
445
446 /*
447 ** WEBPAGE: forumpost
448 **
449 ** Show a single forum posting. The posting is shown in context with
450 ** it's entire thread. The selected posting is enclosed within
451 ** <div class='forumSel'>...</div>. Javascript is used to move the
452 ** selected posting into view after the page loads.
453 **
454 ** Query parameters:
455 **
456 ** name=X REQUIRED. The hash of the post to display
457 ** t Show a chronologic listing instead of hierarchical
458 */
459 void forumpost_page(void){
460 forumthread_page();
461 }
462
463 /*
464 ** WEBPAGE: forumthread
465 **
466 ** Show all forum messages associated with a particular message thread.
467 ** The result is basically the same as /forumpost except that none of
468 ** the postings in the thread are selected.
469 **
470 ** Query parameters:
471 **
472 ** name=X REQUIRED. The hash of any post of the thread.
473 ** t Show a chronologic listing instead of hierarchical
474 */
475 void forumthread_page(void){
476 int fpid;
477 int froot;
@@ -472,18 +491,19 @@
491 style_header("Forum");
492 froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid);
493 if( froot==0 ){
494 webpage_error("Not a forum post: \"%s\"", zName);
495 }
496 if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0;
497 if( P("t") ){
498 if( g.perm.Debug ){
499 style_submenu_element("Hierarchical", "%R/%s/%s", g.zPath, zName);
500 }
501 forum_display_chronological(froot, fpid);
502 }else{
503 if( g.perm.Debug ){
504 style_submenu_element("Chronological", "%R/%s/%s?t", g.zPath, zName);
505 }
506 forum_display_hierarchical(froot, fpid);
507 }
508 style_load_js("forum.js");
509 style_footer();
@@ -587,11 +607,11 @@
607 @ </div>
608 blob_reset(&x);
609 return 0;
610 }else{
611 int nrid = wiki_put(&x, 0, forum_need_moderation());
612 cgi_redirectf("%R/forumpost/%S", rid_to_uuid(nrid));
613 return 1;
614 }
615 }
616
617 /*
@@ -681,23 +701,23 @@
701 fpid = symbolic_name_to_rid(PD("fpid",""), "f");
702 if( fpid<=0 || (pPost = manifest_get(fpid, CFTYPE_FORUM, 0))==0 ){
703 webpage_error("Missing or invalid fpid query parameter");
704 }
705 if( P("cancel") ){
706 cgi_redirectf("%R/forumpost/%S",P("fpid"));
707 return;
708 }
709 isCsrfSafe = cgi_csrf_safe(1);
710 if( g.perm.ModForum && isCsrfSafe ){
711 if( P("approve") ){
712 moderation_approve(fpid);
713 cgi_redirectf("%R/forumpost/%S",P("fpid"));
714 return;
715 }
716 if( P("reject") ){
717 moderation_disapprove(fpid);
718 cgi_redirectf("%R/forumpost/%S",P("fpid"));
719 return;
720 }
721 }
722 isDelete = P("nullout")!=0;
723 if( P("submit") && isCsrfSafe ){
724

Keyboard Shortcuts

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