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) --- Gemfile | 1 + Gemfile.lock | 2 ++ 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 +++ config/routes.rb | 3 ++- 8 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 app/views/blogs/index.atom.builder create mode 100644 app/views/blogs/index.html.haml diff --git a/Gemfile b/Gemfile index 46a6dfb..19e4c66 100644 --- a/Gemfile +++ b/Gemfile @@ -77,3 +77,4 @@ gem 'audited', '~> 5.0' gem 'enumerize' gem 'sprockets', '3.7.2' gem 'lingo', git: "https://git.fourisland.com/lingo", glob: "rails/*.gemspec", branch: "main" +gem 'will_paginate', '~> 4.0' diff --git a/Gemfile.lock b/Gemfile.lock index 0a75380..0dbdb61 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -332,6 +332,7 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + will_paginate (4.0.0) xpath (3.2.0) nokogiri (~> 1.8) zeitwerk (2.6.12) @@ -378,6 +379,7 @@ DEPENDENCIES uglifier (>= 1.3.0) web-console (>= 3.3.0) webrick (~> 1.7) + will_paginate (~> 4.0) BUNDLED WITH 2.2.3 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 diff --git a/config/routes.rb b/config/routes.rb index f524cf1..d1d1d35 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -24,8 +24,9 @@ Rails.application.routes.draw do passwords: 'users/passwords' } - root "records#index" + root "blogs#index" + get 'says', to: 'blogs#index' get 'says/:slug', to: 'blogs#show', as: :blog get 'thinks/:slug', to: 'streams#show', as: :stream -- cgit 1.4.1