comable_core 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 479954f8dc99bd292299c33a2165b403f97a6aa8
4
- data.tar.gz: 045371d05a4e0dce724bbe1aff1881dac6577fc2
3
+ metadata.gz: 27c718d8e2e2faf373aed914672a299e0a7e12ee
4
+ data.tar.gz: 28e127acba3cd8d68afc95499c4fcbc25d8fd70c
5
5
  SHA512:
6
- metadata.gz: 01192b146f265c2e1012c10ad41f6abd3a8ee6700884a5c2797a304d44e300b7fa78245ebe76e8ec9d34cd8998acf538735db8d8df76fb741245eb619d6d406b
7
- data.tar.gz: f0eb496dd837e94dcc6740628fa5e7b33d573d26e37506c99e7798e23621c955864ae21ac76f18f3e0b77139e4e8bbdc7c81a9f2bd407913b1a4fdbc1e5f2e9d
6
+ metadata.gz: e8906c5656b2c1669bb587b92586d1563d3639f62858a9944ba7ae67c0f0c06bdc8d3d5448aebf02503b2b3a7011157a86a7bcf9f9b83681cc2129938ad2ee61
7
+ data.tar.gz: 02757921e5d6a64da82ecc8769c80519b6d28733a230747f1ba8b7224e5e0c3c7e29d0e703bcb1e0a03212bd958bbe4a5705ee034fd98bb8f124a63ebc5e2ead
@@ -48,6 +48,17 @@ module Comable
48
48
  string.respond_to?(:html_safe) ? string.html_safe : string
49
49
  end
50
50
 
51
+ # To use the functionality of liquid-rails
52
+ def liquid_assigns
53
+ view_context.assigns.merge(
54
+ current_store: current_store,
55
+ current_comable_user: current_comable_user,
56
+ current_order: current_order,
57
+ current_trackers: current_trackers,
58
+ form_authenticity_token: form_authenticity_token
59
+ ).stringify_keys
60
+ end
61
+
51
62
  private
52
63
 
53
64
  def after_sign_in_path_for(_resource)
@@ -1,9 +1,13 @@
1
1
  module Comable
2
2
  class Image < ActiveRecord::Base
3
+ include Comable::Liquidable
4
+
3
5
  mount_uploader :file, ImageUploader
4
6
 
5
7
  belongs_to :product, class_name: Comable::Product.name
6
8
 
9
+ liquid_methods :url
10
+
7
11
  delegate :url, to: :file, allow_nil: true
8
12
  delegate :current_path, to: :file, allow_nil: true
9
13
  delegate :identifier, to: :file, allow_nil: true
@@ -8,6 +8,7 @@ module Comable
8
8
  class Order < ActiveRecord::Base
9
9
  include Comable::Checkout
10
10
  include Comable::Ransackable
11
+ include Comable::Liquidable
11
12
  include Comable::Order::Associations
12
13
  include Comable::Order::Callbacks
13
14
  include Comable::Order::Scopes
@@ -16,7 +17,7 @@ module Comable
16
17
 
17
18
  ransack_options attribute_select: { associations: [:payment, :shipment] }, ransackable_attributes: { except: [:bill_address_id, :ship_address_id] }
18
19
 
19
- liquid_methods :code, :payment_fee, :shipment_fee, :item_total_price, :total_price
20
+ liquid_methods :code, :payment_fee, :shipment_fee, :item_total_price, :total_price, :order_items
20
21
 
21
22
  delegate :full_name, to: :bill_address, allow_nil: true, prefix: :bill
22
23
  delegate :full_name, to: :ship_address, allow_nil: true, prefix: :ship
@@ -2,6 +2,7 @@ module Comable
2
2
  class OrderItem < ActiveRecord::Base
3
3
  include Comable::SkuItem
4
4
  include Comable::SkuChoice
5
+ include Comable::Liquidable
5
6
  include Comable::OrderItem::Csvable
6
7
 
7
8
  belongs_to :stock, class_name: Comable::Stock.name, autosave: true
