dato 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +42 -5
- data/.travis.yml +1 -0
- data/Gemfile +1 -1
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/bin/rspec +6 -6
- data/dato.gemspec +1 -1
- data/exe/dato +3 -3
- data/lib/dato.rb +8 -8
- data/lib/dato/account/client.rb +2 -2
- data/lib/dato/api_client.rb +39 -43
- data/lib/dato/api_error.rb +10 -13
- data/lib/dato/cli.rb +18 -18
- data/lib/dato/dump/dsl/add_to_data_file.rb +1 -1
- data/lib/dato/dump/dsl/create_data_file.rb +1 -1
- data/lib/dato/dump/dsl/create_post.rb +1 -1
- data/lib/dato/dump/dsl/directory.rb +4 -4
- data/lib/dato/dump/dsl/root.rb +7 -7
- data/lib/dato/dump/format.rb +3 -3
- data/lib/dato/dump/format/json.rb +1 -1
- data/lib/dato/dump/format/toml.rb +6 -6
- data/lib/dato/dump/format/yaml.rb +3 -3
- data/lib/dato/dump/operation/add_to_data_file.rb +4 -4
- data/lib/dato/dump/operation/create_data_file.rb +3 -3
- data/lib/dato/dump/operation/create_post.rb +5 -6
- data/lib/dato/dump/operation/directory.rb +1 -1
- data/lib/dato/dump/runner.rb +5 -5
- data/lib/dato/dump/ssg_detector.rb +18 -20
- data/lib/dato/json_api_deserializer.rb +15 -16
- data/lib/dato/json_api_serializer.rb +30 -21
- data/lib/dato/json_schema_relationships.rb +19 -23
- data/lib/dato/json_schema_type.rb +47 -0
- data/lib/dato/local/entities_repo.rb +3 -3
- data/lib/dato/local/field_type/color.rb +11 -7
- data/lib/dato/local/field_type/file.rb +18 -24
- data/lib/dato/local/field_type/gallery.rb +1 -1
- data/lib/dato/local/field_type/global_seo.rb +4 -7
- data/lib/dato/local/field_type/lat_lon.rb +1 -1
- data/lib/dato/local/field_type/seo.rb +1 -1
- data/lib/dato/local/field_type/structured_text.rb +4 -10
- data/lib/dato/local/field_type/theme.rb +2 -2
- data/lib/dato/local/field_type/upload_id.rb +5 -5
- data/lib/dato/local/field_type/video.rb +9 -15
- data/lib/dato/local/item.rb +13 -12
- data/lib/dato/local/items_repo.rb +12 -18
- data/lib/dato/local/json_api_entity.rb +4 -3
- data/lib/dato/local/loader.rb +30 -31
- data/lib/dato/local/site.rb +5 -4
- data/lib/dato/paginator.rb +4 -4
- data/lib/dato/repo.rb +23 -30
- data/lib/dato/site/client.rb +5 -5
- data/lib/dato/upload/create_upload_path.rb +7 -10
- data/lib/dato/upload/file.rb +3 -3
- data/lib/dato/upload/image.rb +1 -1
- data/lib/dato/utils/build_modular_block.rb +4 -4
- data/lib/dato/utils/favicon_tags_builder.rb +10 -10
- data/lib/dato/utils/locale_value.rb +1 -1
- data/lib/dato/utils/meta_tags/article_modified_time.rb +3 -3
- data/lib/dato/utils/meta_tags/article_publisher.rb +2 -2
- data/lib/dato/utils/meta_tags/base.rb +6 -6
- data/lib/dato/utils/meta_tags/description.rb +4 -4
- data/lib/dato/utils/meta_tags/image.rb +4 -5
- data/lib/dato/utils/meta_tags/og_locale.rb +2 -2
- data/lib/dato/utils/meta_tags/og_site_name.rb +2 -2
- data/lib/dato/utils/meta_tags/og_type.rb +3 -3
- data/lib/dato/utils/meta_tags/robots.rb +2 -2
- data/lib/dato/utils/meta_tags/title.rb +6 -6
- data/lib/dato/utils/meta_tags/twitter_card.rb +2 -2
- data/lib/dato/utils/meta_tags/twitter_site.rb +2 -2
- data/lib/dato/utils/seo_tags_builder.rb +12 -12
- data/lib/dato/version.rb +1 -1
- metadata +7 -6
    
        data/lib/dato/repo.rb
    CHANGED
    
    | @@ -1,18 +1,18 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 4 | 
            -
            require  | 
