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
18 name.gsub(/\/$/, '').split('/').last
22 '/' + self.controller_name.to_s + '/' + self.action_name.to_s
25 def self.add_local parent, name
26 key = parent.name + name + '/'
27 if i = self.find_by_name(key)
29 i = self.create :name => key, :category_id => 0, :t => 0
31 i.move_to_child_of parent
35 def self.add_remote parent, name, controller_name = nil, action_name = nil
36 key = parent.name + name + '/'
37 if i = self.find_by_name(key)
39 i = self.create :name => key, :category_id => 10, :t => 0,
40 :controller_name => (controller_name || name),
41 :action_name => action_name
43 i.move_to_child_of parent
48 if r = self.find_by_name('/')
50 r = self.create :name => '/', :category_id => 0, :t => 0
55 manga = self.add_local r, 'manga'
56 o = self.add_local r, 'people'
57 doc = self.add_local r, 'documents'
58 mydoc = self.add_local r, 'my documents'
59 sr = self.add_local r, 'system_resource'
62 manga_scroll = self.add_remote manga, 'scrolls'
63 manga_panel = self.add_remote manga, 'panels'
65 # child of /people (owner)
66 au = self.add_remote o, 'authors'
67 ar = self.add_remote o, 'artists'
70 docman = self.add_local doc, 'manga'
71 docpic = self.add_local doc, 'pictures'
72 docparts = self.add_local doc, 'parts'
73 docidx = self.add_local doc, 'index'
74 # child of /documents/manga
75 docman_scroll = self.add_remote docman, 'scrolls'
76 docman_panel = self.add_remote docman, 'panels'
77 # child of /documents/pictures
78 docpic_resource_picture = self.add_remote docpic, 'resource_pictures'
79 # child of /documents/parts
80 docparts_panel_picture = self.add_remote docparts, 'panel_pictures'
81 docparts_speech_balloon = self.add_remote docparts, 'speech_balloons'
82 docparts_balloon = self.add_remote docparts, 'balloons'
83 docparts_speech = self.add_remote docparts, 'speeches'
84 docparts_ground_picture = self.add_remote docparts, 'ground_pictures'
85 docparts_ground_color = self.add_remote docparts, 'ground_colors'
86 # child of /documents/index (all public contents)
87 docidx_scroll = self.add_remote docidx, 'scrolls'
88 docidx_scroll_panel = self.add_remote docidx, 'scroll_panels'
89 docidx_comic = self.add_remote docidx, 'comics'
90 docidx_story = self.add_remote docidx, 'stories'
91 docidx_story_sheet = self.add_remote docidx, 'story_sheets'
92 docidx_sheet = self.add_remote docidx, 'sheets'
93 docidx_sheet_panel = self.add_remote docidx, 'sheet_panels'
94 docidx_panel = self.add_remote docidx, 'panels'
95 docidx_panel_picture = self.add_remote docidx, 'panel_pictures'
96 docidx_speech_balloon = self.add_remote docidx, 'speech_balloons'
97 docidx_balloon = self.add_remote docidx, 'balloons'
98 docidx_speech = self.add_remote docidx, 'speeches'
99 docidx_ground_picture = self.add_remote docidx, 'ground_pictures'
100 docidx_ground_color = self.add_remote docidx, 'ground_colors'
101 docidx_resource_picture = self.add_remote docidx, 'resource_pictures'
103 # child of /my documents
104 mydocman = self.add_local mydoc, 'manga'
105 mydocpic = self.add_local mydoc, 'pictures'
106 mydocparts = self.add_local mydoc, 'parts'
107 mydocidx = self.add_local mydoc, 'index'
108 mydocedt = self.add_local mydoc, 'create'
109 # child of /my documents/manga
110 mydocman_scroll = self.add_remote mydocman, 'scrolls', 'home', 'scrolls'
111 mydocman_panel = self.add_remote mydocman, 'panels', 'home', 'panels'
112 # child of /my documents/pictures
113 mydocpic_original_picture = self.add_remote mydocpic, 'original_pictures'
114 mydocpic_resource_picture = self.add_remote mydocpic, 'resource_pictures', 'home', 'resource_pictures'
115 # child of /my documents/parts
116 mydocparts_panel_picture = self.add_remote mydocparts, 'panel_pictures'
117 mydocparts_speech_balloon = self.add_remote mydocparts, 'speech_balloons'
118 mydocparts_balloon = self.add_remote mydocparts, 'balloons'
119 mydocparts_speech = self.add_remote mydocparts, 'speeches'
120 mydocparts_ground_picture = self.add_remote mydocparts, 'ground_pictures'
121 mydocparts_ground_color = self.add_remote mydocparts, 'ground_colors'
122 # child of /my documents/index
123 mydocidx_scroll = self.add_remote mydocidx, 'scrolls'
124 mydocidx_scroll_panel = self.add_remote mydocidx, 'scroll_panels'
125 mydocidx_comic = self.add_remote mydocidx, 'comics'
126 mydocidx_story = self.add_remote mydocidx, 'stories'
127 mydocidx_story_sheet = self.add_remote mydocidx, 'story_sheets'
128 mydocidx_sheet = self.add_remote mydocidx, 'sheets'
129 mydocidx_sheet_panel = self.add_remote mydocidx, 'sheet_panels'
130 mydocidx_panel = self.add_remote mydocidx, 'panels'
131 mydocidx_panel_picture = self.add_remote mydocidx, 'panel_pictures'
132 mydocidx_speech_balloon = self.add_remote mydocidx, 'speech_balloons'
133 mydocidx_balloon = self.add_remote mydocidx, 'balloons'
134 mydocidx_speech = self.add_remote mydocidx, 'speeches'
135 mydocidx_ground_picture = self.add_remote mydocidx, 'ground_pictures'
136 mydocidx_ground_color = self.add_remote mydocidx, 'ground_colors'
137 mydocpic_original_picture = self.add_remote mydocpic, 'original_pictures'
138 mydocidx_resource_picture = self.add_remote mydocidx, 'resource_pictures'
139 # child of /my documents/create
140 mydocedt_scroll = self.add_remote mydocedt, 'new scroll', 'scrolls', 'new'
141 mydocedt_panel = self.add_remote mydocedt, 'new panel', 'panels', 'new'
142 mydocedt_original_picture = self.add_remote mydocedt, 'upload picture', 'original_pictures', 'new'
144 # child of /system_resource
145 sbt = self.add_remote sr, 'speech_balloon_templates'
146 lg = self.add_remote sr, 'license_groups'
147 ls = self.add_remote sr, 'licenses'
148 sp = self.add_remote sr, 'system_pictures'
149 wf = self.add_remote sr, 'writing_formats'