Skip to content

Instantly share code, notes, and snippets.

@Soldo
Soldo / gist:2517910
Created April 28, 2012 10:48
lightbox gallery
<div id="gallery">
<a title="Sample Caption Text" href="/lightbox_gallery/gallery-photos/1.jpg">
<img src="/lightbox_gallery/gallery-photos/1.jpg" height="80" width="120" />
</a>
<a title="Sample Caption Text" href="/lightbox_gallery/gallery-photos/2.jpg">
<img src="/lightbox_gallery/gallery-photos/2.jpg" height="80" width="120" />
</a>
<a title="Sample Caption Text" href="/lightbox_gallery/gallery-photos/3.jpg">
<img src="/lightbox_gallery/gallery-photos/3.jpg" height="80" width="120" />
</a>
[slasticarnica (master)]$ rake routes
refinery / Refinery::Core::Engine
edmond /edmond(.:format) refinery/pages#edmond
Routes for Refinery::Core::Engine:
/system/resources/*dragonfly(.:format) <Dragonfly::App name=:refinery_resources >
insert_admin_resources GET /refinery/resources/insert(.:format) refinery/admin/resources#insert
admin_resources GET /refinery/resources(.:format) refinery/admin/resources#index
POST /refinery/resources(.:format) refinery/admin/resources#create
new_admin_resource GET /refinery/resources/new(.:format) refinery/admin/resources#new
this code in show.html.erb...
<% @page.children.each do |child| %>
<%= link_to(child) do %>
<%= image_tag @page.key_image.url if @page.key_image.present? %>
<h2><%= child.title %></h2>
<% end %>
<% end %>
is producing this output without images:
Objective: Display "hello world" in "U ponudi" page. (page "u ponudi" is created in backend in Pages tab)
Obstacle: When I overrode pages/show.html.erb file and modified it so that it displays "Hello World" on body_content_left, I don't get "Hello World" on my screen. I just get the content that i placed before in backedn.
This is the FIRST thing I tried. It's not working:
<% if @page.title == 'U ponudi' %>
<% content_for :body_content_left do %>
<h1>Hello World!</h1>
<% end %>
<% end %>
this is the script I included right after the <body> section (generated by facebook):
<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/en_US/all.js#xfbml=1&appId=MY_APP_ID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<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 %>
@Soldo
Soldo / gist:2427002
Created April 20, 2012 07:58
facebook like - blog post
This is the code included in <head> section:
<% require 'nokogiri' %>
<% frag = Nokogiri::HTML.fragment( 'hello world' ) %> (actually here suppose to go @post.body.html_safe)
<% first_img_src = frag.at_css('img')['src'] %>
<% first_p_text = frag.at_css('p').text %>
<meta property="og:title" content="Ovdje ide naslov" />
<meta property="og:type" content="sport" />
<meta property="og:url" content="http://kbk-siroki.herokuapp.com" />
@Soldo
Soldo / _actions.html.erb
Created April 9, 2012 22:44 — forked from jipiboily/_actions.html.erb
How to setup a Refinery custom content type and view (aka "page template")
<!-- path: app/views/refinery/admin/pages/_actions.html.erb -->
<!--
You could override this view, if you want to add links to each page type via the admin UI. If you don't you'll have to add a param the the URL.
WARNING: You most probably want to do it cleaner than that and find a way to hook to this view instead of overriding it if at all possible.
-->
<ul>
<li>
<%= render '/refinery/admin/search', :url => refinery.admin_pages_path %>
</li>
routes.rb:
...
match '/kontakt-page' => 'pages#bidon'
...
pages_controller.rb:
...
def bidon
render_with_templates?
end
<a class="link-news" href="#">
<figure class="img-indent"><%= image_tag("page1-img1.jpg") %></figure>
<div class="extra-wrap">
<time class="tdate-1" datetime="2012-10-21">
<%= post.published_at.strftime('%d, %m, %Y') %>
</time>
<span><%= post.title %></span>
</div>
</a>