Files
growstuff/app/views/crops/show.html.haml
2025-12-13 12:48:14 +10:30

198 lines
7.4 KiB
Plaintext

= render 'schema_org', crop: @crop
- content_for :title do
= @crop.name.titleize
- if @crop.default_scientific_name.present?
= " (#{@crop.default_scientific_name})"
- content_for :meta_description do
- if @crop.description.present?
= @crop.description
- else
= "Learn how to grow #{@crop.name}."
- content_for :opengraph do
= tag("meta", property: "og:image", content: crop_image_path(@crop))
= tag("meta", property: "og:title", content: @crop.name)
= 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 :scripts do
= javascript_include_tag "charts"
- content_for :breadcrumbs do
%li.breadcrumb-item= link_to 'Crops', crops_path
- if @crop.parent
%li.breadcrumb-item.active= link_to @crop.parent.name.capitalize, @crop.parent
%li.breadcrumb-item.active= link_to @crop.name.capitalize, @crop
= render 'approval_status_message', crop: @crop
.jumbotron= render 'crops/info'
.row
.col-md-9= render 'crops/actions', crop: @crop
.col-md-3= render 'wrangle', crop: @crop
.row
.col-md-9
%section.prediction
= cute_icon
= render 'predictions', crop: @crop
- if @crop.all_companions.any?
%section.companions
%h2 Companions
- @crop.all_companions.each do |companion|
= render 'crops/tiny', crop: companion
- if crop_or_parent(@crop, :en_youtube_url).present?
%section.youtube
%h2 Video
.embed-responsive.embed-responsive-16by9
%iframe.embed-responsive-item{ src: "https://www.youtube.com/embed/#{youtube_video_id(crop_or_parent(@crop, :en_youtube_url))}", allowfullscreen: true }
- else
- if member_signed_in?
%section.youtube
%h2 Video
%p= link_to "Submit a video.", edit_crop_path(@crop, anchor: ":~:text=Youtube")
%section.photos
= cute_icon
= render 'crops/photos', crop: @crop
- if @crop.plantings.any? or @crop.harvests.any?
%section.charts
.row
- if @crop.sunniness.any?
.col-lg-4.col-12
%h2 Sunniness
= pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom"
- if @crop.planted_from.any?
.col-lg-4.col-12
%h2 Planted from
= pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom"
- if @crop.harvests.any?
.col-lg-4.col-12
%h2 Harvested for
= pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom"
- if @crop.varieties.any?
%section.varieties
%h2 Varieties
.index-cards
= render 'varieties', crop: @crop
%section.crop-map
%h2
= icon 'fas', 'map'
Crop Map
%p
Only plantings by members who have set their locations are shown on this map.
- if current_member && current_member.location.blank?
= link_to "Set your location.", edit_member_registration_path
#cropmap.map
%section.posts= render 'crops/posts', crop: @crop
= render 'history', crop: @crop
.col-md-3
= cute_icon
.card
.card-body
%h4 How to grow #{@crop.name.pluralize}
= render 'grown_for', crop: @crop
- if @crop.parent
%hr/
%p.parent-crop
= @crop.name
is a variety of
= link_to @crop.parent, @crop.parent
.list-group.list-group-flush
.list-group-item.list-group-flush.d-flex.justify-content-between.align-items-center
= link_to crop_plantings_path(@crop), class: 'card-link' do
= planting_icon
#{@crop.name.capitalize} plantings
%span.badge.badge-primary.badge-pill=@crop.plantings.active.size
.list-group-item.d-flex.justify-content-between.align-items-center
= link_to crop_harvests_path(@crop), class: 'card-link' do
= harvest_icon
#{@crop.name.capitalize} harvests
%span.badge.badge-primary.badge-pill=@crop.harvests.size
.list-group-item.d-flex.justify-content-between.align-items-center
= link_to crop_seeds_path(@crop), class: 'card-link' do
= seed_icon
#{@crop.name.capitalize} seeds
%span.badge.badge-primary.badge-pill=@crop.seeds.size
- if member_signed_in?
.list-group-item.d-flex.justify-content-between.align-items-center
= link_to member_seeds_path(current_member, crop_slug: @crop.slug) do
= display_seed_availability(@current_member, @crop)
.card-body
= render 'scientific_names', crop: @crop
= render 'alternate_names', crop: @crop
= render 'plantings', crop: @crop
= render 'harvests', crop: @crop
= render 'find_seeds', crop: @crop
= render 'openfarm_data', crop: @crop
= render 'nutritional_data', crop: @crop
= cute_icon
.card
.card-body
%h3 Learn more about #{@crop.name.pluralize}
%h4.text-muted resources outside #{ENV['GROWSTUFF_SITE_NAME']}
%ul.list-group.list-group-flush
%li.list-group-item
= link_to @crop.en_wikipedia_url, target: "_blank", rel: "noopener noreferrer" do
= icon 'fas', 'external-link-alt'
Wikipedia (English)
- if @crop.public_food_key.present?
%li.list-group-item
= link_to "https://afcd.foodstandards.gov.au/fooddetails.aspx?PFKID=#{@crop.public_food_key}", target: "_blank", rel: "noopener noreferrer" do
= icon 'fas', 'external-link-alt'
Australian Food Composition Database
%li.list-group-item
= link_to "https://www.gardenate.com/plant/#{CGI.escape @crop.name}",
target: "_blank",
class: 'card-link',
rel: "noopener noreferrer" do
= icon 'fas', 'external-link-alt'
Gardenate - Planting reminders
- if current_member && current_member.location
%li.list-group-item
= link_to 'https://www.google.com/search?q=' + CGI.escape(['Growing', @crop.name, current_member.location].join(' ')),
target: "_blank",
class: 'card-link',
rel: "noopener noreferrer" do
= icon 'fas', 'external-link-alt'
Google
%li.list-group-item
= link_to 'https://chat.openai.com/?model=gpt-4o&prompt=' + CGI.escape(['How do I grow', @crop.name, "and what grows well with it? What should I plant the next season if practicing crop rotation? Explain why and add links to your sources"].join(' ')),
target: "_blank",
class: 'card-link',
rel: "noopener noreferrer" do
= icon 'fas', 'external-link-alt'
ChatGPT
%li.list-group-item
= link_to "https://wikihow.com/wikiHowTo?search=#{CGI.escape "grow #{@crop.name}" }",
target: "_blank",
class: 'card-link',
rel: "noopener noreferrer" do
= icon 'fas', 'external-link-alt'
Wikihow instructions
%li.list-group-item
= link_to "https://www.youtube.com/results?search_query=#{CGI.escape "growing #{@crop.name}"}",
target: "_blank",
class: 'card-link',
rel: "noopener noreferrer" do
= icon 'fab', 'youtube'
YouTube