Skip to content

Commit

Permalink
申請書を作るためのファイルを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
komagata committed Apr 30, 2024
1 parent 4dd4fca commit d9fcf26
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 0 deletions.
40 changes: 40 additions & 0 deletions app/controllers/paper/home_controller.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions app/controllers/paper_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

class PaperController < ApplicationController
before_action :require_admin_login
layout 'paper'
end
10 changes: 10 additions & 0 deletions app/javascript/packs/paper.js
Original file line number Diff line number Diff line change
@@ -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'
5 changes: 5 additions & 0 deletions app/javascript/stylesheets/paper.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.book-name
font-size: 3em

img
max-width: 90%
8 changes: 8 additions & 0 deletions app/views/layouts/paper.html.slim
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions app/views/paper/home/index.html.slim
Original file line number Diff line number Diff line change
@@ -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")
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
get "coc", to: "welcome#coc", as: "coc"
draw :scheduler
draw :api
draw :paper
draw :admin
draw :mentor
draw :current_user
Expand Down
7 changes: 7 additions & 0 deletions config/routes/paper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

Rails.application.routes.draw do
namespace :paper do
root to: "home#index", as: :root
end
end

0 comments on commit d9fcf26

Please sign in to comment.