Personal Pocket PC Wiki

tsteward

Well-Known Member
Licensed User
Longtime User
I have started creating a Personal Wiki.
I decided to post it here under Open Source so all can use this program if they wish, but PLEASE post any improvements you make here.

Goals
  • Must run on both Desktop and PDA
  • Must support current BladeWiki syntax (for now)
It is currently only just the beginning and I am no programmer, just a hack. So anyone wishing to correct my coding or show me a better way then I am all ears.

This program is really coming along now. Thanks to Digitaldon37 and Klaus for there help. Thanks to agraham for his Web Browser.

I use this wiki for everything now. I organise my work documentation, instructions sheets, Product pictures and descriptions. Have Birthday lists, XMas card lists, Bank details. It is great for gathering all you info in one place.

I have bucked what seems to be the standard and included all library files in the zip. I just think its easier.

Regards
Tony Steward

Last Updated 6:00pm 5th Jan 2009
Attachment includes both PPC and Desktop versions.
You will need to add "System.Data.SQLite.dll" its not in the zip because its too large
 

Attachments

  • ppcWikiHelp.zip
    49.6 KB · Views: 507
  • PPPCWiki1-6-4.zip
    311.1 KB · Views: 549
Last edited:

tsteward

Well-Known Member
Licensed User
Longtime User
Reserved Progress Report

Version 1 Realeased :sign0162:

Known Bugs:
  • Only on some PDA's it would seem that only one image is being displayed per page. Note sure why yet.
 
Last edited:

tsteward

Well-Known Member
Licensed User
Longtime User
Struggling with the interpreter for reading in bladewiki files, but getting there slowly.

Currently I load a line from the file then process that line character by character to find the markup.

+ = <h1> Header Level 1
++ = <h2> Header Level 2
- = <li> list item
[ = Start of link to another file
] = end of link to another file

There is more but that's enough for now.

Here is my interpreter so far.
B4X:
Sub GetFile(file)
 file = ProgDir & file
 If FileExist (file) = true Then
  FileOpen (c1,file,cRead ,, cASCII)
   HtmStr = "<html><head><meta http-equiv=" & Chr(34) & "Content-Type" & Chr(34) & " content=" & Chr(34) & "text/html; charset=utf-8" & Chr(34) & ">" & crlf
   HtmStr = HtmStr & "<title>homepage</title>" & crlf
   HtmStr = HtmStr & "<link rel=" & Chr(34) & "stylesheet" & Chr(34) & " href=" & Chr(34) & "file:///" & ProgDir & "wikistyle.css" & Chr(34) & " Type=" & Chr(34) & "text/css" & Chr(34) & ">" & crlf
   HtmStr = HtmStr & "</head><body>" & crlf
   line = FileRead (c1)
   Do Until line = EOF
    If line <> EOF Then                   ' START PROCESSING LINE
                 For i = 0 To StrLength(line)-1
                     If i = 0 AND bullet = True Then     ' CHECK TO SEE IF WE SHOULD END BULLET LIST
                         HtmStr = HtmStr & "</ul>"
                            bullet = False
                        End If
      If i = 0 AND SubString(line, i, 2) = "++" Then ' START HEADER LEVEL 2
                         If header2 = False Then
                          header2 = True
        HtmStr = HtmStr & "<h2><a name=" & Chr(43) & currentpage & Chr(34) & ">"
                            End If
                        Else If i = 0 AND SubString(line, 0, 1) = "+" Then ' START HEADER LEVER 1
                         If header1 = False Then
                          header1 = True
        HtmStr = HtmStr & "<h1><a name=" & Chr(43) & currentpage & Chr(34) & ">"
                            End If
                     Else If i = 0 AND SubString(line, 0, 1) = "-" Then 
                      If bullet = False Then                  ' START BULLET LIST
                          bullet = True
                                HtmStr = HtmStr & "<ul><li>"
                         Else                                    ' CONTINUE BULLET
                          HtmStr = HtmStr & "<li>"
                         End If
                        Else
                         If i = 0 Then
                             HtmStr = HtmStr & "<p>"                ' START PARAGRAPH
                                paragraph = True
                            End If
                         HtmStr = HtmStr & SubString(line, i, 1)
      End If
                    Next                                 ' FINNISHED LINE NOW TIDYUP BEFORE NEXT LINE
    End If
                If header1 = True Then                ' CLOSE HEADER 1
                 header1 = False
                    HtmStr = HtmStr & "</a></h1>" & crlf
                End If
                If header2 = True Then                ' CLOSE HEADER 2
                 header2 = False
                    HtmStr = HtmStr & "</a></h2>" & crlf
                End If
                If paragraph = True Then              ' CLOSE PARAGRAPH
                 paragraph = False
                 HtmStr = HtmStr & "</p>"
    End If
                HtmStr = HtmStr & crlf                ' ADD LINE FEED TO MAKE SOURCE CLEAN
    line = FileRead (c1)
   Loop
  FileClose (c1)
  Return HtmStr
 End If
