Giter Site home page Giter Site logo

spreeja's Introduction

Spree for Japanese

Japanese-localized Spree template.

Installation

git clone this
cd spreeja
bundle install
bundle exec rake db:migrate
bundle exec rake db:seed

How to update

Assets (Image, CSS, JavaScript)

vendor/assets/を修正

View (Only HTML)

HTMLで全部上書き

Spree の本家コードから修正したいviewの場所を特定。

例えばfrontend/app/views/spree/shared/_header.html.erb を編集したい場合、app/views/spree/shared/_header.html.erbを作成し、編集する。

ただし、このやり方は Spree を常に最新にする場合に古いままのHTMLが使われ続けた状態になってしまうのが問題。

Deface で追加

app/overrides 以下に Ruby ファイルを追加。こんな感じで書ける

replace_header_logo.rb

Deface::Override.new(:virtual_path => 'spree/shared/_header',
  :name => 'replace_header_logo',
  :replace_contents => "#logo",   
  :text => "
    <%= image_path 'logo.png', :alt => 'Logo' %>
  ")

Controller

class_evalでデコレートすることで既存コントローラに追加する。

app/controllers/spree/home_controller_decorator.rbを作成

module Spree
  HomeController.class_eval do
    respond_override :index => { :html =>
      { :success => lambda { render 'shared/some_file' } } }

    def sale
      @products = Product.joins(:variants_including_master).where('spree_variants.sale_price is not null').uniq
    end
  end
end

respond_override は既存のアクションの表示を変えたい時に利用。 sale は新規ページ。config/routes にルーティング設定が必要

Model

Migration が必要なレベルの開発は、 Spree エクステンションとして開発すべき。

既存のモデル機能拡張には Decorator を用いる。

Papp/models/spree/product_decorator.rb

module Spree
  Product.class_eval do
    alias_method :orig_price_in, :price_in
    def price_in(currency)
      return orig_price_in(currency) unless sale_price.present?
      Spree::Price.new(:variant_id => self.id, :amount => self.sale_price, :currency => currency)
    end
  end
end

メソッドを別名定義しつつ、機能拡張したメソッドで定義元メソッドを呼び出す。

特集ページ

admin設定の特集ページより

  • STORESの項目のみチェック
  • header へ表示も使える

AWS(S3)

export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export AWS_S3_BUCKET=

Email

設定のメール設定.Gmail で送ってみたい場合

  • smtp.gmail.com
  • smtp.gmail.com
  • 587
  • TLS
  • plain
  • gmail address
  • gmail password

TODO

  • Deploy issue (Heroku & SSL)
  • 特商法関連の精査

Memo

Spree Contrib で 3-0-stable ブランチが出るの待ち

spreeja's People

Contributors

honkimi avatar

Watchers

James Cloos avatar hotuta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.