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:
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);*/
import 'offcanvas-bootstrap/dist/js/bootstrap.offcanvas';
import 'jquery-zoom/jquery.zoom';
import 'meta-lightbox/meta-lightbox';
import './_main';
import './_layout';

View File

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

View File

@ -4,3 +4,16 @@ ru:
JAVASCRIPTREQUIRED: "Для корректной работы страницы требуется включить Javascript!"
UPGRADEBROWSER: "Обновите браузер!"
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;
use DNADesign\Elemental\Models\ElementContent;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\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
* Displays summary of the first content element

View File

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

View File

@ -6,9 +6,22 @@
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Blog\Model\BlogPost;
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()
{
return DBDatetime::now();

View File

@ -1,65 +1,36 @@
<% with $SiteConfig %>
<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>
<div class="field row">
<div class="title col-sm-4">Address:</div>
<div class="value col-sm-8">$Address</div>
</div>
<h2>Contact Us</h2>
<div class="field row">
<div class="title col-sm-4">Address:</div>
<div class="value col-sm-8">$Address</div>
</div>
<div class="field row">
<div class="title col-sm-4">Phone:</div>
<div class="value col-sm-8">$PhoneNumber</div>
</div>
<div class="field row">
<div class="title col-sm-4">Phone:</div>
<div class="value col-sm-8">$PhoneNumber</div>
</div>
<div class="field row">
<div class="title col-sm-4">Email:</div>
<div class="value col-sm-8">$PublicEmail</div>
</div>
<div class="field row">
<div class="title col-sm-4">Email:</div>
<div class="value col-sm-8">$PublicEmail</div>
</div>
<% include Objects\SocialLinks %>
<% include Objects\SocialLinks %>
</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>
<% 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="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 class="col-sm-6 text-right">
<% with $SiteConfig %>
@ -23,4 +23,4 @@
<% if $SiteConfig.Navigation %>
<% include Navigation Navigation=$SiteConfig.Navigation, NavID="Navigation" %>
<% end_if %>
<% end_if %>

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

View File

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

View File

@ -19,7 +19,7 @@
<% if $Description %><p class="carousel-content">$Description</p><% end_if %>
<% if $PageLinkID %>
<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>
<%t Dynamic\FlexSlider\ORM\FlexSlider.LEARN_MORE "Learn more" %>
</a>

View File

@ -28,16 +28,19 @@
"axllent/silverstripe-bootstrap-forms": "^2.0",
"silverstripe/redirectedurls": "dev-master",
"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": {
"phpunit/phpunit": "^5.7",
"lekoala/silverstripe-debugbar": "dev-master"
},
"repositories": [{
"type": "vcs",
"url": "https://github.com/a2nt/silverstripe-font-awesome"
}],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/a2nt/silverstripe-font-awesome"
}
],
"extra": {
"expose": [
"app/client/dist"
@ -62,4 +65,4 @@
},
"prefer-stable": true,
"minimum-stability": "dev"
}
}