Skip to content

Commit

Permalink
Fixed merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
dlozano committed May 8, 2012
2 parents dd8dda5 + 6fd87c3 commit 01db6b9
Show file tree
Hide file tree
Showing 27 changed files with 352 additions and 76 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.3
0.8.1
3 changes: 3 additions & 0 deletions app/controllers/ubiquo/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def index
format.xml {
render :xml => @pages
}
format.js {
render :json => @pages.to_json(:only => [:id, :name])
}
end
end

Expand Down
28 changes: 20 additions & 8 deletions app/controllers/ubiquo/static_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ def new
end

def create
default_page_params = { :is_static => true }
default_page_params = { :is_static => true, :page_template => "static" }
default_widget_params = { :name => "Static Section" }
@static_page = Page.new(params[:page].merge!(default_page_params))
@static_page = Page.new(params[:page].reverse_merge!(default_page_params))
@widget = uhook_create_widget
block_type = Ubiquo::Config.context(:ubiquo_design).get(:block_type_for_static_section_widget)
if params[:publish_page] == "true"
ok = @static_page.add_widget(:main, @widget) && @static_page.publish
ok = @static_page.add_widget(block_type, @widget) && @static_page.publish
else
ok = @static_page.add_widget(:main, @widget)
ok = @static_page.add_widget(block_type, @widget)
end
respond_to do |format|
if ok
Expand All @@ -61,14 +62,15 @@ def create

def edit
@static_page = Page.find(params[:id])
@widget = @static_page.uhook_static_section_widget(current_locale) || uhook_new_widget
@widget = @static_page.uhook_static_section_widget || uhook_new_widget
end

def update
@static_page = Page.find(params[:id])
@widget = params[:from].present? ? uhook_new_widget : (@static_page.uhook_static_section_widget(current_locale) || uhook_create_widget)
@widget = params[:from].present? ? uhook_new_widget : (@static_page.uhook_static_section_widget || uhook_create_widget)
if @widget.new_record?
@static_page.add_widget(:main, @widget)
block_type = Ubiquo::Config.context(:ubiquo_design).get(:block_type_for_static_section_widget)
@static_page.add_widget(block_type, @widget)
else
@widget.update_attributes(params[:static_section])
end
Expand Down Expand Up @@ -114,7 +116,17 @@ def publish
end
redirect_to :action => "edit"
end


def unpublish
static_page = Page.find(params[:id])
if static_page.unpublish
flash[:notice] = t('ubiquo.design.page_unpublished')
else
flash[:error] = t('ubiquo.design.page_unpublish_error')
end
redirect_to :action => "edit"
end

private

def load_page_templates
Expand Down
16 changes: 15 additions & 1 deletion app/controllers/ubiquo/widgets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,21 @@ def update
def change_name
@widget = Widget.find(params[:id])
@widget.update_attributes(:name => params[:value])
render :inline => @widget.name
respond_to do |format|
format.js do
js_response = render_to_string :update do |page|
self.uhook_extra_rjs_on_update(page, true) do |page|
page << 'myLightWindow.deactivate();'
page.replace_html("page_info", :partial => 'ubiquo/designs/pageinfo_sidebar',
:locals => { :page => @page.reload })
page.call "update_error_on_widgets", @page.wrong_widgets_ids
page.replace_html("widget_name_field_#{@widget.id}", @widget.name)
end
end

render :inline => "<%= javascript_tag(#{js_response.to_json}) %>", :locals => {:js_response => js_response }
end
end
end

def change_order
Expand Down
8 changes: 5 additions & 3 deletions app/models/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def publish
UbiquoDesign.cache_manager.expire_page(self) if ActionController::Base.perform_caching
end
return true
rescue Exception => e
rescue StandardError => e
return false
end
end
Expand Down Expand Up @@ -276,9 +276,11 @@ def add_widget(block_key, widget)
block = self.blocks.select { |b| b.block_type == block_key.to_s }.first
block ||= Block.create!(:page_id => self.id, :block_type => block_key.to_s)
block.widgets << widget
widget.save!
uhook_add_widget(widget) do
widget.save!
end
end
rescue Exception => e
rescue StandardError => e
return false
end
end
Expand Down
33 changes: 32 additions & 1 deletion app/models/widget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ class Widget < ActiveRecord::Base

