tomk79/px2-amp-convert

此包已废弃,不再维护。作者建议使用 pickles2/px2-amp-convert 包。

将Pickles 2内容转换为AMP。

0.2.3 2019-02-04 08:43 UTC

This package is not auto-updated.

Last update: 2019-08-01 23:51:25 UTC


README

将Pickles 2内容转换为AMP。

功能 - 功能

pickles2/px2-amp-convert 用于将Pickles 2内容转换为AMP。

转换过程依赖于 tomk79/amp-convert。请参考 tomk79/amp-convert 的 README。

入门步骤 - 设置

1. 在 composer.json 中添加 pickles2/px2-amp-convert

require 项中添加 pickles2/px2-amp-convert

{
	"require": {
		"pickles2/px2-amp-convert": "^0.2"
	},
}

添加后,不要忘记执行 composer update 以反映更改。

$ composer update

2. 在 config.php 中设置插件

编辑设置文件 config.php (通常为 ./px-files/config.php)。

<?php
	/* 中略 */

	// funcs: Before content
	$conf->funcs->before_content = [
		// AMP変換ユーティリティオブジェクトを生成する
		'tomk79\pickles2\ampConvert\main::create_px_amp_convert_utils()',
	];

	/* 中略 */

	// processor
	$conf->funcs->processor->html = array(

		/* 中略 */

		// AMP変換
		'tomk79\pickles2\ampConvert\main::exec()',

		/* 中略 */

	);

如果使用JSON格式编辑Pickles 2设置,请将其添加到 config.json 的相应部分。

3. 通过移动UA访问

对移动用户代理做出反应,自动显示已转换为AMP的内容。

实用工具 - 实用工具

<?php

$utils = $px->amp_convert_utils;

if(!is_object($utils)){
	// または
	$utils = new \tomk79\pickles2\ampConvert\utils( $px );
}

// パスの変換パターンを処理する
echo $utils->rewrite_path('/a/b/c/test.html', '{$dirname}/{$filename}.{$ext}'); // '/a/b/c/test.html'

// コールバックを使用する例
echo $utils->rewrite_path('/a/b/c/test.html', function($path){
	return $path.'.test';
}); // '/a/b/c/test.html.test'

更新日志 - 更新日志

pickles2/px2-amp-convert v0.2.3 (2019年2月4日)

  • 开始缓存资源读取结果。在重复读取大量资源的情况下,可以提高发布的性能。

pickles2/px2-amp-convert v0.2.2 (2019年1月29日)

  • 修复了相对路径书写的图片未替换为 amp-img 元素的问题。
  • 现在可以处理从 // 开始的资源。

pickles2/px2-amp-convert v0.2.1 (2019年1月17日)

  • 修复了当 <link rel="stylesheet"> 的链接目标是 data 模式、URL 模式,且 $conf->path_controot 的设置不为 / 时,无法处理的问题。

pickles2/px2-amp-convert v0.2.0 (2018年9月25日)

  • 迁移到Pickles 2组。

tomk79/px2-amp-convert v0.1.1 (2018年3月9日)

  • 修复了在Windows上运行时出现的问题。

tomk79/px2-amp-convert v0.1.0 (2018年2月4日)

  • 首次发布。

许可证 - 许可证

MIT许可证

作者 - 作者