@@ -0,0 +1,30 @@
1
+ module Comable
2
+ class Page < ActiveRecord::Base
3
+ include Comable::Ransackable
4
+
5
+ extend FriendlyId
6
+ friendly_id :title, use: :slugged
7
+
8
+ validates :title, length: { maximum: 255 }, presence: true
9
+ validates :content, presence: true
10
+ validates :page_title, length: { maximum: 255 }
11
+ validates :meta_description, length: { maximum: 255 }
12
+ validates :meta_keywords, length: { maximum: 255 }
13
+ validates :slug, length: { maximum: 255 }, presence: true, uniqueness: true
14
+
15
+ PREVIEW_SESSION_KEY = :preview_page
16
+
17
+ def published?
18
+ published_at.present? && published_at <= Time.now
19
+ end
20
+
21
+ def default_slug
22
+ id ||= self.class.maximum(:id).next
23
+ "pages_#{id}"
24
+ end
25
+
26
+ def normalize_slug(string)
27
+ normalize_friendly_id(string).presence || default_slug
28
+ end
29
+ end
30
+ end
@@ -2,6 +2,7 @@ module Comable
2
2
  class Product < ActiveRecord::Base
3
3
  include Comable::SkuItem
4
4
  include Comable::Ransackable
5
+ include Comable::Liquidable
5
6
  include Comable::Product::Search
6
7
  include Comable::Product::Csvable
7
8
 
@@ -17,6 +18,8 @@ module Comable
17
18
  validates :sku_h_item_name, length: { maximum: 255 }
18
19
  validates :sku_v_item_name, length: { maximum: 255 }
19
20
 
21
+ liquid_methods :id, :code, :name, :price, :images, :image_url
22
+
20
23
  ransack_options attribute_select: { associations: :stocks }
21
24
 
22
25
  # Add conditions for the images association.
@@ -7,6 +7,7 @@ module Comable
7
7
  include Comable::SkuItem
8
8
  include Comable::SkuChoice
9
9
  include Comable::Ransackable
10
+ include Comable::Liquidable
10
11
  include Comable::Stock::Csvable
11
12
 
12
13
  belongs_to :product, class_name: Comable::Product.name
@@ -1,10 +1,18 @@
1
1
  module Comable
2
2
  class Store < ActiveRecord::Base
3
+ include Comable::Liquidable
4
+
5
+ belongs_to :theme, class_name: Comable::Theme.name
6
+
3
7
  validates :name, length: { maximum: 255 }
4
8
  validates :meta_keywords, length: { maximum: 255 }
5
9
  validates :meta_description, length: { maximum: 255 }
6
10
  validates :email, length: { maximum: 255 }
7
11
 
12
+ liquid_methods :name, :meta_keywords, :meta_description, :email
13
+
14
+ delegate :name, to: :theme, prefix: true, allow_nil: true
15
+
8
16
  class << self
9
17
  def instance
10
18
  first || new(name: default_name)
@@ -0,0 +1,25 @@
1
+ module Comable
2
+ class Theme < ActiveRecord::Base
3
+ has_one :store, class_name: Comable::Store.name
4
+
5
+ validates :name, uniqueness: { scope: :version }
6
+ validates :name, presence: true, length: { maximum: 255 }
7
+ validates :version, presence: true, length: { maximum: 255 }
8
+ validates :display, length: { maximum: 255 }
9
+ validates :description, length: { maximum: 255 }
10
+ validates :homepage, length: { maximum: 255 }
11
+ validates :author, length: { maximum: 255 }
12
+
13
+ def default_version
14
+ '0.1.0'
15
+ end
16
+
17
+ def to_param
18
+ name
19
+ end
20
+
21
+ def display_name
22
+ display.presence || name
23
+ end
24
+ end
25
+ end
@@ -3,6 +3,7 @@ module Comable
3
3
  include Comable::CartOwner
4
4
  include Comable::RoleOwner
5
5
  include Comable::Ransackable
6
+ include Comable::Liquidable
6
7
 
7
8
  has_many :orders, class_name: Comable::Order.name
8
9
  has_many :addresses, class_name: Comable::Address.name, dependent: :destroy
@@ -23,6 +24,8 @@ module Comable
23
24
 
24
25
  ransack_options ransackable_attributes: { except: [:encrypted_password, :reset_password_token, :reset_password_sent_at, :remember_created_at, :bill_address_id, :ship_address_id] }
25
26
 
27
+ liquid_methods :email, :bill_full_name, :ship_full_name, :cart
28
+
26
29
  delegate :full_name, to: :bill_address, allow_nil: true, prefix: :bill
27
30
  delegate :full_name, to: :ship_address, allow_nil: true, prefix: :ship
