Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
2be2d28
Add homepage
thewilkybarkid Mar 19, 2019
2350dfc
Not there anymore
thewilkybarkid Mar 19, 2019
75b044d
Update existing tests
thewilkybarkid Mar 19, 2019
ab67c94
Use specific exception
thewilkybarkid Mar 19, 2019
17a3b37
Merge branch 'master' into homepage
thewilkybarkid Mar 22, 2019
2a92d14
Merge fixes
thewilkybarkid Mar 22, 2019
ace03ab
Set HTML title using translations
thewilkybarkid Mar 22, 2019
3f35854
Add homepage to integration tests
thewilkybarkid Mar 22, 2019
087a021
Fix and test title
thewilkybarkid Mar 22, 2019
24045d5
Merge branch 'master' into homepage
thewilkybarkid Mar 28, 2019
7222c0c
Extract PageEvent
thewilkybarkid Mar 28, 2019
4ebe45f
Merge branch 'master' into homepage
thewilkybarkid Mar 28, 2019
9b8a204
Missed some cases
thewilkybarkid Mar 28, 2019
572d5c3
Merge branch 'master' into homepage
thewilkybarkid Mar 28, 2019
737ff95
Return type
thewilkybarkid Mar 29, 2019
9880898
Tweak configuration
thewilkybarkid Mar 29, 2019
1bc13dc
Improve name
thewilkybarkid Mar 29, 2019
f125fbb
Changes
thewilkybarkid Mar 29, 2019
9c244af
Merge branch 'master' into homepage-lazy
thewilkybarkid Mar 29, 2019
06b0ce8
Merge branch 'master' of github.com:libero/browser into thewilkybarki…
nlisgo Apr 2, 2019
e658709
Introduce pattern library teaser templates
nlisgo Apr 2, 2019
ee06b3f
Introduce teaser pattern
nlisgo Apr 2, 2019
95516a4
Note to set route to content
nlisgo Apr 2, 2019
d8a1bb2
Adjust arguments handled
nlisgo Apr 2, 2019
84a4228
Use teaser-list template
nlisgo Apr 3, 2019
029a201
cs
nlisgo Apr 3, 2019
91d628b
Update vendor-extra/LiberoPageBundle/src/EventListener/BuildView/Item…
thewilkybarkid Apr 3, 2019
137582f
Add in paths
thewilkybarkid Apr 3, 2019
d65a080
Merge branch 'master' into homepage-lazy—teaser
thewilkybarkid Apr 3, 2019
abba688
Make canHandleTemplate parameter optional
nlisgo Apr 4, 2019
ef374e7
Get teaser list working
nlisgo Apr 4, 2019
8844a0e
Merge branch 'homepage-lazy—teaser-new' of github.com:nlisgo/libero-b…
nlisgo Apr 4, 2019
8bbaabc
Re-introduce lazy view
nlisgo Apr 5, 2019
1a0c5fa
cs
nlisgo Apr 5, 2019
b67c520
cs
nlisgo Apr 5, 2019
2666132
Pass only front for teaser listeners in JatsContentBundle
nlisgo Apr 5, 2019
942b30e
Add tests for FrontArticleTitleTeaserListener
nlisgo Apr 5, 2019
57280e9
Add tests for ItemTeaserListener
nlisgo Apr 5, 2019
b8bb328
Merge branch 'master' into homepage-lazy—teaser
thewilkybarkid Apr 8, 2019
6fa6615
Update homepage test and support Libero content
thewilkybarkid Apr 8, 2019
abd30d3
Fix list and add test
thewilkybarkid Apr 8, 2019
922cf53
Add tests
thewilkybarkid Apr 9, 2019
30d382d
Update config
thewilkybarkid Apr 9, 2019
f3b6e6c
Tidy
thewilkybarkid Apr 9, 2019
7c2310e
Not needed here
thewilkybarkid Apr 9, 2019
0cdb625
Add title
thewilkybarkid Apr 9, 2019
b7ee7af
Merge branch 'master' into homepage-lazy—teaser
thewilkybarkid Apr 9, 2019
5868bdb
Set levels
thewilkybarkid Apr 9, 2019
39edf12
Put in grid and fix levels
thewilkybarkid Apr 9, 2019
61e5820
Set empty text
thewilkybarkid Apr 9, 2019
10177c5
Update
thewilkybarkid Apr 9, 2019
3bb1391
Update
thewilkybarkid Apr 9, 2019
56ec635
Fix terminology
thewilkybarkid Apr 9, 2019
c3d74a4
Simplify
thewilkybarkid Apr 9, 2019
63f41a0
Split into three
thewilkybarkid Apr 9, 2019
9605f3e
Missing assertion
thewilkybarkid Apr 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ To run an image reading from two content services (`blog-articles` and `scholarl
pages:
homepage:
path: '/'
primary_listing: 'scholarly-articles/items'
content:
blog-articles:
path: '/blog/{id}'
Expand Down
1 change: 1 addition & 0 deletions config/packages/dev/libero_page.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ libero_page:
pages:
homepage:
path: '/'
primary_listing: 'scholarly-articles/items'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems flexible enough to allow the different services, does it need additions to sample-configuration then?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

->scalarNode('primary_listing')
->isRequired()
->end()
Is required, but can point at either content or search API (anything that returns a libero:item-list).

content:
blog-articles:
path: '/blog/{id}'
Expand Down
1 change: 1 addition & 0 deletions config/packages/test/libero_page.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ libero_page:
pages:
homepage:
path: '/'
primary_listing: 'search'
content:
blog-articles:
path: '/blog/{id}'
Expand Down
54 changes: 52 additions & 2 deletions tests/WebTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,56 @@ public function it_has_a_homepage() : void
{
$client = static::createClient();

self::mockApiResponse(
new Request(
'GET',
'http://localhost/search',
['Accept' => 'application/xml']
),
new Response(
200,
[],
<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<item-list xmlns="http://libero.pub">
<item-ref id="article1" service="scholarly-articles"/>
</item-list>
XML
)
);

self::mockApiResponse(
new Request(
'GET',
'http://localhost/scholarly-articles/items/article1/versions/latest',
['Accept' => 'application/xml']
),
new Response(
200,
[],
<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<item xmlns="http://libero.pub">
<meta>
<id>article1</id>
<service>scholarly-articles</service>
</meta>
<front xml:lang="en">
<id>article1</id>
<title>Scholarly article 1</title>
</front>
</item>
XML
)
);

$crawler = $client->request('GET', '/');
$response = $client->getResponse();

$this->assertSame(200, $response->getStatusCode());
$this->assertSame('text/html; charset=UTF-8', $response->headers->get('Content-Type'));
$this->assertSame('Site Name', trim($crawler->filter('.content-header__title')->text()));
$this->assertSame('Scholarly article 1', trim($crawler->filter('.teaser__heading')->text()));
}

/**
Expand All @@ -45,8 +89,11 @@ public function it_shows_scholarly_articles(string $id) : void
<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<item xmlns="http://libero.pub">
<front xml:lang="en">
<meta>
<id>{$id}</id>
<service>scholarly-articles</service>
</meta>
<front xml:lang="en">
<title>Scholarly article {$id}</title>
</front>
</item>
Expand Down Expand Up @@ -82,8 +129,11 @@ public function it_shows_blog_articles(string $id) : void
<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<item xmlns="http://libero.pub">
<meta>
<id>{$id}</id>
<service>scholarly-articles</service>
</meta>
<front xml:lang="en">
<id>${id}</id>
<title>Blog article ${id}</title>
</front>
</item>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);

namespace Libero\JatsContentBundle\EventListener\BuildView;

use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Views\SimplifiedViewConverterListener;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\ViewConverter;
use function Libero\ViewsBundle\array_has_key;

final class FrontArticleTitleTeaserListener
{
use SimplifiedViewConverterListener;

private $converter;

public function __construct(ViewConverter $converter)
{
$this->converter = $converter;
}

protected function handle(Element $object, TemplateView $view) : View
{
$heading = $object->ownerDocument->xpath()
->firstOf(
'jats:article-meta/jats:title-group/jats:article-title',
$object
);

if (!$heading instanceof Element) {
return $view;
}

return $view
->withArgument(
'heading',
$this->converter
->convert($heading, '@LiberoPatterns/heading.html.twig', $view->getContext())
->getArguments()
);
}

protected function canHandleTemplate(?string $template) : bool
{
return '@LiberoPatterns/teaser.html.twig' === $template;
}

protected function canHandleElement(string $element) : bool
{
return '{http://jats.nlm.nih.gov}front' === $element;
}

protected function canHandleArguments(array $arguments) : bool
{
return !array_has_key($arguments, 'heading');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

declare(strict_types=1);

namespace Libero\JatsContentBundle\EventListener\BuildView;

use FluentDOM\DOM\Element;
use Libero\ViewsBundle\Event\BuildViewEvent;
use Libero\ViewsBundle\Views\TemplateView;
use Libero\ViewsBundle\Views\View;
use Libero\ViewsBundle\Views\ViewConverter;
use function sprintf;

final class ItemTeaserListener
{
private $converter;

public function __construct(ViewConverter $converter)
{
$this->converter = $converter;
}

public function onBuildView(BuildViewEvent $event) : void
{
$object = $event->getObject();
$view = $event->getView();

if (!$view instanceof TemplateView || !$this->canHandleTemplate($view->getTemplate())) {
return;
}

if (!$this->canHandleElement(sprintf('{%s}%s', $object->namespaceURI, $object->localName))) {
return;
}

$handled = $this->handle($object, $view);

if (!$handled instanceof View) {
return;
}

$event->setView($handled);

$event->stopPropagation();
}

protected function handle(Element $object, TemplateView $view) : ?View
{
$front = $object->ownerDocument->xpath()
->firstOf(
'/libero:item/jats:article/jats:front',
$object
);

if (!$front instanceof Element) {
return null;
}

return $this->converter->convert($front, $view->getTemplate(), $view->getContext());
}

protected function canHandleTemplate(?string $template) : bool
{
return '@LiberoPatterns/teaser.html.twig' === $template;
}

protected function canHandleElement(string $element) : bool
{
return '{http://libero.pub}item' === $element;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@
<tag name="kernel.event_listener" event="libero.view.build" method="onBuildView"/>
</service>

<service id="Libero\JatsContentBundle\EventListener\BuildView\ItemTeaserListener"
class="Libero\JatsContentBundle\EventListener\BuildView\ItemTeaserListener">
<argument type="service" id="Libero\ViewsBundle\Views\ViewConverter"/>
<tag name="kernel.event_listener" event="libero.view.build" method="onBuildView" priority="50"/>
</service>

<service id="Libero\JatsContentBundle\EventListener\BuildView\FrontArticleTitleTeaserListener"
class="Libero\JatsContentBundle\EventListener\BuildView\FrontArticleTitleTeaserListener">
<argument type="service" id="Libero\ViewsBundle\Views\ViewConverter"/>
<tag name="kernel.event_listener" event="libero.view.build" method="onBuildView"/>
</service>

<service id="Libero\JatsContentBundle\EventListener\BuildView\SectionListener"
class="Libero\JatsContentBundle\EventListener\BuildView\SectionListener">
<argument type="service" id="Libero\ViewsBundle\Views\ViewConverter"/>
Expand Down
Loading