Skip to content

Commit

Permalink
Version 1.4.6: Optimize Print, add print button, fix text, update cyp…
Browse files Browse the repository at this point in the history
…ress tests
  • Loading branch information
trendschau committed Jun 13, 2021
1 parent bc5c073 commit 7da5da9
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 95 deletions.
15 changes: 0 additions & 15 deletions content/01-cyanine-theme/00-footer.yaml

This file was deleted.

File renamed without changes.
13 changes: 0 additions & 13 deletions content/01-cyanine-theme/01-content-elements.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions content/01-cyanine-theme/02-colors-and-fonts.yaml

This file was deleted.

File renamed without changes.
13 changes: 0 additions & 13 deletions content/01-cyanine-theme/03-landingpage.yaml

This file was deleted.

21 changes: 20 additions & 1 deletion cypress/test01-system-setup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('Typemill Setup', function()
cy.get('.error').should('contain', 'Length between 5 - 20')
})

/*
it('fails without CSRF-token', function ()
{
cy.request({
Expand All @@ -45,8 +46,26 @@ describe('Typemill Setup', function()
}
})
.its('body')
.should('include', 'Failed CSRF check')
.should('include', 'The form has a timeout')
})
*/
it('fails without CSRF-token', function ()
{
cy.visit('/setup')

// enter correct data
cy.get('input[name="username"]').clear().type('trendschau')
cy.get('input[name="email"]').clear().type('[email protected]')
cy.get('input[name="password"]').clear().type('password')
cy.get('#csrf_value').then(elem => {
elem.val('wrongvalue');
});

// submit and get validation errors
cy.get('form').submit()
cy.get('#flash-message').should('contain', 'form has a timeout')
})


it('submits valid form data and visit welcome and settings page', function ()
{
Expand Down
21 changes: 11 additions & 10 deletions cypress/test02-initial-frontend.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ describe('Typemill Initial Frontend', function()

/* has start and setup button */
cy.get('nav').find('a').should(($a) => {
expect($a).to.have.length(10)
expect($a).to.have.length(11)
expect($a[0].href).to.match(/welcome/)
expect($a[1].href).to.match(/welcome\/setup/)
expect($a[2].href).to.match(/welcome\/write-content/)
expect($a[3].href).to.match(/welcome\/get-help/)
expect($a[4].href).to.match(/welcome\/markdown-test/)
expect($a[5].href).to.match(/cyanine-theme/)
expect($a[6].href).to.match(/cyanine-theme\/landingpage/)
expect($a[7].href).to.match(/cyanine-theme\/colors-and-fonts/)
expect($a[8].href).to.match(/cyanine-theme\/footer/)
expect($a[9].href).to.match(/cyanine-theme\/content-elements/)
expect($a[1].href).to.match(/welcome\/setup-your-website/)
expect($a[2].href).to.match(/welcome\/manage-access/)
expect($a[3].href).to.match(/welcome\/write-content/)
expect($a[4].href).to.match(/welcome\/get-help/)
expect($a[5].href).to.match(/welcome\/markdown-test/)
expect($a[6].href).to.match(/cyanine-theme/)
expect($a[7].href).to.match(/cyanine-theme\/landingpage/)
expect($a[8].href).to.match(/cyanine-theme\/colors-and-fonts/)
expect($a[9].href).to.match(/cyanine-theme\/footer/)
expect($a[10].href).to.match(/cyanine-theme\/content-elements/)
})
})

Expand Down
6 changes: 3 additions & 3 deletions cypress/test05-blox-editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ describe('Blox Editor', function()
cy.get('.navi-list')
.should('contain', 'Testpage')
.eq(2).find('a').should(($a) => {
expect($a).to.have.length(5)
expect($a[4].href).to.include('/welcome\/testpage')
expect($a).to.have.length(6)
expect($a[5].href).to.include('/welcome\/testpage')
})
})

Expand Down Expand Up @@ -277,7 +277,7 @@ describe('Blox Editor', function()
cy.get('.navi-list')
.not('contain', 'Testpage')
.eq(2).find('a').should(($a) => {
expect($a).to.have.length(4)
expect($a).to.have.length(5)
})
})
})
18 changes: 1 addition & 17 deletions cypress/test99-login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,6 @@ describe('Typemill Login', function()
cy.contains('Logout').click()
cy.url().should('include', '/tm/login')
})

it('fails without CSRF-token', function ()
{
cy.request({
method: 'POST',
url: '/tm/login', // baseUrl is prepended to url
form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers
failOnStatusCode: false,
body: {
username: 'trendschau',
password: 'password'
}
})
.its('body')
.should('include', 'Failed CSRF check')
})

