Skip to content
This repository has been archived by the owner on Feb 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #162 from MyDry/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rkdora authored Nov 15, 2018
2 parents 7e6d94d + 34ff010 commit e59b28a
Show file tree
Hide file tree
Showing 45 changed files with 1,132 additions and 135 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,4 @@ RUBY VERSION
ruby 2.5.1p57

BUNDLED WITH
1.16.4
1.17.1
3 changes: 3 additions & 0 deletions app/assets/javascripts/words.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
139 changes: 113 additions & 26 deletions app/assets/stylesheets/mandalarts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,122 @@
// You can use Sass (SCSS) here: http://sass-lang.com/

.mandalart{
width: 1200px;
height: 1200px;

width: 900px;
height: 1000px;
margin-left: 100px;
.row{
float: left;
width: 400px;
height: 400px;
//float: left;
.block{
width: 300px;
height: 300px;
margin-top: 0px;
margin-right: 0px;
margin-left: 0px;
margin-bottom: 0px;
float: left;
textarea{
display: block;
float: left;
width: 100px;
height: 100px;
margin-top: 0px;
margin-right: 0px;
margin-left: 0px;
margin-bottom: 0px;
border: 1px solid #999;
text-align: center;
word-wrap: break-word;
resize: none;
}
.core textarea{
display: block;
background-color: rgba(100,100,100,0.3);
width: 100px;
height: 100px;
margin-top: 0px;
margin-right: 0px;
margin-left: 0px;
margin-bottom: 0px;
text-align: center;
word-wrap: break-word;
resize: none;
}
.corecore textarea{
display: block;
background-color: #ffd700;
width: 100px;
height: 100px;
margin-top: 0px;
margin-right: 0px;
margin-left: 0px;
margin-bottom: 0px;
//border: 3px solid #999;
text-align: center;
word-wrap: break-word;
resize: none;
}
}
.pop{
position: absolute;
left: 1400px;
top: 165px;
width: 100px;
height: 100px;
text-align: center;
font-weight: bold;
.save-btn{
background: none;
border: none;
}
}
}

textarea[type=core] {
width: 100px;
height: 100px;
margin-left: 2px;
margin-right: 2px;
margin-top: 0px;
margin-bottom: 0px;
border: 3px solid #999;
#index{
text-align: center;
word-wrap: break-word;
resize: none;
}

textarea[type=sub] {
width: 100px;
height: 100px;
margin-left: 2px;
margin-right: 2px;
margin-top: 0px;
margin-bottom: 0px;
resize: none;
width: 100%;
height: 500px;
.square_btn a{
display: inline-block;
padding: 0.5em 1em;
text-decoration: none;
background: #ffe000;
color: #000;
font-weight: bold;
border-bottom: solid 4px #627295;
border-radius: 3px;
}
.square_btn a:hover{
text-decoration: none;
color: #fff;
}
.square_btn a:active {/*ボタンを押したとき*/
text-decoration: none;
transform: translateY(4px);/*下に動く*/
border-bottom: none;/*線を消す*/
}
.dates{
width: 100%;
text-align: center;
.square_btn a{
width: 100px;
height: 100px;
margin: 20px;
display: inline-block;
padding: 0.5em 1em;
text-decoration: none;
background: #ffe000;
color: #000;
font-weight: bold;
border-bottom: solid 4px #627295;
}
.square_btn a:hover{
text-decoration: none;
color: #fff;
}
.square_btn a:active {/*ボタンを押したとき*/
text-decoration: none;
transform: translateY(4px);/*下に動く*/
border-bottom: none;/*線を消す*/
}
}
}
16 changes: 16 additions & 0 deletions app/assets/stylesheets/words.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.random-words {
.random-tool {
text-align: center;
font-size: 10vh;
a {
font-size: 5vh;
text-decoration: none;
}
}
.words-index {
background-color: lightgray;
font-size: 2vh;
}
.word-form {
}
}
55 changes: 55 additions & 0 deletions app/controllers/mandalarts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,59 @@
class MandalartsController < ApplicationController
def index
@simple_mandals = current_user.simple_mandals
end

def show
@simple_mandal = SimpleMandal.find(params[:id])
end

def new
@simple_mandal = SimpleMandal.new
end

def create
@simple_mandal = current_user.simple_mandals.build(simple_mandal_params)
@simple_mandal.save
redirect_to mandalart_path(id: @simple_mandal)
end

private
def simple_mandal_params
params.require(:simple_mandal).permit(
:elem_1_1, :elem_1_2, :elem_1_3,
:elem_1_4, :elem_1_5, :elem_1_6,
:elem_1_7, :elem_1_8, :elem_1_9,

:elem_2_1, :elem_2_2, :elem_2_3,
:elem_2_4, :elem_2_5, :elem_2_6,
:elem_2_7, :elem_2_8, :elem_2_9,

:elem_3_1, :elem_3_2, :elem_3_3,
:elem_3_4, :elem_3_5, :elem_3_6,
:elem_3_7, :elem_3_8, :elem_3_9,

:elem_4_1, :elem_4_2, :elem_4_3,
:elem_4_4, :elem_4_5, :elem_4_6,
:elem_4_7, :elem_4_8, :elem_4_9,

:elem_5_1, :elem_5_2, :elem_5_3,
:elem_5_4, :elem_5_5, :elem_5_6,
:elem_5_7, :elem_5_8, :elem_5_9,

:elem_6_1, :elem_6_2, :elem_6_3,
:elem_6_4, :elem_6_5, :elem_6_6,
:elem_6_7, :elem_6_8, :elem_6_9,

:elem_7_1, :elem_7_2, :elem_7_3,
:elem_7_4, :elem_7_5, :elem_7_6,
:elem_7_7, :elem_7_8, :elem_7_9,

:elem_8_1, :elem_8_2, :elem_8_3,
:elem_8_4, :elem_8_5, :elem_8_6,
:elem_8_7, :elem_8_8, :elem_8_9,

:elem_9_1, :elem_9_2, :elem_9_3,
:elem_9_4, :elem_9_5, :elem_9_6,
:elem_9_7, :elem_9_8, :elem_9_9)
end
end
1 change: 0 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def destroy
@user.destroy
flash[:success] = "ユーザーを削除しました"
redirect_to users_path

end

private
Expand Down
41 changes: 41 additions & 0 deletions app/controllers/words_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class WordsController < ApplicationController
before_action :admin_user, only: :destroy

def index
@words = Word.all
random_words = Word.order("RANDOM()").limit(2)
@word1 = random_words[0]
@word2 = random_words[1]
end

def new
@word = Word.new
end

def create
@word = Word.new(word_params)
if @word.save
redirect_to words_path
else
render 'new'
end
end

def destroy
@word = Word.find_by(params[:id])
@word.destroy
flash[:success] = "単語を削除しました"
redirect_to words_path
end

private

def word_params
params.require(:word).permit(:word)
end

def admin_user
redirect_to root_path unless current_user.admin?
end

end
20 changes: 0 additions & 20 deletions app/helpers/mandalarts_helper.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
module MandalartsHelper
def show_sub_elem(subNum)
content_tag(:div, id: subNum, style: 'visibility: hidden;') do
default_attributes = {type: 'sub'}
core_attributes = default_attributes.merge({ style: 'visibility: hidden; border: 1px dotted #999;'})
(1..9).each do |n|
attributes = (n == 5) ? core_attributes : default_attributes
concat content_tag(:textarea, ' ', { id: "#{subNum}-#{n}" }.merge(attributes))
end
end
end

def show_core_elem
content_tag(:div, id: 'core') do
get_attributes = lambda{|n| { id: "5-#{n}", type: 'core'}}
(1..9).each do |n|
attributes = get_attributes.call(n)
attributes.merge!(onchange: "animeTest1(#{n}, this.value)") unless n == 5
concat content_tag(:textarea, ' ', attributes)
end
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/words_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module WordsHelper
end
5 changes: 5 additions & 0 deletions app/models/core_mandal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class CoreMandal < ApplicationRecord
belongs_to :user

has_many :sub_mandals, as: :mandal
end
2 changes: 2 additions & 0 deletions app/models/mandal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Mandal < ApplicationRecord
end
3 changes: 3 additions & 0 deletions app/models/simple_mandal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class SimpleMandal < ApplicationRecord
belongs_to :user
end
5 changes: 5 additions & 0 deletions app/models/sub_mandal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class SubMandal < ApplicationRecord
belongs_to :mandal, polymorphic: true

has_many :sub_mandals, as: :mandal
end
4 changes: 3 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class User < ApplicationRecord
has_many :topics, dependent: :destroy
has_many :likes, dependent: :destroy
has_many :notices, dependent: :destroy

has_many :core_mandals, dependent: :destroy
has_many :simple_mandals, dependent: :destroy

mount_uploader :image, ProfileImageUploader
end
3 changes: 3 additions & 0 deletions app/models/word.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Word < ApplicationRecord
validates :word, {presence: true, uniqueness: true}
end
19 changes: 9 additions & 10 deletions app/views/home/top.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,23 @@
<div class="top-image">
<%= image_tag('top.png') %>
</div>
<!-- ここから -->
<div class="top-form">
<h1 align="center">アイデアに出会おう!</h1>
<p align="center">Let's meet the idea!</p>
<%= form_for(@user, url: login_path) do |f| %>
<% if !logged_in? %>
<%= form_for(@user, url: login_path) do |f| %>
<!--
<%= f.label :email, 'メールアドレス' %><br>
<%= f.email_field :email, class: 'form-control', placeholder: 'メールアドレスを入力' %><br>
-->
<%= f.text_field :name, class: 'form-control', placeholder: 'ユーザー名', style:"font-size: 25px" %>
<%= f.password_field :password , class: 'form-control', placeholder: 'パスワード', style:"font-size: 25px" %><br>
<%= f.submit 'ログイン', class: 'btn btn-default btn-lg', style: "background-color: #00BABD; color: white; width: 500px; height: 80px; font-size: 40px;" %><br>
<% end %>
<h2 align="center">-----------または-----------</h2>
<%= link_to 'アカウント作成', new_user_path, class: 'btn btn-warning btn-lg', style: " color: white; width: 500px; height: 80px; font-size: 40px;" %>
<%= f.text_field :name, class: 'form-control', placeholder: 'ユーザー名', style:"font-size: 25px" %>
<%= f.password_field :password , class: 'form-control', placeholder: 'パスワード', style:"font-size: 25px" %><br>
<%= f.submit 'ログイン', class: 'btn btn-default btn-lg', style: "background-color: #00BABD; color: white; width: 500px; height: 80px; font-size: 40px;" %><br>
<% end %>
<h2 align="center">-----------または-----------</h2>
<%= link_to 'アカウント作成', new_user_path, class: 'btn btn-warning btn-lg', style: " color: white; width: 500px; height: 80px; font-size: 40px;" %>
<%end%>
</div>
<br>
<!-- ここまで -->
</div>
</div>
</div>
Loading

0 comments on commit e59b28a

Please sign in to comment.