"dà © jà vu" ----> "déjà-vu" (='.'=)

Are you using LiveCode to create server scripts or CGIs?

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Mariasole
Posts: 201
Joined: Tue May 07, 2013 9:38 pm

Re: déjà vu (='.'=) [LiveCodeServer]

Post by Mariasole » Wed May 25, 2016 6:24 pm

ghettocottage wrote: I was wondering the same thing, but not necessarily using the .htaccess. I wonder if there is a way to have a config file for LivecodeServer to set/change some defaults.
It would be really interesting "to set up" LCS with a configuration file! Maybe it's possible!
But I am a beginner and do not know these things! :|
That's why I humbly ask for help! Thanks to all the people of the forum! :D

Mà rìà sòlè
(='.'=)
No input, no output. Man - Joe Strummer

Mariasole
Posts: 201
Joined: Tue May 07, 2013 9:38 pm

Re: déjà vu (='.'=) [LiveCodeServer]

Post by Mariasole » Wed May 25, 2016 6:27 pm

FourthWorld wrote:Re. #2: I asked because you mentioned that many (most?) of those HTML pages are static, exiting in complete form prior to using LC Server. What is it you want LC Server to do with those?
I want to add some dynamic parts, and I can only do so with the server-side script. So I use PHP or use LCS. But I do not know anything of PHP, however with LCS can try! :wink:

Mà rìà sòlè
(='.'=)
No input, no output. Man - Joe Strummer

Mariasole
Posts: 201
Joined: Tue May 07, 2013 9:38 pm

Re: déjà vu (='.'=) [LiveCodeServer]

Post by Mariasole » Thu May 26, 2016 6:39 pm

Hello to all friends of LiveCode and lovers of the wonderful and always lightly regarded world of Live Code Server (applause)! :lol:


I make a little summary of my little existential problem with LCS 8.0.1:

a) LC Server unfortunately adopts as the default charset output the "iso-8859-1"
b) I want to "run" pages with .htm ext with LC Server in my server
c) my configuration of .htaccess is

Code: Select all

AddHandler livecode-script .lc .irev .html .htm
d) So if I put on server a simple html page that says "déjà-vu", the LC server will restore me as "dà © jà vu".
e) I am aware that I can to remedy the problem write in my .html page

Code: Select all

put header "Content-Type: text/html; charset=utf-8" 
and "dà © jà vu" ----> "déjà-vu"
f) The problem lies in the coexistence of pages with .htm extension that "do something" with LCS and other pages (always with .htm extension) that "do nothing", that is, are completely static.
g) In fact for every static page I should put the string "put header....". But if I simply want to add "box" created by LCS (in some page of the existing site "static") , I'm forced to take down the site, make a parsing of all the pages and pick it up. So I can not "add" simply a new feature on a few pages because all the other pages become unreadable (UTF8 ---> ISO-8859-1).
h) If LCS had the default output UTF8 instead iso-8859-1, there would be no problems.
i) So my question is this: is possible via .htaccess change the default output of LCS from "iso-8859-1"to UTF8?

Is there any RunRev chief engineer who can tell me: " Uh! Put yourself the peace of mind, we have decided that you can not do anything, okay lassie? Uh! Be compliant! Stop experiment! Put some widget on your smartphone and stop tapping on the keyboard! Ok? Uh!"?

:shock: :shock: :shock:
:lol: :lol: :lol:

Thanks for those who will help me! I promise a prayer before going to sleep. I am not joking!

Mà rìà sòlè ----------> if there is a solution the "iso-8859-1" signature will return to UTF8 signature! :wink:
(='.'=)
No input, no output. Man - Joe Strummer

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 263
Joined: Tue Apr 10, 2012 9:18 am

Re: déjà vu (='.'=) [LiveCodeServer]

Post by ghettocottage » Fri May 27, 2016 4:18 pm

just thinking outside the box here...perhaps a simple command or script that goes through every file and adds an include phrase, something like:

Code: Select all

find . -type f -exec sed -i 4i"<?lc include '/path/to/include/file.lc ?>'"  {} \;
The above code will insert the include statement on every file (including files in sub-folders), starting from the folder you are in ...so only run it from inside your website folder.

The number 4 in the code tells it to insert it on the 4th line..but you can change that to whatever number you want.

then your included file could have whatever you need, plus any other functions, links, etc.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6044
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: déjà vu (='.'=) [LiveCodeServer]

Post by FourthWorld » Fri May 27, 2016 7:51 pm

For the dynamic parts you should be able to use something like:

Code: Select all

put textEncode(tSomeData,"UTF-8") into tSomeData
PS: I merged this thread with your other one so we have one place for answers. This seems a better fit for the CGI section anyway. If you don't see activity in a thread for more than 24 hours go ahead and bump it within the thread, but please don't create new threads pointing to one another so folks know where to find the relevant info. Most folks use "New Posts" when they log in, so a bump within the thread is usually all you need.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 302
Joined: Mon Jun 10, 2013 1:32 pm

