seo plugin: amp support

This commit is contained in:
Abdulrahman
2018-12-16 16:44:27 +03:00
parent 651d0f0c9e
commit d830a4ea4f
4 changed files with 593 additions and 0 deletions

302
plugins/kj_amp_seo/amp.html Normal file
View File

@@ -0,0 +1,302 @@
<!doctype html>
<html amp lang="{lang.LANG_SMALL_NAME}" dir="{dir}">
<head>
<meta charset="UTF-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<!-- components -->
<script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script>
<script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
<script async custom-element="amp-sticky-ad" src="https://cdn.ampproject.org/v0/amp-sticky-ad-1.0.js"></script>
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
<title>{title}</title>
<link rel="canonical" href="{amp_canonical}">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<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 both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
<noscript>
<style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style>
</noscript>
<style amp-custom>
.header {
position: relative;
box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.2),0 1px 5px 0 rgba(0,0,0,.12);
padding-top: 52px;
}
.header {
background-color: #607D8B;
}
.header #sample-menu {
position:absolute;
top:0;
<IF NAME="lang.DIR==ltr">left<ELSE>right</IF>:0;
font-size: 18px;
font-weight: 700;
color: white;
text-transform: uppercase;
padding: 13px;
}
.header #sample-logo {
position:absolute;
top:0;
<IF NAME="lang.DIR==ltr">left<ELSE>right</IF>:36px;
font-size: 18px;
font-weight: 400;
color: white;
text-transform: uppercase;
margin: 0 16px;
height: 32px;
text-decoration: none;
line-height: 52px;
}
.header #sample-logo {
visibility: hidden;
opacity: 0;
transition: visibility 0s 0.7s, opacity 0.7s ease;
}
.header #sample-logo {
visibility: visible;
opacity: 1;
transition: opacity 1.5s ease;
}
.m1{margin:1rem}
.svg-icon path,
.svg-icon polygon,
.svg-icon rect {
fill: #fff;
}
.svg-icon circle {
stroke: #fff;
stroke-width: 1;
}
amp-sidebar{margin-top:3.5rem}
.block{display:block}
.p1{padding:1rem}
.text-decoration-none{text-decoration:none}
.ampstart-btn {
font-family: inherit;
font-weight: inherit;
font-size: 1rem;
line-height: 1.125rem;
padding: .7em .8em;
text-decoration: none;
white-space: nowrap;
word-wrap: normal;
vertical-align: middle;
cursor: pointer;
background-color: #fff;
color: #b60845;
border: 1px solid #b60845
}
.ampstart-btn:visited {
color: #b60845
}
.ampstart-btn-secondary {
background-color: #b60845;
color: #fff;
border: 1px solid #fff
}
.ampstart-btn-secondary:visited {
color: #fff
}
.ampstart-btn:active .ampstart-btn:focus {
opacity: .8
}
.ampstart-btn[disabled], .ampstart-btn[disabled]:active, .ampstart-btn[disabled]:focus, .ampstart-btn[disabled]:hover {
opacity: .5;
outline: 0;
cursor: default
}
.file-info-list{
margin: 14px;
}
.file-info-list p{
background: #f9f7f7;
padding: 6px;
box-shadow: 0 1px 1px 0 rgba(0,0,0,.14), 0 1px 1px -1px rgba(0,0,0,.14), 0 1px 5px 0 rgba(0,0,0,.12);
}
.file-info-list p .title{
color: #414446;
}
.clearfix{
clear: both;
}
.download{
margin:10px auto;
text-align: center;
}
.download .size{
display: block;
margin:15px;
color: #4b5257;
}
.svg-down{
margin-bottom: -5px;
}
.svg-down path,
.svg-down polygon,
.svg-down rect {
fill: #b60845;
}
.svg-down circle {
stroke: #b60845;
stroke-width: 1;
}
</style>
</head>
<body>
<!-- sidebar -->
<amp-sidebar id="drawermenu"
layout="nodisplay">
<LOOP NAME="top_menu">
<IF LOOP="show">
<a href="{{url}}" class="text-decoration-none block p1">{{title}}</a>
</IF>
</LOOP>
<LOOP NAME="side_menu">
<IF LOOP="show">
<a href="{{url}}" class="text-decoration-none block p1">{{title}}</a>
</IF>
</LOOP>
</amp-sidebar>
<!-- header -->
<div class="header">
<a id="sample-menu"
on="tap:drawermenu.toggle">
<svg class="svg-icon" viewBox="0 0 20 20" width="24" height="24">
<path d="M10,1.445c-4.726,0-8.555,3.829-8.555,8.555c0,4.725,3.829,8.555,8.555,8.555c4.725,0,8.555-3.83,8.555-8.555C18.555,5.274,14.725,1.445,10,1.445 M10,17.654c-4.221,0-7.654-3.434-7.654-7.654c0-4.221,3.433-7.654,7.654-7.654c4.222,0,7.654,3.433,7.654,7.654C17.654,14.221,14.222,17.654,10,17.654 M14.39,10c0,0.248-0.203,0.45-0.45,0.45H6.06c-0.248,0-0.45-0.203-0.45-0.45s0.203-0.45,0.45-0.45h7.879C14.187,9.55,14.39,9.752,14.39,10 M14.39,12.702c0,0.247-0.203,0.449-0.45,0.449H6.06c-0.248,0-0.45-0.202-0.45-0.449c0-0.248,0.203-0.451,0.45-0.451h7.879C14.187,12.251,14.39,12.454,14.39,12.702 M14.39,7.298c0,0.248-0.203,0.45-0.45,0.45H6.06c-0.248,0-0.45-0.203-0.45-0.45s0.203-0.45,0.45-0.45h7.879C14.187,6.848,14.39,7.051,14.39,7.298"></path>
</svg>
</a>
<a id="sample-logo" href="{config.siteurl}">{config.sitename}</a>
</div>
<!-- title -->
<h1 class="m1">{title}</h1>
<!-- share buttons -->
<div class="m1">
<amp-social-share type="twitter" width="30" height="22"></amp-social-share>
<amp-social-share type="facebook" width="30" height="22"></amp-social-share>
<amp-social-share type="whatsapp" width="30" height="22"></amp-social-share>
<amp-social-share type="gplus" width="30" height="22"></amp-social-share>
<amp-social-share type="email" width="30" height="22"></amp-social-share>
<amp-social-share type="pinterest" width="33" height="22"></amp-social-share>
</div>
<!--extra-->
<div class="clearfix"></div>
<IF NAME="top_ad">
<amp-ad width=300 height=250
type="adsense"
layout="responsive"
data-ad-client="{adsense_client}"
data-ad-slot="{top_ad}">
</amp-ad>
</IF>
<div class="clearfix"></div>
<!-- info list -->
<div class="file-info-list">
<p><span class="title">{lang.FILENAME}: </span> {name}</p>
<p><span class="title">{lang.FILETYPE}: </span> {type}</p>
<p><span class="title">{lang.FILESIZE}: </span> {size}</p>
<p><span class="title">{lang.FILEDATE}: </span> {time}</p>
<p><span class="title">{lang.FILEUPS}: </span> {uploads}</p>
<IF NAME="fusername">
<p><span class="title">{lang.USERNAME}: </span> <a href="{userfolder}">{fusername}</a></p>
</IF>
<p class="report">
<small><a href="{REPORT}" rel="nofollow"> {lang.FILEREPORT}</a></small>
</p>
</div>
<div class="clearfix"></div>
<IF NAME="middle_ad">
<amp-ad width=300 height=250
type="adsense"
layout="responsive"
data-ad-client="{adsense_client}"
data-ad-slot="{middle_ad}">
</amp-ad>
</IF>
<div class="clearfix"></div>
<p class="download">
<a href="{url_file}" target="_blank" class="ampstart-btn">
<svg class="svg-down" viewBox="0 0 20 20" height="24" width="24">
<path d="M13.962,8.885l-3.736,3.739c-0.086,0.086-0.201,0.13-0.314,0.13S9.686,12.71,9.6,12.624l-3.562-3.56C5.863,8.892,5.863,8.611,6.036,8.438c0.175-0.173,0.454-0.173,0.626,0l3.25,3.247l3.426-3.424c0.173-0.172,0.451-0.172,0.624,0C14.137,8.434,14.137,8.712,13.962,8.885 M18.406,10c0,4.644-3.763,8.406-8.406,8.406S1.594,14.644,1.594,10S5.356,1.594,10,1.594S18.406,5.356,18.406,10 M17.521,10c0-4.148-3.373-7.521-7.521-7.521c-4.148,0-7.521,3.374-7.521,7.521c0,4.147,3.374,7.521,7.521,7.521C14.148,17.521,17.521,14.147,17.521,10"></path>
</svg>
{lang.CLICK_DOWN}</a>
<small class="size">{size}</small>
</p>
<IF NAME="sticky_ad">
<amp-sticky-ad layout="nodisplay">
<amp-ad width=300 height=250
type="adsense"
data-ad-client="{adsense_client}"
data-ad-slot="{sticky_ad}">
</amp-ad>
</amp-sticky-ad>
</IF>
</body>
</html>

