web-resources/nette-manager

Nette 框架下管理网络资源的工具

0.1.0 2014-05-16 09:13 UTC

This package is not auto-updated.

Last update: 2024-09-23 14:04:26 UTC


README

主要目的是通过将定义移动到配置(模块配置)和支持自动生成内容来简化脚本和样式的管理。

实验性! 可能会有向下兼容性问题。 这仍然更像是一个草案而不是合适的代码,所以请见谅。

安装

将以下要求添加到您的 composer.json"web-resources/nette-manager": "dev-master"。目录 %WWW_DIR%/assets 必须由服务器可写(可在配置中更改)。

引导

$configurator = new Nette\Config\Configurator;
// after the line above
WebResources\NetteManager\DI\WebResourcesExtension::register($configurator);
// before the line bellow
$container = $configurator->createContainer();

在模板中

<head>
	...
	{include ../../libs/web-resources/nette-manager/@styles.latte}
</head>

<body>
	...
	{include ../../libs/web-resources/nette-manager/@scripts.latte}
</body>

功能

  • 依赖管理

脚本

  • 翻译
  • 每个脚本配置
  • 根据 debugMode 和配置使用公共、精简和原始版本的脚本

样式

  • 支持 less(您必须在路径中有 lessc
  • 使用新的 URL 将资源提取到新文件夹中,以防止缓存问题
  • 重命名文件以防止缓存问题
  • 生成压缩文件 - 可以由 nginx 使用 gzip_static on; 使用

使用方法

在 config.neon 中

resources:

	styles:
		bootstrap:
			filename: %appDir%/../libs/twitter/bootstrap/less/bootstrap.less
		bootstrap.responsive:
			filename: %appDir%/../libs/twitter/bootstrap/less/responsive.less
			depends: bootstrap

	scripts:
		jquery:
			filename: jquery-1.8.2.js
			public: //ajax.googleapis.ac.cn/ajax/libs/jquery/1.8.2/jquery.js
		bootstrap:
			filename: bootstrap.js
			minified: bootstrap.min.js
			depends: jquery
		main:
			filename: main.js
			depends: [ jquery, bootstrap ]
  • 属性 depends 是可选的,默认为空数组([ ]

脚本

  • minified 版本是可选的
  • 至少定义 filenamepublic
  • 在以下顺序中自动切换(productionMode = TRUEpublic > minified > filenamedebugMode = TRUE