Skip to content

Instantly share code, notes, and snippets.

@jogam5
Created June 13, 2013 22:34
Show Gist options
  • Select an option

  • Save jogam5/5777987 to your computer and use it in GitHub Desktop.

Select an option

Save jogam5/5777987 to your computer and use it in GitHub Desktop.
New Post Show using Thumbnail and Picture
<% provide(:title, @micropost.title) %>
<% content_for :meta do %>
<% if [email protected]? %>
<% meta [:property => "og:image", :content => @micropost.thumbnail] %>
<% end %>
<% meta [:property => "og:description", :content => " #{@micropost.title}"] %>
<% meta [:property => "og:type", :content => "website"] %>
<% meta [:property => "og:title", :content => "Soxialit - #{@micropost.title}"] %>
<% meta [:property => "og:url", :content => "https://soxialit.com/microposts/#{@micropost.id}"] %>
<% meta [:property => "fb:app_id", :content => "235628993153454"] %>
<% end %>
<div class="row">
<div class="span2">
<p style="font-family:acta-display; font-size:1.4em; margin-bottom:1em">Te sugerimos:</p>
<% @posts.shuffle.each_with_index do |post, index| %>
<% break if index == 3 %>
<% if post.picture.present? %>
<%= link_to image_tag(post.picture_url, width:200), micropost_path(post) %>
<% else %>
<%= link_to image_tag(post.thumbnail), micropost_path(post) %>
<% end %>
<p style="margin-right:0.5em; margin-top:0.5em">
<% if !post.user.picture.present? %>
<%= link_to image_tag("http://graph.facebook.com/#{post.user.uid}/picture?type=square",
width: 25, height: 25, :id => "like_small_picture"), user_path(post.user) %>
<% else %>
<%= link_to image_tag(post.user.picture_url(:thumb_profile),
width: 25, height: 25, :id => "like_small_picture"), user_path(post.user) %>
<% end %>
<span id="nickname_show_left"><%= link_to post.user.nickname, user_path(post.user) %></span>
</p>
<div style="margin-top:-9%; margin-right: 1%"class="votacion" id="votacion_<%= post.id %>">
<span id="want_<%= post.id %>">
<div style="width:10px">
<div id="love_icon_<%= post.id %>" class="love_icon_active">
<span style="float:left; display:block; margin-left:-50%; color:black" id="love_product_<%= post.id %>">
<%= post.reputation_for(:lovs).to_i %>
</span>
</div>
</div>
</span>
</div>
<hr />
<% end %>
<br/>
</div>
<div class="span9" id="feed_wall" style="padding: 0em 2em 0em 2.5em">
<% if current_user == @micropost.user %>
<span class="micropost_delete"><%= link_to "Eliminar", micropost_path(@micropost), :method => :delete %></span>
<% end %>
<p id="item_link_micropost" style="text-align:center; margin:0.5em; font-size:3.3em; line-height:1.1em"><%= link_to @micropost.title, @micropost.url, target: '_blank' %></p>
<div class="row" style="text-align:center">
<% if @micropost.picture.present? %>
<%= link_to image_tag(@micropost.picture_url, width:500), @micropost.url, target: '_blank' %>
<% else %>
<%= link_to image_tag(@micropost.thumbnail), @micropost.url, target: '_blank' %>
<% end %>
<br /><br />
<div ><span style="color:#999">vía</span> <%= link_to @micropost.provider, @micropost.provider, target: '_blank' %>
<br />
</div>
</div>
<br />
<div style="padding:5%; margin-right:-4%; margin-top:-7%; margin-bottom:5%">
<% if [email protected]_list.first.nil? %>
<p class="tags">TAGS:</p>
<li class="taging" style="width:300px"><%= raw @micropost.tag_list.map { |t| link_to t, tag_path(t) }.join(' ') %></li>
<% end %>
<span style="float:right; display:block">
<div class="fb-like" data-href="" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false"></div>
</span>
<% if signed_in? %>
<div style="margin-top:0.1%; margin-right: 1%"class="votacion" id="votacion_<%= @micropost.id %>">
<% if @micropost.user_id == current_user.id %>
<div id="ajax-status" style="float: right; display:none; margin-left: 50%; width:20px">
<%= image_tag("loading.gif") %>
</div>
<span id="want_<%= @micropost.id %>">
<div id="love_icon_<%= @micropost.id %>" class="love_icon_active">
<span style="float:left; display:block; margin-left:-50%; color:black"
id="love_product_<%= @micropost.id %>">
<%= @micropost.reputation_for(:lovs).to_i %>
</span>
</div>
</span>
<% elsif current_user && !current_user.voted_for?(@micropost) %>
<div id="ajax-status" style="float: right; display:none; margin-left: 50%; width:20px">
<%= image_tag("loading.gif") %>
</div>
<span id="want_<%= @micropost.id %>">
<div id="love_icon_<%= @micropost.id %>" class="love_icon">
<span style="float:left; display:block; margin-left:-50%; color:black"
id="love_product_<%= @micropost.id %>">
<%= @micropost.reputation_for(:lovs).to_i %>
</span>
<%= link_to "xxx", lovs_micropost_path(@micropost, type: "up"),
:class =>"trick_anchor", :remote => true, method: "post", id: "link" %>
</div>
</span>
<% else %>
<div id="ajax-status" style="float: right; display:none; margin-left: 50%; width:20px">
<%= image_tag("loading.gif") %>
</div>
<span id="want_<%= @micropost.id %>">
<div id="love_icon_<%= @micropost.id %>" class="love_icon_active">
<span style="float:left; display:block; margin-left:-50%; color:black" id="love_product_<%= @micropost.id %>">
<%= @micropost.reputation_for(:lovs).to_i %>
</span>
</div>
</span>
<% end %>
</div>
<% else %>
<div style="margin-top:0.1%; margin-right: 1%"class="votacion" id="votacion_<%= @micropost.id %>">
<span id="want_<%= @micropost.id %>">
<div id="love_icon_<%= @micropost.id %>" class="love_icon_active">
<span style="float:left; display:block; margin-left:-50%; color:black" id="love_product_<%= @micropost.id %>">
<%= @micropost.reputation_for(:lovs).to_i %>
</span>
</div>
</span>
</div>
<% end %>
</div>
<div class="red_bar" style="background:black; margin-top:0.5em"></div>
<%= render 'microposts/comments' %>
</div>
</div>
<br/ >
<script type="text/javascript">mixpanel.track("Link: <%= @micropost.title %>")</script>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/es_LA/all.js#xfbml=1&appId=439343236107925";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
$(function(){
$('.new_comment textarea').bind('keyup', function() {
if (event.keyCode == 13) {
$(this).closest('form').submit();
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment