= content_for :title, "#{@garden.owner}'s #{@garden}"

- content_for :opengraph do
  = tag("meta", property: "og:image", content: garden_image_path(@garden))
  - if @garden.description
    = tag("meta", property: "og:description", content: og_description(@garden.description))
  = tag("meta", property: "og:title", content: "#{@garden.owner}'s #{@garden}")
  = tag("meta", property: "og:type", content: "website")
  = tag("meta", property: "og:url", content: request.original_url)
  = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])

- content_for :breadcrumbs do
  %li.breadcrumb-item= link_to 'Gardens', gardens_path
  %li.breadcrumb-item.active= link_to @garden.name, gardens_path(@garden)

.row
  .col-md-9.col-12
    %h2.h1
      %strong= @garden
  .col-md-3.col-12
    = render 'gardens/actions', garden: @garden
.row
  .col-md-9
    - unless @garden.active
      .alert.alert-warning
        This garden is inactive.
        - if can? :edit, @garden
          = link_to 'Set it to active', edit_garden_path(@garden)
          to plant something in this garden.
    %div
      %p
        :markdown
          #{strip_tags markdownify(@garden.description)}
        - unless @garden.description
          .row-fluid
            %p No description available yet.

            - if can? :edit, @garden
              %p
                Why not
                = link_to 'tell us more.', edit_garden_path(@garden)

    - if @garden.plantings.where.not(planted_at: nil).any?
      %section.card
        %h2 Garden progress
        .card-body
          = render 'plantings/progress_list', plantings: @garden.plantings.active

    %section
      %h2 Current plantings in garden
      .index-cards
        - if @current_plantings.size.positive?
          - @current_plantings.each do |planting|
            = render "plantings/card", planting: planting
        - else
          .col-md-12
            %p Nothing is currently planted here.

    %section
      %h2 Current activities in garden
      .index-cards
        - if @current_activities&.size&.positive?
          - @current_activities.each do |activity|
            = render "activities/card", activity: activity
        - else
          .col-md-12
            %p Nothing is currently planned here.

    - if @suggested_companions.any?
      %section.companions
        %h2 Suggestioned companions
        - @suggested_companions.each do |companion|
          = render 'crops/tiny', crop: companion

    %section= render 'previously'

  .col-md-3
    .card
      .card-image
        = image_tag garden_image_path(@garden), class: 'img-card', alt: 'photo of this garden'
      .card-body
        %h4 About this garden
        %p
          %strong Owner:
          = link_to @garden.owner, @garden.owner
        - if @garden.location.present?
          %p
            %strong Location:
            = @garden.location
        - if @garden.area.present?
          %p
            %strong Area:
            = pluralize(@garden.area, @garden.area_unit)
        - if @garden.garden_type.present?
          %p
            %strong Garden type:
            = @garden.garden_type.name

    .card
      .card-header
        %h4 #{@garden.owner}'s gardens
      .card-body
        %ul.list-group.list-group-flush
          - @garden.owner.gardens.active.order_by_name.each do |garden|
            %li.list-group-item.list-group-flush
              = garden_icon
              - if @garden == garden
                = @garden
              - else
                = link_to garden, garden_path(garden)

    - unless @garden.owner.gardens.inactive.empty?
      %h4 Inactive gardens
      %ul
        - @garden.owner.gardens.inactive.order_by_name.each do |othergarden|
          %li
            - if @garden == othergarden
              = @garden.name
            - else
              = link_to othergarden, garden_path(othergarden)

    - if @garden.owner == current_member
      %p
        = link_to new_garden_path, class: 'btn btn-default btn-xs' do
          Add New Garden

    - if can?(:edit, @garden) && can?(:create, Photo)
      %%p
        = add_photo_button(@garden)

    - if @garden.photos.size.positive?
      %section.photos
        %h2= localize_plural(@garden.photos, Photo)
        .index-cards
          - @garden.photos.includes(:owner).each do |photo|
            = render 'photos/thumbnail', photo: photo
