openaustralia/publicwhip

View on GitHub
app/views/policies/_page_header.html.haml

Summary

Maintainability
Test Coverage
- content_for :title, capitalise_initial_character(policy.name)
- set_meta_tags description: "Find out how people in parliament stand on #{policy.name}."
:ruby
  set_meta_tags og: {
    title: "See How They Vote On #{capitalise_initial_character(policy.name)}",
    description: "Find out more and see how they voted on other issues that matter to you",
    type: "website",
    url: request.original_url,
    image: {
      _: card_policy_url(policy, @cardtype),
      alt: "See How They Vote On #{capitalise_initial_character(policy.name)}",
      width: CardScreenshotter::Utils::CARD_WIDTH,
      height: CardScreenshotter::Utils::CARD_HEIGHT
    },
    site_name: Settings.project_name
  }
  set_meta_tags twitter: { card: "summary_large_image" }

.page-header.row
  %nav.header-actions.col-md-3.col-lg-2
    = link_to_if policy, "Edit", edit_policy_path(policy), title: "Change title and definition of policy", class: "link-policy-edit btn btn-default btn-xs"
    = link_to "New policy", new_policy_path, class: "link-policy-new btn btn-primary btn-xs"
  %h1.col-md-9.col-lg-10.long-title
    = yield :title
  .lead.policytext.col-md-12
    Those for this policy agree that
    = policy.description

  .header-secondary.col-sm-12
    .header-secondary-primary-block.subscribe-block
      = button_to watch_policy_path(policy), class: "btn btn-link fi-mail", form_class: "subscribe-button-form " + (current_user && current_user.watching?(policy) ? "subscribe-button-form-unsubscribe" : "subscribe-button-form-subscribe") do
        = (current_user && current_user.watching?(policy) ? "Unsubscribe" : "Subscribe")
      - if policy.watches.count > 0
        %span.subscriber-count.small
          = pluralize policy.watches.count, 'subscriber'
    -# We don't want people sharing incomplete policies
    - if policy.published?
      = render "social_share"

= render "draft_warning", policy: policy