merge Dirk's branch + upgrade a lot of gems (rails, ...etc)

This commit is contained in:
did 2011-02-12 15:00:57 +01:00
commit 94be90986d
17 changed files with 224 additions and 91 deletions

13
Gemfile
View File

@ -2,14 +2,14 @@ source :rubygems
# add in all the runtime dependencies
gem 'rails', '>= 3.0.3'
gem 'rails', '>= 3.0.4'
gem 'warden'
gem 'devise', '= 1.1.3'
gem 'mongoid', '~> 2.0.0.rc.7'
gem 'bson_ext', '1.2.0'
gem 'locomotive_mongoid_acts_as_tree', '0.1.5.2', :require => 'mongoid_acts_as_tree'
gem 'bson_ext', '~> 1.2.1'
gem 'locomotive_mongoid_acts_as_tree', '0.1.5.5', :require => 'mongoid_acts_as_tree' #, :path => '../gems/acts_as_tree'
gem 'will_paginate'
gem 'haml', '3.0.25'
@ -18,7 +18,8 @@ gem 'formtastic', '~> 1.2.3'
gem 'inherited_resources', '~> 1.1.2'
gem 'rmagick', '2.12.2'
gem 'locomotive_carrierwave', '0.5.0.1.beta2', :require => 'carrierwave'
# gem 'locomotive_carrierwave', '0.5.0.1.beta2', :require => 'carrierwave'
gem 'carrierwave', :path => '/Users/didier/Desktop/carrierwave'
gem 'custom_fields', '1.0.0.beta.4'
gem 'fog', '0.3.7'
@ -26,7 +27,7 @@ gem 'mimetype-fu'
gem 'actionmailer-with-request'
gem 'heroku'
gem 'httparty', '>= 0.6.1'
gem 'RedCloth'
gem 'RedCloth', '4.2.7'
gem 'delayed_job', '2.1.2'
gem 'delayed_job_mongoid', '1.0.2'
gem 'rubyzip'
@ -59,4 +60,4 @@ group :test do
gem 'spork'
gem 'launchy'
gem 'mocha', :git => 'git://github.com/floehopper/mocha.git'
end
end

View File