28
31
 
@@ -0,0 +1,12 @@
1
+ module Comable
2
+ module Liquidable
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ # from: http://www.codedisqus.com/0SHjkUjjgW/how-can-i-expose-all-available-liquid-methods-for-a-model.html
7
+ def available_liquid_methods
8
+ self::LiquidDropClass.public_instance_methods - Liquid::Drop.public_instance_methods
9
+ end
10
+ end
11
+ end
12
+ end
@@ -109,11 +109,13 @@ en:
109
109
  back_to_store: 'Back to Store'
110
110
  confirmation_to_remove_product: 'This operation cannot be undone. Would you like to proceed?'
111
111
  confirmation_to_remove_stock: 'This operation cannot be undone. Would you like to proceed?'
112
+ confirmation_to_remove_page: 'This operation cannot be undone. Would you like to proceed?'
112
113
  you_can_drag_and_drop: 'Edit the category tree by drag-and-drop.'
113
114
  you_can_right_click: 'Open the context menu by right click.'
114
115
  link_to_add_new_node: 'Add a new category from the following link: '
115
116
  link_to_add_new_stock: 'Add a new stock from the following link: '
116
117
  check_this_product_in_frontend: 'Check this product in Store'
118
+ preview: 'preview'
117
119
  note: 'NOTE:'
118
120
  results: 'results'
119
121
  times: 'times'
@@ -152,20 +154,32 @@ en:
152
154
  list_of_usable_variables: 'Available variables are as follows.'
153
155
  mote_infomation_for_syntax: 'For more information about the syntax please refer to the following page:'
154
156
  help_of_store_email: 'This field will be used as sender of mail that send to customers. The mail will not be sent when the field is empty.'
157
+ files: 'Files'
158
+ use_this_theme: 'Use this theme'
159
+ available_assigns: 'Available assigns'
160
+ available_assigns_in_all_pages: 'Available assigns in all pages'
161
+ available_filters: 'Available filters'
162
+ about_sintax: 'About sintax'
163
+ please_see_following_page_for_syntax: 'Please see the following page for the syntax:'
164
+ please_select_file_form_directory_tree_to_edit: 'Please select a file form the directory tree to edit.'
165
+ here_editor_will_be_displayed_and_you_can_edit_file: 'Here the editor will be displayed, you can edit file.'
155
166
  nav:
156
167
  dashboard: 'Dashboard'
157
168
  order: 'Orders'
158
169
  product: 'Products'
159
170
  stock: 'Stocks'
160
171
  category: 'Categories'
172
+ page: 'Pages'
161
173
  user: 'Users'
162
174
  general_settings: 'General settings'
163
175
  store: 'Store'
164
176
  shipment_method: 'Shipment methods'
165
177
  payment_method: 'Payment methods'
166
178
  tracker: 'Tracker'
179
+ theme: 'Theme'
167
180
  products:
168
181
  detail: 'Product details'
182
+ list: 'Product list'
169
183
  orders:
170
184
  detail: 'Order details'
171
185
  cart: 'Cart infomation'
@@ -176,6 +190,12 @@ en:
176
190
  detail: 'User details'
177
191
  edit: 'Editing user'
178
192
  new_orders: 'Recently orders (%{count})'
193
+ pages:
194
+ general: 'General'
195
+ seo: 'SEO'
196
+ visibility: 'publishing/closed'
197
+ published: 'Published'
198
+ unpublished: 'Unpublished'
179
199
  stores:
180
200
  edit: 'Editing store'
181
201
  shipment_methods:
@@ -190,6 +210,7 @@ en:
190
210
  destroy: 'Destroy'
191
211
  save: 'Save'
192
212
  cancel: 'Cancel'
213
+ property: 'property'
193
214
  categories:
194
215
  new_node: 'New category'
195
216
 
@@ -364,7 +385,18 @@ en:
364
385
  state: 'Status'
365
386
  tracking_number: 'Tracking number'
366
387
  completed_at: 'Completed at'
367
-
388
+ comable/page:
389
+ id: 'ID'
390
+ title: 'Title'
391
+ content: 'Content'
392
+ seo: 'SEO'
393
+ page_title: 'PageTitle'
394
+ meta_description: 'Meta Description'
395
+ meta_keywords: 'Meta Keywords'
396
+ slug: 'Slug'
397
+ published_at: 'Published at'
398
+ created_at: 'Created at'
399
+ updated_at: 'Updated at'
368
400
  enumerize:
