Adjust page header / title generation.
Now page header can be generated by first h1 header from page content. But page title generated by URL is it was before.
This commit is contained in:
@@ -7,7 +7,7 @@ Mousetrap.bind(['e'], function( e ) {
|
|||||||
</script>
|
</script>
|
||||||
<div id="wiki-wrapper" class="page">
|
<div id="wiki-wrapper" class="page">
|
||||||
<div id="head">
|
<div id="head">
|
||||||
<h1>{{title}}</h1>
|
<h1>{{page_header}}</h1>
|
||||||
<ul class="actions">
|
<ul class="actions">
|
||||||
<li class="minibutton">
|
<li class="minibutton">
|
||||||
{{>searchbar}}
|
{{>searchbar}}
|
||||||
|
|||||||
@@ -8,11 +8,15 @@ module Precious
|
|||||||
DEFAULT_AUTHOR = 'you'
|
DEFAULT_AUTHOR = 'you'
|
||||||
|
|
||||||
def title
|
def title
|
||||||
extract_title(@content) || @page.url_path.gsub("-", " ")
|
@page.url_path.gsub("-", " ")
|
||||||
|
end
|
||||||
|
|
||||||
|
def page_header
|
||||||
|
page_header_from_content(@content) || title
|
||||||
end
|
end
|
||||||
|
|
||||||
def content
|
def content
|
||||||
without_title(@content)
|
content_without_page_header(@content)
|
||||||
end
|
end
|
||||||
|
|
||||||
def author
|
def author
|
||||||
@@ -126,7 +130,7 @@ module Precious
|
|||||||
|
|
||||||
# Extracts title from page if present.
|
# Extracts title from page if present.
|
||||||
#
|
#
|
||||||
def extract_title(content)
|
def page_header_from_content(content)
|
||||||
doc = build_document(content)
|
doc = build_document(content)
|
||||||
title = find_header_node(doc)
|
title = find_header_node(doc)
|
||||||
Sanitize.clean(title.to_html).strip unless title.empty?
|
Sanitize.clean(title.to_html).strip unless title.empty?
|
||||||
@@ -134,7 +138,7 @@ module Precious
|
|||||||
|
|
||||||
# Returns page content without title if it was extracted.
|
# Returns page content without title if it was extracted.
|
||||||
#
|
#
|
||||||
def without_title(content)
|
def content_without_page_header(content)
|
||||||
doc = build_document(content)
|
doc = build_document(content)
|
||||||
title = find_header_node(doc)
|
title = find_header_node(doc)
|
||||||
title.remove unless title.empty?
|
title.remove unless title.empty?
|
||||||
|
|||||||
Reference in New Issue
Block a user