Modifications for design, pages, page_parts…
Move orbit_bar out of kernel.js
This commit is contained in:
parent
5da75161c4
commit
9cd3cbc478
|
@ -0,0 +1,4 @@
|
|||
$(document).ready(function() {
|
||||
$('body').prepend("<div id='orbit_bar'/>");
|
||||
ajax_load_proc($('#orbit_bar'), '/load_orbit_bar');
|
||||
});
|
|
@ -38,8 +38,6 @@ class Admin::PagesController < ApplicationController
|
|||
def create
|
||||
@item = Page.new(params[:page])
|
||||
if @item.save
|
||||
@item.create_parts
|
||||
@item.save
|
||||
flash.now[:notice] = t('admin.create_success_page')
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
|
|
@ -15,7 +15,7 @@ class Design
|
|||
embeds_many :themes, :cascade_callbacks => true
|
||||
embeds_many :javascripts, :cascade_callbacks => true
|
||||
embeds_many :images, :cascade_callbacks => true
|
||||
embeds_many :custom_images, :class_name => 'Image', :cascade_callbacks => true
|
||||
# embeds_many :custom_images, :class_name => 'Image', :cascade_callbacks => true
|
||||
|
||||
validates_presence_of :title
|
||||
validates_presence_of :author
|
||||
|
|
|
@ -7,7 +7,7 @@ class Layout < DesignFile
|
|||
embedded_in :design
|
||||
embeds_many :layout_parts
|
||||
|
||||
after_save :parse_layout
|
||||
before_save :parse_layout
|
||||
|
||||
def content
|
||||
self.file.read.force_encoding("UTF-8") rescue ''
|
||||
|
|
|
@ -4,15 +4,7 @@ class LayoutPart
|
|||
include Mongoid::Timestamps
|
||||
|
||||
field :name
|
||||
field :id_tag
|
||||
field :editable, :type => Boolean
|
||||
field :class_tag
|
||||
field :content
|
||||
|
||||
embedded_in :layout
|
||||
|
||||
def editable?
|
||||
self.editable
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -9,17 +9,21 @@ class Page < Item
|
|||
has_many :page_parts, :autosave => true, :dependent => :destroy
|
||||
accepts_nested_attributes_for :page_parts, :allow_destroy => true
|
||||
|
||||
# embeds_many :custom_images, :class_name => 'Image', as: :design_image
|
||||
before_save :create_parts
|
||||
|
||||
def create_parts
|
||||
page_design = self.design
|
||||
page_design.layout.layout_parts.each do |p|
|
||||
self.page_parts.create( :name => p.name, :i18n_variable => I18nVariable.create, :kind => 'text' ) if p.editable?
|
||||
end
|
||||
end
|
||||
# embeds_many :custom_images, :class_name => 'Image', as: :design_image
|
||||
|
||||
def is_home?
|
||||
self.parent ? false : true
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def create_parts
|
||||
page_design = self.design
|
||||
page_design.layout.layout_parts.each do |layout_part|
|
||||
self.page_parts.new(:name => layout_part.name) unless self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -40,8 +40,8 @@ module ParserBackEnd
|
|||
res
|
||||
end
|
||||
c.define_tag 'image' do |tag|
|
||||
image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
|
||||
image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
|
||||
# image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
|
||||
# image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
|
||||
image = page.design.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
|
||||
if image
|
||||
res = "<img src=#{image.file.url} "
|
||||
|
|
|
@ -72,6 +72,7 @@ module ParserFrontEnd
|
|||
res << "<script type='text/javascript' src='/static/jquery.js'></script>"
|
||||
res << "<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>"
|
||||
res << "<script type='text/javascript' src='/static/kernel.js'></script>"
|
||||
res << "<script type='text/javascript' src='/assets/orbit_bar.js'></script>"
|
||||
page.design.javascripts.each do |js|
|
||||
res << "<script type='text/javascript' src='#{js.file.url}'></script>"
|
||||
end
|
||||
|
@ -98,8 +99,8 @@ module ParserFrontEnd
|
|||
res
|
||||
end
|
||||
c.define_tag 'image' do |tag|
|
||||
image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
|
||||
image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
|
||||
# image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
|
||||
# image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
|
||||
image = page.design.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
|
||||
if image
|
||||
res = "<img src=#{image.file.url} "
|
||||
|
|
|
@ -22,15 +22,14 @@ module ParserLayout
|
|||
layout.menu.levels = i = tag.attr['level'].to_i
|
||||
layout.menu.values.merge!({'home' => tag.attr['home']}) if i == 1
|
||||
layout.menu.values.merge!({"id_#{i}" => tag.attr['id'], "class_#{i}" => tag.attr['class'], "li_class_#{i}" => tag.attr['li_class'], "li_incremental_#{i}" => tag.attr['li_incremental']})
|
||||
layout.menu.save
|
||||
tag.expand
|
||||
end
|
||||
c.define_tag 'content' do |tag|
|
||||
layout.layout_parts.create(:name => tag.attr['name'], :editable => true)
|
||||
layout.layout_parts.new(:name => tag.attr['name'])
|
||||
end
|
||||
c.define_tag 'image' do |tag|
|
||||
image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(tag.expand)) }
|
||||
image.update_attributes(:name => tag.attr['name'], :html_id => tag.attr['id'], :html_class => tag.attr['class'])
|
||||
image.update_attributes(:name => tag.attr['name'], :html_id => tag.attr['id'], :html_class => tag.attr['class']) if image
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -103,11 +103,7 @@ namespace :dev do
|
|||
design_1.save
|
||||
|
||||
|
||||
home = Page.create!( :i18n_variable => var_10, :design_id => design_1.id, :name => 'home', :is_published => true, :theme_id => theme.id )
|
||||
home.page_parts.create!( :name => 'content_1', :content => nil, :kind => nil )
|
||||
home.page_parts.create!( :name => 'content_2', :content => nil, :kind => nil )
|
||||
home.page_parts.create!( :name => 'content_3', :content => nil, :kind => 'text', :i18n_variable => var_13 )
|
||||
home.page_parts.create!( :name => 'content_4', :content => nil, :kind => 'text', :i18n_variable => nil )
|
||||
home = Page.create( :i18n_variable => var_10, :design => design_1, :name => 'home', :is_published => true, :theme_id => theme.id )
|
||||
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/new_blog/new_blog.json").read).save
|
||||
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/announcement/announcement.json").read).save
|
||||
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/web_resource/web_resource.json").read).save
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
$(document).ready(function() {
|
||||
|
||||
$('body').prepend("<div id='orbit_bar'/>");
|
||||
ajax_load_proc($('#orbit_bar'), '/load_orbit_bar');
|
||||
|
||||
$.each($(".dymanic_load"),function(){
|
||||
if($(this).attr("path")==''){$(this).html("App setting Failed");}
|
||||
|
||||
|
|
Reference in New Issue