It is currently Wed Oct 23, 2019 7:51 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: html-files in an app-sub-folder
PostPosted: Fri Dec 02, 2016 7:10 pm 
Offline
User
User

Joined: Mon Dec 14, 2015 2:14 pm
Posts: 30
hi guys,

i have a problem that cost me lots of time, but i couldnt solve it.

Filesystem-history:
help.app/Contents/MacOS/helpfiles/

The app is called "help"
the html-files are how you see above in a sub-folder called "helpfiles"

the damn webgadget should show me the shit with file://

I have a sidebar-list on the left-side of the window and the webgadget at the rightside.

if i click on a html-file in the list, it shell show the damn content in the webgadget.

now the problem:

the app works in the compiled-directory very well. think the compiled-directory is just the project directory. think something like this:

/Users/myhome/myprojects/myhelpApp/

in that path is my source-code and if I compile the whole shit, I get there my help.app

if i double click on it, everything works perfect.

if i copy the shit to another directory on my computer, the program loads, but the html-files wont see.

i cannot post the whole code, because its to large. this is my code to find the correct root permanently:

Code:
Global myPath.s = ""
myPath = GetPathPart(ProgramFilename())
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  #sys_char = "\"
CompilerElse
  #sys_char = "/"
CompilerEndIf
If Right( myPath, 1 ) <> #sys_char
  myPath + #sys_char
EndIf
Global myFiles.s = myPath + "helpfiles/"


in my code, i call the url to a damn file like this:

Code:
SetGadgetText( webGadgetID, "files://" + myFiles + currentFile )


i checked "currentfile" it is correctly filled by the filename from the list:

Code:
If eventCode = #PB_Event_Gadget And EventGadget() = MyListID And EventType() = #PB_EventType_Change
  currentFile = GetGadgetItemText( MyListID, GetGadgetState(MyListID) )
  SetGadgetText( webGadgetID, "files://" + myFiles + currentFile )
EndIf


i think it has something to do with user-rights but i am not sure. i checked the file properties with the Information-Dialog of the mac and set the rights to everyone to read and write. I did it also for the entire help.app-directory and it's content. but doesn't work.

what do you i wrong?

has anyone an idea?


Top
 Profile  
Reply with quote  
 Post subject: Re: html-files in an app-sub-folder
PostPosted: Fri Dec 02, 2016 7:25 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 468
You must set the path to the main.html file relative.
"Resources/helpfiles/" or "Resources/helpfiles/main.html"

And than copy you help files folder inside the Resources inside of the help.app


Top
 Profile  
Reply with quote  
 Post subject: Re: html-files in an app-sub-folder
PostPosted: Fri Dec 02, 2016 7:51 pm 
Offline
User
User

Joined: Mon Dec 14, 2015 2:14 pm
Posts: 30
the relative-path is a good idea. i tried it.

the files become loaded into the listviewgadget successfully, but i cannot load the currentfile into the damn webgadget.

??


Top
 Profile  
Reply with quote  
 Post subject: Re: html-files in an app-sub-folder
PostPosted: Fri Dec 02, 2016 8:28 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 468
5mware wrote:
the relative-path is a good idea. i tried it.

the files become loaded into the listviewgadget successfully, but i cannot load the currentfile into the damn webgadget.

??


