Skip to content

Commit

Permalink
Updated to Laravel 5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Xety committed Oct 26, 2019
1 parent c4331f2 commit 46b1e6a
Show file tree
Hide file tree
Showing 26 changed files with 168 additions and 328 deletions.
1 change: 0 additions & 1 deletion app/Http/Components/AnalyticsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace Xetaravel\Http\Components;

use Carbon\Carbon;
use Rinvex\Country\CountryLoader;
use Spatie\Analytics\AnalyticsFacade;
use Spatie\Analytics\Period;

Expand Down
20 changes: 10 additions & 10 deletions app/Http/Controllers/Admin/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,58 +30,58 @@ public function __construct()
*/
public function index()
{
$minutes = config('analytics.cache_lifetime_in_minutes');
$secondes = config('analytics.cache_lifetime_in_secondes');

$viewDatas = [];

if (config('analytics.enabled')) {
// @codeCoverageIgnoreStart
$visitorsData = Cache::remember('Analytics.visitors', $minutes, function () {
$visitorsData = Cache::remember('Analytics.visitors', $secondes, function () {
return $this->buildVisitorsGraph();
});
array_push($viewDatas, 'visitorsData');

$browsersData = Cache::remember('Analytics.browsers', $minutes, function () {
$browsersData = Cache::remember('Analytics.browsers', $secondes, function () {
return $this->buildBrowsersGraph();
});
array_push($viewDatas, 'browsersData');

$countriesData = Cache::remember('Analytics.countries', $minutes, function () {
$countriesData = Cache::remember('Analytics.countries', $secondes, function () {
return $this->buildCountriesGraph();
});
array_push($viewDatas, 'countriesData');

$devicesGraph = Cache::remember('Analytics.devices', $minutes, function () {
$devicesGraph = Cache::remember('Analytics.devices', $secondes, function () {
return $this->buildDevicesGraph();
});
array_push($viewDatas, 'devicesGraph');

$topCountries = array_slice($countriesData->rows, 0, 3);
array_push($viewDatas, 'topCountries');

$operatingSystemGraph = Cache::remember('Analytics.operatingsystem', $minutes, function () {
$operatingSystemGraph = Cache::remember('Analytics.operatingsystem', $secondes, function () {
return $this->buildOperatingSytemGraph();
});
array_push($viewDatas, 'operatingSystemGraph');

$todayVisitors = Cache::remember('Analytics.todayvisitors', $minutes, function () {
$todayVisitors = Cache::remember('Analytics.todayvisitors', $secondes, function () {
return $this->buildTodayVisitors();
});
array_push($viewDatas, 'todayVisitors');
// @codeCoverageIgnoreEnd
}

$usersCount = Cache::remember('Analytics.users.count', $minutes, function () {
$usersCount = Cache::remember('Analytics.users.count', $secondes, function () {
return User::count();
});
array_push($viewDatas, 'usersCount');

$articlesCount = Cache::remember('Analytics.articles.count', $minutes, function () {
$articlesCount = Cache::remember('Analytics.articles.count', $secondes, function () {
return Article::count();
});
array_push($viewDatas, 'articlesCount');

$commentsCount = Cache::remember('Analytics.comments.count', $minutes, function () {
$commentsCount = Cache::remember('Analytics.comments.count', $secondes, function () {
return Comment::count();
});
array_push($viewDatas, 'commentsCount');
Expand Down
16 changes: 16 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,20 @@ class Kernel extends HttpKernel
'role' => \Ultraware\Roles\Middleware\VerifyRole::class,
'level' => \Ultraware\Roles\Middleware\VerifyLevel::class,
];

/**
* The priority-sorted list of middleware.
*
* This forces non-global middleware to always be in the given order.
*
* @var array
*/
protected $middlewarePriority = [
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\Authenticate::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\Auth\Middleware\Authorize::class,
];
}
16 changes: 11 additions & 5 deletions app/Markdown/Emoji/EmojiExtension.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<?php
namespace Xetaravel\Markdown\Emoji;

use League\CommonMark\Extension\Extension;
use League\CommonMark\ConfigurableEnvironmentInterface;
use League\CommonMark\Extension\ExtensionInterface;

class EmojiExtension extends Extension
final class EmojiExtension implements ExtensionInterface
{
/**
* The emoji parser.
*
* @var \Xetaravel\Markdown\Emoji\EmojiParser
*/
protected $parser;
//protected $parser;

/**
* Create a new emoji parser instance.
*
* @param \Xetaravel\Markdown\Emoji\EmojiParser $parser
*/
public function __construct(EmojiParser $parser)
/*public function __construct(EmojiParser $parser)
{
$this->parser = $parser;
}
Expand All @@ -27,8 +28,13 @@ public function __construct(EmojiParser $parser)
*
* @return array
*/
public function getInlineParsers()
/*public function getInlineParsers()
{
return [$this->parser];
}*/

public function register(ConfigurableEnvironmentInterface $environment)
{
$environment->addInlineParser(new EmojiParser);
}
}
8 changes: 4 additions & 4 deletions app/Markdown/Emoji/EmojiParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
namespace Xetaravel\Markdown\Emoji;

use League\CommonMark\Inline\Element\Image;
use League\CommonMark\Inline\Parser\AbstractInlineParser;
use League\CommonMark\Inline\Parser\InlineParserInterface;
use League\CommonMark\InlineParserContext;

class EmojiParser extends AbstractInlineParser
class EmojiParser implements InlineParserInterface
{
/**
* The emoji mappings.
Expand Down Expand Up @@ -44,7 +44,7 @@ public function __construct()
*
* @return array
*/
public function getCharacters()
public function getCharacters(): array
{
return [':'];
}
Expand All @@ -57,7 +57,7 @@ public function getCharacters()
*
* @return bool
*/
public function parse(InlineParserContext $inlineContext)
public function parse(InlineParserContext $inlineContext): bool
{
$cursor = $inlineContext->getCursor();

Expand Down
16 changes: 12 additions & 4 deletions app/Markdown/Reply/ReplyExtension.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php
namespace Xetaravel\Markdown\Reply;

use League\CommonMark\Extension\Extension;
use League\CommonMark\ConfigurableEnvironmentInterface;
use League\CommonMark\Extension\ExtensionInterface;

class ReplyExtension extends Extension
final class ReplyExtension implements ExtensionInterface
{
/**
* Returns a list of block parsers to add to the existing list.
*
* @return array
*/
public function getBlockParsers()
/*public function getBlockParsers()
{
return [
new ReplyParser(),
Expand All @@ -22,10 +23,17 @@ public function getBlockParsers()
*
* @return array
*/
public function getBlockRenderers()
/*public function getBlockRenderers()
{
return [
Reply::class => new ReplyRenderer(),
];
}*/

public function register(ConfigurableEnvironmentInterface $environment)
{
$environment
->addBlockParser(new ReplyParser)
->addBlockRenderer(Reply::class, new ReplyRenderer);
}
}
10 changes: 5 additions & 5 deletions app/Markdown/Reply/ReplyParser.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php
namespace Xetaravel\Markdown\Reply;

use League\CommonMark\Block\Element\HtmlInline;
use League\CommonMark\Block\Parser\AbstractBlockParser;
use League\CommonMark\Block\Parser\BlockParserInterface;
use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
use League\CommonMark\Util\RegexHelper;

class ReplyParser extends AbstractBlockParser
class ReplyParser implements BlockParserInterface
{

const REGEXP_REPLY = '/\@(?<user>[\w]{4,20})\#(?<post>[0-9]{1,16})/';
Expand All @@ -16,11 +15,12 @@ class ReplyParser extends AbstractBlockParser
* Parse a line and determine if it contains an emoji. If it does,
* then we do the necessary.
*
* @param \League\CommonMark\InlineParserContext $inlineContext
* @param \League\CommonMark\ContextInterface $context
* @param \League\CommonMark\Cursor $cursor
*
* @return bool
*/
public function parse(ContextInterface $context, Cursor $cursor)
public function parse(ContextInterface $context, Cursor $cursor): bool
{
$matches = RegexHelper::matchAll(self::REGEXP_REPLY, $cursor->getLine());

Expand Down
54 changes: 22 additions & 32 deletions app/Markdown/Table/TableExtension.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
<?php
namespace Xetaravel\Markdown\Table;

use League\CommonMark\Extension\Extension;
use Webuni\CommonMark\TableExtension\TableCaptionRenderer;
use Webuni\CommonMark\TableExtension\TableRowsRenderer;
use Webuni\CommonMark\TableExtension\TableRowRenderer;
use Webuni\CommonMark\TableExtension\TableCellRenderer;
use Webuni\CommonMark\TableExtension\TableParser;
use League\CommonMark\ConfigurableEnvironmentInterface;
use League\CommonMark\Extension\ExtensionInterface;
use League\CommonMark\Ext\Table\Table;
use League\CommonMark\Ext\Table\TableParser;
use League\CommonMark\Ext\Table\TableCaption;
use League\CommonMark\Ext\Table\TableCaptionRenderer;
use League\CommonMark\Ext\Table\TableSection;
use League\CommonMark\Ext\Table\TableSectionRenderer;
use League\CommonMark\Ext\Table\TableRow;
use League\CommonMark\Ext\Table\TableRowRenderer;
use League\CommonMark\Ext\Table\TableCell;
use League\CommonMark\Ext\Table\TableCellRenderer;

class TableExtension extends Extension
final class TableExtension implements ExtensionInterface
{
/**
* Returns a list of block parsers to add to the existing list.
*
* @return array
*/
public function getBlockParsers()
public function register(ConfigurableEnvironmentInterface $environment): void
{
return [
new TableParser(),
];
}

/**
* Returns a list of block renderers to add to the existing list.
*
* @return array
*/
public function getBlockRenderers()
{
return [
\Webuni\CommonMark\TableExtension\Table::class => new TableRenderer(),
\Webuni\CommonMark\TableExtension\TableCaption::class => new TableCaptionRenderer(),
\Webuni\CommonMark\TableExtension\TableRows::class => new TableRowsRenderer(),
\Webuni\CommonMark\TableExtension\TableRow::class => new TableRowRenderer(),
\Webuni\CommonMark\TableExtension\TableCell::class => new TableCellRenderer(),
];
$environment
->addBlockParser(new TableParser())
->addBlockRenderer(Table::class, new TableRenderer())
->addBlockRenderer(TableCaption::class, new TableCaptionRenderer())
->addBlockRenderer(TableSection::class, new TableSectionRenderer())
->addBlockRenderer(TableRow::class, new TableRowRenderer())
->addBlockRenderer(TableCell::class, new TableCellRenderer())
;
}
}
9 changes: 4 additions & 5 deletions app/Markdown/Table/TableRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use League\CommonMark\Block\Renderer\BlockRendererInterface;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
use Webuni\CommonMark\TableExtension\Table;
use League\CommonMark\Ext\Table\Table;

class TableRenderer implements BlockRendererInterface
final class TableRenderer implements BlockRendererInterface
{
/**
* Render the table element.
Expand All @@ -20,19 +20,18 @@ class TableRenderer implements BlockRendererInterface
*
* @return \League\CommonMark\HtmlElement
*/
public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, bool $inTightList = false)
{
if (!($block instanceof Table)) {
throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
}

$attrs = [];

foreach ($block->getData('attributes', []) as $key => $value) {
$attrs[$key] = $htmlRenderer->escape($value, true);
}

$attrs['class'] = 'table';

$separator = $htmlRenderer->getOption('inner_separator', "\n");

return new HtmlElement(
Expand Down
44 changes: 0 additions & 44 deletions app/Markdown/TaskLists/TaskListsCheckbox.php

This file was deleted.

Loading

0 comments on commit 46b1e6a

Please sign in to comment.