@ -1,52 +1,58 @@
GIT
remote: git://github.com/floehopper/mocha.git
revision: aae7fdfdff52bb759cca74a2459ce105bba6ff10
revision: 4fb88aea21f12c4fb7a8b14e8b58c5d9bb6829a8
specs:
mocha (0.9.11.20110203233621)
rake
PATH
remote: /Users/didier/Desktop/carrierwave
specs:
carrierwave (0.5.1)
activesupport (~> 3.0)
GEM
remote: http://rubygems.org/
specs:
RedCloth (4.2.3)
RedCloth (4.2.7)
ZenTest (4.4.2)
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (= 3.0.3)
mail (~> 2.2.9)
actionmailer (3.0.4)
actionpack (= 3.0.4)
mail (~> 2.2.15)
actionmailer-with-request (0.1.1)
actionpack (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
actionpack (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.3)
activesupport (= 3.0.3)
activemodel (3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activerecord (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
activeresource (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
activesupport (3.0.4)
archive-tar-minitar (0.5.2)
arel (2.0.7)
arel (2.0.8)
autotest (4.4.6)
ZenTest (>= 4.4.1)
bcrypt-ruby (2.1.4)
bson (1.2.0)
bson_ext (1.2.0)
bson (1.2.1)
bson_ext (1.2.1)
builder (2.1.2)
capybara (0.4.1.1)
capybara (0.4.1.2)
celerity (>= 0.7.9)
culerity (>= 0.2.4)
mime-types (>= 1.16)
@ -76,7 +82,7 @@ GEM
locomotive_carrierwave
mongoid (~> 2.0.0.rc.6)
daemons (1.1.0)
database_cleaner (0.6.1)
database_cleaner (0.6.3)
delayed_job (2.1.2)
activesupport (~> 3.0)
daemons
@ -89,7 +95,7 @@ GEM
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
excon (0.4.0)
excon (0.5.2)
factory_girl (1.3.3)
factory_girl_rails (1.0.1)
factory_girl (~> 1.3)
@ -130,23 +136,22 @@ GEM
yui-compressor (>= 0.9.1)
json (1.5.1)
json_pure (1.4.6)
kgio (2.2.0)
kgio (2.3.0)
launchy (0.3.7)
configuration (>= 0.0.5)
rake (>= 0.8.1)
linecache (0.43)
linecache19 (0.5.11)
ruby_core_source (>= 0.1.4)
locomotive_carrierwave (0.5.0.1.beta2)
locomotive_carrierwave (0.5.0.1)
activesupport (~> 3.0)
locomotive_jammit-s3 (0.5.4.4)
jammit (>= 0.5.4)
mimemagic (>= 0.1.7)
s3 (>= 0.3.7)
locomotive_liquid (2.2.2)
locomotive_mongoid_acts_as_tree (0.1.5.2)
bson (>= 0.20.1)
mongoid (>= 2.0.0.rc.6)
locomotive_mongoid_acts_as_tree (0.1.5.5)
mongoid (~> 2.0.0.rc.7)
mail (2.2.15)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
@ -155,8 +160,8 @@ GEM
mime-types (1.16)
mimemagic (0.1.8)
mimetype-fu (0.1.2)
mongo (1.2.0)
bson (>= 1.2.0)
mongo (1.2.1)
bson (>= 1.2.1)
mongoid (2.0.0.rc.7)
activemodel (~> 3.0)
mongo (~> 1.2)
@ -176,17 +181,17 @@ GEM
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.3)
actionmailer (= 3.0.3)
actionpack (= 3.0.3)
activerecord (= 3.0.3)
activeresource (= 3.0.3)
activesupport (= 3.0.3)
rails (3.0.4)
actionmailer (= 3.0.4)
actionpack (= 3.0.4)
activerecord (= 3.0.4)
activeresource (= 3.0.4)
activesupport (= 3.0.4)
bundler (~> 1.0)
railties (= 3.0.3)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
railties (= 3.0.4)
railties (3.0.4)
actionpack (= 3.0.4)
activesupport (= 3.0.4)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
@ -238,8 +243,8 @@ GEM
polyglot (>= 0.3.1)
trollop (1.16.2)
tzinfo (0.3.24)
unicorn (3.3.1)
kgio (~> 2.1)
unicorn (3.4.0)
kgio (~> 2.2)
rack
warden (0.10.7)
rack (>= 1.0.0)
@ -253,12 +258,13 @@ PLATFORMS
ruby
DEPENDENCIES
RedCloth
RedCloth (= 4.2.7)
ZenTest
actionmailer-with-request
autotest
bson_ext (= 1.2.0)
bson_ext (~> 1.2.1)
capybara
carrierwave!
cucumber (= 0.8.5)
cucumber-rails
custom_fields (= 1.0.0.beta.4)
@ -275,15 +281,14 @@ DEPENDENCIES
httparty (>= 0.6.1)
inherited_resources (~> 1.1.2)
launchy
locomotive_carrierwave (= 0.5.0.1.beta2)
locomotive_jammit-s3
locomotive_liquid (= 2.2.2)
locomotive_mongoid_acts_as_tree (= 0.1.5.2)
locomotive_mongoid_acts_as_tree (= 0.1.5.5)
mimetype-fu
mocha!
mongoid (~> 2.0.0.rc.7)
pickle
rails (>= 3.0.3)
rails (>= 3.0.4)
rmagick (= 2.12.2)
rspec-rails (= 2.3.1)
ruby-debug

View File

@ -12,9 +12,9 @@ module Admin
end
def create
create! do |success, failure|
success.html { redirect_to edit_admin_content_url(@content_type.slug, @content) }
end
@content = @content_type.contents.create(params[:content])
respond_with(@content, :location => edit_admin_content_url(@content_type.slug, @content))
end
def update

View File

@ -23,8 +23,12 @@ module Admin
success.json do
render :json => image_to_json(@asset)
end
failure.json { render :json => { :status => 'error' } }
failure.json do
render :json => { :status => 'error' }
end
end
rescue Exception => e
render :json => { :status => 'error', :message => e.message }
end
protected

View File

@ -0,0 +1,19 @@
module Models
module Extensions
module Page
module Listed
extend ActiveSupport::Concern
included do
field :listed, :type => Boolean, :default => true
end
end
end
end
end

View File

@ -9,6 +9,7 @@ class Page
include Models::Extensions::Page::Render
include Models::Extensions::Page::Templatized
include Models::Extensions::Page::Redirect
include Models::Extensions::Page::Listed
## fields ##
field :title
@ -42,7 +43,7 @@ class Page
scope :not_found, :where => { :slug => '404', :depth => 0 }
scope :published, :where => { :published => true }
scope :fullpath, lambda { |fullpath| { :where => { :fullpath => fullpath } } }
scope :minimal_attributes, :only => %w(title slug fullpath position depth published templatized parent_id created_at updated_at)
scope :minimal_attributes, :only => %w(title slug fullpath position depth published templatized listed parent_id created_at updated_at)
## methods ##

View File

@ -9,16 +9,19 @@
- if not @page.index? and not @page.not_found?
= f.input :parent_id, :as => :select, :collection => parent_pages_options, :include_blank => false
= f.input :slug, :required => false, :hint => @page.slug.blank? ? ' ' : @page.url, :input_html => { :data_url => get_path_admin_pages_url, :disabled => @page.index? || @page.not_found? }, :wrapper_html => { :style => "#{'display: none' if @page.templatized?}" }
= f.input :slug, :required => false, :hint => @page.slug.blank? ? ' ' : @page.url, :input_html => { :data_url => get_path_admin_pages_url, :disabled => @page.index? || @page.not_found? }, :wrapper_html => { :style => "#{'display: none' if @page.templatized?}; height: 50px" }
= f.input :content_type_id, :as => :select, :collection => current_site.content_types.all.to_a, :include_blank => false, :wrapper_html => { :style => "#{'display: none' unless @page.templatized?}; height: 50px" }
= f.custom_input :templatized, :css => 'toggle', :style => "#{'display: none' if @page.redirect?}" do
= f.check_box :templatized
= f.input :content_type_id, :as => :select, :collection => current_site.content_types.all.to_a, :include_blank => false, :wrapper_html => { :style => "#{'display: none' unless @page.templatized?}" }
= f.custom_input :published, :css => 'toggle' do
= f.check_box :published
= f.custom_input :listed, :css => 'toggle' do
= f.check_box :listed
= f.custom_input :redirect, :css => 'toggle', :style => "#{'display: none' if @page.templatized?}" do
= f.check_box :redirect

View File

@ -22,7 +22,7 @@ fr:
shared:
header:
welcome: Bonjour, %{name}
welcome: "Bonjour, %{name}"
see: Voir le site web
logout: Se déconnecter
menu:

View File

@ -43,6 +43,8 @@ en:
published: "Only authenticated accounts can view unpublished pages."
cache_strategy: "Cache the page for better performance. The 'Simple' choice is a good compromise."
templatized: "Use the page as a template for a model you defined."
listed: "Control whether to show the page from generated menus."
content_type_id: "The type of content this page will be a template for."
snippet:
slug: "You need to know it in order to insert the snippet inside a page"
site:

View File

@ -46,6 +46,8 @@ fr:
published: "Seuls les administrateurs authentifiés peuvent voir une page non publiée."
cache_strategy: "Cache la page pour de meilleure performance. L'option 'Simple' est le meilleur compromis."
templatized: "Utilise la page comme un template pour un modèle défini."
listed: "Controle si la page doit être visible depuis les menus automatiquement générés."
content_type_id: "Le type du contenu pour lequel cette page est un template."
snippet:
slug: "Utilisé pour insérer le snippet dans une page."
site:

View File

@ -4,11 +4,13 @@ module Locomotive
# Display the children pages of the site, current page or the parent page. If not precised, nav is applied on the current page.
# The html output is based on the ul/li tags.
#
# Passing through depth will control how many nested children are output
#
# Usage:
#
# {% nav site %} => <ul class="nav"><li class="on"><a href="/features">Features</a></li></ul>
#
# {% nav site, no_wrapper: true, exclude: 'contact|about', id: 'main-nav' }
# {% nav site, no_wrapper: true, depth: 1, exclude: 'contact|about', id: 'main-nav' }
#
class Nav < ::Liquid::Tag
@ -17,7 +19,7 @@ module Locomotive
def initialize(tag_name, markup, tokens, context)
if markup =~ Syntax
@source = ($1 || 'page').gsub(/"|'/, '')
@options = { :id => 'nav' }
@options = { :id => 'nav', :depth => 1 }
markup.scan(::Liquid::TagAttributes) { |key, value| @options[key.to_sym] = value.gsub(/"|'/, '') }
@options[:exclude] = Regexp.new(@options[:exclude]) if @options[:exclude]
@ -38,7 +40,7 @@ module Locomotive
css << 'first' if index == 0
css << 'last' if index == entries.size - 1
children_output << render_entry_link(p, css.join(' '))
children_output << render_entry_link(p,css.join(' '), 1)
end
output = children_output.join("\n")
@ -52,6 +54,7 @@ module Locomotive
private
# Determines root node for the list
def fetch_entries(context)
@current_page = context.registers[:page]
@ -66,8 +69,44 @@ module Locomotive
children.delete_if { |p| !include_page?(p) }
end
# Returns a list element, a link to the page and its children
def render_entry_link(page,css,depth)
selected = @current_page.fullpath =~ /^#{page.fullpath}/ ? ' on' : ''
icon = @options[:icon] ? '<span></span>' : ''
label = %{#{icon if @options[:icon] != 'after' }#{page.title}#{icon if @options[:icon] == 'after' }}
output = %{<li id="#{page.slug.dasherize}" class="link#{selected} #{css}">}
output << %{<a href="/#{page.fullpath}">#{label}</a>}
output << render_entry_children(page,depth.succ) if (depth.succ <= @options[:depth].to_i)
output << %{</li>}
output.strip
end
# Recursively creates a nested unordered list for the depth specified
def render_entry_children(page,depth)
output = %{}
children = page.children_with_minimal_attributes.reject { |c| !include_page?(c) }
if children.present?
output = %{<ul id="#{@options[:id]}-#{page.slug.dasherize}">}
children.each do |c, page|
css = []
css << 'first' if children.first == c
css << 'last' if children.last == c
output << render_entry_link(c,css.join(' '),depth)
end
output << %{</ul>}
end
output
end
# Determines whether or not a page should be a part of the menu
def include_page?(page)
if page.templatized? || !page.published?
if !page.listed? || page.templatized? || !page.published?
false
elsif @options[:exclude]
(page.fullpath =~ @options[:exclude]).nil?
@ -76,19 +115,6 @@ module Locomotive
end
end
def render_entry_link(page, css)
selected = @current_page.fullpath =~ /^#{page.fullpath}/ ? ' on' : ''
icon = @options[:icon] ? '<span></span>' : ''
label = %{#{icon if @options[:icon] != 'after' }#{page.title}#{icon if @options[:icon] == 'after' }}
%{
<li id="#{page.slug.dasherize}" class="link#{selected} #{css}">
<a href="/#{page.fullpath}">#{label}</a>
</li>
}.strip
end
::Liquid::Template.register_tag('nav', Nav)
end
end

View File

@ -52,6 +52,13 @@ module ActionDispatch
Marshal.load(packed.unpack("m*").first)
end
def destroy(env)
session = @@session_class.first(:conditions => { :_id => env[SESSION_RECORD_KEY].id })
session.destroy
env[SESSION_RECORD_KEY] = nil
end
end
end
end

View File

@ -17,12 +17,12 @@ Gem::Specification.new do |s|
s.required_rubygems_version = ">= 1.3.6"
s.rubyforge_project = "nowarning"
s.add_dependency "rails", ">= 3.0.3"
s.add_dependency "rails", ">= 3.0.4"
s.add_dependency "warden"
s.add_dependency "devise", "1.1.3"
s.add_dependency "mongoid", "~> 2.0.0.rc.7"
s.add_dependency "bson_ext", "~> 1.2.0"
s.add_dependency "locomotive_mongoid_acts_as_tree", "0.1.5.2"
s.add_dependency "locomotive_mongoid_acts_as_tree", "0.1.5.5"
s.add_dependency "will_paginate"
s.add_dependency "haml", "3.0.25"
@ -34,12 +34,12 @@ Gem::Specification.new do |s|
s.add_dependency "locomotive_carrierwave", "0.5.0.1.beta2"
s.add_dependency "custom_fields", "1.0.0.beta.4"
s.add_dependency "fog"
s.add_dependency "fog", "0.3.7"
s.add_dependency "mimetype-fu"
s.add_dependency "actionmailer-with-request"
s.add_dependency "heroku"
s.add_dependency "httparty", ">= 0.6.1"
s.add_dependency "RedCloth"
s.add_dependency "RedCloth", "4.2.7"
s.add_dependency "delayed_job", "2.1.2"
s.add_dependency "delayed_job_mongoid", "1.0.2"
s.add_dependency "rubyzip"
@ -59,4 +59,4 @@ Gem::Specification.new do |s|
"README.textile"
]
end
end

View File

@ -56,7 +56,8 @@ var TinyMceDefaultSettings = {
theme_advanced_toolbar_align : "left",
height: '300',
width: '710',
inlinepopups_skin: 'locomotive'
inlinepopups_skin: 'locomotive',
convert_urls: false
};
/* ___ global ___ */

View File

@ -31,18 +31,20 @@ $(document).ready(function() {
}, 'json');
}
});
// templatized feature
$.subscribe('toggle.page_templatized.checked', function(event, data) {
$('#page_slug_input').hide();
$('#page_redirect').parent('li').hide();
$('#page_listed').parent('li').hide();
$('#page_content_type_id_input').show();
}, []);
$.subscribe('toggle.page_templatized.unchecked', function(event, data) {
$('#page_slug_input').show();
$('#page_redirect').parent('li').show();
$('#page_listed').parent('li').show();
$('#page_slug').val(makeSlug($('#page_title').val())).addClass('touched');
$('#page_content_type_id_input').hide();
}, []);

View File

@ -13,8 +13,11 @@ describe Locomotive::Liquid::Tags::Nav do
other_children = [
Page.new(:title => 'Child #2.1', :fullpath => 'child_2/sub_child_1', :slug => 'sub_child_1', :published => true),
Page.new(:title => 'Child #2.2', :fullpath => 'child_2/sub_child_2', :slug => 'sub_child_2', :published => true)
]
Page.new(:title => 'Child #2.2', :fullpath => 'child_2/sub_child_2', :slug => 'sub_child_2', :published => true),
Page.new(:title => 'Unpublished #2.2', :fullpath => 'child_2/sub_child_unpublishd_2', :slug => 'sub_child_unpublished_2', :published => false),
Page.new(:title => 'Templatized #2.3', :fullpath => 'child_2/sub_child_template_3', :slug => 'sub_child_template_3', :published => true, :templatized => true),
Page.new(:title => 'Unlisted #2.4', :fullpath => 'child_2/sub_child_unlisted_4', :slug => 'sub_child_unlisted_4', :published => true, :listed => false)
]
@home.children.last.stubs(:children_with_minimal_attributes).returns(other_children)
@home.children.last.stubs(:children).returns(other_children)
@ -40,7 +43,50 @@ describe Locomotive::Liquid::Tags::Nav do
output = render_nav 'parent', { :page => page }
output.should == '<ul id="nav"><li id="sub-child-1" class="link on first"><a href="/child_2/sub_child_1">Child #2.1</a></li><li id="sub-child-2" class="link last"><a href="/child_2/sub_child_2">Child #2.2</a></li></ul>'
end
it 'renders children to depth' do
output = render_nav('site', {}, 'depth: 2')
output.should match /<ul id="nav">/
output.should match /<li id="child-1" class="link first">/
output.should match /<\/a><ul id="nav-child-2">/
output.should match /<li id="sub-child-1" class="link first">/
output.should match /<li id="sub-child-2" class="link last">/
output.should match /<\/a><\/li><\/ul><\/li><\/ul>/
end
it 'does not render templatized pages' do
output = render_nav('site', {}, 'depth: 2')
output.should_not match /sub-child-template-3/
end
it 'does not render unpublished pages' do
output = render_nav('site', {}, 'depth: 2')
output.should_not match /sub-child-unpublished-3/
end
it 'does not render unlisted pages' do
output = render_nav('site', {}, 'depth: 2')
output.should_not match /sub-child-unlisted-3/
end
it 'does not render nested excluded pages' do
output = render_nav('site', {}, 'depth: 2, exclude: "child_2/sub_child_2"')
output.should match /<li id="child-2" class="link last">/
output.should match /<li id="sub-child-1" class="link first last">/
output.should_not match /sub-child-2/
output = render_nav('site', {}, 'depth: 2, exclude: "child_2"')
output.should match /<li id="child-1" class="link first last">/
output.should_not match /child-2/
output.should_not match /sub-child/
end
it 'adds an icon before the link' do
render_nav('site', {}, 'icon: true').should match /<li id="child-1" class="link first"><a href="\/child_1"><span><\/span>Child #1<\/a>/
render_nav('site', {}, 'icon: before').should match /<li id="child-1" class="link first"><a href="\/child_1"><span><\/span>Child #1<\/a>/

View File

@ -205,6 +205,20 @@ describe Page do
end
end
describe 'listed extension' do
it 'is considered as a visible page' do
@page = Factory.build(:page, :site => nil, :content_type_id => 42)
@page.listed?.should be_true
end
it 'is not considered as a visible page' do
@page = Factory.build(:page, :site => nil, :listed => false, :content_type_id => 42)
@page.listed?.should be_false
end
end
describe 'redirect extension' do