Skip to content

Instantly share code, notes, and snippets.

View parndt's full-sized avatar

Philip Arndt parndt

View GitHub Profile
@parndt
parndt / _menu_branch.html.erb
Created August 19, 2011 04:59 — forked from michaelward82/_menu_branch.html.erb
Limit menu rendering in Refinery CMS
<%
if !!local_assigns[:apply_css] and (classes = menu_branch_css(local_assigns)).any?
css = "class='#{classes.join(' ')}'".html_safe
end
# dom_id DEPRECATED: REMOVE AT 1.1, serves no purpose same with css attributes 'first' and 'last'
dom_id = "id='item_#{menu_branch_counter}'".html_safe if menu_branch.parent_id.nil?
-%>
<li<%= ['', css, dom_id].compact.join(' ').gsub(/\ *$/, '').html_safe %>>
<%= link_to menu_branch.title, menu_branch.url -%>
<% if ( (children = menu_branch.children unless hide_children).present? &&
@parndt
parndt / application.html.erb
Created February 2, 2012 23:08
Change theme
<%= stylesheet_link_tag(current_theme) %>
@parndt
parndt / gist:1726580
Created February 2, 2012 23:54
change theme in your helper for joshuascott
def current_theme
# first, check if we've tried to access this already and if so @current_theme will be populated with a value.
@current_theme ||= if params[:ChangeTheme] == "true"
# If the user is trying to change the theme, first: construct an array of possible themes.
# then: reject the theme in the current session if it is present.
# Finally, grab a random sample to use a random theme from the array of themes.
%w[power.css creative.css communication.css].reject{|theme| theme == session[:current_theme]}.sample
else
# The user is not trying to change the theme so just return the current theme saved to sesssion OR
# return the default theme which is 'power.css'
@parndt
parndt / Gemfile
Created March 19, 2012 21:57 — forked from joemsak/Gemfile
source 'http://rubygems.org'
gem 'rails', '~> 3.0.11'
gem 'foreman'
gem 'unicorn'
gem 'airbrake'
gem 'delayed_job'
gem 'compass', '~> 0.12.alpha'
gem 'acts-as-taggable-on', '~>2.1.0'
@parndt
parndt / gist:4127297
Created November 21, 2012 20:02 — forked from ugisozols/gist:4125166
Stop subclassing array
diff --git a/core/lib/refinery/plugins.rb b/core/lib/refinery/plugins.rb
index a22497f..cef123e 100644
--- a/core/lib/refinery/plugins.rb
+++ b/core/lib/refinery/plugins.rb
@@ -1,5 +1,10 @@
module Refinery
- class Plugins < Array
+ class Plugins
+ include Enumerable
+
require 'gh'
contributions = {}
repositories = {}
longest_name = 0
GH.with(username: ENV['GITHUB_USERNAME'], password: ENV['GITHUB_PASSWORD']) do
GH["orgs/#{ENV['ORG']}/repos"].each do |repository|
repositories[repository['full_name']] = GH["repos/#{repository['full_name']}/contributors"]
end
<section id="carousel">
<div id="myCarousel" class="carousel slide">
<ul class="carousel-inner">
<% @slides.each_with_index do |slide, i| %>
<% if i==0 %>
<li class="item active">
<% else %>
<li class="item">
<% end %>
<%= link_to image_fu(slide.image, '1200x490!'), refinery.slides_slide_path(slide) %>
<section id="carousel">
<div id="myCarousel" class="carousel slide">
<ul class="carousel-inner">
<% @slides.each_with_index do |slide, i| %>
<% if i==0 %>
<li class="item active">
<% else %>
<li class="item">
<% end %>
<%= link_to image_fu(slide.image, '1200x490!'), refinery.slides_slide_path(slide) %>
@parndt
parndt / gist:4505891
Last active December 10, 2015 22:58 — forked from tpendragon/gist:4505845
def content_with_parent_fallback
content_without_parent_fallback.presence || translation_for(parent_translation(I18n.locale)).try(:content)
end
alias_method_chain :content, :parent_fallback
@parndt
parndt / User.rb
Last active December 11, 2015 05:18 — forked from patrickcurl/User.rb
# == Schema Information
# Schema version: 20130116180743
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null