OSDN Git Service

fix editor
authoryasushiito <yas@pen-chan.jp>
Thu, 12 Jun 2014 02:34:31 +0000 (11:34 +0900)
committeryasushiito <yas@pen-chan.jp>
Thu, 12 Jun 2014 02:34:31 +0000 (11:34 +0900)
13 files changed:
app/controllers/ground_colors_controller.rb
app/controllers/ground_pictures_controller.rb
app/controllers/panel_pictures_controller.rb
app/controllers/speech_balloons_controller.rb
app/models/panel.rb
app/views/speech_balloons/_scenario.html.erb [new file with mode: 0644]
app/views/templates/r/panel_editor/panel_editor.html.erb
lib/editor/panel_dock/bay/element.rb
lib/editor/panel_dock/bay/priority.rb
lib/editor/panel_dock/bay/scenario.rb
lib/editor/panel_dock/board/element.rb
lib/editor/pool.rb
lib/peta/root.rb

index 32e3d64..168bda3 100644 (file)
@@ -1,13 +1,13 @@
 class GroundColorsController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_author, :only => []
   else
     before_filter :authenticate_reader, :only => [
       :index, :show, :by_panel, :by_author, :count, :count_by_panel, :count_by_author
     ]
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_author, :only => []
   end
 
   def self.model
@@ -53,88 +53,4 @@ class GroundColorsController < ApplicationController
     list_count
   end
   
