-
Notifications
You must be signed in to change notification settings - Fork 75
textbook(教科書)機能 Phase 1a #9835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
komagata
wants to merge
14
commits into
main
Choose a base branch
from
feature/textbook
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
textbook(教科書)機能 Phase 1a #9835
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2f24ec3
Add textbook tables
komagata 6e50f86
Add textbook models
komagata 75a545c
Add textbook model tests and fixtures
komagata 475e543
Add textbook controllers and routes
komagata d476108
Add textbook views and helper
komagata 9652560
Add Stimulus controllers for textbook
komagata fc4af0c
Add mentor textbook management UI
komagata 57d912e
Add Linux textbook seed data
komagata f0642d8
Fix PjordRespondJob: guard against deleted records and missing mentions
komagata 457c2ce
Replace RuboCop orb with direct execution in CI
komagata 0232893
Exclude seed files from RuboCop
komagata 653bb8c
Set REVIEW_APP env var in review app Cloud Build
komagata f580c76
Improve textbook page designs
komagata ee4fc27
Redesign textbook pages to match bootcamp design system
komagata File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ AllCops: | |
| - db/data_schema.rb | ||
| - db/migrate/* | ||
| - db/schema.rb | ||
| - db/seeds/**/* | ||
| - storage/**/* | ||
| - tmp/**/* | ||
| - bin/**/* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/assets/stylesheets/application/blocks/textbook/_textbook-list.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* 教科書共通 */ | ||
|
|
||
| .textbook-summary { | ||
| margin-top: 0.75rem; | ||
| } | ||
|
|
||
| .textbook-summary__stats { | ||
| font-size: 0.8125rem; | ||
| color: var(--muted-text); | ||
| margin-bottom: 0.375rem; | ||
| } | ||
|
|
||
| .textbook-summary__action { | ||
| margin-top: 0.75rem; | ||
| } | ||
|
|
||
| .a-completed-check { | ||
| color: var(--success); | ||
| margin-right: 0.375rem; | ||
| } | ||
|
|
||
| .a-pending-check { | ||
| color: var(--disabled); | ||
| margin-right: 0.375rem; | ||
| font-size: 0.875em; | ||
| } | ||
|
|
||
| .textbook-breadcrumb { | ||
| font-size: 0.8125rem; | ||
| color: var(--muted-text); | ||
| margin-bottom: 1rem; | ||
| } | ||
|
|
||
| .textbook-breadcrumb a { | ||
| color: var(--link-text); | ||
| } | ||
|
|
||
| .textbook-breadcrumb a:hover { | ||
| text-decoration: underline; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| .piyo-companion { | ||
| position: fixed; | ||
| bottom: 1rem; | ||
| right: 1rem; | ||
| z-index: 1000; | ||
| } | ||
|
|
||
| .piyo-companion__button { | ||
| background: none; | ||
| border: none; | ||
| cursor: pointer; | ||
| padding: 0; | ||
| position: relative; | ||
| transition: transform 0.15s; | ||
| } | ||
|
|
||
| .piyo-companion__button:hover { | ||
| transform: scale(1.1); | ||
| } | ||
|
|
||
| .piyo-companion__image { | ||
| width: 56px; | ||
| height: 56px; | ||
| filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15)); | ||
| } | ||
|
|
||
| .piyo-companion__bubble { | ||
| position: absolute; | ||
| bottom: 64px; | ||
| right: 0; | ||
| background: var(--base, #fff); | ||
| border: 1px solid var(--border, #e0e0e0); | ||
| border-radius: 12px; | ||
| padding: 0.625rem 0.875rem; | ||
| max-width: 220px; | ||
| box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1); | ||
| animation: piyo-bubble-in 0.2s ease-out; | ||
| } | ||
|
|
||
| .piyo-companion__bubble::after { | ||
| content: ''; | ||
| position: absolute; | ||
| bottom: -7px; | ||
| right: 20px; | ||
| width: 0; | ||
| height: 0; | ||
| border-left: 7px solid transparent; | ||
| border-right: 7px solid transparent; | ||
| border-top: 7px solid var(--base, #fff); | ||
| } | ||
|
|
||
| .piyo-companion__message { | ||
| margin: 0; | ||
| font-size: 0.8125rem; | ||
| line-height: 1.5; | ||
| } | ||
|
|
||
| .piyo-companion__badge { | ||
| position: absolute; | ||
| top: -3px; | ||
| right: -3px; | ||
| width: 10px; | ||
| height: 10px; | ||
| background: var(--danger, #ef4444); | ||
| border-radius: 50%; | ||
| border: 2px solid var(--base, #fff); | ||
| } | ||
|
|
||
| @keyframes piyo-bubble-in { | ||
| from { | ||
| opacity: 0; | ||
| transform: translateY(4px); | ||
| } | ||
| to { | ||
| opacity: 1; | ||
| transform: translateY(0); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
app/controllers/api/textbooks/reading_progresses_controller.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class API::Textbooks::ReadingProgressesController < API::BaseController | ||
| include TextbookFeatureGuard | ||
| before_action :require_textbook_enabled | ||
|
|
||
| def create | ||
| @reading_progress = current_user.reading_progresses.find_or_initialize_by( | ||
| textbook_section_id: reading_progress_params[:textbook_section_id] | ||
| ) | ||
| @reading_progress.assign_attributes(reading_progress_params) | ||
| if @reading_progress.save | ||
| head(@reading_progress.previously_new_record? ? :created : :ok) | ||
| else | ||
| head :unprocessable_entity | ||
| end | ||
| rescue ActiveRecord::RecordNotUnique | ||
| retry | ||
| end | ||
|
|
||
| def update | ||
| @reading_progress = current_user.reading_progresses.find(params[:id]) | ||
| if @reading_progress.update(reading_progress_params) | ||
| head :ok | ||
| else | ||
| head :unprocessable_entity | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def reading_progress_params | ||
| params.require(:reading_progress).permit(:textbook_section_id, :read_ratio, :completed, :last_block_index, :last_read_at) | ||
| end | ||
| end | ||
10 changes: 10 additions & 0 deletions
10
app/controllers/api/textbooks/term_explanations_controller.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class API::Textbooks::TermExplanationsController < API::BaseController | ||
| include TextbookFeatureGuard | ||
| before_action :require_textbook_enabled | ||
|
|
||
| def show | ||
| @term_explanation = TermExplanation.find(params[:id]) | ||
| end | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # textbook機能のfeature flag制御 | ||
| module TextbookFeatureGuard | ||
| extend ActiveSupport::Concern | ||
|
|
||
| private | ||
|
|
||
| def require_textbook_enabled | ||
| return if Switchlet.enabled?(:textbook) || Rails.env.local? || staging_or_review? | ||
|
|
||
| head :not_found | ||
| end | ||
|
|
||
| def staging_or_review? | ||
| ENV['REVIEW_APP'].present? || ENV['STAGING'].present? | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Mentor::Textbooks::ChaptersController < ApplicationController | ||
| include TextbookFeatureGuard | ||
| before_action :require_admin_or_mentor_login | ||
| before_action :require_textbook_enabled | ||
| before_action :set_textbook | ||
| before_action :set_chapter, only: %i[edit update destroy] | ||
|
|
||
| def new | ||
| @chapter = @textbook.chapters.build | ||
| end | ||
|
|
||
| def create | ||
| @chapter = @textbook.chapters.build(chapter_params) | ||
| if @chapter.save | ||
| redirect_to mentor_textbook_path(@textbook), notice: '章を作成しました。' | ||
| else | ||
| render :new, status: :unprocessable_entity | ||
| end | ||
| end | ||
|
|
||
| def edit; end | ||
|
|
||
| def update | ||
| if @chapter.update(chapter_params) | ||
| redirect_to mentor_textbook_path(@textbook), notice: '章を更新しました。' | ||
| else | ||
| render :edit, status: :unprocessable_entity | ||
| end | ||
| end | ||
|
|
||
| def destroy | ||
| @chapter.destroy! | ||
| redirect_to mentor_textbook_path(@textbook), notice: '章を削除しました。' | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def set_textbook | ||
| @textbook = Textbook.find(params[:textbook_id]) | ||
| end | ||
|
|
||
| def set_chapter | ||
| @chapter = @textbook.chapters.find(params[:id]) | ||
| end | ||
|
|
||
| def chapter_params | ||
| params.require(:textbook_chapter).permit(:title, :position) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Mentor::Textbooks::SectionsController < ApplicationController | ||
| include TextbookFeatureGuard | ||
| before_action :require_admin_or_mentor_login | ||
| before_action :require_textbook_enabled | ||
| before_action :set_textbook | ||
| before_action :set_chapter | ||
| before_action :set_section, only: %i[edit update destroy] | ||
|
|
||
| def new | ||
| @section = @chapter.sections.build | ||
| end | ||
|
|
||
| def create | ||
| @section = @chapter.sections.build(section_params) | ||
| if @section.save | ||
| redirect_to mentor_textbook_path(@textbook), notice: '節を作成しました。' | ||
| else | ||
| render :new, status: :unprocessable_entity | ||
| end | ||
| end | ||
|
|
||
| def edit; end | ||
|
|
||
| def update | ||
| if @section.update(section_params) | ||
| redirect_to mentor_textbook_path(@textbook), notice: '節を更新しました。' | ||
| else | ||
| render :edit, status: :unprocessable_entity | ||
| end | ||
| end | ||
|
|
||
| def destroy | ||
| @section.destroy! | ||
| redirect_to mentor_textbook_path(@textbook), notice: '節を削除しました。' | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def set_textbook | ||
| @textbook = Textbook.find(params[:textbook_id]) | ||
| end | ||
|
|
||
| def set_chapter | ||
| @chapter = @textbook.chapters.find(params[:chapter_id]) | ||
| end | ||
|
|
||
| def set_section | ||
| @section = @chapter.sections.find(params[:id]) | ||
| end | ||
|
|
||
| def section_params | ||
| params.require(:textbook_section).permit(:title, :body, :estimated_minutes, :position, goals: [], key_terms: []) | ||
| end | ||
| end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.