1 class Folder < Peta::SystemResource
4 validates :name, :presence => true, :uniqueness => true, :length => {:maximum => 200}
5 validates :controller_name, :length => {:maximum => 200}
6 validates :action_name, :length => {:maximum => 200}
7 validates :category_id, :presence => true, :numericality => true
8 validates :t, :presence => true, :numericality => true
10 scope :find_index, -> do
22 name.gsub(/\/$/, '').split('/').last
30 '/' + self.controller_name.to_s + '/' + self.action_name.to_s
33 def self.add_local parent, name
34 key = parent.name + name + '/'
36 :name => key, :category_id => 0, :t => 0
38 if i = self.find_by(name: key)
44 i.move_to_child_of parent
48 def self.add_remote parent, name, controller_name = nil, action_name = nil
49 key = parent.name + name + '/'
51 :name => key, :category_id => 10, :t => 0,
52 :controller_name => (controller_name || name),
53 :action_name => action_name
55 if i = self.find_by(name: key)
61 i.move_to_child_of parent
66 if r = self.find_by(name: '/')
68 r = self.create :name => '/', :category_id => 0, :t => 0
73 manga = self.add_local r, 'manga'
74 o = self.add_local r, 'people'
75 doc = self.add_local r, 'documents'
76 mydoc = self.add_local r, 'my documents'
77 sr = self.add_local r, 'system_resource'
80 manga_scroll = self.add_remote manga, 'scrolls'
81 manga_panel = self.add_remote manga, 'panels'
83 # child of /people (owner)
84 au = self.add_remote o, 'authors'
85 ar = self.add_remote o, 'artists'
88 docman = self.add_local doc, 'manga'
89 docpic = self.add_local doc, 'pictures'
90 docparts = self.add_local doc, 'parts'
91 docidx = self.add_local doc, 'index'
92 # child of /documents/manga
93 docman_scroll = self.add_remote docman, 'scrolls'
94 docman_panel = self.add_remote docman, 'panels'
95 # child of /documents/pictures
96 docpic_resource_picture = self.add_remote docpic, 'resource_pictures'
97 # child of /documents/parts
98 docparts_panel_picture = self.add_remote docparts, 'panel_pictures'
99 docparts_speech_balloon = self.add_remote docparts, 'speech_balloons'
100 docparts_balloon = self.add_remote docparts, 'balloons'
101 docparts_speech = self.add_remote docparts, 'speeches'
102 docparts_ground_picture = self.add_remote docparts, 'ground_pictures'
103 docparts_ground_color = self.add_remote docparts, 'ground_colors'
104 # child of /documents/index (all public contents)
105 docidx_scroll = self.add_remote docidx, 'scrolls'
106 docidx_scroll_panel = self.add_remote docidx, 'scroll_panels'
107 docidx_comic = self.add_remote docidx, 'comics'
108 docidx_comic_story = self.add_remote docidx, 'comic_stories'
109 docidx_story = self.add_remote docidx, 'stories'
110 docidx_story_sheet = self.add_remote docidx, 'story_sheets'
111 docidx_sheet = self.add_remote docidx, 'sheets'
112 docidx_sheet_panel = self.add_remote docidx, 'sheet_panels'
113 docidx_panel = self.add_remote docidx, 'panels'
114 docidx_panel_picture = self.add_remote docidx, 'panel_pictures'
115 docidx_speech_balloon = self.add_remote docidx, 'speech_balloons'
116 docidx_balloon = self.add_remote docidx, 'balloons'
117 docidx_speech = self.add_remote docidx, 'speeches'
118 docidx_ground_picture = self.add_remote docidx, 'ground_pictures'
119 docidx_ground_color = self.add_remote docidx, 'ground_colors'
120 docidx_resource_picture = self.add_remote docidx, 'resource_pictures'
122 # child of /my documents
123 mydocman = self.add_local mydoc, 'manga'
124 mydocpic = self.add_local mydoc, 'pictures'
125 mydocparts = self.add_local mydoc, 'parts'
126 mydocidx = self.add_local mydoc, 'index'
127 mydocedt = self.add_local mydoc, 'create'
128 # child of /my documents/manga
129 mydocman_scroll = self.add_remote mydocman, 'scrolls', 'home', 'scrolls'
130 mydocman_panel = self.add_remote mydocman, 'panels', 'home', 'panels'
131 # child of /my documents/pictures
132 mydocpic_original_picture = self.add_remote mydocpic, 'original_pictures'
133 mydocpic_resource_picture = self.add_remote mydocpic, 'resource_pictures', 'home', 'resource_pictures'
134 # child of /my documents/parts
135 mydocparts_panel_picture = self.add_remote mydocparts, 'panel_pictures'
136 mydocparts_speech_balloon = self.add_remote mydocparts, 'speech_balloons'
137 mydocparts_balloon = self.add_remote mydocparts, 'balloons'
138 mydocparts_speech = self.add_remote mydocparts, 'speeches'
139 mydocparts_ground_picture = self.add_remote mydocparts, 'ground_pictures'
140 mydocparts_ground_color = self.add_remote mydocparts, 'ground_colors'
141 # child of /my documents/index
142 mydocidx_scroll = self.add_remote mydocidx, 'scrolls', 'home', 'scrolls'
143 mydocidx_scroll_panel = self.add_remote mydocidx, 'scroll_panels', 'home', 'scroll_panels'
144 mydocidx_comic = self.add_remote mydocidx, 'comics', 'home', 'comics'
145 mydocidx_comic_story = self.add_remote mydocidx, 'comic_stories', 'home', 'comic_stories'
146 mydocidx_story = self.add_remote mydocidx, 'stories', 'home', 'stories'
147 mydocidx_story_sheet = self.add_remote mydocidx, 'story_sheets', 'home', 'story_sheets'
148 mydocidx_sheet = self.add_remote mydocidx, 'sheets', 'home', 'sheets'
149 mydocidx_sheet_panel = self.add_remote mydocidx, 'sheet_panels', 'home', 'sheet_panels'
150 mydocidx_panel = self.add_remote mydocidx, 'panels', 'home', 'panels'
151 mydocidx_panel_picture = self.add_remote mydocidx, 'panel_pictures', 'home', 'panel_pictures'
152 mydocidx_speech_balloon = self.add_remote mydocidx, 'speech_balloons', 'home', 'speech_balloons'
153 mydocidx_balloon = self.add_remote mydocidx, 'balloons', 'home', 'balloons'
154 mydocidx_speech = self.add_remote mydocidx, 'speeches', 'home', 'speeches'
155 mydocidx_ground_picture = self.add_remote mydocidx, 'ground_pictures', 'home', 'ground_pictures'
156 mydocidx_ground_color = self.add_remote mydocidx, 'ground_colors', 'home', 'ground_colors'
157 mydocpic_original_picture = self.add_remote mydocpic, 'original_pictures'
158 mydocidx_resource_picture = self.add_remote mydocidx, 'resource_pictures', 'home', 'resource_pictures'
159 # child of /my documents/create
160 mydocedt_scroll = self.add_remote mydocedt, 'new scroll', 'scrolls', 'new'
161 mydocedt_panel = self.add_remote mydocedt, 'new panel', 'panels', 'new'
162 mydocedt_original_picture = self.add_remote mydocedt, 'upload picture', 'original_pictures', 'new'
163 # child of /my documents/create/index
164 mydocedtidx = self.add_local mydocedt, 'index'
165 mydocedtidx_scroll = self.add_remote mydocedtidx, 'new scroll', 'scrolls', 'new'
166 mydocedtidx_comic = self.add_remote mydocedtidx, 'new comic', 'comics', 'new'
167 mydocedtidx_story = self.add_remote mydocedtidx, 'new story', 'stories', 'new'
168 mydocedtidx_sheet = self.add_remote mydocedtidx, 'new sheet', 'sheets', 'new'
169 mydocedtidx_panel = self.add_remote mydocedtidx, 'new panel', 'panels', 'new'
171 # child of /system_resource
172 sbt = self.add_remote sr, 'speech_balloon_templates'
173 lg = self.add_remote sr, 'license_groups'
174 ls = self.add_remote sr, 'licenses'
175 sp = self.add_remote sr, 'system_pictures'
176 wf = self.add_remote sr, 'writing_formats'