Revigniter Basics

Are you using LiveCode to create server scripts or CGIs?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

sphere
Posts: 921
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Revigniter Basics

Post by sphere » Wed Aug 21, 2019 11:23 am

Hi,

as there is no Revigniter subforum(which would be a good thing, can someone create it?) i'll start this subject Revigniter Basics. hopefully to put some questions/solutions to some getting started issues.

I have LC server and the welcome page of Revigniter running ok

Hello World!
According this page:https://revigniter.com/userGuide/genera ... llers.html
i should create a file say blog.lc and put it in the controllers folder
then surf to [url]localhost:81/lc/blog[/url] and it should show the page (i use port 81 as port 80 is blocked)
result: Object not found!
What am i doing wrong?
this is in blog.lc:

Code: Select all

<?lc

# PUT YOUR HANDLER NAMES INTO THE GLOBAL gControllerHandlers AS A COMMA SEPARATED LIST
put "index,comments,shoes" into gControllerHandlers

command index
  get rigLoadView("blogview")
end index

command comments
  put "Look at this!"
end comments

command shoes
  put rigFetchSegment(3) && rigFetchSegment(4)
end shoes
?>
2nd where is determined that welcome.lc should be loaded when going to https://localhost:81/lc/
edit: ***waah, i'm too impatient i guess, just keep on reading, the default is set in routes.lc in folder config***

If i'm correct i need to rethink the way all is working when comparing the way an URL/URI works to the way a stack works in the IDE
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

rabit
Posts: 32
Joined: Wed May 31, 2006 8:30 am

Re: Revigniter Basics

Post by rabit » Thu Aug 22, 2019 12:04 pm

Hi sphere,

may be you didn’t adjust your .htaccess file as outlined in
section “revIgniter URLs” of the user guide.
If this is the case you need to add the index file in your URLs like:

localhost:81/lc/index.lc/blog

Of course it is better to shorten the URLs by adding the required
server directives to the .htacces file.

By the way you can omit the closing “?>” tags in LC server scripts.
Generally it is better to leave terminating "?>" tags off, this way whitespace
at the end of the script does not accidentally output content to the browser.
-- Ralf Bitter

sphere
Posts: 921
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Revigniter Basics

Post by sphere » Thu Aug 22, 2019 12:43 pm

Hi Ralf,

i have this in the .htaccess:

Code: Select all

#Options ExecCGI FollowSymLinks
AddHandler livecode-script .lc
DirectoryIndex index.irev index.lc index.php index.html
Action livecode-script /lc/cgi-bin/livecode-community-server.cgi

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !^(index\.lc|image|img|assets|robots\.txt|css|js)
  RewriteRule ^(.*)$ index.lc?/$1 [L]
</IfModule>
if i go to: http://localhost:81/lc then i see the welcome page
if i do http://localhost:81/lc/blog then i get Object not found
if i do http://localhost:81/lc/index.lc/blog i get this:
file "C:/Portable/xampp/htdocs/lc/index.lc"
row 142, col 1: include: could not find file (C:/Portable/xampp/htdocs/lc/index.lc/system/revigniter/RevIgniter.blog)

To me it looks like i do not have to change the path at RewriteBase
i've set the index page in config.lc to blank put "" into gConfig["indexPage"]

the blog.lc is in the folder application/controllers
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

rabit
Posts: 32
Joined: Wed May 31, 2006 8:30 am

Re: Revigniter Basics

Post by rabit » Thu Aug 22, 2019 1:38 pm

Hmm . . . seems like gRigA["systemFolder"] is wrong. What is the value of gRigA["systemFolder"]
in line 19 of index.lc?
Could you check the value of sTempPath by adding a put statement right after line 59
and could you do the same for gRigA["systemFolder"] by adding a put statement after line 70?

What is the value of gConfig["baseUrl"] (in application/config/config.lc)?
-- Ralf Bitter

sphere
Posts: 921
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Revigniter Basics

Post by sphere » Thu Aug 22, 2019 2:06 pm

line 19 is:

Code: Select all

put "system" into gRigA["systemFolder"]
line 59 to 64:

Code: Select all

put $_SERVER["PATH_TRANSLATED"] into sTempPath

  put (the platform is "Win32") into sIsWin
  if sIsWin is TRUE then
    replace "\" with "/" in sTempPath
  end if
