mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-24 13:45:44 +08:00
add site page
This commit is contained in:
49
app/models/page.rb
Normal file
49
app/models/page.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: pages
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer not null
|
||||
# project_id :integer not null
|
||||
# identifier :string(255)
|
||||
# site_name :string(255)
|
||||
# language_frame :integer default("0")
|
||||
# theme :string(255)
|
||||
# last_build_at :datetime
|
||||
# state :boolean default("1")
|
||||
# state_description :string(255)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_pages_on_project_id (project_id)
|
||||
# index_pages_on_user_id (user_id)
|
||||
#
|
||||
|
||||
class Page < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :project
|
||||
|
||||
# language_frame 前端语言框架
|
||||
enum language_frame: { hugo: 0, hexo: 1, jeklly: 2}
|
||||
|
||||
after_create do
|
||||
PageService.genernate_user(user_id)
|
||||
end
|
||||
|
||||
before_save do
|
||||
if state_changed? && state == false
|
||||
PageService.close_site(user_id, identifier)
|
||||
end
|
||||
end
|
||||
|
||||
def deploy_page(branch)
|
||||
PageService.deploy_page(branch,self.id)
|
||||
end
|
||||
|
||||
def url
|
||||
"http://#{user.login}.kingchan.cn/#{identifier}"
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user