Skip to content

Instantly share code, notes, and snippets.

@minikomi
Created April 19, 2011 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minikomi/928304 to your computer and use it in GitHub Desktop.
Save minikomi/928304 to your computer and use it in GitHub Desktop.
フレームワークを作る。
s - "script"
d - "database"
e - "template"
c - "css"
padrino g project blog -s jquery -d activerecord -e haml -c sass
cd blog
bundle install
Modelを作る
padrino g model Post title:string body:text date:datetime
DBを立ち上げる
padrino rake ar:create
padrino rake ar:migrate
Adminを作る (email, pw を入れる)
padrino g admin
padrino rake ar:migrate
padrino rake seed
padrino g admin_page post
下記のファイルを作ってください!
# app/views/layouts/application.haml
!!!
%head
%link{:href => "/main.css", :rel=> "stylesheet", :type => "text/css"}
%title
Blog
%body
=yield
# app/controllers/controllers.rb
Blog.controller do
get '/main.css' do
content_type 'text/css', :charset => 'utf-8'
sass :main
end
get '/' do
@posts = Post.all
render :index
end
end
そして、Root folderから
padrino start
http://localhost:3000/admin -> login
Post -> New -> なんか書く (Date = 19/4/2011とか。。)
http://localhost:3000/ -> Blog を みる
# app/views/index.haml
#h1
Awesome Blog
- @posts.each do |post|
.post
%h2
= post.title
Posted:
%h3
= "#{post.date.day} / #{post.date.month} / #{post.date.year}"
.body
= post.body
# app/views/main.sass
body
background: #fefefe
font-size: 120%
font-color: #222222
#h1
font-size: 600%
text-align: center
.post
width: 500px
margin-left: auto
margin-right: auto
border: 6px solid #bbb
padding: 10px
h2
font: Georgia
font-size: 1.2em
line-height: 1em
margin: 0
h3
display: inline
font: Georgia
size: 0.8em
font-weight: bold
.body
font-size: 0.8em
font: Helvetica, sans-serif
border-top: 1px solid #bbb
padding: 10px
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment