Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Skylark » Skylark -- Static files -- CSS and js
Skylark -- Static files -- CSS and js [message #53739] Sun, 26 April 2020 09:14 Go to next message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi

I am using following folder layout

/opt/myapp -- application folder
/opt/myapp/templates -- for witz files
/opt/myapp/static -- for CSS and js files

With this I have one problem. css and js files are not accessible in web browser
When I see html source it shows path for css as

static/css/mystyle.css
and full url as
localhost:8001/myapp/static/css/mystyle.css

but this file is not accesible from the location.

What folder layout I should use to make CSS available.


Warm Regards

Deepak
Re: Skylark -- Static files -- CSS and js [message #53755 is a reply to message #53739] Tue, 28 April 2020 09:56 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Have you set "path" configuration variable?
Re: Skylark -- Static files -- CSS and js [message #53779 is a reply to message #53739] Wed, 29 April 2020 23:58 Go to previous messageGo to next message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello Deep,

In my application I have a folder resources contening my img /css / js / and even my custom fonts.

to make allow user to retrieve it from their browser, I use this kind of path in my witz template :

...
<img id="notFound" src="/ressources/404.png" alt="404notFound">
...

the real path of 404 img file on my server is ..../ressources/img/404.png
To do the transformation the simple path on my witz to the real path I have this kind of handler in my Handler file :
SKYLARK(RessourcesHandler, "/ressources/*"){
	if(http[0].Find(".png") != -1){
		http.SetHeader("Cache-Control","public");
		http.ContentType("image/png") <<  LoadFile(GetFilePath("ressources/img/" +http[0]));
	}else if(http[0].Find(".css")!= -1){
		http.SetHeader("Cache-Control","public");
		http.ContentType("text/css") <<  LoadFile(GetFilePath("ressources/css/" +http[0]));
	}else if(http[0].Find("fonts")!= -1){
		http.SetHeader("Cache-Control","public");
		http.ContentType("text/css") <<  LoadFile(GetFilePath("ressources/fonts/" +http[0]));
	}else if(http[0].Find(".js")!= -1){
		http.SetHeader("Cache-Control","public");
		http.ContentType("text/javascript") <<  LoadFile(GetFilePath("ressources/js/" +http[0]));
	}else{
		http.Response(404,"File not found");
	}
}


I don't know if it is a good way of working but it work and allow me to easily manage all ressource I want to share
Re: Skylark -- Static files -- CSS and js [message #53787 is a reply to message #53755] Fri, 01 May 2020 10:42 Go to previous message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi Mirek,

Now I set path variable and it is working.

But I have question.

My path settings
path="static";

Template files are located in myapp/templates folder. It is working without adding it to path. but for js/css files I need to add "static" to path.
I use to render.
.RenderResult ( "templates/index" );


Warm Regards

Deepak
Previous Topic: Skylark and SSL (Https)
Next Topic: Skylark - Witz on the fly
Goto Forum:
  


Current Time: Thu Mar 28 13:21:31 CET 2024

Total time taken to generate the page: 0.01444 seconds