Fossil SCM

New setting "forum-title" is the title of the Forum.

drh 2024-11-19 12:52 trunk
Commit f646537cb626f11e8bdbe84c7f6e5671e6b59cc88cf2b1faae560b3333e69a9d
-7
--- src/db.c
+++ src/db.c
@@ -4681,17 +4681,10 @@
46814681
** to obtain a check-in lock during auto-sync, the server will
46824682
** send the "pragma avoid-delta-manifests" statement in its reply,
46834683
** which will cause the client to avoid generating a delta
46844684
** manifest.
46854685
*/
4686
-/*
4687
-** SETTING: forum-close-policy boolean default=off
4688
-** If true, forum moderators may close/re-open forum posts, and reply
4689
-** to closed posts. If false, only administrators may do so. Note that
4690
-** this only affects the forum web UI, not post-closing tags which
4691
-** arrive via the command-line or from synchronization with a remote.
4692
-*/
46934686
/*
46944687
** SETTING: gdiff-command width=40 default=gdiff sensitive
46954688
** The value is an external command to run when performing a graphical
46964689
** diff. If undefined, text diff will be used.
46974690
*/
46984691
--- src/db.c
+++ src/db.c
@@ -4681,17 +4681,10 @@
4681 ** to obtain a check-in lock during auto-sync, the server will
4682 ** send the "pragma avoid-delta-manifests" statement in its reply,
4683 ** which will cause the client to avoid generating a delta
4684 ** manifest.
4685 */
4686 /*
4687 ** SETTING: forum-close-policy boolean default=off
4688 ** If true, forum moderators may close/re-open forum posts, and reply
4689 ** to closed posts. If false, only administrators may do so. Note that
4690 ** this only affects the forum web UI, not post-closing tags which
4691 ** arrive via the command-line or from synchronization with a remote.
4692 */
4693 /*
4694 ** SETTING: gdiff-command width=40 default=gdiff sensitive
4695 ** The value is an external command to run when performing a graphical
4696 ** diff. If undefined, text diff will be used.
4697 */
4698
--- src/db.c
+++ src/db.c
@@ -4681,17 +4681,10 @@
4681 ** to obtain a check-in lock during auto-sync, the server will
4682 ** send the "pragma avoid-delta-manifests" statement in its reply,
4683 ** which will cause the client to avoid generating a delta
4684 ** manifest.
4685 */
 
 
 
 
 
 
 
