/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 | 86 | json |
| 87 | 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 | 97 | def store_page(store, id) |
| 90 | 98 | index = EntryIndex.new |
| 91 | 99 | pages = PageDb.new |
| @@ -16,7 +16,7 @@ module Docs · 15 unmodified lines | ||
| 16 | 16 | def as_json |
| 17 | 17 | @docs.each_with_object [] do |doc, result| |
| 18 | 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 | 20 | end |
| 21 | 21 | end |
| 22 | 22 | |