Resources directories manage resource files like image files or preference files. The directories are resources directory and web server resources directory setted for resourcesand web_server_resourcesattributes of CKApplication.
Resources are files not sent to browsers, web server resources are files to send to browsers. Locate web server resources directory in document root of web server.
Use CKResourceManage to access to resources. You can get CKResourceManager object with CKApplication#resource_manager.
Main methods of CKResourceManager are url()and path(). url() returns URLs for resources, path() does absolute file paths. url() works only for resources in web server resources directory. You can?t get URLs for resources in resources directory.
| Methods | Description |
|---|---|
url(name) |
Returns the public URL for the specified resource when it is under the web server resources directory. Otherwise returns nil. |
path(name) |
Returns the file path of the specified resource. |
bytedata(name) |
Returns a CKByteData object for the specified resource. |
content_type(path) |
Finds the content type for extension of the specified path. If the path don't have extension, returns nil. |
CKImage can display resource files as image. Do setting the following to display an image file (cgikit.png) in ImagePage of Examples.
????-1->move resourcesdirectory to path enables displaying images.?????-1->
resourceattribute of CKAppication.
??????>move resourcesdirectory???????>
[localhost:/var/www/cgi-bin/Examples] user% mv resources ../../htdocs
??????>set path of resourcesdirectory (Example.cgi)???????>
app = CKApplication.new app.web_server_resources = '../../htdocs/resources' app.run
??????>set an image file name of fileattribute (ImagePage.ckd)???????>
FileInResource : CKImage {
alt = "File in resource direcory";
file = "cgikit.png";
}
This is an example to display static an image file. CKImage can display dinamically using with dataattribute.