From 6c1b0c11810eaaa4b1053c9f5ff5d44739532f50 Mon Sep 17 00:00:00 2001 From: nishitatsu-dev Date: Fri, 29 Mar 2024 10:14:23 +0900 Subject: [PATCH 1/4] =?UTF-8?q?Vue=E3=81=8B=E3=82=89HTML=E3=81=AB=E7=A7=BB?= =?UTF-8?q?=E8=A1=8C=EF=BC=88=E3=83=A1=E3=83=A2=E3=81=82=E3=82=8A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 途中保存。テスト未確認、Vueコンポーネント削除前。 途中保存(書き方修正) 途中保存(vueファイル削除。他コメント) VueからHTMLに移行(メモあり) --- .../api/external_entries_controller.rb | 4 +- .../external_entries_controller.rb | 4 +- .../components/external-entries.vue | 90 ------------------- app/javascript/components/external-entry.vue | 55 ------------ app/javascript/packs/application.js | 2 - app/models/external_entry.rb | 1 + .../_external_entry.json.jbuilder | 2 + .../api/external_entries/index.json.jbuilder | 7 +- .../_external_entries.html.slim | 7 ++ .../_external_entry.html.slim | 22 +++++ app/views/external_entries/index.html.slim | 2 +- 11 files changed, 43 insertions(+), 153 deletions(-) delete mode 100644 app/javascript/components/external-entries.vue delete mode 100644 app/javascript/components/external-entry.vue create mode 100644 app/views/external_entries/_external_entries.html.slim create mode 100644 app/views/external_entries/_external_entry.html.slim diff --git a/app/controllers/api/external_entries_controller.rb b/app/controllers/api/external_entries_controller.rb index 1b79c6d7c68..34d4864dc82 100644 --- a/app/controllers/api/external_entries_controller.rb +++ b/app/controllers/api/external_entries_controller.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true class API::ExternalEntriesController < API::BaseController - def index - @external_entries = ExternalEntry.all.order(published_at: :desc).page(params[:page]) - end + def index; end end diff --git a/app/controllers/external_entries_controller.rb b/app/controllers/external_entries_controller.rb index f0f8d3ce119..04c6e94f1d6 100644 --- a/app/controllers/external_entries_controller.rb +++ b/app/controllers/external_entries_controller.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true class ExternalEntriesController < ApplicationController - def index; end + def index + @external_entries = ExternalEntry.with_avatar.order(published_at: :desc).page(params[:page]) + end end diff --git a/app/javascript/components/external-entries.vue b/app/javascript/components/external-entries.vue deleted file mode 100644 index 182e99068b0..00000000000 --- a/app/javascript/components/external-entries.vue +++ /dev/null @@ -1,90 +0,0 @@ - - - diff --git a/app/javascript/components/external-entry.vue b/app/javascript/components/external-entry.vue deleted file mode 100644 index c279f0c84cc..00000000000 --- a/app/javascript/components/external-entry.vue +++ /dev/null @@ -1,55 +0,0 @@ - - - diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 461978aaad2..b12e535b011 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -60,7 +60,6 @@ import '../invitation-url-updater.js' import VueMounter from '../VueMounter.js' import Books from '../components/books.vue' -import ExternalEntries from '../components/external-entries.vue' import Questions from '../components/questions.vue' import WorriedUsers from '../components/worried-users.vue' import UsersAnswers from '../components/users-answers.vue' @@ -79,7 +78,6 @@ import '../stylesheets/application' const mounter = new VueMounter() mounter.addComponent(Books) -mounter.addComponent(ExternalEntries) mounter.addComponent(Questions) mounter.addComponent(WorriedUsers) mounter.addComponent(UsersAnswers) diff --git a/app/models/external_entry.rb b/app/models/external_entry.rb index 9c5addefa3b..58ca13ede0b 100644 --- a/app/models/external_entry.rb +++ b/app/models/external_entry.rb @@ -2,6 +2,7 @@ class ExternalEntry < ApplicationRecord include ActionView::Helpers::AssetUrlHelper + include WithAvatar belongs_to :user diff --git a/app/views/api/external_entries/_external_entry.json.jbuilder b/app/views/api/external_entries/_external_entry.json.jbuilder index 17afa8d4396..a08bab5e017 100644 --- a/app/views/api/external_entries/_external_entry.json.jbuilder +++ b/app/views/api/external_entries/_external_entry.json.jbuilder @@ -4,3 +4,5 @@ json.thumbnailUrl external_entry.thumbnail_url json.user do json.partial! 'api/users/user', user: external_entry.user end + +# にしたつ#TODO - このファイルは残しておく(参考:プルリク #7447) diff --git a/app/views/api/external_entries/index.json.jbuilder b/app/views/api/external_entries/index.json.jbuilder index 4bf0e9c2760..4de947fc2d7 100644 --- a/app/views/api/external_entries/index.json.jbuilder +++ b/app/views/api/external_entries/index.json.jbuilder @@ -1,2 +1,7 @@ json.external_entries @external_entries, partial: 'api/external_entries/external_entry', as: :external_entry -json.total_pages @external_entries.total_pages +# json.total_pages @external_entries.total_pages +# 「プルリク #7447」と同様に、/api/external_entries_controller.rb でインスタンス変数を消した場合、 +# http://localhost:3000/api/external_entries.json に接続した時に、上記のコメントアウト行でエラーが出る +# エラーを回避するには「行を削除」か「/api/talks/index.json.jbuilder のような書き方に変更する」 + +# にしたつ#TODO - このファイルは残しておく(参考:プルリク #7447) diff --git a/app/views/external_entries/_external_entries.html.slim b/app/views/external_entries/_external_entries.html.slim new file mode 100644 index 00000000000..a097c67cc7a --- /dev/null +++ b/app/views/external_entries/_external_entries.html.slim @@ -0,0 +1,7 @@ +.page-main + .page-body + .container.is-md + = paginate(@external_entries) + .card-list.a-card + = render(@external_entries) + = paginate(@external_entries) diff --git a/app/views/external_entries/_external_entry.html.slim b/app/views/external_entries/_external_entry.html.slim new file mode 100644 index 00000000000..1825e4adcfb --- /dev/null +++ b/app/views/external_entries/_external_entry.html.slim @@ -0,0 +1,22 @@ +.card-list-item + .card-list-item__inner + .card-list-item__user + = render('users/icon', user: external_entry.user, image_class: 'card-list-item__user-icon') + .card-list-item__rows + .card-list-item__row + .card-list-item-title + h2.card-list-item-title__title + = link_to(external_entry.title, external_entry.url, rel: 'noopener', target: '_blank', class: 'card-list-item-title__link a-text-link') + .card-list-item__row + .card-list-item__summary + p + | #{external_entry.summary} + .card-list-item__row + .card-list-item-meta + .card-list-item-meta__items + .card-list-item-meta__item + time.a-meta + = l(external_entry.published_at) + .card-list-item__thumbnail + = link_to(external_entry.url, class: 'card-list-item__thumbnail-inner', target: '_blank', rel: 'noopener') do + = image_tag(external_entry.thumbnail_url, class: 'card-list-item__thumbnail-image') diff --git a/app/views/external_entries/index.html.slim b/app/views/external_entries/index.html.slim index 55e3f1f1125..5d32b70e21a 100644 --- a/app/views/external_entries/index.html.slim +++ b/app/views/external_entries/index.html.slim @@ -22,4 +22,4 @@ header.page-header | ブログのフィード URL の登録 | をしてください。 -div(data-vue="ExternalEntries") += render('external_entries') From c80d3984a81c556be056a675934571bad55e0a80 Mon Sep 17 00:00:00 2001 From: nishitatsu-dev Date: Wed, 10 Apr 2024 17:56:58 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=E3=83=A1=E3=83=A2=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=80=81API=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/external_entries/_external_entry.json.jbuilder | 2 -- app/views/api/external_entries/index.json.jbuilder | 7 +------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/views/api/external_entries/_external_entry.json.jbuilder b/app/views/api/external_entries/_external_entry.json.jbuilder index a08bab5e017..17afa8d4396 100644 --- a/app/views/api/external_entries/_external_entry.json.jbuilder +++ b/app/views/api/external_entries/_external_entry.json.jbuilder @@ -4,5 +4,3 @@ json.thumbnailUrl external_entry.thumbnail_url json.user do json.partial! 'api/users/user', user: external_entry.user end - -# にしたつ#TODO - このファイルは残しておく(参考:プルリク #7447) diff --git a/app/views/api/external_entries/index.json.jbuilder b/app/views/api/external_entries/index.json.jbuilder index 4de947fc2d7..4d132b40b75 100644 --- a/app/views/api/external_entries/index.json.jbuilder +++ b/app/views/api/external_entries/index.json.jbuilder @@ -1,7 +1,2 @@ json.external_entries @external_entries, partial: 'api/external_entries/external_entry', as: :external_entry -# json.total_pages @external_entries.total_pages -# 「プルリク #7447」と同様に、/api/external_entries_controller.rb でインスタンス変数を消した場合、 -# http://localhost:3000/api/external_entries.json に接続した時に、上記のコメントアウト行でエラーが出る -# エラーを回避するには「行を削除」か「/api/talks/index.json.jbuilder のような書き方に変更する」 - -# にしたつ#TODO - このファイルは残しておく(参考:プルリク #7447) +json.total_pages @external_entries.total_pages if @external_entries.respond_to? :total_pages From 247562f34dfb0e009db9d728a22fb0703138d6d4 Mon Sep 17 00:00:00 2001 From: nishitatsu-dev Date: Tue, 21 May 2024 14:26:07 +0900 Subject: [PATCH 3/4] =?UTF-8?q?link=5Fto=E3=81=AE=E6=9B=B8=E3=81=8D?= =?UTF-8?q?=E6=96=B9=E3=82=92=E4=BB=96=E3=81=A8=E7=B5=B1=E4=B8=80=EF=BC=88?= =?UTF-8?q?=E3=82=AB=E3=83=83=E3=82=B3=E3=82=92=E5=89=8A=E9=99=A4=EF=BC=89?= =?UTF-8?q?=E3=80=82author=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/external_entries/_external_entry.html.slim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/external_entries/_external_entry.html.slim b/app/views/external_entries/_external_entry.html.slim index 1825e4adcfb..ce338ac4f65 100644 --- a/app/views/external_entries/_external_entry.html.slim +++ b/app/views/external_entries/_external_entry.html.slim @@ -6,7 +6,7 @@ .card-list-item__row .card-list-item-title h2.card-list-item-title__title - = link_to(external_entry.title, external_entry.url, rel: 'noopener', target: '_blank', class: 'card-list-item-title__link a-text-link') + = link_to external_entry.title, external_entry.url, rel: 'noopener', target: '_blank', class: 'card-list-item-title__link a-text-link' .card-list-item__row .card-list-item__summary p @@ -18,5 +18,5 @@ time.a-meta = l(external_entry.published_at) .card-list-item__thumbnail - = link_to(external_entry.url, class: 'card-list-item__thumbnail-inner', target: '_blank', rel: 'noopener') do + = link_to external_entry.url, class: 'card-list-item__thumbnail-inner', target: '_blank', rel: 'noopener' do = image_tag(external_entry.thumbnail_url, class: 'card-list-item__thumbnail-image') From c02cdefb972565361cb836db2e5f6b254c571ed7 Mon Sep 17 00:00:00 2001 From: nishitatsu-dev Date: Tue, 21 May 2024 14:31:21 +0900 Subject: [PATCH 4/4] =?UTF-8?q?api=E9=96=A2=E9=80=A3=E3=81=AE=E3=80=8C?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=80=8D=E3=81=A8=E3=80=8C?= =?UTF-8?q?=E3=83=AB=E3=83=BC=E3=83=86=E3=82=A3=E3=83=B3=E3=82=B0=E3=80=8D?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4=E3=80=82author=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/external_entries_controller.rb | 5 ----- .../api/external_entries/_external_entry.json.jbuilder | 6 ------ app/views/api/external_entries/index.json.jbuilder | 2 -- config/routes/api.rb | 1 - 4 files changed, 14 deletions(-) delete mode 100644 app/controllers/api/external_entries_controller.rb delete mode 100644 app/views/api/external_entries/_external_entry.json.jbuilder delete mode 100644 app/views/api/external_entries/index.json.jbuilder diff --git a/app/controllers/api/external_entries_controller.rb b/app/controllers/api/external_entries_controller.rb deleted file mode 100644 index 34d4864dc82..00000000000 --- a/app/controllers/api/external_entries_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -class API::ExternalEntriesController < API::BaseController - def index; end -end diff --git a/app/views/api/external_entries/_external_entry.json.jbuilder b/app/views/api/external_entries/_external_entry.json.jbuilder deleted file mode 100644 index 17afa8d4396..00000000000 --- a/app/views/api/external_entries/_external_entry.json.jbuilder +++ /dev/null @@ -1,6 +0,0 @@ -json.(external_entry, :title, :url, :summary, :published_at) -json.thumbnailUrl external_entry.thumbnail_url - -json.user do - json.partial! 'api/users/user', user: external_entry.user -end diff --git a/app/views/api/external_entries/index.json.jbuilder b/app/views/api/external_entries/index.json.jbuilder deleted file mode 100644 index 4d132b40b75..00000000000 --- a/app/views/api/external_entries/index.json.jbuilder +++ /dev/null @@ -1,2 +0,0 @@ -json.external_entries @external_entries, partial: 'api/external_entries/external_entry', as: :external_entry -json.total_pages @external_entries.total_pages if @external_entries.respond_to? :total_pages diff --git a/config/routes/api.rb b/config/routes/api.rb index 6a579e547e6..46ad223c1ee 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -89,7 +89,6 @@ resources :books, only: %i(index) resources :courses, only: %i(index) resources :footprints, only: %i(index) - resources :external_entries, only: %i(index) resources :survey_question_listings, only: %i() do resource :position, only: %i(update), controller: "survey_question_listings/position" end