From d9fcf265a32650d679bb4d20e930755b20f9f5a4 Mon Sep 17 00:00:00 2001 From: komagata Date: Wed, 24 Apr 2024 21:52:39 +0900 Subject: [PATCH] =?UTF-8?q?=E7=94=B3=E8=AB=8B=E6=9B=B8=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E3=82=8B=E3=81=9F=E3=82=81=E3=81=AE=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/paper/home_controller.rb | 40 ++++++++++++++++++++++++ app/controllers/paper_controller.rb | 6 ++++ app/javascript/packs/paper.js | 10 ++++++ app/javascript/stylesheets/paper.sass | 5 +++ app/views/layouts/paper.html.slim | 8 +++++ app/views/paper/home/index.html.slim | 36 +++++++++++++++++++++ config/routes.rb | 1 + config/routes/paper.rb | 7 +++++ 8 files changed, 113 insertions(+) create mode 100644 app/controllers/paper/home_controller.rb create mode 100644 app/controllers/paper_controller.rb create mode 100644 app/javascript/packs/paper.js create mode 100644 app/javascript/stylesheets/paper.sass create mode 100644 app/views/layouts/paper.html.slim create mode 100644 app/views/paper/home/index.html.slim create mode 100644 config/routes/paper.rb diff --git a/app/controllers/paper/home_controller.rb b/app/controllers/paper/home_controller.rb new file mode 100644 index 00000000000..2805a74f404 --- /dev/null +++ b/app/controllers/paper/home_controller.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'csv' + +class Paper::HomeController < PaperController + CSV_FILE_NAME = 'カリキュラム一覧.csv' + + def index + ignore_practice_ids = [6, 19, 23, 25, 57] + @categories = Course.find(1).categories.where.not(id: ignore_practice_ids) + + respond_to do |format| + format.html + format.csv do + send_data(csv_data, filename: CSV_FILE_NAME) + end + end + end + + private + + def csv_data + CSV.generate do |csv| + csv << %w[章番号 章 章の目的 単元番号 所要時間 単元 URL].freeze + @categories.each_with_index do |category, i| + category.practices.each_with_index do |practice, h| + csv << [ + i + 1, + category.name, + category.description, + "#{i + 1}-#{h + 1}", + time_format, + practice.title, + "https://bootcamp.fjord.jp/practices/#{practice.id}" + ] + end + end + end + end +end diff --git a/app/controllers/paper_controller.rb b/app/controllers/paper_controller.rb new file mode 100644 index 00000000000..c86e9ebbd2e --- /dev/null +++ b/app/controllers/paper_controller.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +class PaperController < ApplicationController + before_action :require_admin_login + layout 'paper' +end diff --git a/app/javascript/packs/paper.js b/app/javascript/packs/paper.js new file mode 100644 index 00000000000..b5e9ddf5bfa --- /dev/null +++ b/app/javascript/packs/paper.js @@ -0,0 +1,10 @@ +/* eslint no-console:0 */ +// This file is automatically compiled by Webpack, along with any other files +// present in this directory. You're encouraged to place your actual application logic in +// a relevant structure within app/javascript and only use these pack files to reference +// that code so it'll be compiled. +// +// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate +// layout file, like app/views/layouts/application.html.erb + +import '../stylesheets/paper' diff --git a/app/javascript/stylesheets/paper.sass b/app/javascript/stylesheets/paper.sass new file mode 100644 index 00000000000..ec2e12663cc --- /dev/null +++ b/app/javascript/stylesheets/paper.sass @@ -0,0 +1,5 @@ +.book-name + font-size: 3em + +img + max-width: 90% diff --git a/app/views/layouts/paper.html.slim b/app/views/layouts/paper.html.slim new file mode 100644 index 00000000000..2878efcdb4a --- /dev/null +++ b/app/views/layouts/paper.html.slim @@ -0,0 +1,8 @@ +doctype html +html(lang='ja') + head + = javascript_include_tag 'application' + = javascript_pack_tag 'application' + = stylesheet_pack_tag 'paper', media: 'all' + body + = yield diff --git a/app/views/paper/home/index.html.slim b/app/views/paper/home/index.html.slim new file mode 100644 index 00000000000..87f82cff764 --- /dev/null +++ b/app/views/paper/home/index.html.slim @@ -0,0 +1,36 @@ +.book-name フィヨルドブートキャンプカリキュラム + +div(style="page-break-before:always") + +h2 目次 + +- @categories.each_with_index do |category, i| + | #{i + 1} #{category.name} + br + - category.practices.each_with_index do |practice, h| + |   #{i + 1}.#{h + 1} + = link_to practice.title, "##{practice.id}" + br + +div(style="page-break-before:always") + +- @categories.each_with_index do |category, i| + h3.category_name + | #{i + 1} #{category.name} + = category.description + + div(style="page-break-before:always") + + - category.practices.each_with_index do |practice, h| + h3.practice_title(id="#{practice.id}") + | #{i + 1}.#{h + 1} #{practice.title.strip} + + div(style="page-break-before:always") + + .a-long-text.is-md.js-markdown-view = practice.description + + h2 終了条件 + + = practice.goal + + div(style="page-break-before:always") diff --git a/config/routes.rb b/config/routes.rb index 948ee5396d5..502fe278375 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,6 +17,7 @@ get "coc", to: "welcome#coc", as: "coc" draw :scheduler draw :api + draw :paper draw :admin draw :mentor draw :current_user diff --git a/config/routes/paper.rb b/config/routes/paper.rb new file mode 100644 index 00000000000..e1e429a0913 --- /dev/null +++ b/config/routes/paper.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +Rails.application.routes.draw do + namespace :paper do + root to: "home#index", as: :root + end +end