Permalink
Browse files

split nav metadata into head and body components

  • Loading branch information...
1 parent f1187d9 commit 30a292b287ad94d1262f5a1b7123ea75105a6093 @sudo-reboot sudo-reboot committed Feb 18, 2014
@@ -10,7 +10,8 @@ define [
'cs!gh-book/uuid'
'hbs!templates/gh-book/defaults/opf'
'hbs!templates/gh-book/defaults/nav'
- 'hbs!templates/gh-book/nav-metadata'
+ 'hbs!templates/gh-book/nav-body-metadata'
+ 'hbs!templates/gh-book/nav-head-metadata'
], (
Backbone,
mediaTypes,
@@ -23,7 +24,8 @@ define [
uuid,
defaultOpf,
defaultNav,
- navMetadata
+ navBodyMetadata,
+ navHeadMetadata
) ->
SAVE_DELAY = 10 # ms
@@ -69,9 +71,12 @@ define [
# This way we can ignore firing events when Backbone is parsing as well as
# when we are internally updating models.
setNavModel = (options) =>
+ console.log 'here'
if not options.doNotReparse
+ console.log 'here2'
options.doNotReparse = true
- @navModel.set 'body', @_serializeNavModel(), options
+ @navModel.set 'head', @_serializeNavModelHead(), options
+ @navModel.set 'body', @_serializeNavModelBody(), options
# if we're updating the nav the spine also probably needs to be updated
@_buildSpine()
@@ -99,7 +104,9 @@ define [
return if not value
container = @$xml.find('metadata')
- selector = tagName.replace(':', '\\:')
+
+ # remove any namespace on the tagname so jquery will work
+ selector = tagName.replace(/.*:/, '')
element = @$xml[0].createElement(tagName)
@@ -147,7 +154,10 @@ define [
return if not values.length
container = @$xml.find('metadata')
- selector = tagName.replace(':', '\\:')
+
+ # remove any namespace on the tagname so jquery will work
+ selector = tagName.replace(/.*:/, '')
+
template = @$xml[0].createElement(tagName)
_.forIn attributes, (value, key) ->
@@ -184,7 +194,7 @@ define [
container = @$xml.find('metadata')
template = "<dc:subject></dc:subject>"
- @$xml.find('dc\\:subject').not('[xsi\\:type="http://github.com/Connexions/rhaptos.cnxmlutils/rhaptos/cnxmlutils/schema"]').remove()
+ @$xml.find('subject').not('[xsi\\:type="http://github.com/Connexions/rhaptos.cnxmlutils/rhaptos/cnxmlutils/schema"]').remove()
_.each(value, (keyword) ->
container.append(' ')
@@ -202,7 +212,7 @@ define [
return if not creators.length
# remove the existing ones so we don't get dupes
- @$xml.find('dc\\:creator[id^="'+type+'"]').remove()
+ @$xml.find('creator[id^="'+type+'"]').remove()
@$xml.find('meta[refines^="#'+type+'"]').remove()
container = @$xml.find('metadata')
@@ -452,12 +462,12 @@ define [
@_markDirty({}) if start != @serialize()
- _serializeNavModel: () ->
- $wrapper = $('<div></div>')
+ _serializeNavModelHead: () ->
+ return navHeadMetadata(@toJSON())
- $wrapper
- .append(navMetadata(@toJSON()))
- .append('<nav></nav>')
+ _serializeNavModelBody: () ->
+ $wrapper = $('<div></div>')
+ $wrapper.append('<nav></nav>')
$nav = $wrapper.find 'nav'
@@ -494,7 +504,7 @@ define [
# Trim the HTML and put newlines between elements
html = $wrapper.html()
html = html.replace(/></g, '>\n<')
- return html
+ return navBodyMetadata(@toJSON()) + html
parse: (json) ->
@@ -0,0 +1,5 @@
+ <h1 itemprop="name">{{ title }}</h1>
+ {{#if authors }}<span class="authors">By: {{#each authors }}{{#if @index }}, {{/if}}<span itemprop="author">{{ this }}</span>{{/each}}</span>{{/if}}
+ {{#if publishers }}<span class="publisher">Published By: {{#each publishers }}{{#if @index }}, {{/if}}<span itemprop="publisher">{{ this }}</span>{{/each}}</span>{{/if}}
+ {{#if description }}<p itemprop="description">{{ description }}</p>{{/if}}
+ <h1>Table of Contents</h1>
@@ -1,25 +1,19 @@
<title>{{ title }}</title>
- {{#if language }}<meta itemprop="inLanguage" content="{{ language }}" />{{/if}}
- {{#if rights }}<meta property="dc:license" content="{{ rights }}" />{{/if}}
- {{#if rightsUrl }}<meta property="lrmi:useRightsUrl" content="{{ rightsUrl }}" />{{/if}}
- {{#if dateModified }}<meta itemprop="dateModified" content="{{ dateModified }}" />{{/if}}
- {{#if datePublished }}<meta itemprop="dateCreated" content="{{ datePublished }}" />{{/if}}
- {{#each subject}}<meta itemprop="about" content="{{ this }}" />
+ {{#if language }}<meta itemprop="inLanguage" content="{{ language }}"></meta>{{/if}}
+ {{#if rights }}<meta property="dc:license" content="{{ rights }}"></meta>{{/if}}
+ {{#if rightsUrl }}<meta property="lrmi:useRightsUrl" content="{{ rightsUrl }}"></meta>{{/if}}
+ {{#if dateModified }}<meta itemprop="dateModified" content="{{ dateModified }}"></meta>{{/if}}
+ {{#if datePublished }}<meta itemprop="dateCreated" content="{{ datePublished }}"></meta>{{/if}}
+ {{#each subject}}<meta itemprop="about" content="{{ this }}"></meta>
{{/each}}
- {{#each keywords}}<meta itemprop="keywords" content="{{ this }}" />
+ {{#each keywords}}<meta itemprop="keywords" content="{{ this }}"></meta>
{{/each}}
- {{#each rightsHolders}}<meta itemprop="copyrightHolder" content="{{ this }}" />
+ {{#each rightsHolders}}<meta itemprop="copyrightHolder" content="{{ this }}"></meta>
{{/each}}
- {{#each editors }}<meta itemprop="editor" content="{{ this }}" />
+ {{#each editors }}<meta itemprop="editor" content="{{ this }}"></meta>
{{/each}}
- {{#each translators }}<meta id="translator{{@key }}" itemprop="contributor" content="{{ this }}"/>
- <meta refines="#translator{{@key }}" property="role" scheme="marc:relators" content="trl" />
+ {{#each translators }}<meta id="translator{{@key }}" itemprop="contributor" content="{{ this }}"></meta>
+ <meta refines="#translator{{@key }}" property="role" scheme="marc:relators" content="trl"></meta>
{{/each}}
- {{#each illustrators }}<meta itemprop="illustrator" content="{{ this }}" />
+ {{#each illustrators }}<meta itemprop="illustrator" content="{{ this }}"></meta>
{{/each}}
-
- <h1 itemprop="name">{{ title }}</h1>
- {{#if authors }}<span class="authors">By: {{#each authors }}{{#if @index }}, {{/if}}<span itemprop="author">{{ this }}</span>{{/each}}</span>{{/if}}
- {{#if publishers }}<span class="publisher">Published By: {{#each publishers }}{{#if @index }}, {{/if}}<span itemprop="publisher">{{ this }}</span>{{/each}}</span>{{/if}}
- {{#if description }}<p itemprop="description">{{ description }}</p>{{/if}}
- <h1>Table of Contents</h1>

0 comments on commit 30a292b

Please sign in to comment.