From c143b5bbd04c441428220ccf3b5aa30698c60cb8 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 10 Apr 2018 22:48:23 +0300 Subject: [PATCH] fix blog index and links --- app/controllers/concerns/.keep | 0 app/helpers/application_helper.rb | 7 +++++++ app/views/blog/index.haml | 8 ++++---- app/views/pages/index.html.haml | 15 +++++---------- .../_2017-9-5-more-types-will-come-but-later.haml | 9 +++++---- 5 files changed, 21 insertions(+), 18 deletions(-) delete mode 100644 app/controllers/concerns/.keep diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..84dbf31 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,9 @@ module ApplicationHelper + def post_link(index) + post = Post.posts.values[index] + return "" unless post + link = post.date.to_s + " " + link += link_to( post.title , blog_post_url(post.slug)) + link.html_safe + end end diff --git a/app/views/blog/index.haml b/app/views/blog/index.haml index 8d315ad..59a6da4 100644 --- a/app/views/blog/index.haml +++ b/app/views/blog/index.haml @@ -1,9 +1,9 @@ .blog.blog_index - - @pages.each do |slug , page| + - @posts.each do |slug , post| .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) + %h2= link_to post.title , blog_post_url(post.slug) + = render( "posts/#{post.template_name}" )[0 ... 350].html_safe + %span.whole= link_to ". . . .Read whole post" , blog_post_url(post.slug) .col-md-2 diff --git a/app/views/pages/index.html.haml b/app/views/pages/index.html.haml index c4a7a72..de71172 100644 --- a/app/views/pages/index.html.haml +++ b/app/views/pages/index.html.haml @@ -77,13 +77,8 @@ %a{:href => "https://groups.google.com/forum/#!forum/ruby-x"} mail %h2.center News %p - Last but not least, i try to get recent developments down on paper when they are still fresh. - %p - {{ site.posts[0].date | date: "%d.%m.%y" }}: - %a{:href => "{{ site.posts[0].url }}"} {{ site.posts[0].title }} - %p - {{ site.posts[1].date | date: "%d.%m.%y" }}: - %a{:href => "{{ site.posts[1].url }}"} {{ site.posts[1].title }} - %p - {{ site.posts[2].date | date: "%d.%m.%y" }}: - %a{:href => "{{ site.posts[2].url }}"} {{ site.posts[2].title }} + Last but not least, i try to get recent developments down on paper when they are + still fresh. + %p=post_link(0) + %p=post_link(1) + %p=post_link(2) diff --git a/app/views/posts/_2017-9-5-more-types-will-come-but-later.haml b/app/views/posts/_2017-9-5-more-types-will-come-but-later.haml index 7bc2ca6..e7c915b 100644 --- a/app/views/posts/_2017-9-5-more-types-will-come-but-later.haml +++ b/app/views/posts/_2017-9-5-more-types-will-come-but-later.haml @@ -7,10 +7,11 @@ The %a{:href => "/rubyx/layers.html"} architecture document outlines this in more detail, but in short: - \- types are immutable - \- every object has a type (which may change) - \- a type implements the interface of a class at a given time - \- a type is defined by a list of attribute names + %ul + %li types are immutable + %li every object has a type (which may change) + %li a type implements the interface of a class at a given time + %li a type is defined by a list of attribute names %p %img{:alt => "Types diagram", :src => "/assets/types.jpg"}/ %h3#how-classes-work How classes work