diff --git a/app/controllers/blog_controller.rb b/app/controllers/blog_controller.rb index 1d708e0..bdc7b55 100644 --- a/app/controllers/blog_controller.rb +++ b/app/controllers/blog_controller.rb @@ -1,19 +1,19 @@ class BlogController < ApplicationController def index - @pages = Page.pages + @posts = Post.posts end - def page + def post title = params[:title] return redirect_to(root_path) unless title - @page = get_page(title) - return redirect_to(root_path) unless @page + @post = get_post(title) + return redirect_to(root_path) unless @post end - def get_page(title) - page = Page.pages[title] - #puts "No #{title} in #{Page.pages.keys.join(':')}" - page + def get_post(title) + post = Post.posts[title] + #puts "No #{title} in #{Post.posts.keys.join(':')}" + post end end diff --git a/app/views/blog/index.haml b/app/views/blog/index.haml new file mode 100644 index 0000000..8d315ad --- /dev/null +++ b/app/views/blog/index.haml @@ -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 diff --git a/app/views/blog/post.haml b/app/views/blog/post.haml new file mode 100644 index 0000000..86ed2a7 --- /dev/null +++ b/app/views/blog/post.haml @@ -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 ) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index c658e11..e661533 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -26,9 +26,9 @@ %li %a{:href => "/project/motivation.html"} About %li - %a{:href => "{{site.posts.first.url}}"} News - %a{:href => "https://github.com/ruby-x"} - %img{:alt => "Logo", :src => "/assets/images/x-small.png", :style => "position: absolute; top: 15px; right: 15px; border: 0; width: 70px"}/ + = link_to "News" , blog_post_url(Post.posts.keys.first) + =link_to "https://github.com/ruby-x" do + =image_tag "x-small.png", style: "position: absolute; top: 15px; right: 15px; border: 0; width: 70px" .container = yield %footer diff --git a/config/routes.rb b/config/routes.rb index fcb59bc..5dfccda 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,6 @@ Rails.application.routes.draw do root to: 'high_voltage/pages#show' , id: '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