From 26485fdc94aad6e87484cfe8c31a71996dbee375 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Tue, 12 Nov 2013 17:17:28 +0900 Subject: [PATCH] t#32349:addd js model --- app/assets/javascripts/application.js | 4 + app/assets/javascripts/content.js.coffee | 141 +++++++++ app/assets/javascripts/element.js.coffee | 316 +++++++++------------ app/assets/javascripts/item.js.coffee | 141 +++++++++ app/assets/javascripts/models/artist.js.coffee | 25 ++ app/assets/javascripts/models/author.js.coffee | 25 ++ app/assets/javascripts/models/balloon.js.coffee | 70 +++++ app/assets/javascripts/models/comic.js.coffee | 25 ++ .../javascripts/models/ground_color.js.coffee | 70 +++++ .../javascripts/models/ground_picture.js.coffee | 70 +++++ app/assets/javascripts/models/license.js.coffee | 25 ++ .../javascripts/models/license_group.js.coffee | 25 ++ .../javascripts/models/original_picture.js.coffee | 25 ++ app/assets/javascripts/models/panel.js.coffee | 25 ++ .../javascripts/models/panel_picture.js.coffee | 70 +++++ app/assets/javascripts/models/picture.js.coffee | 25 ++ .../javascripts/models/resource_picture.js.coffee | 25 ++ app/assets/javascripts/models/scroll.js.coffee | 25 ++ .../javascripts/models/scroll_panel.js.coffee | 25 ++ app/assets/javascripts/models/sheet.js.coffee | 25 ++ .../javascripts/models/sheet_panel.js.coffee | 25 ++ app/assets/javascripts/models/speech.js.coffee | 70 +++++ .../javascripts/models/speech_balloon.js.coffee | 70 +++++ .../models/speech_balloon_template.js.coffee | 25 ++ app/assets/javascripts/models/story.js.coffee | 25 ++ .../javascripts/models/story_sheet.js.coffee | 25 ++ .../javascripts/models/system_picture.js.coffee | 25 ++ .../javascripts/models/writing_format.js.coffee | 25 ++ app/assets/javascripts/panels.js.coffee | 5 + vendor/plugins/content/init.rb | 1 + vendor/plugins/content/lib/content.rb | 75 +++++ vendor/plugins/element/init.rb | 1 + vendor/plugins/element/lib/element.rb | 23 ++ vendor/plugins/item/init.rb | 1 + vendor/plugins/item/lib/item.rb | 160 +++++++++++ 35 files changed, 1555 insertions(+), 183 deletions(-) create mode 100644 app/assets/javascripts/content.js.coffee create mode 100644 app/assets/javascripts/item.js.coffee create mode 100644 app/assets/javascripts/models/artist.js.coffee create mode 100644 app/assets/javascripts/models/author.js.coffee create mode 100644 app/assets/javascripts/models/balloon.js.coffee create mode 100644 app/assets/javascripts/models/comic.js.coffee create mode 100644 app/assets/javascripts/models/ground_color.js.coffee create mode 100644 app/assets/javascripts/models/ground_picture.js.coffee create mode 100644 app/assets/javascripts/models/license.js.coffee create mode 100644 app/assets/javascripts/models/license_group.js.coffee create mode 100644 app/assets/javascripts/models/original_picture.js.coffee create mode 100644 app/assets/javascripts/models/panel.js.coffee create mode 100644 app/assets/javascripts/models/panel_picture.js.coffee create mode 100644 app/assets/javascripts/models/picture.js.coffee create mode 100644 app/assets/javascripts/models/resource_picture.js.coffee create mode 100644 app/assets/javascripts/models/scroll.js.coffee create mode 100644 app/assets/javascripts/models/scroll_panel.js.coffee create mode 100644 app/assets/javascripts/models/sheet.js.coffee create mode 100644 app/assets/javascripts/models/sheet_panel.js.coffee create mode 100644 app/assets/javascripts/models/speech.js.coffee create mode 100644 app/assets/javascripts/models/speech_balloon.js.coffee create mode 100644 app/assets/javascripts/models/speech_balloon_template.js.coffee create mode 100644 app/assets/javascripts/models/story.js.coffee create mode 100644 app/assets/javascripts/models/story_sheet.js.coffee create mode 100644 app/assets/javascripts/models/system_picture.js.coffee create mode 100644 app/assets/javascripts/models/writing_format.js.coffee create mode 100644 vendor/plugins/content/init.rb create mode 100644 vendor/plugins/content/lib/content.rb create mode 100644 vendor/plugins/element/init.rb create mode 100644 vendor/plugins/element/lib/element.rb create mode 100644 vendor/plugins/item/init.rb create mode 100644 vendor/plugins/item/lib/item.rb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 750f9652..07ab6a00 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,7 +12,11 @@ //= require jquery.validate.localization/messages_ja //= require textchange //= require underscore +//= require backbone //= require configurations +//= require item +//= require element +//= require_directory ./models //= require pettanr_editor //= require pettanr_sheeter //= require writing_formats diff --git a/app/assets/javascripts/content.js.coffee b/app/assets/javascripts/content.js.coffee new file mode 100644 index 00000000..eae373ad --- /dev/null +++ b/app/assets/javascripts/content.js.coffee @@ -0,0 +1,141 @@ +class Content extends Item + @single: () -> + 'Name' + + @plural: () -> + 'Names' + + @class_name: () -> + @single() + + @item_name: () -> + @underscore(@single()) + + @table_name: () -> + @underscore(@plural()) + + @path_name: (with_engine = false) -> + @table_name() + + #>> https://gist.github.com/davidjbeveridge/3813724 + @xeach: (arr, func, index=0) -> + if index < arr.length then [ func(arr[index], index), @xeach(arr, func, index + 1)... ] else [] + + @camelize: (input) -> + pieces = input.split(/[\W_-]/) + @xeach(pieces, @capitalize).join("") + + @capitalize: (input) -> + input.charAt(0).toUpperCase() + input.slice(1) + + @lowercase: (input) -> + input.toLowerCase() + + @underscore: (input) -> + pieces = input.replace(/([A-Z])/g, '_$1').split(/[\W_-]/).filter (n) -> !!n + @xeach(pieces, @lowercase ).join("_") + # << + @is_a_string: (str) -> + if (str instanceof String) or (typeof str == "string") + true + else + false + + has_picture: () -> + false + + has_helper: (column_name) -> + c = @constructor.colum_structures() + if c[column_name] and c[column_name]['helper'] + true + else + false + + element_name: () -> + @constructor.element_name() + + extend_column: () -> + null + + extend_element_name: () -> + if @extend_column() + @get(@extend_column()) + else + @element_name() + + find_configurations: (hash, key) -> + if @constructor.is_a_string(hash[key]) + @find_configurations(hash, hash[key]) + else + return hash[key] + + tag_id: (c = null) -> + 'panel' + @tag_panel_id() + @tag_element_type() + @tag_element_id() + c + + field_tag_id: (f) -> + @tag_id() + f + + tag_panel_id: () -> + @get_panel().get('id') || '0' + + tag_element_id: () -> + @get('id') || '0' + + tag_element_type: () -> + @constructor.element_name() + + tag_new_index: () -> + @new_index() + + path_name: (with_engine = false) -> + @constructor.path_name(with_engine) + + form_template: (with_engine = false) -> + @path_name(with_engine) + '/form' + + form_helper_template: (column_name) -> + c = @constructor.colum_structures() + if @has_helper(column_name) + c[colum_name]['helper'] + else + '' + + tag_attributes: (column = null, opt = {}) -> + r = { + id: @field_tag_id(column), panel_id: @tag_panel_id(), + element_id: @tag_element_id(), element_type: @tag_element_type() + } + _.extend(r, opt) + r + + field_tag_attributes: (column, no_attr, opt = {}) -> + r = @tag_attributes(column) + _.extend(r, {column: column, new_index: @tag_new_index(), no_attr: no_attr}) + _.extend(r, opt) + r + + #render element by body + any_tag_attributes: (name = null, opt = {}) -> + r = @tag_attributes(name) + if @new_index() + _.extend(r, {new_index: @tag_new_index()}) + _.extend(r, opt) + r + + select_tag_attributes: (selected, column, no_attr) -> + [ + 'last', 'first', + {html: {selected: selected}}, + @field_tag_attributes(column, no_attr) + ] + + tag_attr: (column = null, opt = {}) -> + @tag_attributes(column, opt).to_attr + + field_tag_attr: (column, no_attr, opt = {}) -> + @field_tag_attributes(column, no_attr, opt).to_attr + + any_tag_attr: (name = null, opt = {}) -> + @any_tag_attributes(name, opt).to_attr + +@Item = Item diff --git a/app/assets/javascripts/element.js.coffee b/app/assets/javascripts/element.js.coffee index 9d28ad31..24d6d40a 100644 --- a/app/assets/javascripts/element.js.coffee +++ b/app/assets/javascripts/element.js.coffee @@ -1,224 +1,174 @@ -class Element - colum_structures = () -> - raise +class Element extends Item + @single: () -> + 'Name' - list_opt_for_panel = () -> - {} + @plural: () -> + 'Names' - show_opt_for_panel = () -> - {} + @class_name: () -> + @single() - json_opt_for_panel = () -> - {} + @element_name: () -> + @underscore(@single()) - path_name = (with_engine = false) -> - self.to_s.tableize + @table_name: () -> + @underscore(@plural()) + @path_name: (with_engine = false) -> + @table_name() + @colum_structures: -> + {} - has_picture? = () -> - false + #>> https://gist.github.com/davidjbeveridge/3813724 + @xeach: (arr, func, index=0) -> + if index < arr.length then [ func(arr[index], index), @xeach(arr, func, index + 1)... ] else [] + + @camelize: (input) -> + pieces = input.split(/[\W_-]/) + @xeach(pieces, @capitalize).join("") + + @capitalize: (input) -> + input.charAt(0).toUpperCase() + input.slice(1) + + @lowercase: (input) -> + input.toLowerCase() + + @underscore: (input) -> + pieces = input.replace(/([A-Z])/g, '_$1').split(/[\W_-]/).filter (n) -> !!n + @xeach(pieces, @lowercase ).join("_") + # << + @is_a_string: (str) -> + if (str instanceof String) or (typeof str == "string") + true + else + false - has_part? = () -> + has_picture: () -> false - parts = () -> - @parts ||= [] + has_part: () -> + false - has_helper? = (column_name) -> - self.class.colum_structures[column_name] and self.class.colum_structures[column_name][:helper] + parts: () -> + @_parts ? @_parts = [] - element_name = () -> - self.class.to_s.underscore + has_helper: (column_name) -> + c = @constructor.colum_structures() + if c[column_name] and c[column_name]['helper'] + true + else + false - extend_column = () -> - nil + element_name: () -> + @constructor.element_name() - extend_element_name = () -> - self.extend_column ? self.attributes[extend_column] : self.element_name + extend_column: () -> + null - find_configurations hash, key = () -> - if hash[key].is_a? String - self.find_configurations hash, hash[key] - else - return hash[key] + extend_element_name: () -> + if @extend_column() + @get(@extend_column()) + else + @element_name() - new_index = () -> - @new_index + find_configurations: (hash, key) -> + if @constructor.is_a_string(hash[key]) + @find_configurations(hash, hash[key]) + else + return hash[key] - new_index= v = () -> - @new_index = v + new_index: () -> + @_new_index - new_panel = () -> - @new_panel + set_new_index: (v) -> + @_new_index = v - new_panel= v = () -> - @new_panel = v + get_new_panel: () -> + @_new_panel - get_panel = () -> - self.panel || @new_panel + set_new_panel: (v) -> + @_new_panel = v - tag_id = (c = nil) -> - 'panel' + self.tag_panel_id + self.tag_element_type + self.tag_element_id + c.to_s + set_panel: (v) -> + @_panel = v - field_tag_id = (f) -> - self.tag_id + f.to_s + get_panel: () -> + @_panel || @_new_panel - tag_panel_id = () -> - self.get_panel.new_record? ? '0' : self.get_panel.id.to_s + tag_id: (c = null) -> + 'panel' + @tag_panel_id() + @tag_element_type() + @tag_element_id() + c - tag_element_id = () -> - self.new_record? ? '0' : self.id.to_s + field_tag_id: (f) -> + @tag_id() + f - tag_element_type = () -> - raise + tag_panel_id: () -> + @get_panel().get('id') || '0' - tag_new_index = () -> - self.new_index.to_s + tag_element_id: () -> + @get('id') || '0' - path_name = (with_engine = false) -> - self.class.path_name(with_engine) + tag_element_type: () -> + @constructor.element_name() - form_template = (with_engine = false) -> - self.path_name(with_engine) + '/form' + tag_new_index: () -> + @new_index() - scenario_template = (with_engine = false) -> - self.path_name(with_engine) + '/scenario' + path_name: (with_engine = false) -> + @constructor.path_name(with_engine) - element_face_template = (with_engine = false) -> - self.path_name(with_engine) + '/element_face' + form_template: (with_engine = false) -> + @path_name(with_engine) + '/form' - form_helper_template(colum_name) = () -> - self.class.colum_structures[colum_name][:helper] + scenario_template: (with_engine = false) -> + @path_name(with_engine) + '/scenario' - tag_attributes = (column = nil, opt = {}) -> - { - :id => self.field_tag_id(column), :panel_id => self.tag_panel_id, - :element_id => self.tag_element_id, :element_type => self.tag_element_type - }.merge(opt) + element_face_template: (with_engine = false) -> + @path_name(with_engine) + '/element_face' - field_tag_attributes = (column, no_attr, opt = {}) -> - self.tag_attributes(column).merge( - {:column => column, :new_index => self.tag_new_index, :no_attr => no_attr} - ).merge(opt) + form_helper_template: (column_name) -> + c = @constructor.colum_structures() + if @has_helper(column_name) + c[colum_name]['helper'] + else + '' + + tag_attributes: (column = null, opt = {}) -> + r = { + id: @field_tag_id(column), panel_id: @tag_panel_id(), + element_id: @tag_element_id(), element_type: @tag_element_type() + } + _.extend(r, opt) + r + + field_tag_attributes: (column, no_attr, opt = {}) -> + r = @tag_attributes(column) + _.extend(r, {column: column, new_index: @tag_new_index(), no_attr: no_attr}) + _.extend(r, opt) + r #render element by body - any_tag_attributes = (name = nil, opt = {}) -> - r = self.tag_attributes(name) - _.extend(r, - {:new_index => self.tag_new_index} - ) if self.new_index - r.merge(opt) - - select_tag_attributes = (selected, column, no_attr) -> + any_tag_attributes: (name = null, opt = {}) -> + r = @tag_attributes(name) + if @new_index() + _.extend(r, {new_index: @tag_new_index()}) + _.extend(r, opt) + r + + select_tag_attributes: (selected, column, no_attr) -> [ - :last, :first, - {:html => {:selected => selected}}, - self.field_tag_attributes(column, no_attr) + 'last', 'first', + {html: {selected: selected}}, + @field_tag_attributes(column, no_attr) ] - tag_attr = (column = nil, opt = {}) -> - self.tag_attributes(column, opt).to_attr - - field_tag_attr = (column, no_attr, opt = {}) -> - self.field_tag_attributes(column, no_attr, opt).to_attr + tag_attr: (column = null, opt = {}) -> + @tag_attributes(column, opt).to_attr - any_tag_attr = (name = nil, opt = {}) -> - self.any_tag_attributes(name, opt).to_attr - - @pettanr_current_panel_id = 0 + field_tag_attr: (column, no_attr, opt = {}) -> + @field_tag_attributes(column, no_attr, opt).to_attr - @new_element_index = {} - @new_element_index[PettanrEditor.pettanr_current_panel_id] = 0 - - @current_panel = () -> - $('#panel' + PettanrEditor.pettanr_current_panel_id.toString()) - - @set_tree_value = (keys, last_attr, value) -> - key = keys.shift() - if keys.length <= 0 - last_attr[key] = value - else - last_attr[key] = last_attr[key] || {} - PettanrEditor.set_tree_value(keys, last_attr[key], value) - - @repeat_texts = ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'] - - @is_editting = () -> - trace = '#panel' + PettanrEditor.pettanr_current_panel_id.toString() + 'wrapper' - if $(trace) and $(trace).attr('editable') - return true - else - return false - @is_editable = (p) -> - if p.parent().attr('editable') - return true - else - return false - @is_var = (o) -> - if parseInt(o.attr('no_attr')) > 0 - return false - else - if o.attr('column') - if o.attr('column') == '_destroy' and o.val().length < 1 - return false - else - return true - else - return false - @is_panel = (o) -> - if PettanrEditor.is_element(o) - return false - else - return true - @is_element = (o) -> - if o.attr('element_type') - return true - else - return false - @is_element_part = (o) -> - if o.attr('element_part_type') - return true - else - return false - @element_is = (element_type, o) -> - if PettanrEditor.is_element(o) and o.attr('element_type') == element_type - return true - else - return false - @element_types = {'panel_picture': 'panel_pictures', 'speech_balloon': 'speech_balloons', 'ground_picture': 'ground_pictures', 'ground_color': 'ground_colors'} - @element_type_to_table = (element_type) -> - PettanrEditor.element_types[element_type] - @text_align_texts = ['left', 'left', 'right', 'center'] + any_tag_attr: (name = null, opt = {}) -> + @any_tag_attributes(name, opt).to_attr - @make_tree = (attr, o) -> - if PettanrEditor.is_var(o) - tree = 'panels-' + o.attr('panel_id') + '-' - if PettanrEditor.is_element(o) - tree = tree + PettanrEditor.element_type_to_table(o.attr('element_type')) + '_attributes-' + o.attr('element_id') + '-' - if PettanrEditor.is_element_part(o) - tree = tree + o.attr('element_part_type') + '_attributes-' - tree = tree + o.attr('column') - keys = tree.split('-') - PettanrEditor.set_tree_value(keys, attr, o.val()) - - @panel_tag_id = (element) -> - '#panel' + element.attr('panel_id') - - @element_tag_id = (element) -> - '#panel' + element.attr('panel_id') + element.attr('element_type') + element.attr('element_id') - - @element_part_tag_id = (element_part) -> - '#panel' + element_part.attr('panel_id') + element_part.attr('element_type') + element_part.attr('element_id') + element_part.attr('element_part_type') + element_part.attr('element_part_id') - - @refresh_attribute = (field) -> - attr = {} - $('input').map -> - PettanrEditor.make_tree(attr, $(@)) - $('textarea').map -> - PettanrEditor.make_tree(attr, $(@)) - $('select').map -> - PettanrEditor.make_tree(attr, $(@)) - field.val(JSON.stringify(attr['panels'][PettanrEditor.pettanr_current_panel_id.toString() ])) - -@PettanrEditor = PettanrEditor +@Element = Element diff --git a/app/assets/javascripts/item.js.coffee b/app/assets/javascripts/item.js.coffee new file mode 100644 index 00000000..130f241b --- /dev/null +++ b/app/assets/javascripts/item.js.coffee @@ -0,0 +1,141 @@ +class Item extends Backbone.Model + @singular: () -> + 'Name' + + @plural: () -> + 'Names' + + @class_name: () -> + @single() + + @item_name: () -> + @underscore(@single()) + + @table_name: () -> + @underscore(@plural()) + + @path_name: (with_engine = false) -> + @table_name() + + #>> https://gist.github.com/davidjbeveridge/3813724 + @xeach: (arr, func, index=0) -> + if index < arr.length then [ func(arr[index], index), @xeach(arr, func, index + 1)... ] else [] + + @camelize: (input) -> + pieces = input.split(/[\W_-]/) + @xeach(pieces, @capitalize).join("") + + @capitalize: (input) -> + input.charAt(0).toUpperCase() + input.slice(1) + + @lowercase: (input) -> + input.toLowerCase() + + @underscore: (input) -> + pieces = input.replace(/([A-Z])/g, '_$1').split(/[\W_-]/).filter (n) -> !!n + @xeach(pieces, @lowercase ).join("_") + # << + @is_a_string: (str) -> + if (str instanceof String) or (typeof str == "string") + true + else + false + + has_picture: () -> + false + + has_helper: (column_name) -> + c = @constructor.colum_structures() + if c[column_name] and c[column_name]['helper'] + true + else + false + + element_name: () -> + @constructor.element_name() + + extend_column: () -> + null + + extend_element_name: () -> + if @extend_column() + @get(@extend_column()) + else + @element_name() + + find_configurations: (hash, key) -> + if @constructor.is_a_string(hash[key]) + @find_configurations(hash, hash[key]) + else + return hash[key] + + tag_id: (c = null) -> + 'panel' + @tag_panel_id() + @tag_element_type() + @tag_element_id() + c + + field_tag_id: (f) -> + @tag_id() + f + + tag_panel_id: () -> + @get_panel().get('id') || '0' + + tag_element_id: () -> + @get('id') || '0' + + tag_element_type: () -> + @constructor.element_name() + + tag_new_index: () -> + @new_index() + + path_name: (with_engine = false) -> + @constructor.path_name(with_engine) + + form_template: (with_engine = false) -> + @path_name(with_engine) + '/form' + + form_helper_template: (column_name) -> + c = @constructor.colum_structures() + if @has_helper(column_name) + c[colum_name]['helper'] + else + '' + + tag_attributes: (column = null, opt = {}) -> + r = { + id: @field_tag_id(column), panel_id: @tag_panel_id(), + element_id: @tag_element_id(), element_type: @tag_element_type() + } + _.extend(r, opt) + r + + field_tag_attributes: (column, no_attr, opt = {}) -> + r = @tag_attributes(column) + _.extend(r, {column: column, new_index: @tag_new_index(), no_attr: no_attr}) + _.extend(r, opt) + r + + #render element by body + any_tag_attributes: (name = null, opt = {}) -> + r = @tag_attributes(name) + if @new_index() + _.extend(r, {new_index: @tag_new_index()}) + _.extend(r, opt) + r + + select_tag_attributes: (selected, column, no_attr) -> + [ + 'last', 'first', + {html: {selected: selected}}, + @field_tag_attributes(column, no_attr) + ] + + tag_attr: (column = null, opt = {}) -> + @tag_attributes(column, opt).to_attr + + field_tag_attr: (column, no_attr, opt = {}) -> + @field_tag_attributes(column, no_attr, opt).to_attr + + any_tag_attr: (name = null, opt = {}) -> + @any_tag_attributes(name, opt).to_attr + +@Item = Item diff --git a/app/assets/javascripts/models/artist.js.coffee b/app/assets/javascripts/models/artist.js.coffee new file mode 100644 index 00000000..e548ce0f --- /dev/null +++ b/app/assets/javascripts/models/artist.js.coffee @@ -0,0 +1,25 @@ +class Artist extends Item + @single: () -> + 'Artist' + + @plural: () -> + 'Artists' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/author.js.coffee b/app/assets/javascripts/models/author.js.coffee new file mode 100644 index 00000000..80d12c9e --- /dev/null +++ b/app/assets/javascripts/models/author.js.coffee @@ -0,0 +1,25 @@ +class Author extends Item + @single: () -> + 'Author' + + @plural: () -> + 'Authors' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/balloon.js.coffee b/app/assets/javascripts/models/balloon.js.coffee new file mode 100644 index 00000000..9b03bf71 --- /dev/null +++ b/app/assets/javascripts/models/balloon.js.coffee @@ -0,0 +1,70 @@ +class Balloon extends Element + @single: () -> + 'Balloon' + + @plural: () -> + 'Balloons' + + @colum_structures: -> + {} + + defaults: { + x: 11 + } + + initialize: () -> + confirm("Welcome to this world") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + confirm( @path_name() ) + confirm( @colum_structures() ) + + has_picture: () -> + true + + has_part: () -> + false + + extend_column: () -> + null + + test: () -> + confirm( @has_picture() ) + confirm( @has_part() ) + confirm( @parts() ) + confirm( @has_helper('column_name') ) + confirm( @element_name() ) + confirm( @extend_column() ) + confirm( @extend_element_name() ) + confirm( @find_configurations(window.configurations,'v') ) + confirm( @new_index() ) + confirm( @set_new_index(3) ) + confirm( @set_new_panel('v') ) + confirm( @get_new_panel() ) + confirm( '@get_panel()' ) + confirm( @get_panel() ) + confirm( @tag_id('c') ) + confirm( @field_tag_id('f') ) + confirm( @tag_panel_id() ) + confirm( @tag_element_id() ) + confirm( @tag_element_type() ) + confirm( @tag_new_index() ) + confirm( @path_name() ) + confirm( @form_template() ) + confirm( @scenario_template() ) + confirm( @element_face_template() ) + confirm( @form_helper_template('colum_name') ) + confirm( @tag_attributes('column') ) + confirm( @field_tag_attributes('column', 0, {}) ) + confirm( @any_tag_attributes('name', {}) ) + confirm( @select_tag_attributes(true, 'column', 0) ) + confirm( @tag_attr('column', {}) ) + confirm( @field_tag_attr('column', 1, {}) ) + confirm( @any_tag_attr('name', {}) ) + +@PanelPicture = PanelPicture diff --git a/app/assets/javascripts/models/comic.js.coffee b/app/assets/javascripts/models/comic.js.coffee new file mode 100644 index 00000000..4291d537 --- /dev/null +++ b/app/assets/javascripts/models/comic.js.coffee @@ -0,0 +1,25 @@ +class Comic extends Item + @single: () -> + 'Comic' + + @plural: () -> + 'Comics' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/ground_color.js.coffee b/app/assets/javascripts/models/ground_color.js.coffee new file mode 100644 index 00000000..eaca96d1 --- /dev/null +++ b/app/assets/javascripts/models/ground_color.js.coffee @@ -0,0 +1,70 @@ +class GroundColor extends Element + @single: () -> + 'GroundColor' + + @plural: () -> + 'GroundColors' + + @colum_structures: -> + {} + + defaults: { + x: 11 + } + + initialize: () -> + confirm("Welcome to this world") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + confirm( @path_name() ) + confirm( @colum_structures() ) + + has_picture: () -> + true + + has_part: () -> + false + + extend_column: () -> + null + + test: () -> + confirm( @has_picture() ) + confirm( @has_part() ) + confirm( @parts() ) + confirm( @has_helper('column_name') ) + confirm( @element_name() ) + confirm( @extend_column() ) + confirm( @extend_element_name() ) + confirm( @find_configurations(window.configurations,'v') ) + confirm( @new_index() ) + confirm( @set_new_index(3) ) + confirm( @set_new_panel('v') ) + confirm( @get_new_panel() ) + confirm( '@get_panel()' ) + confirm( @get_panel() ) + confirm( @tag_id('c') ) + confirm( @field_tag_id('f') ) + confirm( @tag_panel_id() ) + confirm( @tag_element_id() ) + confirm( @tag_element_type() ) + confirm( @tag_new_index() ) + confirm( @path_name() ) + confirm( @form_template() ) + confirm( @scenario_template() ) + confirm( @element_face_template() ) + confirm( @form_helper_template('colum_name') ) + confirm( @tag_attributes('column') ) + confirm( @field_tag_attributes('column', 0, {}) ) + confirm( @any_tag_attributes('name', {}) ) + confirm( @select_tag_attributes(true, 'column', 0) ) + confirm( @tag_attr('column', {}) ) + confirm( @field_tag_attr('column', 1, {}) ) + confirm( @any_tag_attr('name', {}) ) + +@PanelPicture = PanelPicture diff --git a/app/assets/javascripts/models/ground_picture.js.coffee b/app/assets/javascripts/models/ground_picture.js.coffee new file mode 100644 index 00000000..d5820fad --- /dev/null +++ b/app/assets/javascripts/models/ground_picture.js.coffee @@ -0,0 +1,70 @@ +class GroundPicture extends Element + @single: () -> + 'GroundPicture' + + @plural: () -> + 'GroundPictures' + + @colum_structures: -> + {} + + defaults: { + x: 11 + } + + initialize: () -> + confirm("Welcome to this world") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + confirm( @path_name() ) + confirm( @colum_structures() ) + + has_picture: () -> + true + + has_part: () -> + false + + extend_column: () -> + null + + test: () -> + confirm( @has_picture() ) + confirm( @has_part() ) + confirm( @parts() ) + confirm( @has_helper('column_name') ) + confirm( @element_name() ) + confirm( @extend_column() ) + confirm( @extend_element_name() ) + confirm( @find_configurations(window.configurations,'v') ) + confirm( @new_index() ) + confirm( @set_new_index(3) ) + confirm( @set_new_panel('v') ) + confirm( @get_new_panel() ) + confirm( '@get_panel()' ) + confirm( @get_panel() ) + confirm( @tag_id('c') ) + confirm( @field_tag_id('f') ) + confirm( @tag_panel_id() ) + confirm( @tag_element_id() ) + confirm( @tag_element_type() ) + confirm( @tag_new_index() ) + confirm( @path_name() ) + confirm( @form_template() ) + confirm( @scenario_template() ) + confirm( @element_face_template() ) + confirm( @form_helper_template('colum_name') ) + confirm( @tag_attributes('column') ) + confirm( @field_tag_attributes('column', 0, {}) ) + confirm( @any_tag_attributes('name', {}) ) + confirm( @select_tag_attributes(true, 'column', 0) ) + confirm( @tag_attr('column', {}) ) + confirm( @field_tag_attr('column', 1, {}) ) + confirm( @any_tag_attr('name', {}) ) + +@PanelPicture = PanelPicture diff --git a/app/assets/javascripts/models/license.js.coffee b/app/assets/javascripts/models/license.js.coffee new file mode 100644 index 00000000..19e5b943 --- /dev/null +++ b/app/assets/javascripts/models/license.js.coffee @@ -0,0 +1,25 @@ +class License extends Item + @single: () -> + 'License' + + @plural: () -> + 'Licenses' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/license_group.js.coffee b/app/assets/javascripts/models/license_group.js.coffee new file mode 100644 index 00000000..db6e7599 --- /dev/null +++ b/app/assets/javascripts/models/license_group.js.coffee @@ -0,0 +1,25 @@ +class LicenseGroup extends Item + @single: () -> + 'LicenseGroup' + + @plural: () -> + 'LicenseGroups' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/original_picture.js.coffee b/app/assets/javascripts/models/original_picture.js.coffee new file mode 100644 index 00000000..cb58ca35 --- /dev/null +++ b/app/assets/javascripts/models/original_picture.js.coffee @@ -0,0 +1,25 @@ +class OriginalPicture extends Item + @single: () -> + 'OriginalPicture' + + @plural: () -> + 'OriginalPictures' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/panel.js.coffee b/app/assets/javascripts/models/panel.js.coffee new file mode 100644 index 00000000..1e476e11 --- /dev/null +++ b/app/assets/javascripts/models/panel.js.coffee @@ -0,0 +1,25 @@ +class Panel extends Item + @single: () -> + 'Panel' + + @plural: () -> + 'Panels' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/panel_picture.js.coffee b/app/assets/javascripts/models/panel_picture.js.coffee new file mode 100644 index 00000000..1dcb93e2 --- /dev/null +++ b/app/assets/javascripts/models/panel_picture.js.coffee @@ -0,0 +1,70 @@ +class PanelPicture extends Element + @single: () -> + 'PanelPicture' + + @plural: () -> + 'PanelPictures' + + @colum_structures: -> + {} + + defaults: { + x: 11 + } + + initialize: () -> + confirm("Welcome to this world") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + confirm( @path_name() ) + confirm( @colum_structures() ) + + has_picture: () -> + true + + has_part: () -> + false + + extend_column: () -> + null + + test: () -> + confirm( @has_picture() ) + confirm( @has_part() ) + confirm( @parts() ) + confirm( @has_helper('column_name') ) + confirm( @element_name() ) + confirm( @extend_column() ) + confirm( @extend_element_name() ) + confirm( @find_configurations(window.configurations,'v') ) + confirm( @new_index() ) + confirm( @set_new_index(3) ) + confirm( @set_new_panel('v') ) + confirm( @get_new_panel() ) + confirm( '@get_panel()' ) + confirm( @get_panel() ) + confirm( @tag_id('c') ) + confirm( @field_tag_id('f') ) + confirm( @tag_panel_id() ) + confirm( @tag_element_id() ) + confirm( @tag_element_type() ) + confirm( @tag_new_index() ) + confirm( @path_name() ) + confirm( @form_template() ) + confirm( @scenario_template() ) + confirm( @element_face_template() ) + confirm( @form_helper_template('colum_name') ) + confirm( @tag_attributes('column') ) + confirm( @field_tag_attributes('column', 0, {}) ) + confirm( @any_tag_attributes('name', {}) ) + confirm( @select_tag_attributes(true, 'column', 0) ) + confirm( @tag_attr('column', {}) ) + confirm( @field_tag_attr('column', 1, {}) ) + confirm( @any_tag_attr('name', {}) ) + +@PanelPicture = PanelPicture diff --git a/app/assets/javascripts/models/picture.js.coffee b/app/assets/javascripts/models/picture.js.coffee new file mode 100644 index 00000000..295cb857 --- /dev/null +++ b/app/assets/javascripts/models/picture.js.coffee @@ -0,0 +1,25 @@ +class Picture extends Item + @single: () -> + 'Picture' + + @plural: () -> + 'Pictures' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/resource_picture.js.coffee b/app/assets/javascripts/models/resource_picture.js.coffee new file mode 100644 index 00000000..1853af30 --- /dev/null +++ b/app/assets/javascripts/models/resource_picture.js.coffee @@ -0,0 +1,25 @@ +class ResourcePicture extends Item + @single: () -> + 'ResourcePicture' + + @plural: () -> + 'ResourcePictures' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/scroll.js.coffee b/app/assets/javascripts/models/scroll.js.coffee new file mode 100644 index 00000000..52f9581c --- /dev/null +++ b/app/assets/javascripts/models/scroll.js.coffee @@ -0,0 +1,25 @@ +class Scroll extends Item + @single: () -> + 'Scroll' + + @plural: () -> + 'Scrolls' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/scroll_panel.js.coffee b/app/assets/javascripts/models/scroll_panel.js.coffee new file mode 100644 index 00000000..f5b289ca --- /dev/null +++ b/app/assets/javascripts/models/scroll_panel.js.coffee @@ -0,0 +1,25 @@ +class ScrollPanel extends Item + @single: () -> + 'ScrollPanel' + + @plural: () -> + 'ScrollPanels' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/sheet.js.coffee b/app/assets/javascripts/models/sheet.js.coffee new file mode 100644 index 00000000..d4ee92d8 --- /dev/null +++ b/app/assets/javascripts/models/sheet.js.coffee @@ -0,0 +1,25 @@ +class Sheet extends Item + @single: () -> + 'Sheet' + + @plural: () -> + 'Sheets' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/sheet_panel.js.coffee b/app/assets/javascripts/models/sheet_panel.js.coffee new file mode 100644 index 00000000..ed3c1b14 --- /dev/null +++ b/app/assets/javascripts/models/sheet_panel.js.coffee @@ -0,0 +1,25 @@ +class SheetPanel extends Item + @single: () -> + 'SheetPanel' + + @plural: () -> + 'SheetPanels' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/speech.js.coffee b/app/assets/javascripts/models/speech.js.coffee new file mode 100644 index 00000000..bf3fb395 --- /dev/null +++ b/app/assets/javascripts/models/speech.js.coffee @@ -0,0 +1,70 @@ +class SpeechBalloon extends Element + @single: () -> + 'Speech' + + @plural: () -> + 'Speeches' + + @colum_structures: -> + {} + + defaults: { + x: 11 + } + + initialize: () -> + confirm("Welcome to this world") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + confirm( @path_name() ) + confirm( @colum_structures() ) + + has_picture: () -> + true + + has_part: () -> + false + + extend_column: () -> + null + + test: () -> + confirm( @has_picture() ) + confirm( @has_part() ) + confirm( @parts() ) + confirm( @has_helper('column_name') ) + confirm( @element_name() ) + confirm( @extend_column() ) + confirm( @extend_element_name() ) + confirm( @find_configurations(window.configurations,'v') ) + confirm( @new_index() ) + confirm( @set_new_index(3) ) + confirm( @set_new_panel('v') ) + confirm( @get_new_panel() ) + confirm( '@get_panel()' ) + confirm( @get_panel() ) + confirm( @tag_id('c') ) + confirm( @field_tag_id('f') ) + confirm( @tag_panel_id() ) + confirm( @tag_element_id() ) + confirm( @tag_element_type() ) + confirm( @tag_new_index() ) + confirm( @path_name() ) + confirm( @form_template() ) + confirm( @scenario_template() ) + confirm( @element_face_template() ) + confirm( @form_helper_template('colum_name') ) + confirm( @tag_attributes('column') ) + confirm( @field_tag_attributes('column', 0, {}) ) + confirm( @any_tag_attributes('name', {}) ) + confirm( @select_tag_attributes(true, 'column', 0) ) + confirm( @tag_attr('column', {}) ) + confirm( @field_tag_attr('column', 1, {}) ) + confirm( @any_tag_attr('name', {}) ) + +@PanelPicture = PanelPicture diff --git a/app/assets/javascripts/models/speech_balloon.js.coffee b/app/assets/javascripts/models/speech_balloon.js.coffee new file mode 100644 index 00000000..4a282025 --- /dev/null +++ b/app/assets/javascripts/models/speech_balloon.js.coffee @@ -0,0 +1,70 @@ +class SpeechBalloon extends Element + @single: () -> + 'SpeechBalloon' + + @plural: () -> + 'SpeechBalloons' + + @colum_structures: -> + {} + + defaults: { + x: 11 + } + + initialize: () -> + confirm("Welcome to this world") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + confirm( @path_name() ) + confirm( @colum_structures() ) + + has_picture: () -> + true + + has_part: () -> + false + + extend_column: () -> + null + + test: () -> + confirm( @has_picture() ) + confirm( @has_part() ) + confirm( @parts() ) + confirm( @has_helper('column_name') ) + confirm( @element_name() ) + confirm( @extend_column() ) + confirm( @extend_element_name() ) + confirm( @find_configurations(window.configurations,'v') ) + confirm( @new_index() ) + confirm( @set_new_index(3) ) + confirm( @set_new_panel('v') ) + confirm( @get_new_panel() ) + confirm( '@get_panel()' ) + confirm( @get_panel() ) + confirm( @tag_id('c') ) + confirm( @field_tag_id('f') ) + confirm( @tag_panel_id() ) + confirm( @tag_element_id() ) + confirm( @tag_element_type() ) + confirm( @tag_new_index() ) + confirm( @path_name() ) + confirm( @form_template() ) + confirm( @scenario_template() ) + confirm( @element_face_template() ) + confirm( @form_helper_template('colum_name') ) + confirm( @tag_attributes('column') ) + confirm( @field_tag_attributes('column', 0, {}) ) + confirm( @any_tag_attributes('name', {}) ) + confirm( @select_tag_attributes(true, 'column', 0) ) + confirm( @tag_attr('column', {}) ) + confirm( @field_tag_attr('column', 1, {}) ) + confirm( @any_tag_attr('name', {}) ) + +@PanelPicture = PanelPicture diff --git a/app/assets/javascripts/models/speech_balloon_template.js.coffee b/app/assets/javascripts/models/speech_balloon_template.js.coffee new file mode 100644 index 00000000..04168333 --- /dev/null +++ b/app/assets/javascripts/models/speech_balloon_template.js.coffee @@ -0,0 +1,25 @@ +class SpeechBalloonTemplate extends Item + @single: () -> + 'SpeechBalloonTemplate' + + @plural: () -> + 'SpeechBalloonTemplates' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/story.js.coffee b/app/assets/javascripts/models/story.js.coffee new file mode 100644 index 00000000..d635ff74 --- /dev/null +++ b/app/assets/javascripts/models/story.js.coffee @@ -0,0 +1,25 @@ +class Story extends Item + @single: () -> + 'Story' + + @plural: () -> + 'Stories' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/story_sheet.js.coffee b/app/assets/javascripts/models/story_sheet.js.coffee new file mode 100644 index 00000000..95f4b2c5 --- /dev/null +++ b/app/assets/javascripts/models/story_sheet.js.coffee @@ -0,0 +1,25 @@ +class StorySheet extends Item + @single: () -> + 'StorySheet' + + @plural: () -> + 'StorySheets' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/system_picture.js.coffee b/app/assets/javascripts/models/system_picture.js.coffee new file mode 100644 index 00000000..628870b6 --- /dev/null +++ b/app/assets/javascripts/models/system_picture.js.coffee @@ -0,0 +1,25 @@ +class SystemPicture extends Item + @single: () -> + 'SystemPicture' + + @plural: () -> + 'SystemPictures' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/models/writing_format.js.coffee b/app/assets/javascripts/models/writing_format.js.coffee new file mode 100644 index 00000000..620b3313 --- /dev/null +++ b/app/assets/javascripts/models/writing_format.js.coffee @@ -0,0 +1,25 @@ +class WritingFormat extends Item + @single: () -> + 'WritingFormat' + + @plural: () -> + 'WritingFormats' + + defaults: { + id: 11 + } + + initialize: () -> + confirm("Welcome to Panel") + + @test: () -> + confirm( @single()) + confirm( @plural() ) + confirm( @class_name() ) + confirm( @element_name() ) + confirm( @table_name() ) + + + test: () -> + +@Panel = Panel diff --git a/app/assets/javascripts/panels.js.coffee b/app/assets/javascripts/panels.js.coffee index c5466fe5..a0fd3306 100644 --- a/app/assets/javascripts/panels.js.coffee +++ b/app/assets/javascripts/panels.js.coffee @@ -13,6 +13,11 @@ $ -> PictureSizeHelper = window.PettanrPictureSizeHelper ColorHelper = window.PettanrColorHelper + #panel = new Panel + #pp = new PanelPicture + #pp.set_panel(panel) + #confirm( PanelPicture.test() ) + #confirm( pp.test() ) find_configurations = ( hash, key) -> if typeof(hash[key]) == 'string' find_configurations(hash, hash[key]) diff --git a/vendor/plugins/content/init.rb b/vendor/plugins/content/init.rb new file mode 100644 index 00000000..c5f49cc6 --- /dev/null +++ b/vendor/plugins/content/init.rb @@ -0,0 +1 @@ +require 'content' diff --git a/vendor/plugins/content/lib/content.rb b/vendor/plugins/content/lib/content.rb new file mode 100644 index 00000000..23570066 --- /dev/null +++ b/vendor/plugins/content/lib/content.rb @@ -0,0 +1,75 @@ +module ActiveRecord + class Base + module Content + def self.included(base) + base.extend(ClassMethods) + base.__send__ :include, InstanceMethods + end + + module ClassMethods + + def self.mylist_where au + ['panels.author_id = ?', au.id] + end + + def self.himlist_where au + ['panels.author_id = ? and panels.publish > 0', au.id] + end + + def self.mylist au, page = 1, page_size = Author.default_panel_picture_page_size + PanelPicture.where(self.mylist_where(au)).includes(PanelPicture.list_opt).order('panel_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size) + end + + def self.himlist au, page = 1, page_size = Author.default_panel_picture_page_size + PanelPicture.where(self.himlist_where(au)).includes(PanelPicture.list_opt).order('panel_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size) + end + + def self.mylist_paginate au, page = 1, page_size = Author.default_panel_picture_page_size + Kaminari.paginate_array(Array.new(PanelPicture.where(self.mylist_where(au)).includes(PanelPicture.list_opt).count, nil)).page(page).per(page_size) + end + + def self.himlist_paginate au, page = 1, page_size = Author.default_panel_picture_page_size + Kaminari.paginate_array(Array.new(PanelPicture.where(self.himlist_where(au)).includes(PanelPicture.list_opt).count, nil)).page(page).per(page_size) + end + + end + + module InstanceMethods + private + + public + + def visible? roles + if MagicNumber['run_mode'] == 0 + return false unless guest_role_check(roles) + else + return false unless reader_role_check(roles) + end + return true if self.panel.own?(roles) + self.panel.visible? roles + end + + def supply_default + self.x = 0 + self.y = 0 + if self.picture + self.width = self.picture.width + self.height = self.picture.height + end + if self.panel + self.t = self.panel.new_t + self.z = self.panel.new_z + end + end + + def overwrite pid + self.panel_id = pid + end + + end + + end + include Content + end +end + diff --git a/vendor/plugins/element/init.rb b/vendor/plugins/element/init.rb new file mode 100644 index 00000000..6c58bcbf --- /dev/null +++ b/vendor/plugins/element/init.rb @@ -0,0 +1 @@ +require 'element' diff --git a/vendor/plugins/element/lib/element.rb b/vendor/plugins/element/lib/element.rb new file mode 100644 index 00000000..154a9ba1 --- /dev/null +++ b/vendor/plugins/element/lib/element.rb @@ -0,0 +1,23 @@ +module ActiveRecord + class Base + module Element + def self.included(base) + base.extend(ClassMethods) + base.__send__ :include, InstanceMethods + end + + module ClassMethods + end + + module InstanceMethods + private + + public + + end + + end + include Element + end +end + diff --git a/vendor/plugins/item/init.rb b/vendor/plugins/item/init.rb new file mode 100644 index 00000000..e81018bd --- /dev/null +++ b/vendor/plugins/item/init.rb @@ -0,0 +1 @@ +require 'item' diff --git a/vendor/plugins/item/lib/item.rb b/vendor/plugins/item/lib/item.rb new file mode 100644 index 00000000..986bd827 --- /dev/null +++ b/vendor/plugins/item/lib/item.rb @@ -0,0 +1,160 @@ +module ActiveRecord + class Base + module Item + def self.included(base) + base.extend(ClassMethods) + base.__send__ :include, InstanceMethods + end + + module ClassMethods + # class_name + # table_name + + def singular + end + + def plural + end + + def item_name + end + + def path_name + end + + def self.default_page_size + 25 + end + + def self.max_page_size + 100 + end + + def self.page prm = nil + page = prm.to_i + page = 1 if page < 1 + page + end + + def self.page_size prm = self.default_page_size + page_size = prm.to_i + page_size = self.max_page_size if page_size > self.max_page_size + page_size = self.default_page_size if page_size < 1 + page_size + end + + def self.list_where + 'panels.publish > 0' + end + + def self.list page = 1, page_size = self.default_page_size + PanelPicture.where(self.list_where()).includes(PanelPicture.list_opt).order('panel_pictures.updated_at desc').offset((page -1) * page_size).limit(page_size) + end + + def self.list_paginate page = 1, page_size = self.default_page_size + Kaminari.paginate_array(Array.new(PanelPicture.where(self.list_where()).includes(PanelPicture.list_opt).count, nil)).page(page).per(page_size) + end + + def self.list_opt + {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}} } + end + + def self.list_json_opt + {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }} + end + + def self.show cid, au + opt = {} + opt.merge!(PanelPicture.show_opt) + res = PanelPicture.find(cid, opt) + raise ActiveRecord::Forbidden unless res.visible?(au) + res + end + + def self.show_opt + {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}} + end + + def self.show_json_opt + {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }} + end + + end + + module InstanceMethods + private + + public + + def item_name + end + + def item_id + self.new_record? ? '0' : self.id.to_s + end + + def tag_item_id c = nil + self.item_name + self.item_id + c.to_s + end + + def tag_item_field_id field_name + self.tag_item_id + field_name.to_s + end + + def path_name with_engine = false + self.class.path_name(with_engine) + end + + def form_template with_engine = false + self.path_name(with_engine) + '/form' + end + + def tag_item_attributes column = nil, opt = {} + { + :id => self.field_tag_id(column), :panel_id => self.tag_panel_id, + :element_id => self.tag_element_id, :element_type => self.tag_element_type + }.merge(opt) + end + + def field_tag_attributes column, no_attr, opt = {} + self.tag_attributes(column).merge( + {:column => column, :new_index => self.tag_new_index, :no_attr => no_attr} + ).merge(opt) + end + + #render element by body + def any_tag_attributes name = nil, opt = {} + r = self.tag_attributes(name) + r.merge!( + {:new_index => self.tag_new_index} + ) if self.new_index + r.merge(opt) + end + + def select_tag_attributes(selected, column, no_attr) + [ + :last, :first, + {:html => {:selected => selected}}, + self.field_tag_attributes(column, no_attr) + ] + end + + def tag_attr column = nil, opt = {} + self.tag_attributes(column, opt).to_attr + end + + def field_tag_attr column, no_attr, opt = {} + self.field_tag_attributes(column, no_attr, opt).to_attr + end + + def any_tag_attr name = nil, opt = {} + self.any_tag_attributes(name, opt).to_attr + end + + end + + end + include Item + end +end + -- 2.11.0