Use doc full name (incl. version) throughout the app

Ref #25.
pull/308/merge
Thibaut Courouble 9 years ago
parent 2ece8d13da
commit 5015405e7c

@ -5,6 +5,7 @@ class app.models.Doc extends app.Model
super super
@reset @ @reset @
[@slug_without_version, @version] = @slug.split('~v') [@slug_without_version, @version] = @slug.split('~v')
@fullName = "#{@name}" + if @version then " #{@version}" else ''
@icon = @slug_without_version @icon = @slug_without_version
@text = @toEntry().text @text = @toEntry().text
@ -39,7 +40,7 @@ class app.models.Doc extends app.Model
toEntry: -> toEntry: ->
@entry ||= new app.models.Entry @entry ||= new app.models.Entry
doc: @ doc: @
name: @name name: @fullName
path: 'index' path: 'index'
findEntryByPathAndHash: (path, hash) -> findEntryByPathAndHash: (path, hash) ->

@ -1,7 +1,7 @@
notice = (text) -> """<p class="_notice-text">#{text}</p>""" notice = (text) -> """<p class="_notice-text">#{text}</p>"""
app.templates.singleDocNotice = (doc) -> app.templates.singleDocNotice = (doc) ->
notice """ You're currently browsing the #{doc.name} documentation. To browse all docs, go to notice """ You're currently browsing the #{doc.fullName} documentation. To browse all docs, go to
<a href="http://#{app.config.production_host}" target="_top">#{app.config.production_host}</a> (or press <code>esc</code>). """ <a href="http://#{app.config.production_host}" target="_top">#{app.config.production_host}</a> (or press <code>esc</code>). """
app.templates.disabledDocNotice = -> app.templates.disabledDocNotice = ->

@ -51,11 +51,10 @@ canICloseTheTab = ->
app.templates.offlineDoc = (doc, status) -> app.templates.offlineDoc = (doc, status) ->
outdated = doc.isOutdated(status) outdated = doc.isOutdated(status)
version = if doc.version then " (#{doc.version})" else ''
html = """ html = """
<tr data-slug="#{doc.slug}"#{if outdated then ' class="_highlight"' else ''}> <tr data-slug="#{doc.slug}"#{if outdated then ' class="_highlight"' else ''}>
<td class="_docs-name _icon-#{doc.icon}">#{doc.name}#{version}</td> <td class="_docs-name _icon-#{doc.icon}">#{doc.fullName}</td>
<td class="_docs-size">#{Math.ceil(doc.db_size / 100000) / 10} MB</td> <td class="_docs-size">#{Math.ceil(doc.db_size / 100000) / 10} MB</td>
""" """

@ -1,5 +1,5 @@
app.templates.typePage = (type) -> app.templates.typePage = (type) ->
""" <h1>#{type.doc.name} / #{type.name}</h1> """ <h1>#{type.doc.fullName} / #{type.name}</h1>
<ul class="_entry-list">#{app.templates.render 'typePageEntry', type.entries()}</ul> """ <ul class="_entry-list">#{app.templates.render 'typePageEntry', type.entries()}</ul> """
app.templates.typePageEntry = (entry) -> app.templates.typePageEntry = (entry) ->

@ -1,5 +1,5 @@
app.templates.path = (doc, type, entry) -> app.templates.path = (doc, type, entry) ->
html = """<a href="#{doc.fullPath()}" class="_path-item _icon-#{doc.icon}">#{doc.name}</a>""" html = """<a href="#{doc.fullPath()}" class="_path-item _icon-#{doc.icon}">#{doc.fullName}</a>"""
html += """<a href="#{type.fullPath()}" class="_path-item">#{type.name}</a>""" if type html += """<a href="#{type.fullPath()}" class="_path-item">#{type.name}</a>""" if type
html += """<span class="_path-item">#{$.escape entry.name}</span>""" if entry html += """<span class="_path-item">#{$.escape entry.name}</span>""" if entry
html html

@ -3,7 +3,7 @@ templates = app.templates
templates.sidebarDoc = (doc, options = {}) -> templates.sidebarDoc = (doc, options = {}) ->
link = """<a href="#{doc.fullPath()}" class="_list-item _icon-#{doc.icon} """ link = """<a href="#{doc.fullPath()}" class="_list-item _icon-#{doc.icon} """
link += if options.disabled then '_list-disabled' else '_list-dir' link += if options.disabled then '_list-disabled' else '_list-dir'
link += """" data-slug="#{doc.slug}" title="#{doc.name} #{doc.version || ''}">""" link += """" data-slug="#{doc.slug}" title="#{doc.fullName}">"""
if options.disabled if options.disabled
link += """<span class="_list-enable" data-enable="#{doc.slug}">Enable</span>""" link += """<span class="_list-enable" data-enable="#{doc.slug}">Enable</span>"""
else else
@ -41,9 +41,7 @@ templates.sidebarLabel = (doc, options = {}) ->
label += " _icon-#{doc.icon}" unless doc.version label += " _icon-#{doc.icon}" unless doc.version
label += """"><input type="checkbox" name="#{doc.slug}" class="_list-checkbox" """ label += """"><input type="checkbox" name="#{doc.slug}" class="_list-checkbox" """
label += "checked" if options.checked label += "checked" if options.checked
label += ">#{doc.name}" label + ">#{doc.fullName}</label>"
label += " #{doc.version}" if doc.version
label + "</label>"
templates.sidebarVersionedDoc = (doc, versions, options = {}) -> templates.sidebarVersionedDoc = (doc, versions, options = {}) ->
html = """<div class="_list-item _list-dir _list-rdir _icon-#{doc.icon}""" html = """<div class="_list-item _list-dir _list-rdir _icon-#{doc.icon}"""

@ -75,7 +75,7 @@ class app.views.EntryPage extends app.View
app.views["#{docType[0].toUpperCase()}#{docType[1..]}Page"] or app.views.BasePage app.views["#{docType[0].toUpperCase()}#{docType[1..]}Page"] or app.views.BasePage
getTitle: -> getTitle: ->
@entry.doc.name + if @entry.isIndex() then ' documentation' else "/#{@entry.name}" @entry.doc.fullName + if @entry.isIndex() then ' documentation' else " / #{@entry.name}"
beforeRoute: => beforeRoute: =>
@abort() @abort()

@ -12,7 +12,7 @@ class app.views.TypePage extends app.View
return return
getTitle: -> getTitle: ->
"#{@type.doc.name}/#{@type.name}" "#{@type.doc.fullName} / #{@type.name}"
onRoute: (context) -> onRoute: (context) ->
@render context.type @render context.type

@ -50,7 +50,7 @@ class app.views.SearchScope extends app.View
selectDoc: (doc) -> selectDoc: (doc) ->
@doc = doc @doc = doc
@tag.textContent = doc.name @tag.textContent = doc.fullName
@tag.style.display = 'block' @tag.style.display = 'block'
@input.removeAttribute 'placeholder' @input.removeAttribute 'placeholder'

Loading…
Cancel
Save