Re: "dà © jà vu" ----> "déjà-vu" (='.'=)

Post by Lagi Pittas » Fri May 27, 2016 10:54 pm

Hi

Maybe this might help it adds the headers to all files (or so we are told) - never tried it.

Code: Select all

AddDefaultCharset UTF-8 
Lagi

SparkOut
Posts: 1751
Joined: Sun Sep 23, 2007 4:58 pm

Re: "dà © jà vu" ----> "déjà-vu" (='.'=)

Post by SparkOut » Sat May 28, 2016 3:21 am

Cara Maria

I have tried for a few hours to work out how to fix your problem, without success. All the .htaccess directives work correctly if you don't assign the .htm extension to the livecode server engine. I could not find a way to use .htaccess to override the output from LC.

Until someone manages to work out how you can achieve this globally, I think that probably the best thing you can do is to add

Code: Select all

<?lc put header "Content-Type: text/html; charset=utf-8" ?>
as the first line in each of your files to be served from the server.

You can use livecode to loop through all the files and put the required line "before" the content of each one. (If you get it wrong you can always change by putting the updated statement into line 1 of each file.)

Sorry for lack of success

Mariasole
Posts: 201
Joined: Tue May 07, 2013 9:38 pm

Re: "dà © jà vu" ----> "déjà-vu" (='.'=)

Post by Mariasole » Sat May 28, 2016 1:26 pm

Thank you all for your patience and for your support!

Thank you ghettocottage , your solution is very useful, although of course it does not solve the problem of default LCS output, but I think at this point that there are no solutions ...

Thank you Lagi I tried doing it ... but it does not work!

Thank you Richard , I'm really sorry. :cry: I did not want to be inopportune nor much less intrusive, just looking for help elsewhere in the forum, never imagining create entropy. Excuse me for my rudeness and I want to thank you for the hard work that you put in the administration of our community! Thanks, I realize how difficult, even humanly, may be. I'll try to be less "pasionaria"! :oops:

Thank you SparkOut, thanks for having dedicated your time :D . And for taking seriously my problem that, in fact, it seems a bit 'crazy :wink: . I think today what you suggested is the only way to get closer to a solution, even though, of course, if you could change the default output of the LCS problem would be solved! Thanks for trying, you are a treasure! :mrgreen:

Since the solution to my problem was found, namely, that no longer exists solution to my problem, will return for signature in UTF8!


Grazie a tutti!

Mariasole
(='.'=)
No input, no output. Man - Joe Strummer

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6044
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: "dà © jà vu" ----> "déjà-vu" (='.'=)

Post by FourthWorld » Sat May 28, 2016 7:35 pm

Mariasole wrote:Thank you Richard , I'm really sorry. :cry: I did not want to be inopportune nor much less intrusive, just looking for help elsewhere in the forum, never imagining create entropy. Excuse me for my rudeness and I want to thank you for the hard work that you put in the administration of our community! Thanks, I realize how difficult, even humanly, may be. I'll try to be less "pasionaria"! :oops:
On the contrary, your passionate nature if very helpful; it gives you the perseverance to keep trying even difficult things. Please don't change that.

The forums here are organized in a bit of a messy way. Too many categories in my opinion, but I haven't had enough time to trim them down and merge topics where they might benefit from a leaner taxonomy. So my merging your thread wasn't a reflection of you, but of the poor taxonomy here. You're fine, it's the forums that need fixing. :)

Was my suggestion of coercing LC's output to UTF-8 when it merges with the rest of your UTF-8 page helpful?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Mariasole
Posts: 201
Joined: Tue May 07, 2013 9:38 pm

Re: "dà © jà vu" ----> "déjà-vu" (='.'=)

Post by Mariasole » Mon May 30, 2016 6:52 pm

Grazie Richard!
I give me a lot of courage to continue experimenting! :D
Your advice was very helpful, although I did not want that LCS had an "active" role in the static page!
Sure there's no way to tell the CGI to change output from iso-8859-1to UTF-8? :roll:

Grazie tante davvero Richard!
Mariasole
(='.'=)
No input, no output. Man - Joe Strummer

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6044
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: "dà © jà vu" ----> "déjà-vu" (='.'=)

Post by FourthWorld » Tue May 31, 2016 5:07 pm

Mariasole wrote:Your advice was very helpful, although I did not want that LCS had an "active" role in the static page!
That's what I was asking about earlier. Your .htaccess is set up for LC Server to handle not only .lc files, but also .html. This directs Apache to pass every page on your site to LC Server, even those for which you don't want LC working on them at all.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Mariasole
Posts: 201
Joined: Tue May 07, 2013 9:38 pm

Re: "dà © jà vu" ----> "déjà-vu" (='.'=)