it('blocks after 3 fails', function ()
{
Expand All @@ -82,6 +66,6 @@ describe('Typemill Login', function()
cy.get('form').submit()
cy.get('#flash-message').should('contain', 'Too many bad logins')
cy.contains('wait')
cy.contains('Forgot password')
cy.contains('forgot password')
})
})
4 changes: 2 additions & 2 deletions system/Controllers/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public function create($request, $response, $args)
{
if($request->isPost())
{
if( $request->getattribute('csrf_result') === false )
if( ( null !== $request->getattribute('csrf_result') ) OR ( $request->getattribute('csrf_result') === false ) )
{
$this->c->flash->addMessage('error', 'The form has a timeout, please try again.');
return $response->withRedirect($this->c->router->pathFor('setup.welcome'));
return $response->withRedirect($this->c->router->pathFor('setup.show'));
}

$params = $request->getParams();
Expand Down
49 changes: 49 additions & 0 deletions themes/cyanine/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -509,4 +509,53 @@ button.play-video::after {
font-size: inherit;
max-height: inherit;
}
}

@media print {
#contentnav, #bottompager{
display: none;
}
.grid-main{
margin-top: -10px!important;
padding-top: 0px!important;
}
.logo a[href]:after {
content: "Homepage: " attr(href);
display: block;
margin: 1rem 0;
font-size: 14px;
font-weight: normal;
}
body{
// padding: 3rem 3rem 3rem 5rem!important;
}
main{
padding-bottom: 0!important;
}
aside{
padding-top: 0!important;
padding-bottom: 0!important;
}
main,footer{
border: 0px!important;
}
footer .ph3
{
padding-top: 0;
padding-bottom: 0;
}
body, .landingpagecontrast, .account, main, footer, .landingpageintro, .landingpageinfo, .landingpageteaser, .landingpagenavi, .landingpagenews, button.expander, .notice4{
background: #fff!important;
color: black!important;
}
article a[href]{
color: black;
text-decoration: underline;
}
article a[href]:after {
content: " (" attr(href) ")";
}
nav .mw6{
width: 100%;
}
}
26 changes: 26 additions & 0 deletions themes/cyanine/cyanine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,32 @@ forms:
label: Text/label for edit link
placeholder: edit on github

editIcon:
type: checkbox
label: Icon
checkboxlabel: use an edit-icon instead of text

fieldsetPrint:
type: fieldset
legend: Print Button
fields:
printPosition:
type: checkboxlist
label: Position of the print-button (top/bottom)
options:
top: Top
bottom: Bottom

printText:
type: text
label: Text/label for print-button
placeholder: print

printIcon:
type: checkbox
label: Icon
checkboxlabel: use a print-icon instead of text

fieldsetNavigations:
type: fieldset
legend: Navigations and Chapters
Expand Down
7 changes: 7 additions & 0 deletions themes/cyanine/layout.twig
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@
<symbol id="icon-user" viewBox="0 0 20 28">
<path d="M20 21.859c0 2.281-1.5 4.141-3.328 4.141h-13.344c-1.828 0-3.328-1.859-3.328-4.141 0-4.109 1.016-8.859 5.109-8.859 1.266 1.234 2.984 2 4.891 2s3.625-0.766 4.891-2c4.094 0 5.109 4.75 5.109 8.859zM16 8c0 3.313-2.688 6-6 6s-6-2.688-6-6 2.688-6 6-6 6 2.688 6 6z"></path>
</symbol>
<symbol id="icon-pencil" viewBox="0 0 32 32">
<path d="M27 0c2.761 0 5 2.239 5 5 0 1.126-0.372 2.164-1 3l-2 2-7-7 2-2c0.836-0.628 1.874-1 3-1zM2 23l-2 9 9-2 18.5-18.5-7-7-18.5 18.5zM22.362 11.362l-14 14-1.724-1.724 14-14 1.724 1.724z"></path>
</symbol>
<symbol id="icon-printer" viewBox="0 0 32 32">
<path d="M8 2h16v4h-16v-4z"></path>
<path d="M30 8h-28c-1.1 0-2 0.9-2 2v10c0 1.1 0.9 2 2 2h6v8h16v-8h6c1.1 0 2-0.9 2-2v-10c0-1.1-0.9-2-2-2zM4 14c-1.105 0-2-0.895-2-2s0.895-2 2-2 2 0.895 2 2-0.895 2-2 2zM22 28h-12v-10h12v10z"></path>
</symbol>
</defs>
</svg>
<div class="account fixed pb2 top-0 right-0 left-0">
Expand Down
22 changes: 14 additions & 8 deletions themes/cyanine/page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<div class="grid-main ph3 ph4-l pv3 lh-copy f4 fw3">

