Sha256: 7c0d2d126c6733299ae53e01b7797e6f92ab0e8fab2091c8d5227ae4b95b300a
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
module Brief::Model::Serializers def as_json(options={}) options.symbolize_keys! docs_path = options.fetch(:docs_path) { briefcase.docs_path } docs_path = docs_path.to_pathname if docs_path.is_a?(String) doc_path = path.relative_path_from(docs_path).to_s # TEMP title = data.try(:[], :title) || extracted_content.try(:title) || (send(:title) rescue nil) || path.basename.to_s.gsub(/\.html.md/,'') title = title.to_s.gsub(/\.md/,'') { data: data, extracted: extracted_content_data, path: path.to_s, type: type, group: type.to_s.pluralize, title: title, actions: self.class.defined_actions, urls: { view_content_url: "/view/content/#{ doc_path }", view_rendered_url: "/view/rendered/#{ doc_path }", view_details_url: "/view/details/#{ doc_path }", update_url: "/update/#{ doc_path }", remove_url: "/remove/#{ doc_path }", schema_url: "/schema/#{ type }", actions_url: "/actions/:action/#{ doc_path }" } }.tap do |h| h[:content] = document.combined_data_and_content if options[:content] h[:rendered] = document.to_html if options[:rendered] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
brief-1.6.1 | lib/brief/model/serializers.rb |
brief-1.6.0 | lib/brief/model/serializers.rb |
brief-1.5.2 | lib/brief/model/serializers.rb |