Permalink
Browse files

Inital commit

  • Loading branch information...
0 parents commit c7bdf58d54eb69ea43273abb224f2fd9f57f01dc @ghoppe committed May 13, 2012
70 Gemfile
@@ -0,0 +1,70 @@
+source "http://rubygems.org"
+
+gemspec
+
+gem 'refinerycms', '~> 2.0.0', :git => 'git://github.com/resolve/refinerycms.git'
+
+# Refinery/rails should pull in the proper versions of these
+group :assets do
+ gem 'sass-rails'
+ gem 'coffee-rails'
+ gem 'uglifier'
+ gem 'bootstrap-sass', '~> 2.0.3'
+end
+
+gem 'jquery-rails'
+
+group :development, :test do
+ gem 'refinerycms-testing', '~> 2.0.0'
+ gem 'factory_girl_rails'
+ gem 'generator_spec'
+
+ require 'rbconfig'
+
+ platforms :jruby do
+ gem 'activerecord-jdbcsqlite3-adapter'
+ gem 'activerecord-jdbcmysql-adapter'
+ gem 'activerecord-jdbcpostgresql-adapter'
+ gem 'jruby-openssl'
+ end
+
+ unless defined?(JRUBY_VERSION)
+ gem 'sqlite3'
+ gem 'mysql2'
+ gem 'pg'
+ end
+
+ platforms :mswin, :mingw do
+ gem 'win32console'
+ gem 'rb-fchange', '~> 0.0.5'
+ gem 'rb-notifu', '~> 0.0.4'
+ end
+
+ platforms :ruby do
+ gem 'spork', '0.9.0.rc9'
+ gem 'guard-spork'
+
+ unless ENV['TRAVIS']
+ if RbConfig::CONFIG['target_os'] =~ /darwin/i
+ gem 'rb-fsevent', '>= 0.3.9'
+ gem 'growl', '~> 1.0.3'
+ end
+ if RbConfig::CONFIG['target_os'] =~ /linux/i
+ gem 'rb-inotify', '>= 0.5.1'
+ gem 'libnotify', '~> 0.1.3'
+ end
+ end
+ end
+
+ platforms :jruby do
+ unless ENV['TRAVIS']
+ if RbConfig::CONFIG['target_os'] =~ /darwin/i
+ gem 'growl', '~> 1.0.3'
+ end
+ if RbConfig::CONFIG['target_os'] =~ /linux/i
+ gem 'rb-inotify', '>= 0.5.1'
+ gem 'libnotify', '~> 0.1.3'
+ end
+ end
+ end
+end
27 Guardfile
@@ -0,0 +1,27 @@
+guard 'spork', :wait => 60, :cucumber => false, :rspec_env => { 'RAILS_ENV' => 'test' } do
+ watch('config/application.rb')
+ watch('config/environment.rb')
+ watch(%r{^config/environments/.+\.rb$})
+ watch(%r{^config/initializers/.+\.rb$})
+ watch('spec/spec_helper.rb')
+ watch(%r{^spec/support/.+\.rb$})
+ watch(%r{^vendor/extensions/(.+)/spec/support/.+\.rb$})
+end
+
+guard 'rspec', :version => 2, :cli => "--color --drb --format Fuubar", :all_on_start => false, :all_after_pass => false do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+
+ # Rails example
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
+ watch('spec/spec_helper.rb') { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+ # Capybara request specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+end
20 Rakefile
@@ -0,0 +1,20 @@
+#!/usr/bin/env rake
+begin
+ require 'bundler/setup'
+rescue LoadError
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+end
+
+ENGINE_PATH = File.dirname(__FILE__)
+APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
+
+if File.exists?(APP_RAKEFILE)
+ load 'rails/tasks/extension.rake'
+end
+
+require "refinerycms-testing"
+Refinery::Testing::Railtie.load_tasks
+Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
+
+load File.expand_path('../tasks/testing.rake', __FILE__)
+load File.expand_path('../tasks/rspec.rake', __FILE__)
8 app/controllers/refinery/bootstrap/admin/bootstrap_controller.rb
@@ -0,0 +1,8 @@
+module Refinery
+ module Bootstrap
+ module Admin
+ class BootstrapController < ::Refinery::AdminController
+ end
+ end
+ end
+end
21 app/views/layouts/application.html.erb
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<%= render '/refinery/html_tag' %>
+ <% site_bar = render('/refinery/site_bar', :head => true) -%>
+ <%= render '/refinery/head' %>
+ <body>
+ <%= site_bar -%>
+ <%= render '/refinery/ie6check' if request.env['HTTP_USER_AGENT'] =~ /MSIE/ -%>
+ <div id="page_container" class="container">
+ <header id="header">
+ <%= render '/refinery/header' -%>
+ </header>
+ <div id="page">
+ <%= yield %>
+ </div>
+ <footer>
+ <%= render '/refinery/footer' -%>
+ </footer>
+ </div>
+ <%= render '/refinery/javascripts' %>
+ </body>
+</html>
1 app/views/refinery/_header.html.erb
@@ -0,0 +1 @@
+<%= render(:partial => "/refinery/bootstrap/navbar", :locals => {}) %>
18 app/views/refinery/bootstrap/_menu.html.erb
@@ -0,0 +1,18 @@
+<%
+ # Collect the root items.
+ # ::Refinery::Menu is smart enough to remember all of the items in the original collection.
+ if (roots = local_assigns[:roots] || (collection ||= refinery_menu_pages).roots).present?
+ dom_id ||= 'menu'
+ css = [(css || 'menu')].flatten.join(' ')
+ hide_children = Refinery::Core.menu_hide_children if hide_children.nil?
+-%>
+ <ul class="nav">
+ <%= render :partial => '/refinery/bootstrap/menu_branch', :collection => roots,
+ :locals => {
+ :hide_children => hide_children,
+ :sibling_count => (roots.length - 1),
+ :menu_levels => local_assigns[:menu_levels],
+ :apply_css => true #if you don't care about class='first' class='last' or class='selected' set apply_css to false for speed.
+ } -%>
+ </ul>
+<% end -%>
40 app/views/refinery/bootstrap/_menu_branch.html.erb
@@ -0,0 +1,40 @@
+<%
+ if !!local_assigns[:apply_css] and (classes = menu_branch_css(local_assigns)).any?
+ css = "class='#{classes.join(' ')}'".html_safe
+ end
+
+ if menu_branch.ancestors.length == 0
+ parent_css = "dropdown"
+ parent_title = link_to(raw("#{menu_branch.title.upcase} <b class=\"caret\"></b>"), "#menu_#{menu_branch.title}", :class => "dropdown-toggle", "data-toggle" => "dropdown")
+ else
+ parent_css = "nav-header"
+ parent_title = menu_branch.title.upcase
+ end
+
+-%>
+ <% if ( (children = menu_branch.children unless hide_children).present? &&
+ (!local_assigns[:menu_levels] || menu_branch.ancestors.length < local_assigns[:menu_levels]) ) -%>
+ <li id="menu_<%= menu_branch.title %>" class="<%= parent_css %>">
+ <%= parent_title -%>
+ <% if menu_branch.ancestors.length == 0 %>
+ <ul class='dropdown-menu'>
+ <% end %>
+ <%= render :partial => '/refinery/bootstrap/menu_branch', :collection => children,
+ :locals => {
+ :apply_css => local_assigns[:apply_css],
+ :hide_children => !!hide_children,
+ :menu_levels => local_assigns[:menu_levels]
+ } -%>
+ <% if menu_branch.ancestors.length == 0 %>
+ </ul>
+ <% end %>
+ <% else -%>
+ <li<%= ['', css].compact.join(' ').gsub(/\ *$/, '').html_safe %>>
+ <%= link_to(menu_branch.title.upcase, refinery.url_for(menu_branch.url)) -%>
+ <% end -%>
+</li>
+
+<% if (!classes.include?(Refinery::Core.menu_css[:last]) && menu_branch.ancestors.length == 0) then %>
+ <li class="divider-vertical"></li>
+<% end %>
+
9 app/views/refinery/bootstrap/_navbar.html.erb
@@ -0,0 +1,9 @@
+<% nav_class = "navbar"; nav_class << " navbar-fixed-top" if local_assigns[:fixed].present? %>
+<div class="<%= nav_class %>">
+ <div class="navbar-inner">
+ <div class="container">
+ <%= link_to Refinery::Core.site_name, refinery.root_path, :class => "brand" if local_assigns[:brand].present? %>
+ <%= render(:partial => "/refinery/bootstrap/menu") %>
+ </div>
+ </div>
+</div>
3 config/initializers/refinery/core.rb
@@ -0,0 +1,3 @@
+Refinery::Core.configure do |config|
+ config.menu_css = {:selected=>"active", :first=>"first", :last=>"last"}
+end
27 config/locales/en.yml
@@ -0,0 +1,27 @@
+en:
+ refinery:
+ plugins:
+ bootstrap:
+ title: Bootstrap
+ bootstrap:
+ admin:
+ bootstrap:
+ actions:
+ create_new: Add New Bootstrap
+ reorder: Reorder Bootstrap
+ reorder_done: Done Reordering Bootstrap
+ records:
+ title: Bootstrap
+ sorry_no_results: Sorry! There are no results found.
+ no_items_yet: There are no Bootstrap yet. Click "Add New Bootstrap" to add your first bootstrap.
+ bootstrap:
+ view_live_html: View this bootstrap live <br/><em>(opens in a new window)</em>
+ edit: Edit this bootstrap
+ delete: Remove this bootstrap forever
+ bootstrap:
+ show:
+ other: Other Bootstrap
+ activerecord:
+ attributes:
+ 'refinery/bootstrap/bootstrap':
+ title: Title
28 config/locales/es.yml
@@ -0,0 +1,28 @@
+es:
+ refinery:
+ plugins:
+ bootstrap:
+ title: Bootstrap
+# article: masculino/femenino
+ bootstrap:
+ admin:
+ bootstrap:
+ actions:
+ create_new: Crear nuevo bootstrap
+ reorder: Reordenar bootstrap
+ reorder_done: Reordenación de bootstrap completada
+ records:
+ title: Bootstrap
+ sorry_no_results: Lo siento, no hay resultados
+ no_items_yet: No hay bootstrap todavía. Pulsa en "Crear nuevo Bootstrap" para crear tu primer bootstrap.
+ bootstrap:
+ view_live_html: Ver este bootstrap como abierto al público <br/><em>(abre en ventana nueva)</em>
+ edit: Editar este bootstrap
+ delete: Borrar este bootstrap para siempre
+ bootstrap:
+ show:
+ other: Otros bootstrap
+ activerecord:
+ attributes:
+ 'refinery/bootstrap/bootstrap':
+ title: Title
27 config/locales/fr.yml
@@ -0,0 +1,27 @@
+fr:
+ refinery:
+ plugins:
+ bootstrap:
+ title: Bootstrap
+ bootstrap:
+ admin:
+ bootstrap:
+ actions:
+ create_new: Créer un(e) nouve(au/l/lle) Bootstrap
+ reorder: Réordonner les Bootstrap
+ reorder_done: Fin de réordonnancement des Bootstrap
+ records:
+ title: Bootstrap
+ sorry_no_results: "Désolé ! Aucun résultat."
+ no_items_yet: 'Il n''y a actuellement aucun(e) Bootstrap. Cliquer sur "Créer un(e) nouve(au/l/lle) Bootstrap" pour créer votre premi(er/ère) bootstrap.'
+ bootstrap:
+ view_live_html: Voir ce(t/tte) bootstrap <br/><em>(Ouvre une nouvelle fenêtre)</em>
+ edit: Modifier ce(t/tte) bootstrap
+ delete: Supprimer définitivement ce(t/tte) bootstrap
+ bootstrap:
+ show:
+ other: Autres Bootstrap
+ activerecord:
+ attributes:
+ 'refinery/bootstrap/bootstrap':
+ title: Title
27 config/locales/nb.yml
@@ -0,0 +1,27 @@
+nb:
+ refinery:
+ plugins:
+ bootstrap:
+ title: Bootstrap
+ bootstraps:
+ admin:
+ bootstrap:
+ actions:
+ create_new: Lag en ny Bootstrap
+ reorder: Endre rekkefølgen på Bootstrap
+ reorder_done: Ferdig å endre rekkefølgen Bootstrap
+ records:
+ title: Bootstrap
+ sorry_no_results: Beklager! Vi fant ikke noen resultater.
+ no_items_yet: Det er ingen Bootstraps enda. Klikk på "Lag en ny Bootstrap" for å legge til din første bootstrap.
+ bootstrap:
+ view_live_html: Vis hvordan denne bootstrap ser ut offentlig <br/><em>(åpner i et nytt vindu)</em>
+ edit: Rediger denne bootstrap
+ delete: Fjern denne bootstrap permanent
+ bootstraps:
+ show:
+ other: Andre Bootstrap
+ activerecord:
+ attributes:
+ 'refinery/bootstrap/bootstrap':
+ title: Title
27 config/locales/nl.yml
@@ -0,0 +1,27 @@
+nl:
+ refinery:
+ plugins:
+ bootstrap:
+ title: Bootstrap
+ bootstrap:
+ admin:
+ bootstrap:
+ actions:
+ create_new: Maak een nieuwe Bootstrap
+ reorder: Wijzig de volgorde van de Bootstrap
+ reorder_done: Klaar met het wijzingen van de volgorde van de Bootstrap
+ records:
+ title: Bootstrap
+ sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
+ no_items_yet: Er zijn nog geen Bootstraps. Druk op 'Maak een nieuwe Bootstrap' om de eerste aan te maken.
+ bootstrap:
+ view_live_html: Bekijk deze bootstrap op de website <br/><em>(opent een nieuw venster)</em>
+ edit: Bewerk deze bootstrap
+ delete: Verwijder deze bootstrap voor eeuwig
+ bootstrap:
+ show:
+ other: Andere Bootstrap
+ activerecord:
+ attributes:
+ 'refinery/bootstrap/bootstrap':
+ title: Title
4 config/routes.rb
@@ -0,0 +1,4 @@
+Refinery::Core::Engine.routes.append do
+
+
+end
21 lib/refinery/bootstrap.rb
@@ -0,0 +1,21 @@
+require 'refinerycms-core'
+
+module Refinery
+ autoload :BootstrapGenerator, 'generators/refinery/bootstrap_generator'
+
+ module Bootstrap
+ require 'refinery/bootstrap/engine'
+
+ class << self
+ attr_writer :root
+
+ def root
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
+ end
+
+ def factory_paths
+ @factory_paths ||= [ root.join('spec', 'factories').to_s ]
+ end
+ end
+ end
+end
15 lib/refinery/bootstrap/engine.rb
@@ -0,0 +1,15 @@
+module Refinery
+ module Bootstrap
+ class Engine < Rails::Engine
+ include Refinery::Engine
+ isolate_namespace Refinery::Bootstrap
+
+ engine_name :refinery_bootstrap
+
+
+ config.after_initialize do
+ Refinery.register_extension(Refinery::Bootstrap)
+ end
+ end
+ end
+end
1 lib/refinerycms-bootstrap.rb
@@ -0,0 +1 @@
+require 'refinery/bootstrap'
13 lib/tasks/refinery/bootstrap.rake
@@ -0,0 +1,13 @@
+namespace :refinery do
+
+ namespace :bootstrap do
+
+ # call this task by running: rake refinery:bootstrap:my_task
+ # desc "Description of my task below"
+ # task :my_task => :environment do
+ # # add your logic here
+ # end
+
+ end
+
+end
10 readme.md
@@ -0,0 +1,10 @@
+# Bootstrap extension for Refinery CMS.
+
+## How to build this extension as a gem
+
+ cd vendor/extensions/bootstrap
+ gem build refinerycms-bootstrap.gemspec
+ gem install refinerycms-bootstrap.gem
+
+ # Sign up for a http://rubygems.org/ account and publish the gem
+ gem push refinerycms-bootstrap.gem
19 refinerycms-bootstrap.gemspec
@@ -0,0 +1,19 @@
+# Encoding: UTF-8
+
+Gem::Specification.new do |s|
+ s.platform = Gem::Platform::RUBY
+ s.name = 'refinerycms-bootstrap'
+ s.version = '1.0'
+ s.description = 'Ruby on Rails Bootstrap extension for Refinery CMS'
+ s.date = '2012-03-09'
+ s.summary = 'Bootstrap extension for Refinery CMS'
+ s.require_paths = %w(lib)
+ s.files = Dir["{app,config,db,lib}/**/*"] + ["readme.md"]
+
+ # Runtime dependencies
+ s.add_dependency 'refinerycms-core', '~> 2.0.1'
+ s.add_dependency 'bootstrap-sass', '~> 2.0.0'
+
+ # Development dependencies (usually used for testing)
+ s.add_development_dependency 'refinerycms-testing', '~> 2.0.1'
+end
18 spec/models/refinery/bootstrap/bootstrap_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+module Refinery
+ module Bootstrap
+ describe Bootstrap do
+ describe "validations" do
+ subject do
+ FactoryGirl.create(:bootstrap,
+ :title => "Refinery CMS")
+ end
+
+ it { should be_valid }
+ its(:errors) { should be_empty }
+ its(:title) { should == "Refinery CMS" }
+ end
+ end
+ end
+end
101 spec/requests/refinery/bootstrap/admin/bootstrap_spec.rb
@@ -0,0 +1,101 @@
+# encoding: utf-8
+require "spec_helper"
+
+describe Refinery do
+ describe "Bootstrap" do
+ describe "Admin" do
+ describe "bootstrap" do
+ login_refinery_user
+
+ describe "bootstrap list" do
+ before(:each) do
+ FactoryGirl.create(:bootstrap, :title => "UniqueTitleOne")
+ FactoryGirl.create(:bootstrap, :title => "UniqueTitleTwo")
+ end
+
+ it "shows two items" do
+ visit refinery.bootstrap_admin_bootstrap_path
+ page.should have_content("UniqueTitleOne")
+ page.should have_content("UniqueTitleTwo")
+ end
+ end
+
+ describe "create" do
+ before(:each) do
+ visit refinery.bootstrap_admin_bootstrap_path
+
+ click_link "Add New Bootstrap"
+ end
+
+ context "valid data" do
+ it "should succeed" do
+ fill_in "Title", :with => "This is a test of the first string field"
+ click_button "Save"
+
+ page.should have_content("'This is a test of the first string field' was successfully added.")
+ Refinery::Bootstrap::Bootstrap.count.should == 1
+ end
+ end
+
+ context "invalid data" do
+ it "should fail" do
+ click_button "Save"
+
+ page.should have_content("Title can't be blank")
+ Refinery::Bootstrap::Bootstrap.count.should == 0
+ end
+ end
+
+ context "duplicate" do
+ before(:each) { FactoryGirl.create(:bootstrap, :title => "UniqueTitle") }
+
+ it "should fail" do
+ visit refinery.bootstrap_admin_bootstrap_path
+
+ click_link "Add New Bootstrap"
+
+ fill_in "Title", :with => "UniqueTitle"
+ click_button "Save"
+
+ page.should have_content("There were problems")
+ Refinery::Bootstrap::Bootstrap.count.should == 1
+ end
+ end
+
+ end
+
+ describe "edit" do
+ before(:each) { FactoryGirl.create(:bootstrap, :title => "A title") }
+
+ it "should succeed" do
+ visit refinery.bootstrap_admin_bootstrap_path
+
+ within ".actions" do
+ click_link "Edit this bootstrap"
+ end
+
+ fill_in "Title", :with => "A different title"
+ click_button "Save"
+
+ page.should have_content("'A different title' was successfully updated.")
+ page.should have_no_content("A title")
+ end
+ end
+
+ describe "destroy" do
+ before(:each) { FactoryGirl.create(:bootstrap, :title => "UniqueTitleOne") }
+
+ it "should succeed" do
+ visit refinery.bootstrap_admin_bootstrap_path
+
+ click_link "Remove this bootstrap forever"
+
+ page.should have_content("'UniqueTitleOne' was successfully removed.")
+ Refinery::Bootstrap::Bootstrap.count.should == 0
+ end
+ end
+
+ end
+ end
+ end
+end
50 spec/spec_helper.rb
@@ -0,0 +1,50 @@
+def setup_environment
+ # Configure Rails Environment
+ ENV["RAILS_ENV"] ||= 'test'
+
+ require File.expand_path("../dummy/config/environment", __FILE__)
+
+ require 'rspec/rails'
+ require 'capybara/rspec'
+
+ Rails.backtrace_cleaner.remove_silencers!
+
+ RSpec.configure do |config|
+ config.mock_with :rspec
+ config.treat_symbols_as_metadata_keys_with_true_values = true
+ config.filter_run :focus => true
+ config.run_all_when_everything_filtered = true
+ end
+end
+
+def each_run
+ Rails.cache.clear
+ ActiveSupport::Dependencies.clear
+ FactoryGirl.reload
+
+ # Requires supporting files with custom matchers and macros, etc,
+ # in ./support/ and its subdirectories including factories.
+ ([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
+ Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
+ }.flatten.sort.each do |support_file|
+ require support_file
+ end
+end
+
+# If spork is available in the Gemfile it'll be used but we don't force it.
+unless (begin; require 'spork'; rescue LoadError; nil end).nil?
+ Spork.prefork do
+ # Loading more in this block will cause your tests to run faster. However,
+ # if you change any configuration or code from libraries loaded here, you'll
+ # need to restart spork for it take effect.
+ setup_environment
+ end
+
+ Spork.each_run do
+ # This code will be run each time you run your specs.
+ each_run
+ end
+else
+ setup_environment
+ each_run
+end
7 spec/support/factories/refinery/bootstrap.rb
@@ -0,0 +1,7 @@
+
+FactoryGirl.define do
+ factory :bootstrap, :class => Refinery::Bootstrap::Bootstrap do
+ sequence(:title) { |n| "refinery#{n}" }
+ end
+end
+
6 tasks/rspec.rake
@@ -0,0 +1,6 @@
+require 'rspec/core/rake_task'
+
+desc "Run specs"
+RSpec::Core::RakeTask.new do |t|
+ t.pattern = "./spec"
+end
8 tasks/testing.rake
@@ -0,0 +1,8 @@
+namespace :refinery do
+ namespace :testing do
+ # Put any code in here that you want run when you test this extension against a dummy app.
+ # For example, the call to require your gem and start your generator.
+ task :setup_extension do
+ end
+ end
+end

0 comments on commit c7bdf58

Please sign in to comment.