有没有办法为动态网页创建谷歌放大器?我的网站包含表格元素,如主要表单,页面评论等.我对AMP印象深刻,并希望通过我的网站实现它.
我正在使用Node.js来创建媒体上传微服务.此服务的工作原理是将上传的二进制数据输入缓冲区,然后使用S3 npm包上传到S3存储桶.我正在尝试使用该包中的eventEmitter,它显示上传到S3的数据量,并将其发送回正在进行上载的客户端(以便他们可以看到上传进度).我正在使用socket.io将进度数据发送回客户端.
我遇到的问题是socket.io中的.emit事件会将上传进度数据发送到所有连接的客户端,而不仅仅是发起上传的客户端.据我所知,套接字连接到'connection'上的默认房间,该房间由客户端的'id'镜像.根据官方文档,使用socket.to(id).emit()应该只将作用域的数据发送到该客户端,但这对我不起作用.
更新示例代码:
server.js:
var http = require('http'),
users = require('./data'),
app = require('./app')(users);
var server = http.createServer(app);
server.listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
var io = require('./socket.js').listen(server);
Run Code Online (Sandbox Code Playgroud)
socket.js:
var socketio = require('socket.io');
var socketConnection = exports = module.exports = {};
socketConnection.listen = function listen(app) {
io = socketio.listen(app);
exports.sockets = io.sockets;
io.sockets.on('connection', function (socket) {
socket.join(socket.id);
socket.on('disconnect', function(){
console.log("device "+socket.id+" disconnected");
});
socketConnection.upload = function upload (data) {
socket.to(socket.id).emit('progress', {progress:(data.progressAmount/data.progressTotal)*100});
};
});
return …Run Code Online (Sandbox Code Playgroud) 我已经开始将AMP概念集成到我目前的Magento实时项目中.
我做过以下事情.
这里建议的www文件夹中的一个测试html文件,https://www.ampproject.org/docs/get_started/create/basic_markup.html这很有用.
我在magento项目中用1column.phtml做过,
<!DOCTYPE html>
<html amp lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
Run Code Online (Sandbox Code Playgroud)
在head.phtml中,添加第一行如下
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />
<link rel="canonical" href="http://www.example.com" />
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"headline": "Open-source framework for publishing content",
"datePublished": "2015-10-07T12:02:41Z",
"image": [
"logo.jpg"
]
}
</script>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal …Run Code Online (Sandbox Code Playgroud) 我想在我的第一个AMP项目中解决这个问题,
这是我的问题:
error.js:58:
Origin of <amp-iframe> must not be equal to container
Run Code Online (Sandbox Code Playgroud)
这是我的index.html中的amp-iframe代码:
<amp-iframe
width=100
height=100
layout="nodisplay"
sandbox="allow-same-origin allow-forms allow-scripts"
src="https://www.example.com/scripts/app.js">
</amp-iframe>
Run Code Online (Sandbox Code Playgroud)
当我浏览控制台选项卡时,这就是我所拥有的:
Powered by AMP ? HTML – Version 1462999126709
AMP validation successful.
Run Code Online (Sandbox Code Playgroud)
我曾经<amp-iframe>使用外部javascript,我的custom.js
AMP验证器说"除了特定形式外,不允许使用标签'脚本'."
现在我知道这个标签'script'是由newrelic_rpm自动创建的.
我的问题是如何在AMP页面上禁用newrelic_rpm.
我的AMP页面的URL就像http://example.com/foo/bar.amp.
所以我尝试了这样的设置config/newrelic.yml:
common: &default_settings
license_key: foobarfoobarfoobarfoobar
app_name: Foobar
rules.ignore_url_regexes: ["amp", ".*amp"]
development:
<<: *default_settings
app_name: FooBar (Development)
developer_mode: true
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我的项目环境:
我们如何在Meteor JS 1.1.0.3和Meteor 1.3中实现AMP(加速移动页面)?
在meteor 1.1.0.3中没有<html>标签.如果我添加<html ?>它会给出错误.并在流星1.1.0.3中自动标记和构建.所以它给出放大器验证错误The tag 'script' is disallowed except in specific forms.任何帮助表示赞赏.