Skip to content

Commit

Permalink
Merge pull request #3339 from fjordllc/main
Browse files Browse the repository at this point in the history
Release 2021-10-12 05:41:07
  • Loading branch information
komagata committed Oct 12, 2021
2 parents 4885d7e + 385e156 commit 28e07ec
Show file tree
Hide file tree
Showing 47 changed files with 650 additions and 224 deletions.
Binary file added app/assets/images/mentors/kaito.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions app/assets/stylesheets/atoms/_a-page-notice.sass
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@
background-color: $danger
.page-body &
+margin(vertical, -.5rem 1rem)
.page-body .page-notices__item &
+margin(vertical, 0)
.page-tools + &
margin-top: -1px
.page-tabs + &
margin-top: 1rem

.a-page-notice__inner
+padding(vertical, .5rem)
&.has-close
padding: 0
position: relative
display: flex
align-items: center
p
+text-block(1em 1.4, $reversal-text center)
+media-breakpoint-up(md)
Expand All @@ -21,3 +28,33 @@
a
color: $reversal-text
+hover-link-reversal
&.has-badge
text-decoration: none
+media-breakpoint-down(sm)
display: block
position: relative
padding-left: 4rem
.a-badge
margin-right: .75rem
background-color: rgba(black, .4)
border: none
+media-breakpoint-down(sm)
+position(absolute, left 0, top 0)
.a-page-notice__label
+hover-link-reversal

.a-page-notice__inner-start
flex: 1

.a-page-notice__close
+size(2.75rem)
display: flex
align-items: center
justify-content: center
cursor: pointer
font-size: 1.5rem
opacity: .6
transition: all .2s ease-out
margin-left: .5rem
&:hover
opacity: 1
30 changes: 30 additions & 0 deletions app/assets/stylesheets/blocks/company/_company-counts.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.company-counts__items
display: flex
justify-content: center
+margin(horizontal, -.125rem)
flex-wrap: wrap
margin-bottom: -.25rem

.company-counts__item
+padding(horizontal, .125rem)
margin-bottom: .25rem
+media-breakpoint-up(xxl)
flex: 0 0 25%
+media-breakpoint-down(xl)
flex: 0 0 33.33%
+media-breakpoint-down(sm)
flex: 0 0 50%

.company-counts__item-inner
border: solid 1px $border
border-radius: 3px

.company-counts__item-label
+text-block(.625rem 1.4, center)
+padding(vertical, .125rem)
border-bottom: solid 1px $border
background-color: $background-more-tint

.company-counts__item-value
+text-block(1rem 1.4, center)
padding-bottom: .125rem
14 changes: 14 additions & 0 deletions app/assets/stylesheets/blocks/company/_company-links.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.company-links__items
display: flex
justify-content: center
+margin(horizontal, -.125rem)
flex-wrap: wrap
margin-bottom: -.25rem

.company-links__item
+padding(horizontal, .125rem)
margin-bottom: .25rem
+media-breakpoint-up(xxl)
flex: 0 0 33.33%
+media-breakpoint-down(xl)
flex: 0 0 50%
39 changes: 39 additions & 0 deletions app/assets/stylesheets/blocks/company/_company-profile.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.company-profile__header
padding: 1rem
.company-links__items
justify-content: flex-start

.company-profile__header-inner
+media-breakpoint-up(md)
display: flex
+media-breakpoint-down(sm)
text-align: center

.company-profile__header-start
margin-right: 1.25rem

.company-profile__header-end
flex: 1

.company-profile__logo
+media-breakpoint-down(sm)
position: static
text-align: center
margin-bottom: .25rem

.company-profile__logo-image
+media-breakpoint-up(md)
+size(4.5rem)
+media-breakpoint-down(sm)
+size(3.5rem)

.company-profile__name
+text-block(1em 1.45, 700 $main-text)
+media-breakpoint-up(md)
font-size: 1.5rem
+media-breakpoint-down(sm)
font-size: 1.25rem

.company-profile__body
padding: 1rem
border-top: solid 1px $border
19 changes: 0 additions & 19 deletions app/assets/stylesheets/blocks/page/_page-notice.sass

This file was deleted.

7 changes: 7 additions & 0 deletions app/assets/stylesheets/blocks/page/_page-notices.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.page-notices
+margin(vertical, -.5rem 1rem)
background-color: $info

.page-notices__item
&:not(:first-child)
border-top: dashed 1px rgba(white, .2)
65 changes: 65 additions & 0 deletions app/assets/stylesheets/blocks/user/_companies-item.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
.companies-item
padding-top: .375rem
padding-bottom: 1.5rem
height: 100%

.companies-item__inner
+media-breakpoint-up(md)
height: 100%

.companies-item__header
+position(relative)
padding-left: 3.5rem
padding-right: 1rem
padding-top: .5rem
padding-bottom: .5rem
+media-breakpoint-down(sm)
padding-left: 3rem
&:not(:last-child)
border-bottom: solid 1px $background