Code:
Bundle = CocoaMessage(0, 0, "NSBundle mainBundle")
BundlePath = CocoaMessage(0, Bundle, "bundlePath")
Path.s = PeekS(CocoaMessage(0, BundlePath, "UTF8String"), -1, #PB_UTF8)
Debug Path +"/Resources/helpfiles/"


Top
 Profile  
Reply with quote  
 Post subject: Re: html-files in an app-sub-folder
PostPosted: Fri Dec 02, 2016 8:47 pm 
Offline
User
User

Joined: Mon Dec 14, 2015 2:14 pm
Posts: 30
could the webgadget has a bug?

is there any special thing to do to get it work? maybe something with cocoa. e.g. pathing the url by cocoa instead of SetGadgetText()?

url = file://Resources/helpfiles/index.html

Cheching like this:

Code:
MessageRequester(Str(Filesize(currentFile)),currentFile)


is successful. In both ways (relative position and with the bundlepath from cocoa).

but the webgadget doens't respond anyway. it's blank.

I checked my html-files with firefox, chrome, opera. all fine. no problem.

??


Top
 Profile  
Reply with quote  
 Post subject: Re: html-files in an app-sub-folder
PostPosted: Fri Dec 02, 2016 9:06 pm 
Offline
User
User

Joined: Mon Dec 14, 2015 2:14 pm
Posts: 30
code:

Code:
  If pure_event = #PB_Event_Gadget And EventGadget() = #MyListID And EventType() = #PB_EventType_Change
    SetGadgetText( #WebGadgetID, "file://" + currentFile )
    SetWindowTitle( #MyWindow, URL = " + GetGadgetText(#WebGadgetID) )
  EndIf


result:

The webgadget keeps blank. no response.
but it returns the full-path to the html-file correctly to the window-title.

maybe a bug??


Top
 Profile  
Reply with quote  
 Post subject: Re: html-files in an app-sub-folder
PostPosted: Fri Dec 02, 2016 10:27 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 468
This is tested and works.

Code:
Bundle = CocoaMessage(0, 0, "NSBundle mainBundle")
BundlePath = CocoaMessage(0, Bundle, "bundlePath")
Path.s = PeekS(CocoaMessage(0, BundlePath, "UTF8String"), -1, #PB_UTF8)
Path +"/Contents/Resources/helpfiles/Main.html"
Debug Path


If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
    WebGadget(0, 10, 10, 580, 280, "file://" +Path)

    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: html-files in an app-sub-folder
PostPosted: Sat Dec 03, 2016 12:42 am 
Offline
User
User

Joined: Mon Dec 14, 2015 2:14 pm
Posts: 30
ok i solved it.

in your first code-snip you wrote

Code:
Bundle = CocoaMessage(0, 0, "NSBundle mainBundle")
BundlePath = CocoaMessage(0, Bundle, "bundlePath")
Path.s = PeekS(CocoaMessage(0, BundlePath, "UTF8String"), -1, #PB_UTF8)
Debug Path +"/Resources/helpfiles/"


in your last post your added "/Contents/Resource/helpfiles/". That helped and it works.

but i found the main reason why it doens't work, if you copy help.app to another directory.

the problem was white-spaces in the directory-names. Sample:

Quote:
/Users/myhome/mydir1/sample dir/help.app
... doens't work. dont know why.

Quote:
/Users/myhome/mydir1/sample-dir/help.app
or
Quote:
/Users/myhome/mydir1/sample_dir/help.app
works perfect.

maybe that would help some one who have the same problem.

:-) thanks.


Top
 Profile  
Reply with quote  
 Post subject: Re: html-files in an app-sub-folder
PostPosted: Sat Dec 03, 2016 12:16 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 468
5mware wrote:

Quote:
/Users/myhome/mydir1/sample dir/help.app
... doens't work. dont know why.

Quote:
/Users/myhome/mydir1/sample-dir/help.app
or
Quote:
/Users/myhome/mydir1/sample_dir/help.app
works perfect.




Add this code to your app.
Code:
Path = URLEncoder(Path)


Top
 Profile  
Reply with quote  
 Post subject: Re: html-files in an app-sub-folder
PostPosted: Sat Dec 03, 2016 12:40 pm 
Offline
User
User

Joined: Mon Dec 14, 2015 2:14 pm
Posts: 30
i solved the problem.

the webgadget does not accept white-spaces in the url. but you can change the white-spaces into %20. then it works without any problems.

:-)


Top
 Profile  
Reply with quote  
 Post subject: Re: html-files in an app-sub-folder
PostPosted: Sat Dec 03, 2016 3:02 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 468
It is not just the space (%20), there are more characters that have this problem.
So you must use the URLEncoder() function!

Code:
Path = URLEncoder(Path)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye