FIX: SS Blog

This commit is contained in:
Tony Air 2018-08-06 18:46:54 +07:00
parent 18085772c5
commit e2ec5b0c75
14 changed files with 169 additions and 112 deletions

View File

@ -20,3 +20,10 @@ SilverStripe\View\SSViewer:
SilverStripe\Forms\HTMLEditor\TinyMCEConfig: SilverStripe\Forms\HTMLEditor\TinyMCEConfig:
editor_css: editor_css:
- 'app/client/dist/css/editor.css' - 'app/client/dist/css/editor.css'
SilverStripe\Assets\File:
allowed_extensions:
- svg
app_categories:
image:
- svg

View File

@ -22,6 +22,8 @@ import 'bootstrap/js/dist/tab';
Vue.use(Carousel);*/ Vue.use(Carousel);*/
import 'offcanvas-bootstrap/dist/js/bootstrap.offcanvas'; import 'offcanvas-bootstrap/dist/js/bootstrap.offcanvas';
import 'jquery-zoom/jquery.zoom';
import 'meta-lightbox/meta-lightbox';
import './_main'; import './_main';
import './_layout'; import './_layout';

View File

@ -16,6 +16,10 @@
.carousel-indicators li { .carousel-indicators li {
box-shadow: 1px 1px #000; box-shadow: 1px 1px #000;
&.active {
background: $blue;
}
} }
.carousel-title, .carousel-title,

View File

@ -4,3 +4,16 @@ ru:
JAVASCRIPTREQUIRED: "Для корректной работы страницы требуется включить Javascript!" JAVASCRIPTREQUIRED: "Для корректной работы страницы требуется включить Javascript!"
UPGRADEBROWSER: "Обновите браузер!" UPGRADEBROWSER: "Обновите браузер!"
OUTDATEDBROWSER: "Вы используете устаревшую версию браузера. Обновите ваш браузер сейчас для повышения уровня безопасности вашей системы." OUTDATEDBROWSER: "Вы используете устаревшую версию браузера. Обновите ваш браузер сейчас для повышения уровня безопасности вашей системы."
PaginationLabel: "Переключение страниц"
PaginationPrevious: "Назад"
PaginationNext: "Вперед"
SilverStripe\Blog\Model\Blog:
PostedIn: "Категории"
Tagged: "Отметки"
Comments: "Коментарии"
Posted: "Опубликовано"
By: " - "
AND: "и"
LessThanAMinuteToRead: "Меньше минуты на чтение"
MinutesToRead: "Минут на чтение"
READMORE: "Подробнее"

View File

