Fossil SCM

added dynamic behavior page, no special layout. Reusing the commandline help and simply listing all options

wolfgang 2010-09-15 18:46 wolfgangFormat2CSS_2
Commit 757a5e5b4e60d4f64f1b87b4f78a038dc0b96fb7
2 files changed +46 -27 +47
+46 -27
--- src/db.c
+++ src/db.c
@@ -1492,10 +1492,48 @@
14921492
}
14931493
db_finalize(&q);
14941494
}
14951495
14961496
1497
+/*
1498
+** define all settings, which can be controlled via the set/unset
1499
+** command. var is the name of the internal configuration name for db_(un)set.
1500
+** If var is 0, the settings name is used.
1501
+** width is the length for the edit field on the behavior page, 0
1502
+** is used for on/off checkboxes.
1503
+** The behaviour page doesn't use a special layout. It lists all
1504
+** set-commands and displays the 'set'-help as info.
1505
+*/
1506
+#if INTERFACE
1507
+struct stControlSettings {
1508
+ char const * name;
1509
+ char const * var;
1510
+ int width;
1511
+ char const * def;
1512
+};
1513
+#endif /* INTERFACE */
1514
+struct stControlSettings const ctrlSettings[] = {
1515
+ { "auto-captcha", "autocaptcha", 0, "0" },
1516
+ { "auto-shun", 0, 0, "1" },
1517
+ { "autosync", 0, 0, "0" },
1518
+ { "binary-glob", 0, 0, "1" },
1519
+ { "clearsign", 0, 0, "0" },
1520
+ { "diff-command", 0, 16, "diff" },
1521
+ { "dont-push", 0, 0, "0" },
1522
+ { "editor", 0, 16, "" },
1523
+ { "gdiff-command", 0, 16, "gdiff" },
1524
+ { "ignore-glob", 0, 40, "" },
1525
+ { "http-port", 0, 16, "8080" },
1526
+ { "localauth", 0, 0, "0" },
1527
+ { "mtime-changes", 0, 0, "0" },
1528
+ { "pgp-command", 0, 32, "gpg --clearsign -o " },
1529
+ { "proxy", 0, 32, "off" },
1530
+ { "ssh-command", 0, 32, "" },
1531
+ { "web-browser", 0, 32, "" },
1532
+ { 0,0,0,0 }
1533
+};
1534
+
14971535
/*
14981536
** COMMAND: settings
14991537
** COMMAND: unset
15001538
** %fossil settings ?PROPERTY? ?VALUE? ?-global?
15011539
** %fossil unset PROPERTY ?-global?
@@ -1567,29 +1605,10 @@
15671605
** web browser when given a URL as an argument.
15681606
** Defaults to "start" on windows, "open" on Mac,
15691607
** and "firefox" on Unix.
15701608
*/
15711609
void setting_cmd(void){
1572
- static const char *azName[] = {
1573
- "auto-captcha",
1574
- "auto-shun",
1575
- "autosync",
1576
- "binary-glob",
1577
- "clearsign",
1578
- "diff-command",
1579
- "dont-push",
1580
- "editor",
1581
- "gdiff-command",
1582
- "ignore-glob",
1583
- "http-port",
1584
- "localauth",
1585
- "mtime-changes",
1586
- "pgp-command",
1587
- "proxy",
1588
- "ssh-command",
1589
- "web-browser",
1590
- };
15911610
int i;
15921611
int globalFlag = find_option("global","g",0)!=0;
15931612
int unsetFlag = g.argv[1][0]=='u';
15941613
db_open_config(1);
15951614
db_find_and_open_repository(0);
@@ -1598,28 +1617,28 @@
15981617
}
15991618
if( unsetFlag && g.argc!=3 ){
16001619
usage("PROPERTY ?-global?");
16011620
}
16021621
if( g.argc==2 ){
1603
- for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
1604
- print_setting(azName[i]);
1622
+ for(i=0; ctrlSettings[i].name; i++){
1623
+ print_setting(ctrlSettings[i].name);
16051624
}
16061625
}else if( g.argc==3 || g.argc==4 ){
16071626
const char *zName = g.argv[2];
16081627
int n = strlen(zName);
1609
- for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
1610
- if( strncmp(azName[i], zName, n)==0 ) break;
1628
+ for(i=0; ctrlSettings[i].name; i++){
1629
+ if( strncmp(ctrlSettings[i].name, zName, n)==0 ) break;
16111630
}
1612
- if( i>=sizeof(azName)/sizeof(azName[0]) ){
1631
+ if( !ctrlSettings[i].name ){
16131632
fossil_fatal("no such setting: %s", zName);
16141633
}
16151634
if( unsetFlag ){
1616
- db_unset(azName[i], globalFlag);
1635
+ db_unset(ctrlSettings[i].name, globalFlag);
16171636
}else if( g.argc==4 ){
1618
- db_set(azName[i], g.argv[3], globalFlag);
1637
+ db_set(ctrlSettings[i].name, g.argv[3], globalFlag);
16191638
}else{
1620
- print_setting(azName[i]);
1639
+ print_setting(ctrlSettings[i].name);
16211640
}
16221641
}else{
16231642
usage("?PROPERTY? ?VALUE?");
16241643
}
16251644
}
16261645
--- src/db.c
+++ src/db.c
@@ -1492,10 +1492,48 @@
1492 }
1493 db_finalize(&q);
1494 }
1495
1496
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1497 /*
1498 ** COMMAND: settings
1499 ** COMMAND: unset
1500 ** %fossil settings ?PROPERTY? ?VALUE? ?-global?
1501 ** %fossil unset PROPERTY ?-global?
@@ -1567,29 +1605,10 @@
1567 ** web browser when given a URL as an argument.
1568 ** Defaults to "start" on windows, "open" on Mac,
1569 ** and "firefox" on Unix.
1570 */
1571 void setting_cmd(void){
1572 static const char *azName[] = {
1573 "auto-captcha",
1574 "auto-shun",
1575 "autosync",
1576 "binary-glob",
1577 "clearsign",
1578 "diff-command",
1579 "dont-push",
1580 "editor",
1581 "gdiff-command",
1582 "ignore-glob",
1583 "http-port",
1584 "localauth",
1585 "mtime-changes",
1586 "pgp-command",
1587 "proxy",
1588 "ssh-command",
1589 "web-browser",
1590 };
1591 int i;
1592 int globalFlag = find_option("global","g",0)!=0;
1593 int unsetFlag = g.argv[1][0]=='u';
1594 db_open_config(1);
1595 db_find_and_open_repository(0);
@@ -1598,28 +1617,28 @@
1598 }
1599 if( unsetFlag && g.argc!=3 ){
1600 usage("PROPERTY ?-global?");
1601 }
1602 if( g.argc==2 ){
1603 for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
1604 print_setting(azName[i]);
1605 }
1606 }else if( g.argc==3 || g.argc==4 ){
1607 const char *zName = g.argv[2];
1608 int n = strlen(zName);
1609 for(i=0; i<sizeof(azName)/sizeof(azName[0]); i++){
1610 if( strncmp(azName[i], zName, n)==0 ) break;
1611 }
1612 if( i>=sizeof(azName)/sizeof(azName[0]) ){
1613 fossil_fatal("no such setting: %s", zName);
1614 }
1615 if( unsetFlag ){
1616 db_unset(azName[i], globalFlag);
1617 }else if( g.argc==4 ){
1618 db_set(azName[i], g.argv[3], globalFlag);
1619 }else{
1620 print_setting(azName[i]);
1621 }
1622 }else{
1623 usage("?PROPERTY? ?VALUE?");
1624 }
1625 }
1626
--- src/db.c
+++ src/db.c
@@ -1492,10 +1492,48 @@
1492 }
1493 db_finalize(&q);
1494 }
1495
1496
1497 /*
1498 ** define all settings, which can be controlled via the set/unset
1499 ** command. var is the name of the internal configuration name for db_(un)set.
1500 ** If var is 0, the settings name is used.
1501 ** width is the length for the edit field on the behavior page, 0
1502 ** is used for on/off checkboxes.
1503 ** The behaviour page doesn't use a special layout. It lists all
1504 ** set-commands and displays the 'set'-help as info.
1505 */
1506 #if INTERFACE
1507 struct stControlSettings {
1508 char const * name;
1509 char const * var;
1510 int width;
1511 char const * def;
1512 };
1513 #endif /* INTERFACE */
1514 struct stControlSettings const ctrlSettings[] = {
1515 { "auto-captcha", "autocaptcha", 0, "0" },
1516 { "auto-shun", 0, 0, "1" },
1517 { "autosync", 0, 0, "0" },
1518 { "binary-glob", 0, 0, "1" },
1519 { "clearsign", 0, 0, "0" },
1520 { "diff-command", 0, 16, "diff" },
1521 { "dont-push", 0, 0, "0" },
1522 { "editor", 0, 16, "" },
1523 { "gdiff-command", 0, 16, "gdiff" },
1524 { "ignore-glob", 0, 40, "" },
1525 { "http-port", 0, 16, "8080" },
1526 { "localauth", 0, 0, "0" },
1527 { "mtime-changes", 0, 0, "0" },
1528 { "pgp-command", 0, 32, "gpg --clearsign -o " },
1529 { "proxy", 0, 32, "off" },
1530 { "ssh-command", 0, 32, "" },
1531 { "web-browser", 0, 32, "" },
1532 { 0,0,0,0 }
1533 };
1534
1535 /*
1536 ** COMMAND: settings
1537 ** COMMAND: unset
1538 ** %fossil settings ?PROPERTY? ?VALUE? ?-global?
1539 ** %fossil unset PROPERTY ?-global?
@@ -1567,29 +1605,10 @@
1605 ** web browser when given a URL as an argument.
1606 ** Defaults to "start" on windows, "open" on Mac,
1607 ** and "firefox" on Unix.
1608 */
1609 void setting_cmd(void){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1610 int i;
1611 int globalFlag = find_option("global","g",0)!=0;
1612 int unsetFlag = g.argv[1][0]=='u';
1613 db_open_config(1);
1614 db_find_and_open_repository(0);
@@ -1598,28 +1617,28 @@
1617 }
1618 if( unsetFlag && g.argc!=3 ){
1619 usage("PROPERTY ?-global?");
1620 }
1621 if( g.argc==2 ){
1622 for(i=0; ctrlSettings[i].name; i++){
1623 print_setting(ctrlSettings[i].name);
1624 }
1625 }else if( g.argc==3 || g.argc==4 ){
1626 const char *zName = g.argv[2];
1627 int n = strlen(zName);
1628 for(i=0; ctrlSettings[i].name; i++){
1629 if( strncmp(ctrlSettings[i].name, zName, n)==0 ) break;
1630 }
1631 if( !ctrlSettings[i].name ){
1632 fossil_fatal("no such setting: %s", zName);
1633 }
1634 if( unsetFlag ){
1635 db_unset(ctrlSettings[i].name, globalFlag);
1636 }else if( g.argc==4 ){
1637 db_set(ctrlSettings[i].name, g.argv[3], globalFlag);
1638 }else{
1639 print_setting(ctrlSettings[i].name);
1640 }
1641 }else{
1642 usage("?PROPERTY? ?VALUE?");
1643 }
1644 }
1645
+47
--- src/setup.c
+++ src/setup.c
@@ -19,10 +19,17 @@
1919
*/
2020
#include <assert.h>
2121
#include "config.h"
2222
#include "setup.h"
2323
24
+/*
25
+** The table of web pages supported by this application is generated
26
+** automatically by the "mkindex" program and written into a file
27
+** named "page_index.h". We include that file here to get access
28
+** to the table.
29
+*/
30
+#include "page_index.h"
2431
2532
/*
2633
** Output a single entry for a menu generated using an HTML table.
2734
** If zLink is not NULL or an empty string, then it is the page that
2835
** the menu entry will hyperlink to. If zLink is NULL or "", then
@@ -57,10 +64,12 @@
5764
"Grant privileges to individual users.");
5865
setup_menu_entry("Access", "setup_access",
5966
"Control access settings.");
6067
setup_menu_entry("Configuration", "setup_config",
6168
"Configure the WWW components of the repository");
69
+ setup_menu_entry("Behavior", "setup_behavior",
70
+ "Configure the version control part of the repository");
6271
setup_menu_entry("Timeline", "setup_timeline",
6372
"Timeline display preferences");
6473
setup_menu_entry("Tickets", "tktsetup",
6574
"Configure the trouble-ticketing system for this repository");
6675
setup_menu_entry("Skins", "setup_skin",
@@ -841,10 +850,48 @@
841850
@ "0" there is no length limit.</p>
842851
843852
@ <hr />
844853
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
845854
@ </div></form>
855
+ db_end_transaction(0);
856
+ style_footer();
857
+}
858
+
859
+/*
860
+** WEBPAGE: setup_behavior
861
+*/
862
+void setup_behavior(void){
863
+ int i;
864
+ struct stControlSettings const * azSet;
865
+
866
+ login_check_credentials();
867
+ if( !g.okSetup ){
868
+ login_needed();
869
+ }
870
+
871
+ style_header("SCM Behavior");
872
+ db_begin_transaction();
873
+ @ <form action="%s(g.zBaseURL)/setup_behavior" method="post"><div>
874
+ login_insert_csrf_secret();
875
+ for (azSet=ctrlSettings;azSet->name;azSet++) {
876
+ if (azSet->width==0) {
877
+ /* found boolean attribute */
878
+ onoff_attribute(azSet->name, azSet->name, azSet->var?azSet->var:azSet->name, (azSet->def[0]=='1')?1:0);
879
+ @ <hr />
880
+ }
881
+ }
882
+ for (azSet=ctrlSettings;azSet->name;azSet++) {
883
+ if (azSet->width!=0) {
884
+ entry_attribute(azSet->name, azSet->width, azSet->name, azSet->var?azSet->var:azSet->name, (char*)azSet->def);
885
+ @ <hr />
886
+ }
887
+ }
888
+ @ <p><input type="submit" name="submit" value="Apply Changes" /></p>
889
+ @ <hr />
890
+ @ These settings work in the same way, as the <kbd>set</kbd> commandline:<br>
891
+ @ <pre>%s(zHelp_setting_cmd)</pre>
892
+ @ </div></form>
846893
db_end_transaction(0);
847894
style_footer();
848895
}
849896
850897
/*
851898
--- src/setup.c
+++ src/setup.c
@@ -19,10 +19,17 @@
19 */
20 #include <assert.h>
21 #include "config.h"
22 #include "setup.h"
23
 
 
 
 
 
 
 
