From ffcc44d1a73ae1191e835fa625f2f8a7e3e25bda Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 11 Oct 2023 10:31:33 -0400 Subject: Blogs list is now main page (with pagination) --- app/assets/stylesheets/main/entries.scss | 3 --- app/assets/stylesheets/main/layout.scss | 1 + app/controllers/blogs_controller.rb | 9 +++++++++ app/views/blogs/index.atom.builder | 15 +++++++++++++++ app/views/blogs/index.html.haml | 3 +++ 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 app/views/blogs/index.atom.builder create mode 100644 app/views/blogs/index.html.haml (limited to 'app') diff --git a/app/assets/stylesheets/main/entries.scss b/app/assets/stylesheets/main/entries.scss index b2832e4..1b2d1c6 100644 --- a/app/assets/stylesheets/main/entries.scss +++ b/app/assets/stylesheets/main/entries.scss @@ -2,9 +2,6 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ -@import url('https://fonts.googleapis.com/css?family=Slabo+27px'); -@import url('https://fonts.googleapis.com/css?family=Roboto:400,700'); - #blog-post { font-size: 16px; line-height: 24px; diff --git a/app/assets/stylesheets/main/layout.scss b/app/assets/stylesheets/main/layout.scss index 180d1c7..5aa5095 100644 --- a/app/assets/stylesheets/main/layout.scss +++ b/app/assets/stylesheets/main/layout.scss @@ -186,6 +186,7 @@ blockquote.bubble.bottom::after { .breadcrumb { margin-left: 1em; + margin-bottom: 1em; a, a:visited { color: #555d66; diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 8ee472e..eda1bbb 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -1,5 +1,14 @@ class BlogsController < ApplicationController + def index + @blogs = Blog.where(published: true).order(published_at: :desc).paginate(page: params[:page], per_page: 10) + + respond_to do |format| + format.html + format.atom + end + end + def show @blog = Blog.find_by_slug(params[:slug]) diff --git a/app/views/blogs/index.atom.builder b/app/views/blogs/index.atom.builder new file mode 100644 index 0000000..dd498c8 --- /dev/null +++ b/app/views/blogs/index.atom.builder @@ -0,0 +1,15 @@ +atom_feed do |feed| + feed.title("Four Island") + feed.updated(@blogs[0].published_at) if @blogs.length > 0 + + @blogs.each do |blog| + feed.entry(blog) do |entry| + entry.title(blog.title) + entry.content(blog.body, type: 'html') + + entry.author do |author| + author.name("hatkirby") + end + end + end +end diff --git a/app/views/blogs/index.html.haml b/app/views/blogs/index.html.haml new file mode 100644 index 0000000..a1ad64c --- /dev/null +++ b/app/views/blogs/index.html.haml @@ -0,0 +1,3 @@ +- @blogs.each do |blog| + = render blog += will_paginate @blogs -- cgit 1.4.1