Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
frisoft committed Jul 11, 2011
2 parents 33b2b83 + dc9570d commit d5e2d20
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gem 'locomotive_liquid', '2.2.2', :require => 'liquid'
gem 'formtastic', '~> 1.2.3'
gem 'inherited_resources', '~> 1.1.2'

gem 'rmagick', '2.12.2'
gem 'rmagick', '2.12.2', :require => 'RMagick'
gem 'locomotive_carrierwave', '0.5.4.beta3'
gem 'dragonfly', '~> 0.9.1'
gem 'rack-cache', :require => 'rack/cache'
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ require File.expand_path('../config/application', __FILE__)

require 'rubygems'

require 'rake/dsl_definition'
require 'rake'
require 'rdoc/task'
require 'rubygems/package_task'
Expand Down
8 changes: 4 additions & 4 deletions doc/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,9 @@ x Rights to set roles (ticket #104)
x export: problems with templatized pages (source => multi levels pages)
x do not rename files for fonts
x icon for redirection page in the pages section (back-office)
- tooltip to explain the difference between 1.) Admin 2.) Author 3.) Designer?
- installed on heroku with source
- test and/or convert existing templates (the 2 of the themes section)

- [bushido] guiders / welcome page / devise cas authentication (SSO)


BACKLOG:

- custom_fields:
Expand All @@ -99,6 +96,9 @@ BACKLOG:
- import only theme assets
- endless pagination
- overide sort for contents
- tooltip to explain the difference between 1.) Admin 2.) Author 3.) Designer?
- [bushido] guiders / welcome page / devise cas authentication (SSO)


REFACTORING:

Expand Down
2 changes: 1 addition & 1 deletion lib/locomotive/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def manage_subdomain_n_domains?
self.manage_subdomain? && self.manage_domains?
end

def reserved_domains
def reserved_subdomains
if self.multi_sites?
if self.multi_sites.reserved_subdomains.blank?
@@defaults[:reserved_subdomains]
Expand Down
19 changes: 12 additions & 7 deletions lib/locomotive/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Export
def initialize(site, filename = nil)
@site = site
@filename = filename || Time.now.to_i.to_s
@target_folder = File.join(Rails.root, 'tmp', 'export', filename)
@target_folder = File.join(Rails.root, 'tmp', 'export', @filename)
@site_hash = {} # used to generate the site.yml and compiled_site.yml files

self.create_target_folder
Expand Down Expand Up @@ -259,7 +259,7 @@ def extract_contents(content_type)
content.custom_fields.each do |field|
next if field._name == highlighted_field_name

case field.kind
value = (case field.kind
when 'file'
uploader = content.send(field._name)
unless uploader.blank?
Expand All @@ -268,13 +268,18 @@ def extract_contents(content_type)
else
filepath = nil
end
hash[field._alias] = filepath
filepath
when 'text'
value = self.replace_asset_urls_in(content.send(field._name.to_sym) || '')
hash[field._alias] = value
self.replace_asset_urls_in(content.send(field._name.to_sym) || '')
when 'has_one'
content.send(field.safe_alias.to_sym).highlighted_field_value
when 'has_many'
content.send(field.safe_alias.to_sym).collect(&:highlighted_field_value)
else
hash[field._alias] = content.send(field._name.to_sym)
end
content.send(field.safe_alias.to_sym)
end)

hash[field._alias] = value
end

data << { content.highlighted_field_value => hash }
Expand Down
2 changes: 1 addition & 1 deletion public/stylesheets/admin/box.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ body { background: #000 url(/images/admin/background/body.png) repeat 0 0; }
padding: 0px;
}

#panel fieldset ol li p.inline-errors {
#panel fieldset ol li div.inline-errors p {
padding: 3px 5px;
margin: 5px 0px;
background: #FFE5E5;
Expand Down
10 changes: 2 additions & 8 deletions public/stylesheets/admin/editable_elements.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#editable-elements .wrapper {
background: #ebedf4 url(/images/admin/form/footer.png) no-repeat 0 bottom;
width: 880px;
padding: 10px 20px 0px 20px;
padding: 10px 0px 16px 0px;
border-top: 1px solid #ccced7;
}

Expand Down Expand Up @@ -57,9 +56,4 @@

