Skip to content

Commit

Permalink
Merge branch 'release/6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
IllyaMoskvin committed Jan 21, 2020
2 parents ba3e269 + 0665b05 commit c07ec18
Show file tree
Hide file tree
Showing 40 changed files with 363 additions and 169 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,6 @@ DEBUG_BAR_IN_FE=
SITEMAP_BASE_URL=

IPINFO_TOKEN=

# `php artisan update:links` will automatically convert any Block links to these domains to absolute links
SCRUB_DOMAINS='www.artic.edu'
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0
6.1
35 changes: 35 additions & 0 deletions app/Console/Commands/UpdateLinks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class UpdateLinks extends Command
{

protected $signature = 'update:links';

protected $description = 'Remove old URLs from blocks';

public function handle()
{

foreach( config('app.scrub_domains') as $url ) {
$blocks = \A17\Twill\Models\Block::whereRaw("content::text LIKE '%" . $url . "%'");

$blocks = $blocks->cursor();

foreach( $blocks as $block ) {
$content = $block->getOriginal('content');
$content = str_replace("http:\/\/" . $url, '', $content);
$content = str_replace("https:\/\/" . $url, '', $content);
$content = str_replace('"' . $url, '"', $content);
$block->content = $block->fromJson( $content ); // $casts as array
$block->save();
$this->info('Updated ' . $url . ' in ' . $block->blockable_type . ', #' . $block->blockable_id);
}
}

}

}
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
$schedule->command('sitemap:generate')->twiceDaily();
$schedule->command('update:links')->daily();
}

