<commit_before>- @page_title = @community.short_name

%h1= h @community.name

#community-box
  %p
    %label
      Type of community:
    = h @community.category  # TODO: This should be pulled from lookup table
  
  %p
    %label
      Headquarters:
    = "#{@community.city}&nbsp; #{@community.prov_state}&nbsp; #{@community.country}"

  %p
    %label
      Regional scope:
    = h @community.scope

  %p
    %label
      Official website:
    = if @community.official_url
      = auto_link_urls(@community.official_url, :target => "_blank")

  %p
    %label
      Wiki:
    = if @community.wiki_url
      = auto_link_urls(@community.wiki_url, :target => "_blank")

  %p
    %label
      Description:
    = truncate(@community.description, :length => 200)

  %p= link_to('Add to community data', add_to_community_path(@community))

  - if current_user and (current_user.permission >= 4.0)
    %p.permission
      = link_to('Edit community data', edit_object_path(@community))

%h3
  Which websites/blogs deserve more support from the 
  = h @community.short_name 
  voter community?

- if @community.websites.any?
  %p
    Vote for as many as you like: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    = '[' + link_to('FAQ on voting', '/faqs/#Voting') + ']'
	
  %table#table1
    %tr.header
      %th.header-centred= "Rank"
      - if current_user and (current_user.permission >= 7.0)
        %th.header-centred.permission= "Votes"
      %th.header-centred{:colspan => 2}= "Your Vote"
      %th.header-left= "Website/Blog"
      %th.header-centred= "Date added"

    - @rank_sequence = 0

    - @rankings.each do |ranking|
      / In case website was deleted but orphaned ranking record still exists:
      - if ranking[:website]
        %tr{:class => cycle('list-line-odd', 'list-line-even')}
          - @rank_sequence += 1
          %td.cell-centred= @rank_sequence
          - if current_user and (current_user.permission >= 7.0)
            %td.cell-centred.permission= number_with_precision(ranking[:rank], :precision => 2)
          -# TODO: use named_route/resource
          %td.cell-centred= button_to 'Support', :action => :vote_for_website, :id => ranking[:website], :community => @community
          %td
            /- if @ballot.clicks.find(:first, :conditions => ["community_id = ? and website_id = ?", @community.id, ranking[:website].id])
            ✔
          %td.cell-link= link_to truncate(ranking[:website].title, :length => 50), ranking[:website].url, :target => "_blank"
          %td.cell-centred= ranking[:created_at].to_s(:Ymd)
          %td= @community.id
          %td= ranking[:website].id
          - if current_user and (current_user.permission >= 4.0)
            %td.permission= link_to 'Edit', edit_website_path(ranking[:website])
          - if current_user and (current_user.permission >= 5.0)
            %td.permission= link_to 'Destroy', ranking[:website], :confirm => 'Are you sure?', :method => :delete

  %p= will_paginate @rankings

  %p= link_to 'Add a website/blog to this community', new_website_path(:community_id => @community)
  
- else
  %p
    So far no one has added a website/blog to this community. 
    You can 
    %strong= link_to 'add one here', new_website_path(:community_id => @community)

  %p
    If you don't know of one, try searching e.g. for 
    = link_to "#{@community.short_name} election blog", "http://www.google.ca/search?q=#{@community.short_name.strip}+election+blog", :target => "_blank"

  %p
    If you still don't find one, how about creating one?! It's easy with free tools at sites like
    = link_to 'Wordpress', 'http://wordpress.com/', :target => '_blank'
    or
    = link_to 'Blogger', 'http://blogger.com/', :target => '_blank'
    \.

%br

%table
  %tr
    %th Community_id
    %th Website_id
  - for click in @ballot.clicks
    %tr
      %td= click.community_id
      %td= click.website_id

%br<commit_msg>Display current session's votes in rankings table. There must be a better way to code this!<commit_after>- @page_title = @community.short_name

%h1= h @community.name