BIN
plugins/kj_amp_seo/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

55
plugins/kj_amp_seo/index.html Executable file
View File

@@ -0,0 +1,55 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256"/>
<title>Powered by Kleeja</title>
<style type="text/css">* {
font-size: 100%;
margin: 0;
padding: 0;
color: #CECFCE;
}
body {
font-family: Tahoma, Arial, sans-serif;
font-size: 100%;
color: #69788E;
margin: 10px 30px;
background: #F7F7F7;
}
a:link, a:visited {
text-decoration: none;
color: #CECFCE;
}
a:active, a:hover {
text-decoration: underline;
color: #111;
}
h1 {
font-family: "Trebuchet MS", Helvetica, sans-serif;
font-size: 1.70em;
font-weight: normal;
color: #333333;
margin-top: 0;
margin-bottom: 10px;
}
.content_box {
border: 1px dashed #CECFCE;
background: #FFFFFF;
padding: 10px;
margin-right: auto;
margin-left: auto;
}</style>
</head>
<body title="&#1603;&#1604;&#1610;&#1580;&#1575;"><br/>
<div class="content_box"><h1><span style="font-size:250%;color:#D80000;">403 - Access forbidden!</span></h1></div>
<br/>
<div class="content_box"><span style="font-size: 140%">Powered by <a target="_blank"
href="http://www.kleeja.com">Kleeja</a></span>
</div>
</body>
</html>