/**
Expand Down
114 changes: 114 additions & 0 deletions app/Http/Controllers/Admin/IssueArticleController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

namespace App\Http\Controllers\Admin;

use A17\Twill\Http\Controllers\Admin\ModuleController;
use App\Repositories\IssueRepository;

class IssueArticleController extends ModuleController
{
protected $moduleName = 'issues.articles';
protected $modelName = 'IssueArticle';

protected function getParentModuleForeignKey()
{
return 'issue_id';
}

protected $indexColumns = [
'image' => [
'title' => 'Hero',
'thumb' => true,
'variant' => [
'role' => 'hero',
'crop' => 'default',
],
],
'title' => [
'title' => 'Title',
'edit_link' => true,
'sort' => true,
'field' => 'title',
],
'date' => [
'title' => 'Date',
'edit_link' => true,
'sort' => true,
'field' => 'date',
'present' => true,
],
'issue_number' => [
'title' => 'Issue No.',
'edit_link' => true,
'sort' => true,
'field' => 'issueNumber',
'present' => true,
],
];

protected $defaultOrders = ['position' => 'asc'];

protected function indexData($request)
{
$issue = app(IssueRepository::class)->getById(request('issue'));
return [
'breadcrumb' => [
[
'label' => 'Issues',
'url' => moduleRoute('issues', 'collection', 'index'),
],
[
'label' => $issue->title,
'url' => moduleRoute('issues', 'collection', 'edit', $issue->id),
],
[
'label' => 'Articles',
],

],
];
}

protected function formData($request)
{
$issue = app(IssueRepository::class)->getById(request('issue'));
return [
'breadcrumb' => [
[
'label' => 'Issues',
'url' => moduleRoute('issues', 'collection', 'index'),
],
[
'label' => $issue->title,
'url' => moduleRoute('issues', 'collection', 'edit', $issue->id),
],
[
'label' => 'Articles',
'url' => moduleRoute('issues.articles', 'collection', 'index', $request->route('issue')),
],
[
'label' => $issue->title,
],
],
];
}

protected function getPermalinkBaseUrl()
{
$issue = app(IssueRepository::class)->getById(request('issue'));
return request()->getScheme() . '://' . config('app.url') . '/journal/issue/' . $issue->id . '/' . $issue->getSlug() . '/';
}
/*
protected function formData($request)
{
$item = $this->repository->getById(request('article') ?? request('id'));
$baseUrl = '//' . config('app.url') . '/' .$this->permalinkBase . $item->present()->issue_number . '/';
$baseUrl .= $item->issue ? $item->issue->getSlug() : '';
$baseUrl .= '/' . $item->id . '/';
return [
'baseUrl' => $baseUrl,
];
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use A17\Twill\Http\Controllers\Admin\ModuleController;

class JournalIssueController extends ModuleController
class IssueController extends ModuleController
{
protected $moduleName = 'journalIssues';
protected $moduleName = 'issues';

protected $permalinkBase = 'journal/issue/';

Expand Down Expand Up @@ -39,13 +39,17 @@ class JournalIssueController extends ModuleController
'field' => 'issueNumber',
'present' => true,
],
'articles' => [
'title' => 'Articles',
'nested' => 'articles',
]
];

protected $defaultOrders = ['position' => 'asc'];

protected function formData($request)
{
$item = $this->repository->getById(request('journalIssue') ?? request('id'));
$item = $this->repository->getById(request('issue') ?? request('id'));
$baseUrl = '//' . config('app.url') . '/' .$this->permalinkBase . $item->issue_number . '/';

return [
Expand Down
57 changes: 0 additions & 57 deletions app/Http/Controllers/Admin/JournalArticleController.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use A17\Twill\Http\Requests\Admin\Request;

class JournalArticleRequest extends Request
class IssueArticleRequest extends Request
{
public function rulesForCreate()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use A17\Twill\Http\Requests\Admin\Request;

class JournalIssueRequest extends Request
class IssueRequest extends Request
{
public function rulesForCreate()
{
Expand Down
11 changes: 8 additions & 3 deletions app/Models/JournalIssue.php → app/Models/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
use A17\Twill\Models\Behaviors\Sortable;
use A17\Twill\Models\Model;

class JournalIssue extends Model implements Sortable
class Issue extends Model implements Sortable
{
use HasSlug, HasMedias, HasRevisions, HasPosition;

protected $presenter = 'App\Presenters\Admin\JournalIssuePresenter';
protected $presenterAdmin = 'App\Presenters\Admin\JournalIssuePresenter';
protected $presenter = 'App\Presenters\Admin\IssuePresenter';
protected $presenterAdmin = 'App\Presenters\Admin\IssuePresenter';

protected $fillable = [
'published',
Expand Down Expand Up @@ -61,6 +61,11 @@ class JournalIssue extends Model implements Sortable
],
];

public function articles()
{
return $this->hasMany('App\Models\IssueArticle', 'issue_id');
}

// Generates the id-slug type of URL
public function getRouteKeyName()
{
Expand Down
12 changes: 6 additions & 6 deletions app/Models/JournalArticle.php → app/Models/IssueArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
use A17\Twill\Models\Behaviors\Sortable;
use A17\Twill\Models\Model;

class JournalArticle extends Model implements Sortable
class IssueArticle extends Model implements Sortable
{
use HasSlug, HasMedias, HasRevisions, HasPosition;

protected $presenter = 'App\Presenters\Admin\JournalArticlePresenter';
protected $presenterAdmin = 'App\Presenters\Admin\JournalArticlePresenter';
protected $presenter = 'App\Presenters\Admin\IssueArticlePresenter';
protected $presenterAdmin = 'App\Presenters\Admin\IssueArticlePresenter';

protected $fillable = [
'published',
Expand All @@ -29,7 +29,7 @@ class JournalArticle extends Model implements Sortable
'review_status',
'license_text',
'publish_start_date',
'journal_issue_id',
'issue_id',
'position',
];

Expand Down Expand Up @@ -68,7 +68,7 @@ class JournalArticle extends Model implements Sortable

public function issue()
{
return $this->belongsTo('App\Models\JournalIssue');
return $this->belongsTo('App\Models\Issue');
}

// Generates the id-slug type of URL
Expand All @@ -79,6 +79,6 @@ public function getRouteKeyName()

public function getIssueSlugAttribute()
{
return join([$this->issue()->issue_number ?? '', $this->issue()->getSlug(), $this->id, $this->getSlug()], '/');
return join([$this->issue->issue_number ?? '', $this->issue->getSlug(), $this->id, $this->getSlug()], '/');
}
}
10 changes: 10 additions & 0 deletions app/Models/Revisions/IssueArticleRevision.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Models\Revisions;

use A17\Twill\Models\Revision;

class IssueArticleRevision extends Revision
{
protected $table = "issue_article_revisions";
}
10 changes: 10 additions & 0 deletions app/Models/Revisions/IssueRevision.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Models\Revisions;

use A17\Twill\Models\Revision;

class IssueRevision extends Revision
{
protected $table = "issue_revisions";
}
10 changes: 0 additions & 10 deletions app/Models/Revisions/JournalArticleRevision.php

This file was deleted.

10 changes: 0 additions & 10 deletions app/Models/Revisions/JournalIssueRevision.php

This file was deleted.

Loading

0 comments on commit c07ec18

Please sign in to comment.