.companies-item__name
+text-block(1em 1.4, 600 $main block)
margin-bottom: .125rem
+media-breakpoint-up(md)
font-size: 1.25rem
+media-breakpoint-down(sm)
font-size: 1.125rem

.companies-item__name-link
color: $main-text
display: block
+hover-link

.companies-item__user-icon-image
background-color: white
box-shadow: rgba(black, .2) 0 0 .25rem
+media-breakpoint-up(md)
+size(4rem)
+position(absolute, left -1rem, top -.375rem)
border: solid $base .25rem
+media-breakpoint-down(sm)
+size(3rem)
+position(absolute, left -.5rem, top -.25rem)
border: solid $base .125rem

.companies-item__body
padding: 1rem

.companies-item__body-row
&:not(:first-child)
margin-top: .75rem

.companies-item__description
p
+text-block(.75rem 1.6)

.user-item__company-logo
max-width: 3rem
background-color: $base
+position(absolute, right 0.5rem, top 0.5rem)
border-radius: .25rem
border: solid 1px $border
+media-breakpoint-down(lg)
+position(absolute, right -0.5rem, top -0.5rem)
border-radius: 50%
10 changes: 0 additions & 10 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

class Admin::UsersController < AdminController
before_action :set_user, only: %i[show edit update]
PAGER_NUMBER = 100

def index
@direction = params[:direction] || 'desc'
Expand All @@ -11,16 +10,7 @@ def index
.preload(%i[company course])
.order_by_counts(params[:order_by] || 'id', @direction)
.users_role(@target)
.page(params[:page]).per(PAGER_NUMBER)
@emails = User.users_role(@target).pluck(:email)

if Rails.env.production?
@subscriptions = Subscription.new.all
@subscription_ids = @subscriptions.map { |s| s['id'] }
else
@subscriptions = []
@subscription_ids = []
end
end

def show
Expand Down
11 changes: 11 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ def index
.order(published_at: :desc)
.limit(5)
@completed_learnings = current_user.learnings.where(status: 3).order(updated_at: :desc)
@inactive_students = User.inactive_students_and_trainees.order(updated_at: :desc)
cookies_ids = JSON.parse(cookies[:confirmed_event_ids]) if cookies[:confirmed_event_ids]
@events_coming_soon = Event.where(start_at: today_to_tomorrow).or(Event.where(start_at: tomorrow_to_day_after_tomorrow)).where.not(id: cookies_ids)
set_required_fields
render aciton: :index
end
Expand All @@ -33,4 +36,12 @@ def set_required_fields
discord_account: current_user.discord_account
)
end

def today_to_tomorrow
(Time.zone.today + 9.hours)..(Time.zone.tomorrow + 9.hours)
end

def tomorrow_to_day_after_tomorrow
(Time.zone.tomorrow + 9.hours)..(Time.zone.tomorrow + 1.day + 9.hours)
end
end
17 changes: 17 additions & 0 deletions app/controllers/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def create
@question = Question.new(question_params)
@question.user = current_user
if @question.save
create_mentors_watch
notify_to_chat(@question)
redirect_to @question, notice: '質問を作成しました。'
else
Expand Down Expand Up @@ -95,4 +96,20 @@ def questions_property
QuestionsProperty.new('未解決の質問一覧', '未解決の質問はまだありません。')
end
end

def create_mentors_watch
Watch.insert_all(watch_records) # rubocop:disable Rails/SkipsModelValidations
end

def watch_records
User.mentor.map do |mentor|
{
watchable_type: 'Question',
watchable_id: @question.id,
created_at: Time.current,
updated_at: Time.current,
user_id: mentor.id
}
end
end
end
7 changes: 0 additions & 7 deletions app/controllers/watches_controller.rb

This file was deleted.

16 changes: 14 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

module ApplicationHelper
EXTRACTING_CHARACTERS = 50

def my_practice?(practice)
return false if current_user.blank?

Expand All @@ -17,8 +19,18 @@ def md_summary(comment, word_count)
simple_format(truncate(summary, length: word_count))
end

def searchable_summary(comment, word_count)
def searchable_summary(comment, word_count, word = '')
summary = strip_tags(md2html(comment)).gsub(/[\r\n]/, '')
truncate(summary, length: word_count)
words = word.split(/[[:space:]]+/).compact.reject(&:empty?) unless word.nil?
return truncate(summary, length: word_count) if words.blank?

words_pattern = words.map { |keyword| Regexp.escape(keyword) }.join('|')
words_regexp = Regexp.new(words_pattern, Regexp::IGNORECASE)
match = words_regexp.match(summary)
return truncate(summary, length: word_count) if match.nil?

begin_offset = (match.begin(0) - EXTRACTING_CHARACTERS).clamp(0, Float::INFINITY)
end_offset = match.end(0) + EXTRACTING_CHARACTERS
summary[begin_offset...end_offset]
end
end
11 changes: 11 additions & 0 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module HomeHelper
def today_or_tommorow(event)
if event.start_at.to_date.today?
'今日'
elsif event.start_at.to_date == Date.tomorrow
'明日'
end
end
end
Loading

0 comments on commit 28e07ec

Please sign in to comment.