Merge branch 'master' into desktop

* master: (57 commits)
  Add translations
  Add mobile version in site settings
  Add mobile but remove news in it
  Remove mysql
  Fix album widget options
  Fix link for ad_banner Add missing helper for web_link_category Show design's js in front-end
  Add link to default widget (temporary)
  Ika's fix for width
  Ika's fix for width
  Gallery i18n
  Ika's changes for css default widgets
  Ika's changes for css default widgets
  change bulletin object to bulletin title
  fixing default widget error when needs image
  make default widget works without init
  Fix order in structure
  Fix old tags
  correct pic file format
  complete page error handler logic
  change sub_menu to header in site setting
  ...
This commit is contained in:
Rueshyna committed 2013-01-07 16:44:05 +08:00
commit a34da20e48
144 files changed
+8148 -583

No files matched your search

+3 -3
View File
@@ -47,16 +47,16 @@ class Item
new_parent = Item.find(new_parent)
current_position_sibling = find_by_parent_and_position(new_parent, position.to_i)
if current_position_sibling
current_position_sibling.at_bottom? ? move_below(current_position_sibling) : move_above(current_position_sibling)
move_above(current_position_sibling)
elsif self.parent != new_parent
self.parent = new_parent
save!
save
end
end
end
def show_in_sitemap_for(locale)
if !sitemap_enabled[locale].blank?
if sitemap_enabled && !sitemap_enabled[locale].blank?
sitemap_enabled[locale].eql?('true') ? true : false
else
true
+18 -2
View File
@@ -12,12 +12,13 @@ class ModuleApp
field :update_info
field :create_date
field :enable_frontend, type: Boolean, :default => true
field :app_pages ,type: Array
# field :widgets ,type: Array
field :widgets ,type: Hash
field :widget_fields ,type: Array
field :widget_options,type:Hash
field :widget_options_fields_i18n,type:Hash
has_many :managers,as: :managing_app ,:class_name => "AppManager" ,:dependent => :destroy#,:foreign_key => "managing_app_id",:inverse_of => :managing_app
has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager", :dependent => :destroy#,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app
@@ -29,6 +30,13 @@ class ModuleApp
before_save :set_key
#>>>>>>>>>>>>> remove after app config applied
def get_default_widget
{:query=>'Bulletin.all',:image=> 'image'}
end
#<<<<<<<<<<<<@@
def is_manager?(user)
managing_users.include?(user)
end
@@ -79,6 +87,14 @@ class ModuleApp
end
end
def needs_to_widget_option?
if self.widget_options
self.widget_options.has_key? widgets.first
else
false
end
end
protected
def set_key
+8 -7
View File
@@ -24,9 +24,8 @@ class Page < Item
has_many :page_metas, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :page_parts, :allow_destroy => true
before_save :delete_empty_frontend_field
before_save :create_parts, if: Proc.new { |page| page.new_record? || page.design_id_changed? }
after_save :generate_html
before_save :delete_empty_frontend_field, :generate_html
protected
@@ -37,7 +36,8 @@ class Page < Item
page_design.layout.layout_parts.each do |layout_part|
current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)}
current_part = self.page_parts.build(:name => layout_part.name) unless current_part
if menu_part && current_part.name.eql?(menu_part.name)
if menu_part && current_part.name.eql?(menu_part.name)
if current_part.new_record?
current_part.kind = menu_part.kind
current_part.public_r_tag = menu_part.public_r_tag
@@ -50,6 +50,10 @@ class Page < Item
current_part.update_attributes(:kind => menu_part.kind, :public_r_tag => menu_part.public_r_tag, :public_r_tag_object_id => menu_part.public_r_tag_object_id)
end
end
elsif current_part.new_record?
PagePart.without_callback(:save, :after, :update_parent) do
current_part.save
end
end
end
end
@@ -67,10 +71,7 @@ class Page < Item
end
def generate_html
Page.without_callback(:save, :after, :generate_html) do
self.content_translations = parse_page_noko(self, Site.first)
self.save
end
self.content_translations = parse_page_noko(self, Site.first)
end
end
+3
View File
@@ -14,6 +14,7 @@ class PagePart
field :widget_style
field :widget_field , :type => Array
field :widget_options ,:type=>Hash
field :widget_data_count
belongs_to :page
@@ -22,6 +23,7 @@ class PagePart
before_save :delete_empty_widget_field
after_save :update_parent
protected
def delete_empty_widget_field
@@ -35,4 +37,5 @@ class PagePart
self.page.save
end
end
+2
View File
@@ -25,6 +25,8 @@ class Site
field :title, localize: true
field :footer, localize: true
field :sub_menu, localize: true
field :mobile_on, :type => Boolean, :default => false
belongs_to :design
has_many :site_metas, :autosave => true, :dependent => :destroy
+43 -2
View File
@@ -1,4 +1,45 @@
class Tag < ProtoTag
belongs_to :module_app
# class Tag < ProtoTag
# belongs_to :module_app
# end
class Tag
include Mongoid::Document
include Mongoid::Timestamps
include Impressionist::Impressionable
is_impressionable :counter_cache => { :column_name => :view_count }
field :key
field :view_count, :type => Integer, :default => 0
#field :cloud_amper,:type: Integer,:default=> 0
def self.sorted_for_cloud
tags = {}
self.all.each{ |tag|
tags.merge!({tag => self.get_impressionist(tag)})
}
if !tags.blank?
sorted_tags = tags.sort{|a,b| a[1]<=>b[1]}.reverse
sorted_tags[0][1] = :hot1
offset = (sorted_tags.size - 1) / 3
i = 1
class_i = 2
sorted_tags[1..-1].collect!{ |x|
x[1] = "hot#{class_i}"
i == offset ? i = 1 : i += 1 if class_i < 4
class_i += 1 if i == offset && class_i < 4
}
sorted_tags
else
[]
end
end
protected
def self.get_impressionist(item_tag = self)
item_tag.impressions.where(:created_at.gte=> 14.days.ago,:created_at.lte => Time.now).count
end
end