Skip to content

Commit ca19a09

Browse files
committed
TASK: Add backend module
1 parent 4017273 commit ca19a09

File tree

13 files changed

+323
-1
lines changed

13 files changed

+323
-1
lines changed

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[*]
2+
charset = utf-8
3+
end_of_line = lf
4+
insert_final_newline = true
5+
trim_trailing_whitespace = true
6+
indent_style = space
7+
indent_size = 4
8+
9+
[*.tsx]
10+
indent_size = 4
11+
12+
[*.{yml,yaml,json}]
13+
indent_size = 2
14+
15+
[*.md]
16+
indent_size = 2
17+
trim_trailing_whitespace = false
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CodeQ\LinkChecker\Controller;
6+
7+
use Neos\Flow\Annotations as Flow;
8+
use Neos\Fusion\View\FusionView;
9+
use Neos\Neos\Controller\Module\AbstractModuleController;
10+
11+
/**
12+
* @Flow\Scope("singleton")
13+
*/
14+
class ModuleController extends AbstractModuleController
15+
{
16+
/**
17+
* @var FusionView
18+
*/
19+
protected $view;
20+
21+
/**
22+
* @var string
23+
*/
24+
protected $defaultViewObjectName = FusionView::class;
25+
26+
public function indexAction(): void
27+
{
28+
$links = [
29+
[
30+
'uuid' => '332c1ba3-d97b-407c-9e21-32a178d6d2e6',
31+
'domain' => 'meine-neos-webseite.at',
32+
'source' => '/unterseite',
33+
'target' => 'https://invalid-url.com/',
34+
'error' => 'Not found (404)',
35+
'foundAt' => new \DateTimeImmutable('07-06-2022 14:35'),
36+
],
37+
[
38+
'uuid' => '332c1ba3-d97b-407c-9e21-32a178d6d2e7',
39+
'domain' => 'meine-neos-webseite.at',
40+
'source' => '/unterseite',
41+
'target' => 'https://broken-url.com/',
42+
'error' => 'Internal Server Error (500)',
43+
'foundAt' => new \DateTimeImmutable('08-06-2022 15:11'),
44+
],
45+
];
46+
47+
$flashMessages = $this->controllerContext->getFlashMessageContainer()->getMessagesAndFlush();
48+
49+
$this->view->assignMultiple([
50+
'links' => $links,
51+
'flashMessages' => $flashMessages,
52+
]);
53+
}
54+
55+
public function runAction(): void
56+
{
57+
$this->addFlashMessage('Hello from run action!');
58+
$this->redirect('index');
59+
}
60+
61+
public function markAsDoneAction(): void
62+
{
63+
$this->addFlashMessage('Hello from markAsDone action!');
64+
$this->redirect('index');
65+
}
66+
67+
public function ignoreAction(): void
68+
{
69+
$this->addFlashMessage('Hello from ignore action!');
70+
$this->redirect('index');
71+
}
72+
}

Configuration/Policy.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
privilegeTargets:
2+
'Neos\Flow\Security\Authorization\Privilege\Method\MethodPrivilege':
3+
'CodeQ.LinkChecker:Module':
4+
matcher: 'method(CodeQ\LinkChecker\Controller\ModuleController->(index|run)Action())'
5+
6+
'Neos\Neos\Security\Authorization\Privilege\ModulePrivilege':
7+
'CodeQ.LinkChecker:Backend.Module.Management.LinkChecker':
8+
matcher: 'management/link-checker'
9+
10+
roles:
11+
'Neos.Neos:Administrator':
12+
privileges:
13+
- privilegeTarget: 'CodeQ.LinkChecker:Backend.Module.Management.LinkChecker'
14+
permission: GRANT
15+
- privilegeTarget: 'CodeQ.LinkChecker:Module'
16+
permission: GRANT
17+
18+
'Neos.Neos:AbstractEditor':
19+
privileges:
20+
-
21+
privilegeTarget: 'CodeQ.LinkChecker:Module'
22+
permission: GRANT

Configuration/Settings.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
Neos:
22
Neos:
3+
userInterface:
4+
translation:
5+
autoInclude:
6+
'CodeQ.LinkChecker': ['Modules']
7+
modules:
8+
management:
9+
submodules:
10+
link-checker:
11+
label: 'CodeQ.LinkChecker:Modules:module.label'
12+
description: 'CodeQ.LinkChecker:Modules:module.description'
13+
icon: 'fas fa-link'
14+
controller: '\CodeQ\LinkChecker\Controller\ModuleController'
15+
resource: 'CodeQ.LinkChecker:Backend.Module'
16+
privilegeTarget: 'CodeQ.LinkChecker:Module'
17+
additionalResources:
18+
styleSheets:
19+
- 'resource://CodeQ.LinkChecker/Public/Styles/link-checker.css'
320
fusion:
421
autoInclude:
522
CodeQ.LinkChecker: true

