johnrees/fablabs

View on GitHub
app/views/projects/_main_cover.html.haml

Summary

Maintainability
Test Coverage
.row
  .col-lg-12.main-title
    .row.header
      .col-lg-4
        %h1= @project.title
        - if current_user
          +1:
          - if current_user.favourited? @project.id
            = link_to icon('thumbs-up'), user_favourite_path(current_user, current_user.favourite(@project.id), project_id: @project.id), class: 'fav', method: :delete
          - else
            = link_to icon('thumbs-o-up'), user_favourites_path(current_user, project_id: @project.id), class: 'fav', method: :post
          Stars:
          - if current_user.graded? @project.id
            = icon('star')
            = @project.grade_average
            = link_to 'Remove stars', user_grade_path(current_user, current_user.grade(@project.id), project_id: @project.id), class: 'star', method: :delete
          - else
            = link_to icon('star-o'), user_grades_path(current_user, project_id: @project.id, stars: 1), class: 'star', method: :post
            = link_to icon('star-o'), user_grades_path(current_user, project_id: @project.id, stars: 2), class: 'star', method: :post
            = link_to icon('star-o'), user_grades_path(current_user, project_id: @project.id, stars: 3), class: 'star', method: :post
            = link_to icon('star-o'), user_grades_path(current_user, project_id: @project.id, stars: 4), class: 'star', method: :post
            = link_to icon('star-o'), user_grades_path(current_user, project_id: @project.id, stars: 5), class: 'star', method: :post
        %ul.project-links
          %li
            = icon('code')
            = link_to @project.owner do
              = @project.owner.username

          - if @project.lab.present?
            %li
              = icon('map-marker')
              = link_to @project.lab do
                = @project.lab.name

          - if (@project.contributors.count > 0)
            %li
              = icon('users')
              = @project.contributors.count + 1
              contributors

          %li
            = icon('clock-o')
            Last updated at:
            = time_tag(@project.updated_at.to_date)

        - if @project.tag_list.present?
          %ul.taglist
            = icon('tags')
            - @project.tag_list.each do |tag|
              %li.gray
                %strong
                  = link_to "##{tag}", "/projects/tags?q=#{tag}"

        .share
          %a.twitter-share-button{"data-hashtags" => "fablabsio", :href => "https://twitter.com/share"} Tweet
          :javascript
            !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');

      .col-lg-8.polaroid
        - if @project.documents.present?

          #carousel-documents.carousel.slide{"data-ride" => "carousel"}
            %ol.carousel-indicators
              - @project.documents.each_with_index do |document, index|
                %li{class: (index == 0 ? 'active' : nil), "data-slide-to" => index, "data-target" => "#carousel-documents"}

            .carousel-inner{:role => "listbox"}
              - @project.documents.each_with_index do |document, index|
                .item{class: index == 0 ? 'active' : nil}
                  - if document.photo.present?
                    = image_tag document.photo.thumb("640x640>").url, alt: "slide #{index}"
            %a.left.carousel-control{"data-slide" => "prev", :href => "#carousel-documents", :role => "button"}
              %span.fa.fa-chevron-left{"aria-hidden" => "true"}
              %span.sr-only Previous
            %a.right.carousel-control{"data-slide" => "next", :href => "#carousel-documents", :role => "button"}
              %span.fa.fa-chevron-right{"aria-hidden" => "true"}
              %span.sr-only Next