@ -9,10 +9,22 @@
namespace Site\Extensions; namespace Site\Extensions;
use DNADesign\Elemental\Models\ElementContent; use DNADesign\Elemental\Models\ElementContent;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\DataExtension;
class BlogPostExtension extends DataExtension class BlogPostExtension extends DataExtension
{ {
private static $db = [
'Featured' => 'Boolean(0)',
];
public function updateCMSFields(FieldList $fields)
{
$mainTab = $fields->findOrMakeTab('Root.Main');
$mainTab->push(CheckboxField::create('Featured'));
}
/* /*
* Shows custom summary of the post, otherwise * Shows custom summary of the post, otherwise
* Displays summary of the first content element * Displays summary of the first content element

View File

@ -11,14 +11,15 @@ use SilverStripe\Forms\TreeMultiselectField;
class SiteConfigExtension extends DataExtension class SiteConfigExtension extends DataExtension
{ {
private static $db = [ private static $db = [
'ShortDescription' => 'Text',
'ExtraCode' => 'Text', 'ExtraCode' => 'Text',
]; ];
private static $has_one = [
'PrivacyPolicy' => SiteTree::class,
];
private static $many_many = [ private static $many_many = [
'Navigation' => SiteTree::class, 'Navigation' => SiteTree::class,
'Services' => SiteTree::class,
'QuickLinks' => SiteTree::class,
]; ];
public function updateCMSFields(FieldList $fields) public function updateCMSFields(FieldList $fields)
@ -31,18 +32,7 @@ class SiteConfigExtension extends DataExtension
SiteTree::class SiteTree::class
)); ));
$tab->push(TreeMultiselectField::create( $tab->push(TreeDropdownField::create('PrivacyPolicyID', 'Select privacy policy page', SiteTree::class));
'Services',
'Services',
SiteTree::class
));
$tab->push(TreeMultiselectField::create(
'QuickLinks',
'QuickLinks',
SiteTree::class
));
$tab->push(TextareaField::create('ShortDescription'));
$tab->push(TextareaField::create('ExtraCode', 'Extra site-wide HTML code')); $tab->push(TextareaField::create('ExtraCode', 'Extra site-wide HTML code'));
} }

View File

@ -6,9 +6,22 @@
use SilverStripe\CMS\Controllers\ContentController; use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Blog\Model\BlogPost;
class PageController extends ContentController class PageController extends ContentController
{ {
private static $static_path = '/resources/app/client/dist/';
public function RecentBlogPosts()
{
return BlogPost::get()->sort('PublishDate DESC');
}
public function StaticPath($path = '')
{
return self::join_links($this->config()->get('static_path'), $path);
}
public function CurrentTime() public function CurrentTime()
{ {
return DBDatetime::now(); return DBDatetime::now();

View File

@ -1,40 +1,5 @@
<% with $SiteConfig %> <% with $SiteConfig %>
<div class="container"> <div class="container">
<div class="row">
<div class="col-md-4">
<div class="col">
<h2>About Us</h2>
<div class="typography short-description">
$ShortDescription
</div>
</div>
</div>
<div class="col-md-2">
<div class="col">
<h2>Services</h2>
<ul class="links">
<% loop $Services %>
<li>
<a href="{$Link}">$Title</a>
</li>
<% end_loop %>
</ul>
</div>
</div>
<div class="col-md-2">
<div class="col">
<h2>Quick Links</h2>
<ul class="links">
<% loop $QuickLinks %>
<li>
<a href="{$Link}">$Title</a>
</li>
<% end_loop %>
</ul>
</div>
</div>
<div class="col-md-4">
<div class="col">
<h2>Contact Us</h2> <h2>Contact Us</h2>
<div class="field row"> <div class="field row">
<div class="title col-sm-4">Address:</div> <div class="title col-sm-4">Address:</div>
@ -53,13 +18,19 @@
<% include Objects\SocialLinks %> <% include Objects\SocialLinks %>
</div> </div>
<div class="copyright">
<div class="container">
<div class="row">
<div class="col-sm-6">
Copyright &copy; {$Top.CurrentTime.Format("Y")} {$Title} All rights reserved.
</div>
<div class="col-sm-6">
<% if $PrivacyPolicy %>
<a href="$PrivacyPolicy.Link" target="_blank">$PrivacyPolicy.Title</a>
<% end_if %>
</div>
</div> </div>
</div> </div>
</div> </div>
<% end_with %> <% end_with %>
<div class="copyright">
<div class="container">
Copyright &copy; {$CurrentTime.Format("Y")} All rights reserved.
</div>
</div>

View File

@ -1,6 +1,6 @@
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<a id="Logo" href="/"><img src="/resources/app/client/dist/img/logo.png" alt="{$SiteConfig.Title}" /></a> <a id="Logo" href="/"><img src="{$StaticPath('img/logo.png')}" alt="{$SiteConfig.Title}" /></a>
</div> </div>
<div class="col-sm-6 text-right"> <div class="col-sm-6 text-right">
<% with $SiteConfig %> <% with $SiteConfig %>

View File

@ -0,0 +1,31 @@
<%-- NOTE: Before including this, you will need to wrap the include in a with block --%>
<% if $MoreThanOnePage %>
<nav aria-label="<%t Page.PaginationLabel "Pagination" %>">
<ul class="pagination justify-content-center">
<li class="page-item<% if $FirstPage %> disabled<% end_if %>">
<a class="page-link" href="{$PrevLink}" aria-label="<%t Page.PaginationPrevious "Previous" %>">
<span aria-hidden="true">&laquo;</span>
<span class="sr-only"><%t Page.PaginationPrevious "Previous" %></span>
</a>
</li>
<% loop $PaginationSummary(12) %>
<li class="page-item<% if $CurrentBool %> active<% end_if %>">
<% if $Link %>
<a href="$Link" class="page-link">$PageNum</a>
<% else %>
<span>...</span>
<% end_if %>
</li>
<% end_loop %>
<li class="page-item<% if $LastPage %> disabled<% end_if %>">
<a class="page-link" href="{$NextLink}" aria-label="<%t Page.PaginationNext "Next" %>">
<span aria-hidden="true">&raquo;</span>
<span class="sr-only"><%t Page.PaginationNext "Next" %></span>
</a>
</li>
</ul>
</nav>
<% end_if %>

View File

@ -1,46 +1,57 @@
<div class="blog-post-meta"> <div class="blog-post-meta text-muted">
<%-- if $Categories.exists %> <% if $Categories.exists %>
<div class="categories">
<%t SilverStripe\\Blog\\Model\\Blog.PostedIn "Posted in" %> <%t SilverStripe\\Blog\\Model\\Blog.PostedIn "Posted in" %>
<% loop $Categories %> <% loop $Categories %>
<a href="$Link" title="$Title">$Title</a><% if not Last %>, <% else %>;<% end_if %> <a href="$Link" title="$Title" class="category">$Title</a><% if not Last %>, <% else %>;<% end_if %>
<% end_loop %> <% end_loop %>
<% end_if --%> </div>
<% end_if %>
<%-- if $Tags.exists %> <% if $Tags.exists %>
<div class="tags">
<%t SilverStripe\\Blog\\Model\\Blog.Tagged "Tagged" %> <%t SilverStripe\\Blog\\Model\\Blog.Tagged "Tagged" %>
<% loop $Tags %> <% loop $Tags %>
<a href="$Link" title="$Title">$Title</a><% if not Last %>, <% else %>;<% end_if %> <a href="$Link" title="$Title" class="tag">$Title</a><% if not Last %>, <% else %>;<% end_if %>
<% end_loop %> <% end_loop %>
<% end_if --%> </div>
<% end_if %>
<%-- t SilverStripe\\Blog\\Model\\Blog.Posted "Posted" %> <div class="posted-ago">
<a href="$MonthlyArchiveLink">$PublishDate.ago</a --%> <%t SilverStripe\\Blog\\Model\\Blog.Posted "Posted" %>
<a href="$MonthlyArchiveLink">$PublishDate.ago</a>
</div>
<% if $Credits %> <% if $Credits %>
<div class="credits">
<%t SilverStripe\\Blog\\Model\\Blog.By "by" %> <%t SilverStripe\\Blog\\Model\\Blog.By "by" %>
<% loop $Credits %> <% loop $Credits %>
<% if not $First && not $Last %>, <% end_if %> <% if not $First && not $Last %>, <% end_if %>
<% if not $First && $Last %> <%t SilverStripe\\Blog\\Model\\Blog.AND "and" %> <% end_if %> <% if not $First && $Last %> <%t SilverStripe\\Blog\\Model\\Blog.AND "and" %> <% end_if %>
<% if $URLSegment && not $Up.ProfilesDisabled %> <% if $URLSegment && not $Up.ProfilesDisabled %>
<a href="$URL">$Name.XML</a> <a href="$URL" class="credit">$Name.XML</a>
<% else %> <% else %>
$Name.XML <span class="credit">$Name.XML</span>
<% end_if %> <% end_if %>
<% end_loop %> <% end_loop %>
</div>
<% end_if %> <% end_if %>
<% if $Comments.exists %> <% if $Comments.exists %>
<a href="{$Link}#comments-holder"> <a class="comments" href="{$Link}#comments-holder">
$Comments.count <span class="count">$Comments.count</span>
<%t SilverStripe\\Blog\\Model\\Blog.Comments "comments" %> <%t SilverStripe\\Blog\\Model\\Blog.Comments "comments" %>
</a> </a>
<% end_if %> <% end_if %>
<br/> <% if $MinutesToRead %>
<div class="reading-time">
<% if $MinutesToRead < 1 %> <% if $MinutesToRead < 1 %>
<%t SilverStripe\\Blog\\Model\\Blog.LessThanAMinuteToRead "Less than a minute to read" %> <%t SilverStripe\\Blog\\Model\\Blog.LessThanAMinuteToRead "Less than a minute to read" %>
<% else %> <% else %>
$MinutesToRead <%t SilverStripe\\Blog\\Model\\Blog.MinutesToRead "Minute(s) to read" %> $MinutesToRead <%t SilverStripe\\Blog\\Model\\Blog.MinutesToRead "Minute(s) to read" %>
<% end_if %> <% end_if %>
</div> </div>
<% end_if %>
</div>

View File

@ -33,7 +33,7 @@
<% end_if %> <% end_if %>
<% with $PaginatedList %> <% with $PaginatedList %>
<% include SilverStripe\\Blog\\Pagination %> <% include Objects\Pagination %>
<% end_with %> <% end_with %>
$CommentsForm $CommentsForm

View File

@ -19,7 +19,7 @@
<% if $Description %><p class="carousel-content">$Description</p><% end_if %> <% if $Description %><p class="carousel-content">$Description</p><% end_if %>
<% if $PageLinkID %> <% if $PageLinkID %>
<p> <p>
<a href="$PageLink.Link" title="$PageLink.MenuTitle.XML" class="btn btn-default"> <a href="$PageLink.Link" title="$PageLink.MenuTitle.XML" class="btn btn-default btn-lg">
<i class="fas fa-bars"></i> <i class="fas fa-bars"></i>
<%t Dynamic\FlexSlider\ORM\FlexSlider.LEARN_MORE "Learn more" %> <%t Dynamic\FlexSlider\ORM\FlexSlider.LEARN_MORE "Learn more" %>
</a> </a>

View File

@ -28,16 +28,19 @@
"axllent/silverstripe-bootstrap-forms": "^2.0", "axllent/silverstripe-bootstrap-forms": "^2.0",
"silverstripe/redirectedurls": "dev-master", "silverstripe/redirectedurls": "dev-master",
"undefinedoffset/silverstripe-nocaptcha": "*", "undefinedoffset/silverstripe-nocaptcha": "*",
"a2nt/silverstripe-font-awesome-field": "dev-master" "a2nt/silverstripe-font-awesome-field": "dev-master",
"stevie-mayhew/silverstripe-svg": "^2.1"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^5.7", "phpunit/phpunit": "^5.7",
"lekoala/silverstripe-debugbar": "dev-master" "lekoala/silverstripe-debugbar": "dev-master"
}, },
"repositories": [{ "repositories": [
{
"type": "vcs", "type": "vcs",
"url": "https://github.com/a2nt/silverstripe-font-awesome" "url": "https://github.com/a2nt/silverstripe-font-awesome"
}], }
],
"extra": { "extra": {
"expose": [ "expose": [
"app/client/dist" "app/client/dist"