Module: Testimonials
- Defined in:
- lib/testimonials.rb,
lib/testimonials/engine.rb,
lib/testimonials/widget.rb,
lib/testimonials/version.rb,
lib/testimonials/configuration.rb,
lib/testimonials/prompt_helper.rb,
app/models/testimonials/testimonial.rb,
app/models/testimonials/nps_response.rb,
app/models/testimonials/prompt_event.rb,
app/helpers/testimonials/widget_helper.rb,
app/models/testimonials/application_record.rb,
app/controllers/testimonials/nps_controller.rb,
app/controllers/testimonials/media_controller.rb,
app/controllers/testimonials/events_controller.rb,
app/controllers/testimonials/widgets_controller.rb,
app/controllers/testimonials/api/base_controller.rb,
app/controllers/testimonials/api/stats_controller.rb,
app/controllers/testimonials/collection_controller.rb,
app/controllers/testimonials/application_controller.rb,
app/controllers/testimonials/testimonials_controller.rb,
app/controllers/testimonials/nps_responses_controller.rb,
lib/generators/testimonials/install/install_generator.rb,
app/controllers/testimonials/api/testimonials_controller.rb
Overview
Testimonials, reviews and NPS for Rails. An iOS-style in-app widget collects star ratings and testimonials (text or video) at moments your code chooses; a public page collects them from shareable links; NPS promoters are routed straight into the testimonial ask. Everything lands in your own database with a minimal dashboard to approve, feature, and pick best lines — and a read API to render approved testimonials wherever you like.
Defined Under Namespace
Modules: Api, Generators, PromptHelper, Widget, WidgetHelper Classes: ApplicationController, ApplicationRecord, CollectionController, Configuration, Engine, EventsController, MediaController, NpsController, NpsResponse, NpsResponsesController, PromptEvent, Testimonial, TestimonialsController, WidgetsController
Constant Summary collapse
- VERSION =
'0.4.2'
Class Method Summary collapse
-
.admin?(request) ⇒ Boolean
Can this request browse and triage submissions? Checked by every dashboard action.
- .app_name ⇒ Object
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
-
.consent_text ⇒ Object
The public-use consent line, stored verbatim when a customer allows their testimonial to be shown publicly.
-
.consent_text_for(public_use) ⇒ Object
The exact line the customer agreed to, given their public/private choice.
-
.consent_text_private ⇒ Object
The private-use line, stored when a customer allows only internal use.
-
.enabled?(request) ⇒ Boolean
Can this request see the widget and submit? Checked on the server for every public endpoint and by the helper before rendering.
-
.questions ⇒ Object
The guiding questions for the current locale, with %app filled in.
Class Method Details
.admin?(request) ⇒ Boolean
Can this request browse and triage submissions? Checked by every dashboard action.
33 34 35 |
# File 'lib/testimonials.rb', line 33 def admin?(request) !!config..call(request) end |
.app_name ⇒ Object
37 38 39 |
# File 'lib/testimonials.rb', line 37 def app_name config.app_name.presence || rails_app_name end |
.config ⇒ Object
17 18 19 |
# File 'lib/testimonials.rb', line 17 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
21 22 23 |
# File 'lib/testimonials.rb', line 21 def configure yield config end |
.consent_text ⇒ Object
The public-use consent line, stored verbatim when a customer allows their testimonial to be shown publicly. Override with config.consent_text.
54 55 56 57 58 |
# File 'lib/testimonials.rb', line 54 def config..presence || I18n.t('testimonials.consent_public', default: 'You can use my testimonial publicly in your marketing and sales.') end |
.consent_text_for(public_use) ⇒ Object
The exact line the customer agreed to, given their public/private choice.
67 68 69 |
# File 'lib/testimonials.rb', line 67 def (public_use) public_use ? : end |
.consent_text_private ⇒ Object
The private-use line, stored when a customer allows only internal use.
61 62 63 64 |
# File 'lib/testimonials.rb', line 61 def I18n.t('testimonials.consent_private', default: 'You can only use my testimonial privately in your marketing and sales.') end |
.enabled?(request) ⇒ Boolean
Can this request see the widget and submit? Checked on the server for every public endpoint and by the helper before rendering.
27 28 29 |
# File 'lib/testimonials.rb', line 27 def enabled?(request) !!config.enabled.call(request) end |
.questions ⇒ Object
The guiding questions for the current locale, with %app filled in. I18n leaves the token alone when no interpolation values are passed, so a plain gsub covers built-in, literal, and lambda-provided strings alike.
45 46 47 48 49 50 |
# File 'lib/testimonials.rb', line 45 def questions list = config.questions list = list.call if list.respond_to?(:call) list = I18n.t('testimonials.questions', default: []) if list.nil? Array(list).map { |q| q.to_s.gsub('%{app}', app_name) } end |