From d017502f18cc488dd35a8edc07db670d53583d4e Mon Sep 17 00:00:00 2001 From: Torsten Date: Sun, 15 Jan 2023 14:59:06 +0200 Subject: [PATCH] polish teachers --- Gemfile | 1 + Gemfile.lock | 1 + app/controllers/teachers_controller.rb | 2 +- app/helpers/application_helper.rb | 20 ++++++++++++++++++++ app/views/teachers/index.html.haml | 4 +--- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 4c7e8c4..8606aea 100644 --- a/Gemfile +++ b/Gemfile @@ -16,6 +16,7 @@ gem 'html2haml' gem 'devise' gem 'carrierwave', '>= 3.0.0.beta', '< 4.0' +gem 'kaminari' gem "ruby2js" , git: "https://github.com/ruby2js/ruby2js/" , branch: "haml_fix" gem 'thredded', '~> 1.0' gem "rest-client" diff --git a/Gemfile.lock b/Gemfile.lock index be9a1fc..1131449 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -438,6 +438,7 @@ DEPENDENCIES haml-rails html2haml importmap-rails + kaminari merged! mina passenger diff --git a/app/controllers/teachers_controller.rb b/app/controllers/teachers_controller.rb index 6db265e..16f6c40 100644 --- a/app/controllers/teachers_controller.rb +++ b/app/controllers/teachers_controller.rb @@ -3,7 +3,7 @@ class TeachersController < ApplicationController # GET /teachers def index - @teachers = Teacher.all + @teachers = Teacher.page params[:page] end # GET /teachers/1 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index df5818d..ac6e660 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -10,6 +10,17 @@ module ApplicationHelper Redcarpet::Markdown.new(html, options) end + def shorten(text , to = 100) + return "" if text.blank? + "#{text[0..to]} . . . ".html_safe + end + + def prose_classes + classes = "prose lg:prose-lg " + classes += "prose-headings:text-inherit " + { class: classes } + end + def markdown(text) return "" if text.blank? text = text.text unless text.is_a?(String) @@ -25,4 +36,13 @@ module ApplicationHelper "mr-3 inline-block rounded-lg px-3 py-2 text-md font-medium border border-gray-500" end + def image_for(someone , classes = "") + if someone.picture.blank? + image = asset_url("no_image.png") + else + image = someone.picture.url + end + image_tag(image , alt: someone.name , class: classes ) + end + end diff --git a/app/views/teachers/index.html.haml b/app/views/teachers/index.html.haml index f6d1c9a..85e2bff 100644 --- a/app/views/teachers/index.html.haml +++ b/app/views/teachers/index.html.haml @@ -6,10 +6,8 @@ .fex.flex-col.overflow-hidden.rounded-lg.border.border-gray-100.shadow-sm.m-10 =link_to teacher do = image_for( teacher , class: "h-60 w-full object-cover") - %h3.pt-5.text-2xl.bg-gray-100.text-black.font-bold.text-center + %h3.py-5.text-2xl.bg-gray-100.text-black.font-bold.text-center = teacher.name - .p-2.text-xs.bg-gray-50.text-black.font-bold.text-center - = stayed teacher %div.h-full .p-5.text-center .m-2.text-sm.leading-relaxed.line-clamp-3{ prose_classes }