danielweinmann/unlock

View on GitHub
app/views/initiatives/show.html.slim

Summary

Maintainability
Test Coverage
- suppress_headline_and_article!
- content_for :title do
  == strip_tags(@initiative.name)
- content_for :meta_tags do
  meta name="description" content=strip_tags(@initiative.first_text_html)
  meta name="keywords" content=strip_tags(@initiative.first_text_html)
  meta property="og:title" content=@initiative.name
  meta property="og:type" content="website"
  meta property="og:url" content=initiative_by_permalink_url(@initiative)
  meta property="og:image" content=(@initiative.image.present? ? @initiative.image.url : "#{request.protocol}#{request.host_with_port}#{image_path("logo_facebook.png")}")
  meta property="og:description" content=strip_tags(@initiative.first_text_html)
  meta name="author" content=@initiative.user.name
- content_for :pre_header do
  .image
    - if @initiative.image.present?
      = link_to image_tag(@initiative.image.url, style: "margin-top: #{@initiative.margin}"), @initiative.image.url, target: :_blank
- content_for :header do
  h1= @initiative.name
  - if @initiative.first_text.present?
    section.first_text= @initiative.first_text_html
- content_for :post_header do
  section.status
    h2
      span.currency= @initiative.display_currency
      span.number= @initiative.total_value
      div= Initiative.human_attribute_name(:total_value).downcase
    h2
      span.number= @initiative.total_contributions
      div
        - words = Initiative.human_attribute_name(:total_contributions).downcase.split(' ')
        = words[0].pluralize(@initiative.total_contributions)
        = " "
        = link_to words[1].pluralize(@initiative.total_contributions), initiative_contributions_path(@initiative.id)
article id=dom_id(@initiative) data-url=initiative_path(@initiative.id)
  - if @initiative.can_contribute?
    section.contribute
      a.button href=new_initiative_contribution_path(@initiative.id)
        = t('contribute')
  - if @initiative.second_text.present?
    section.second_text= @initiative.second_text_html
    - if @initiative.second_text.length > 400 && @initiative.can_contribute?
      section.contribute
        a.button href=new_initiative_contribution_path(@initiative.id)
          = t('contribute')
  - if policy(@initiative).update?
    section.actions
      .action= link_to t('devise.registrations.edit.title', resource: nil), edit_initiative_path(@initiative.id), class: 'button'
      .action= link_to Gateway.model_name.human.pluralize, initiative_gateways_path(@initiative.id), class: 'button'
      - if @initiative.can_publish?
        .action= link_to t('activerecord.state_machines.initiative.state.events.publish'), publish_initiative_path(@initiative.id), method: :put, data: { confirm: t('confirm') }, class: 'button'
      - if @initiative.can_revert_to_draft?
        .action= link_to t('activerecord.state_machines.initiative.state.events.revert_to_draft'), revert_to_draft_initiative_path(@initiative.id), method: :put, data: { confirm: t('confirm') }, class: 'button'
      - if policy(@initiative).destroy?
        .action= link_to t('destroy'), initiative_path(@initiative.id), method: :delete, data: { confirm: t('confirm') }, class: "button careful"