|
|
@ -87,8 +87,15 @@ module Docs
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def store_page(store, id)
|
|
|
|
def store_page(store, id)
|
|
|
|
|
|
|
|
index = EntryIndex.new
|
|
|
|
|
|
|
|
pages = PageDb.new
|
|
|
|
|
|
|
|
|
|
|
|
store.open(path) do
|
|
|
|
store.open(path) do
|
|
|
|
if page = new.build_page(id) and store_page?(page)
|
|
|
|
if page = new.build_page(id) and store_page?(page)
|
|
|
|
|
|
|
|
index.add page[:entries]
|
|
|
|
|
|
|
|
pages.add page[:path], page[:output]
|
|
|
|
|
|
|
|
store_index(store, INDEX_FILENAME, index, false)
|
|
|
|
|
|
|
|
store_index(store, DB_FILENAME, pages, false)
|
|
|
|
store.write page[:store_path], page[:output]
|
|
|
|
store.write page[:store_path], page[:output]
|
|
|
|
true
|
|
|
|
true
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -137,11 +144,11 @@ module Docs
|
|
|
|
page[:entries].present?
|
|
|
|
page[:entries].present?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def store_index(store, filename, index)
|
|
|
|
def store_index(store, filename, index, read_write=true)
|
|
|
|
old_json = store.read(filename) || '{}'
|
|
|
|
old_json = read_write && store.read(filename) || '{}'
|
|
|
|
new_json = index.to_json
|
|
|
|
new_json = index.to_json
|
|
|
|
instrument "#{filename.remove('.json')}.doc", before: old_json, after: new_json
|
|
|
|
instrument "#{filename.remove('.json')}.doc", before: old_json, after: new_json
|
|
|
|
store.write(filename, new_json)
|
|
|
|
read_write && store.write(filename, new_json)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def store_meta(store)
|
|
|
|
def store_meta(store)
|
|
|
|