Configuration/Views.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-
2+
requestFilter: 'isPackage("CodeQ.LinkChecker") && isController("Module") && isFormat("html")'
3+
viewObjectName: 'Neos\Fusion\View\FusionView'
4+
options:
5+
fusionPathPatterns:
6+
- 'resource://Neos.Fusion/Private/Fusion'
7+
- 'resource://CodeQ.LinkChecker/Private/FusionModule'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
prototype(CodeQ.LinkChecker:Component.FlashMessages) < prototype(Neos.Fusion:Component) {
2+
flashMessages = ${[]}
3+
4+
renderer = afx`
5+
<div class="neos-module-container">
6+
<div id="neos-notifications-inline" @if.hasMessages={props.flashMessages}>
7+
<Neos.Fusion:Loop items={props.flashMessages} itemName="message">
8+
<CodeQ.LinkChecker:Component.FlashMessages.Message message={message}/>
9+
</Neos.Fusion:Loop>
10+
</div>
11+
</div>
12+
`
13+
}
14+
15+
prototype(CodeQ.LinkChecker:Component.FlashMessages.Message) < prototype(Neos.Fusion:Component) {
16+
message = ${{}}
17+
18+
severity = ${String.toLowerCase(this.message.severity)}
19+
20+
renderer = afx`
21+
<li data-type={props.severity}>
22+
{props.message.message}
23+
</li>
24+
`
25+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
prototype(CodeQ.LinkChecker:Component.Links.List) < prototype(Neos.Fusion:Component) {
2+
links = '[]'
3+
4+
renderer = afx`
5+
<table class="neos-table codeq-link-checker-table">
6+
<thead>
7+
<tr>
8+
<th>{I18n.translate('CodeQ.LinkChecker:Modules:domain')}</th>
9+
<th>
10+
{I18n.translate('CodeQ.LinkChecker:Modules:source')} <i class="fas fa-sort-amount-down"></i>
11+
</th>
12+
<th>{I18n.translate('CodeQ.LinkChecker:Modules:targetUriPath')}</th>
13+
<th>{I18n.translate('CodeQ.LinkChecker:Modules:error')}</th>
14+
<th>{I18n.translate('CodeQ.LinkChecker:Modules:foundAt')}</th>
15+
<th></th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
<Neos.Fusion:Loop items={props.links} itemName="link">
20+
<CodeQ.LinkChecker:Component.Links.List.Link link={link}/>
21+
</Neos.Fusion:Loop>
22+
</tbody>
23+
</table>
24+
`
25+
}
26+
27+
prototype(CodeQ.LinkChecker:Component.Links.List.Link) < prototype(Neos.Fusion:Component) {
28+
link = '{}'
29+
30+
markAsDoneAction = Neos.Fusion:UriBuilder {
31+
action = 'markAsDone'
32+
}
33+
ignoreAction = Neos.Fusion:UriBuilder {
34+
action = 'ignore'
35+
}
36+
37+
renderer = afx`
38+
<tr>
39+
<td>{link.domain}</td>
40+
<td>
41+
{link.source}
42+
<a href="#" target="_blank" class="neos-button neos-button--small">
43+
<i class="fas fa-edit"></i>
44+
</a>
45+
<a href={link.source} target="_blank" class="neos-button neos-button--small">
46+
<i class="fas fa-external-link-alt"></i>
47+
</a>
48+
</td>
49+
<td>
50+
<a href={link.target} target="_blank" class="neos-button target-page-button">{link.target} <i class="fas fa-external-link-alt"></i></a>
51+
</td>
52+
<td>{link.error}</td>
53+
<td>{Date.format(link.foundAt, 'd.m.Y H:i')}</td>
54+
<td class="neos-action">
55+
<div class="neos-pull-right">
56+
<a class="neos-button"
57+
href={props.markAsDoneAction}
58+
title={I18n.translate('CodeQ.LinkChecker:Modules:list.action.markAsDone')}
59+
>
60+
<i class="fas fa-check"></i>
61+
</a>
62+
<a class="neos-button"
63+
href={props.ignoreAction}
64+
title={I18n.translate('CodeQ.LinkChecker:Modules:list.action.ignore')}
65+
>
66+
<i class="fas fa-eye-slash"></i>
67+
</a>
68+
</div>
69+
</td>
70+
</tr>
71+
`
72+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CodeQ.LinkChecker.ModuleController {
2+
index = afx`
3+
<CodeQ.LinkChecker:Component.FlashMessages flashMessages={flashMessages}/>
4+
<CodeQ.LinkChecker:Module.Index links={links}/>
5+
`
6+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include: resource://Neos.Fusion/Private/Fusion/Root.fusion
2+
include: resource://CodeQ.LinkChecker/Private/FusionModule/**/*.fusion
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
prototype(CodeQ.LinkChecker:Module.Index) < prototype(Neos.Fusion:Component) {
2+
links = '[]'
3+
4+
runAction = Neos.Fusion:UriBuilder {
5+
action = 'run'
6+
}
7+
8+
renderer = afx`
9+
<div class="neos-content neos-container-fluid">
10+
<div class="neos-row-fluid">
11+
<CodeQ.LinkChecker:Component.Links.List links={props.links}/>
12+
</div>
13+
<div class="neos-footer">
14+
<a class="neos-button neos-button-primary" href={props.runAction}>
15+
{I18n.translate('CodeQ.LinkChecker:Modules:action.run')}
16+
</a>
17+
</div>
18+
</div>
19+
`
20+
}

0 commit comments

Comments
 (0)