4686 /*
4687 ** SETTING: gdiff-command width=40 default=gdiff sensitive
4688 ** The value is an external command to run when performing a graphical
4689 ** diff. If undefined, text diff will be used.
4690 */
4691
+26 -1
--- src/dispatch.c
+++ src/dispatch.c
@@ -1307,17 +1307,42 @@
13071307
}
13081308
13091309
/*
13101310
** Return a pointer to the setting information array.
13111311
**
1312
-** This routine provides access to the aSetting2[] array which is created
1312
+** This routine provides access to the aSetting[] array which is created
13131313
** by the mkindex utility program and included with <page_index.h>.
13141314
*/
13151315
const Setting *setting_info(int *pnCount){
13161316
if( pnCount ) *pnCount = (int)(sizeof(aSetting)/sizeof(aSetting[0])) - 1;
13171317
return aSetting;
13181318
}
1319
+
1320
+/*
1321
+** Return a pointer to a specific Setting entry for the setting named
1322
+** in the argument. Or return NULL if no such setting exists.
1323
+**
1324
+** The pointer returned points into the middle of the global aSetting[]
1325
+** array that is generated by mkindex. Use setting_info() to fetch the
1326
+** whole array. Use this routine to fetch a specific entry.
1327
+*/
1328
+const Setting *setting_find(const char *zName){
1329
+ int iFirst = 0;
1330
+ int iLast = ArraySize(aSetting)-1;
1331
+ while( iFirst<=iLast ){
1332
+ int iCur = (iFirst+iLast)/2;
1333
+ int c = strcmp(aSetting[iCur].name, zName);
1334
+ if( c<0 ){
1335
+ iFirst = iCur+1;
1336
+ }else if( c>0 ){
1337
+ iLast = iCur-1;
1338
+ }else{
1339
+ return &aSetting[iCur];
1340
+ }
1341
+ }
1342
+ return 0;
1343
+}
13191344
13201345
/*****************************************************************************
13211346
** A virtual table for accessing the information in aCommand[], and
13221347
** especially the help-text
13231348
*/
13241349
--- src/dispatch.c
+++ src/dispatch.c
@@ -1307,17 +1307,42 @@
1307 }
1308
1309 /*
1310 ** Return a pointer to the setting information array.
1311 **
1312 ** This routine provides access to the aSetting2[] array which is created
1313 ** by the mkindex utility program and included with <page_index.h>.
1314 */
1315 const Setting *setting_info(int *pnCount){
1316 if( pnCount ) *pnCount = (int)(sizeof(aSetting)/sizeof(aSetting[0])) - 1;
1317 return aSetting;
1318 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1319
1320 /*****************************************************************************
1321 ** A virtual table for accessing the information in aCommand[], and
1322 ** especially the help-text
1323 */
1324
--- src/dispatch.c
+++ src/dispatch.c
@@ -1307,17 +1307,42 @@
1307 }
1308
1309 /*
1310 ** Return a pointer to the setting information array.
1311 **
1312 ** This routine provides access to the aSetting[] array which is created
1313 ** by the mkindex utility program and included with <page_index.h>.
1314 */
1315 const Setting *setting_info(int *pnCount){
1316 if( pnCount ) *pnCount = (int)(sizeof(aSetting)/sizeof(aSetting[0])) - 1;
1317 return aSetting;
1318 }
1319
1320 /*
1321 ** Return a pointer to a specific Setting entry for the setting named
1322 ** in the argument. Or return NULL if no such setting exists.
1323 **
1324 ** The pointer returned points into the middle of the global aSetting[]
1325 ** array that is generated by mkindex. Use setting_info() to fetch the
1326 ** whole array. Use this routine to fetch a specific entry.
1327 */
1328 const Setting *setting_find(const char *zName){
1329 int iFirst = 0;
1330 int iLast = ArraySize(aSetting)-1;
1331 while( iFirst<=iLast ){
1332 int iCur = (iFirst+iLast)/2;
1333 int c = strcmp(aSetting[iCur].name, zName);
1334 if( c<0 ){
1335 iFirst = iCur+1;
1336 }else if( c>0 ){
1337 iLast = iCur-1;
1338 }else{
1339 return &aSetting[iCur];
1340 }
1341 }
1342 return 0;
1343 }
1344
1345 /*****************************************************************************
1346 ** A virtual table for accessing the information in aCommand[], and
1347 ** especially the help-text
1348 */
1349
+55 -16
--- src/forum.c
+++ src/forum.c
@@ -1761,20 +1761,35 @@
17611761
@ </form>
17621762
forum_emit_js();
17631763
style_finish_page();
17641764
}
17651765
1766
+/*
1767
+** SETTING: forum-close-policy boolean default=off
1768
+** If true, forum moderators may close/re-open forum posts, and reply
1769
+** to closed posts. If false, only administrators may do so. Note that
1770
+** this only affects the forum web UI, not post-closing tags which
1771
+** arrive via the command-line or from synchronization with a remote.
1772
+*/
1773
+/*
1774
+** SETTING: forum-title width=20 default=Forum
1775
+** This is the name or "title" of the Forum for this repository. The
1776
+** default is just "Forum". But in some setups, admins might want to
1777
+** change it to "Developer Forum" or "User Forum" or whatever other name
1778
+** seems more appropriate for the particular usage.
1779
+*/
1780
+
17661781
/*
17671782
** WEBPAGE: setup_forum
17681783
**
17691784
** Forum configuration and metrics.
17701785
*/
17711786
void forum_setup(void){
17721787
/* boolean config settings specific to the forum. */
1773
- const char * zSettingsBool[] = {
1774
- "forum-close-policy",
1775
- NULL /* sentinel entry */
1788
+ static const char *azForumSettings[] = {
1789
+ "forum-close-policy",
1790
+ "forum-title",
17761791
};
17771792
17781793
login_check_credentials();
17791794
if( !g.perm.Setup ){
17801795
login_needed(g.anon.Setup);
@@ -1850,32 +1865,55 @@
18501865
18511866
@ <h2>Settings</h2>
18521867
@ <p>Configuration settings specific to the forum.</p>
18531868
if( P("submit") && cgi_csrf_safe(2) ){
18541869
int i = 0;
1855
- const char *zSetting;
18561870
db_begin_transaction();
1857
- while( (zSetting = zSettingsBool[i++]) ){
1858
- const char *z = P(zSetting);
1859
- if( !z || !z[0] ) z = "off";
1860
- db_set(zSetting/*works-like:"x"*/, z, 0);
1871
+ for(i=0; i<ArraySize(azForumSettings); i++){
1872
+ char zQP[4];
1873
+ const char *z;
1874
+ const Setting *pSetting = setting_find(azForumSettings[i]);
1875
+ if( pSetting==0 ) continue;
1876
+ zQP[0] = 'a'+i;
1877
+ zQP[1] = zQP[0];
1878
+ zQP[2] = 0;
1879
+ z = P(zQP);
1880
+ if( z==0 || z[0]==0 ) continue;
1881
+ db_set(pSetting->name/*works-like:"x"*/, z, 0);
18611882
}
18621883
db_end_transaction(0);
18631884
@ <p><em>Settings saved.</em></p>
18641885
}
18651886
{
18661887
int i = 0;
1867
- const char *zSetting;
18681888
@ <form action="%R/setup_forum" method="post">
18691889
login_insert_csrf_secret();
18701890
@ <table class='forum-settings-list'><tbody>
1871
- while( (zSetting = zSettingsBool[i++]) ){
1872
- @ <tr><td>
1873
- onoff_attribute("", zSetting, zSetting/*works-like:"x"*/, 0, 0);
1874
- @ </td><td>
1875
- @ <a href='%R/help?cmd=%h(zSetting)'>%h(zSetting)</a>
1876
- @ </td></tr>
1891
+ for(i=0; i<ArraySize(azForumSettings); i++){
1892
+ char zQP[4];
1893
+ const Setting *pSetting = setting_find(azForumSettings[i]);
1894
+ if( pSetting==0 ) continue;
1895
+ zQP[0] = 'a'+i;
1896
+ zQP[1] = zQP[0];
1897
+ zQP[2] = 0;
1898
+ if( pSetting->width==0 ){
1899
+ /* Boolean setting */
1900
+ @ <tr><td>&nbsp;<td width="5">
1901
+ onoff_attribute("", zQP, pSetting->name/*works-like:"x"*/, 0, 0);
1902
+ @ </td><td>
1903
+ @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>
1904
+ @ </td>
1905
+ @ <td>&nbsp;</td></tr>
1906
+ }else{
1907
+ /* Text value setting */
1908
+ @ <tr><td colspan="2">
1909
+ entry_attribute("", 25, pSetting->name, zQP/*works-like:""*/,
1910
+ pSetting->def, 0);
1911
+ @ </td><td>
1912
+ @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>
1913
+ @ </td></tr>
1914
+ }
18771915
}
18781916
@ </tbody></table>
18791917
@ <input type='submit' name='submit' value='Apply changes'>
18801918
@ </form>
18811919
}
@@ -1910,11 +1948,12 @@
19101948
login_needed(g.anon.RdForum);
19111949
return;
19121950
}
19131951
cgi_check_for_malice();
19141952
style_set_current_feature("forum");
1915
- style_header( "%s", isSearch ? "Forum Search Results" : "Forum" );
1953
+ style_header("%s%s", db_get("forum-title","Forum"),
1954
+ isSearch ? " Search Results" : "");
19161955
style_submenu_element("Timeline", "%R/timeline?ss=v&y=f&vfx");
19171956
if( g.perm.WrForum ){
19181957
style_submenu_element("New Thread","%R/forumnew");
19191958
}else{
19201959
/* Can't combine this with previous case using the ternary operator
19211960
--- src/forum.c
+++ src/forum.c
@@ -1761,20 +1761,35 @@
1761 @ </form>
1762 forum_emit_js();
1763 style_finish_page();
1764 }
1765
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1766 /*
1767 ** WEBPAGE: setup_forum
1768 **
1769 ** Forum configuration and metrics.
1770 */
1771 void forum_setup(void){
1772 /* boolean config settings specific to the forum. */
1773 const char * zSettingsBool[] = {
1774 "forum-close-policy",
1775 NULL /* sentinel entry */
1776 };
1777
1778 login_check_credentials();
1779 if( !g.perm.Setup ){
1780 login_needed(g.anon.Setup);
@@ -1850,32 +1865,55 @@
1850
1851 @ <h2>Settings</h2>
1852 @ <p>Configuration settings specific to the forum.</p>
1853 if( P("submit") && cgi_csrf_safe(2) ){
1854 int i = 0;
1855 const char *zSetting;
1856 db_begin_transaction();
1857 while( (zSetting = zSettingsBool[i++]) ){
1858 const char *z = P(zSetting);
1859 if( !z || !z[0] ) z = "off";
1860 db_set(zSetting/*works-like:"x"*/, z, 0);
 
 
 
 
 
 
 
1861 }
1862 db_end_transaction(0);
1863 @ <p><em>Settings saved.</em></p>
1864 }
1865 {
1866 int i = 0;
1867 const char *zSetting;
1868 @ <form action="%R/setup_forum" method="post">
1869 login_insert_csrf_secret();
1870 @ <table class='forum-settings-list'><tbody>
1871 while( (zSetting = zSettingsBool[i++]) ){
1872 @ <tr><td>
1873 onoff_attribute("", zSetting, zSetting/*works-like:"x"*/, 0, 0);
1874 @ </td><td>
1875 @ <a href='%R/help?cmd=%h(zSetting)'>%h(zSetting)</a>
1876 @ </td></tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1877 }
1878 @ </tbody></table>
1879 @ <input type='submit' name='submit' value='Apply changes'>
1880 @ </form>
1881 }
@@ -1910,11 +1948,12 @@
1910 login_needed(g.anon.RdForum);
1911 return;
1912 }
1913 cgi_check_for_malice();
1914 style_set_current_feature("forum");
1915 style_header( "%s", isSearch ? "Forum Search Results" : "Forum" );
 
1916 style_submenu_element("Timeline", "%R/timeline?ss=v&y=f&vfx");
1917 if( g.perm.WrForum ){
1918 style_submenu_element("New Thread","%R/forumnew");
1919 }else{
1920 /* Can't combine this with previous case using the ternary operator
1921
--- src/forum.c
+++ src/forum.c
@@ -1761,20 +1761,35 @@
1761 @ </form>
1762 forum_emit_js();
1763 style_finish_page();
1764 }
1765
1766 /*
1767 ** SETTING: forum-close-policy boolean default=off
1768 ** If true, forum moderators may close/re-open forum posts, and reply
1769 ** to closed posts. If false, only administrators may do so. Note that
1770 ** this only affects the forum web UI, not post-closing tags which
1771 ** arrive via the command-line or from synchronization with a remote.
1772 */
1773 /*
1774 ** SETTING: forum-title width=20 default=Forum
1775 ** This is the name or "title" of the Forum for this repository. The
1776 ** default is just "Forum". But in some setups, admins might want to
1777 ** change it to "Developer Forum" or "User Forum" or whatever other name
1778 ** seems more appropriate for the particular usage.
1779 */
1780
1781 /*
1782 ** WEBPAGE: setup_forum
1783 **
1784 ** Forum configuration and metrics.
1785 */
1786 void forum_setup(void){
1787 /* boolean config settings specific to the forum. */
1788 static const char *azForumSettings[] = {
1789 "forum-close-policy",
1790 "forum-title",
1791 };
1792
1793 login_check_credentials();
1794 if( !g.perm.Setup ){
1795 login_needed(g.anon.Setup);
@@ -1850,32 +1865,55 @@
1865
1866 @ <h2>Settings</h2>
1867 @ <p>Configuration settings specific to the forum.</p>
1868 if( P("submit") && cgi_csrf_safe(2) ){
1869 int i = 0;
 
1870 db_begin_transaction();
1871 for(i=0; i<ArraySize(azForumSettings); i++){
1872 char zQP[4];
1873 const char *z;
1874 const Setting *pSetting = setting_find(azForumSettings[i]);
1875 if( pSetting==0 ) continue;
1876 zQP[0] = 'a'+i;
1877 zQP[1] = zQP[0];
1878 zQP[2] = 0;
1879 z = P(zQP);
1880 if( z==0 || z[0]==0 ) continue;
1881 db_set(pSetting->name/*works-like:"x"*/, z, 0);
1882 }
1883 db_end_transaction(0);
1884 @ <p><em>Settings saved.</em></p>
1885 }
1886 {
1887 int i = 0;
 
1888 @ <form action="%R/setup_forum" method="post">
1889 login_insert_csrf_secret();
1890 @ <table class='forum-settings-list'><tbody>
1891 for(i=0; i<ArraySize(azForumSettings); i++){
1892 char zQP[4];
1893 const Setting *pSetting = setting_find(azForumSettings[i]);
1894 if( pSetting==0 ) continue;
1895 zQP[0] = 'a'+i;
1896 zQP[1] = zQP[0];
1897 zQP[2] = 0;
1898 if( pSetting->width==0 ){
1899 /* Boolean setting */
1900 @ <tr><td>&nbsp;<td width="5">
1901 onoff_attribute("", zQP, pSetting->name/*works-like:"x"*/, 0, 0);
1902 @ </td><td>
1903 @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>
1904 @ </td>
1905 @ <td>&nbsp;</td></tr>
1906 }else{
1907 /* Text value setting */
1908 @ <tr><td colspan="2">
1909 entry_attribute("", 25, pSetting->name, zQP/*works-like:""*/,
1910 pSetting->def, 0);
1911 @ </td><td>
1912 @ <a href='%R/help?cmd=%h(pSetting->name)'>%h(pSetting->name)</a>
1913 @ </td></tr>
1914 }
1915 }
1916 @ </tbody></table>
1917 @ <input type='submit' name='submit' value='Apply changes'>
1918 @ </form>
1919 }
@@ -1910,11 +1948,12 @@
1948 login_needed(g.anon.RdForum);
1949 return;
1950 }
1951 cgi_check_for_malice();
1952 style_set_current_feature("forum");
1953 style_header("%s%s", db_get("forum-title","Forum"),
1954 isSearch ? " Search Results" : "");
1955 style_submenu_element("Timeline", "%R/timeline?ss=v&y=f&vfx");
1956 if( g.perm.WrForum ){
1957 style_submenu_element("New Thread","%R/forumnew");
1958 }else{
1959 /* Can't combine this with previous case using the ternary operator
1960
+2 -1
--- src/sitemap.c
+++ src/sitemap.c
@@ -192,11 +192,12 @@
192192
}
193193
if( g.perm.Chat ){
194194
@ <li>%z(href("%R/chat"))Chat</a></li>
195195
}
196196
if( g.perm.RdForum ){
197
- @ <li>%z(href("%R/forum"))Forum</a>
197
+ const char *zTitle = db_get("forum-title","Forum");
198
+ @ <li>%z(href("%R/forum"))%h(zTitle)</a>
198199
@ <ul>
199200
@ <li>%z(href("%R/timeline?y=f"))Recent activity</a></li>
200201
@ </ul>
201202
@ </li>
202203
}
203204
--- src/sitemap.c
+++ src/sitemap.c
@@ -192,11 +192,12 @@
192 }
193 if( g.perm.Chat ){
194 @ <li>%z(href("%R/chat"))Chat</a></li>
195 }
196 if( g.perm.RdForum ){
197 @ <li>%z(href("%R/forum"))Forum</a>
 
198 @ <ul>
199 @ <li>%z(href("%R/timeline?y=f"))Recent activity</a></li>
200 @ </ul>
201 @ </li>
202 }
203
--- src/sitemap.c
+++ src/sitemap.c
@@ -192,11 +192,12 @@
192 }
193 if( g.perm.Chat ){
194 @ <li>%z(href("%R/chat"))Chat</a></li>
195 }
196 if( g.perm.RdForum ){
197 const char *zTitle = db_get("forum-title","Forum");
198 @ <li>%z(href("%R/forum"))%h(zTitle)</a>
199 @ <ul>
200 @ <li>%z(href("%R/timeline?y=f"))Recent activity</a></li>
201 @ </ul>
202 @ </li>
203 }
204

Keyboard Shortcuts

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