From: Marcel Werk Date: Sun, 19 Jun 2016 22:02:02 +0000 (+0200) Subject: Added amp version of the article page X-Git-Tag: 3.0.0_Beta_1~1393 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6a4d8742e874f637b7ca43f686884f058933d92e;p=GitHub%2FWoltLab%2FWCF.git Added amp version of the article page --- diff --git a/com.woltlab.wcf/templates/ampArticle.tpl b/com.woltlab.wcf/templates/ampArticle.tpl new file mode 100644 index 0000000000..87f49b04f6 --- /dev/null +++ b/com.woltlab.wcf/templates/ampArticle.tpl @@ -0,0 +1,68 @@ +{capture assign='pageTitle'}{$articleContent->title}{/capture} + +{capture assign='headContent'} + +{/capture} + +{include file='ampHeader'} + +
+
+

{$articleContent->title}

+ + +
+ + {if $articleContent->getImage()} +
+ + {if $articleContent->getImage()->caption} +
{$articleContent->getImage()->caption}
+ {/if} +
+ {/if} + + {if $articleContent->teaser} + + {/if} + +
+ {@$articleContent->getFormattedContent()} +
+
+ +{include file='ampFooter'} diff --git a/com.woltlab.wcf/templates/ampFooter.tpl b/com.woltlab.wcf/templates/ampFooter.tpl new file mode 100644 index 0000000000..3b64c54fa7 --- /dev/null +++ b/com.woltlab.wcf/templates/ampFooter.tpl @@ -0,0 +1,48 @@ + + + + + +

{lang}wcf.menu.page.navigation{/lang}

+
    + {foreach from=$__wcf->getBoxHandler()->getBoxByIdentifier('com.woltlab.wcf.MainMenu')->getMenu()->getMenuItemNodeList() item=menuItemNode} + {if $menuItemNode->getDepth() == 1 || $menuItemNode->getParentNode()->isActiveNode()} +
  1. + {lang}{$menuItemNode->title}{/lang} + + {if $menuItemNode->hasChildren() && $menuItemNode->isActiveNode()}
      {else}{/if} + + {if !$menuItemNode->hasChildren() && $menuItemNode->isLastSibling()} + {@"
  2. "|str_repeat:$menuItemNode->getOpenParentNodes()} + {/if} + {/if} + {/foreach} +
+
    + {foreach from=$__wcf->getBoxHandler()->getBoxByIdentifier('com.woltlab.wcf.FooterMenu')->getMenu()->getMenuItemNodeList() item=menuItemNode} +
  1. {lang}{$menuItemNode->title}{/lang}
  2. + {/foreach} +
+ +

{lang}wcf.menu.page.location{/lang}

+ +
+ + {if MODULE_COOKIE_POLICY_PAGE && !$__wcf->user->userID} + + {lang}wcf.page.cookiePolicy.info{/lang} + + + {/if} + + + + diff --git a/com.woltlab.wcf/templates/ampHeader.tpl b/com.woltlab.wcf/templates/ampHeader.tpl new file mode 100644 index 0000000000..9aa993198a --- /dev/null +++ b/com.woltlab.wcf/templates/ampHeader.tpl @@ -0,0 +1,193 @@ + + + + + {@$pageTitle} - {PAGE_TITLE|language} + + + {if !$headContent|empty} + {@$headContent} + {/if} + + + {literal}{/literal} + + + + + + +
+ + + +
+
diff --git a/com.woltlab.wcf/templates/article.tpl b/com.woltlab.wcf/templates/article.tpl index 1b3b1cf899..ba470e4779 100644 --- a/com.woltlab.wcf/templates/article.tpl +++ b/com.woltlab.wcf/templates/article.tpl @@ -75,6 +75,7 @@ {/if} {/foreach} {/if} + {/capture} {include file='header'} diff --git a/wcfsetup/install/files/lib/page/ArticleAmpPage.class.php b/wcfsetup/install/files/lib/page/ArticleAmpPage.class.php new file mode 100644 index 0000000000..b318184067 --- /dev/null +++ b/wcfsetup/install/files/lib/page/ArticleAmpPage.class.php @@ -0,0 +1,108 @@ + + * @package WoltLabSuite\Core\Page + * @since 3.0 + */ +class ArticleAmpPage extends AbstractPage { + /** + * @inheritDoc + */ + public $templateName = 'ampArticle'; + + /** + * @inheritDoc + */ + public $neededModules = ['MODULE_ARTICLE']; + + /** + * article content id + * @var integer + */ + public $articleContentID = 0; + + /** + * article content object + * @var ViewableArticleContent + */ + public $articleContent; + + /** + * article object + * @var ViewableArticle + */ + public $article; + + /** + * @inheritDoc + */ + public function readParameters() { + parent::readParameters(); + + if (isset($_REQUEST['id'])) $this->articleContentID = intval($_REQUEST['id']); + $this->articleContent = ViewableArticleContent::getArticleContent($this->articleContentID); + if ($this->articleContent === null) { + throw new IllegalLinkException(); + } + $this->article = ViewableArticle::getArticle($this->articleContent->articleID); + } + + /** + * @inheritDoc + */ + public function checkPermissions() { + parent::checkPermissions(); + + if (!$this->article->canRead()) { + throw new PermissionDeniedException(); + } + } + + /** + * @inheritDoc + */ + public function readData() { + parent::readData(); + + // update view count + $articleEditor = new ArticleEditor($this->article->getDecoratedObject()); + $articleEditor->updateCounters([ + 'views' => 1 + ]); + + // set location + PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.CategoryArticleList', $this->article->categoryID, $this->article->getCategory()); + foreach ($this->article->getCategory()->getParentCategories() as $parentCategory) { + PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.CategoryArticleList', $parentCategory->categoryID, $parentCategory); + } + PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.ArticleList'); + } + + /** + * @inheritDoc + */ + public function assignVariables() { + parent::assignVariables(); + + WCF::getTPL()->assign([ + 'articleContentID' => $this->articleContentID, + 'articleContent' => $this->articleContent, + 'article' => $this->article, + 'category' => $this->article->getCategory(), + 'regularCanonicalURL' => $this->articleContent->getLink() + ]); + } +} diff --git a/wcfsetup/install/files/style/ui/article.scss b/wcfsetup/install/files/style/ui/article.scss index 597e510ca7..2651f9ff27 100644 --- a/wcfsetup/install/files/style/ui/article.scss +++ b/wcfsetup/install/files/style/ui/article.scss @@ -6,7 +6,8 @@ overflow: hidden; img { - width: 100%; + height: auto !important; + width: 100% !important; } }