Skip to content

Commit a639aed

Browse files
committed
Remove index_path and db_path from docs manifest
1 parent e1c0218 commit a639aed

7 files changed

Lines changed: 16 additions & 14 deletions

File tree

‎assets/javascripts/app/config.coffee.erb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
app.config =
2+
db_filename: 'db.json'
23
default_docs: <%= App.default_docs.to_json %>
34
docs_host: '<%= App.docs_host %>'
45
env: '<%= App.environment %>'
56
history_cache_size: 10
7+
index_filename: 'index.json'
68
index_path: '/<%= App.docs_prefix %>'
79
max_results: 50
810
production_host: 'devdocs.io'

‎assets/javascripts/models/doc.coffee‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class app.models.Doc extends app.Model
2-
# Attributes: name, slug, type, release, index_path, db_path, db_size, mtime, links
2+
# Attributes: name, slug, type, release, db_size, mtime, links
33

44
constructor: ->
55
super
@@ -29,10 +29,10 @@ class app.models.Doc extends app.Model
2929
"#{app.config.docs_host}#{@fullPath(path)}?#{@mtime}"
3030

3131
dbUrl: ->
32-
"#{app.config.docs_host}/#{@db_path}?#{@mtime}"
32+
"#{app.config.docs_host}/#{@slug}/#{app.config.db_filename}?#{@mtime}"
3333

3434
indexUrl: ->
35-
"#{app.indexHost()}/#{@index_path}?#{@mtime}"
35+
"#{app.indexHost()}/#{@slug}/#{app.config.index_filename}?#{@mtime}"
3636

3737
toEntry: ->
3838
@entry ||= new app.models.Entry

‎lib/app.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def docs
118118
def doc_index_urls
119119
docs.each_with_object [] do |slug, result|
120120
if doc = settings.docs[slug]
121-
result << File.join('', settings.docs_prefix, doc['index_path']) + "?#{doc['mtime']}"
121+
result << File.join('', settings.docs_prefix, slug, 'index.json') + "?#{doc['mtime']}"
122122
end
123123
end
124124
end

‎lib/docs/core/doc.rb‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ def as_json
3737
slug: slug,
3838
type: type,
3939
release: release,
40-
index_path: index_path,
41-
db_path: db_path,
4240
links: links }
4341
end
4442

‎lib/docs/core/manifest.rb‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ def store
1414
end
1515

1616
def as_json
17-
indexed_docs.map(&:as_json).each do |json|
18-
json[:mtime] = doc_mtime(json)
19-
json[:db_size] = doc_db_size(json)
17+
indexed_docs.map do |doc|
18+
json = doc.as_json
19+
json[:mtime] = doc_mtime(doc)
20+
json[:db_size] = doc_db_size(doc)
21+
json
2022
end
2123
end
2224

@@ -33,11 +35,11 @@ def indexed_docs
3335
end
3436

3537
def doc_mtime(doc)
36-
[@store.mtime(doc[:index_path]).to_i, @store.mtime(doc[:db_path]).to_i].max
38+
[@store.mtime(doc.index_path).to_i, @store.mtime(doc.db_path).to_i].max
3739
end
3840

3941
def doc_db_size(doc)
40-
@store.size(doc[:db_path])
42+
@store.size(doc.db_path)
4143
end
4244
end
4345
end

‎test/files/docs.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"name":"CSS","slug":"css","type":"mdn","version":null,"index_path":"css/index.json","db_path":"css/db.json","mtime":1420139788,"db_size":3460507},{"name":"DOM","slug":"dom","type":"mdn","version":null,"index_path":"dom/index.json","db_path":"dom/db.json","mtime":1420139789,"db_size":11399128},{"name":"DOM Events","slug":"dom_events","type":"mdn","version":null,"index_path":"dom_events/index.json","db_path":"dom_events/db.json","mtime":1420139790,"db_size":889020},{"name":"HTML","slug":"html","type":"mdn","version":null,"index_path":"html/index.json","db_path":"html/db.json","mtime":1420139790,"db_size":1835646},{"name":"HTTP","slug":"http","type":"rfc","version":null,"index_path":"http/index.json","db_path":"http/db.json","mtime":1420139790,"db_size":183083},{"name":"JavaScript","slug":"javascript","type":"mdn","version":null,"index_path":"javascript/index.json","db_path":"javascript/db.json","mtime":1420139791,"db_size":4125477}]
1+
[{"name":"CSS","slug":"css","type":"mdn","release":null,"mtime":1420139788,"db_size":3460507},{"name":"DOM","slug":"dom","type":"mdn","release":null,"mtime":1420139789,"db_size":11399128},{"name":"DOM Events","slug":"dom_events","type":"mdn","release":null,"mtime":1420139790,"db_size":889020},{"name":"HTML","slug":"html","type":"mdn","release":null,"mtime":1420139790,"db_size":1835646},{"name":"HTTP","slug":"http","type":"rfc","release":null,"mtime":1420139790,"db_size":183083},{"name":"JavaScript","slug":"javascript","type":"mdn","release":null,"mtime":1420139791,"db_size":4125477}]

‎test/lib/docs/core/doc_test.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ class DocsDocTest < MiniTest::Spec
115115
assert_instance_of Hash, doc.as_json
116116
end
117117

118-
it "includes the doc's name, slug, type, release, index_path and db_path" do
119-
%w(name slug type release index_path db_path links).each do |attribute|
118+
it "includes the doc's name, slug, type, and release" do
119+
%w(name slug type release links).each do |attribute|
120120
eval "stub(doc).#{attribute} { attribute }"
121121
assert_equal attribute, doc.as_json[attribute.to_sym]
122122
end

0 commit comments

Comments
 (0)