24
25 /*
26 ** Output a single entry for a menu generated using an HTML table.
27 ** If zLink is not NULL or an empty string, then it is the page that
28 ** the menu entry will hyperlink to. If zLink is NULL or "", then
@@ -57,10 +64,12 @@
57 "Grant privileges to individual users.");
58 setup_menu_entry("Access", "setup_access",
59 "Control access settings.");
60 setup_menu_entry("Configuration", "setup_config",
61 "Configure the WWW components of the repository");
 
 
62 setup_menu_entry("Timeline", "setup_timeline",
63 "Timeline display preferences");
64 setup_menu_entry("Tickets", "tktsetup",
65 "Configure the trouble-ticketing system for this repository");
66 setup_menu_entry("Skins", "setup_skin",
@@ -841,10 +850,48 @@
841 @ "0" there is no length limit.</p>
842
843 @ <hr />
844 @ <p><input type="submit" name="submit" value="Apply Changes" /></p>
845 @ </div></form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
846 db_end_transaction(0);
847 style_footer();
848 }
849
850 /*
851
--- src/setup.c
+++ src/setup.c
@@ -19,10 +19,17 @@
19 */
20 #include <assert.h>
21 #include "config.h"
22 #include "setup.h"
23
24 /*
25 ** The table of web pages supported by this application is generated
26 ** automatically by the "mkindex" program and written into a file
27 ** named "page_index.h". We include that file here to get access
28 ** to the table.
29 */
30 #include "page_index.h"
31
32 /*
33 ** Output a single entry for a menu generated using an HTML table.
34 ** If zLink is not NULL or an empty string, then it is the page that
35 ** the menu entry will hyperlink to. If zLink is NULL or "", then
@@ -57,10 +64,12 @@
64 "Grant privileges to individual users.");
65 setup_menu_entry("Access", "setup_access",
66 "Control access settings.");
67 setup_menu_entry("Configuration", "setup_config",
68 "Configure the WWW components of the repository");
69 setup_menu_entry("Behavior", "setup_behavior",
70 "Configure the version control part of the repository");
71 setup_menu_entry("Timeline", "setup_timeline",
72 "Timeline display preferences");
73 setup_menu_entry("Tickets", "tktsetup",
74 "Configure the trouble-ticketing system for this repository");
75 setup_menu_entry("Skins", "setup_skin",
@@ -841,10 +850,48 @@
850 @ "0" there is no length limit.</p>
851
852 @ <hr />
853 @ <p><input type="submit" name="submit" value="Apply Changes" /></p>
854 @ </div></form>
855 db_end_transaction(0);
856 style_footer();
857 }
858
859 /*
860 ** WEBPAGE: setup_behavior
861 */
862 void setup_behavior(void){
863 int i;
864 struct stControlSettings const * azSet;
865
866 login_check_credentials();
867 if( !g.okSetup ){
868 login_needed();
869 }
870
871 style_header("SCM Behavior");
872 db_begin_transaction();
873 @ <form action="%s(g.zBaseURL)/setup_behavior" method="post"><div>
874 login_insert_csrf_secret();
875 for (azSet=ctrlSettings;azSet->name;azSet++) {
876 if (azSet->width==0) {
877 /* found boolean attribute */
878 onoff_attribute(azSet->name, azSet->name, azSet->var?azSet->var:azSet->name, (azSet->def[0]=='1')?1:0);
879 @ <hr />
880 }
881 }
882 for (azSet=ctrlSettings;azSet->name;azSet++) {
883 if (azSet->width!=0) {
884 entry_attribute(azSet->name, azSet->width, azSet->name, azSet->var?azSet->var:azSet->name, (char*)azSet->def);
885 @ <hr />
886 }
887 }
888 @ <p><input type="submit" name="submit" value="Apply Changes" /></p>
889 @ <hr />
890 @ These settings work in the same way, as the <kbd>set</kbd> commandline:<br>
891 @ <pre>%s(zHelp_setting_cmd)</pre>
892 @ </div></form>
893 db_end_transaction(0);
894 style_footer();
895 }
896
897 /*
898

Keyboard Shortcuts

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