tag:crieit.net,2005:https://crieit.net/users/kuronekopunk/feed あっきー💃の投稿 - Crieit Crieitでユーザーあっきー💃による最近の投稿 2020-09-20T19:59:51+09:00 https://crieit.net/users/kuronekopunk/feed tag:crieit.net,2005:PublicArticle/16065 2020-09-20T19:59:37+09:00 2020-09-20T19:59:51+09:00 https://crieit.net/posts/Windows-WSL-Ubuntu-GoogleChrome Windows WSLのUbuntuにGoogleChromeをインストールする <p>Railsで開発をしていてRspecでChromeDriverでのテストを利用しているためChromeが必要になったのでインストール</p> <pre><code class="bash">sudo apt-get update # 必要なライブラリのインストール sudo apt-get install libappindicator1 libappindicator3-1 fonts-liberation # 最新安定版のDL、インストール curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb sudo dpkg -i google-chrome-stable_current_amd64.deb # ここでパッケージの依存関係で怒られたので依存関係の解消 sudo apt --fix-broken install # 再度インストールを試した sudo dpkg -i google-chrome-stable_current_amd64.deb # インストールされていることの確認 google-chrome --version </code></pre> <h1 id="参考"><a href="#%E5%8F%82%E8%80%83">参考</a></h1> <ul> <li><a target="_blank" rel="nofollow noopener" href="https://loumo.jp/archives/19801">WSL Ubuntu 18.04 に Headless Chrome を入れて Ruby で操作する | Lonely Mobiler</a></li> <li><a target="_blank" rel="nofollow noopener" href="https://qiita.com/ma-tsu-ba-ra/items/25e404387d1726d21cc9#wslでもheadless-chromeを使ってみよう">WindowsとWSLでHeadless Chromeを使ってみよう! - Qiita</a></li> </ul> あっきー💃 tag:crieit.net,2005:PublicArticle/15885 2020-05-01T22:32:30+09:00 2020-05-01T22:32:30+09:00 https://crieit.net/posts/Rails Railsでモーダルの出し分けを管理する <p>Railsでモーダルの表示処理をまとめて衝突しないように管理する方法を紹介します。</p> <h1 id="背景"><a href="#%E8%83%8C%E6%99%AF">背景</a></h1> <p><a target="_blank" rel="nofollow noopener" href="https://tsukulink.net/">ツクリンク</a>を運営する中でモーダルが少しづつ増え、衝突することがあったためモーダルの優先順位を付け、衝突しないよう実装をしました。</p> <h1 id="実装"><a href="#%E5%AE%9F%E8%A3%85">実装</a></h1> <h2 id="前提"><a href="#%E5%89%8D%E6%8F%90">前提</a></h2> <p>以下の3つのモーダルがあるとします。</p> <ul> <li>A: 初回ログインで出すモーダル(全ページ)</li> <li>B: 特定のユーザーにだけお知らせを出すモーダル(全ページ)</li> <li>C: 特定のページで出すモーダル(Posts#show)</li> </ul> <h2 id="コードサンプル"><a href="#%E3%82%B3%E3%83%BC%E3%83%89%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB">コードサンプル</a></h2> <p>全ページに出すモーダルはApplicationControllerで該当ユーザーか判断しモーダルに必要な情報をセットします。</p> <pre><code class="ruby"># controllers/application_controller.rb class ApplicationController < ActionController::Base before_action :set_modal_A before_action :set_modal_B def set_modal_A return if cookies['modal_A'].present? # 表示済みなら何もしない if is_first_signed_in? # 初回ログインか? @modal_A = { title: '表示に必要な情報など' } end end def set_modal_B return if cookies['modal_B'].present? # 表示済みなら何もしない if show_notice? # お知らせを出すユーザーか? @modal_B = true end end end </code></pre> <p>Viewごとに出るモーダルは <code>provide</code> でモーダルをセット</p> <pre><code class="ruby"># views/posts/show.html.erb <% provide :modal, render('modal/C') %> </code></pre> <p>レイアウトのView(もしくはそれに準ずるパーシャル)でモーダルの出し分けを行います。<br /> ifの上位にあるものが優先され、モーダルが複数renderされるのを防いでいます。</p> <pre><code class="ruby"># views/layouts/application.html.erb <% if yield(:modal).present? %> <%= yield(:modal) %> <% elsif @modal_B.present? %> <%= render 'modal/B' %> <% elsif @modal_A.present? %> <%= render 'modal/A' %> <% end %> </code></pre> <p>各モーダルのViewでは表示を管理するCookieを保存するなどの処理をしています。</p> <pre><code class="ruby"># views/modal/A.html.erb <% cookies.permanent['modal_A'] = { value: true, expires: 1.day } %> <div class="modal">お知らせだよ!</div> </code></pre> あっきー💃 tag:crieit.net,2005:PublicArticle/15155 2019-06-23T17:06:57+09:00 2019-06-23T17:10:40+09:00 https://crieit.net/posts/7cd9ab785e8538bbd0ea7bed7c70d69e インスタグラムのブログパーツを作った📷 <h1 id="作ったもの"><a href="#%E4%BD%9C%E3%81%A3%E3%81%9F%E3%82%82%E3%81%AE">作ったもの</a></h1> <p><a target="_blank" rel="nofollow noopener" href="https://insta-window-tool.web.app/">Insta Window Tool</a></p> <p>こんな感じでインスタの写真をサイトに貼り付けられます。</p> <p><a href="https://crieit.now.sh/upload_images/b8f32a7ff24dbbdad55883ff65403fdb5d0f31171640c.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/b8f32a7ff24dbbdad55883ff65403fdb5d0f31171640c.png?mw=700" width="50%"></a></p> <h1 id="作った背景"><a href="#%E4%BD%9C%E3%81%A3%E3%81%9F%E8%83%8C%E6%99%AF">作った背景</a></h1> <p>インスタグラムの写真をサイトに貼る必要があったので調べたところ、ブログパーツは既にあったのですがブログパーツのサイトにリンクしてしまう残念仕様だったので自作しました。</p> <h1 id="技術スタック"><a href="#%E6%8A%80%E8%A1%93%E3%82%B9%E3%82%BF%E3%83%83%E3%82%AF">技術スタック</a></h1> <ul> <li>VueJs</li> <li>FirebaseHosting</li> <li>UIKit</li> </ul> <p>くらいかな?</p> <h1 id="今後の予定"><a href="#%E4%BB%8A%E5%BE%8C%E3%81%AE%E4%BA%88%E5%AE%9A">今後の予定</a></h1> <p>ブログパーツのサイズや色など設定できるようにしていくつもりです(いつか)</p> <p>突貫で作ったものなのでキレイにしてくれたり機能追加してくれる方募集中です😉<br /> <a target="_blank" rel="nofollow noopener" href="https://github.com/akinov/insta_window">https://github.com/akinov/insta_window</a></p> <p>なにかあれば<a target="_blank" rel="nofollow noopener" href="https://twitter.com/kuronekopunk">@kuronekopunk</a>へ💁‍♀️</p> あっきー💃