OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
authoryasushiito <yas@pen-chan.jp>
Fri, 18 Apr 2014 07:10:07 +0000 (16:10 +0900)
committeryasushiito <yas@pen-chan.jp>
Fri, 18 Apr 2014 07:10:07 +0000 (16:10 +0900)
20 files changed:
Gemfile
app/assets/javascripts/folders.js.coffee [new file with mode: 0644]
app/assets/javascripts/manifest/work/forms.js.coffee.erb
app/assets/stylesheets/folders.css.scss [new file with mode: 0644]
app/controllers/folders_controller.rb [new file with mode: 0644]
app/helpers/folders_helper.rb [new file with mode: 0644]
app/models/folder.rb [new file with mode: 0644]
app/views/home/index.html.erb
app/views/templates/r/form/_extend_form.html.erb [moved from app/views/templates/r/form/_extend_fform.html.erb with 54% similarity]
app/views/templates/r/form/_fields.html.erb
config/locales/pettanr.ja.yml
db/migrate/20140415021754_create_folders.rb [new file with mode: 0644]
lib/locmare/form.rb
lib/locmare/form/extend_field.rb
lib/locmare/form/field.rb
lib/manifest/item/base.rb
public/local_manifest.json
spec/controllers/folders_controller_spec.rb [new file with mode: 0644]
spec/helpers/folders_helper_spec.rb [new file with mode: 0644]
spec/models/folder_spec.rb [new file with mode: 0644]

diff --git a/Gemfile b/Gemfile
index 289e613..d9887dd 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -8,6 +8,7 @@ gem 'backbone-rails'
 gem 'kaminari'
 gem 'sanitize'
 gem 'aws-s3'
+gem 'awesome_nested_set'
 gem 'validates_existence'
 gem "validate_url"
 gem "pettanr_creative_commons_v30_licenses"
diff --git a/app/assets/javascripts/folders.js.coffee b/app/assets/javascripts/folders.js.coffee
new file mode 100644 (file)
index 0000000..7615679
--- /dev/null
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
index 642cc36..9df9ebc 100644 (file)
       'open', \r
       'commercial', \r
       'official', \r
-      'attribution:', \r
+      'attribution', \r
       'derive', \r
       'thumbnail', \r
       'gif_convert', \r
diff --git a/app/assets/stylesheets/folders.css.scss b/app/assets/stylesheets/folders.css.scss
new file mode 100644 (file)
index 0000000..1dea791
--- /dev/null
@@ -0,0 +1,3 @@
+// Place all the styles related to the folders controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/folders_controller.rb b/app/controllers/folders_controller.rb
new file mode 100644 (file)
index 0000000..318f1c8
--- /dev/null
@@ -0,0 +1,32 @@
+class FoldersController < ApplicationController
+  if Manifest.manifest.magic_numbers['run_mode'] == 0
+    before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+  else
+    before_filter :authenticate_reader, :only => [:index, :show]
+    before_filter :authenticate_admin, :only => [:new, :create, :edit, :update, :destroy]
+  end
+  
+  def self.model
+    Folder
+  end
+  
+  def index
+    filer_list
+  end
+  
+  def show_html_format format
+    format.html {
+      @folder = @item
+    }
+  end
+  
+  def show
+    set_show
+    respond_to do |format|
+      show_html_format format
+      show_prof_format format
+      show_json_format format
+    end
+  end
+  
+end
diff --git a/app/helpers/folders_helper.rb b/app/helpers/folders_helper.rb
new file mode 100644 (file)
index 0000000..d27e7b4
--- /dev/null
@@ -0,0 +1,2 @@
+module FoldersHelper
+end
diff --git a/app/models/folder.rb b/app/models/folder.rb
new file mode 100644 (file)
index 0000000..c3c8673
--- /dev/null
@@ -0,0 +1,17 @@
+class Folder < Peta::Item
+  acts_as_nested_set
+  
+  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
+  
+  def self.generate
+    if self.root
+    else
+      self.create :category_id => 0
+    end
+    
+  end
+  
+end
index 54accf3..e50c6e8 100644 (file)
@@ -1,64 +1,69 @@
 <h1><%= t '.title' -%></h1>
+<% if @operators.author -%>
 <h2><%= link_to h(@operators.author.name), main_app.author_path(@operators.author) -%></h2>
 <h3><%= t('.updated_scroll') -%></h3>