gives
C:\Portable\xampp\htdocs\lc\index.lc
&
C:/Portable/xampp/htdocs/lc/system


the baseUrl in config.lc is: put "localhost:81/lc/" into gConfig["baseUrl"]

Now on this page:https://revigniter.com/userGuide/general/hooks.html is stated this:
First you need a script only stack which removes all comments and whitespace from the output. Here is the script which is included since version 1.3.21b and is located in system/application/hooks/overrideOutput.livecodescript for your convenience:
But in the zip file and when unpacked the folder application is not in the folder system but in the root.
I noticed that it not seems to matter where the application folder is placed.
when i move it from root to the system folder, the welcome page still works ok
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

rabit
Posts: 32
Joined: Wed May 31, 2006 8:30 am

Re: Revigniter Basics

Post by rabit » Thu Aug 22, 2019 3:09 pm

This is all correct, but strange. According to your explanations I actually expected
gRigA["systemFolder"] to be something like C:/Portable/xampp/htdocs/lc/index.lc
Do you get the same results if you use:

http://localhost:81/lc/index.lc/blog

sphere wrote:
Thu Aug 22, 2019 2:06 pm

Now on this page:https://revigniter.com/userGuide/general/hooks.html is stated this:
First you need a script only stack which removes all comments and whitespace from the output. Here is the script which is included since version 1.3.21b and is located in system/application/hooks/overrideOutput.livecodescript for your convenience:
But in the zip file and when unpacked the folder application is not in the folder system but in the root.
I noticed that it not seems to matter where the application folder is placed.
when i move it from root to the system folder, the welcome page still works ok
Yes, it doesn’t matter. In the past (prior to version 2) the system folder
contained the application folder, though you could move it to document root
without changing any code. Anyway, I am currently adjusting the
user guide accordingly to avoid confusion.
-- Ralf Bitter

sphere
Posts: 921
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Revigniter Basics

Post by sphere » Thu Aug 22, 2019 8:03 pm

Hi Ralph,

i think i missed one you asked so i did it again:

Code: Select all

gRigA after line 19=system
sTempPath after line 64=c:/portable/xampp/htdocs/lc/index.lc
gRigA after line 70=c:/portable/xampp/htdocs/lc/system 
with http://localhost:81/lc/index.lc/blog
only Object not found
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

rabit
Posts: 32
Joined: Wed May 31, 2006 8:30 am

Re: Revigniter Basics

Post by rabit » Fri Aug 23, 2019 12:23 am

sphere wrote:
Thu Aug 22, 2019 8:03 pm
Hi Ralph,

i think i missed one you asked so i did it again:

Code: Select all

gRigA after line 19=system
sTempPath after line 64=c:/portable/xampp/htdocs/lc/index.lc
gRigA after line 70=c:/portable/xampp/htdocs/lc/system 
with http://localhost:81/lc/index.lc/blog
only Object not found
Please forgive me but I am a bit confused now, because in an earlier post you explained:
if i do http://localhost:81/lc/index.lc/blog i get this:
file "C:/Portable/xampp/htdocs/lc/index.lc"
row 142, col 1: include: could not find file (C:/Portable/xampp/htdocs/lc/index.lc/system/revigniter/RevIgniter.blog)
And if below line 70 gRigA["systemFolder"] = c:/portable/xampp/htdocs/lc/system then
the statement in line 142:

Code: Select all

include gRigA["BASEPATH"] & "revigniter/RevIgniter" & gRigA["EXT"]
can not result in a path to RevIgniter.lc like:

C:/Portable/xampp/htdocs/lc/index.lc/system/revigniter/RevIgniter.blog

because gRigA["BASEPATH"] = gRigA["systemFolder"] & "/"

So, at this point I would take a step back, I would temporarily comment out the
mod_rewrite directive in .htaccess.
Then, if you go to:

http://localhost:81/lc

you should see the welcome page,
if you go to:

http://localhost:81/lc/blog

you should get the object not found error,
but if you go to:

http://localhost:81/lc/index.lc/blog

you should see the blog page. If not you should check the value
of sTempPath right after line 59 and the value of gRigA["systemFolder"]
after line 70 again.
-- Ralf Bitter