#community-box
  %p
    %label
      Type of community:
    = h @community.category  # TODO: This should be pulled from lookup table
  
  %p
    %label
      Headquarters:
    = "#{@community.city}&nbsp; #{@community.prov_state}&nbsp; #{@community.country}"

  %p
    %label
      Regional scope:
    = h @community.scope

  %p
    %label
      Official website:
    = if @community.official_url
      = auto_link_urls(@community.official_url, :target => "_blank")

  %p
    %label
      Wiki:
    = if @community.wiki_url
      = auto_link_urls(@community.wiki_url, :target => "_blank")

  %p
    %label
      Description:
    = truncate(@community.description, :length => 200)

  %p= link_to('Add to community data', add_to_community_path(@community))

  - if current_user and (current_user.permission >= 4.0)
    %p.permission
      = link_to('Edit community data', edit_object_path(@community))

%h3
  Which websites/blogs deserve more support from the 
  = h @community.short_name 
  voter community?

- if @community.websites.any?
  %p
    Vote for as many as you like: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    = '[' + link_to('FAQ on voting', '/faqs/#Voting') + ']'
	
  %table#table1
    %tr.header
      %th.header-centred= "Rank"
      - if current_user and (current_user.permission >= 7.0)
        %th.header-centred.permission= "Votes"
      %th.header-centred{:colspan => 2}= "Your Vote"
      %th.header-left= "Website/Blog"
      %th.header-centred= "Date added"

    - @rank_sequence = 0

    - @rankings.each do |ranking|
      / In case website was deleted but orphaned ranking record still exists:
      - if ranking[:website]
        %tr{:class => cycle('list-line-odd', 'list-line-even')}
          - @rank_sequence += 1
          %td.cell-centred= @rank_sequence
          - if current_user and (current_user.permission >= 7.0)
            %td.cell-centred.permission= number_with_precision(ranking[:rank], :precision => 2)
          -# TODO: use named_route/resource
          %td.cell-centred= button_to 'Support', :action => :vote_for_website, :id => ranking[:website], :community => @community
          %td
            /- if @ballot.clicks.find(:last, :conditions => ["community_id = ? and website_id = ?", @community.id, ranking[:website].id]) this doesn't work so I wrote the ugly code below:
            - @flag = 0
            - for click in @ballot.clicks
              - if click.community_id == @community.id && click.website_id == ranking[:website].id
                - @flag = 1
            - if @flag == 1
              ✔
          %td.cell-link= link_to truncate(ranking[:website].title, :length => 50), ranking[:website].url, :target => "_blank"
          %td.cell-centred= ranking[:created_at].to_s(:Ymd)
          - if current_user and (current_user.permission >= 4.0)
            %td.permission= link_to 'Edit', edit_website_path(ranking[:website])
          - if current_user and (current_user.permission >= 5.0)
            %td.permission= link_to 'Destroy', ranking[:website], :confirm => 'Are you sure?', :method => :delete

  %p= will_paginate @rankings
  
  %p If you don't want other users of this computer to see your votes, please exit browser when finished voting.

  %p= link_to 'Add a website/blog to this community', new_website_path(:community_id => @community)
  
- else
  %p
    So far no one has added a website/blog to this community. 
    You can 
    %strong= link_to 'add one here', new_website_path(:community_id => @community)

  %p
    If you don't know of one, try searching e.g. for 
    = link_to "#{@community.short_name} election blog", "http://www.google.ca/search?q=#{@community.short_name.strip}+election+blog", :target => "_blank"

  %p
    If you still don't find one, how about creating one?! It's easy with free tools at sites like
    = link_to 'Wordpress', 'http://wordpress.com/', :target => '_blank'
    or
    = link_to 'Blogger', 'http://blogger.com/', :target => '_blank'
    \.

%br
{'fraction_non_alphanumeric': 0.1393667414609823, 'fraction_numerical': 0.005858888057840937, 'mean_word_length': 2.862782859894078, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4245376', 'n_tokens_mistral': 2746, 'n_tokens_neox': 2549, 'n_words': 676}