End Sub
 

digitaldon37

Active Member
Licensed User
Longtime User
wiki parser

Hi Tony,

I noticed that you are reading the wiki file one line at a time. There are some pros and cons to that, but my opinion is that you may want to read the whole file at once and then parse. The reason is that you don't have to write the wiki text with the closing tags all on one line.

I created two new procedures that you may want to look at

Read File
B4X:
Sub ReadWikiFile(file)
   file = ProgDir & file
   If FileExist (file) = true Then
      FileOpen (c1, file, cRead ,, cASCII)
      wiki = FileReadToEnd(c1)
      FileClose (c1)
      
      Return ParseWiki(wiki)

   Else
   ' wiki file doesn't exist - how did that happen?
   End If
End Sub

Parser
B4X:
Sub ParseWiki (wiki)
   'HTML Header
   HtmStr = "<html><head><meta http-equiv=" & Chr(34) & "Content-Type" & Chr(34) & " content=" & Chr(34) & "text/html; charset=utf-8" & Chr(34) & ">" & crlf
      HtmStr = HtmStr & "<title>homepage</title>" & crlf
      HtmStr = HtmStr & "<link rel=" & Chr(34) & "stylesheet" & Chr(34) & " href=" & Chr(34) & "file:///" & ProgDir & "wikistyle.css" & Chr(34) & " Type=" & Chr(34) & "text/css" & Chr(34) & ">" & crlf
     HtmStr = HtmStr & "</head><body>" & crlf

   For x=0 To StrLength(wiki)
      
   
      schr=SubString(wiki,x,1)
      ' Msgbox(schr)
      
      ' --- CONVERT SIMPLE SINGLE CHARACTERS ---
      If schr=" " Then
         HtmStr=HtmStr & "&nbsp;"
      End If
      If schr=Chr(13) Then
         HtmStr=Htmstr & "<br>"
      End If
      
      ' --- CONVERT LINK ---
      Select schr
         Case "["
      'If schr="[" Then
         If SubString(wiki,x+1,1)="[" Then ' this is reference with differnt text ie [[wiki][welcome to my wiki!]]
            
         End If
         y=StrIndexOf(wiki, "]", x)
         'Msgbox(x & " " & y)
         HtmStr=Htmstr & "<a href='" & SubString(wiki,x+1,y-x-1) & "'>" & SubString(wiki,x+1,y-x-1) & "</a>"
         ' Msgbox(SubString(wiki,x+1,y-x-1))
         'Msgbox(htmstr)
         x=y
      'End If
      
      Case Else
         HtmStr=HtmStr & schr
      End Select
   Next
   
   'HTML FOOTER
   HtmStr=HtmStr & "</body></html>"
   
   
   Return Htmstr
End Sub

This was tested on your sample wiki text and it creates links out of the "[text]" markups. It still needs a lot of work but it's an example.
 
Last edited:

tsteward

Well-Known Member
Licensed User
Longtime User
Yes I agree reading the whole file at once would be better and generally speeds up programs and is usually less drain on resources.

