/about: Obtain credits from docs metadata
Showing the changes to lib/docs (2 of 5 files). Show all
Unified · Split
| @@ -86,6 +86,14 @@ module Docs · 85 unmodified lines | |||
| 86 | json | 86 | json |
| 87 | end | 87 | end |
| 88 | 88 | ||
| 89 | def as_json_extra(store) | ||
| 90 | json = self.as_json | ||
| 91 | json[:attribution] = options[:attribution].strip if self.class.method_defined?(:options) and options[:attribution].present? | ||
| 92 | json[:db_size] = store.size(self.db_path) if store.exist?(self.db_path) | ||
| 93 | json[:mtime] = store.mtime(self.meta_path).to_i if store.exist?(self.meta_path) | ||
| 94 | json | ||
| 95 | end | ||
| 96 | |||
| 89 | def store_page(store, id) | 97 | def store_page(store, id) |
| 90 | index = EntryIndex.new | 98 | index = EntryIndex.new |
| 91 | pages = PageDb.new | 99 | pages = PageDb.new |
| @@ -16,7 +16,7 @@ module Docs · 15 unmodified lines | |||
| 16 | def as_json | 16 | def as_json |
| 17 | @docs.each_with_object [] do |doc, result| | 17 | @docs.each_with_object [] do |doc, result| |
| 18 | next unless @store.exist?(doc.meta_path) | 18 | next unless @store.exist?(doc.meta_path) |
| 19 | result << JSON.parse(@store.read(doc.meta_path)) | 19 | result << doc.as_json_extra(@store) |
| 20 | end | 20 | end |
| 21 | end | 21 | end |
| 22 | 22 | ||