-<table>
-  <tr height="100px">
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('Scroll'), '/home/scrolls' %>
-      <%= link_to t('*'), new_scroll_path %>
-    </td>
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('ScrollPanel'), '/home/scroll_panels' %>
-      <%= link_to t('*'), new_scroll_panel_path %>
-    </td>
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('Comic'), '/home/comics' %>
-      <%= link_to t('*'), new_comic_path %>
-    </td>
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('Story'), '/home/stories' %>
-      <%= link_to t('*'), new_story_path %>
-    </td>
-  </tr>
-  <tr height="100px">
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('StorySheet'), '/home/story_sheets' %>
-      <%= link_to t('*'), new_story_sheet_path %>
-    </td>
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('Sheet'), '/home/sheets' %>
-      <%= link_to t('*'), new_sheet_path %>
-    </td>
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('SheetPanel'), '/home/sheet_panels' %>
-      <%= link_to t('*'), new_sheet_panel_path %>
-    </td>
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('Panel'), '/home/panels' %>
-      <%= link_to t('*'), new_panel_path %>
-    </td>
-  </tr>
-</table>
-<h3><%= t('.used_element') -%></h3>
-<table>
-  <tr height="100px">
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('PanelPicture'), '/home/panel_pictures' %>
-    </td>
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('SpeechBalloon'), '/home/speech_balloons' %>
-    </td>
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('GroundPicture'), '/home/ground_pictures' %>
-    </td>
-    <td width="200px" align="center" valign="middle">
-      <%= link_to t_m('GroundColor'), '/home/ground_colors' %>
-      <%= link_to t('*'), new_ground_color_path %>
-    </td>
-    <td width="200px" align="center" valign="middle">
-    </td>
-  </tr>
-</table>
+  <table>
+    <tr height="100px">
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('Scroll'), '/home/scrolls' %>
+        <%= link_to t('*'), new_scroll_path %>
+      </td>
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('ScrollPanel'), '/home/scroll_panels' %>
+        <%= link_to t('*'), new_scroll_panel_path %>
+      </td>
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('Comic'), '/home/comics' %>
+        <%= link_to t('*'), new_comic_path %>
+      </td>
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('Story'), '/home/stories' %>
+        <%= link_to t('*'), new_story_path %>
+      </td>
+    </tr>
+    <tr height="100px">
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('StorySheet'), '/home/story_sheets' %>
+        <%= link_to t('*'), new_story_sheet_path %>
+      </td>
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('Sheet'), '/home/sheets' %>
+        <%= link_to t('*'), new_sheet_path %>
+      </td>
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('SheetPanel'), '/home/sheet_panels' %>
+        <%= link_to t('*'), new_sheet_panel_path %>
+      </td>
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('Panel'), '/home/panels' %>
+        <%= link_to t('*'), new_panel_path %>
+      </td>
+    </tr>
+  </table>
+  <h3><%= t('.used_element') -%></h3>
+  <table>
+    <tr height="100px">
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('PanelPicture'), '/home/panel_pictures' %>
+      </td>
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('SpeechBalloon'), '/home/speech_balloons' %>
+      </td>
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('GroundPicture'), '/home/ground_pictures' %>
+      </td>
+      <td width="200px" align="center" valign="middle">
+        <%= link_to t_m('GroundColor'), '/home/ground_colors' %>
+        <%= link_to t('*'), new_ground_color_path %>
+      </td>
+      <td width="200px" align="center" valign="middle">
+      </td>
+    </tr>
+  </table>
+<% else -%>
+  <h2><%= t('.author') -%></h2>
+  <h3><%= link_to t('.not_author'), main_app.new_author_path -%></h2>
+<% end -%>
 <% if @operators.artist -%>
   <h2><%= link_to h(@operators.artist.name), main_app.artist_path(@operators.artist) -%></h2>
   <h3><%= t('.updated_picture') -%></h3>
@@ -81,6 +86,5 @@
   </table>
 <% else -%>
   <h2><%= t('.artist') -%></h2>
-  <h3><%= t('.updated_picture') -%></h3>
   <h3><%= link_to t('.not_artist'), main_app.new_artist_path -%></h2>
 <% end -%>
@@ -1,4 +1,4 @@
-<%= form_for(form.item, :html => form.item.tag_attributes('form', 'data-form-name' => form.form_name)) do |f| %>
+<%= form_for(form.item) do |f| %>
   <%= render 'system/error_explanation', :obj => form.item %>
   <%= render form.fields_template_name, :form => form, :f => f %>
 <% end %>
index 15b510e..7202fd2 100644 (file)
@@ -1,5 +1,5 @@
 <div class="fields">
   <% form.each_field do |field_name, field| %>
-    <%= render field.template_name, :field => field %>
+    <%= render field.template_name, field.template_option %>
   <% end %>
 </div>
index 309d9e1..0581854 100644 (file)
@@ -483,7 +483,9 @@ ja:
       catch: つかんでいるコマ
       used_element: 最近使った部品
       updated_picture: 最近更新した画像
+      author: 作家
       artist: 絵師
+      not_author: 作品を公開するには作家登録
       not_artist: 画像を公開するには絵師登録
     scrolls:
       title: 最近更新したスクロール
@@ -1084,6 +1086,9 @@ ja:
       title: 作家プロフィール編集
     destroy:
       title: 休筆
+    submit:
+      new: 登録
+      edit: 変更
   artists:
     index:
       title: 絵師一覧
@@ -1102,6 +1107,9 @@ ja:
       title: 絵師プロフィール編集
     destroy:
       title: 活動停止