Thanks for that code suggestion I'll look at it. It seems less confusing than what I did.
 

tsteward

Well-Known Member
Licensed User
Longtime User
Damn
Ok we need to work on a way to communicate on who is doing what.
I have a version working beautifully on my desktop but not running on ppc.
I haven't looked at your code above yet but will do so.
Have to go out for the day will do more tonight. about 6 hrs time

Thanks
Tony

This is where I was up to (your changes not included yet)
 

Attachments

  • wiki.sbp
    7.4 KB · Views: 375

tsteward

Well-Known Member
Licensed User
Longtime User
Ok the error causing PPPCWiki not to run on ppc is:
B4X:
HtmStr = HtmStr & "<link rel=" & Chr(34) & "stylesheet" & Chr(34) & " href=" & Chr(34) & "file:///" & ProgDir & "wikistyle.css" & Chr(34) & " Type=" & Chr(34) & "text/css" & Chr(34) & ">" & crlf

I'm not really sure why:sign0085:
Its around line 56, just comment it out and all is fine but of course the css won't be working.
 

Cableguy

Expert
Licensed User
Longtime User
Damn
Ok we need to work on a way to communicate on who is doing what.

Tony

I would suggest you to subscrive to an Web based project Share space....
I havent search for one, but i'm sure that they are available, and mos surelly, for free too...
 

digitaldon37

Active Member
Licensed User
Longtime User
works on desktop, not on pda

Tony,

I've tried everything I can think of - this works on my PC but I get an "invalid address" on the PDA. I've written and rewritten the web_navigating procedure and get the same results.

Is this working on your PDA?

Don
 

Attachments

  • wiki.sbp
    10.2 KB · Views: 391

tsteward

Well-Known Member
Licensed User
Longtime User
Tony,

I've tried everything I can think of - this works on my PC but I get an "invalid address" on the PDA. I've written and rewritten the web_navigating procedure and get the same results.

Is this working on your PDA?

Don

No its not working I get error:
This URL is not properly formatted.
 

digitaldon37

Active Member
Licensed User
Longtime User
wiki .12

I'm still getting the invalid addresses in the web browser, but at least now I'm able to navigate to the linked pages.

Attached is latest version.

I don't get the error on the main page, or when saving after an edit (which does a wb.document) - only when clicking on a link and navigating to another page. And only on the PDA.

The PDA is adding intermediate page urls such as "blankTEST" when I click on the test link. I'm intercepting those pages and reformatting but it still throws a PIE error.

Frustrating!:sign0085:
 

tsteward

Well-Known Member
Licensed User
Longtime User
Agreed I get the same error.
Maybe this is something the author of WebBrowser.dll could help with? or do you thinks its PIE causing the problems.
 

agraham

Expert
Licensed User
Longtime User
What OS have you on the PDA? Devices have different functionality depending upon the OS as I partially documented in the help. See this page How to: Use the WebBrowser Control in the .NET Compact Framework although I would treat it as a guide rather than gospel.

The .NET Compact Framework WebBrowser control is very limited compared the desktop version and although I have limited the functionality in the library to that (nominally) available on the device it may work differently as the underlying browser controls are different. This may be why css doesn't work on the device - if indeed it works on the desktop.

By the way, I am a systems engineer not a web designer so I know little or nothing (nor want to :) ) about webby stuff - HTML, style sheets etc. so I can't help out with anything related to content - only funtionality and even then I will need example code, preferably bare-bones, that I could run to see the problem.
 

tsteward

Well-Known Member
Licensed User
Longtime User
I am using Windows Mobile 6.
The problem is not so much loading or using the css file.
The problem we are having is that when clicking on a link we cant load the file as we get an error "URL is incorrectly formatted". However on the desktop it works fine.

digitaldon37 may be able to give a better explaination. But we load the first text file and convert it into html and send it to the browser. Clicking on a link we trap that, extract the filename and load that text file. Convert it into html and on the cycle goes.