| 5 | 
            -
            require  | 
| 3 | 
            +
            require "dato/json_api_serializer"
         | 
| 4 | 
            +
            require "dato/json_api_deserializer"
         | 
| 5 | 
            +
            require "dato/paginator"
         | 
| 6 6 |  | 
| 7 7 | 
             
            module Dato
         | 
| 8 8 | 
             
              class Repo
         | 
| 9 9 | 
             
                attr_reader :client, :type, :schema
         | 
| 10 10 |  | 
| 11 | 
            -
                IDENTITY_REGEXP = /\{\(.*?definitions%2F(.*?)%2Fdefinitions%2Fidentity\)} | 
| 11 | 
            +
                IDENTITY_REGEXP = /\{\(.*?definitions%2F(.*?)%2Fdefinitions%2Fidentity\)}/.freeze
         | 
| 12 12 |  | 
| 13 13 | 
             
                METHOD_NAMES = {
         | 
| 14 | 
            -
                   | 
| 15 | 
            -
                   | 
| 14 | 
            +
                  "instances" => :all,
         | 
| 15 | 
            +
                  "self" => :find,
         | 
| 16 16 | 
             
                }.freeze
         | 
| 17 17 |  | 
| 18 18 | 
             
                def initialize(client, type, schema)
         | 
| @@ -32,23 +32,23 @@ module Dato | |
| 32 32 | 
             
                private
         | 
| 33 33 |  | 
| 34 34 | 
             
                def method_missing(method, *args, &block)
         | 
| 35 | 
            -
                  link = schema.links.find do | | 
