Created
July 29, 2014 17:01
-
-
Save braidn/181ffa387823c83a0bbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
include Spree::BaseHelper | |
def checkout_steps | |
states = checkout_states | |
current_index = states.index(@order.state) + 1 | |
order_title = @order.state.titleize | |
return "Step #{current_index} of #{states.length}: #{order_title}" | |
end | |
def checkout_image_url(product) | |
image = product.images.first | |
return unless image | |
image_url = image.attachment.url(:checkout) | |
# Allow to be used under other protocols | |
image_url.gsub('http://', '//') | |
end | |
def last_issue_image_url(product) | |
image = product.subscription_plan.previous_issue.image ? | |
product.subscription_plan.previous_issue.image : product.subscription_plan. | |
archived_issues.last.image | |
return "store/generic_package.jpg" if !image | |
image_url = image.attachment.url(:small) | |
# Allow to be used under other protocols | |
image_url.gsub('http://', '//') | |
end | |
def checkout_back_anchor | |
states = checkout_states | |
current_index = states.index(@order.state) | |
if 0 < current_index | |
link_to 'Back', checkout_state_path(checkout_states[current_index - 1]), :class => 'checkout-back' | |
end | |
end | |
def pretty_time(time) | |
[I18n.l(time.to_date, format: :long), | |
time.strftime("%l:%M %p")].join(" ") | |
end | |
def markdown(content) | |
options = {} | |
Kramdown::Document.new(content, options).to_html.html_safe | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment