Skip to content

Commit

Permalink
gem => creditor, paperclip 추가 및 모델 생성, db 수정 및 Notice, freeboard 뷰 파일 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
k352ex committed Nov 15, 2015
1 parent bc58705 commit af42836
Show file tree
Hide file tree
Showing 25 changed files with 249 additions and 96 deletions.
18 changes: 3 additions & 15 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,31 @@
source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'ckeditor', github: 'galetahub/ckeditor'
gem 'paperclip'

gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
gem 'bootstrap-sass', '~> 3.3.5'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# User
gem 'devise'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
gem "better_errors"
gem 'quiet_assets'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end

21 changes: 21 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
GIT
remote: git://github.com/galetahub/ckeditor.git
revision: a69dcdbe0babbd49085e9dc17efffc63297ab0b4
specs:
ckeditor (4.1.4)
cocaine
orm_adapter (~> 0.5.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -52,6 +60,10 @@ GEM
sass (>= 3.3.0)
builder (3.2.2)
byebug (8.2.0)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.7)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.0)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
Expand Down Expand Up @@ -86,12 +98,19 @@ GEM
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.6.2)
mimemagic (0.3.0)
mini_portile (0.6.2)
minitest (5.8.2)
multi_json (1.11.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
orm_adapter (0.5.0)
paperclip (4.3.1)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
cocaine (~> 0.5.5)
mime-types
mimemagic (= 0.3.0)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rack (1.6.4)
Expand Down Expand Up @@ -168,10 +187,12 @@ DEPENDENCIES
better_errors
bootstrap-sass (~> 3.3.5)
byebug
ckeditor!
coffee-rails (~> 4.1.0)
devise
jbuilder (~> 2.0)
jquery-rails
paperclip
quiet_assets
rails (= 4.2.5)
sass-rails (~> 5.0)
Expand Down
Binary file removed app/assets/images/index_background.png
Binary file not shown.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require ckeditor/init
3 changes: 2 additions & 1 deletion app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
*= require_tree .
*= require_self
*/



6 changes: 5 additions & 1 deletion app/assets/stylesheets/notice.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
font-size: 15px;
background-color: rgba(58, 64, 136, 0.49);
border-radius: 3px;
}
}

a {
color: rgb(6, 6, 6);
}
20 changes: 19 additions & 1 deletion app/controllers/freeboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,29 @@ def index
@freeboard = Freeboard.all
end

def new
def show
@freeboard = Freeboard.find(params[:id])
end

def new
@freeboard = Freeboard.new
end

def create
@freeboard = Freeboard.new(freeboard_params)

if @freeboard.save
flash[:notice] = "글이 작성되었습니다."
redirect_to freeboard_path(@freeboard)
else
flash[:alert] = '실패'
render 'new'
end
end

private

def freeboard_params
params.require(:freeboard).permit(:title, :content, :author)
end
end
6 changes: 4 additions & 2 deletions app/controllers/index_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class IndexController < ApplicationController

def index
@post = Post.all
end
@post = Post.all.last(5)
@freeboard = Freeboard.all.last(5)
end

end
2 changes: 1 addition & 1 deletion app/controllers/notice_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create
end

def show
@post = Post.all
@post = Post.find(params[:id])
end

def update
Expand Down
4 changes: 4 additions & 0 deletions app/models/ckeditor/asset.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Ckeditor::Asset < ActiveRecord::Base
include Ckeditor::Orm::ActiveRecord::AssetBase
include Ckeditor::Backend::Paperclip
end
13 changes: 13 additions & 0 deletions app/models/ckeditor/attachment_file.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Ckeditor::AttachmentFile < Ckeditor::Asset
has_attached_file :data,
:url => "/ckeditor_assets/attachments/:id/:filename",
:path => ":rails_root/public/ckeditor_assets/attachments/:id/:filename"

validates_attachment_presence :data
validates_attachment_size :data, :less_than => 100.megabytes
do_not_validate_attachment_file_type :data

def url_thumb
@url_thumb ||= Ckeditor::Utils.filethumb(filename)
end
end
14 changes: 14 additions & 0 deletions app/models/ckeditor/picture.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Ckeditor::Picture < Ckeditor::Asset
has_attached_file :data,
:url => "/ckeditor_assets/pictures/:id/:style_:basename.:extension",
:path => ":rails_root/public/ckeditor_assets/pictures/:id/:style_:basename.:extension",
:styles => { :content => '800>', :thumb => '118x100#' }

