羽扇
js.yui的Python项目详细描述
js.yui
简介
这个库为fanstatic打包YUI。它知道你的 结构和不同模式(正常、缩小、调试)。
这需要web框架与fanstatic之间的集成, 并确保原始资源(在^{tt2}中$ js.yui中的目录被发布到某个url。
js.yui基础测试
以下是js.yui的一些基本测试。
让我们通过挑选其中的资源来检查yui结构:
>>> import js.yui >>> from fanstatic import init_needed >>> needed = init_needed(base_url='http://localhost') >>> needed.need(js.yui.fonts) >>> print needed.render() <link rel="stylesheet" type="text/css" href="http://localhost/fanstatic/yui/fonts/fonts.css" />
让我们尝试一个依赖于字体的资源,即 grids:
>>> needed = init_needed(base_url='http://localhost') >>> needed.need(js.yui.grids) >>> print needed.render() <link rel="stylesheet" type="text/css" href="http://localhost/fanstatic/yui/fonts/fonts.css" /> <link rel="stylesheet" type="text/css" href="http://localhost/fanstatic/yui/grids/grids.css" />
让我们同时需要两个资源:
>>> needed = init_needed(base_url='http://localhost') >>> needed.need(js.yui.grids) >>> needed.need(js.yui.reset) >>> print needed.render() <link rel="stylesheet" type="text/css" href="http://localhost/fanstatic/yui/fonts/fonts.css" /> <link rel="stylesheet" type="text/css" href="http://localhost/fanstatic/yui/reset/reset.css" /> <link rel="stylesheet" type="text/css" href="http://localhost/fanstatic/yui/grids/grids.css" />
我们也一样,缩小版:
>>> needed = init_needed(base_url='http://localhost', minified=True) >>> needed.need(js.yui.grids) >>> needed.need(js.yui.reset) >>> print needed.render() <link rel="stylesheet" type="text/css" href="http://localhost/fanstatic/yui/fonts/fonts-min.css" /> <link rel="stylesheet" type="text/css" href="http://localhost/fanstatic/yui/reset/reset-min.css" /> <link rel="stylesheet" type="text/css" href="http://localhost/fanstatic/yui/grids/grids-min.css" />
现在让我们看看合并:我们包括网格并在 同时。既然这次我们可以进行滚动,我们希望看到 汇总reset-fonts-grids:
>>> needed = init_needed( ... base_url='http://localhost', rollup=True) >>> needed.need(js.yui.grids) >>> needed.need(js.yui.reset) >>> print needed.render() <link rel="stylesheet" type="text/css" href="http://localhost/fanstatic/yui/reset-fonts-grids/reset-fonts-grids.css" />
请求缩小对汇总没有影响,因为原始 汇总已缩小:
>>> needed = init_needed( ... base_url='http://localhost', rollup=True, minified=True) >>> needed.need(js.yui.grids) >>> needed.need(js.yui.reset) >>> print needed.render() <link rel="stylesheet" type="text/css" href="http://localhost/fanstatic/yui/reset-fonts-grids/reset-fonts-grids.css" />
更改
2.8.2-1(2011-04-13)
- 更新至fanstatic 0.11.1。
- 不再把它自己的资源列为它自己的缩小版本。
2.8.2(2011-01-07)
- 重写hurry.yui以使用fanstatic而不是hurry.resource。
- 使用YUI版本2.8.2。