mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-22 10:33:22 +00:00
Glossary should be output as a normal page
This commit is contained in:
@@ -44,6 +44,15 @@ util.inherits(Glossary, BackboneFile);
|
||||
|
||||
Glossary.prototype.type = 'glossary';
|
||||
|
||||
// Get templating context
|
||||
Glossary.prototype.getContext = function() {
|
||||
return {
|
||||
glossary: {
|
||||
path: this.path
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Parse the readme content
|
||||
Glossary.prototype.parse = function(content) {
|
||||
var that = this;
|
||||
@@ -73,4 +82,16 @@ Glossary.prototype.isEmpty = function(id) {
|
||||
return _.size(this.entries) === 0;
|
||||
};
|
||||
|
||||
// Convert the glossary to a list of annotations
|
||||
Glossary.prototype.annotations = function() {
|
||||
return _.map(this.entries, function(entry) {
|
||||
return {
|
||||
id: entry.id,
|
||||
name: entry.name,
|
||||
description: entry.description,
|
||||
href: '/' + this.path + '#' + entry.id
|
||||
};
|
||||
}, this);
|
||||
};
|
||||
|
||||
module.exports = Glossary;
|
||||
|
||||
@@ -169,6 +169,7 @@ Output.prototype.getPageContext = function(page) {
|
||||
gitbook.getContext(),
|
||||
this.book.getContext(),
|
||||
this.book.summary.getContext(),
|
||||
this.book.glossary.getContext(),
|
||||
this.book.config.getContext()
|
||||
);
|
||||
};
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ HTMLPipeline.prototype.applyAnnotations = function() {
|
||||
replaceText(that.$, this, searchRegex, function(match) {
|
||||
that.opts.onAnnotation(annotation);
|
||||
|
||||
return '<a href="'+that.opts.onRelativeLink(annotation.href) + '#' + annotation.id+'" '
|
||||
return '<a href="' + that.opts.onRelativeLink(annotation.href) + '" '
|
||||
+ 'class="glossary-term" title="'+_.escape(annotation.description)+'">'
|
||||
+ match
|
||||
+ '</a>';
|
||||
|
||||
+1
-8
@@ -166,14 +166,7 @@ Page.prototype.toHTML = function(output) {
|
||||
},
|
||||
|
||||
// Convert glossary entries to annotations
|
||||
annotations: _.map(that.book.glossary.entries, function(entry) {
|
||||
return {
|
||||
id: entry.id,
|
||||
name: entry.name,
|
||||
description: entry.description,
|
||||
href: '/GLOSSARY.html'
|
||||
};
|
||||
})
|
||||
annotations: that.book.glosary.annotations()
|
||||
};
|
||||
var pipeline = new HTMLPipeline(that.content, pipelineOpts);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user