#editable-elements .wrapper ul li fieldset { margin-bottom: 0px; }

#editable-elements .wrapper ul li fieldset ol { margin-top: 0px; border-top: 0px; background: #EBEDF4; }
#editable-elements .wrapper ul li fieldset ol li label { padding-left: 0px; padding-right: 3em; }
#editable-elements .wrapper ul li fieldset ol li p.remove,
#editable-elements .wrapper ul li fieldset ol li p.inline-hints { margin-left: 13.3em; }
#editable-elements .wrapper ul li fieldset ol li input[type=text] { width: 695px; }

#editable-elements .wrapper ul li fieldset ol { margin-top: 0px; border-top: 0px; background: #EBEDF4; }
19 changes: 19 additions & 0 deletions spec/lib/locomotive/configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper'

describe Locomotive::Configuration do

before(:each) do
@old_config = Locomotive.config.dup
end

it 'allows a different value for the reserved subdomains' do
Locomotive.config.reserved_subdomains.include?('www').should be_true # by default
Locomotive.config.multi_sites { |multi_sites| multi_sites.reserved_subdomains = %w(empty) }
Locomotive.config.reserved_subdomains.should == ['empty']
end

after(:each) do
Locomotive.config = @old_config
end

end
59 changes: 58 additions & 1 deletion spec/lib/locomotive/export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,64 @@

describe Locomotive::Export do

context 'when successful' do
context '#content_type' do

before(:each) do
site = Factory.build('another site')
Site.stubs(:find).returns(site)
project_type = build_project_type(site)
project_type.contents.build(:title => 'Project #1', :description => 'Lorem ipsum', :active => true)
project_type.contents.build(:title => 'Project #2', :description => 'More Lorem ipsum', :active => false)

team_type = build_team_type(site, project_type)
team_type.contents.build(:name => 'Ben', :projects => project_type.contents, :current_project => project_type.contents.first)
team_type.contents.build(:name => 'Zach', :current_project => project_type.contents.last)

@project_data = ::Locomotive::Export.new(site).send(:extract_contents, project_type)
@team_data = ::Locomotive::Export.new(site).send(:extract_contents, team_type)
end

it 'includes the exact number of contents' do
@project_data.size.should == 2
@project_data.collect { |n| n.keys.first }.should == ['Project #1', 'Project #2']
end

it 'deals with real booleans' do
@project_data.first.values.first['active'].should be_true
end

it 'stores the list of highlighted values in a has_many relationship' do
@team_data.first.values.first['projects'].size.should == 2
@team_data.first.values.first['projects'].should == ['Project #1', 'Project #2']
@team_data.last.values.first['projects'].should == []
end

it 'stores a highlighted value in a has_one relationship' do
@team_data.collect { |n| n.values.first['current_project'] }.should == ['Project #1', 'Project #2']
end

def build_project_type(site)
Factory.build(:content_type, :site => site, :highlighted_field_name => 'custom_field_1').tap do |content_type|
content_type.content_custom_fields.build :label => 'Title', :_alias => 'title', :kind => 'string'
content_type.content_custom_fields.build :label => 'My Description', :_alias => 'description', :kind => 'text'
content_type.content_custom_fields.build :label => 'Active', :kind => 'boolean'
end
end

def build_team_type(site, project_type)
Object.send(:remove_const, 'TestProject') rescue nil
klass = Object.const_set('TestProject', Class.new { def self.embedded?; false; end })
content_type = Factory.build(:content_type, :site => site, :name => 'team', :highlighted_field_name => 'custom_field_1')
content_type.content_custom_fields.build :label => 'Name', :_alias => 'name', :kind => 'string'
content_type.content_custom_fields.build :label => 'Projects', :kind => 'has_many', :_alias => 'projects', :target => 'TestProject'
content_type.content_custom_fields.build :label => 'Bio', :_alias => 'bio', :kind => 'text'
content_type.content_custom_fields.build :label => 'Current Project', :kind => 'has_one', :_alias => 'current_project', :target => 'TestProject'
content_type
end

end

context '#zipfile' do

before(:all) do
@site = Factory('another site')
Expand Down

0 comments on commit d5e2d20

Please sign in to comment.