Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add time-based slides #34

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

kevinnio
Copy link

@kevinnio kevinnio commented Sep 7, 2017

This makes possible to control slides publication using timestamps. This adds three new behaviors:

  1. Slides where both starts_at and ends_at are defined are only shown if they are published and Time.current is between starts_at and ends_at.
  2. Slides that have only starts_at defined will be be shown only if they are published and starts_at is in the past.
  3. Slides where starts_at and ends_at are nil and are always shown if they are published.

Users can use the new in_time scope to get only the slides that are supposed to be visible at a given time.

Also, this adds fields to capture starts_at and ends_at for each slide in the admin UI.

@@ -31,4 +38,8 @@ def slide_link
def slide_image
!image.file? && product.present? && product.images.any? ? product.images.first.attachment : image
end

def in_time?
Time.now.between?(starts_at || 1.second.ago, ends_at || 1.second.from_now)
Copy link

@dportalesr dportalesr Sep 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Favor the use of Time.current instead of Time.now

image
Source

@kevinnio kevinnio force-pushed the master branch 3 times, most recently from 291f144 to c3e15af Compare November 30, 2017 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants