From 35ccbf642e8d189558e795a87005513e456d9a5d Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 27 Jan 2006 04:23:17 +0000 Subject: Added assets section to quickstart tutorial. --- .gitattributes | 2 + demos/quickstart/protected/controls/TopicList.tpl | 19 +++----- .../protected/pages/Advanced/Assets.page | 57 ++++++++++++++++++++++ .../protected/pages/Advanced/Themes.page | 6 +++ 4 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 demos/quickstart/protected/pages/Advanced/Assets.page create mode 100644 demos/quickstart/protected/pages/Advanced/Themes.page diff --git a/.gitattributes b/.gitattributes index ae17cc37..1930edeb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -36,6 +36,8 @@ demos/quickstart/protected/controls/SampleLayout.php -text demos/quickstart/protected/controls/SampleLayout.tpl -text demos/quickstart/protected/controls/TopicList.php -text demos/quickstart/protected/controls/TopicList.tpl -text +demos/quickstart/protected/pages/Advanced/Assets.page -text +demos/quickstart/protected/pages/Advanced/Themes.page -text demos/quickstart/protected/pages/Configurations/AppConfig.page -text demos/quickstart/protected/pages/Configurations/Overview.page -text demos/quickstart/protected/pages/Configurations/PageConfig.page -text diff --git a/demos/quickstart/protected/controls/TopicList.tpl b/demos/quickstart/protected/controls/TopicList.tpl index fb3a2e56..26ef4294 100644 --- a/demos/quickstart/protected/controls/TopicList.tpl +++ b/demos/quickstart/protected/controls/TopicList.tpl @@ -60,16 +60,6 @@ -
-
Avanced Features
- -
-
Security
-
Performance
+
Avanced Topics
diff --git a/demos/quickstart/protected/pages/Advanced/Assets.page b/demos/quickstart/protected/pages/Advanced/Assets.page new file mode 100644 index 00000000..857da3a1 --- /dev/null +++ b/demos/quickstart/protected/pages/Advanced/Assets.page @@ -0,0 +1,57 @@ + + +

Assets

+

+Assets are resource files (such as images, sounds, videos, CSS stylesheets, javascripts, etc.) that belong to specific component classes. Assets are meant to be provided to Web users. For better reusability and easier deployment of the corresponding component classes, assets should reside together with the component class files . For example, a toggle button may use two images, stored in file down.gif and up.gif, to show different toggle states. If we require the image files be stored under images directory under the Web server document root, it would be inconvenient for the users of the toggle button component, because each time they develop or deploy a new application, they would have to manually copy the image files to that specific directory. To eliminate this requirement, a directory relative to the component class file should be used for storing the image files. A common strategy is to use the directory containing the component class file to store the asset files. +

+

+Because directories containing component class files are normally inaccessible by Web users, PRADO implements an asset publishing scheme to make available the assets to Web users. An asset, after being published, will have a URL by which Web users can retrieve the asset file. +

+ +

Asset Publishing

+

+Asset publishing is managed by the System.Web.UI.TAssetManager module. By default, all published asset files are stored under the [AppEntryPath]/assets directory, where AppEntryPath refers to the directory containing the application entry script. Make sure the assets directory is writable by the Web server process. You may change this directory to another by setting the BasePath and BaseUrl properties of the System.Web.UI.TAssetManager module. +

+

+PRADO provides several methods for publishing assets or directories containing assets: +

+ +

+BE AWARE: Be very careful with assets publishing, because it gives Web users access to files that were previously inaccessible to them. Make sure that you do not publish files that do not want Web users to see. +

+ +

Performance

+

+PRADO uses caching techniques to ensure the efficiency of asset publishing. Publishing an asset essentially requires file copy operation, which is expensive. To save unnecessary file copy operations, System.Web.UI.TAssetManager only publishes an asset when it has a newer file modification time than the published file. When an application runs under the Performance mode, such timestamp checkings are also omitted. +

+

+ADVISORY: Do not overuse asset publishing. The asset concept is mainly used to help better reuse and redistribute component classes. Normally, you should not use asset publishing for resources that are not bound to any components in an application. For example, you should not use asset publishing for images that are mainly used as design elements (e.g. logos, background images, etc.) Let Web server to directly serve these images will help improve the performance of your application. +

+ +

A Toggle Button Example

+

+We now use the toggle button example to explain the usage of assets. The control uses two image files up.gif and down.gif, which are stored under the directory containing the control class file. When the button is in Up state, we would like to show the up.gif image. This can be done as follows, + +class ToggleButton extends TWebControl { + ... + protected function addAttributesToRender($writer) { + ... + if($this->getState()==='Up') { + $url=$this->getAsset('up.gif'); + $writer->addAttribute('src',$url); + } + ... + } + ... +} + +In the above, the call $this->getAsset('up.gif') will publish the up.gif image file and return a URL for the published image file. The URL is then rendered as the src attribute of the HTML image tag. +

+

+To redistribute ToggleButton, simply pack together the class file and the image files. Users of ToggleButton merely need to unpack the file, and they can use it right away, without worrying about where to copy the image files to. +

+
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Advanced/Themes.page b/demos/quickstart/protected/pages/Advanced/Themes.page new file mode 100644 index 00000000..f640aa7d --- /dev/null +++ b/demos/quickstart/protected/pages/Advanced/Themes.page @@ -0,0 +1,6 @@ + + +

Themes and Skins

+ + +
\ No newline at end of file -- cgit v1.2.3