369
401
  comable/user:
370
402
  role:
@@ -109,11 +109,13 @@ ja:
109
109
  back_to_store: ストアに戻る
110
110
  confirmation_to_remove_product: この操作は元に戻せません。商品を削除してもよろしいですか?
111
111
  confirmation_to_remove_stock: この操作は元に戻せません。在庫を削除してもよろしいですか?
112
+ confirmation_to_remove_page: この操作は元に戻せません。ページを削除してもよろしいですか?
112
113
  you_can_drag_and_drop: ドラッグ&ドロップの操作でツリーを編集できます。
113
114
  you_can_right_click: 右クリックでメニューを表示できます。
114
115
  link_to_add_new_node: '次のリンクから新しいカテゴリを追加できます: '
115
116
  link_to_add_new_stock: '次のリンクから新しい在庫を追加できます: '
116
117
  check_this_product_in_frontend: 'この商品をフロントで確認する'
118
+ preview: プレビュー
117
119
  note: 'NOTE:'
118
120
  results: 件
119
121
  times: 回
@@ -152,20 +154,32 @@ ja:
152
154
  list_of_usable_variables: '利用可能な変数は次の通りです。'
153
155
  mote_infomation_for_syntax: '構文についての詳しい情報は次のページをご覧ください:'
154
156
  help_of_store_email: 'この項目は顧客に送信するメールの送信元として利用されます。未入力の場合はメールが送信されません。'
157
+ files: 'ファイル一覧'
158
+ use_this_theme: 'このテーマを使う'
159
+ available_assigns: '利用可能な変数'
160
+ available_assigns_in_all_pages: 'すべてのページで利用可能な変数'
161
+ available_filters: '利用可能なフィルター'
162
+ about_sintax: '構文について'
163
+ please_see_following_page_for_syntax: '構文については次のページを参照してください:'
164
+ please_select_file_form_directory_tree_to_edit: 'ディレクトリーツリーから編集したいファイルを選択してください。'
165
+ here_editor_will_be_displayed_and_you_can_edit_file: 'ここにエディタが表示されてファイルの内容を編集できます。'
155
166
  nav:
156
167
  dashboard: ダッシュボード
157
168
  order: 注文管理
158
169
  product: 商品管理
159
170
  stock: 在庫管理
160
171
  category: カテゴリ
172
+ page: ページ
161
173
  user: ユーザー
162
174
  general_settings: 一般設定
163
175
  store: ストア設定
164
176
  shipment_method: 発送管理
165
177
  payment_method: 決済管理
166
178
  tracker: トラッキング情報
179
+ theme: 'テーマ'
167
180
  products:
168
181
  detail: 商品詳細
182
+ list: '商品一覧'
169
183
  orders:
170
184
  detail: 注文明細
171
185
  cart: カート情報
@@ -176,6 +190,12 @@ ja:
176
190
  detail: ユーザー詳細
177
191
  edit: 編集
178
192
  new_orders: '最新の注文 (%{count}件)'
193
+ pages:
194
+ general: 一般
195
+ seo: SEO
196
+ visibility: 公開/非公開
197
+ published: 公開
198
+ unpublished: 非公開
179
199
  stores:
180
200
  edit: 編集
181
201
  shipment_methods:
@@ -190,6 +210,7 @@ ja:
190
210
  destroy: 削除する
191
211
  save: 保存する
192
212
  cancel: キャンセル
213
+ property: 'プロパティ'
193
214
  categories:
194
215
  new_node: 新しいカテゴリ
195
216
 
@@ -364,6 +385,18 @@ ja:
364
385
  state: 'ステータス'
365
386
  tracking_number: 'トラッキング番号'
366
387
  completed_at: '発送日時'
388
+ comable/page:
389
+ id: ID
390
+ title: タイトル
391
+ content: 内容
392
+ seo: 検索対策
393
+ page_title: ページタイトル
394
+ meta_description: メタディスクリプション
395
+ meta_keywords: メタキーワード
396
+ slug: スラッグ
397
+ published_at: 公開日
398
+ created_at: 作成日
399
+ updated_at: 更新日
367
400
 
368
401
  enumerize:
369
402
  comable/user:
