-class Folder < Peta::Item
+class Folder < Peta::SystemResource
acts_as_nested_set
+ validates :name, :presence => true, :uniqueness => true, :length => {:maximum => 200}
validates :controller_name, :length => {:maximum => 200}
validates :action_name, :length => {:maximum => 200}
validates :category_id, :presence => true, :numericality => true
validates :t, :presence => true, :numericality => true
+ #remove last dir name
+ def dir
+ r = name.split('/')
+ r.pop
+ r.join '/'
+ end
+
+ def caption
+ name.gsub(/\/$/, '').split('/').last
+ end
+
+ def remote_name
+ '/' + self.controller_name.to_s + '/' + self.action_name.to_s
+ end
+
+ def self.add_local parent, name
+ key = parent.name + name + '/'
+ if i = self.find_by_name(key)
+ else
+ i = self.create :name => key, :category_id => 0, :t => 0
+ end
+ i.move_to_child_of parent
+ i
+ end
+
+ def self.add_remote parent, name, controller_name = nil, action_name = nil
+ key = parent.name + name + '/'
+ if i = self.find_by_name(key)
+ else
+ i = self.create :name => key, :category_id => 10, :t => 0,
+ :controller_name => (controller_name || name),
+ :action_name => action_name
+ end
+ i.move_to_child_of parent
+ i
+ end
+
def self.generate
- if self.root
+ if r = self.find_by_name('/')
else
- self.create :category_id => 0
+ r = self.create :name => '/', :category_id => 0, :t => 0
end
+ #
+ # child of root
+ #
+ manga = self.add_local r, 'manga'
+ o = self.add_local r, 'people'
+ doc = self.add_local r, 'documents'
+ mydoc = self.add_local r, 'my documents'
+ sr = self.add_local r, 'system_resource'
+
+ # child of /manga
+ manga_scroll = self.add_remote manga, 'scrolls'
+ manga_panel = self.add_remote manga, 'panels'
+
+ # child of /people (owner)
+ au = self.add_remote o, 'authors'
+ ar = self.add_remote o, 'artists'
+
+ # child of /documents
+ docman = self.add_local doc, 'manga'
+ docpic = self.add_local doc, 'pictures'
+ docparts = self.add_local doc, 'parts'
+ docidx = self.add_local doc, 'index'
+ # child of /documents/manga
+ docman_scroll = self.add_remote docman, 'scrolls'
+ docman_panel = self.add_remote docman, 'panels'
+ # child of /documents/pictures
+ docpic_resource_picture = self.add_remote docpic, 'resource_pictures'
+ # child of /documents/parts
+ docparts_panel_picture = self.add_remote docparts, 'panel_pictures'
+ docparts_speech_balloon = self.add_remote docparts, 'speech_balloons'
+ docparts_balloon = self.add_remote docparts, 'balloons'
+ docparts_speech = self.add_remote docparts, 'speeches'
+ docparts_ground_picture = self.add_remote docparts, 'ground_pictures'
+ docparts_ground_color = self.add_remote docparts, 'ground_colors'
+ # child of /documents/index (all public contents)
+ docidx_scroll = self.add_remote docidx, 'scrolls'
+ docidx_scroll_panel = self.add_remote docidx, 'scroll_panels'
+ docidx_comic = self.add_remote docidx, 'comics'
+ docidx_story = self.add_remote docidx, 'stories'
+ docidx_story_sheet = self.add_remote docidx, 'story_sheets'
+ docidx_sheet = self.add_remote docidx, 'sheets'
+ docidx_sheet_panel = self.add_remote docidx, 'sheet_panels'
+ docidx_panel = self.add_remote docidx, 'panels'
+ docidx_panel_picture = self.add_remote docidx, 'panel_pictures'
+ docidx_speech_balloon = self.add_remote docidx, 'speech_balloons'
+ docidx_balloon = self.add_remote docidx, 'balloons'
+ docidx_speech = self.add_remote docidx, 'speeches'
+ docidx_ground_picture = self.add_remote docidx, 'ground_pictures'
+ docidx_ground_color = self.add_remote docidx, 'ground_colors'
+ docidx_resource_picture = self.add_remote docidx, 'resource_pictures'
+
+ # child of /my documents
+ mydocman = self.add_local mydoc, 'manga'
+ mydocpic = self.add_local mydoc, 'pictures'
+ mydocparts = self.add_local mydoc, 'parts'
+ mydocidx = self.add_local mydoc, 'index'
+ mydocedt = self.add_local mydoc, 'create'
+ # child of /my documents/manga
+ mydocman_scroll = self.add_remote mydocman, 'scrolls', 'home', 'scrolls'
+ mydocman_panel = self.add_remote mydocman, 'panels', 'home', 'panels'
+ # child of /my documents/pictures
+ mydocpic_original_picture = self.add_remote mydocpic, 'original_pictures'
+ mydocpic_resource_picture = self.add_remote mydocpic, 'resource_pictures', 'home', 'resource_pictures'
+ # child of /my documents/parts
+ mydocparts_panel_picture = self.add_remote mydocparts, 'panel_pictures'
+ mydocparts_speech_balloon = self.add_remote mydocparts, 'speech_balloons'
+ mydocparts_balloon = self.add_remote mydocparts, 'balloons'
+ mydocparts_speech = self.add_remote mydocparts, 'speeches'
+ mydocparts_ground_picture = self.add_remote mydocparts, 'ground_pictures'
+ mydocparts_ground_color = self.add_remote mydocparts, 'ground_colors'
+ # child of /my documents/index
+ mydocidx_scroll = self.add_remote mydocidx, 'scrolls'
+ mydocidx_scroll_panel = self.add_remote mydocidx, 'scroll_panels'
+ mydocidx_comic = self.add_remote mydocidx, 'comics'
+ mydocidx_story = self.add_remote mydocidx, 'stories'
+ mydocidx_story_sheet = self.add_remote mydocidx, 'story_sheets'
+ mydocidx_sheet = self.add_remote mydocidx, 'sheets'
+ mydocidx_sheet_panel = self.add_remote mydocidx, 'sheet_panels'
+ mydocidx_panel = self.add_remote mydocidx, 'panels'
+ mydocidx_panel_picture = self.add_remote mydocidx, 'panel_pictures'
+ mydocidx_speech_balloon = self.add_remote mydocidx, 'speech_balloons'
+ mydocidx_balloon = self.add_remote mydocidx, 'balloons'
+ mydocidx_speech = self.add_remote mydocidx, 'speeches'
+ mydocidx_ground_picture = self.add_remote mydocidx, 'ground_pictures'
+ mydocidx_ground_color = self.add_remote mydocidx, 'ground_colors'
+ mydocpic_original_picture = self.add_remote mydocpic, 'original_pictures'
+ mydocidx_resource_picture = self.add_remote mydocidx, 'resource_pictures'
+ # child of /my documents/create
+ mydocedt_scroll = self.add_remote mydocedt, 'new scroll', 'scrolls', 'new'
+ mydocedt_panel = self.add_remote mydocedt, 'new panel', 'panels', 'new'
+ mydocedt_original_picture = self.add_remote mydocedt, 'upload picture', 'original_pictures', 'new'
+
+ # child of /system_resource
+ sbt = self.add_remote sr, 'speech_balloon_templates'
+ lg = self.add_remote sr, 'license_groups'
+ ls = self.add_remote sr, 'licenses'
+ sp = self.add_remote sr, 'system_pictures'
+ wf = self.add_remote sr, 'writing_formats'
end
</table>\r
</div>\r
<div width="100%" style="background-color: #ddfadd; padding: 5px;">\r
+ <%= link_to t_m('Folder'), main_app.root_folders_path() %>\r
+ :\r
<%= link_to t('tab.reader.title'), '/' %>\r
- <%= link_to t_m('Comic'), main_app.comics_path %>\r
<%= link_to t_m('Scroll'), main_app.scrolls_path %>\r
<%= link_to t_m('Panel'), main_app.panels_path %>\r
<%= link_to t_m('ResourcePicture'), main_app.resource_pictures_path %>\r
- <%= link_to t_m('SpeechBalloonTemplate'), main_app.speech_balloon_templates_path %>\r
- : \r
- <%= link_to t_m('Author'), main_app.authors_path %>\r
- <%= link_to t_m('Artist'), main_app.artists_path %>\r
-</div>\r
-<div width="100%" style="background-color: #fadddd; padding: 5px;">\r
+ :\r
<%= link_to t('tab.creator.home'), '/home' %>\r
<% if @operators.author %>\r
- <%= link_to t('tab.creator.comic'), '/home/comics' %>\r
- <%= link_to t('*'), main_app.new_comic_path %>\r
- <%= link_to t('tab.creator.story'), '/home/stories' %>\r
- <%= link_to t('tab.creator.sheet'), '/home/sheets' %>\r
- <%= link_to t('*'), main_app.new_sheet_path %>\r
<%= link_to t('tab.creator.scroll'), '/home/scrolls' %>\r
<%= link_to t('*'), main_app.new_scroll_path %>\r
<%= link_to t('tab.creator.panel'), '/home/panels' %>\r
<%= link_to t('*'), main_app.new_original_picture_path %>\r
<%= link_to t('tab.creator.resource_picture'), '/home/resource_pictures' %>\r
<% end %>\r
- <% if @operators.author and @operators.author.working? -%>\r
- <%= link_to t('tab.creator..catch'), main_app.panel_path(@operators.author.working_panel) %>\r
- <% end %>\r
</div>\r
<%= yield %>\r
<div width="100%" style="background-color: #faddfa; padding: 5px;">\r