update for desktop widgets

This commit is contained in:
Harry Bomrah authored and chris committed 2012-11-05 11:40:11 +08:00
1 parent 2e809c5c19
commit ca3e06c58b
37 files changed
+284 -179

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
class Desktop
include Mongoid::Document
include Mongoid::Timestamps
field :theme, default: "4f8d3f493b67fcd05f086359"
field :customtheme
field :wallpaper
belongs_to :user
has_many :sections, :autosave => true, :dependent => :destroy
# has_many :desktop_widgets, :autosave => true, :dependent => :destroy
before_create :initialize_section
def initialize_section
self.sections.build(name: "Desktop 1")
self.sections.build(name: "Desktop 2")
self.sections.build(name: "Desktop 3")
self.sections.build(name: "Desktop 4")
end
end
+9
View File
@@ -0,0 +1,9 @@
class DesktopTheme
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :author
end
+31
View File
@@ -0,0 +1,31 @@
class DesktopWidget
include Mongoid::Document
include Mongoid::Timestamps
include ParserLayoutWidget
field :name
field :author
field :shape
field :version, :type => String
has_one :css_default, :autosave => true, :dependent => :destroy
has_one :widget_layout, :autosave => true, :dependent => :destroy
has_many :images, :autosave => true, :dependent => :destroy
has_many :javascripts, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :images, :allow_destroy => true
accepts_nested_attributes_for :javascripts, :allow_destroy => true
after_save :parse_css_for_images
# belongs_to :desktop
protected
def parse_css_for_images
self.css_default.parse_widgets_urls
parse_widget_for_images(self)
end
end
+19
View File
@@ -0,0 +1,19 @@
class Group
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :section
has_many :tiles, :autosave => true, :dependent => :destroy
before_create :initialize_tile
def initialize_tile
self.tiles.build(data_category: "widget", data_content: "timetable", position: 1, shape: "w2 h2", title: "Tiime Table")
self.tiles.build(data_category: "app", data_content: "quotes", position: 2, shape: "w1 h1", title: "Quotes")
self.tiles.build(data_category: "widget", data_content: "weather", position: 3, shape: "w2 h2", title: "Weather")
self.tiles.build(data_category: "widget", data_content: "clock", position: 4, shape: "w2 h1", title: "Clock")
self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 5, shape: "w1 h1", title: "Daily English Word")
self.tiles.build(data_category: "widget", data_content: "school_events", position: 6, shape: "w2 h1", title: "School Events")
end
end
+15
View File
@@ -0,0 +1,15 @@
class OtherAccount
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Encryptor
field :user_id
field :type
field :email
field :encrypted_password
encrypts :encrypted_password, :mode => :symmetric, :password => 'rulingcom'
belongs_to :user
end
+17
View File
@@ -0,0 +1,17 @@
class Section
include Mongoid::Document
include Mongoid::Timestamps
field :name
belongs_to :desktop
has_many :groups, :autosave => true, :dependent => :destroy
before_create :initialize_group
def initialize_group
self.groups.build
self.groups.build
end
end
+13
View File
@@ -0,0 +1,13 @@
class Tile
include Mongoid::Document
include Mongoid::Timestamps
field :data_category
field :data_content
field :position, type: Integer
field :shape
field :title
belongs_to :group
end
+18
View File
@@ -0,0 +1,18 @@
class WidgetLayout < DesignFile
attr_reader :content
field :body
belongs_to :desktop_widget
def content
self.file.read.force_encoding("UTF-8") rescue ''
end
def self.exist_one?
WidgetLayout.count > 0
end
end