-  def new
-    raise Pettanr::NotWork unless @operators.author.working_panel
-    @panel = Panel.edit(@operators.author.working_panel, @operators)
-    @ground_color = GroundColor.new :panel_id => @panel.id, :code => params[:code].to_i
-    @ground_color.supply_default
-
-    respond_to do |format|
-      format.html
-      format.json { render :json => @ground_color.to_json(GroundColor.show_json_opt) }
-    end
-  end
-
-  def edit
-    @ground_color = GroundColor.show(params[:id], @operators)
-    @panel = Panel.edit(@ground_color.panel.id, @operators)
-    
-    respond_to do |format|
-      format.html
-    end
-  end
-
-  def create
-    raise Pettanr::NotWork unless @operators.author.working_panel
-    @panel = Panel.edit(@operators.author.working_panel, @operators)
-    
-    @ground_color = GroundColor.new 
-    @ground_color.attributes = params[:ground_color]
-    @ground_color.overwrite @panel.id
-    
-    respond_to do |format|
-      if @ground_color.valid?
-        if @ground_color.store @operators
-          flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
-          format.html { redirect_to @panel }
-          format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
-        else
-          flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human)
-          format.html { render action: "new" }
-          format.json { render json: @ground_color.errors, status: :unprocessable_entity }
-        end
-      else
-        flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundColor.model_name.human)
-        format.html { render action: "new" }
-        format.json { render json: @ground_color.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  def update
-    @ground_color = GroundColor.show(params[:id], @operators)
-    @ground_color.attributes = params[:ground_color]
-    @panel = Panel.edit(@ground_color.panel.id, @operators)
-    @ground_color.overwrite @panel.id
-    
-    respond_to do |format|
-      if @ground_color.store @operators
-        flash[:notice] = I18n.t('flash.notice.updated', :model => GroundColor.model_name.human)
-        format.html { redirect_to @ground_color }
-        format.json { head :ok }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_updated', :model => GroundColor.model_name.human)
-        format.html { render action: "edit" }
-        format.json { render json: @ground_color.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  def destroy
-    @ground_color = GroundColor.show(params[:id], @operators)
-    @panel = Panel.edit(@ground_color.panel.id, @operators)
-    
-    respond_to do |format|
-      if @ground_color.remove @operators
-        flash[:notice] = I18n.t('flash.notice.destroyed', :model => GroundColor.model_name.human)
-        format.html { redirect_to @panel }
-        format.json { head :ok }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => GroundColor.model_name.human)
-        format.html { redirect_to @ground_color }
-        format.json { render json: @ground_color.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-  
 end
index a4616e6..7d5fb1c 100644 (file)
@@ -1,15 +1,15 @@
 class GroundPicturesController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_author, :only => []
   else
     before_filter :authenticate_reader, :only => [
       :index, :show, :by_panel, :by_author, :count, :count_by_panel, :count_by_author
     ]
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_author, :only => []
   end
-
+  
   def self.model
     GroundPicture
   end
@@ -53,97 +53,4 @@ class GroundPicturesController < ApplicationController
     list_count
   end
   
-  def new
-    raise Pettanr::NotWork unless @operators.author.working_panel
-    @picture = Picture.show params[:picture_id], @operators
-    raise ActiveRecord::Forbidden unless @picture.enable?
-    @panel = Panel.edit(@operators.author.working_panel, @operators)
-    
-    @ground_picture = GroundPicture.new :panel_id => @panel.id, :picture_id => @picture.id
-    @ground_picture.supply_default
-
-    respond_to do |format|
-      format.html
-      format.json { render :json => @ground_picture.to_json(GroundPicture.show_json_opt) }
-    end
-  end
-
-  def edit
-    @ground_picture = GroundPicture.show(params[:id], @operators)
-    @panel = Panel.edit(@ground_picture.panel.id, @operators)
-    
-    respond_to do |format|
-      format.html
-    end
-  end
-
-  def create
-    raise Pettanr::NotWork unless @operators.author.working_panel
-    @panel = Panel.edit(@operators.author.working_panel, @operators)
-    
-    @ground_picture = GroundPicture.new
-    @ground_picture.attributes = params[:ground_picture]
-    @ground_picture.overwrite @panel.id
-    
-    @picture = Picture.show @ground_picture.picture_id, @operators
-    raise ActiveRecord::Forbidden unless @picture.enable?
-    
-    respond_to do |format|
-      if @ground_picture.valid?
-        if @ground_picture.store @operators
-          flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
-          format.html { redirect_to @panel }
-          format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
-        else
-          flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundPicture.model_name.human)
-          format.html { render action: "new" }
-          format.json { render json: @panel.errors, status: :unprocessable_entity }
-        end
-      else
-        flash[:notice] = I18n.t('flash.notice.not_created', :model => GroundPicture.model_name.human)
-        format.html { render action: "new" }
-        format.json { render json: @ground_picture.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  def update
-    @ground_picture = GroundPicture.show(params[:id], @operators)
-    @ground_picture.attributes = params[:ground_picture]
-    @panel = Panel.edit(@ground_picture.panel.id, @operators)
-    @ground_picture.overwrite @panel.id
-    
-    @picture = Picture.show @ground_picture.picture_id, @operators
-    raise ActiveRecord::Forbidden unless @picture.enable?
-    
-    respond_to do |format|
-      if @ground_picture.store @operators
-        flash[:notice] = I18n.t('flash.notice.updated', :model => GroundPicture.model_name.human)
-        format.html { redirect_to @ground_picture }
-        format.json { head :ok }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_updated', :model => GroundPicture.model_name.human)
-        format.html { render action: "edit" }
-        format.json { render json: @ground_picture.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  def destroy
-    @ground_picture = GroundPicture.show(params[:id], @operators)
-    @panel = Panel.edit(@ground_picture.panel.id, @operators)
-    
-    respond_to do |format|
-      if @ground_picture.remove @operators
-        flash[:notice] = I18n.t('flash.notice.destroyed', :model => GroundPicture.model_name.human)
-        format.html { redirect_to @panel }
-        format.json { head :ok }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => GroundPicture.model_name.human)
-        format.html { redirect_to @ground_picture }
-        format.json { render json: @ground_picture.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-  
 end
index 728215c..09d1f54 100644 (file)
@@ -1,15 +1,15 @@
 class PanelPicturesController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_author, :only => []
   else
     before_filter :authenticate_reader, :only => [
       :index, :show, :by_panel, :by_author, :count, :count_by_panel, :count_by_author
     ]
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_author, :only => []
   end
-
+  
   def self.model
     PanelPicture
   end
@@ -40,7 +40,7 @@ class PanelPicturesController < ApplicationController
       show_json_format format
     end
   end
-
+  
   def count
     list_count
   end
@@ -53,104 +53,4 @@ class PanelPicturesController < ApplicationController
     list_count
   end
   
-  def new
-    raise Pettanr::NotWork unless @operators.author.working_panel
-    @picture = Picture.show params[:picture_id], @operators
-    raise ActiveRecord::Forbidden unless @picture.enable?
-    @panel = Panel.edit(@operators.author.working_panel, @operators)
-    
-    @item = PanelPicture.new :panel_id => @panel.id, :picture_id => @picture.id
-    @item.supply_default
-    respond_to do |format|
-      format.html {
-        mounted = 1
-        form_manager = Pettanr::Application::manifest.form_managers[@item.form_name]
-        @form = form_manager.open @item, @operators, mounted
-      }
-      format.json { render :json => @panel_picture.to_json(PanelPicture.show_json_opt) }
-    end
-  end
-
-  def edit
-    @item = PanelPicture.show(params[:id], @operators)
-    @panel = Panel.edit(@item.panel.id, @operators)
-    
-    respond_to do |format|
-      format.html {
-        mounted = 1
-        form_manager = Pettanr::Application::manifest.form_managers[@item.form_name]
-        @form = form_manager.open @item, @operators, mounted
-      }
-    end
-  end
-
-  def create
-    raise Pettanr::NotWork unless @operators.author.working_panel
-    @panel = Panel.edit(@operators.author.working_panel, @operators)
-    
-    @panel_picture = PanelPicture.new 
-    @panel_picture.attributes = params[:panel_picture]
-    @panel_picture.overwrite @panel.id
-    
-    @picture = Picture.show @panel_picture.picture_id, @operators
-    raise ActiveRecord::Forbidden unless @picture.enable?
-    
-    respond_to do |format|
-      if @panel_picture.valid?
-        if @panel_picture.store @operators
-          flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
-          format.html { redirect_to @panel }
-          format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
-        else
-          flash[:notice] = I18n.t('flash.notice.not_created', :model => PanelPicture.model_name.human)
-          format.html { render action: "new" }
-          format.json { render json: @panel.errors, status: :unprocessable_entity }
-        end
-      else
-        flash[:notice] = I18n.t('flash.notice.not_created', :model => PanelPicture.model_name.human)
-        format.html { render action: "new" }
-        format.json { render json: @panel_picture.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  def update
-    @panel_picture = PanelPicture.show(params[:id], @operators)
-    @panel_picture.attributes = params[:panel_picture]
-    @panel = Panel.edit(@panel_picture.panel.id, @operators)
-    @panel_picture.overwrite @panel.id
-    
-    @picture = Picture.show @panel_picture.picture_id, @operators
-    raise ActiveRecord::Forbidden unless @picture.enable?
-    
-    respond_to do |format|
-      if @panel_picture.store @operators
-        flash[:notice] = I18n.t('flash.notice.updated', :model => PanelPicture.model_name.human)
-        format.html { redirect_to @panel_picture }
-        format.json { head :ok }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_updated', :model => PanelPicture.model_name.human)
-        format.html { render action: "edit" }
-        format.json { render json: @panel_picture.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  def destroy
-    @panel_picture = PanelPicture.show(params[:id], @operators)
-    @panel = Panel.edit(@panel_picture.panel.id, @operators)
-    
-    respond_to do |format|
-      if @panel_picture.remove @operators
-        flash[:notice] = I18n.t('flash.notice.destroyed', :model => PanelPicture.model_name.human)
-        format.html { redirect_to @panel }
-        format.json { head :ok }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => PanelPicture.model_name.human)
-        format.html { redirect_to @panel_picture }
-        format.json { render json: @panel_picture.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-  
 end
index aeeb9ce..688d8cd 100644 (file)
@@ -1,15 +1,15 @@
 class SpeechBalloonsController < ApplicationController
   if Manifest.manifest.magic_numbers['run_mode'] == 0
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_author, :only => []
   else
     before_filter :authenticate_reader, :only => [
       :index, :show, :by_panel, :by_author, :by_speech_balloon_template, :count, :count_by_panel, :count_by_author, :count_by_speech_balloon_template
     ]
-    before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy]
-    before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy]
+    before_filter :authenticate_user, :only => []
+    before_filter :authenticate_author, :only => []
   end
-
+  
   def self.model
     SpeechBalloon
   end
@@ -62,87 +62,4 @@ class SpeechBalloonsController < ApplicationController
     list_count
   end
   
-  def new
-    form_new
-  end
-  
-  def edit
-    form_edit
-  end
-  
-  def create
-    raise Pettanr::NotWork unless @operators.author.working_panel
-    SpeechBalloon.fold_extend_settings params
-    @panel = Panel.edit(@operators.author.working_panel, @operators)
-    @speech_balloon = SpeechBalloon.new 
-    @speech_balloon.attributes = params[:speech_balloon]
-    
-    @speech_balloon_template = @speech_balloon.speech_balloon_template
-    @speech_balloon.boost
-    
-    params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.get_balloon.select_system_picture 
-    
-    @speech_balloon.overwrite @panel.id
-    
-    respond_to do |format|
-      if @speech_balloon.valid? and @speech_balloon.store(@operators, params[:speech_balloon])
-        flash[:notice] = I18n.t('flash.notice.created', :model => Panel.model_name.human)
-        format.html { redirect_to @panel }
-        format.json { render json: @panel.panel_elements_as_json, status: :created, location: @panel }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_created', :model => SpeechBalloon.model_name.human)
-        format.html {
-          render @speech_balloon_template.engine_name + '/speech_balloons/new'
-        }
-        format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  def update
-    @item = SpeechBalloon.show(params[:id], @operators)
-    @speech_balloon = @item
-    @form = Locmare::Bucket.factory @item.item_name, @item, true, true, @operators
-    @form.fold_extend_settings params
-    @speech_balloon.attributes = params[:speech_balloon]
-    
-    @speech_balloon_template = @speech_balloon.speech_balloon_template
-    
-    params[:speech_balloon][:balloon_attributes][:system_picture_id] = @speech_balloon.balloon.select_system_picture 
-    
-    @panel = Panel.edit(@speech_balloon.panel.id, @operators)
-    @speech_balloon.overwrite @panel.id
-    
-    respond_to do |format|
-      if @speech_balloon.save
-        flash[:notice] = I18n.t('flash.notice.updated', :model => SpeechBalloon.model_name.human)
-        format.html { redirect_to @speech_balloon }
-        format.json { head :ok }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_updated', :model => SpeechBalloon.model_name.human)
-        format.html {
-          render @speech_balloon.speech_balloon_template.engine_name + '/speech_balloons/edit'
-        }
-        format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
-  def destroy
-    @speech_balloon = SpeechBalloon.show(params[:id], @operators)
-    @panel = Panel.edit(@speech_balloon.panel.id, @operators)
-    
-    respond_to do |format|
-      if @speech_balloon.remove @operators.author
-        flash[:notice] = I18n.t('flash.notice.destroyed', :model => SpeechBalloon.model_name.human)
-        format.html { redirect_to @panel }
-        format.json { head :ok }
-      else
-        flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => SpeechBalloon.model_name.human)
-        format.html { redirect_to @speech_balloon }
-        format.json { render json: @speech_balloon.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-  
 end
index e2a17b4..ad20b01 100644 (file)
@@ -79,13 +79,13 @@ class Panel < Peta::Root
   end
   
   def scenario
-    panel_elements.map { |e|
+    scenario_elements.map { |e|
       e.scenario
     }.join
   end
   
   def plain_scenario
-    panel_elements.map { |e|
+    scenario_elements.map { |e|
       e.plain_scenario
     }.join
   end
diff --git a/app/views/speech_balloons/_scenario.html.erb b/app/views/speech_balloons/_scenario.html.erb
new file mode 100644 (file)
index 0000000..9833380
--- /dev/null
@@ -0,0 +1,19 @@
+<% if element.speech.quotes.blank? -%>
+<% else -%>
+  <style>
+  <!--
+  #<%= element.speech.dom_item_id('scenario') -%>:before  {
+    content:"<%= element.speech.arrayed_quotes[0] -%>";
+  }
+  #<%= element.speech.dom_item_id('scenario') -%>:after {
+    content:"<%= element.speech.arrayed_quotes[1] -%>";
+  }
+  -->
+  </style>
+<% end -%>
+<%= content_tag :div, '', element.balloon.tag_attributes('scenario', :class => "circle_speech_balloon-balloon-scenario") do %>
+  <%= h(element.caption) %>
+<% end %>
+<%= content_tag :div, '', element.speech.tag_attributes('scenario', :class => "circle_speech_balloon-speech-scenario") do %>
+  <%= h(element.speech.content) %>
+<% end %>
index a5070d2..e2bf1b4 100644 (file)
@@ -4,7 +4,7 @@
   <%= render editor.generator.template_name, :generator => editor.generator %>
   <div id="writing_formats">
     <% WritingFormat.enable_list().each do |wf| %>
-      <div id="writing_format-<%= wf.id -%>" writing_format_id="<%= wf.id -%>" writing_format_engine_name="<%= wf.engine_name -%>">
+      <div id="writing_format-<%= wf.id -%>" writing_format_id="<%= wf.id -%>" writing_format_engine_name="<%= wf.my_engine_name -%>">
       </div>
     <% end %>
   </div>
index 2ae8eb4..f6937bd 100644 (file)
@@ -13,7 +13,7 @@ module Editor
         end
         
         def elements
-          self.root_item.panel_elements
+          self.root_item.scenario_elements
         end
         
       end
index 5218b7f..95a997d 100644 (file)
@@ -13,7 +13,7 @@ module Editor
         end
         
         def elements
-          self.root_item.panel_elements
+          self.root_item.scenario_elements
         end
         
         def class_name
index 7ebb42d..b347077 100644 (file)
@@ -13,7 +13,7 @@ module Editor
         end
         
         def elements
-          self.root_item.panel_elements
+          self.root_item.scenario_elements
         end
         
         def class_name
index a525ad0..36ae41a 100644 (file)
@@ -36,7 +36,7 @@ module Editor
           
           def initialize parent
             super
-            @form = Locmare::Form.new self.element.item_name, self.element, self.mounted, false, @operators
+            @form = Locmare::Bucket.new self.element.item_name, self.element, self.mounted, false, @operators
             @bucket = FormBucket.new self, @form
           end
           
index f59608c..8c60797 100644 (file)
@@ -14,17 +14,17 @@ module Editor
       def editize
         @root_item.boosts 'post'
         self.register nil, @root_item
-        # editize_element @root_item # test
+        editize_element @root_item
       end
       
       def editize_element parent
-        parent.class.child_element_names(@root_item.class.element_tree_name).each do |element_name|
+        parent.class.child_element_names.each do |element_name|
           e = parent.__send__ element_name
-          e = [e] unless e.respond_to? :each
-          e.each do |element|
-            element.boost
-            self.register parent, element
-            self.editize_element element
+          e = [e] unless e.respond_to?(:each)
+          e.each do |element_item|
+            element_item.boosts 'post'
+            self.register parent, element_item
+            self.editize_element element_item
           end
         end
       end
index 9ff74f3..d2fd100 100644 (file)
@@ -64,21 +64,6 @@ module Peta
       res
     end
     
-    def elements
-      self.scenario_elements.map {|e|
-        #(-_-;)<... kore wa hidoi
-        JSON.parse e.to_json({:include => e.class.json_opt_for_panel})
-      }
-    end
-    
-    def scenario_elements_as_json
-      self.to_json({:include => {:author => {}}, :methods => :elements})
-    end
-    
-  def self.list_as_json_text ary
-    '[' + ary.map {|i| i.panel_elements_as_json }.join(',') + ']'
-  end
-  
     def new_t
       self.scenario_elements.size
     end