From baf45acac1c9c0d35b4a7c8b4a1dc00218da6d96 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 10 Dec 2017 15:44:14 +0100 Subject: [PATCH] theme: test page rendering. --- doc/pelican/theme-test.rst | 48 ----------- doc/static/dummy.css | 1 - pelican-theme/test/__init__.py | 12 +++ pelican-theme/test/page/page.html | 42 +++++++++ pelican-theme/test/page/page.rst | 7 ++ pelican-theme/test/page_breadcrumb/page.html | 41 +++++++++ pelican-theme/test/page_breadcrumb/page.rst | 5 ++ .../test/page_breadcrumb/subpage.html | 42 +++++++++ .../test/page_breadcrumb/subpage.rst | 6 ++ pelican-theme/test/page_extra_css/page.html | 38 +++++++++ pelican-theme/test/page_extra_css/page.rst | 5 ++ .../test/page_header_footer/page.html | 60 +++++++++++++ .../test/page_header_footer/page.rst | 8 ++ .../test/page_landing/hide-navbar-brand.html | 54 ++++++++++++ .../test/page_landing/hide-navbar-brand.rst | 13 +++ pelican-theme/test/page_landing/page.html | 64 ++++++++++++++ pelican-theme/test/page_landing/page.rst | 18 ++++ pelican-theme/test/page_landing/ship.jpg | 1 + pelican-theme/test/page_minimal/page.html | 36 ++++++++ pelican-theme/test/page_minimal/page.rst | 2 + .../test/page_title_sitename_alias/page.html | 36 ++++++++ .../test/page_title_sitename_alias/page.rst | 2 + pelican-theme/test/test_page.py | 85 +++++++++++++++++++ 23 files changed, 577 insertions(+), 49 deletions(-) delete mode 100644 doc/pelican/theme-test.rst delete mode 100644 doc/static/dummy.css create mode 100644 pelican-theme/test/page/page.html create mode 100644 pelican-theme/test/page/page.rst create mode 100644 pelican-theme/test/page_breadcrumb/page.html create mode 100644 pelican-theme/test/page_breadcrumb/page.rst create mode 100644 pelican-theme/test/page_breadcrumb/subpage.html create mode 100644 pelican-theme/test/page_breadcrumb/subpage.rst create mode 100644 pelican-theme/test/page_extra_css/page.html create mode 100644 pelican-theme/test/page_extra_css/page.rst create mode 100644 pelican-theme/test/page_header_footer/page.html create mode 100644 pelican-theme/test/page_header_footer/page.rst create mode 100644 pelican-theme/test/page_landing/hide-navbar-brand.html create mode 100644 pelican-theme/test/page_landing/hide-navbar-brand.rst create mode 100644 pelican-theme/test/page_landing/page.html create mode 100644 pelican-theme/test/page_landing/page.rst create mode 120000 pelican-theme/test/page_landing/ship.jpg create mode 100644 pelican-theme/test/page_minimal/page.html create mode 100644 pelican-theme/test/page_minimal/page.rst create mode 100644 pelican-theme/test/page_title_sitename_alias/page.html create mode 100644 pelican-theme/test/page_title_sitename_alias/page.rst create mode 100644 pelican-theme/test/test_page.py diff --git a/doc/pelican/theme-test.rst b/doc/pelican/theme-test.rst deleted file mode 100644 index 7a887819..00000000 --- a/doc/pelican/theme-test.rst +++ /dev/null @@ -1,48 +0,0 @@ -.. - This file is part of m.css. - - Copyright © 2017 Vladimír Vondruš - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. -.. - -Test -#### - -:save_as: pelican/theme/test/index.html -:breadcrumb: {filename}/pelican.rst Pelican - {filename}/pelican/theme.rst Theme -:css: {filename}/static/dummy.css - {filename}/static/dummy.css -:summary: um -:highlight: pelican/theme -:header: - .. note-warning:: - - This is a page header with an `internal link <{filename}/pelican.rst>`_. - This shouldn't be wrapped in a ``

``. -:footer: - .. note-danger:: - - This is a page footer with an `internal link <{filename}/pelican.rst>`_. - This shouldn't be wrapped in a ``

