Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | merged in [help-www] branch: adds help support for /www/pages. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
b38bb4f9bd27d0347b62ecfac63c4b8f |
| User & Date: | stephan 2013-02-22 17:34:19.327 |
Context
|
2013-02-23
| ||
| 10:58 | Added /json/status command. check-in: d1e4d100ad user: stephan tags: trunk | |
|
2013-02-22
| ||
| 17:34 | merged in [help-www] branch: adds help support for /www/pages. check-in: b38bb4f9bd user: stephan tags: trunk | |
|
2013-02-21
| ||
| 22:21 | Provide a compile-time option to open the check-out database file (.fslckout or _FOSSIL_) in WAL mode. Also shorten source code lines to 80 characters in db.c. check-in: 8c35f07d06 user: drh tags: trunk | |
| 19:41 | CLI help command now (cosmetically) differentiates between pages and commands. Closed-Leaf check-in: 5be5933348 user: stephan tags: help-www | |
Changes
Changes to src/main.c.
| ︙ | ︙ | |||
728 729 730 731 732 733 734 |
/*
** COMMAND: test-list-webpage
**
** List all web pages
*/
void cmd_test_webpage_list(void){
int i, nCmd;
| | | > | | > > | 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
/*
** COMMAND: test-list-webpage
**
** List all web pages
*/
void cmd_test_webpage_list(void){
int i, nCmd;
const char *aCmd[count(aCommand)];
for(i=nCmd=0; i<count(aCommand); i++){
if(0x08 & aCommand[i].cmdFlags){
aCmd[nCmd++] = aWebpage[i].zName;
}
}
assert(nCmd && "page list is empty?");
multi_column_list(aCmd, nCmd);
}
/*
** COMMAND: version
**
** Usage: %fossil version
|
| ︙ | ︙ | |||
761 762 763 764 765 766 767 768 769 |
** Display information on how to use COMMAND. To display a list of
** available commands one of:
**
** %fossil help Show common commands
** %fossil help --all Show both common and auxiliary commands
** %fossil help --test Show test commands only
** %fossil help --aux Show auxiliary commands only
*/
void help_cmd(void){
| > | > > > > > > | | > > > > > > > > | > | | | | | | | 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 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 |
** Display information on how to use COMMAND. To display a list of
** available commands one of:
**
** %fossil help Show common commands
** %fossil help --all Show both common and auxiliary commands
** %fossil help --test Show test commands only
** %fossil help --aux Show auxiliary commands only
** %fossil help --www Show list of WWW pages
*/
void help_cmd(void){
int rc, idx, isPage = 0;
const char *z;
char const * zCmdOrPage;
char const * zCmdOrPagePlural;
if( g.argc<3 ){
z = g.argv[0];
fossil_print(
"Usage: %s help COMMAND\n"
"Common COMMANDs: (use \"%s help --all\" for a complete list)\n",
z, z);
command_list(0, CMDFLAG_1ST_TIER);
version_cmd();
return;
}
if( find_option("all",0,0) ){
command_list(0, CMDFLAG_1ST_TIER | CMDFLAG_2ND_TIER);
return;
}
else if( find_option("www",0,0) ){
command_list(0, CMDFLAG_WEBPAGE);
return;
}
else if( find_option("aux",0,0) ){
command_list(0, CMDFLAG_2ND_TIER);
return;
}
else if( find_option("test",0,0) ){
command_list(0, CMDFLAG_TEST);
return;
}
isPage = ('/' == *g.argv[2]) ? 1 : 0;
if(isPage){
zCmdOrPage = "page";
zCmdOrPagePlural = "pages";
}else{
zCmdOrPage = "command";
zCmdOrPagePlural = "commands";
}
rc = name_search(g.argv[2], aCommand, count(aCommand), &idx);
if( rc==1 ){
fossil_print("unknown %s: %s\nAvailable %s:\n",
zCmdOrPage, g.argv[2], zCmdOrPagePlural);
command_list(0, isPage ? CMDFLAG_WEBPAGE : (0xff & ~CMDFLAG_WEBPAGE));
fossil_exit(1);
}else if( rc==2 ){
fossil_print("ambiguous %s prefix: %s\nMatching %s:\n",
zCmdOrPage, g.argv[2], zCmdOrPagePlural);
command_list(g.argv[2], 0xff);
fossil_exit(1);
}
z = aCmdHelp[idx].zText;
if( z==0 ){
fossil_fatal("no help available for the %s %s",
aCommand[idx].zName, zCmdOrPage);
}
while( *z ){
if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){
fossil_print("%s", g.argv[0]);
z += 7;
}else{
putchar(*z);
|
| ︙ | ︙ | |||
827 828 829 830 831 832 833 |
const char * zCmd = P("cmd");
if( zCmd==0 ) zCmd = P("name");
style_header("Command-line Help");
if( zCmd ){
int rc, idx;
char *z, *s, *d;
| | | | | 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 |
const char * zCmd = P("cmd");
if( zCmd==0 ) zCmd = P("name");
style_header("Command-line Help");
if( zCmd ){
int rc, idx;
char *z, *s, *d;
char const * zCmdOrPage = ('/'==*zCmd) ? "page" : "command";
style_submenu_element("Command-List", "Command-List", "%s/help", g.zTop);
@ <h1>The "%s(zCmd)" %s(zCmdOrPage):</h1>
rc = name_search(zCmd, aCommand, count(aCommand), &idx);
if( rc==1 ){
@ unknown command: %s(zCmd)
}else if( rc==2 ){
@ ambiguous command prefix: %s(zCmd)
}else{
z = (char*)aCmdHelp[idx].zText;
if( z==0 ){
@ no help available for the %s(aCommand[idx].zName) command
}else{
z=s=d=mprintf("%s",z);
while( *s ){
if( *s=='%' && strncmp(s, "%fossil", 7)==0 ){
s++;
|
| ︙ | ︙ | |||
862 863 864 865 866 867 868 |
}else{
int i, j, n;
@ <h1>Available commands:</h1>
@ <table border="0"><tr>
for(i=j=0; i<count(aCommand); i++){
const char *z = aCommand[i].zName;
| | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 |
}else{
int i, j, n;
@ <h1>Available commands:</h1>
@ <table border="0"><tr>
for(i=j=0; i<count(aCommand); i++){
const char *z = aCommand[i].zName;
if( '/'==*z || strncmp(z,"test",4)==0 ) continue;
j++;
}
n = (j+6)/7;
for(i=j=0; i<count(aCommand); i++){
const char *z = aCommand[i].zName;
if( '/'==*z || strncmp(z,"test",4)==0 ) continue;
if( j==0 ){
@ <td valign="top"><ul>
}
@ <li><a href="%s(g.zTop)/help?cmd=%s(z)">%s(z)</a></li>
j++;
if( j>=n ){
@ </ul></td>
j = 0;
}
}
if( j>0 ){
@ </ul></td>
}
@ </tr></table>
@ <h1>Available pages:</h1>
@ (Only pages with help text are linked.)
@ <table border="0"><tr>
for(i=j=0; i<count(aCommand); i++){
const char *z = aCommand[i].zName;
if( '/'!=*z ) continue;
j++;
}
n = (j+4)/5;
for(i=j=0; i<count(aCommand); i++){
const char *z = aCommand[i].zName;
if( '/'!=*z ) continue;
if( j==0 ){
@ <td valign="top"><ul>
}
if( aCmdHelp[i].zText && *aCmdHelp[i].zText ){
@ <li><a href="%s(g.zTop)/help?cmd=%s(z)">%s(z+1)</a></li>
}else{
@ <li>%s(z+1)</li>
}
j++;
if( j>=n ){
@ </ul></td>
j = 0;
}
}
if( j>0 ){
@ </ul></td>
}
@ </tr></table>
}
style_footer();
}
/*
** WEBPAGE: test-all-help
**
** Show all help text on a single page. Useful for proof-reading.
*/
void test_all_help_page(void){
int i;
style_header("Testpage: All Help Text");
for(i=0; i<count(aCommand); i++){
if( memcmp(aCommand[i].zName, "test", 4)==0 ) continue;
@ <h2>%s(aCommand[i].zName):</h2>
@ <blockquote><pre>
@ %h(aCmdHelp[i].zText)
@ </pre></blockquote>
}
style_footer();
}
/*
** Set the g.zBaseURL value to the full URL for the toplevel of
|
| ︙ | ︙ |
Changes to src/mkindex.c.
| ︙ | ︙ | |||
172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
char *z;
if( nUsed<=nFixed ) return;
if( strncmp(zLine, "**", 2)==0
&& isspace(zLine[2])
&& strlen(zLine)<sizeof(zHelp)-nHelp-1
&& nUsed>nFixed
&& memcmp(zLine,"** COMMAND:",11)!=0
){
if( zLine[2]=='\n' ){
zHelp[nHelp++] = '\n';
}else{
if( strncmp(&zLine[3], "Usage: ", 6)==0 ) nHelp = 0;
strcpy(&zHelp[nHelp], &zLine[3]);
nHelp += strlen(&zHelp[nHelp]);
| > | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
char *z;
if( nUsed<=nFixed ) return;
if( strncmp(zLine, "**", 2)==0
&& isspace(zLine[2])
&& strlen(zLine)<sizeof(zHelp)-nHelp-1
&& nUsed>nFixed
&& memcmp(zLine,"** COMMAND:",11)!=0
&& memcmp(zLine,"** WEBPAGE:",11)!=0
){
if( zLine[2]=='\n' ){
zHelp[nHelp++] = '\n';
}else{
if( strncmp(&zLine[3], "Usage: ", 6)==0 ) nHelp = 0;
strcpy(&zHelp[nHelp], &zLine[3]);
nHelp += strlen(&zHelp[nHelp]);
|
| ︙ | ︙ | |||
240 241 242 243 244 245 246 |
}
/*
** Build the binary search table.
*/
void build_table(void){
int i;
| < > < | | > | | | | | | > | > | > | | | > | | | | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
}
/*
** Build the binary search table.
*/
void build_table(void){
int i;
qsort(aEntry, nFixed, sizeof(aEntry[0]), e_compare);
for(i=0; i<nFixed; i++){
if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
printf("extern void %s(void);\n", aEntry[i].zFunc);
if( aEntry[i].zIf ) printf("#endif\n");
}
printf(
"typedef struct NameMap NameMap;\n"
"struct NameMap {\n"
" const char *zName;\n"
" void (*xFunc)(void);\n"
" char cmdFlags;\n"
"};\n"
"#define CMDFLAG_1ST_TIER 0x01\n"
"#define CMDFLAG_2ND_TIER 0x02\n"
"#define CMDFLAG_TEST 0x04\n"
"#define CMDFLAG_WEBPAGE 0x08\n"
"static const NameMap aWebpage[] = {\n"
);
for(i=0; i<nFixed && aEntry[i].eType==0; i++){
const char *z = aEntry[i].zPath;
int n = strlen(z);
if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
printf(" { \"%s\",%*s %s,%*s 1 },\n",
z,
25-n, "",
aEntry[i].zFunc,
(int)(35-strlen(aEntry[i].zFunc)), ""
);
if( aEntry[i].zIf ) printf("#endif\n");
}
printf("};\n");
printf(
"static const NameMap aCommand[] = {\n"
);
for(i=0; i<nFixed /*&& aEntry[i].eType==1*/; i++){
const char *z = aEntry[i].zPath;
int n = strlen(z);
int cmdFlags = (1==aEntry[i].eType) ? 0x01 : 0x08;
if(0x01==cmdFlags){
if( z[n-1]=='*' ){
n--;
cmdFlags = 0x02;
}else if( memcmp(z, "test-", 5)==0 ){
cmdFlags = 0x04;
}
}
if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
printf(" { \"%s%.*s\",%*s %s,%*s %d },\n",
(0x08 & cmdFlags) ? "/" : "",
n, z,
25-n, "",
aEntry[i].zFunc,
(int)(35-strlen(aEntry[i].zFunc)), "",
cmdFlags
);
if( aEntry[i].zIf ) printf("#endif\n");
}
printf("};\n");
for(i=0; i<nFixed; i++){
char *z = aEntry[i].zHelp;
if( z && z[0] ){
if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
printf("static const char zHelp_%s[] = \n", aEntry[i].zFunc);
printf(" \"");
while( *z ){
if( *z=='\n' ){
printf("\\n\"\n \"");
}else if( *z=='"' ){
printf("\\\"");
}else{
putchar(*z);
}
z++;
}
printf("\";\n");
if( aEntry[i].zIf ) printf("#endif\n");
aEntry[i].zHelp[0] = 0;
}
}
puts("struct CmdHelp {"
"int eType; "
"char const * zText;"
"};");
puts("static struct CmdHelp aCmdHelp[] = {");
for(i=0; i<nFixed; i++){
if( aEntry[i].zIf ) printf("%s", aEntry[i].zIf);
if( aEntry[i].zHelp==0 ){
printf("{%d, 0},\n", aEntry[i].eType);
}else{
printf("{%d, zHelp_%s},\n", aEntry[i].eType, aEntry[i].zFunc);
}
if( aEntry[i].zIf ) printf("#endif\n");
}
printf("};\n");
}
/*
|
| ︙ | ︙ |
Changes to src/rss.c.
| ︙ | ︙ | |||
20 21 22 23 24 25 26 | #include "config.h" #include <time.h> #include "rss.h" #include <assert.h> /* ** WEBPAGE: timeline.rss | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include "config.h" #include <time.h> #include "rss.h" #include <assert.h> /* ** WEBPAGE: timeline.rss ** URL: /timeline.rss?y=TYPE&n=LIMIT&tkt=UUID&tag=TAG&wiki=NAME&name=FILENAME ** ** Produce an RSS feed of the timeline. ** ** TYPE may be: all, ci (show checkins only), t (show tickets only), ** w (show wiki only). LIMIT is the number of items to show. ** ** tkt=UUID filters for only those events for the specified ticket. tag=TAG |
| ︙ | ︙ |