@@behaviours = {}

@inheritable_attributes = inheritable_attributes.merge(:previewable => true)
@inheritable_attributes = inheritable_attributes.merge(
:previewable => true,
:clonation_exceptions => [:asset_relations]
)

cattr_accessor :behaviours

Expand Down Expand Up @@ -64,6 +67,9 @@ def self.allowed_options=(opts)
define_method("#{option}=") do |value|
self.options[option] = value
end
define_method("#{option}_before_type_cast") do
self.options[option]
end
end
end

Expand Down Expand Up @@ -147,6 +153,31 @@ def url
def expire(options = {})
UbiquoDesign.cache_manager.expire(self, options)
end

def self.clonation_exception(value)
exceptions = clonation_exceptions + [value.to_sym]
write_inheritable_attribute :clonation_exceptions, exceptions.uniq
end

def self.clonation_exceptions
Array(read_inheritable_attribute(:clonation_exceptions))
end

def self.is_a_clonable_has_one?(reflection)
reflection = self.reflections[reflection.to_sym] unless reflection.is_a?(ActiveRecord::Reflection::AssociationReflection)
reflection.macro == :has_one && is_relation_clonable?(reflection.name)
end

def self.is_a_clonable_has_many?(reflection)
reflection = self.reflections[reflection.to_sym] unless reflection.is_a?(ActiveRecord::Reflection::AssociationReflection)
reflection.macro == :has_many &&
!reflection.options.include?(:through) &&
is_relation_clonable?(reflection.name)
end

def self.is_relation_clonable?(relation_name)
!clonation_exceptions.include?(relation_name.to_sym)
end

private

