From e6fb20bc143b8cfe681d3ee15b1493f5a7d595d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=AF=9A=E8=AF=9A?= Date: Thu, 13 Sep 2018 14:12:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0AMP=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/amp.php | 36 ++++--- application/views/amp_editor.php | 129 ++++++++++++++---------- application/views/bootstrap/welcome.php | 2 +- 3 files changed, 99 insertions(+), 68 deletions(-) diff --git a/application/controllers/amp.php b/application/controllers/amp.php index 2895f5fa..652e5f48 100644 --- a/application/controllers/amp.php +++ b/application/controllers/amp.php @@ -1,12 +1,11 @@ permission->is_admin(); //$this->output->enable_profiler(TRUE); @@ -14,16 +13,14 @@ class Amp extends CI_Controller $this->load->model('InfoMetas_model'); } - public function index() - { + public function index() { $data = array(); $this->load->view('bootstrap3/header', $data); $this->load->view('amp_editor'); $this->load->view('bootstrap3/footer'); } - public function edit($ic_id) - { + public function edit($ic_id) { $data = array(); $data['information'] = $this->Information_model->detail_by_ic_id($ic_id); if ($data['information'] == FALSE) { @@ -34,8 +31,7 @@ class Amp extends CI_Controller $this->load->view('bootstrap3/footer'); } - public function auto_create($ic_id) - { + public function auto_create($ic_id) { $data = array(); $data['information'] = $this->Information_model->detail_by_ic_id($ic_id); if ($data['information'] == FALSE) { @@ -43,7 +39,6 @@ class Amp extends CI_Controller } //144.76.185.44:8029 - //根据站点不同,配置不同参数 $site_code = strtolower($this->config->item('site_code')); switch ($site_code) { @@ -79,8 +74,7 @@ class Amp extends CI_Controller echo json_encode(array('result' => 'no', 'data' => '不知道哪里错了,看代码')); } - public function edit_save() - { + public function edit_save() { $data = array(); $ic_id = $this->input->post('ic_id'); $textarea_htmlcode = $this->input->post('textarea_htmlcode'); @@ -92,8 +86,20 @@ class Amp extends CI_Controller } //CH的页面没有canonical内容,在这里帮补上 - $textarea_htmlcode=str_replace('',$this->config->item('site_url'). $data['information']->ic_url, $textarea_htmlcode); + $textarea_htmlcode = str_replace('', $this->config->item('site_url') . $data['information']->ic_url, $textarea_htmlcode); + //AMP格式验证 + //把AMP网页内容到purifycss处理,内置了AMP-Validator + $purifycss_server = 'http://184.172.113.216:33033/'; + if ($this->config->item('site_code' == 'gm')) {//德语站点使用自己的css处理服务器 + $purifycss_server = 'http://158.177.67.52:33033/'; + } + $validator_result = GET_HTTP($purifycss_server, 'amp_source=' . urlencode($textarea_htmlcode), 'POST'); + $validator_result = json_decode($validator_result); + if ($validator_result->status == 'FAIL') { + echo json_encode(array('name' => 'no', 'value' => $validator_result->errors)); + return; + } $amp = $this->InfoMetas_model->get($ic_id, 'AMP'); if ($amp === false) { $this->InfoMetas_model->add($ic_id, 'AMP', $textarea_htmlcode); diff --git a/application/views/amp_editor.php b/application/views/amp_editor.php index 6fc138c9..1f6d2db4 100644 --- a/application/views/amp_editor.php +++ b/application/views/amp_editor.php @@ -18,7 +18,9 @@
+
+
@@ -51,10 +53,10 @@
- config->item('site_code')=='cht'){ ?> - 看看 - + config->item('site_code') == 'cht') { ?> + 看看 +
@@ -65,6 +67,9 @@
+
+ +

@@ -73,57 +78,77 @@ diff --git a/application/views/bootstrap/welcome.php b/application/views/bootstrap/welcome.php index d2bca395..05843494 100644 --- a/application/views/bootstrap/welcome.php +++ b/application/views/bootstrap/welcome.php @@ -42,7 +42,7 @@
  • 订单邮件管理
  • 信息分享平台
  • 全站静态化更新
  • -
  • 全站AMP更新
  • +