amp自动转换改为各站通用程序

hotfix/远程访问多媒体中心
尹诚诚 7 years ago
parent 016faeadaf
commit 594d91c265

@ -42,11 +42,30 @@ class Amp extends CI_Controller
echo json_encode(array('result' => 'no', 'data' => '找不到这个页面')); echo json_encode(array('result' => 'no', 'data' => '找不到这个页面'));
} }
//获取网页当前源码,然后发送到信息平台 //获取网页当前源码,然后发送到信息平台
$html_source = GET_HTTP($this->config->item('site_url').'/index.php/information/detail/?no_cache=true&static_html_url='. $data['information']->ic_url); $html_source = GET_HTTP($this->config->item('site_url') . '/index.php/information/detail/?no_cache=true&static_html_url=' . $data['information']->ic_url);
if (!empty($html_source)) { if (!empty($html_source)) {
$post_data = array('websitehost' => 'https://data.asiahighlights.com', 'create_amp' => 'true', 'htmlsource' => $html_source); //websitehost是表示资源下载的域名在网页代码中有/css/xxx.css之类的路径程序需要添加域名组成完整URL去下载文件一般是data域名或者www域名
echo GET_HTTP(site_url('/apps/htmlcompressor/index/optimize'), $post_data, 'POST'); $site_code = strtolower($this->config->item('site_code'));
return; switch ($site_code) {
case 'ah':
$websitehost = 'https://data.asiahighlights.com';
break;
case 'cht':
$websitehost = 'https://data.chinahighlights.com';
break;
case 'gm':
$websitehost = 'https://data.chinarundreisen.com';
break;
case 'ct':
$websitehost = 'https://data.chinatravel.com';
break;
default:
$websitehost = $this->config->item('site_url');
}
$post_data = array('websitehost' => $websitehost, 'template_name' => $site_code, 'create_amp' => 'true', 'htmlsource' => $html_source);
echo GET_HTTP(site_url('/apps/htmlcompressor/index/optimize'), $post_data, 'POST');
return;
} }
echo json_encode(array('result' => 'no', 'data' => '不知道哪里错了,看代码')); echo json_encode(array('result' => 'no', 'data' => '不知道哪里错了,看代码'));
} }

@ -20,6 +20,7 @@ class Index extends CI_Controller
{ {
$htmlsource = $this->input->post('htmlsource'); $htmlsource = $this->input->post('htmlsource');
$websitehost = $this->input->post('websitehost'); $websitehost = $this->input->post('websitehost');
$template_name = $this->input->post('template_name');
$create_amp = $this->input->post('create_amp'); $create_amp = $this->input->post('create_amp');
if (empty($htmlsource) || empty($websitehost)) { if (empty($htmlsource) || empty($websitehost)) {
$this->output->set_status_header(500); $this->output->set_status_header(500);
@ -138,7 +139,7 @@ class Index extends CI_Controller
//只返回AMP代码 //只返回AMP代码
if (!empty($create_amp)) { if (!empty($create_amp)) {
$amp = $this->create_amp($html_object, 'ah', $websitehost); $amp = $this->create_amp($html_object, $template_name, $websitehost);
echo json_encode(array('result' => 'ok', 'data' => array('amp' => $amp))); echo json_encode(array('result' => 'ok', 'data' => array('amp' => $amp)));
return; return;
} }

@ -14,8 +14,18 @@
<h1>页面样式精简</h1> <h1>页面样式精简</h1>
<form name="form_htmlsource" id="form_htmlsource" action="<?php echo site_url('apps/htmlcompressor/index/optimize'); ?>" method="post"> <form name="form_htmlsource" id="form_htmlsource" action="<?php echo site_url('apps/htmlcompressor/index/optimize'); ?>" method="post">
<input type="text" name="websitehost" id="websitehost" style="width:200px;" placeholder="域名" /><br/><br/> <input type="text" name="websitehost" id="websitehost" style="width:200px;" placeholder="域名" /><br/><br/>
<textarea name="htmlsource" id="htmlsource" rows="22" style="width:800px;" placeholder="网页代码" ></textarea><br/><br/> <textarea name="htmlsource" id="htmlsource" rows="22" style="width:800px;" placeholder="网页代码" ></textarea><br/><br/>
<label><input type="checkbox" value="true" name="create_amp">生成AMP页面</label><br/><br/> <label><input type="checkbox" value="true" name="create_amp">生成AMP页面</label>
<select name="template_name" id="template_name" class="form-control" onselect="">
<option selected="" value="none">模板选择生成AMP才需要</option>
<option value="ah">AH</option>
<option value="gm">GM</option>
<option value="cht">CHT</option>
<option value="ct">CT</option>
</select>
<br/><br/>
<input type="submit"/> <input type="submit"/>
</form> </form>

Loading…
Cancel
Save