+    submit:
+      new: 登録
+      edit: 変更
   system_pictures:
     index:
       title: システム画像一覧
diff --git a/db/migrate/20140415021754_create_folders.rb b/db/migrate/20140415021754_create_folders.rb
new file mode 100644 (file)
index 0000000..265e379
--- /dev/null
@@ -0,0 +1,17 @@
+class CreateFolders < ActiveRecord::Migration
+  def change
+    create_table :folders do |t|
+      t.string :controller_name, :null => false
+      t.string :action_name, :null => false
+      t.integer :category_id, :null => false, :default => 0
+      t.integer :t, :null => false, :default => 0
+      t.integer :parent_id
+      t.integer :lft
+      t.integer :rgt
+      t.integer :depth # this is optional.
+
+      t.timestamps
+    end
+    add_index :folders , [:rgt]
+  end
+end
index a9e3054..ce92660 100644 (file)
@@ -54,8 +54,8 @@ module Locmare
     def init_fields
       @manifest.each_field do |field_name, field_manifest| 
         if boost_name = @item.class.find_boost_name(field_name)
+        p [field_name]
           extend_form_name = @item.boosters[boost_name].model_name
-          extend_form_manifest = LocalManifest.manifest.forms[extend_form_name]
           extend_item = @item.boosters[boost_name].extend_item
           @fields[field_name] = ExtendForm.new self, extend_form_name, extend_item, @mounted, @operators
         else
@@ -97,13 +97,7 @@ module Locmare
     
     def init_fields
       @manifest.each_field do |field_name, field_manifest| 
-        if boost_name = @item.class.find_boost_name(field_name)
-          extend_form_name = @item.boosters[boost_name].model_name
-          extend_form_manifest = LocalManifest.manifest.forms[extend_form_name]
-          @fields[field_name] = ExtendField.new self, field_name, field_manifest, @item.boosters[n].extend_item
-        else
-       #   @fields[field_name] = Field.new self, field_name, field_manifest
-        end
+        @fields[field_name] = ExtendField.new self, field_name, field_manifest
       end
     end
     
@@ -111,6 +105,10 @@ module Locmare
       "extend_form"
     end
     
+    def template_option
+      {:form=> self}
+    end
+    
   end
   
 end
index 1987c4a..01abed5 100644 (file)
@@ -1,6 +1,7 @@
 module Locmare
   module FormModule
     class ExtendField
+      include FieldModule
       attr :form, :field_name, :field_manifest, 
         :label, :tag, :helpers, :options
       def initialize form, field_name, field_manifest
@@ -33,7 +34,7 @@ module Locmare
       end
       
       def options tag_options = {}
-        self.item.field_tag_attributes(@field_manifest.column_name, tag_options).merge(self.mount_option)
+        tag_options
       end
       
       def form_field_name
@@ -56,6 +57,10 @@ module Locmare
         self.template_dir + self.template_file_name
       end
       
+      def template_option
+        {:field => self}
+      end
+      
       def row_break_template_dir
         @form.template_dir + 'row_break/'
       end
index fc24e93..5fa970b 100644 (file)
@@ -60,6 +60,10 @@ module Locmare
         self.template_dir + self.template_file_name
       end
       
+      def template_option
+        {:field => self}
+      end
+      
       def row_break_template_dir
         @form.template_dir + 'row_break/'
       end
index 6fc61dc..cfe34ac 100644 (file)
@@ -30,7 +30,7 @@ module Manifest
       
       def find_boost_name column_name
         @boost.each do |boost_name, boost_manifest|
-          return boost_name if boost_manifest.extend_column_name == column_name
+          return boost_name if boost_manifest.settings_column_name == column_name
         end
         nil
       end
index 5d877a0..02780a3 100644 (file)
         "open",\r
         "commercial",\r
         "official",\r
-        "attribution:",\r
+        "attribution",\r
         "derive",\r
         "thumbnail",\r
         "gif_convert",\r
diff --git a/spec/controllers/folders_controller_spec.rb b/spec/controllers/folders_controller_spec.rb
new file mode 100644 (file)
index 0000000..b43fe5c
--- /dev/null
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe FoldersController do
+
+end
diff --git a/spec/helpers/folders_helper_spec.rb b/spec/helpers/folders_helper_spec.rb
new file mode 100644 (file)
index 0000000..7f19667
--- /dev/null
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+# Specs in this file have access to a helper object that includes
+# the FoldersHelper. For example:
+#
+# describe FoldersHelper do
+#   describe "string concat" do
+#     it "concats two strings with spaces" do
+#       helper.concat_strings("this","that").should == "this that"
+#     end
+#   end
+# end
+describe FoldersHelper do
+  pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/folder_spec.rb b/spec/models/folder_spec.rb
new file mode 100644 (file)
index 0000000..e8035fd
--- /dev/null
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Folder do
+  pending "add some examples to (or delete) #{__FILE__}"
+end