Skip to content

Commit

Permalink
Always use h2 heading chapter content and make chapter block more com…
Browse files Browse the repository at this point in the history
…pact.

- Make the block-title of a chapter (and textblocks) to be
  displayed as h2 in the chapter simplelayout view as this is
  semantically correct and looks consitent on all levels.

- Make the chapter block more compact for improved usability.
  • Loading branch information
jone committed Nov 6, 2019
1 parent 92397a5 commit 7f52716
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 25 deletions.
1 change: 1 addition & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
4.0.2 (unreleased)
------------------

- Always use h2 heading chapter content and make chapter block more compact. [jone]
- Remove "Type" column from listing block table in PDF. [jone]
- Fix navigation and search settings for new DX types. [jone]
- Fix chapter's title translation. [jone]
Expand Down
2 changes: 2 additions & 0 deletions ftw/book/browser/blockview.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def block_title(self):
return TableOfContents().html_heading(
self.context,
linked=False,
tagname='h2',
prepend_html_headings=self.prepend_html_headings)

def has_tables_with_missing_widths(self):
Expand Down Expand Up @@ -69,6 +70,7 @@ def __call__(self, prepend_html_headings=False):
def block_title(self):
return TableOfContents().html_heading(
self.context,
tagname='h2',
linked=True,
prepend_html_headings=self.prepend_html_headings)

Expand Down
8 changes: 8 additions & 0 deletions ftw/book/browser/resources/theming.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ ul.book-index {
}


body .sl-simplelayout.sl-can-edit .sl-block.ftw-book-chapter {
min-height: 0;
}
.sl-block.ftw-book-chapter h2 {
margin: .5em 0;
}


/* let chapter be addable although its a sl block
https://github.com/4teamwork/ftw.simplelayout/blob/master/ftw/simplelayout/browser/dynamic_scss_resources.py */
body #plone-contentmenu-factories .contenttype-ftw-book-chapter {
Expand Down
4 changes: 2 additions & 2 deletions ftw/book/tests/test_fti_chapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def test_subchapter_is_rendered_as_block_in_parent(self, browser):

browser.login().visit(chapter)
self.assertIn(
u'<h3 class="toc3"><a href="{}">China</a></h3>'.format(
u'<h2 class="toc3"><a href="{}">China</a></h2>'.format(
subchapter.absolute_url()),
map(attrgetter('outerHTML'), browser.css('.sl-block h3')))
map(attrgetter('outerHTML'), browser.css('.sl-block h2')))

browser.css('#content-core').first.find('China').click()
self.assertEquals(subchapter, browser.context)
16 changes: 8 additions & 8 deletions ftw/book/tests/test_fti_htmlblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def test_creating_htmlblock(self, browser):
'Expected chapter to have exactly one block')

self.assertEquals(
u'<h3 class="toc3">The HTML Block</h3>',
browser.css('.sl-block h3').first.outerHTML)
u'<h2 class="toc3">The HTML Block</h2>',
browser.css('.sl-block h2').first.outerHTML)

self.assertEquals(
'Some <b>body</b> text',
Expand All @@ -44,12 +44,12 @@ def test_hiding_block_title(self, browser):
self.htmlblock.show_title = False
transaction.commit()
browser.login().visit(self.htmlblock)
self.assertNotIn(title, browser.css('.sl-block h3').text)
self.assertNotIn(title, browser.css('.sl-block h2').text)

self.htmlblock.show_title = True
transaction.commit()
browser.reload()
self.assertIn(title, browser.css('.sl-block h3').text)
self.assertIn(title, browser.css('.sl-block h2').text)

@browsing
def test_no_prefix_when_hiding_title_from_table_of_contents(self, browser):
Expand All @@ -60,15 +60,15 @@ def test_no_prefix_when_hiding_title_from_table_of_contents(self, browser):
transaction.commit()
browser.login().visit(self.htmlblock)
self.assertIn(
u'<h3 class="toc3">An HTML Block</h3>',
map(attrgetter('outerHTML'), browser.css('.sl-block h3')))
u'<h2 class="toc3">An HTML Block</h2>',
map(attrgetter('outerHTML'), browser.css('.sl-block h2')))

