Last active
November 8, 2016 08:54
-
-
Save CB9TOIIIA/78e8699f0eba585256af17c3cf243e85 to your computer and use it in GitHub Desktop.
⚡ AMP Joomla! by Lullabot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| defined('_JEXEC') or die; | |
| //need: https://github.com/Lullabot/amp-library | |
| require_once '/amp/vendor/autoload.php'; | |
| use Lullabot\AMP\AMP; | |
| use Lullabot\AMP\Validate\Scope; | |
| <?php $checkamp = $_SERVER['REQUEST_URI']; ?> | |
| <?php //edit match for you ?> | |
| <?php if (!preg_match('/ampproject/', $checkamp)) : ?> | |
| <?php | |
| // +-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+ | |
| // |y|o|u|r| |t|e|m|p|l|a|t|e| |J|o|o|m|l|a| | |
| // +-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+ | |
| ?> | |
| <?php endif; ?> | |
| <!doctype html> | |
| <html ⚡> | |
| <head> | |
| <?php | |
| $document = JFactory::getDocument(); | |
| echo "<title>".$document->title."</title>".PHP_EOL; | |
| if (!empty($document->description)) { | |
| echo "<meta name='description' content='".$document->description."'/>"; | |
| } | |
| else { | |
| $descr = str_replace("\n", ' ', $document->_custom[8]); //description | |
| echo $descr; | |
| } | |
| $amp = new AMP(); | |
| $html = file_get_contents(JURI::current().'?tmpl=raw'); | |
| $amp->loadHtml($html); | |
| $amp_html = $amp->convertToAmpHtml(); | |
| // dump($amp_html,0,'test'); | |
| ?> | |
| <meta content="article" property="og:type" /> | |
| <meta charset="utf-8"> | |
| <link rel='canonical' href='<?php echo JURI::current(); ?>' > | |
| <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> | |
| <script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script> | |
| <script async src="https://cdn.ampproject.org/v0.js"></script> | |
| <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script> | |
| <script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script> | |
| <script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script> | |
| <script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></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 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> | |
| /* any custom style goes here. */ | |
| body { background-color: white; overflow: hidden; font-family: Tahoma, Arial, Geneva, sans-serif; } amp-img { background-color: #fff; } .logo amp-img {background-color: #fff;} h1 {font-size: 1.1em; padding: 10px; } .logo {text-align: center; width: 95%;} .text {padding: 10px; } .date {margin-left: 5px;}.main-body { margin: 0 auto 42px; max-width: 600px; } .text img {max-width: 100%; } .row {position: relative;} .mainsite {background-color: #007E93; text-align: center; padding: 20px 10px; } .mainsite a {color: #fff; padding: 10px;} | |
| </style> | |
| </head> | |
| <body> | |
| <div class="main-body"> | |
| //analytics | |
| <?php echo $amp_html; ?> | |
| <div class="row gosite"> | |
| <p class="mainsite"><a href="<?php echo JURI::current(); ?>">Перейти на основную версию сайта</a></p> | |
| <p class="bordo"><a href="<?php echo JURI::current(); ?>#disqus_thread">Комментарии</a></p> | |
| </div> | |
| </div> | |
| </body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment