Sha256: 00b3d9825d3142f934c6260c5f77384eb3edea2eab013b08e2730bfe87c67dd9
Contents?: true
Size: 1.34 KB
Versions: 12
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true module Spotlight ## # Exhibit feedback form class ContactForm include ActiveModel::Model attr_accessor :current_exhibit, :name, :email, Spotlight::Engine.config.spambot_honeypot_email_field, :message, :current_url, :request validates :email, format: { with: /\A([\w.%+-]+)@([\w-]+\.)+(\w{2,})\z/i } # the spambot_honeypot_email_field field is intended to be hidden visually from the user, # in hope that a spam bot filling out the form will enter a value, whereas a human with a # browser wouldn't, allowing us to differentiate and reject likely spam messages. # the field must be present, since we expect real users to just submit the form as-is w/o # hacking what fields are present. validates Spotlight::Engine.config.spambot_honeypot_email_field, length: { is: 0 } def headers { to: to, subject: I18n.t(:'spotlight.contact_form.subject', application_name: application_name), cc: contact_emails.join(', ') } end private def application_name current_exhibit&.title || Spotlight::Site.instance.title || I18n.t(:'blacklight.application_name') end def to Spotlight::Engine.config.default_contact_email || contact_emails.first.to_s end def contact_emails current_exhibit&.contact_emails || [] end end end
Version data entries
12 entries across 12 versions & 1 rubygems