Skip to content

Commit d4e6b51

Browse files
committed
fbdoc: separate methods for loading a page and the index in CWikiCon.LoadPage() and LoadIndex()
1 parent f93b399 commit d4e6b51

File tree

7 files changed

+82
-37
lines changed

7 files changed

+82
-37
lines changed

doc/fbchkdoc/getindex.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ else
326326
end if
327327

328328
print "Loading '" + sPage + "': ";
329-
if( wikicon->LoadPage( sPage, FALSE, FALSE, sBody ) = FALSE ) then
329+
if( wikicon->LoadIndex( sPage, sBody ) = FALSE ) then
330330
print "Error"
331331
else
332332
print "OK"

doc/fbchkdoc/putpage.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ if( app_opt.pageCount > 0 ) then
137137
print "Unable to load"
138138
else
139139
print "OK"
140-
if( wikicon->LoadPage( sPage, TRUE, TRUE, sBodyOld ) <> FALSE ) then
140+
if( wikicon->LoadPage( sPage, sBodyOld ) <> FALSE ) then
141141
if( wikicon->GetPageID() > 0 ) then
142142
if( wikicon->Login( app_opt.wiki_username, app_opt.wiki_password ) ) = FALSE then
143143
print "Unable to login"

doc/libfbdoc/CWikiCon.bas

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,32 @@ namespace fb.fbdoc
4040
'':::::
4141
function CWikiCon.LoadPage _
4242
( _
43-
byval page as zstring ptr, _
44-
byval israw as integer, _
45-
byval getid as integer, _
43+
byval pagename as zstring ptr, _
4644
byref body as string _
4745
) as boolean
4846

47+
body = ""
48+
function = false
49+
50+
end function
51+
52+
'':::::
53+
function CWikiCon.LoadIndex _
54+
( _
55+
byval pagename as zstring ptr, _
56+
byref body as string _
57+
) as boolean
58+
59+
body = ""
4960
function = false
5061

5162
end function
5263

5364
'':::::
5465
function CWikiCon.StorePage _
5566
( _
56-
byval sPage as zstring ptr, _
57-
byval sBody as zstring ptr _
67+
byval body as zstring ptr, _
68+
byval note as zstring ptr _
5869
) as boolean
5970

6071
function = false

doc/libfbdoc/CWikiCon.bi

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ namespace fb.fbdoc
3030

3131
declare virtual function LoadPage _
3232
( _
33-
byval page as zstring ptr, _
34-
byval israw as integer, _
35-
byval getid as integer, _
33+
byval pagename as zstring ptr, _
34+
byref body as string _
35+
) as boolean
36+
37+
declare virtual function LoadIndex _
38+
( _
39+
byval pagename as zstring ptr, _
3640
byref body as string _
3741
) as boolean
3842

3943
declare virtual function StorePage _
4044
( _
41-
byval sPage as zstring ptr, _
42-
byval sBody as zstring ptr _
45+
byval body as zstring ptr, _
46+
byval note as zstring ptr _
4347
) as boolean
4448

4549
declare virtual function StoreNewPage _

doc/libfbdoc/CWikiConUrl.bas

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,49 @@ namespace fb.fbdoc
372372

373373
'':::::
374374
function CWikiConUrl.LoadPage _
375+
( _
376+
byval pagename as zstring ptr, _
377+
byref body as string _
378+
) as boolean
379+
380+
function = FALSE
381+
body = ""
382+
383+
if( ctx = NULL ) then
384+
exit function
385+
end if
386+
387+
ctx->pageid = -1
388+
ctx->pagename = reallocate( ctx->pagename, len( *pagename ) + 1 )
389+
*ctx->pagename = *pagename
390+
391+
dim as CHttpStream ptr stream
392+
393+
stream = new CHttpStream( ctx->http )
394+
if( stream = NULL ) then
395+
exit function
396+
end if
397+
398+
dim URL as string
399+
URL = build_url( ctx, NULL, @wakka_raw )
400+
401+
if( stream->Receive( URL, TRUE, ctx->ca_file ) ) then
402+
body = stream->Read()
403+
remove_http_headers( body )
404+
end if
405+
406+
delete stream
407+
408+
ctx->pageid = get_pageid( ctx )
409+
410+
function = TRUE
411+
412+
end function
413+
414+
'':::::
415+
function CWikiConUrl.LoadIndex _
375416
( _
376417
byval page as zstring ptr, _
377-
byval israw as integer, _
378-
byval getid as integer, _
379418
byref body as string _
380419
) as boolean
381420

@@ -397,43 +436,30 @@ namespace fb.fbdoc
397436
exit function
398437
end if
399438

400-
dim as zstring ptr rawmethod = iif( israw, @wakka_raw, NULL )
401-
402439
dim URL as string
403-
URL = build_url( ctx, NULL, rawmethod )
440+
URL = build_url( ctx, NULL, NULL )
404441

405442
if( stream->Receive( URL, TRUE, ctx->ca_file ) ) then
406443
body = stream->Read()
407444
remove_http_headers( body )
408-
'' remove_trailing_whitespace( body )
409445
end if
410446

411447
delete stream
412448

413-
if( getid ) then
414-
'if( len( body ) > 0 ) then
415-
ctx->pageid = get_pageid( ctx )
416-
'else
417-
' ctx->pageid = -1
418-
'end if
419-
else
420-
ctx->pageid = -1
421-
end if
449+
ctx->pageid = -1
422450

423-
''body += chr( 13, 10 )
424-
425451
function = TRUE
426452

427453
end function
428454

429455
'':::::
430456
function CWikiConUrl.StorePage _
431457
( _
432-
byval body_in as zstring ptr, _
458+
byval body as zstring ptr, _
433459
byval note as zstring ptr _
434460
) as boolean
435461

436-
dim body as string
462+
dim body_out as string
437463

438464
if( ctx = NULL ) then
439465
return FALSE
@@ -452,9 +478,9 @@ namespace fb.fbdoc
452478

453479
form->Add( "wakka", *ctx->pagename + wakka_edit )
454480
form->Add( "previous", ctx->pageid )
455-
body = *body_in
456-
'' remove_trailing_whitespace( body )
457-
form->Add( "body", body, "text/html" )
481+
body_out = *body
482+
483+
form->Add( "body", body_out, "text/html" )
458484
if( note ) then
459485
form->Add( "note", *note )
460486
else

doc/libfbdoc/CWikiConUrl.bi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ namespace fb.fbdoc
4949
declare function LoadPage _
5050
( _
5151
byval page as zstring ptr, _
52-
byval israw as integer, _
53-
byval getid as integer = TRUE, _
52+
byref body as string _
53+
) as boolean
54+
55+
declare function LoadIndex _
56+
( _
57+
byval page as zstring ptr, _
5458
byref body as string _
5559
) as boolean
5660

doc/libfbdoc/fbdoc_loader.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace fb.fbdoc
8080
if( bLoadPage ) then
8181
dim as CWikiConUrl ptr wikicon = Connection_Create( )
8282
printlog "Loading '" + *sPage + "'"
83-
if( wikicon->LoadPage( sPage, TRUE, TRUE, sBody ) <> FALSE ) then
83+
if( wikicon->LoadPage( sPage, sBody ) <> FALSE ) then
8484
if( wikicon->GetPageID() > 0 ) then
8585
if( len(sBody) > 0 ) then
8686
wikicache->SavePage( sPage, sBody )

0 commit comments

Comments
 (0)