@@ -0,0 +1,17 @@
1
+ class CreateComablePages < ActiveRecord::Migration
2
+ def change
3
+ create_table :comable_pages do |t|
4
+ t.string :title, null: false
5
+ t.text :content, null: false
6
+ t.string :page_title
7
+ t.string :meta_description
8
+ t.string :meta_keywords
9
+ t.string :slug, null: false
10
+ t.datetime :published_at
11
+
12
+ t.timestamps null: false
13
+ end
14
+
15
+ add_index :comable_pages, :slug, unique: true
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ class CreateComableThemes < ActiveRecord::Migration
2
+ def change
3
+ create_table :comable_themes do |t|
4
+ t.string :name, null: false
5
+ t.string :version, null: false
6
+ t.string :display
7
+ t.string :description
8
+ t.string :homepage
9
+ t.string :author
10
+ t.timestamps null: false
11
+ end
12
+
13
+ add_index :comable_themes, [:name, :version], unique: true
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ class AddThemeIdToComableStores < ActiveRecord::Migration
2
+ def change
3
+ change_table :comable_stores do |t|
4
+ t.references :theme
5
+ end
6
+ end
7
+ end
@@ -9,6 +9,8 @@ require 'comma'
9
9
  require 'axlsx_rails'
10
10
  require 'roo'
11
11
  require 'liquid'
12
+ require 'liquid-rails'
13
+ require 'friendly_id'
12
14
 
13
15
  require 'comable/core/configuration'
14
16
  require 'comable/core/engine'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comable_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YOSHIDA Hiroki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-01 00:00:00.000000000 Z
11
+ date: 2015-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -198,6 +198,40 @@ dependencies:
198
198
  - - "~>"
199
199
  - !ruby/object:Gem::Version
200
200
  version: 3.0.2
201
+ - !ruby/object:Gem::Dependency
202
+ name: liquid-rails
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - "~>"
206
+ - !ruby/object:Gem::Version
207
+ version: 0.1.2
208
+ type: :runtime
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: 0.1.2
215
+ - !ruby/object:Gem::Dependency
216
+ name: friendly_id
217
+ requirement: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: 4.0.10
222
+ - - "<"
223
+ - !ruby/object:Gem::Version
224
+ version: '6'
225
+ type: :runtime
226
+ prerelease: false
227
+ version_requirements: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - ">="
230
+ - !ruby/object:Gem::Version
231
+ version: 4.0.10
232
+ - - "<"
233
+ - !ruby/object:Gem::Version
234
+ version: '6'
201
235
  description: Provide core functions for Comable.
202
236
  email:
203
237
  - hyoshida@appirits.com
@@ -225,6 +259,7 @@ files:
225
259
  - app/models/comable/order/validations.rb
226
260
  - app/models/comable/order_item.rb
227
261
  - app/models/comable/order_item/csvable.rb
262
+ - app/models/comable/page.rb
228
263
  - app/models/comable/payment.rb
229
264
  - app/models/comable/payment_method.rb
230
265
  - app/models/comable/product.rb
@@ -234,11 +269,13 @@ files:
234
269
  - app/models/comable/stock.rb
235
270
  - app/models/comable/stock/csvable.rb
236
271
  - app/models/comable/store.rb
272
+ - app/models/comable/theme.rb
237
273
  - app/models/comable/tracker.rb
238
274
  - app/models/comable/user.rb
239
275
  - app/models/concerns/comable/cart_owner.rb
240
276
  - app/models/concerns/comable/checkout.rb
241
277
  - app/models/concerns/comable/importable.rb
278
+ - app/models/concerns/comable/liquidable.rb
242
279
  - app/models/concerns/comable/product/search.rb
243
280
  - app/models/concerns/comable/ransackable.rb
244
281
  - app/models/concerns/comable/role_owner.rb
@@ -264,6 +301,9 @@ files:
264
301
  - db/migrate/20150423095210_create_comable_shipments.rb
265
302
  - db/migrate/20150511171940_create_comable_payments.rb
266
303
  - db/migrate/20150513185230_create_comable_trackers.rb
304
+ - db/migrate/20150519080729_create_comable_pages.rb
305
+ - db/migrate/20150612143226_create_comable_themes.rb
306
+ - db/migrate/20150612143445_add_theme_id_to_comable_stores.rb
267
307
  - db/seeds.rb
268
308
  - db/seeds/comable/users.rb
269
309
  - lib/comable/core/configuration.rb