Skip to content

Commit

Permalink
Merge pull request #22 from oerpub/module-metadata
Browse files Browse the repository at this point in the history
Module metadata
  • Loading branch information
kathi-fletcher committed Mar 3, 2014
2 parents 0969250 + 9f69f22 commit c5b602f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions scripts/configs/aloha.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ define ['jquery'], ($) ->
'oer/multipart'
'oer/copy'
'oer/cleanup'
'oer/metadata'
]

# This whole thing is what's needed to:
Expand Down
26 changes: 26 additions & 0 deletions scripts/views/workspace/content/content-edit.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,29 @@ define [

# **NOTE:** This template is not wrapped in an element
template: contentEditTemplate

initialize: () ->
Aloha.settings.plugins.metadata = Aloha.settings.plugins.metadata || {}
Aloha.settings.plugins.metadata.supplement = ''

Aloha.settings.plugins.metadata.setMetadata = (metadata) =>
@model.set('title', metadata.title, {triggeredByMetadata: true})
head = '<title>'+metadata.title+'</title>'
head += '<meta data-type="language" itemprop="inLanguage" content="'+metadata.language+ '" />'
@model.set('head', head)

Aloha.settings.plugins.metadata.filterMetadata = (metadata) =>
delete metadata.language if metadata.language
metadata

@listenTo @model, "change:title", (model, value, options) =>
Aloha.settings.plugins.metadata.extendMetadata({title: value}) if not options.triggeredByMetadata

@listenTo @model, "change:head", (model, value, options) =>
# sometimes there is no head. which is dumb.
if @model.get('head')
Aloha.settings.plugins.metadata.supplement = @model.get('head')
else
Aloha.settings.plugins.metadata.supplement = "<title>" + @model.get("title") + "</title>"

super()
4 changes: 4 additions & 0 deletions scripts/views/workspace/content/layouts/editor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ define [
@$el.parent().parent().parent().parent().find(
'#module-title-indicator').text(@model.get('title'))

@listenTo @model, "change:title", =>
@$el.parent().parent().parent().parent().find(
'#module-title-indicator').text(@model.get('title'))

# Focus the editor. This has to be done here, because @$el isn't attached
# to the DOM before this. We also have to wait until the content is
# loaded and the editor is actually activated.
Expand Down
2 changes: 1 addition & 1 deletion scripts/views/workspace/sidebar/toc-branch.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,6 @@ define [
# TocPointerNodes which inherit their title if it is not overridden
title = prompt('Edit Title:', @model.toJSON().title)
if title and title != @model.toJSON().title
@model.set('title', title)
(@model.dereferencePointer?() or @model).set('title', title)

@renderModelOnly()

0 comments on commit c5b602f

Please sign in to comment.