sphere
Posts: 921
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Revigniter Basics

Post by sphere » Fri Aug 23, 2019 8:51 am

Sorry, that was my mistake, i wrote it down false.
It should be:

with http://localhost:81/lc/blog
only Object not found

with http://localhost:81/lc/index.lc/blog i get this:
file "C:/Portable/xampp/htdocs/lc/index.lc"
row 142, col 1: include: could not find file (C:/Portable/xampp/htdocs/lc/index.lc/system/revigniter/RevIgniter.blog)

i commented out the rewrite part in the .htaccess
with http://localhost:81/lc/blog
Object not found

with http://localhost:81/lc/index.lc/blog
gRigA after line 19 = system
sTempPath after line 59 = C:\Portable\xampp\htdocs\lc\index.lc\blog
gRigA after line 70 = C:/Portable/xampp/htdocs/lc/index.lc/system

file "C:/Portable/xampp/htdocs/lc/index.lc"
row 147, col 1: include: could not find file (C:/Portable/xampp/htdocs/lc/index.lc/system/revigniter/RevIgniter.blog)
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

rabit
Posts: 32
Joined: Wed May 31, 2006 8:30 am

Re: Revigniter Basics

Post by rabit » Fri Aug 23, 2019 4:47 pm

Thanks for the info. The problem is: $_SERVER["PATH_TRANSLATED"]
gives the wrong path, it should be:

C:\Portable\xampp\htdocs\lc\index.lc

So, here is a workaround, add the following code right after line 64 in index.lc:

Code: Select all

  set the itemDel to "."
  if item -2 of sTempPath <> "index" then
    put (char 1 to (offset("index.lc", sTempPath ) - 1) of sTempPath) & "index.lc" into sTempPath
  end if
Now the issue should be fixed. If yes, you can uncomment the
mod_rewrite directive in .htaccess.
-- Ralf Bitter

sphere
Posts: 921
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Revigniter Basics

Post by sphere » Fri Aug 23, 2019 6:14 pm

Thanks Ralph for taking the time to get this solved, i appreciate it.

Ok we are getting a bit further:
sTempPath after line 64=D:/server/xampp/htdocs/lc/index.lc/blog

The Object not found is gone.
Now it should show the blogview.lc as that file is stored in folder views because in blog.lc(in folder controllers) is

Code: Select all

<?lc
# PUT YOUR HANDLER NAMES INTO THE GLOBAL gControllerHandlers AS A COMMA SEPARATED LIST
put "index,comments,shoes" into gControllerHandlers

command index
  get rigLoadView("blogview")
end index

command comments
  put "Look at this!"
end comments

command shoes
  put rigFetchSegment(3) && rigFetchSegment(4)
end shoes
But what it shows is welcome.lc
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

rabit
Posts: 32
Joined: Wed May 31, 2006 8:30 am

Re: Revigniter Basics

Post by rabit » Fri Aug 23, 2019 11:48 pm

OK, now the URI string is empty (should be “blog”). Could you please once again
try out other uri protocols including “Auto” as described in application/config/config.lc?
-- Ralf Bitter

sphere
Posts: 921
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Revigniter Basics

Post by sphere » Sat Aug 24, 2019 1:16 pm

if i set it to AUTO i get this:
An Error Was Encountered
Unable to load your default controller. Please make sure the controller specified in your routes.lc file is valid.
it only works with: QUERY_STRING and ORIG_PATH_INFO
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

rabit
Posts: 32
Joined: Wed May 31, 2006 8:30 am

Re: Revigniter Basics

Post by rabit » Sat Aug 24, 2019 2:52 pm

This turns out to be tedious, but hang on we will find a solution.
The problem is that all these server variables don’t give the
expected values.
So, all that is left we need to know are the values for:

$_SERVER["QUERY_STRING"]
and
$_SERVER["ORIG_PATH_INFO”]

Could you please check these in index.lc right before the last statement
using the URL:

http://localhost:81/lc/index.lc/blog
-- Ralf Bitter

sphere
Posts: 921
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: Revigniter Basics

Post by sphere » Mon Aug 26, 2019 12:07 pm

What the h*ll??
What's going on with the forum?
Suddenly page 2 and a few messages are gone? :evil:
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

Post Reply

Return to “CGIs and the Server”