how to load a local file into the browser widget?

2019-05-25 Thread Curt Ford via use-livecode

Thanks, hh, that does it! :)

*answer*file"Choose an html file"

*put*urlEncode(textEncode(it, "UTF-8")) intotPathWithCyrillic

*set*theurlofwidget"Browser"totPathWithCyrillic


Occasional accents & punctuation in the file names are not causing 
problems either (so far). But then the spaces..


*replace*" "with"%20"intPathWithCyrillic

didn't work since the urlEncode was inserting "+" where it found a space.

So replacing "+" with "%20" fixes that. Final version:

*answer*file"Choose an html file"

*put*urlEncode(textEncode(it, "UTF-8")) intotPathWithCyrillic

*replace*"+"with"%20"intPathWithCyrillic

*set*theurlofwidget"Browser"totPathWithCyrillic

Thanks everyone!

Curt



You could try to use (for example):

urlEncode(textEncode("брать","UTF-8"))



--
Sent from Postbox 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: how to load a local file into the browser widget?

2019-05-25 Thread Paul Dupuis via use-livecode

On 5/25/2019 7:47 AM, Paul Dupuis via use-livecode wrote:

On 5/25/2019 4:17 AM, Klaus major-k via use-livecode wrote:

Sorry, I don't know, someone else needs to chime in here.
Obvioulsy "Unicode, it just works" doesn't do with filenames. :-/



Our experience with LC90x has been that Unicode DOES just work with 
filename, for 'open file , there is a file , put URL 
 into , and most other file related commands and functions. 
HOWEVER, I would never claim we've tested every LC file related 
command and function. We've done with with Russian text and Chinese 
(simplified and traditional) in both paths and file names.


Just another data point.


That was supposed to say: Just another data point, although we've never 
tested with a Browser Widget.



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: how to load a local file into the browser widget?

2019-05-25 Thread Paul Dupuis via use-livecode

On 5/25/2019 4:17 AM, Klaus major-k via use-livecode wrote:

Sorry, I don't know, someone else needs to chime in here.
Obvioulsy "Unicode, it just works" doesn't do with filenames. :-/



Our experience with LC90x has been that Unicode DOES just work with 
filename, for 'open file , there is a file , put URL 
 into , and most other file related commands and functions. 
HOWEVER, I would never claim we've tested every LC file related command 
and function. We've done with with Russian text and Chinese (simplified 
and traditional) in both paths and file names.


Just another data point.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: how to load a local file into the browser widget?

2019-05-25 Thread hh via use-livecode
>> Curt wrote:
>> While I'm at it... some of the folders in the file path will
>> be in Russian, which is breaking my current handler...
>> I can run those items of the file path through a quick
>> transliteration function to change брать into brat' etc., but
>> thought it's worth checking...

> Klaus wrote:
> Obvioulsy "Unicode, it just works" doesn't do with filenames. :-/

You could try to use (for example):

urlEncode(textEncode("брать","UTF-8"))
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: how to load a local file into the browser widget?

2019-05-25 Thread Klaus major-k via use-livecode
Hi Curt,

> Am 25.05.2019 um 00:43 schrieb Curt Ford via use-livecode 
> :
> 
> Thanks Klaus, those are great tips!

you are welcome!

> While I'm at it... some of the folders in the file path will be in Russian, 
> which is breaking my current handler. Is there a way to run them through some 
> unicode-type function to make them work in a file path?
> 
> I can run those items of the file path through a quick transliteration 
> function to change брать into brat' etc., but thought it's worth checking...

Sorry, I don't know, someone else needs to chime in here.
Obvioulsy "Unicode, it just works" doesn't do with filenames. :-/

> Curt

Best

Klaus

--
Klaus Major
http://www.major-k.de
kl...@major-k.de


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

how to load a local file into the browser widget?

2019-05-24 Thread Curt Ford via use-livecode

Thanks Klaus, those are great tips!

While I'm at it... some of the folders in the file path will be in 
Russian, which is breaking my current handler. Is there a way to run 
them through some unicode-type function to make them work in a file path?


I can run those items of the file path through a quick transliteration 
function to change брать into brat' etc., but thought it's worth checking...


Curt
--
Sent from Postbox 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

how to load a local file into the browser widget?

2019-05-24 Thread Curt Ford via use-livecode

Ah, thanks, Tore, that was it! Using two slashes in the handler

*put*"file://"& thedefaultFolder& slash& "Future.html"intotFile

produced the filePath with three slashes,

file:///Users/cford/Desktop/BrowserTryout/Future.html

which is now working fine. :)


--
Sent from Postbox 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: how to load a local file into the browser widget?

2019-05-24 Thread Klaus major-k via use-livecode
Hi all,

> Am 24.05.2019 um 23:00 schrieb Tore Nilsen via use-livecode 
> :
> 
> Try to start the url with «file:/// « this is what I get at the 
> start of the url of a browser widget
> when i set the url from a script using «answer file» to navigate to any valid 
> html file:
> on mouseUp
> answer file "Choose html file to display"
> set url of widget "browser" to it
> end mouseUp
> 
> Tore
> 
>> 24. mai 2019 kl. 22:29 skrev Curt Ford via use-livecode 
>> :
>>> You must make sure that the filePath to the html file you would like to see 
>>> does not contain any invalid characters like spaces, which you will find is 
>>> OK by the file system but not with the browser.
>> I had wondered about this; I renamed the file to "Browsertryout" and moved 
>> it to the desktop (so there were no spaces in the filePath, which is now 
>> "file://Users/cford/Desktop/Browsertryout.app/Contents/MacOS/Future.html"), 
>> but I'm still getting the same result (a blank widget).
>> 
>> Curt

