- content_for :title, @member.login_name
- content_for :meta_description do
  - if @member.bio.present?
    = @member.bio
  - else
    = "Gardening profile for #{@member.login_name}."
- content_for :opengraph do
  = tag("meta", property: "og:image", content: avatar_uri(@member, 200))
  = tag("meta", property: "og:image:user_generated", content: "true")
  = tag("meta", property: "og:title", content: @member.login_name)
  = tag("meta", property: "og:type", content: "profile")
  = tag("meta", property: "og:url", content: request.original_url)
  = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])

- content_for :member_rss_login_name, @member.login_name
- content_for :member_rss_slug, @member.slug

- content_for :breadcrumbs do
  %li.breadcrumb-item= link_to 'Members', members_path
  %li.breadcrumb-item.active= link_to @member.login_name, member_path(@member)

.row
  .col-md-2
    .card
      .card-body
        .row
          .col= render "bio", member: @member
          .col= render "avatar", member: @member
        .row
          .col
            %p
              %small
                %a{href: "#content"}
                  Skip to main content
            - if @member.bio.blank?
              - if member_signed_in? && current_member == @member
                = link_to "Add a bio to complete your profile.", edit_member_registration_path
              - else
                #{@member.login_name} hasn't written a bio yet.
            - else
              :markdown
                #{ strip_tags markdownify(@member.bio) }

        - if @member.roles.any?
          %p
            - @member.roles.each do |role|
              %span.badge.badge-info= role.name.titleize
        - if @member.location.present?
          %p.badge.badge-location{ title: @member.location }
            = icon 'fas', 'map-marker'
            = truncate(@member.location, length: 15, separator: ' ', omission: '... ')
        %p
          %small
            %strong Member since
            %br
            = @member.created_at.to_fs(:date)
        - if @member.last_sign_in_at
          %p
            %small
              %strong Last Login
              %br
              = @member.last_sign_in_at&.to_fs(:default)

        - if can? :update, @member
          = link_to edit_member_registration_path, class: 'btn btn-block' do
            = member_icon
            = t('members.edit_profile')

        - if can?(:create, Notification) && current_member != @member
          = link_to new_message_path(recipient_id: @member.id), class: 'btn btn-block' do
            = icon('fas', 'envelope')
            Send message

        = render 'members/follow_buttons', member: @member

        - if can?(:destroy, @member)
          %hr/
          = link_to admin_member_path(slug: @member.slug), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-block btn-light text-danger' do
            = icon 'fas', 'ban'
            Ban member
          %hr/

      = render "stats", member: @member
      .card-footer
        = render "contact", member: @member, flickr_auth: @flickr_auth

  .col-md-10#content
    .row
      %section.order-3.order-md-1.col-12= render "map", member: @member
      - if @harvesting.size.positive? 
        %section.harvests.order-2.order-md-1.col-12#harvests
          %h2 Ready to harvest
          .index-cards
            - @harvesting.each do |planting|
              = render 'plantings/thumbnail', planting: planting

      - if @others.size.positive?
        %section.planting-progress.order-2.order-md-1.col-12#planting-progress
          %h2 Progress report
          %p Still growing and not ready for harvesting.
          .list-group
            - @others.each do |planting|
              .list-group-item
                %span= render 'plantings/tiny', planting: planting
                %span= render 'plantings/progress', planting: planting
      - if @late.size.positive?
        %section.late.order-2.order-md-1.col-12#late
          %h2 Late
          %p
            These plantings are at the end of their lifecycle.
            - if member_signed_in? && @member == current_member
              %strong When you have removed the planting from your garden, mark the planting as finished in Growstuff.
          .index-cards
            - @late.each do |planting|
              = render 'plantings/thumbnail', planting: planting
      - if @super_late.any?
        %section.superlate.order-2.order-md-1.col-12#superlate
          %h2 Super late
          %p
            We suspect the following plantings finished long ago and no longer need tracking.
            - if member_signed_in? && current_member == @member
              %strong You can mark these plantings as finished to stop tracking.
          %ul
            - @super_late.each do |planting|
              %li
                = link_to planting.crop_name, planting_url(slug: planting.slug)
                planted on #{planting.planted_at.to_date}

      - if @harvests.any?
        %section.havests.order-2.order-md-1.col-12#recent-harvests
          %h2 Recent Harvests
          .index-cards
            - @harvests.each do |harvest|
              = render 'harvests/thumbnail', harvest: harvest

      - if @activity.any?
        %section.activity.order-2.order-md-1.col-12#activity
          %h2 Activity
          .list-group
            - @activity.each do |event|
              .list-group-item.list-group-item-action.flex-column.align-items-start{:href => "#!"}
                .d-flex.w-100.justify-content-between
                  %h5.col-md-11.col-xs-10.text-truncate
                    = icon_for_model(event.event_type)
                    = event_description(event)
                    = render 'timeline/photos', photo: resolve_model(event) if event.event_type == 'photo'
                  %small.col-md-1.col-xs-2.text-right
                    - if event.event_at.present?
                      - if event.event_at.kind_of?(Date)
                        #{distance_of_time_in_words(event.event_at, Time.zone.now.to_date)} ago
                      - else
                        #{time_ago_in_words(event.event_at)} ago
                    - else
                      unknown date
