\r
},\r
},\r
+ by_original_picture: {\r
+ type: 'list',\r
+ },\r
by_license: {\r
type: 'list',\r
},\r
},\r
private: {\r
},\r
+ by_original_picture: {\r
+ },\r
by_license: {\r
},\r
by_artist: {\r
--- /dev/null
+#マニフェスト\r
+@magic_numbers = {\r
+ run_mode: 1, \r
+ thumbnail_width: 64, \r
+ thumbnail_height: 64, \r
+ profile: {\r
+ users: {\r
+ caption: "ペンギン王国",\r
+ url: "http://localhost:3001/", \r
+ description: "ペンギン王国はペンギン素材を豊富に用意したペンギンマニアのサイトです。",\r
+ },\r
+ admins: {\r
+ caption: "site name for admin",\r
+ url: "http://your.site.url/admins/", \r
+ description: "admin register",\r
+ },\r
+ demand_users: {\r
+ caption: "provider name",\r
+ url: "http://your.site.url/demanders/", \r
+ description: "provider description",\r
+ },\r
+ },\r
+ provider_sources: [\r
+ 'http://sourceforge.jp/projects/pettanr/wiki/ProviderSource/attach/provider_source.json'\r
+ ], \r
+}\r
private: {\r
type: 'private',\r
},\r
+ by_original_picture: {\r
+ type: 'filter',\r
+ },\r
by_license: {\r
type: 'filter',\r
},\r
'artist',\r
],\r
has_one: [\r
- 'resource_picture',\r
+ 'resource_picture.by_original_picture',\r
],\r
}, \r
},\r
],\r
}\r
}\r
-@magic_numbers = {\r
- run_mode: 1, \r
- thumbnail_width: 64, \r
- thumbnail_height: 64, \r
- profile: {\r
- users: {\r
- caption: "ペンギン王国",\r
- url: "http://localhost:3001/", \r
- description: "ペンギン王国はペンギン素材を豊富に用意したペンギンマニアのサイトです。",\r
- },\r
- admins: {\r
- caption: "site name for admin",\r
- url: "http://your.site.url/admins/", \r
- description: "admin register",\r
- },\r
- demand_users: {\r
- caption: "provider name",\r
- url: "http://your.site.url/demanders/", \r
- description: "provider description",\r
- },\r
- },\r
- provider_sources: [\r
- 'http://sourceforge.jp/projects/pettanr/wiki/ProviderSource/attach/provider_source.json'\r
- ], \r
-}\r
before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
else
before_filter :authenticate_resource_reader, :only => [
- :index, :show, :credit, :by_license, :by_artist, :count, :count_by_license, :count_by_artist
+ :index, :show, :credit, :by_original_picture, :by_license, :by_artist, :count, :count_by_license, :count_by_artist
]
before_filter :authenticate_user, :only => [:new, :create, :update, :destroy]
before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy]
filer_list
end
+ def by_original_picture
+ filer_list
+ end
+
def by_license
filer_list
end
end
end
- def opt_div_style spot = nil, opacity = 20
- o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
- "position: absolute; left:#{self.div_x}%; top:#{self.div_y}%; width:#{self.div_width}%; height:#{self.div_height}%; z-index:#{self.z}; background-color:##{format("%06x", self.code)}; #{o}"
+ def style spot = nil, opacity = 20
+ r = {
+ 'position' => 'absolute', 'z-index' => self.z,
+ 'top' => self.div_y.to_s + '%', 'left' => self.div_x.to_s + '%',
+ 'width' => self.div_width.to_s + '%', 'height' => self.div_height.to_s + '%',
+ 'background-color' => '#' + format("%06x", self.code)
+ }
+ self.merge_opacity(r, opacity) if spot and spot != self
+ r
end
def boost
self.owner_model.visible? operators
end
- def opt_div_style full_url, spot = nil, opacity = 20
- o = (spot and spot != self) ? "opacity: #{opacity.to_f/100}; filter:alpha(opacity=#{opacity});" : ''
- "position: absolute; width:#{self.get_panel.width}px; height:#{self.get_panel.height}px; top: 0px; left: 0px; z-index:#{self.z}; background-image: url(#{full_url}); background-repeat: #{self.repeat_text}; background-position: #{self.x}px #{self.y}px; #{o}"
+ def style spot = nil, opacity = 20
+ r = {
+ 'position' => 'absolute', 'top' => '0px', 'left' => '0px', 'z-index' => self.z,
+ 'background-image' => "url(#{self.picture.url})",
+ 'background-repeat' => self.repeat_text,
+ 'background-position' => "#{self.x}px #{self.y}px"
+ }
+ self.merge_opacity(r, opacity) if spot and spot != self
+ r
end
def tmb_opt_img_tag
self.publish > 0
end
+ # ground_picture element template
+ def style_wh
+ {
+ 'width' => self.width.to_s + 'px', 'height' => self.height.to_s + 'px'
+ }
+ end
+
def tag_id c = nil
'panel' + self.tag_panel_id + c.to_s
end
end
def boost
- self.extend self.speech_balloon_template.engine_speech_balloon_module
+ self.extend self.speech_balloon_template.engine_extend_module
if self.balloon
else
self.new_balloon = self.build_balloon
engine.const_get 'SpeechBalloonModule'
end
+ def engine_extend_module
+ engine.extend_module
+ end
+
def engine_balloon_model
engine.const_get 'Balloon'
end
-<%= content_tag :div, element.tag_attributes(:div, {'class' => "pettanr-comic-ground-color", 'style' => element.opt_div_style(spot)}) do %>
+<%= content_tag :div, element.tag_attributes(:div, {'class' => "pettanr-comic-ground-color", 'style' => raw(element.style(spot).to_style)}) do %>
<% end %>
-<%= content_tag :div, element.tag_attributes(:div, {'class' => "pettanr-comic-ground-picture", 'style' => element.opt_div_style(full_url(element.picture.url), spot)}) do %>
+<%= content_tag :div, element.tag_attributes(:div, {'class' => "pettanr-comic-ground-picture", 'style' => raw(element.style(spot).merge(root.style_wh).to_style)}) do %>
<% end %>
-<% panel.panel_elements.each do |elm| %>
- <% case elm.class.to_s %>
- <% when 'SpeechBalloon' %>
- <% elm.boost %>
- <% end %>
-<% end %>
<%= content_tag :div, :id => panel.tag_id, :panel_id => panel.tag_panel_id, :class => "pettanr-comic-panel", :style => "width: #{panel.width}px; height: #{panel.height}px; border-style: solid; border-width: #{panel.border}px; border-color: black; background-color: white;" do %>
<% if panel.visible? operators -%>
<% panel.panel_elements.each do |element| %>
- <%= render element.path_name + '/element', :element => element, :spot => spot %>
+ <%= render element.path_name + '/element', :element => element, :root => panel, :spot => spot %>
<% end %>
<% else %>
<h2><%= t('panels.hidden') %></h2>
end
def filer
- l = @has_many_manifest.list
list_result = @has_many_manifest.list.open(self.profiler.operators, {:id => self.item.id, :page => 1, :page_size => 3})
items = list_result.items
::Manifest::View::Filer.new self.has_many_model.item_name, items, nil, self.profiler.operators
module ProfilerModule
module AssociationModule
class HasOne
- attr :association, :column_name
- def initialize association, belongs_to_name
+ attr :association, :has_one_manifest
+ def initialize association, has_one_manifest
@association = association
- @belongs_to_name = belongs_to_name
- end
-
- def profiler
- @association.profiler
+ @has_one_manifest = has_one_manifest
end
def item
self.profiler.item
end
- def parent_model
- self.model_belongs_to_manifest.model
- end
-
- def parent_id
- self.item.attributes[self.model_belongs_to_manifest.id_column]
+ def has_one_model
+ @has_one_manifest.model
end
def filer
- filer = nil
- begin
- r = self.parent_model.show(self.parent_id, self.profiler.operators)
- if r
- filer = Manifest::View::Filer.new self.item.item_name, [r], nil, self.profiler.operators
- end
- rescue ActiveRecord::RecordNotFound, ActiveRecord::Forbidden
- end
- filer
- end
-
- def model_manifest
- ::Manifest.manifest.models[@profiler.item_name]
+ list_result = @has_one_manifest.list.open(self.profiler.operators, {:id => self.item.id})
+ items = list_result.items
+ ::Manifest::View::Filer.new self.has_one_model.item_name, items, nil, self.profiler.operators
end
- def model_belongs_to_manifest
- self.model_manifest.belongs_to[@belongs_to_name]
- end
-
- def template_dir
- @profiler.template_dir
- end
-
- def template_file_name
- "ssociations"
- end
-
- def template_name
- self.template_dir + self.template_file_name
+ def profiler
+ @association.profiler
end
end
class Manifest
cattr_accessor :manifest
attr :system_resources, :magic_numbers,
- :controllers, :models, :list_groups, :profilers, :filers, :forms, :lists, :views
+ :controllers, :models,
+ :list_groups, :profilers, :filers, :forms
# call me before load routes.rb
# routes.rb needs engine_resources manifest in system_resources
# ex. it's adding license_groups routes
def init
# managers can't initialize before load application.rb
return unless defined? ::Pettanr
- @controllers = Controller.manager(self, @manifest['controllers'])
- @models = Model.manager(self, @manifest['models'])
+ @controllers = Controller.manager(self, @manifest['controllers'] || {})
+ @models = Model.manager(self, @manifest['models'] || {})
@locals = @manifest['locals']
@list_groups = ListGroup.manager(self, @locals['list_groups'] || {})
- @filers = Filer.manager(self, @locals['filers'])
- @profilers = Profiler.manager(self, @locals['profilers'])
- @forms = Form.base_manager(self, @locals['forms'])
- @forms.merge(Form.extend_manager(self, @locals['forms']))
+ @filers = Filer.manager(self, @locals['filers'] || {})
+ @profilers = Profiler.manager(self, @locals['profilers'] || {})
+ @forms = Form.base_manager(self, @locals['forms'] || {})
+ @forms.merge(Form.extend_manager(self, @locals['forms'] || {}))
@system_resources.init
- add_action
end
def load_models_manifest
name.singularize
end
+ def pluralize name
+ name.pluralize
+ end
+
end
extend ModuleMethods
@model_name = @table_name.singularize
@list_name = n[1]
else
- raise "undefined list for profilers > #{self.profiler.item_name} > lists > #{@my_name}\n" unless @list_manifest['model_name']
+ raise "undefined list for profilers > #{self.profiler.item_name} > has_many > #{@profiler_list_name}\n"
end
end
@list_group = ::Manifest.manifest.list_groups[@model_name]
module ProfilerModule
module AssociationModule
class HasOne
- attr :association, :list_name
- def initialize association, list_name
+ attr :association, :profiler_list_name,
+ :model_name, :list_name, :list
+ def initialize association, profiler_list_name
@association = association
- @list_name = list_name
+ @profiler_list_name = profiler_list_name
self.set_default
self.init
end
end
def init
+ if list_manifest = self.profiler.lists[@profiler_list_name]
+ @model_name = list_manifest.model_name
+ @list_name = list_manifest.list_name
+ else
+ n = @profiler_list_name.split '.'
+ if n.size > 1
+ @model_name = n[0]
+ @list_name = n[1]
+ else
+ raise "undefined list for profilers > #{self.profiler.item_name} > has_one > #{@profiler_list_name}\n"
+ end
+ end
+ @list_group = ::Manifest.manifest.list_groups[@model_name]
+ raise "undefined list_group for profilers > #{self.profiler.item_name} > lists > #{@my_name} ... #{@model_name}\n" unless @list_group
+ @list = @list_group.lists[@list_name]
+ raise "undefined list for profilers > #{self.profiler.item_name} > lists > #{@my_name} ... #{@list_name}\n" unless @list
end
def model
@association.association_name
end
+ def profiler
+ @association.profiler
+ end
+
+ def profiler_manifest
+ @association.profiler_manifest
+ end
+
end
end
r
end
+ def merge_opacity s, opacity
+ s.merge({
+ 'opacity' => opacity.to_f/100,
+ 'filter' => "alpha(opacity=#{opacity})"
+ })
+ end
+
end
end
#InstanceMethods
+ def self.fold_extend_settings params
+ speech_balloon_settings = params[:speech_balloon][:settings]
+ if speech_balloon_settings.is_a?(Hash)
+ params[:speech_balloon][:settings] = speech_balloon_settings.to_json
+ end
+ balloon_settings = params[:speech_balloon][:balloon_attributes][:settings]
+ if balloon_settings.is_a?(Hash)
+ params[:speech_balloon][:balloon_attributes][:settings] = balloon_settings.to_json
+ end
+ speech_settings = params[:speech_balloon][:speech_attributes][:settings]
+ if speech_settings.is_a?(Hash)
+ params[:speech_balloon][:speech_attributes][:settings] = speech_settings.to_json
+ end
+ end
+
+ def extend_engine_module
+ self.extend self.speech_balloon_template.engine_speech_balloon_module
+ self.elements.each do |element|
+ element.extend_item
+ end
+ end
+
def item_name
self.class.item_name
end
"list_name": "public"\r
}\r
},\r
+ "by_original_picture": {\r
+ "type": "list"\r
+ },\r
"by_license": {\r
"type": "list"\r
},\r
"private": {\r
"type": "private"\r
},\r
+ "by_original_picture": {\r
+ "type": "filter"\r
+ },\r
"by_license": {\r
"type": "filter"\r
},\r
"artist"\r
],\r
"has_one": [\r
- "resource_picture"\r
+ "resource_picture.by_original_picture"\r
]\r
}\r
},\r
"lists": {\r
"public": {},\r
"private": {},\r
+ "by_original_picture": {},\r
"by_license": {},\r
"by_artist": {}\r
}\r