diff --git a/Gemfile b/Gemfile index a8f3e2b..3e950f5 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,7 @@ gem 'thredded', '~> 1.0' gem "simple_form" , "5.1.0" gem "simple_form_tailwind_css" gem 'kaminari' +gem 'ransack' gem "passenger" , "6.0.15" , require: "phusion_passenger/rack_handler" gem "bootsnap", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 48d4796..99efdb2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -306,6 +306,10 @@ GEM thor (~> 1.0) zeitwerk (~> 2.5) rake (13.0.6) + ransack (3.2.1) + activerecord (>= 6.1.5) + activesupport (>= 6.1.5) + i18n rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) @@ -429,6 +433,7 @@ DEPENDENCIES pg (~> 1.1) pundit (~> 2.3) rails (~> 7.0) + ransack ruby2js! sassc-rails selenium-webdriver diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index a666c9f..91b684d 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -2,7 +2,9 @@ class StoriesController < ApplicationController before_action :set_story, only: %i[ show edit update destroy ] def index - @stories = Story.all.page params[:page] + @q = Story.ransack(params[:q]) + @q.sorts = 'created_at desc' if @q.sorts.empty? + @stories = @q.result(distinct: true).page( params[:page]) end def show diff --git a/app/views/layouts/_footer.haml b/app/views/layouts/_footer.haml index 9c05895..f9df47b 100644 --- a/app/views/layouts/_footer.haml +++ b/app/views/layouts/_footer.haml @@ -9,27 +9,33 @@ %nav.mt-6{"aria-label" => "Footer Navigation - Services"} %ul.space-y-4.text-sm %li - %a.text-gray-700.transition.hover:opacity-75{:href => "/local"} + %a.text-gray-700.transition.hover:opacity-75{:href => "/local_area"} Local Area %li - %a.text-gray-700.transition.hover:opacity-75{:href => "/helsinki"} + %a.text-gray-700.transition.hover:opacity-75{:href => "/helsinki_turku"} Helsinki & Turkku %li - %a.text-gray-700.transition.hover:opacity-75{:href => "/other_sites"} - Other Sites + %a.text-gray-700.transition.hover:opacity-75{:href => "/in_summer"} + In Summer + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "/in_winter"} + In Winter .col-span-2.sm:col-span-1 %p.font-medium.text-gray-900 Information %nav.mt-6{"aria-label" => "Footer Navigation - Hub Feenix"} %ul.space-y-4.text-sm %li %a.text-gray-700.transition.hover:opacity-75{:href => "/info"} - Info + Living @ Feenix Info + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "/the_deal"} + About Volunteeing %li %a.text-gray-700.transition.hover:opacity-75{:href => "/arriving"} - Arriving + Getting here %li %a.text-gray-700.transition.hover:opacity-75{:href => "/about"} - About + About Hub Feenix .col-span-2.sm:col-span-1 %p.font-medium.text-gray-900 People %nav.mt-6{"aria-label" => "Footer Navigation - Hub Feenix"} diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml index e487f79..9aa533a 100644 --- a/app/views/layouts/application.haml +++ b/app/views/layouts/application.haml @@ -32,7 +32,7 @@ - if false %script{:src => "https://cdn.tailwindcss.com"} - %body.max-w-screen-2xl.xl:mx-auto + %body.xl:mx-auto{class: "max-w-[1920px]"} = render "layouts/header" = render "layouts/messages" = yield diff --git a/app/views/stories/index.html.haml b/app/views/stories/index.html.haml index 7b9d194..d192696 100644 --- a/app/views/stories/index.html.haml +++ b/app/views/stories/index.html.haml @@ -1,4 +1,10 @@ = paginate @stories + +.flex.justify-end + = sort_link(@q, :happened ,class: 'flex flex-nowrap text-md') + .border-r-4.mx-4 + = sort_link(@q, :created_at , class: 'flex flex-nowrap text-md') + - @stories.each do |story| = render_story(story) diff --git a/config/deploy.rb b/config/deploy.rb index c2d65be..f765f35 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -9,6 +9,7 @@ require 'mina/rbenv' # for rbenv support. (https://rbenv.org) # branch - Branch name to deploy. (needed by mina/git) set :application_name, 'volunteers' +#set :domain, 'www.rubydesign.fi' set :domain, '192.168.129.10' set :deploy_to, '/home/feenix/volunteers' set :repository, "https://github.com/HubFeenixMakers/volunteers.git" diff --git a/config/initializers/ransack.rb b/config/initializers/ransack.rb new file mode 100644 index 0000000..89e412c --- /dev/null +++ b/config/initializers/ransack.rb @@ -0,0 +1,18 @@ +require "ransack" + +Ransack.configure do |config| + + config.custom_arrows = { + up_arrow: '
', + down_arrow: '', + } + # Change default search parameter key name. + # Default key name is :q + config.search_key = :q + + # Raise errors if a query contains an unknown predicate or attribute. + # Default is true (do not raise error on unknown conditions). + config.ignore_unknown_conditions = false + + config.hide_sort_order_indicators = false +end diff --git a/config/tailwind.config.js b/config/tailwind.config.js index 4944cb3..6a389a2 100644 --- a/config/tailwind.config.js +++ b/config/tailwind.config.js @@ -11,6 +11,7 @@ module.exports = { content: [ './public/*.html', './app/helpers/**/*.rb', + './config/initializers/**/*.rb', './app/javascript/**/*.js', './app/views/**/*.{erb,haml,html,slim}' , fullname , fullname2