self.htmlblock.hide_from_toc = True
transaction.commit()
browser.reload()
self.assertIn(
u'<h3 class="no-toc">An HTML Block</h3>',
map(attrgetter('outerHTML'), browser.css('.sl-block h3')))
u'<h2 class="no-toc">An HTML Block</h2>',
map(attrgetter('outerHTML'), browser.css('.sl-block h2')))

@browsing
def test_warning_when_table_widths_not_specified(self, browser):
Expand Down
14 changes: 7 additions & 7 deletions ftw/book/tests/test_fti_listingblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def test_create_listingblock(self, browser):
'Expected chapter to have exactly one block')

self.assertEquals(
u'<h3 class="toc3">Recipes</h3>',
browser.css('.sl-block h3').first.outerHTML)
u'<h2 class="toc3">Recipes</h2>',
browser.css('.sl-block h2').first.outerHTML)

@browsing
def test_showing_block_title(self, browser):
title = 'Important Documents'
selector = '.sl-block h4'
selector = '.sl-block h2'

self.grant('Manager')
browser.login().visit(aq_parent(self.listingblock))
Expand All @@ -50,12 +50,12 @@ def test_hiding_title_from_table_of_contents_removes_prefix(self, browser):
self.grant('Manager')
browser.login().visit(aq_parent(self.listingblock))
self.assertIn(
u'<h4 class="toc4">Important Documents</h4>',
map(attrgetter('outerHTML'), browser.css('.sl-block h4')))
u'<h2 class="toc4">Important Documents</h2>',
map(attrgetter('outerHTML'), browser.css('.sl-block h2')))

self.listingblock.hide_from_toc = True
transaction.commit()
browser.reload()
self.assertIn(
u'<h4 class="no-toc">Important Documents</h4>',
map(attrgetter('outerHTML'), browser.css('.sl-block h4')))
u'<h2 class="no-toc">Important Documents</h2>',
map(attrgetter('outerHTML'), browser.css('.sl-block h2')))
16 changes: 8 additions & 8 deletions ftw/book/tests/test_fti_textblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def test_creating_textblock(self, browser):
'Expected chapter to have exactly one block')

self.assertEquals(
u'<h3 class="toc3">The Text Block</h3>',
browser.css('.sl-block h3').first.outerHTML)
u'<h2 class="toc3">The Text Block</h2>',
browser.css('.sl-block h2').first.outerHTML)

@browsing
def test_showing_block_title(self, browser):
Expand All @@ -37,12 +37,12 @@ def test_showing_block_title(self, browser):
self.textblock.show_title = False
transaction.commit()
browser.login().visit(self.textblock)
self.assertNotIn(title, browser.css('.sl-block h4').text)
self.assertNotIn(title, browser.css('.sl-block h2').text)

self.textblock.show_title = True
transaction.commit()
browser.reload()
self.assertIn(title, browser.css('.sl-block h4').text)
self.assertIn(title, browser.css('.sl-block h2').text)

@browsing
def test_hiding_title_from_table_of_contents_removes_prefix(self, browser):
Expand All @@ -53,15 +53,15 @@ def test_hiding_title_from_table_of_contents_removes_prefix(self, browser):
transaction.commit()
browser.login().visit(self.textblock)
self.assertIn(
u'<h4 class="toc4">First things first</h4>',
map(attrgetter('outerHTML'), browser.css('.sl-block h4')))
u'<h2 class="toc4">First things first</h2>',
map(attrgetter('outerHTML'), browser.css('.sl-block h2')))

self.textblock.hide_from_toc = True
transaction.commit()
browser.reload()
self.assertIn(
u'<h4 class="no-toc">First things first</h4>',
map(attrgetter('outerHTML'), browser.css('.sl-block h4')))
u'<h2 class="no-toc">First things first</h2>',
map(attrgetter('outerHTML'), browser.css('.sl-block h2')))

@browsing
def test_warning_when_table_widths_not_specified(self, browser):
Expand Down

0 comments on commit 7f52716

Please sign in to comment.