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
Re: Skylark -- Static files -- CSS and js [message #53779 is a reply to message #53739] Wed, 29 April 2020 23:58 Go to previous 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
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Skylark and SSL (Https)
Next Topic: Skylark - Witz on the fly
Goto Forum:
  


Current Time: Mon May 06 06:06:21 CEST 2024

Total time taken to generate the page: 0.02892 seconds