WebJames help
Dave Higton (1515) 3404 posts |
I’ve just started using WebJames (to provide the web GUI for my new heating control system). I can get the simple things to work OK, but I’m having difficulty finding out how to do one or two things. How do I (or, indeed, can I) specify a cascading stylesheet? I’ve tried this line:
but all I get is an error message, on the BBxM, that Zap is already running – even when the browser is on a different machine. At present, styles.css is of type text, but changing it to type CSS simply changes the error message: App to load that filetype not found. I’ve used that line when generating HTML that wasn’t served by WebJames, and it appears to be understood OK. WebJames’ log file indicates that the path to the file is correct, i.e. the error is not caused by failing to find the file. |
Clive Semmens (2335) 3130 posts |
I don’t think The stylesheets themselves are a right royal pain to get right though… |
Chris Hall (132) 3503 posts |
I use
on my web pages and it seems to work. |
Clive Semmens (2335) 3130 posts |
Mine’s typically simply
(where CKS.css is a particular stylesheet) – and that works, too. No mention of TYPE=“text/css” anywhere, not even in the stylesheet itself. |
Dave Higton (1515) 3404 posts |
More experimentation. When the HTML is generated by a BASIC app in the cgi-bin directory, it behaves as I describe in the first posting. But when the HTML is served up from an HTML file in the Site directory, which is a level above cgi-bin, it behaves fine – the CSS file is served up and the browser interprets it. In the BASIC, all the header stuff (including the CSS link line) is just copied in from a text file by means of a call to OS_File 16. So it appears that WebJames is interpreting the link element in some way instead of simply shipping it out to the browser. |
John Sandgrounder (1650) 574 posts |
Hi Dave, I have found that it is best, with webjames, to always specify the full webserver path for the css files, eg
as relative paths are different for BASIC generated CGI and normal HTML files. I use Ras Pi RC15, but the same link used to work OK with Webjames on a RiscPC and VRPC |
Chris Mahoney (1684) 2100 posts |
It’s optional but won’t cause any issues. It used to be required with earlier versions of the HTML standard, but text/css is now the default value. |
Jeffrey Lee (213) 6046 posts |
Take a moment and think about what the cgi-bin directory is. It’s a location to store scripts that the server should execute. So if you have a file in cgi-bin, and the server receives a request for that file, it will try executing it, regardless of its filetype. John’s advice of changing the generated HTML to specify an absolute path (i.e. relative to |
Dave Higton (1515) 3404 posts |
Thank you, Jeffrey. That makes sense. |
Chris Hall (132) 3503 posts |
When the HTML is generated by a BASIC app in the cgi-bin directory, it behaves as I describe in the first posting. But when the HTML is served up from an HTML file in the Site directory, which is a level above cgi-bin, it behaves fine If you specify a relative address, starting from different places will point to different things. Simples. |
Dave Higton (1515) 3404 posts |
How do I access the arguments part of a Request-URI, equivalent to the QUERY_STRING of WebJames, from a BASIC cgi script? WebJames’ docs led me to believe that QUERY_STRING etc. are system variables, but I haven’t found a way to access them and act on the result. The show-vars Obey file in cgi-bin2 shows how to return the text to the client but that isn’t what I want – I need to be able to generate some HTML based on the content, and ultimately to send Wimp messages to another app. Please forgive me, I’m only a beginner at HTML, and even more so at this kind of scripting. The first time I used WebJames was less than a week ago. |
John Sandgrounder (1650) 574 posts |
Hi Dave, My webjames cgi-lib file has evolved over the years, such that I now can not tell what was original and what I have added. I have a Function my cgi-lib 50 DEF FNget_url_param(arg_name$): LOCAL arg_value$, param_name%, param_value% 60 p%=CGI_RequestLine% 70 arg_value$="" 80 REPEAT: p%+=1: UNTIL ?p%=32 90 p%+=1 100 REPEAT: p%+=1: UNTIL ?p%=ASC("?") OR ?p%=32 102 IF ?p%=32 THEN ="" 110 REPEAT 120 p%+=1: param_name%=p% 130 REPEAT 140 p%+=1 150 UNTIL ?p%=ASC("=") OR ?p%=13 160 ?p%=13: p%+=1: param_value%=p% 170 REPEAT 180 p%+=1 190 UNTIL ?p%=ASC("&") OR ?p%=32 OR ?p%=13 192 ?p%=13 194 IF $param_name%=arg_name$ THEN arg_value$=$param_value% 200 UNTIL p%?1=ASC("H") 220 =arg_value$ I can use this in WebJames style scripts (BASIC) to read parameters from the URL request. |
Chris Hall (132) 3503 posts |
Perl does this more easily:
|
Dave Higton (1515) 3404 posts |
Thank you, John, for your help, for which I am grateful. And not least for reminding me of the bleedin’ obvious: look what cgi-lib offers. I blame the onward march of senility :-( In the spirit of trying to spread knowledge around, I can offer some information in return. After calling PROCCGI_Init, the variable CGI_Parameters% points to the tail of the URI (i.e. after the question mark), and CGI_ParametersSize% is the length of the tail. Note that the length is zero if there is no tail. Also, FNCGI_DecodeEscaped is easy to use to undo the escaping of non-alphanumeric characters, such as spaces, in the tail. |