finish renaming pages to posts
This commit is contained in:
parent
ed8e3a93ad
commit
981048098a
@ -1,19 +1,19 @@
|
|||||||
class BlogController < ApplicationController
|
class BlogController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@pages = Page.pages
|
@posts = Post.posts
|
||||||
end
|
end
|
||||||
|
|
||||||
def page
|
def post
|
||||||
title = params[:title]
|
title = params[:title]
|
||||||
return redirect_to(root_path) unless title
|
return redirect_to(root_path) unless title
|
||||||
@page = get_page(title)
|
@post = get_post(title)
|
||||||
return redirect_to(root_path) unless @page
|
return redirect_to(root_path) unless @post
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_page(title)
|
def get_post(title)
|
||||||
page = Page.pages[title]
|
post = Post.posts[title]
|
||||||
#puts "No #{title} in #{Page.pages.keys.join(':')}"
|
#puts "No #{title} in #{Post.posts.keys.join(':')}"
|
||||||
page
|
post
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
9
app/views/blog/index.haml
Normal file
9
app/views/blog/index.haml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
.blog.blog_index
|
||||||
|
- @pages.each do |slug , page|
|
||||||
|
.row
|
||||||
|
.col-md-2
|
||||||
|
.col-md-8
|
||||||
|
%h2= link_to page.title , blog_page_url(page.slug)
|
||||||
|
= render( page.template_name )[0 ... 350].html_safe
|
||||||
|
%span.whole= link_to ". . . .Read whole post" , blog_page_url(page.slug)
|
||||||
|
.col-md-2
|
16
app/views/blog/post.haml
Normal file
16
app/views/blog/post.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
.social_box
|
||||||
|
.social
|
||||||
|
.social__item
|
||||||
|
%span.fa.icon-facebook{"data-count" => "", "data-social" => "fb"}
|
||||||
|
.social__item
|
||||||
|
%span.fa.icon-twitter{"data-count" => "", "data-social" => "tw"}
|
||||||
|
.social__item
|
||||||
|
%span.fa.icon-linkedin{"data-count" => "", "data-social" => "ln"}
|
||||||
|
.social__item
|
||||||
|
%span.fa.icon-gplus{"data-count" => "", "data-social" => "gp"}
|
||||||
|
|
||||||
|
.blog
|
||||||
|
.center_col
|
||||||
|
%h1= @post.title
|
||||||
|
.center_col
|
||||||
|
= render( @post.template_name )
|
@ -26,9 +26,9 @@
|
|||||||
%li
|
%li
|
||||||
%a{:href => "/project/motivation.html"} About
|
%a{:href => "/project/motivation.html"} About
|
||||||
%li
|
%li
|
||||||
%a{:href => "{{site.posts.first.url}}"} News
|
= link_to "News" , blog_post_url(Post.posts.keys.first)
|
||||||
%a{:href => "https://github.com/ruby-x"}
|
=link_to "https://github.com/ruby-x" do
|
||||||
%img{:alt => "Logo", :src => "/assets/images/x-small.png", :style => "position: absolute; top: 15px; right: 15px; border: 0; width: 70px"}/
|
=image_tag "x-small.png", style: "position: absolute; top: 15px; right: 15px; border: 0; width: 70px"
|
||||||
.container
|
.container
|
||||||
= yield
|
= yield
|
||||||
%footer
|
%footer
|
||||||
|
@ -3,6 +3,6 @@ Rails.application.routes.draw do
|
|||||||
root to: 'high_voltage/pages#show' , id: 'index'
|
root to: 'high_voltage/pages#show' , id: 'index'
|
||||||
|
|
||||||
get "/blog" , to: "blog#index" , as: :blog_index
|
get "/blog" , to: "blog#index" , as: :blog_index
|
||||||
get "/blog/*title" , to: "blog#page" , as: :blog_page
|
get "/blog/*title" , to: "blog#post" , as: :blog_post
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user