it is TWO slashes actually -> file://
The third slash is from the actual filename -> 
/Users/cford/Desktop/Browsertryout.app/Contents/MacOS/Future.html

But why on earth are you always messing around with the DEFAULTFOLDER when we 
these lovely specialfolderpath() functions? 8-)
Do like this:
1. Add your files (hmtl, images, videos, sounds or whatever) to your standalone 
via the "Standalone Application Settings" -> "Copy files"
2. Then you will find them in your standalone in -> 
specialfolderpath("resources") on ANY platform
You can also use -> specialfolderpath("resources") in the IDE, where it points 
to the folder containing the executing stack.
Keep all your files (and folders) in that folder and with that and 1. above you 
do not need to script something different
for the IDE and standalone on ANY platform!
3. Do this to display the html file in a browser widget:
...
put specialfolderpath("resources") & "/Future.html" into tFile
## Important, if the pathname contains spaces:
replace " " with "%20" in tFile
set the url of widget "el browsero" to tFile
...

Hint:
Be aware that iOS and Android are case-sensitive operating systems: Future.html 
<> future.html
So it may be a good idea to name all of your files with lowercase and your are 
on the safe side.


Best

Klaus

--
Klaus Major
http://www.major-k.de
kl...@major-k.de


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: how to load a local file into the browser widget?

2019-05-24 Thread Tore Nilsen via use-livecode
Try to start the url with «file:/// « this is what I get at the start 
of the url of a browser widget when i set the url from a script using «answer 
file» to navigate to any valid html file:

on mouseUp

answer file "Choose html file to display"

set url of widget "browser" to it

end mouseUp


Tore

> 24. mai 2019 kl. 22:29 skrev Curt Ford via use-livecode 
> :
> 
>> You must make sure that the filePath to the html file you would like to see 
>> does not contain any invalid characters like spaces, which you will find is 
>> OK by the file system but not with the browser.
> I had wondered about this; I renamed the file to "Browsertryout" and moved it 
> to the desktop (so there were no spaces in the filePath, which is now 
> "file://Users/cford/Desktop/Browsertryout.app/Contents/MacOS/Future.html"), 
> but I'm still getting the same result (a blank widget).
> 
> Curt
> 
> -- 
> Sent from Postbox 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

how to load a local file into the browser widget?

2019-05-24 Thread Curt Ford via use-livecode

You must make sure that the filePath to the html file you would like to see 
does not contain any invalid characters like spaces, which you will find is OK 
by the file system but not with the browser.

I had wondered about this; I renamed the file to "Browsertryout" and moved it to the 
desktop (so there were no spaces in the filePath, which is now 
"file://Users/cford/Desktop/Browsertryout.app/Contents/MacOS/Future.html"), but I'm still 
getting the same result (a blank widget).

Curt

--
Sent from Postbox 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: how to load a local file into the browser widget?

2019-05-24 Thread Tore Nilsen via use-livecode
You must make sure that the filePath to the html file you would like to see 
does not contain any invalid characters like spaces, which you will find is OK 
by the file system but not with the browser.

Tore

> 24. mai 2019 kl. 22:02 skrev Curt Ford via use-livecode 
> :
> 
> Is there a trick to getting a local html file to display in the browser 
> widget? I'm using this in a test button (in 9.0.4, on a Mac):
> 
> *on*mouseUp
> 
> *# set the defaultFolder to the folder containing the stackfile*
> 
> *set*theitemDelimitertoslash*
> get*theeffectivefilenameofthisstack*
> set*thedefaultFoldertoitem1to-2 ofit*
> answer*"defaultFolder is"&& thedefaultFolder
> 
> *if* thereisafile"Future.html"*then**
> answer*"OK, it's there"*
> else**
> answer*"not found!"*
> end* *if*
> 
> *put*"file:/"& thedefaultFolder& slash& "Future.html"intotFile*
> set*theURLofwidget"Browser"totFile*
> answer*"the URL is"&& theURLofwidget"Browser"
> 
> *end*mouseUp
> 
> The .html file is in the same folder with the stack file, and in the 
> standalone I've copied it into the bundle & the stack seems to find it, but 
> nothing displays in the widget, both in IDE and the standalone. Loading a 
> remote location works fine with
> 
> *put*"https://nytimes.com"intotFile
> 
> *set*theURLofwidget"Browser"totFile
> 
> Is there something else to keep in mind when displaying a local file?
> 
> Curt
> 
> 
> -- 
> Sent from Postbox 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


how to load a local file into the browser widget?

2019-05-24 Thread Curt Ford via use-livecode
Is there a trick to getting a local html file to display in the browser 
widget? I'm using this in a test button (in 9.0.4, on a Mac):


*on*mouseUp

*# set the defaultFolder to the folder containing the stackfile*

*set*theitemDelimitertoslash*
get*theeffectivefilenameofthisstack*
set*thedefaultFoldertoitem1to-2 ofit*
answer*"defaultFolder is"&& thedefaultFolder

*if* thereisafile"Future.html"*then**
answer*"OK, it's there"*
else**
answer*"not found!"*
end* *if*

*put*"file:/"& thedefaultFolder& slash& "Future.html"intotFile*
set*theURLofwidget"Browser"totFile*
answer*"the URL is"&& theURLofwidget"Browser"

*end*mouseUp

The .html file is in the same folder with the stack file, and in the 
standalone I've copied it into the bundle & the stack seems to find it, 
but nothing displays in the widget, both in IDE and the standalone. 
Loading a remote location works fine with


*put*"https://nytimes.com"intotFile

*set*theURLofwidget"Browser"totFile

Is there something else to keep in mind when displaying a local file?

Curt


--
Sent from Postbox 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode