Ver código fonte

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

Ref #25.
Thibaut Courouble 10 anos atrás
pai
commit
5015405e7c

+ 2 - 1
assets/javascripts/models/doc.coffee

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

+ 1 - 1
assets/javascripts/templates/notice_tmpl.coffee

@@ -1,7 +1,7 @@
 notice = (text) -> """<p class="_notice-text">#{text}</p>"""
 
 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>). """
 
 app.templates.disabledDocNotice = ->

+ 1 - 2
assets/javascripts/templates/pages/offline_tmpl.coffee

@@ -51,11 +51,10 @@ canICloseTheTab = ->
 
 app.templates.offlineDoc = (doc, status) ->
   outdated = doc.isOutdated(status)
-  version = if doc.version then " (#{doc.version})" else ''
 
   html = """
     <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>
   """
 

+ 1 - 1
assets/javascripts/templates/pages/type_tmpl.coffee

@@ -1,5 +1,5 @@
 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> """
 
 app.templates.typePageEntry = (entry) ->

+ 1 - 1
assets/javascripts/templates/path_tmpl.coffee

@@ -1,5 +1,5 @@
 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 += """<span class="_path-item">#{$.escape entry.name}</span>""" if entry
   html

+ 2 - 4
assets/javascripts/templates/sidebar_tmpl.coffee

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

+ 1 - 1
assets/javascripts/views/content/entry_page.coffee

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

+ 1 - 1
assets/javascripts/views/content/type_page.coffee

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

+ 1 - 1
assets/javascripts/views/search/search_scope.coffee

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