Skip to content

Instantly share code, notes, and snippets.

@Soldo
Created April 20, 2012 09:54
Show Gist options
  • Select an option

  • Save Soldo/2427429 to your computer and use it in GitHub Desktop.

Select an option

Save Soldo/2427429 to your computer and use it in GitHub Desktop.
<head>
<meta charset='<%= Rails.application.config.encoding %>' />
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><![endif]-->
<title><%= browser_title(yield(:title)) %></title>
<%= raw(%(<meta name="description" content="#{@meta.meta_description}" />)) if @meta.meta_description.present? -%>
<%= raw(%(<meta name="keywords" content="#{@meta.meta_keywords}">)) if @meta.meta_keywords.present? -%>
<%= raw(%(<link rel="canonical" content="#{@canonical}" />)) if @canonical.present? -%>
<%= csrf_meta_tags if Refinery::Core.authenticity_token_on_frontend -%>
<%= yield :meta %>
<%= stylesheet_link_tag "application", "formatting", "theme" %>
<%= stylesheet_link_tag "home" if home_page? %>
<%= stylesheet_link_tag "http://fonts.googleapis.com/css?family=Anton" %>
<%= stylesheet_link_tag "style" %>
<%= stylesheet_link_tag "lightbox" %>
<%= stylesheet_link_tag "page_parts" %>
<%= yield :stylesheets %>
<%= favicon_link_tag 'favicon.ico', :rel => 'shortcut icon' %>
<%= favicon_link_tag 'animated_favicon1.gif', :rel => 'icon', :type => 'image/gif' %>
<%= stylesheet_link_tag "screen" %>
<%= render '/refinery/google_analytics' %>
<%= yield :facebook_meta %>
</head>
require 'acts-as-taggable-on'
require 'seo_meta'
module Refinery
module Blog
class Post < ActiveRecord::Base
extend FriendlyId
friendly_id :friendly_id_source, :use => [:slugged]
is_seo_meta if self.table_exists?
default_scope :order => 'published_at DESC'
belongs_to :author, :class_name => 'Refinery::User', :foreign_key => :user_id, :readonly => true
has_many :comments, :dependent => :destroy, :foreign_key => :blog_post_id
acts_as_taggable
has_many :categorizations, :dependent => :destroy, :foreign_key => :blog_post_id
has_many :categories, :through => :categorizations, :source => :blog_category
acts_as_indexed :fields => [:title, :body]
validates :title, :presence => true, :uniqueness => true
validates :body, :presence => true
validates :source_url, :url => { :if => 'Refinery::Blog.validate_source_url',
:update => true,
:allow_nil => true,
:allow_blank => true,
:verify => [:resolve_redirects]}
attr_accessible :title, :body, :custom_teaser, :tag_list, :draft, :published_at, :custom_url, :author
attr_accessible :browser_title, :meta_keywords, :meta_description, :user_id, :category_ids
attr_accessible :source_url, :source_url_title
self.per_page = Refinery::Blog.posts_per_page
def next
self.class.next(self)
end
def prev
self.class.previous(self)
end
def live?
!draft and published_at <= Time.now
end
def friendly_id_source
custom_url.present? ? custom_url : title
end
def face_book_img
require 'nokogiri'
frag = Nokogiri::HTML.fragment( self.custom_teaser )
first_img_src = frag.at_css('img')['src']
end
class << self
def by_archive(date)
where(:published_at => date.beginning_of_month..date.end_of_month)
end
def by_year(date)
where(:published_at => date.beginning_of_year..date.end_of_year)
end
def published_dates_older_than(date)
published_before(date).pluck(:published_at)
end
def recent(count)
live.limit(count)
end
def popular(count)
unscoped.order("access_count DESC").limit(count)
end
def previous(item)
published_before(item.published_at).first
end
def uncategorized
live.includes(:categories).where(:categories => { Refinery::Categorization.table_name => { :blog_category_id => nil } })
end
def next(current_record)
where(["published_at > ? and draft = ?", current_record.published_at, false]).first
end
def published_before(date=Time.now)
where("published_at < ? and draft = ?", date, false)
end
alias_method :live, :published_before
def comments_allowed?
Refinery::Setting.find_or_set(:comments_allowed, true, :scoping => 'blog')
end
def teasers_enabled?
Refinery::Setting.find_or_set(:teasers_enabled, true, :scoping => 'blog')
end
def teaser_enabled_toggle!
currently = Refinery::Setting.find_or_set(:teasers_enabled, true, :scoping => 'blog')
Refinery::Setting.set(:teasers_enabled, :value => !currently, :scoping => 'blog')
end
end
module ShareThis
def self.enabled?
Refinery::Blog.share_this_key != "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
end
end
end
end
end
<% content_for :body_content_left do %>
<div id="show_blog_post">
<div id="blog" class="entry">
<%= render 'post' %>
<% if Refinery::Blog::Post.comments_allowed? %>
<%= render 'comments'%>
<% end %>
</div>
</div>
<% end %>
<%= render :partial => '/refinery/blog/shared/body_content_right' %>
<%= render :partial => "/refinery/content_page", :locals => { :remove_automatic_sections => true } %>
<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/frontend') %>
<% content_for :javascripts do %>
<%# enable AJAX'd post nav at your own risk until html5 history API implemented. %>
<%#= javascript_include_tag('refinery/blog/frontend') %>
<script src="http://w.sharethis.com/button/buttons.js"></script>
<script>stLight.options({publisher:'<%= Blog::Post::ShareThis.key %>'});</script>
<% end if Refinery::Blog::Post::ShareThis.enabled? %>
<% content_for :facebook_meta do %>
<meta property="og:title" content="Ovdje ide naslov" />
<meta property="og:type" content="sport" />
<meta property="og:url" content="http://kbk-siroki.herokuapp.com" />
<meta property="og:image" content=<%= @post.face_book_img %> />
<meta property="og:site_name" content="Kickboxing Klub Siroki Brijeg" />
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment