Skip to content
This repository was archived by the owner on Aug 17, 2025. It is now read-only.

Commit 49ecb47

Browse files
committed
Provide templates for all zend-expressive-template implementations
Provides working templates for all zend-expressive-template implementations, and documents them.
1 parent 37c1ba2 commit 49ecb47

File tree

5 files changed

+202
-2
lines changed

5 files changed

+202
-2
lines changed

docs/book/templates.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Login Templates
2+
3+
This package ships with a number of built-in templates for displaying the
4+
"login" page when a user is unauthorized; these are in the `templates/`
5+
subdirectory, and map to the `oauth2clientauthentication::401` template.
6+
7+
The templates provided expose links for each of the GitHub, Google, and (when
8+
enabled) Debug providers. Further, they are written using [Bootstrap
9+
theming](http://getbootstrap.com). As such, you will likely want to override
10+
them.
11+
12+
Below, we demonstrate each of the default shipped versions.
13+
14+
## Plates
15+
16+
```php
17+
<?php $this->layout('layout::layout', [
18+
'title' => 'Unauthorized',
19+
]); ?>
20+
21+
<section class="col-md-8 col-md-offset-2 code_401">
22+
<h2>Unauthorized</h2>
23+
24+
<p>
25+
You are not logged in, and therefore cannot perform this action.
26+
</p>
27+
28+
<p>
29+
Login to continue:
30+
<p>
31+
32+
<div class="btn-group-vertical" role="group">
33+
<a class="btn btn-default" href="<?= $auth_path ?>/github?redirect=<?= $redirect ?>">GitHub</a>
34+
<a class="btn btn-default" href="<?= $auth_path ?>/google?redirect=<?= $redirect ?>">Google</a>
35+
<?php if ($debug) : ?>
36+
<a class="btn btn-default" href="<?= $auth_path ?>/debug?redirect=<?= $redirect ?>">Debug</a>
37+
<?php endif ?>
38+
</div>
39+
</section>
40+
```
41+
42+
## Twig
43+
44+
```twig
45+
{% extends '@layout/default.html.twig' %}
46+
47+
{% block title %}404 Not Found{% endblock %}
48+
49+
{% block content %}
50+
<section class="col-md-8 col-md-offset-2 code_401">
51+
<h2>Unauthorized</h2>
52+
53+
<p>
54+
You are not logged in, and therefore cannot perform this action.
55+
</p>
56+
57+
<p>
58+
Login to continue:
59+
<p>
60+
61+
<div class="btn-group-vertical" role="group">
62+
<a class="btn btn-default" href="{{ auth_path }}/github?redirect={{ redirect }}">GitHub</a>
63+
<a class="btn btn-default" href="{{ auth_path }}/google?redirect={{ redirect }}">Google</a>
64+
{% if debug is defined %}
65+
<a class="btn btn-default" href="{{ auth_path }}/debug?redirect={{ redirect }}">Debug</a>
66+
{% endif %}
67+
</div>
68+
</section>
69+
{% endblock %}
70+
```
71+
72+
## zend-view
73+
74+
```php
75+
<?php $this->headTitle('Unauthorized') ?>
76+
77+
<section class="col-md-8 col-md-offset-2 code_401">
78+
<h2>Unauthorized</h2>
79+
80+
<p>
81+
You are not logged in, and therefore cannot perform this action.
82+
</p>
83+
84+
<p>
85+
Login to continue:
86+
<p>
87+
88+
<div class="btn-group-vertical" role="group">
89+
<a class="btn btn-default" href="<?= $this->auth_path ?>/github?redirect=<?= $this->redirect ?>">GitHub</a>
90+
<a class="btn btn-default" href="<?= $this->auth_path ?>/google?redirect=<?= $this->redirect ?>">Google</a>
91+
<?php if ($debug) : ?>
92+
<a class="btn btn-default" href="<?= $this->auth_path ?>/debug?redirect=<?= $this->redirect ?>">Debug</a>
93+
<?php endif ?>
94+
</div>
95+
</section>
96+
```
97+
98+
## Mustache
99+
100+
This example can be used via the
101+
[phly-expressive-mustache](https://github.com/phly/phly-expressive-mustache)
102+
renderer for zend-expressive-template:
103+
104+
```mustache
105+
{{<layout::layout}}
106+
{{$title}}Unauthorized{{/title}}
107+
{{$content}}
108+
<section class="col-md-8 col-md-offset-2 code_401">
109+
<h2>Unauthorized</h2>
110+
111+
<p>
112+
You are not logged in, and therefore cannot perform this action.
113+
</p>
114+
115+
<p>
116+
Login to continue:
117+
<p>
118+
119+
<div class="btn-group-vertical" role="group">
120+
<a class="btn btn-default" href="{{auth_path}}/github?redirect={{redirect}}">GitHub</a>
121+
<a class="btn btn-default" href="{{auth_path}}/google?redirect={{redirect}}">Google</a>
122+
{{#debug}}
123+
<a class="btn btn-default" href="{{auth_path}}/debug?redirect={{redirect}}">Debug</a>
124+
{{/debug}}
125+
</div>
126+
</section>
127+
{{/content}}
128+
{{/layout::layout}}
129+
```

mkdocs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ site_dir: docs/html
33
pages:
44
- index.md
55
- Introduction: intro.md
6-
- Configuration: config.md
7-
- "Debug Provider": debug.md
6+
- Reference:
7+
- Configuration: config.md
8+
- "Debug Provider": debug.md
9+
- Templates: templates.md
810
site_name: 'phly'
911
site_description: 'league/oauth2-client adapter for zend-expressive-authentication'
1012
repo_url: 'https://github.com/phly/phly-expressive-oauth2clientauthentication'

templates/401.html.twig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{% extends '@layout/default.html.twig' %}
2+
3+
{% block title %}404 Not Found{% endblock %}
4+
5+
{% block content %}
6+
<section class="col-md-8 col-md-offset-2 code_401">
7+
<h2>Unauthorized</h2>
8+
9+
<p>
10+
You are not logged in, and therefore cannot perform this action.
11+
</p>
12+
13+
<p>
14+
Login to continue:
15+
<p>
16+
17+
<div class="btn-group-vertical" role="group">
18+
<a class="btn btn-default" href="{{ auth_path }}/github?redirect={{ redirect }}">GitHub</a>
19+
<a class="btn btn-default" href="{{ auth_path }}/google?redirect={{ redirect }}">Google</a>
20+
{% if debug is defined %}
21+
<a class="btn btn-default" href="{{ auth_path }}/debug?redirect={{ redirect }}">Debug</a>
22+
{% endif %}
23+
</div>
24+
</section>
25+
{% endblock %}

templates/401.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php $this->layout('layout::layout', [
2+
'title' => 'Unauthorized',
3+
]); ?>
4+
5+
<section class="col-md-8 col-md-offset-2 code_401">
6+
<h2>Unauthorized</h2>
7+
8+
<p>
9+
You are not logged in, and therefore cannot perform this action.
10+
</p>
11+
12+
<p>
13+
Login to continue:
14+
<p>
15+
16+
<div class="btn-group-vertical" role="group">
17+
<a class="btn btn-default" href="<?= $auth_path ?>/github?redirect=<?= $redirect ?>">GitHub</a>
18+
<a class="btn btn-default" href="<?= $auth_path ?>/google?redirect=<?= $redirect ?>">Google</a>
19+
<?php if ($debug) : ?>
20+
<a class="btn btn-default" href="<?= $auth_path ?>/debug?redirect=<?= $redirect ?>">Debug</a>
21+
<?php endif ?>
22+
</div>
23+
</section>

templates/401.phtml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php $this->headTitle('Unauthorized') ?>
2+
3+
<section class="col-md-8 col-md-offset-2 code_401">
4+
<h2>Unauthorized</h2>
5+
6+
<p>
7+
You are not logged in, and therefore cannot perform this action.
8+
</p>
9+
10+
<p>
11+
Login to continue:
12+
<p>
13+
14+
<div class="btn-group-vertical" role="group">
15+
<a class="btn btn-default" href="<?= $this->auth_path ?>/github?redirect=<?= $this->redirect ?>">GitHub</a>
16+
<a class="btn btn-default" href="<?= $this->auth_path ?>/google?redirect=<?= $this->redirect ?>">Google</a>
17+
<?php if ($debug) : ?>
18+
<a class="btn btn-default" href="<?= $this->auth_path ?>/debug?redirect=<?= $this->redirect ?>">Debug</a>
19+
<?php endif ?>
20+
</div>
21+
</section>

0 commit comments

Comments
 (0)