236
plugins/kj_amp_seo/init.php Normal file
View File

@@ -0,0 +1,236 @@
<?php
# kleeja plugin
# kj_amp_seo
# developer: kleeja team
# prevent illegal run
if (!defined('IN_PLUGINS_SYSTEM')) {
exit();
}
# plugin basic information
$kleeja_plugin['kj_amp_seo']['information'] = array(
# the casucal name of this plugin, anything can a human being understands
'plugin_title' => array(
'en' => 'KJ AMP SEO',
'ar' => 'AMP سيو'
),
# who wrote this plugin?
'plugin_developer' => 'kleeja.com',
# this plugin version
'plugin_version' => '1.1',
# explain what is this plugin, why should i use it?
'plugin_description' => array(
'en' => 'Add AMP support to download pages to enhance SEO for Kleeja',
'ar' => 'دعم الـ AMP لصفحات التحميل لدعم السيو في كليجا'
),
# min version of kleeja that's required to run this plugin
'plugin_kleeja_version_min' => '2.0',
# max version of kleeja that support this plugin, use 0 for unlimited
'plugin_kleeja_version_max' => '3.0',
# should this plugin run before others?, 0 is normal, and higher number has high priority
'plugin_priority' => 0
);
//after installation message, you can remove it, it's not requiered
$kleeja_plugin['kj_amp_seo']['first_run']['ar'] = "
شكراً لاستخدامك إضافة كليجا هذه، قم بمراسلتنا بالأخطاء عند ظهورها على البريد: <br>
info@kleeja.com
";
$kleeja_plugin['kj_amp_seo']['first_run']['en'] = "
Thank you for using our plugin, if you encounter any bugs and errors, contact us: <br>
info@kleeja.com
";
# plugin installation function
$kleeja_plugin['kj_amp_seo']['install'] = function ($plg_id) {
//new options
$options = array(
'kj_amp_seo_enable' =>
array(
'value' => '1',
'html' => configField('kj_amp_seo_enable', 'yesno'),
'plg_id' => $plg_id,
'type' => 'kj_amp_seo',
'order' => '1',
),
'kj_amp_seo_share_buttons' =>
array(
'value' => '1',
'html' => configField('kj_amp_seo_share_buttons', 'yesno'),
'plg_id' => $plg_id,
'type' => 'kj_amp_seo',
'order' => '2',
),
'kj_amp_seo_top_ad' =>
array(
'value' => '',
'html' => configField('kj_amp_seo_top_ad'),
'plg_id' => $plg_id,
'type' => 'kj_amp_seo',
'order' => '3',
),
'kj_amp_seo_middle_ad' =>
array(
'value' => '',
'html' => configField('kj_amp_seo_middle_ad'),
'plg_id' => $plg_id,
'type' => 'kj_amp_seo',
'order' => '4',
),
'kj_amp_seo_sticky_ad' =>
array(
'value' => '',
'html' => configField('kj_amp_seo_sticky_ad'),
'plg_id' => $plg_id,
'type' => 'kj_amp_seo',
'order' => '5',
),
'kj_amp_seo_adsense_client' =>
array(
'value' => '',
'html' => configField('kj_amp_seo_adsense_client'),
'plg_id' => $plg_id,
'type' => 'kj_amp_seo',
'order' => '6',
),
);
add_config_r($options);
//new language variables
add_olang(array(
'CONFIG_KLJ_MENUS_KJ_AMP_SEO' => 'خيارات AMP سيو',
'KJ_AMP_SEO_ENABLE' => 'تفعيل صفحات AMP المسرعة ',
'KJ_AMP_SEO_SHARE_BUTTONS' => 'عرض أزرار المشاركة',
'KJ_AMP_SEO_TOP_AD' => 'كود slot لإعلان AMP أدسنس علوي، دعه فارغ للتعطيل',
'KJ_AMP_SEO_MIDDLE_AD' => 'كود slot لإعلان AMP أدسنس وسطي، دعه فارغ للتعطيل',
'KJ_AMP_SEO_STICKY_AD' => 'كود slot لإعلان AMP أدسنس لاصق، دعه فارغ للتعطيل',
'KJ_AMP_SEO_ADSENSE_CLIENT' => 'كود client العام لحساب ادسنس الخاص بالإعلانات',
),
'ar',
$plg_id);
add_olang(array(
'CONFIG_KLJ_MENUS_KJ_AMP_SEO' => 'AMP SEO Options',
'KJ_AMP_SEO_ENABLE' => 'Enable fast AMP pages',
'KJ_AMP_SEO_SHARE_BUTTONS' => 'Enable social share buttons',
'KJ_AMP_SEO_TOP_AD' => 'Slot code for Top AdSense AMP ad, keep it empty to disable',
'KJ_AMP_SEO_MIDDLE_AD' => 'Slot code for Middle AdSense AMP ad, keep it empty to disable',
'KJ_AMP_SEO_STICKY_AD' => 'Slot code for Sticky AdSense AMP ad, keep it empty to disable',
'KJ_AMP_SEO_ADSENSE_CLIENT' => 'Client code for AdSense ads',
),
'en',
$plg_id);
};
//plugin update function, called if plugin is already installed but version is different than current
$kleeja_plugin['kj_amp_seo']['update'] = function ($old_version, $new_version) {
// if(version_compare($old_version, '0.5', '<')){
// //... update to 0.5
// }
//
// if(version_compare($old_version, '0.6', '<')){
// //... update to 0.6
// }
//you could use update_config, update_olang
};
# plugin uninstalling, function to be called at uninstalling
$kleeja_plugin['kj_amp_seo']['uninstall'] = function ($plg_id) {
//delete options
delete_config(array(
'kj_amp_seo_enable',
'kj_amp_seo_share_buttons',
'kj_amp_seo_top_ad',
'kj_amp_seo_middle_ad',
'kj_amp_seo_sticky_ad',
'kj_amp_seo_adsense_client',
));
delete_olang(null, null, $plg_id);
};
# plugin functions
$kleeja_plugin['kj_amp_seo']['functions'] = array(
'Saaheader_links_func' => function ($args) {
if(defined('IN_DOWNLOAD') && !ig('amp_page')){
global $config;
$current_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$current_url .= strpos($current_url, '?') === false ? '?' : '&';
$current_url .= 'amp_page=1';
$extra = $args['extra'] . '<link rel="amphtml" href="'.htmlspecialchars($current_url).'">';
return compact('extra');
}
},
'b4_showsty_downlaod_id_filename' => function($args){
if(!ig('amp_page')){
return;
}
global $tpl, $lang;
extract($args);
$dir = $lang['DIR'];
$side_menu = array(
1 => array('name' => 'profile', 'title' => $lang['PROFILE'], 'url' => $config['mod_writer'] ? 'profile.html' : 'ucp.php?go=profile', 'show' => $user_is),
2 => array('name' => 'fileuser', 'title' => $lang['YOUR_FILEUSER'], 'url' => $config['mod_writer'] ? 'fileuser.html' : 'ucp.php?go=fileuser', 'show' => $config['enable_userfile'] && user_can('access_fileuser')),
3 => $user_is
? array('name' => 'logout', 'title' => $lang['LOGOUT'], 'url' => $config['mod_writer'] ? 'logout.html' : 'ucp.php?go=logout', 'show' => true)
: array('name' => 'login', 'title' => $lang['LOGIN'], 'url' => $config['mod_writer'] ? 'login.html' : 'ucp.php?go=login', 'show' => true),
4 => array('name' => 'register', 'title' => $lang['REGISTER'], 'url' => $config['mod_writer'] ? 'register.html' : 'ucp.php?go=register', 'show' => !$user_is && $config['register']),
);
$top_menu = array(
1 => array('name' => 'index', 'title' => $lang['INDEX'], 'url' => $config['siteurl'], 'show' => true),
2 => array('name' => 'rules', 'title' => $lang['RULES'], 'url' => $config['mod_writer'] ? 'rules.html' : 'go.php?go=rules', 'show' => true),
3 => array('name' => 'guide', 'title' => $lang['GUIDE'], 'url' => $config['mod_writer'] ? 'guide.html' : 'go.php?go=guide', 'show' => true),
4 => array('name' => 'stats', 'title' => $lang['STATS'], 'url' => $config['mod_writer'] ? 'stats.html' : 'go.php?go=stats', 'show' => $config['allow_stat_pg'] && user_can('access_stats')),
5 => array('name' => 'report', 'title' => $lang['REPORT'], 'url' => $config['mod_writer'] ? 'report.html' : 'go.php?go=report', 'show' => user_can('access_report')),
6 => array('name' => 'call', 'title' => $lang['CALL'], 'url' => $config['mod_writer'] ? 'call.html' : 'go.php?go=call', 'show' => user_can('access_call')),
);
$tpl->assign("side_menu", $side_menu);
$tpl->assign("top_menu", $top_menu);
$tpl->assign("dir", $dir);
$current_url = 'http://'.$_SERVER['HTTP_HOST']
. preg_replace('/[\&amp;|\?|\/]amp_page=\d/', '', $_SERVER['REQUEST_URI']);
$tpl->assign("amp_canonical", $current_url);
//ads
$tpl->assign("top_ad", trim($config['kj_amp_seo_top_ad']) == '' ? false : trim($config['kj_amp_seo_top_ad']));
$tpl->assign("middle_ad", trim($config['kj_amp_seo_middle_ad']) == '' ? false : trim($config['kj_amp_seo_middle_ad']));
$tpl->assign("sticky_ad", trim($config['kj_amp_seo_sticky_ad']) == '' ? false : trim($config['kj_amp_seo_sticky_ad']));
$tpl->assign("adsense_client", trim($config['kj_amp_seo_adsense_client']));
header('Content-type: text/html; charset=UTF-8');
header('Cache-Control: private, no-cache="set-cookie"');
header('Pragma: no-cache');
header('x-frame-options: SAMEORIGIN');
header('x-xss-protection: 1; mode=block');
exit($tpl->display('amp', __DIR__));
}
);