| 36 | 
            -
                    METHOD_NAMES.fetch( | 
| 35 | 
            +
                  link = schema.links.find do |ilink|
         | 
| 36 | 
            +
                    METHOD_NAMES.fetch(ilink.rel, ilink.rel).to_sym == method.to_sym
         | 
| 37 37 | 
             
                  end
         | 
| 38 38 |  | 
| 39 | 
            -
                  return super  | 
| 39 | 
            +
                  return super unless link
         | 
| 40 40 |  | 
| 41 41 | 
             
                  min_arguments_count = [
         | 
| 42 42 | 
             
                    link.href.scan(IDENTITY_REGEXP).size,
         | 
| 43 | 
            -
                    link.schema && link.method != :get ? 1 : 0
         | 
| 43 | 
            +
                    link.schema && link.method != :get ? 1 : 0,
         | 
| 44 44 | 
             
                  ].reduce(0, :+)
         | 
| 45 45 |  | 
| 46 | 
            -
                  (args.size >= min_arguments_count)  | 
| 47 | 
            -
                    raise | 
| 46 | 
            +
                  (args.size >= min_arguments_count) ||
         | 
| 47 | 
            +
                    raise(ArgumentError, "wrong number of arguments (given #{args.size}, expected #{min_arguments_count})")
         | 
| 48 48 |  | 
| 49 49 | 
             
                  placeholders = []
         | 
| 50 50 |  | 
| 51 | 
            -
                  url = link[ | 
| 51 | 
            +
                  url = link["href"].gsub(IDENTITY_REGEXP) do |_stuff|
         | 
| 52 52 | 
             
                    placeholder = args.shift.to_s
         | 
| 53 53 | 
             
                    placeholders << placeholder
         | 
| 54 54 | 
             
                    placeholder
         | 
| @@ -61,19 +61,16 @@ module Dato | |
| 61 61 | 
             
                    body = link.schema ? args.shift : {}
         | 
| 62 62 | 
             
                    query_string = args.shift || {}
         | 
| 63 63 |  | 
| 64 | 
            -
                  elsif link.method | 
| 65 | 
            -
                    query_string = args.shift || {}
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                  elsif link.method == :get
         | 
| 64 | 
            +
                  elsif %i[get delete].include?(link.method)
         | 
| 68 65 | 
             
                    query_string = args.shift || {}
         | 
| 69 66 | 
             
                  end
         | 
| 70 67 |  | 
| 71 68 | 
             
                  options = args.any? ? args.shift.symbolize_keys : {}
         | 
| 72 69 |  | 
| 73 70 | 
             
                  if link.schema && %i[post put].include?(link.method) && options.fetch(:serialize_response, true)
         | 
| 74 | 
            -
                    body = JsonApiSerializer.new( | 
| 71 | 
            +
                    body = JsonApiSerializer.new(link: link).serialize(
         | 
| 75 72 | 
             
                      body,
         | 
| 76 | 
            -
                      link.method == :post ? nil : placeholders.last
         | 
| 73 | 
            +
                      link.method == :post ? nil : placeholders.last,
         | 
| 77 74 | 
             
                    )
         | 
| 78 75 | 
             
                  end
         | 
| 79 76 |  | 
| @@ -92,21 +89,19 @@ module Dato | |
| 92 89 | 
             
                  if response && response[:data] && response[:data].is_a?(Hash) && response[:data][:type] == "job"
         | 
| 93 90 | 
             
                    job_result = nil
         | 
| 94 91 |  | 
| 95 | 
            -
                     | 
| 92 | 
            +
                    until job_result
         | 
| 96 93 | 
             
                      begin
         | 
| 97 94 | 
             
                        sleep(1)
         | 
| 98 95 | 
             
                        job_result = client.job_result.find(response[:data][:id])
         | 
| 99 | 
            -
                      rescue ApiError =>  | 
| 100 | 
            -
                        if  | 
| 101 | 
            -
                          raise error
         | 
| 102 | 
            -
                        end
         | 
| 96 | 
            +
                      rescue ApiError => e
         | 
| 97 | 
            +
                        raise e if e.response[:status] != 404
         | 
| 103 98 | 
             
                      end
         | 
| 104 99 | 
             
                    end
         | 
| 105 100 |  | 
| 106 101 | 
             
                    if job_result[:status] < 200 || job_result[:status] >= 300
         | 
| 107 102 | 
             
                      error = ApiError.new(
         | 
| 108 103 | 
             
                        status: job_result[:status],
         | 
| 109 | 
            -
                        body: JSON.dump(job_result[:payload])
         | 
| 104 | 
            +
                        body: JSON.dump(job_result[:payload]),
         | 
| 110 105 | 
             
                      )
         | 
| 111 106 |  | 
| 112 107 | 
             
                      puts "===="
         | 
| @@ -121,12 +116,10 @@ module Dato | |
| 121 116 | 
             
                    else
         | 
| 122 117 | 
             
                      job_result.payload
         | 
| 123 118 | 
             
                    end
         | 
| 119 | 
            +
                  elsif options.fetch(:deserialize_response, true)
         | 
| 120 | 
            +
                    JsonApiDeserializer.new(link.target_schema).deserialize(response)
         | 
| 124 121 | 
             
                  else
         | 
| 125 | 
            -
                     | 
| 126 | 
            -
                      JsonApiDeserializer.new(link.target_schema).deserialize(response)
         | 
| 127 | 
            -
                    else
         | 
| 128 | 
            -
                      response
         | 
| 129 | 
            -
                    end
         | 
| 122 | 
            +
                    response
         | 
| 130 123 | 
             
                  end
         | 
| 131 124 | 
             
                end
         | 
| 132 125 | 
             
              end
         | 
    
        data/lib/dato/site/client.rb
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 4 | 
            -
            require  | 
| 5 | 
            -
            require  | 
| 3 | 
            +
            require "dato/api_client"
         | 
| 4 | 
            +
            require "dato/upload/file"
         | 
| 5 | 
            +
            require "dato/upload/create_upload_path"
         | 
| 6 6 |  | 
| 7 7 | 
             
            module Dato
         | 
| 8 8 | 
             
              module Site
         | 
| 9 9 | 
             
                class Client
         | 
| 10 10 | 
             
                  include ApiClient
         | 
| 11 11 |  | 
| 12 | 
            -
                  json_schema  | 
| 12 | 
            +
                  json_schema "site-api"
         | 
| 13 13 |  | 
| 14 14 | 
             
                  def create_upload_path(path_or_url)
         | 
| 15 15 | 
             
                    file = Upload::CreateUploadPath.new(self, path_or_url)
         | 
| @@ -30,7 +30,7 @@ module Dato | |
| 30 30 | 
             
                    request(
         | 
| 31 31 | 
             
                      :post,
         | 
| 32 32 | 
             
                      "/pusher/authenticate",
         | 
| 33 | 
            -
                      { socket_id: socket_id, channel_name: channel}
         | 
| 33 | 
            +
                      { socket_id: socket_id, channel_name: channel },
         | 
| 34 34 | 
             
                    )
         | 
| 35 35 | 
             
                  end
         | 
| 36 36 | 
             
                end
         | 
| @@ -1,9 +1,9 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 4 | 
            -
            require  | 
| 5 | 
            -
            require  | 
| 6 | 
            -
            require  | 
| 3 | 
            +
            require "mime/types"
         | 
| 4 | 
            +
            require "tempfile"
         | 
| 5 | 
            +
            require "addressable"
         | 
| 6 | 
            +
            require "net/http"
         | 
| 7 7 |  | 
| 8 8 | 
             
            module Dato
         | 
| 9 9 | 
             
              module Upload
         | 
| @@ -19,7 +19,7 @@ module Dato | |
| 19 19 | 
             
                    @file ||= if http_source?
         | 
| 20 20 | 
             
                                uri = Addressable::URI.parse(source)
         | 
| 21 21 | 
             
                                ext = ::File.extname(uri.path).downcase
         | 
| 22 | 
            -
                                tempfile = Tempfile.new([ | 
| 22 | 
            +
                                tempfile = Tempfile.new(["file", ext])
         | 
| 23 23 | 
             
                                tempfile.binmode
         | 
| 24 24 | 
             
                                tempfile.write(download_file(source))
         | 
| 25 25 | 
             
                                tempfile.rewind
         | 
| @@ -31,7 +31,7 @@ module Dato | |
| 31 31 |  | 
| 32 32 | 
             
                  def http_source?
         | 
| 33 33 | 
             
                    uri = Addressable::URI.parse(source)
         | 
| 34 | 
            -
                    uri.scheme ==  | 
| 34 | 
            +
                    uri.scheme == "http" || uri.scheme == "https"
         | 
| 35 35 | 
             
                  rescue Addressable::URI::InvalidURIError
         | 
| 36 36 | 
             
                    false
         | 
| 37 37 | 
             
                  end
         | 
| @@ -51,9 +51,7 @@ module Dato | |
| 51 51 | 
             
                    mime_type = MIME::Types.of(filename).first
         | 
| 52 52 |  | 
| 53 53 | 
             
                    request = Net::HTTP::Put.new(uri)
         | 
| 54 | 
            -
                    if mime_type
         | 
| 55 | 
            -
                      request.add_field("Content-Type", mime_type.to_s)
         | 
| 56 | 
            -
                    end
         | 
| 54 | 
            +
                    request.add_field("Content-Type", mime_type.to_s) if mime_type
         | 
| 57 55 | 
             
                    request.body = file.read
         | 
| 58 56 |  | 
| 59 57 | 
             
                    http = Net::HTTP.new(uri.host, uri.port)
         | 
| @@ -78,4 +76,3 @@ module Dato | |
| 78 76 | 
             
                end
         | 
| 79 77 | 
             
              end
         | 
| 80 78 | 
             
            end
         | 
| 81 | 
            -
             | 
    
        data/lib/dato/upload/file.rb
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 3 | 
            +
            require "dato/upload/create_upload_path"
         | 
| 4 4 |  | 
| 5 5 | 
             
            module Dato
         | 
| 6 6 | 
             
              module Upload
         | 
| @@ -18,14 +18,14 @@ module Dato | |
| 18 18 | 
             
                    upload_path = CreateUploadPath.new(client, source).upload_path
         | 
| 19 19 |  | 
| 20 20 | 
             
                    upload = client.uploads.create(
         | 
| 21 | 
            -
                      upload_attributes.merge(path: upload_path)
         | 
| 21 | 
            +
                      upload_attributes.merge(path: upload_path),
         | 
| 22 22 | 
             
                    )
         | 
| 23 23 |  | 
| 24 24 | 
             
                    {
         | 
| 25 25 | 
             
                      alt: nil,
         | 
| 26 26 | 
             
                      title: nil,
         | 
| 27 27 | 
             
                      custom_data: {},
         | 
| 28 | 
            -
                    }.merge(field_attributes).merge(upload_id: upload[ | 
| 28 | 
            +
                    }.merge(field_attributes).merge(upload_id: upload["id"])
         | 
| 29 29 | 
             
                  end
         | 
| 30 30 | 
             
                end
         | 
| 31 31 | 
             
              end
         | 
    
        data/lib/dato/upload/image.rb
    CHANGED
    
    
| @@ -1,22 +1,22 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 3 | 
            +
            require "dato/json_api_serializer"
         | 
| 4 4 |  | 
| 5 5 | 
             
            module Dato
         | 
| 6 6 | 
             
              module Utils
         | 
| 7 7 | 
             
                module BuildModularBlock
         | 
| 8 8 | 
             
                  def self.build(unserialized_body)
         | 
| 9 | 
            -
                    json_api_serializer = JsonApiSerializer.new( | 
| 9 | 
            +
                    json_api_serializer = JsonApiSerializer.new(type: "item")
         | 
| 10 10 | 
             
                    attributes = json_api_serializer.serialized_attributes(unserialized_body)
         | 
| 11 11 |  | 
| 12 12 | 
             
                    payload = {
         | 
| 13 | 
            -
                      type:  | 
| 13 | 
            +
                      type: "item",
         | 
| 14 14 | 
             
                      attributes: attributes,
         | 
| 15 15 | 
             
                      relationships: {
         | 
| 16 16 | 
             
                        item_type: {
         | 
| 17 17 | 
             
                          data: {
         | 
| 18 18 | 
             
                            id: unserialized_body[:item_type],
         | 
| 19 | 
            -
                            type:  | 
| 19 | 
            +
                            type: "item_type",
         | 
| 20 20 | 
             
                          },
         | 
| 21 21 | 
             
                        },
         | 
| 22 22 | 
             
                      },
         | 
| @@ -20,7 +20,7 @@ module Dato | |
| 20 20 | 
             
                      build_apple_icon_tags,
         | 
| 21 21 | 
             
                      build_windows_tags,
         | 
| 22 22 | 
             
                      build_color_tags,
         | 
| 23 | 
            -
                      build_app_name_tag
         | 
| 23 | 
            +
                      build_app_name_tag,
         | 
| 24 24 | 
             
                    ].flatten.compact
         | 
| 25 25 | 
             
                  end
         | 
| 26 26 |  | 
| @@ -29,9 +29,9 @@ module Dato | |
| 29 29 |  | 
| 30 30 | 
             
                    APPLE_TOUCH_ICON_SIZES.map do |size|
         | 
| 31 31 | 
             
                      link_tag(
         | 
| 32 | 
            -
                         | 
| 32 | 
            +
                        "apple-touch-icon",
         | 
| 33 33 | 
             
                        url(size),
         | 
| 34 | 
            -
                        sizes: "#{size}x#{size}"
         | 
| 34 | 
            +
                        sizes: "#{size}x#{size}",
         | 
| 35 35 | 
             
                      )
         | 
| 36 36 | 
             
                    end
         | 
| 37 37 | 
             
                  end
         | 
| @@ -41,10 +41,10 @@ module Dato | |
| 41 41 |  | 
| 42 42 | 
             
                    ICON_SIZES.map do |size|
         | 
| 43 43 | 
             
                      link_tag(
         | 
| 44 | 
            -
                         | 
| 44 | 
            +
                        "icon",
         | 
| 45 45 | 
             
                        url(size),
         | 
| 46 46 | 
             
                        sizes: "#{size}x#{size}",
         | 
| 47 | 
            -
                        type: "image/#{site.favicon.format}"
         | 
| 47 | 
            +
                        type: "image/#{site.favicon.format}",
         | 
| 48 48 | 
             
                      )
         | 
| 49 49 | 
             
                    end
         | 
| 50 50 | 
             
                  end
         | 
| @@ -58,15 +58,15 @@ module Dato | |
| 58 58 | 
             
                  end
         | 
| 59 59 |  | 
| 60 60 | 
             
                  def build_app_name_tag
         | 
| 61 | 
            -
                    meta_tag( | 
| 61 | 
            +
                    meta_tag("application-name", site.name)
         | 
| 62 62 | 
             
                  end
         | 
| 63 63 |  | 
| 64 64 | 
             
                  def build_color_tags
         | 
| 65 65 | 
             
                    return unless theme_color
         | 
| 66 66 |  | 
| 67 67 | 
             
                    [
         | 
| 68 | 
            -
                      meta_tag( | 
| 69 | 
            -
                      meta_tag( | 
| 68 | 
            +
                      meta_tag("theme-color", theme_color),
         | 
| 69 | 
            +
                      meta_tag("msapplication-TileColor", theme_color),
         | 
| 70 70 | 
             
                    ]
         | 
| 71 71 | 
             
                  end
         | 
| 72 72 |  | 
| @@ -75,11 +75,11 @@ module Dato | |
| 75 75 | 
             
                  end
         | 
| 76 76 |  | 
| 77 77 | 
             
                  def meta_tag(name, value)
         | 
| 78 | 
            -
                    { tag_name:  | 
| 78 | 
            +
                    { tag_name: "meta", attributes: { name: name, content: value } }
         | 
| 79 79 | 
             
                  end
         | 
| 80 80 |  | 
| 81 81 | 
             
                  def link_tag(rel, href, attrs = {})
         | 
| 82 | 
            -
                    { tag_name:  | 
| 82 | 
            +
                    { tag_name: "link", attributes: attrs.merge(rel: rel, href: href) }
         | 
| 83 83 | 
             
                  end
         | 
| 84 84 | 
             
                end
         | 
| 85 85 | 
             
              end
         | 
| @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 4 | 
            -
            require  | 
| 3 | 
            +
            require "dato/utils/meta_tags/base"
         | 
| 4 | 
            +
            require "time"
         | 
| 5 5 |  | 
| 6 6 | 
             
            module Dato
         | 
| 7 7 | 
             
              module Utils
         | 
| 8 8 | 
             
                module MetaTags
         | 
| 9 9 | 
             
                  class ArticleModifiedTime < Base
         | 
| 10 10 | 
             
                    def build
         | 
| 11 | 
            -
                      og_tag( | 
| 11 | 
            +
                      og_tag("article:modified_time", item.updated_at.iso8601) if item
         | 
| 12 12 | 
             
                    end
         | 
| 13 13 | 
             
                  end
         | 
| 14 14 | 
             
                end
         | 
| @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 3 | 
            +
            require "dato/utils/meta_tags/base"
         | 
| 4 4 |  | 
| 5 5 | 
             
            module Dato
         | 
| 6 6 | 
             
              module Utils
         | 
| 7 7 | 
             
                module MetaTags
         | 
| 8 8 | 
             
                  class ArticlePublisher < Base
         | 
| 9 9 | 
             
                    def build
         | 
| 10 | 
            -
                      og_tag( | 
| 10 | 
            +
                      og_tag("article:publisher", facebook_page_url) if facebook_page_url
         | 
| 11 11 | 
             
                    end
         | 
| 12 12 |  | 
| 13 13 | 
             
                    def facebook_page_url
         | 
| @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 4 | 
            -
            require  | 
| 5 | 
            -
            require  | 
| 3 | 
            +
            require "forwardable"
         | 
| 4 | 
            +
            require "dato/local/field_type/seo"
         | 
| 5 | 
            +
            require "active_support/core_ext/object/blank"
         | 
| 6 6 |  | 
| 7 7 | 
             
            module Dato
         | 
| 8 8 | 
             
              module Utils
         | 
| @@ -19,7 +19,7 @@ module Dato | |
| 19 19 | 
             
                      fallback_seo = site.global_seo && site.global_seo.fallback_seo
         | 
| 20 20 |  | 
| 21 21 | 
             
                      seo_field = item &&
         | 
| 22 | 
            -
                                  item.fields.detect { |f| f.field_type ==  | 
| 22 | 
            +
                                  item.fields.detect { |f| f.field_type == "seo" }
         | 
| 23 23 |  | 
| 24 24 | 
             
                      item_seo_value = seo_field &&
         | 
| 25 25 | 
             
                                       item[seo_field.api_key] &&
         | 
| @@ -36,11 +36,11 @@ module Dato | |
| 36 36 | 
             
                    end
         | 
| 37 37 |  | 
| 38 38 | 
             
                    def meta_tag(name, content)
         | 
| 39 | 
            -
                      tag( | 
| 39 | 
            +
                      tag("meta", name: name, content: content)
         | 
| 40 40 | 
             
                    end
         | 
| 41 41 |  | 
| 42 42 | 
             
                    def og_tag(property, content)
         | 
| 43 | 
            -
                      tag( | 
| 43 | 
            +
                      tag("meta", property: property, content: content)
         | 
| 44 44 | 
             
                    end
         | 
| 45 45 |  | 
| 46 46 | 
             
                    def card_tag(name, content)
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 3 | 
            +
            require "dato/utils/meta_tags/base"
         | 
| 4 4 |  | 
| 5 5 | 
             
            module Dato
         | 
| 6 6 | 
             
              module Utils
         | 
| @@ -10,9 +10,9 @@ module Dato | |
| 10 10 | 
             
                      return unless description.present?
         | 
| 11 11 |  | 
| 12 12 | 
             
                      [
         | 
| 13 | 
            -
                        meta_tag( | 
| 14 | 
            -
                        og_tag( | 
| 15 | 
            -
                        card_tag( | 
| 13 | 
            +
                        meta_tag("description", description),
         | 
| 14 | 
            +
                        og_tag("og:description", description),
         | 
| 15 | 
            +
                        card_tag("twitter:description", description),
         | 
| 16 16 | 
             
                      ]
         | 
| 17 17 | 
             
                    end
         | 
| 18 18 |  | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 3 | 
            +
            require "dato/utils/meta_tags/base"
         | 
| 4 4 |  | 
| 5 5 | 
             
            module Dato
         | 
| 6 6 | 
             
              module Utils
         | 
| @@ -10,8 +10,8 @@ module Dato | |
| 10 10 | 
             
                      return unless image
         | 
| 11 11 |  | 
| 12 12 | 
             
                      [
         | 
| 13 | 
            -
                        og_tag( | 
| 14 | 
            -
                        card_tag( | 
| 13 | 
            +
                        og_tag("og:image", image.url),
         | 
| 14 | 
            +
                        card_tag("twitter:image", image.url),
         | 
| 15 15 | 
             
                      ]
         | 
| 16 16 | 
             
                    end
         | 
| 17 17 |  | 
| @@ -21,11 +21,10 @@ module Dato | |
| 21 21 |  | 
| 22 22 | 
             
                    def item_image
         | 
| 23 23 | 
             
                      item && item.fields
         | 
| 24 | 
            -
                                  .select { |field| field.field_type ==  | 
| 24 | 
            +
                                  .select { |field| field.field_type == "file" }
         | 
| 25 25 | 
             
                                  .map { |field| item[field.api_key] }
         | 
| 26 26 | 
             
                                  .compact
         | 
| 27 27 | 
             
                                  .find do |image|
         | 
| 28 | 
            -
             | 
| 29 28 | 
             
                                    image.width && image.height &&
         | 
| 30 29 | 
             
                                      image.width >= 200 && image.height >= 200
         | 
| 31 30 | 
             
                                  end
         |