Merge branch 'feature/posts' into develop
This commit is contained in:
commit
bd414bac7e
|
@ -77,7 +77,6 @@ pipeline:
|
||||||
- sed -i "s#app_directory#$APP_DIRECTORY#g" .mage.yml
|
- sed -i "s#app_directory#$APP_DIRECTORY#g" .mage.yml
|
||||||
- /root/.config/composer/vendor/bin/mage deploy "$CI_BUILD_DEPLOY_TARGET"
|
- /root/.config/composer/vendor/bin/mage deploy "$CI_BUILD_DEPLOY_TARGET"
|
||||||
when:
|
when:
|
||||||
branch: [master, master-*, develop, develop-*]
|
|
||||||
event: [deployment]
|
event: [deployment]
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
|
@ -463,10 +463,14 @@ pre[class*="language-"] {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:not(.button), h1, h2, h3, h4, h5, p, ul {
|
a:not(.button), h1, h2, h3, h4, h5, p, ul:not(.btn-group) {
|
||||||
color: $color-body-text;
|
color: $color-body-text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.btn-group a {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
p a, ul a {
|
p a, ul a {
|
||||||
border-bottom: 2px dotted $color-blue2;
|
border-bottom: 2px dotted $color-blue2;
|
||||||
}
|
}
|
||||||
|
@ -1253,7 +1257,7 @@ $links: (
|
||||||
}
|
}
|
||||||
|
|
||||||
.bg-box {
|
.bg-box {
|
||||||
background: #fbfcff;
|
background: #f1f1f1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.invalid-feedback {
|
.invalid-feedback {
|
||||||
|
|
BIN
assets/images/post-image-logo.png
Normal file
BIN
assets/images/post-image-logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -9,16 +9,22 @@ class PxImage {
|
||||||
const images = doc.querySelectorAll('.quick-image img, .card figure img')
|
const images = doc.querySelectorAll('.quick-image img, .card figure img')
|
||||||
|
|
||||||
for (let i = 0, len = images.length; i < len; i++) {
|
for (let i = 0, len = images.length; i < len; i++) {
|
||||||
(function(image) {
|
((image) => {
|
||||||
const source = image.getAttribute('data-src')
|
const source = image.getAttribute('data-src')
|
||||||
|
const sourceError = image.getAttribute('data-src-error')
|
||||||
|
const color = image.getAttribute('data-color')
|
||||||
const loader = new Image()
|
const loader = new Image()
|
||||||
|
|
||||||
loader.onload = function() {
|
loader.onload = () => {
|
||||||
image.style.backgroundImage = 'url(' + source + ')'
|
image.style.background = `${color ? color : null} url(${source})`
|
||||||
image.style.backgroundSize = 'cover'
|
image.style.backgroundSize = 'cover'
|
||||||
image.style.backgroundPosition = 'center'
|
image.style.backgroundPosition = 'center'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loader.onerror = () => {
|
||||||
|
image.style.background = `${color ? color : null} url('${sourceError}') center center`
|
||||||
|
}
|
||||||
|
|
||||||
loader.src = source
|
loader.src = source
|
||||||
})(images[i])
|
})(images[i])
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ class PostController extends PageController
|
||||||
public function posts(int $page = 1): Response
|
public function posts(int $page = 1): Response
|
||||||
{
|
{
|
||||||
$entities = $this->createQuery()
|
$entities = $this->createQuery()
|
||||||
->paginate($page, 5)
|
->paginate($page, 9)
|
||||||
;
|
;
|
||||||
|
|
||||||
return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [
|
return $this->defaultRender($this->siteRequest->getPage()->getTemplate(), [
|
||||||
|
@ -111,7 +111,7 @@ class PostController extends PageController
|
||||||
if ($query || $tag) {
|
if ($query || $tag) {
|
||||||
$entities = $this->createQuery()
|
$entities = $this->createQuery()
|
||||||
->search($query, $tag)
|
->search($query, $tag)
|
||||||
->paginate($page, 5)
|
->paginate($page, 9)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class PostController extends PageController
|
||||||
{
|
{
|
||||||
$entities = $this->createQuery()
|
$entities = $this->createQuery()
|
||||||
->inCategory($category, false)
|
->inCategory($category, false)
|
||||||
->paginate($page, 5)
|
->paginate($page, 9)
|
||||||
;
|
;
|
||||||
|
|
||||||
if (!$category->getIsActive() && !$this->getUser()) {
|
if (!$category->getIsActive() && !$this->getUser()) {
|
||||||
|
|
38
src/Twig/Extension/ColorExtension.php
Normal file
38
src/Twig/Extension/ColorExtension.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Twig\Extension;
|
||||||
|
|
||||||
|
use Twig\Extension\AbstractExtension;
|
||||||
|
use Twig\TwigFunction;
|
||||||
|
|
||||||
|
class ColorExtension extends AbstractExtension
|
||||||
|
{
|
||||||
|
public function getFunctions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new TwigFunction('generate_color_by_string', [$this, 'generateColorByString']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateColorByString(string $value)
|
||||||
|
{
|
||||||
|
srand(crc32($value));
|
||||||
|
|
||||||
|
$colors = [];
|
||||||
|
|
||||||
|
for ($i = 0; $i < 3; ++$i) {
|
||||||
|
$colors[] = mt_rand(20 * ($i + 1), 50 * ($i + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
$red = dechex($colors[0]);
|
||||||
|
$green = dechex($colors[1]);
|
||||||
|
$blue = dechex($colors[2]);
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'#%s%s%s',
|
||||||
|
strlen($red) != 2 ? '0'.$red : $red,
|
||||||
|
strlen($green) != 2 ? '0'.$green : $green,
|
||||||
|
strlen($blue) != 2 ? '0'.$blue : $blue,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
28
src/Twig/Extension/TypoExtension.php
Normal file
28
src/Twig/Extension/TypoExtension.php
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Twig\Extension;
|
||||||
|
|
||||||
|
use Twig\Extension\AbstractExtension;
|
||||||
|
use Twig\TwigFilter;
|
||||||
|
use Twig\TwigFunction;
|
||||||
|
|
||||||
|
class TypoExtension extends AbstractExtension
|
||||||
|
{
|
||||||
|
public function getFilters(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new TwigFilter('nbsp', [$this, 'nbsp']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nbsp(string $value)
|
||||||
|
{
|
||||||
|
return preg_replace_callback(
|
||||||
|
'/(.+)(\.+|,+|;+|:+|!+|\?+)/isU',
|
||||||
|
function($d) {
|
||||||
|
return sprintf('%s %s', trim($d[1]), $d[2]);
|
||||||
|
},
|
||||||
|
$value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,13 +19,13 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{% for post in pager %}
|
<div class="grid grid-flow-row-dens grid-cols-12 md:p-8 gap-5">
|
||||||
{% if not loop.first %}
|
{% for post in pager %}
|
||||||
<hr class="col-12">
|
<div class="card shadow-md col-span-12 md:col-span-6 lg:col-span-4 m-3 bg-box">
|
||||||
{% endif %}
|
{{ include('page/post/_post_card.html.twig') }}
|
||||||
|
</div>
|
||||||
{{ include('page/post/_post.html.twig', {post: post}) }}
|
{% endfor %}
|
||||||
{% endfor %}
|
</div>
|
||||||
|
|
||||||
{% if pager.getPaginationData.pageCount > 1 %}
|
{% if pager.getPaginationData.pageCount > 1 %}
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|
|
@ -76,26 +76,8 @@
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<div class="grid grid-flow-row-dens grid-cols-3 gap-5">
|
<div class="grid grid-flow-row-dens grid-cols-3 gap-5">
|
||||||
{% for item in similarPosts %}
|
{% for item in similarPosts %}
|
||||||
{% set url = safe_path('blog_menu_post', {post: item.id, slug: item.slug, _domain: _domain}) %}
|
|
||||||
|
|
||||||
<div class="card shadow-md col-span-3 md:col-span-1 bg-box">
|
<div class="card shadow-md col-span-3 md:col-span-1 bg-box">
|
||||||
<div class="card">
|
{{ include('page/post/_post_card.html.twig', {post: item, summarySize: 100}) }}
|
||||||
{%- if item.image -%}
|
|
||||||
<figure>
|
|
||||||
<a href="{{ url }}">
|
|
||||||
{% set image = asset(item.image)|imagine_filter('post_preview_filter') %}
|
|
||||||
<img src="{{ asset('build/images/px.png') }}" data-src="{{ image }}" alt="{{ item.title }}">
|
|
||||||
</a>
|
|
||||||
</figure>
|
|
||||||
{%- endif -%}
|
|
||||||
<div class="card-body">
|
|
||||||
<h3 class="card-title">
|
|
||||||
<a href="{{- url -}}">
|
|
||||||
{{- item.title -}}
|
|
||||||
</a>
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
42
templates/page/post/_post_card.html.twig
Normal file
42
templates/page/post/_post_card.html.twig
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
{% set url = safe_path('blog_menu_post', {post: post.id, slug: post.slug, _domain: _domain}) %}
|
||||||
|
{% set color = generate_color_by_string(post.title) %}
|
||||||
|
|
||||||
|
{%- set image -%}
|
||||||
|
{%- if post.image -%}
|
||||||
|
{{ asset(post.image)|imagine_filter('post_preview_filter') }}
|
||||||
|
{%- elseif post.quickImage -%}
|
||||||
|
{{ post.quickImage }}
|
||||||
|
{% else %}
|
||||||
|
{{ asset('build/images/post-image-logo.png') }}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endset -%}
|
||||||
|
|
||||||
|
<figure>
|
||||||
|
<a href="{{ url }}">
|
||||||
|
<img src="{{ asset('build/images/px.png') }}" data-color="{{ generate_color_by_string(post.id) }}" data-src="{{- image -}}" data-src-error="{{ asset('build/images/post-image-logo.png') }}" alt="{{ post.title }}">
|
||||||
|
</a>
|
||||||
|
</figure>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
<h3 class="card-title">
|
||||||
|
<a href="{{- url -}}">
|
||||||
|
{{- post.title|nbsp|raw -}}
|
||||||
|
</a>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
{% set content %}
|
||||||
|
{% if post.contentFormat == 'html' %}
|
||||||
|
{{- post.content|murph_url|file_attributes|post -}}
|
||||||
|
{% elseif post.contentFormat == 'markdown' %}
|
||||||
|
{{- post.content|murph_url|file_attributes|markdown('post')|lazy_load -}}
|
||||||
|
{% elseif post.contentFormat == 'editorjs' %}
|
||||||
|
{{- post.content|murph_url|file_attributes|editorjs_to_html|raw -}}
|
||||||
|
{% endif %}
|
||||||
|
{%- endset -%}
|
||||||
|
|
||||||
|
{% set summarySize = summarySize ?? 200 %}
|
||||||
|
|
||||||
|
{% set content = content|striptags[:summarySize] %}
|
||||||
|
|
||||||
|
<p>{{ content }}{% if content|length >= summarySize %}…{% endif %}</p>
|
||||||
|
</div>
|
|
@ -1,13 +1,13 @@
|
||||||
{% extends "page/titled/default.html.twig" %}
|
{% extends "page/titled/default.html.twig" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{% for post in pager %}
|
<div class="grid grid-flow-row-dens grid-cols-12 md:p-8 gap-5">
|
||||||
{% if not loop.first %}
|
{% for post in pager %}
|
||||||
<hr class="col-12">
|
<div class="card shadow-md col-span-12 md:col-span-6 lg:col-span-4 m-3 bg-box">
|
||||||
{% endif %}
|
{{ include('page/post/_post_card.html.twig') }}
|
||||||
|
</div>
|
||||||
{{ include('page/post/_post.html.twig', {post: post}) }}
|
{% endfor %}
|
||||||
{% endfor %}
|
</div>
|
||||||
|
|
||||||
{% if pager.getPaginationData.pageCount > 1 %}
|
{% if pager.getPaginationData.pageCount > 1 %}
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|
|
@ -14,13 +14,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if pager %}
|
{% if pager %}
|
||||||
{% for post in pager %}
|
<div class="grid grid-flow-row-dens grid-cols-12 md:p-8 gap-5">
|
||||||
{% if not loop.first %}
|
{% for post in pager %}
|
||||||
<hr class="col-12">
|
<div class="card shadow-md col-span-12 md:col-span-6 lg:col-span-4 m-3 bg-box">
|
||||||
{% endif %}
|
{{ include('page/post/_post_card.html.twig') }}
|
||||||
|
</div>
|
||||||
{{ include('page/post/_post.html.twig', {post: post}) }}
|
{% endfor %}
|
||||||
{% endfor %}
|
</div>
|
||||||
|
|
||||||
{% if pager.getPaginationData.pageCount > 1 %}
|
{% if pager.getPaginationData.pageCount > 1 %}
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|
Loading…
Reference in a new issue