Please download the file on post #1 and run it on your device if possible.

All help appreciated

Thanks
Tony
 

tsteward

Well-Known Member
Licensed User
Longtime User
Here is a barebones or as close as I can get version.
 

agraham

Expert
Licensed User
Longtime User
I don't really understand what all this "about:" and "href" stuff is about :confused: but after a couple of hours of trial and error I got BareWiki working on my device by changing

HtmStr=Htmstr & "<a href='" & SubString(wiki,x+1,y-x-1) & "'> ...

to

HtmStr=Htmstr & "<a href='about:" & SubString(wiki,x+1,y-x-1) & "'> ...

On my WM2003 device I didn't get that "URL is incorrectly formatted" error, it just didn''t work. If I had paid due attention to your error I might have zeroed in a bit quicker. Just shows how details pay off in debugging (or should have done!).

If you have further problems note that although you might get away with assigning DocumentText in the Navigating event you might get reentrancy problems - or you might not. YMMV.

Note that one time waster I encountered was that I discovered that, on Vista at least, having the device connected to the desktop screws up Internet Explorer and the WebBrowser control - I think because the Mobile Device Center/ActiveSync drivers mess around with the network settings on the device and assign it a new IP (or something!).
 
Last edited:

digitaldon37

Active Member
Licensed User
Longtime User
pda error

I think the problem is related to reentry. There are a couple of other procedures where the web.document is being set and no error is generated. This seems to only throw an error on the PDA when setting web.document in the web_navigating procedure.

I'm not sure how I can work around that, as I am using the web_navigating procedure to trap the click. It seems that trapping the click (which invokes the web_navigating procedure) to set the web.document property in turn generates an event that calls web_navigating.

I tried adding an "on error" but it doesn't work - this seems to be an error that PIE is messaging back.

The only thing I can think of is to modify the browser wrapper to validate the URL and to return invalid ones and pass along valid ones. But at the moment I'm not sure what is being considered invalid URLs.:sign0085:

In case anyone is interested, I added some debug printing (see attached) - in this example the program loads the main wiki page (one call to web_navigating) and then I clicked on the "test" link (two calls to web_navigating)
 
Last edited:

agraham

Expert
Licensed User
Longtime User
:sign0085:
I'm afraid that as far as I am concerned you are pretty much on your own unless some other guy that knows about this HTML stuff (Alfcen?) can comment. The WebBrowser library has no logic in it, it merely exposes to B4ppc the WeBrowser properties and methods so what you are seeing is what the .NET WebBrowser control does. I know how to write code, I don't know how to write HTML and investigate the functionality of the WebBrowser.

Incidentally have you seen what badkarma has done using the WebBrowser library. He has managed to work around the OS differences and it is quite impressive http://www.b4x.com/forum/share-your-creations/2190-adventure-pda.html He is doing this with some sort of local (non-Internet) links but I have no idea how!
 
Last edited:

digitaldon37

Active Member
Licensed User
Longtime User
pda error - web.document

agraham,

Thanks for the suggestion. I looked at the source for AdvPDA and noticed that he is not setting web.document within web_navigating. I think I will have to come up with something like he's doing; he has links within his browser display and is able to intercept the click and parse the link (for "north", "south" etc)

The debug file that I ran on the pda shows that on a click the navigating procedure is called, parsing is executed, navigating procedure is called, and then there are two navigating ends. In other words it looks like a nested call - and that the error is generated on the inner one.

I'm not sure why this causes a URI error on the PDA and not on the PC. The PC version of IE must be more forgiving.

UPDATE: I don't think it's the multiple calls within the procedure - I think that the problem is pocket IE doesn't like any URIs besides "About:blank" I can type in "about:blank" into the web browser and there's no error, but if I type in "about:test" (one of our links) it causes an error.

In my code, the top level page's navigating.url is "about:blank" (so there is no error) but the links from within that page have a navigating.url that is like "about:test" (which causes PIE to throw an invalid address error)
 
Last edited:
Top