``. - -This page should have a breadcrumb, summary in a meta tag, header and a footer -and also two additional links to ``/static/dummy.css``. It should also -highlight the Pelican Theme menu item in the top navbar. diff --git a/doc/static/dummy.css b/doc/static/dummy.css deleted file mode 100644 index 8b137891..00000000 --- a/doc/static/dummy.css +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pelican-theme/test/__init__.py b/pelican-theme/test/__init__.py index 80f8d95d..7264c1ce 100644 --- a/pelican-theme/test/__init__.py +++ b/pelican-theme/test/__init__.py @@ -59,6 +59,18 @@ class BaseTestCase(MinimalTestCase): } MinimalTestCase.run_pelican(self, {**implicit_settings, **settings}) +class PageTestCase(BaseTestCase): + def run_pelican(self, settings): + implicit_settings = { + 'M_FINE_PRINT': None, + 'PAGE_PATHS': ['.'], + 'PAGE_SAVE_AS': '{slug}.html', + 'PAGE_URL': '{slug}.html', + 'ARTICLE_PATHS': ['articles'], # doesn't exist + 'DIRECT_TEMPLATES': [] + } + BaseTestCase.run_pelican(self, {**implicit_settings, **settings}) + class BlogTestCase(BaseTestCase): def run_pelican(self, settings): implicit_settings = { diff --git a/pelican-theme/test/page/page.html b/pelican-theme/test/page/page.html new file mode 100644 index 00000000..a98294e6 --- /dev/null +++ b/pelican-theme/test/page/page.html @@ -0,0 +1,42 @@ + + + + + A page | A Pelican Blog + + + + + + + + + + + + + + +

+
+
+
+
+
+

A page

+ +

Page content for those who actually read.

+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/pelican-theme/test/page/page.rst b/pelican-theme/test/page/page.rst new file mode 100644 index 00000000..07c0f6c9 --- /dev/null +++ b/pelican-theme/test/page/page.rst @@ -0,0 +1,7 @@ +A page +###### + +:description: Page description for the fake SEO believers. +:summary: Page description for the social people. + +Page content for those who actually read. diff --git a/pelican-theme/test/page_breadcrumb/page.html b/pelican-theme/test/page_breadcrumb/page.html new file mode 100644 index 00000000..7ce0eeb4 --- /dev/null +++ b/pelican-theme/test/page_breadcrumb/page.html @@ -0,0 +1,41 @@ + + + + + Index page » A page | A Pelican Blog + + + + + + + + + + + +
+
+ +
+ + diff --git a/pelican-theme/test/page_breadcrumb/page.rst b/pelican-theme/test/page_breadcrumb/page.rst new file mode 100644 index 00000000..019f7927 --- /dev/null +++ b/pelican-theme/test/page_breadcrumb/page.rst @@ -0,0 +1,5 @@ +A page +###### + +:breadcrumb: + {index} Index page diff --git a/pelican-theme/test/page_breadcrumb/subpage.html b/pelican-theme/test/page_breadcrumb/subpage.html new file mode 100644 index 00000000..27bb5f1a --- /dev/null +++ b/pelican-theme/test/page_breadcrumb/subpage.html @@ -0,0 +1,42 @@ + + + + + Index page » A page » Subpage | A Pelican Blog + + + + + + + + + + + +
+
+ +
+ + diff --git a/pelican-theme/test/page_breadcrumb/subpage.rst b/pelican-theme/test/page_breadcrumb/subpage.rst new file mode 100644 index 00000000..13780444 --- /dev/null +++ b/pelican-theme/test/page_breadcrumb/subpage.rst @@ -0,0 +1,6 @@ +Subpage +####### + +:breadcrumb: + {index} Index page + {filename}/page.rst A page diff --git a/pelican-theme/test/page_extra_css/page.html b/pelican-theme/test/page_extra_css/page.html new file mode 100644 index 00000000..024393de --- /dev/null +++ b/pelican-theme/test/page_extra_css/page.html @@ -0,0 +1,38 @@ + + + + + A page | A Pelican Blog + + + + + + + + + + + + + +
+
+
+
+
+
+

A page

+
+
+
+
+
+ + diff --git a/pelican-theme/test/page_extra_css/page.rst b/pelican-theme/test/page_extra_css/page.rst new file mode 100644 index 00000000..0a1d86c7 --- /dev/null +++ b/pelican-theme/test/page_extra_css/page.rst @@ -0,0 +1,5 @@ +A page +###### + +:css: static/m-debug.css + static/m-grid.css diff --git a/pelican-theme/test/page_header_footer/page.html b/pelican-theme/test/page_header_footer/page.html new file mode 100644 index 00000000..701f8cf1 --- /dev/null +++ b/pelican-theme/test/page_header_footer/page.html @@ -0,0 +1,60 @@ + + + + + A page | A Pelican Blog + + + + + + + + + + + + + +
+
+
+
+
+ +

Page header. With multiple lines. +Linking to self.

+ +
+
+
+
+
+
+
+

A page

+ +

Page content.

+ +
+
+
+
+
+
+
+ +

Page footer. Linking to self.

+ +
+
+
+
+ + diff --git a/pelican-theme/test/page_header_footer/page.rst b/pelican-theme/test/page_header_footer/page.rst new file mode 100644 index 00000000..d0592a4d --- /dev/null +++ b/pelican-theme/test/page_header_footer/page.rst @@ -0,0 +1,8 @@ +A page +###### + +:header: Page header. With multiple lines. + Linking to `self <{filename}/page.rst>`_. +:footer: Page footer. Linking to `self <{filename}/page.rst>`_. + +Page content. diff --git a/pelican-theme/test/page_landing/hide-navbar-brand.html b/pelican-theme/test/page_landing/hide-navbar-brand.html new file mode 100644 index 00000000..9d690151 --- /dev/null +++ b/pelican-theme/test/page_landing/hide-navbar-brand.html @@ -0,0 +1,54 @@ + + + + + A page | A Pelican Blog + + + + + + + + + + + + + + + +
+
+
+
+
+
+ +
+
+Landing text.
+
+ +
+
+
+
+
+
+ +

Page text.

+ +
+
+
+
+
+ + diff --git a/pelican-theme/test/page_landing/hide-navbar-brand.rst b/pelican-theme/test/page_landing/hide-navbar-brand.rst new file mode 100644 index 00000000..3ff5ab23 --- /dev/null +++ b/pelican-theme/test/page_landing/hide-navbar-brand.rst @@ -0,0 +1,13 @@ +A page +###### + +:cover: {filename}/ship.jpg +:hide_navbar_brand: True +:landing: + .. container:: m-row + + .. container:: m-col-m-6 m-push-m-3 + + Landing text. + +Page text. diff --git a/pelican-theme/test/page_landing/page.html b/pelican-theme/test/page_landing/page.html new file mode 100644 index 00000000..3c7a3ab9 --- /dev/null +++ b/pelican-theme/test/page_landing/page.html @@ -0,0 +1,64 @@ + + + + + A page title that displays only in title | A Pelican Blog + + + + + + + + + + + + + + + +
+
+
+
+
+
+ +
+
+

A page title that displays on page

Some text. Linking to self.

+
+
+ +
+
+
+
+
+
+ +

Some page text.

+ +
+
+
+
+
+
+
+ +This is visible on the bottom. + +
+
+
+
+ + diff --git a/pelican-theme/test/page_landing/page.rst b/pelican-theme/test/page_landing/page.rst new file mode 100644 index 00000000..42d07b79 --- /dev/null +++ b/pelican-theme/test/page_landing/page.rst @@ -0,0 +1,18 @@ +A page title that displays only in title +######################################## + +:cover: {filename}/ship.jpg +:header: This shouldn't be visible anywhere. +:footer: This is visible on the bottom. +:landing: + .. container:: m-row + + .. container:: m-col-l-6 m-push-l-1 m-col-m-7 m-nopadb + + .. raw:: html + +

A page title that displays on page

+ + Some text. Linking `to self <{filename}/page.rst>`_. + +Some page text. diff --git a/pelican-theme/test/page_landing/ship.jpg b/pelican-theme/test/page_landing/ship.jpg new file mode 120000 index 00000000..d4469e38 --- /dev/null +++ b/pelican-theme/test/page_landing/ship.jpg @@ -0,0 +1 @@ +../../../doc/static/ship.jpg \ No newline at end of file diff --git a/pelican-theme/test/page_minimal/page.html b/pelican-theme/test/page_minimal/page.html new file mode 100644 index 00000000..c73ad4cb --- /dev/null +++ b/pelican-theme/test/page_minimal/page.html @@ -0,0 +1,36 @@ + + + + + A page | A Pelican Blog + + + + + + + + + + + +
+
+
+
+
+
+

A page

+
+
+
+
+
+ + \ No newline at end of file diff --git a/pelican-theme/test/page_minimal/page.rst b/pelican-theme/test/page_minimal/page.rst new file mode 100644 index 00000000..58c8b8ca --- /dev/null +++ b/pelican-theme/test/page_minimal/page.rst @@ -0,0 +1,2 @@ +A page +###### diff --git a/pelican-theme/test/page_title_sitename_alias/page.html b/pelican-theme/test/page_title_sitename_alias/page.html new file mode 100644 index 00000000..1d4e3ba1 --- /dev/null +++ b/pelican-theme/test/page_title_sitename_alias/page.html @@ -0,0 +1,36 @@ + + + + + Site name + + + + + + + + + + + +
+
+
+
+
+
+

Site name

+
+
+
+
+
+ + diff --git a/pelican-theme/test/page_title_sitename_alias/page.rst b/pelican-theme/test/page_title_sitename_alias/page.rst new file mode 100644 index 00000000..4f7e2b27 --- /dev/null +++ b/pelican-theme/test/page_title_sitename_alias/page.rst @@ -0,0 +1,2 @@ +Site name +######### diff --git a/pelican-theme/test/test_page.py b/pelican-theme/test/test_page.py new file mode 100644 index 00000000..070a49d6 --- /dev/null +++ b/pelican-theme/test/test_page.py @@ -0,0 +1,85 @@ +from test import PageTestCase + +class Page(PageTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, '', *args, **kwargs) + + def test(self): + self.run_pelican({ + 'FORMATTED_FIELDS': ['summary', 'description'] + }) + + # The content and summary meta tag shouldn't be there at all + self.assertEqual(*self.actual_expected_contents('page.html')) + +class Minimal(PageTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'minimal', *args, **kwargs) + + def test(self): + self.run_pelican({}) + + # The content and summary meta tag shouldn't be there at all + self.assertEqual(*self.actual_expected_contents('page.html')) + +class Breadcrumb(PageTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'breadcrumb', *args, **kwargs) + + def test(self): + self.run_pelican({}) + + # Internal links should work and guide the user from one page to + # another + self.assertEqual(*self.actual_expected_contents('page.html')) + self.assertEqual(*self.actual_expected_contents('subpage.html')) + +class ExtraCss(PageTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'extra_css', *args, **kwargs) + + def test(self): + self.run_pelican({}) + + # The page should contain two extra CSS links + self.assertEqual(*self.actual_expected_contents('page.html')) + +class HeaderFooter(PageTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'header_footer', *args, **kwargs) + + def test(self): + self.run_pelican({ + 'FORMATTED_FIELDS': ['header', 'footer'] + }) + + # The header and footer should have the links expanded + self.assertEqual(*self.actual_expected_contents('page.html')) + +class Landing(PageTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'landing', *args, **kwargs) + + def test(self): + self.run_pelican({ + 'STATIC_PATHS': ['ship.jpg'], + 'FORMATTED_FIELDS': ['landing'] + }) + + # The landing field should have the links expanded, header should not + # be shown, footer should be. Navbar brand should be hidden in the + # second case. + self.assertEqual(*self.actual_expected_contents('page.html')) + self.assertEqual(*self.actual_expected_contents('hide-navbar-brand.html')) + +class TitleSitenameAlias(PageTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'title_sitename_alias', *args, **kwargs) + + def test(self): + self.run_pelican({ + 'SITENAME': "Site name" + }) + + # The page title should be just one name, not both + self.assertEqual(*self.actual_expected_contents('page.html')) -- 2.30.2