Skip to content

Instantly share code, notes, and snippets.

@y-yagi
Last active September 20, 2018 02:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save y-yagi/d166b23a5f652c7826d9c47f3a49b858 to your computer and use it in GitHub Desktop.
Save y-yagi/d166b23a5f652c7826d9c47f3a49b858 to your computer and use it in GitHub Desktop.
Ginzarb 63

Dev.to

とは

セットアップ

Stack

  • black_box
    • BlackBox クラスがある
      • scoreの計算をしている
    • 後はGoogleAnalytic用クラス
  • controllers
    • 普通にRailsのcontroller
    • ちょっと長い、なと思う処理もあるものの、全体的に普通な印象
  • dashboards
    • administrate(管理画面用gem)用のクラス群
  • decorators
    • Drapper
  • fields
    • これもadministrate(管理画面用gem)用のクラス群。Dashboardで使用する。
  • helpers
    • 普通にRailsのhelper
  • javascript
    • これは別で
  • labor
    • ARを継承していないRubyのクラス群
    • ビジネスロジックをここに集約している印象
  • lib
    • acts-as-taggable-onやredcarpetなどの、ライブラリを拡張したコードの置き場
  • liquid_tags
    • liquidで使う用のTagクラス
    • 記事を書く際にLiquid Tagsが使えるようになっており、その独自拡張の為のクラス
  • mailers
    • 普通にRailsのmailer
  • models
    • 普通なRailsのmodel
    • 基本的にはActiveRecord::Baseの子クラスのみ置いており、プレーンなRubyのclassはここには無い
      • email_message.rbやtag.rbのような例外もあり
  • observers
  • policies
    • 認可にpunditを使っており、そちらで使用する為のclass
  • sanitizers
    • rails/rails-html-sanitizerを拡張した独自のsanitizer
    • Markdown用
      • codeblock用のvaliation処理を独自に行っている
  • services
    • 素のRubyのclass
    • publicメソッドが複数ある
  • uploaders
  • views
    • erb
    • jbuilderを使っており、API用のviewもこの配下にある
    • app/views/layouts/_styles.html.erb
      • (なみだぐましい)
      • CSSをHTMLの中に直接埋め込むよう

bin

  • 特にコメントなし

config

environments

  • 特にコメントなし

initializers

routes.rb

lib

  • 特にコメントなし

Gemfile

front

css

  • layouts/application.html.erb でrender "layouts/styles"
  • _styles.html.erbでは生成したcssをcacheして、viewのrenderが行われないようにしている

JS

  • app/assets/javascripts/initializePage.js.erb で初期化諸々
  • bodyのdata属性にユーザ情報を埋め込んでいるが、これを非同期にやるようにしている
    • CDNにcacheさせるHTMLにユーザ情報が入らないようにしている
  • ユーザデータはlocalStorageにもcacheするようにしてい、そちらからデータが取得出来る場合はそちらの値を使用している

ServiceWorker

  • app/assets/javascripts/serviceworker.js.erb
  • install時に最低限必要なassetsをcache
  • オフラインで使えるようにしている
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment