View Single Post
  #33 (permalink)  
Old 07-31-2008, 11:23 PM
digitaldon37 digitaldon37 is online now
Senior Member
 
Join Date: Jan 2008
Posts: 143
Default agraham's suggestion works great

I noticed agraham's suggestion after I posted my reply, so I decided to give it a try. I took your example and made the following mods

1. Added a "splash" page on load - this could be written as an index for the different wikis - after the web.new

Code:
web.DocumentText="<html><body><p><a class='internal' href='homepage.txt'>Home Page</a></p></body></html>"
2. Changed GetFile routine. I changed this
Code:
web.DocumentText = HtmStr
to this:
Code:
Return HtmStr
3. Modified web_Navigating route to this:
Code:
Sub web_Navigating
	
	If web.NavigatingURL = "about:blank" Then
		
		url="homepage.txt"
	
	Else
		'Msgbox (web.NavigatingURL)
		
		url=SubString(web.NavigatingURL,6, StrLength(web.NavigatingURL)-6)
		x=getFile(url)
		web.DocumentText=x
	End If
 
End Sub
I created a couple of wiki texts with the filenames that you had in your example file and ran it. The result was this

1. Page loaded with one link to "Home Page" (click on link)
2. Home Page loaded (click on 1st link)
3. New page loaded (wiki text file that I created)

Here's your new code:
Code:
Sub Globals
    'Declare the global variables here.
	ReEntry = false ' in Globals

End Sub

Sub App_Start
  Form1.Show
  web.New1("Form1",10,30,770,500)
  web.DocumentText="<html><body><p><a class='internal' href='homepage.txt'>Home Page</a></p></body></html>"
  
End Sub


Sub Button1_Click
    'web.Navigate(Textbox1.Text)
	
    web.url = Textbox1.Text 'either Navigate or assigning to Url will load the web page
End Sub

Sub GetFile(file)
 If FileExist (file) = true Then
  FileOpen (c1,file,cRead ,, cASCII)
   HtmStr = "<html><head><meta http-equiv=Content-Type content=text/html; charset=utf-8>"
   HtmStr = HtmStr & "<title>homepage</title>"
   HtmStr = HtmStr & "<link rel=stylesheet href=file:///C:\Users\Tony\Documents\WM_Wiki_Pages\Locks\wikistyle.css Type=text/css>"
   HtmStr = HtmStr & "</head><body>"
            line = FileRead (c1)
   Do Until line = EOF
    If line <> EOF Then
                    If SubString(line, 0, 1) = "[" Then
                     If SubString(line,1,1) = "^" Then
                         ' do nothing
                            HtmStr = HtmStr & "Insert page here" & crlf
                        Else
                      HtmStr = HtmStr & "<p><a class=" & Chr(34) & "internal" & Chr(34) & " href=" & Chr(34)
                         HtmStr = HtmStr & SubString(line,1, StrLength(line)-2) & ".txt" & Chr(34) & ">" & SubString(line,1, StrLength(line)-2)
                         HtmStr = HtmStr & " </a> &nbsp;</p>" & crlf
                        End If
                    End If
                    If SubString(line, 0, 1) = "+" Then
                     HtmStr = HtmStr & "<h1><a name=Locks%20Wiki>"
                        HtmStr = HtmStr & SubString(line,1, StrLength(line))
                        HtmStr = HtmStr & "</a></h1>" & crlf
                    End If
                End If
                line = FileRead (c1)
   Loop
  FileClose (c1)
  Return HtmStr
  	'	Msgbox(HtmStr)
    '    web.DocumentText = HtmStr
	'	Msgbox("complete")
 End If
End Sub

Sub Button2_Click
 GetFile("homepage.txt")
End Sub
Sub web_DocumentCompleted
    'Msgbox("Completed", web.Url)
	'Msgbox("web_completed")
End Sub

Sub web_Navigating
	
	If web.NavigatingURL = "about:blank" Then
		
		url="homepage.txt"
	
	Else
		'Msgbox (web.NavigatingURL)
		
		url=SubString(web.NavigatingURL,6, StrLength(web.NavigatingURL)-6)
		'Msgbox(url)
		x=getFile(url)
		'Msgbox(x)
		web.DocumentText=x
	End If
 
End Sub

Sub web_Navigated
'	Msgbox("web_Navigated")
'    Msgbox("Navigated to" &  crlf & web.Url)
    Textbox1.Text = web.Url
End Sub
Credit goes to agraham for the web browser library and his suggestion.
Reply With Quote