<nav>
<nav id="breadcrumb">
{% include 'partials/breadcrumb.twig' %}
</nav>

Expand All @@ -43,7 +43,7 @@

<h1>{{ title }}</h1>

{% if (settings.themes.cyanine.datePosition.top or settings.themes.cyanine.authorPosition.top or settings.themes.cyanine.gitPosition.top) %}
{% if (settings.themes.cyanine.datePosition.top or settings.themes.cyanine.authorPosition.top or settings.themes.cyanine.gitPosition.top or settings.themes.cyanine.printPosition.top) %}
<div class="f5 pv1 flex justify-between">
<div class="byline">
{% if settings.themes.cyanine.datePosition.top %}
Expand All @@ -54,15 +54,18 @@
{% endif %}
</div>
{% if settings.themes.cyanine.gitPosition.top %}
<a class="link" title="edit on github" href="{{ settings.themes.cyanine.gitLink }}{{ item.path }}">{{ settings.themes.cyanine.editText }}</a>
<a class="link" title="edit on github" href="{{ settings.themes.cyanine.gitLink }}{{ item.path }}">{% if settings.themes.cyanine.editIcon %}<svg class="icon baseline icon-edit"><use xlink:href="#icon-edit"></use></svg>{% else %}{{ settings.themes.cyanine.editText }}{% endif %}</a>
{% endif %}
{% if settings.themes.cyanine.printPosition.top %}
<a class="link" title="open printer dialogue" href="#" onclick="if (window.print) {window.print();}">{% if settings.themes.cyanine.printIcon %}<svg class="icon baseline icon-printer"><use xlink:href="#icon-printer"></use></svg>{% else %}{{ settings.themes.cyanine.printText }}{% endif %}</a>
{% endif %}
</div>
{% endif %}
</header>

{{ content }}

{% if (settings.themes.cyanine.datePosition.bottom or settings.themes.cyanine.authorPosition.bottom or settings.themes.cyanine.gitPosition.bottom) %}
{% if (settings.themes.cyanine.datePosition.bottom or settings.themes.cyanine.authorPosition.bottom or settings.themes.cyanine.gitPosition.bottom or settings.themes.cyanine.printPosition.bottom) %}
<div class="f5 pv1 flex justify-between">
<div class="byline">
{% if settings.themes.cyanine.datePosition.bottom %}
Expand All @@ -72,9 +75,12 @@
<adress class="pr2">{{ settings.themes.cyanine.authorIntro }} {{ metatabs.meta.author|default(settings.author) }}</adress>
{% endif %}
</div>
{% if settings.themes.cyanine.gitPosition.bottom %}
<a class="link" title="edit on github" href="{{ settings.themes.cyanine.gitLink }}{{ item.path }}">{{ settings.themes.cyanine.editText }}</a>
{% endif %}
{% if settings.themes.cyanine.gitPosition.bottom %}
<a class="link" title="edit on github" href="{{ settings.themes.cyanine.gitLink }}{{ item.path }}">{% if settings.themes.cyanine.editIcon %}<svg class="icon baseline icon-edit"><use xlink:href="#icon-edit"></use></svg>{% else %}{{ settings.themes.cyanine.editText }}{% endif %}</a>
{% endif %}
{% if settings.themes.cyanine.printPosition.bottom %}
<a class="link" title="open printer dialogue" href="#" onclick="if (window.print) {window.print();}">{% if settings.themes.cyanine.printIcon %}<svg class="icon baseline icon-printer"><use xlink:href="#icon-printer"></use></svg>{% else %}{{ settings.themes.cyanine.printText }}{% endif %}</a>
{% endif %}
</div>
{% endif %}

Expand All @@ -84,7 +90,7 @@

{% if item.prevItem or item.nextItem %}

<div class="f5 pv5 flex justify-between {{ settings.themes.cyanine.fontnavi|default('tm-sans-serif') }}">
<div id="bottompager" class="f5 pv5 flex justify-between {{ settings.themes.cyanine.fontnavi|default('tm-sans-serif') }}">
{% if item.prevItem %}
<a class="navigation link pv2 ph3 ba dim" href="{{ item.prevItem.urlRel }}">&lsaquo;&nbsp; {{ item.prevItem.name }}</a>
{% endif %}
Expand Down

0 comments on commit 7da5da9

Please sign in to comment.