validates_attachment_presence :data
validates_attachment_size :data, :less_than => 2.megabytes
validates_attachment_content_type :data, :content_type => /\Aimage/

def url_content
url(:content)
end
end
53 changes: 32 additions & 21 deletions app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
<h2>Log in</h2>
<div class="row">
<div class="col-md-2"></div>

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>

<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="col-md-8">
<h2>로그인</h2>
<%= form_for(resource, :html => {:class => 'form-horizontal'}, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="form-group">
<%= f.label :email, :class => "col-sm-2 control-label", for: "email" %>
<div class="col-sm-10">
<%= f.email_field :email, autofocus: true, id:"inputEmail3" , :class => "form-control", placeholder: "이메일" %>
</div>
</div>

<% if devise_mapping.rememberable? -%>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
<div class="form-group">
<%= f.label :password, :class => "col-sm-2 control-label", for: "password" %>
<div class="col-sm-10">
<%= f.password_field :password, autocomplete: "off", :class => "form-control", placeholder: "비밀번호" %>
</div>
</div>
<% end -%>

<div class="actions">
<%= f.submit "Log in" %>
<% if devise_mapping.rememberable? -%>
<div class="form-group">
<%= f.check_box :remember_me%>
<%= f.label :remember_me ,:class => "col-sm-2 control-label"%>
</div>
<% end %>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="actions">
<%= f.submit("로그인",:class => "btn btn-default") %>
</div>
</div>
</div>
<% end %>
</div>
<% end %>

<%= render "devise/shared/links" %>
<div class="col-md-2"> </div>
</div>
11 changes: 5 additions & 6 deletions app/views/freeboard/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<div style="padding:50px;"> </div>
<div style="padding:20px;"> </div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<table class="table">

<div class="panel panel-default">
<div class="panel-body">
자유 게시판
<div class="panel-body" style="font-size:20px;">
자유 게시판
</div>
</div>
</div>

<!-- <caption class="NoticeAll"> 전체 공지 </caption> -->
<thead>
Expand All @@ -22,7 +21,7 @@
<% @freeboard.reverse.each do |p| %>
<tr>
<th scope="row"><%= p.id %></th>
<td> <%= link_to "#{p.title}", notice_path(p.id) %> </td>
<td> <%= link_to "#{p.title}", freeboard_path(p.id) %> </td>
<td> <%= p.author %> </td>
<td> <%= p.updated_at %> </td>
</tr>
Expand Down
7 changes: 7 additions & 0 deletions app/views/freeboard/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%= form_for @freeboard, class: "form-control", url: {action: "create"} do |f| %>
<%= f.text_field :title , class: "form-control", placeholder: "타이틀", :required => true, autofocus: true %>
<%= f.text_field :author, class: "form-control", placeholder: "작성자" %>
<!-- <%= f.text_area :content, size: "25x4" , class: "form-control" , placeholder: "내용" %> -->
<%= f.cktext_area :content, rows: 10 %>
<%= f.submit "제출", class: "btn btn-default" %>
<% end %>
10 changes: 10 additions & 0 deletions app/views/freeboard/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% if flash[:notice] %>
<div class="notice">
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<%= flash[:notice] %>
</div>
</div>
<% end %>
13 changes: 6 additions & 7 deletions app/views/index/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- <div style="margin:80px"> </div> -->
<!--
<!--
<div class="jumbotron" id="MainJumbotron">
<h2> 원광대학교 컴퓨터공학과 </h2>
<p><a class="btn btn-primary btn-lg" href="#" role="button">가입하기</a></p>
Expand Down Expand Up @@ -65,7 +65,7 @@
</tr>
<% end %>
</tbody>
</table>
</table>
</div>
<div class="col-xs-12 col-md-6">
<div class="well well-sm">
Expand All @@ -81,7 +81,7 @@
</tr>
</thead>
<tbody>
<% @post.reverse.each do |p| %>
<% @freeboard.reverse.each do |p| %>
<tr>
<th scope="row"> <%= p.id %> </th>
<td> <%= p.title %> </td>
Expand All @@ -90,11 +90,11 @@
</tr>
<% end %>
</tbody>
</table>
</table>
</div>
</div>

<!--
<!--
<div class="row">
<div class="col-xs-6 col-sm-4"></div>
<div class="col-xs-6 col-sm-4">
Expand All @@ -117,8 +117,7 @@
</tr>
<% end %>
</tbody>
</table>
</table>
</div>
<div class="col-xs-6 col-sm-4"></div>
</div> -->

Loading

0 comments on commit af42836

Please sign in to comment.