Post by Mariasole » Wed Jun 01, 2016 7:34 pm

Your .htaccess is set up for LC Server to handle not only .lc files, but also .html. This directs Apache to pass every page on your site to LC Server, even those for which you don't want LC working on them at all.
Dear Richard
This explanation is perfect! It happens exactly that. But I do not understand how to tell LC: this html page (that is, the static) you can not take into account! Leave it as it is! :oops:

I'm sorry, I do not understand the answer, you know that I have a hard head like a rock! :roll:
Thanks for your time and kindness! :D

(='.'=) Mariasole
No input, no output. Man - Joe Strummer

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6044
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: "dà © jà vu" ----> "déjà-vu" (='.'=)

Post by FourthWorld » Thu Jun 02, 2016 8:17 pm

Mariasole wrote:
Your .htaccess is set up for LC Server to handle not only .lc files, but also .html. This directs Apache to pass every page on your site to LC Server, even those for which you don't want LC working on them at all.
Dear Richard
This explanation is perfect! It happens exactly that. But I do not understand how to tell LC: this html page (that is, the static) you can not take into account! Leave it as it is! :oops:
A while back in this thread I asked about the inclusion of .html in your .htaccess directive for file types requiring LC Server:

Code: Select all

AddHandler livecode-script .lc .irev .html .htm
If you changed that to:

Code: Select all

AddHandler livecode-script .lc .irev
...then Apache will return to handling .htm and .html files directly without invoking LC Server for those, but will use LC Server for the types specified (.lc and .irev).

Is that what you're after?
I'm sorry, I do not understand the answer, you know that I have a hard head like a rock! :roll:
I prefer to think of that as indicative of a solid mind. :)
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Mariasole
Posts: 201
Joined: Tue May 07, 2013 9:38 pm

Re: "dà © jà vu" ----> "déjà-vu" (='.'=)

Post by Mariasole » Wed Jun 08, 2016 5:53 pm

Dear Richard,
thanks for your advice that, in fact, would be the wisest thing. :?
But I wanted to get that LCS could be treated differently a "static html" or a "dynamic html" (ie treated with LCS inside)! At the same time! 8)
I think though, unless we can not change the output of LCS in UTF8 , there is no solution! :cry:

Every now and then the solid mind crashed on the wall! :shock: :D

Grazie ancora...
Mariasole
(='.'=)
No input, no output. Man - Joe Strummer

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 996
Joined: Thu Apr 11, 2013 11:27 am

Re: "dà © jà vu" ----> "déjà-vu" (='.'=)

Post by LCMark » Fri Jun 10, 2016 9:46 am

@Mariasole: If I understand your problem correctly then:

1) You have a collection of HTML pages which are currently static and encoded with UTF-8.

2) You have some dynamic pages which you want to run through LC Server.

3) You want to be able to add some dynamic elements to *some* of the currently static HTML pages.

In general, it is much much better to let Apache serve static pages directly, leaving only the dynamic ones to go through LC Server / PHP / any other CGI-like thing. The reason here is that there is a significant performance cost to serving dynamic pages compared to static pages.

Okay, my suggestion for getting things working right now (which has already been suggested - in part) would be to use different extensions for these two types of pages - htm/html for the static ones and lc/lcs for the dynamic ones. You can then change the extensions of the pages as you add dynamic elements to them.

However, I'm guessing that your pages have links between each others so you *cannot* change the name of any of the files easily. However, I think a solution to this would be to use rewriting rules in the .htaccess file (take a look here https://www.addedbytes.com/articles/for ... beginners/) to map a uniform set of filenames to the actual filenames:

RewriteEngine On # Turn on the rewriting engine
RewriteRule ^originalname.htm dynamicname.lc [NC,L]

This should work as rewriting occurs *before* Apache tries to serve a page. So, when a user clicks on a link in one of your pages with the name 'mysite.com/mypage.htm', Apache will look through the rewriting rules, and will map that to 'mysite.com/mypage.lc' - *if* you have a rewriting rule which maps from mypage.html -> mypage.lc. If there is no such rule, it will just serve mypage.htm. (Note, in this case you should remove .html and .htm from the AddHandler livecode-script clause).

This approach would mean adding a new rewrite rule every time you added dynamic elements to a page, which (at least initially) should be okay to maintain as long as you have many many many more static pages than dynamic ones.

I've spent a bit of time thinking about this, and I've not yet thought of another way to solve this problem beyond @SparkOut's suggestions of prepending all your files with

Code: Select all

<?lc put header "Content-Type: text/html; charset=utf-8" ?>
. There is definitely some work needed on LC Server to help with this situation, and it should be possible to solve now that the engine supports Unicode transparently. (Indeed, I think your problem is similar / related to http://quality.livecode.com/show_bug.cgi?id=17244 although I need to spend some more time understanding that bug report!).

Post Reply

Return to “CGIs and the Server”