Expand Down
15 changes: 11 additions & 4 deletions app/views/ubiquo/designs/_pageinfo_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,17 @@
<% end %>
<% end %>
<% if page.published? %>
<li>
<%= button_to t('ubiquo.design.unpublish'),
unpublish_ubiquo_page_design_path(page), :method => :put, :class => 'unpublish' %>
</li>
<% if page_type == "static_page" %>
<li>
<%= button_to t('ubiquo.design.unpublish'),
unpublish_ubiquo_static_page_path(page), :method => :put, :class => 'unpublish' %>
</li>
<% else %>
<li>
<%= button_to t('ubiquo.design.unpublish'),
unpublish_ubiquo_page_design_path(page), :method => :put, :class => 'unpublish' %>
</li>
<% end %>
<% end %>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/ubiquo/pages/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<% @page_templates.each do |template_key| %>
<li>
<%= f.radio_button(:page_template, template_key) %>
<%= f.label "page_template_#{template_key}", template_key %>
<%= f.label "page_template_#{template_key}", t("ubiquo.page_templates.#{template_key}") %>
<%= ubiquo_image_tag("page_templates/#{template_key}.png", {
:id => "page_template_#{template_key}",
:onclick => "$('page_' + this.id).click(); return false;"
Expand Down
24 changes: 2 additions & 22 deletions app/views/ubiquo/static_pages/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,6 @@
</div>
</fieldset>
</fieldset>
<% if @static_page.new_record? %>
<fieldset>
<legend><%= t('ubiquo.design.page_template') %></legend>
<ul class="page_templates">
<% @page_templates.each do |template_key| %>
<li>
<%= form.radio_button(:page_template, template_key) %>
<%= form.label "page_template_#{template_key}", template_key %>
<% # image_tag(template.thumbnail.url,
# :id => "page_template_#{template_key}",
# :onclick => "$('page_' + this.id).click(); return false;") %>
<%= ubiquo_image_tag("page_templates/#{template_key}.png", {
:id => "page_template_#{template_key}",
:onclick => "$('page_' + this.id).click(); return false;"
}) %>
</li>
<% end %>
</ul>
</fieldset>
<% end %>
<fieldset>
<legend><%= t('ubiquo.design.metatags') %></legend>
<div class="form-item">
Expand Down Expand Up @@ -70,13 +50,13 @@
<%= widget_form.text_area :body, :rows => 30, :class => 'visual_editor' %>
</div>
<% if widget_form.object.respond_to?(:image) %>
<fieldset>
<fieldset class="group-related-assets">
<legend><%= t('ubiquo.widgets.static_section.image') %></legend>
<%= media_selector widget_form, :image %>
</fieldset>
<% end %>
<% if widget_form.object.respond_to?(:docs) %>
<fieldset>
<fieldset class="group-related-assets">
<legend><%= t('ubiquo.widgets.static_section.docs') %></legend>
<%= media_selector widget_form, :docs %>
</fieldset>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/ca/ubiquo/ubiquo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ ca:
empty_list_title: "Maquetació"
empty_list_message: "Aquí pots veure, modificar i maquetar les pàgines de l'aplicació."
no_parent: "Cap"
page_templates:
home: Plantilla de la pàgina d'inici
static: Plantilla de la pàgina estàtica
design:
metatags: "Metatags"
design: "Maquetació"
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en/ubiquo/ubiquo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ en:
empty_list_title: "Design"
empty_list_message: "Here you can see, modify and design the application pages."
no_parent: "None"
page_templates:
home: Home page template
static: Static page template
design:
metatags: "Metatags"
design: "Design"
Expand Down
3 changes: 3 additions & 0 deletions config/locales/es/ubiquo/ubiquo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ es:
empty_list_title: "Maquetación"
empty_list_message: "Aquí puede ver, modificar y maquetar las páginas de la aplicación."
no_parent: "Ninguna"
page_templates:
home: Plantilla de la página de Inicio
static: Plantilla de las páginas estáticas
design:
metatags: "Metatags"
design: "Maquetación"
Expand Down
2 changes: 1 addition & 1 deletion config/plugin_routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
map.namespace :ubiquo do |ubiquo|
ubiquo.resources :static_pages, :member => { :publish => :put }
ubiquo.resources :static_pages, :member => { :publish => :put, :unpublish => :put }
ubiquo.resources :pages do |pages|
pages.resource :design, :member => {:preview => :get, :publish => :put, :unpublish => :put} do |design|
design.resources :widgets, :collection => {:change_order => :any}, :member => {:change_name => :post}
Expand Down
9 changes: 6 additions & 3 deletions install/app/helpers/pages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ def metatags(page)

# Displays the image for a given generic element
def list_element_image(element)
if element.respond_to?(:image) && element.image.try(:first)
image_tag(url_for_media_attachment(element.image.first))
end
images = try_methods([:images, :image], element)
image = images.try(:first)

image_tag url_for_media_attachment(image) if image.present?
end

# Displays the title for a given generic element
Expand Down Expand Up @@ -36,6 +37,8 @@ def try_methods(methods, element)
methods.each do |method|
return element.send(method) if element.respond_to? method
end

nil
end

def find_detail_page(element)
Expand Down
1 change: 0 additions & 1 deletion install/public/stylesheets/ubiquo/plugins/design.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ li.widget .editor_field {
}
#sidebar li.widget h4{
width: 13em;
margin: 0 1em;
line-height: 1em;
}
#central li.widget a.edit {
Expand Down
10 changes: 5 additions & 5 deletions install/test/functional/widgets/static_section_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class StaticSectionWidgetTest < ActionController::TestCase
assert_select "div.static-section" do
assert_select "h2"
assert_select "p.summary"
assert_select "p.body"
assert_select "p.body"
end
end

Expand Down Expand Up @@ -46,7 +46,7 @@ class StaticSectionWidgetTest < ActionController::TestCase
else
puts 'ubiquo_media not found, omitting StaticSection with media attributes tests'
end

private

def widget_attributes
Expand All @@ -57,11 +57,11 @@ def widget_attributes

def widget_media_attributes
{
:image_ids => [assets(:image).id.to_s],
:docs_ids => [assets(:video).id.to_s, assets(:doc).id.to_s],
:image => [assets(:image)],
:docs => [assets(:video), assets(:doc)],
}
end

def create_widget(type, options = {})
insert_widget_in_page(type, widget_attributes.merge(options))
end
Expand Down
Loading

0 comments on commit 01db6b9

Please sign in to comment.