diff --git a/Gemfile b/Gemfile index 6ad5dfa..02197e5 100644 --- a/Gemfile +++ b/Gemfile @@ -23,8 +23,8 @@ gem "simple_form" , "5.1.0" gem "simple_form_tailwind_css" gem 'kaminari' -gem "merged" , git: "https://github.com/HubFeenixMakers/merged" -#gem "merged" , path: "../merged" +#gem "merged" , git: "https://github.com/HubFeenixMakers/merged" +gem "merged" , path: "../merged" gem "passenger" , require: "phusion_passenger/rack_handler" @@ -49,3 +49,5 @@ group :test do gem "selenium-webdriver" gem "webdrivers" end + +gem "pundit", "~> 2.3" diff --git a/Gemfile.lock b/Gemfile.lock index 9ddda49..a66048e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,14 @@ GIT - remote: https://github.com/HubFeenixMakers/merged - revision: a8f5229935e22f5aa8092647ec8c610477bdaa98 + remote: https://github.com/ruby2js/ruby2js/ + revision: f204f4e8f14cde6e4d4c6aafc55251a8d488a78d + branch: haml_fix + specs: + ruby2js (5.0.1) + parser + regexp_parser (~> 2.1.1) + +PATH + remote: ../merged specs: merged (0.1.0) active_hash @@ -11,15 +19,6 @@ GIT redcarpet ruby2js (~> 5.0, >= 5.0.1) -GIT - remote: https://github.com/ruby2js/ruby2js/ - revision: f204f4e8f14cde6e4d4c6aafc55251a8d488a78d - branch: haml_fix - specs: - ruby2js (5.0.1) - parser - regexp_parser (~> 2.1.1) - GEM remote: https://rubygems.org/ specs: @@ -144,7 +143,7 @@ GEM formatador (1.1.0) friendly_id (5.5.0) activerecord (>= 4.0.0) - git (1.13.0) + git (1.13.1) addressable (~> 2.8) rchardet (~> 1.8) globalid (1.0.0) @@ -427,6 +426,7 @@ DEPENDENCIES mina passenger pg (~> 1.1) + pundit (~> 2.3) rails (~> 7.0) ruby2js! sassc-rails diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b13688d..b9887bf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,9 +1,18 @@ class ApplicationController < ActionController::Base before_action :configure_permitted_parameters, if: :devise_controller? - protected + include Pundit::Authorization + alias :current_user :current_member + rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized - def configure_permitted_parameters - devise_parameter_sanitizer.permit(:sign_up, keys: [:name]) - end + protected + + def configure_permitted_parameters + devise_parameter_sanitizer.permit(:sign_up, keys: [:name]) + end + + def user_not_authorized + flash[:alert] = "You are not authorized to perform this action." + redirect_back(fallback_location: root_path) + end end diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 6af667e..fdf670d 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -17,6 +17,7 @@ class StoriesController < ApplicationController # GET /stories/1/edit def edit + authorize @story end # POST /stories diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb new file mode 100644 index 0000000..0b2edd4 --- /dev/null +++ b/app/policies/application_policy.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +class ApplicationPolicy + attr_reader :member, :record + + def initialize(member, record) + @member = member + @record = record + end + + def index? + false + end + + def show? + false + end + + def create? + false + end + + def new? + create? + end + + def update? + false + end + + def edit? + update? + end + + def destroy? + false + end + + class Scope + def initialize(member, scope) + @member = member + @scope = scope + end + + def resolve + raise NotImplementedError, "You must define #resolve in #{self.class}" + end + + private + + attr_reader :member, :scope + end +end diff --git a/app/policies/story_policy.rb b/app/policies/story_policy.rb new file mode 100644 index 0000000..53b3bb4 --- /dev/null +++ b/app/policies/story_policy.rb @@ -0,0 +1,9 @@ +class StoryPolicy < ApplicationPolicy + + def edit? + (member == record.member) or member.admin? + end + alias :update? :edit? + alias :destroy? :edit? + +end diff --git a/app/views/app/views/active_storage/blobs/_blob.html.erb b/app/views/app/views/active_storage/blobs/_blob.html.erb deleted file mode 100644 index e69de29..0000000 diff --git a/app/views/home/torsten/code/hubfeenix.fi b/app/views/home/torsten/code/hubfeenix.fi deleted file mode 100644 index e69de29..0000000 diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml index 094293f..5eecd05 100644 --- a/app/views/layouts/application.haml +++ b/app/views/layouts/application.haml @@ -4,6 +4,25 @@ %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ %title Hubfeenix Volunteers %meta{:content => "width=device-width,initial-scale=1", :name => "viewport"}/ + // https://www.favicon-generator.org/ + %link{:href => "/apple-icon-57x57.png", :rel => "apple-touch-icon", :sizes => "57x57"}/ + %link{:href => "/apple-icon-60x60.png", :rel => "apple-touch-icon", :sizes => "60x60"}/ + %link{:href => "/apple-icon-72x72.png", :rel => "apple-touch-icon", :sizes => "72x72"}/ + %link{:href => "/apple-icon-76x76.png", :rel => "apple-touch-icon", :sizes => "76x76"}/ + %link{:href => "/apple-icon-114x114.png", :rel => "apple-touch-icon", :sizes => "114x114"}/ + %link{:href => "/apple-icon-120x120.png", :rel => "apple-touch-icon", :sizes => "120x120"}/ + %link{:href => "/apple-icon-144x144.png", :rel => "apple-touch-icon", :sizes => "144x144"}/ + %link{:href => "/apple-icon-152x152.png", :rel => "apple-touch-icon", :sizes => "152x152"}/ + %link{:href => "/apple-icon-180x180.png", :rel => "apple-touch-icon", :sizes => "180x180"}/ + %link{:href => "/android-icon-192x192.png", :rel => "icon", :sizes => "192x192", :type => "image/png"}/ + %link{:href => "/favicon-32x32.png", :rel => "icon", :sizes => "32x32", :type => "image/png"}/ + %link{:href => "/favicon-96x96.png", :rel => "icon", :sizes => "96x96", :type => "image/png"}/ + %link{:href => "/favicon-16x16.png", :rel => "icon", :sizes => "16x16", :type => "image/png"}/ + %link{:href => "/manifest.json", :rel => "manifest"}/ + %meta{:content => "#ffffff", :name => "msapplication-TileColor"}/ + %meta{:content => "/ms-icon-144x144.png", :name => "msapplication-TileImage"}/ + %meta{:content => "#ffffff", :name => "theme-color"}/ + = csrf_meta_tags = csp_meta_tag = stylesheet_link_tag "tailwind" diff --git a/config/deploy.rb b/config/deploy.rb index 3f1f801..c2d65be 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -25,6 +25,8 @@ set :user, 'feenix' # Username in the server to SSH to. set :shared_dirs, fetch(:shared_dirs, []).push('tmp/pids' , 'tmp/sockets' , 'public/uploads') set :shared_files, fetch(:shared_files, []).push('config/master.key') +set :force_migrate , true + # This task is the environment that is loaded for all remote run commands, such as # `mina deploy` or `mina rake`. task :remote_environment do @@ -53,6 +55,7 @@ task :deploy do invoke :'deploy:link_shared_paths' invoke :'bundle:install' invoke :'rails:assets_precompile' + invoke :'rails:db_migrate' invoke :'deploy:cleanup' on :launch do diff --git a/public/android-icon-144x144.png b/public/android-icon-144x144.png new file mode 100644 index 0000000..92bf261 Binary files /dev/null and b/public/android-icon-144x144.png differ diff --git a/public/android-icon-192x192.png b/public/android-icon-192x192.png new file mode 100644 index 0000000..aec9dba Binary files /dev/null and b/public/android-icon-192x192.png differ diff --git a/public/android-icon-36x36.png b/public/android-icon-36x36.png new file mode 100644 index 0000000..a242f9f Binary files /dev/null and b/public/android-icon-36x36.png differ diff --git a/public/android-icon-48x48.png b/public/android-icon-48x48.png new file mode 100644 index 0000000..9eeae81 Binary files /dev/null and b/public/android-icon-48x48.png differ diff --git a/public/android-icon-72x72.png b/public/android-icon-72x72.png new file mode 100644 index 0000000..dba9cf8 Binary files /dev/null and b/public/android-icon-72x72.png differ diff --git a/public/android-icon-96x96.png b/public/android-icon-96x96.png new file mode 100644 index 0000000..048077e Binary files /dev/null and b/public/android-icon-96x96.png differ diff --git a/public/apple-icon-114x114.png b/public/apple-icon-114x114.png new file mode 100644 index 0000000..ad76865 Binary files /dev/null and b/public/apple-icon-114x114.png differ diff --git a/public/apple-icon-120x120.png b/public/apple-icon-120x120.png new file mode 100644 index 0000000..db82dd7 Binary files /dev/null and b/public/apple-icon-120x120.png differ diff --git a/public/apple-icon-144x144.png b/public/apple-icon-144x144.png new file mode 100644 index 0000000..92bf261 Binary files /dev/null and b/public/apple-icon-144x144.png differ diff --git a/public/apple-icon-152x152.png b/public/apple-icon-152x152.png new file mode 100644 index 0000000..6a9895c Binary files /dev/null and b/public/apple-icon-152x152.png differ diff --git a/public/apple-icon-180x180.png b/public/apple-icon-180x180.png new file mode 100644 index 0000000..909d684 Binary files /dev/null and b/public/apple-icon-180x180.png differ diff --git a/public/apple-icon-57x57.png b/public/apple-icon-57x57.png new file mode 100644 index 0000000..b97a3a5 Binary files /dev/null and b/public/apple-icon-57x57.png differ diff --git a/public/apple-icon-60x60.png b/public/apple-icon-60x60.png new file mode 100644 index 0000000..a4337aa Binary files /dev/null and b/public/apple-icon-60x60.png differ diff --git a/public/apple-icon-72x72.png b/public/apple-icon-72x72.png new file mode 100644 index 0000000..dba9cf8 Binary files /dev/null and b/public/apple-icon-72x72.png differ diff --git a/public/apple-icon-76x76.png b/public/apple-icon-76x76.png new file mode 100644 index 0000000..c910811 Binary files /dev/null and b/public/apple-icon-76x76.png differ diff --git a/public/apple-icon-precomposed.png b/public/apple-icon-precomposed.png new file mode 100644 index 0000000..eb8d014 Binary files /dev/null and b/public/apple-icon-precomposed.png differ diff --git a/public/apple-icon.png b/public/apple-icon.png new file mode 100644 index 0000000..eb8d014 Binary files /dev/null and b/public/apple-icon.png differ diff --git a/public/browserconfig.xml b/public/browserconfig.xml new file mode 100644 index 0000000..c554148 --- /dev/null +++ b/public/browserconfig.xml @@ -0,0 +1,2 @@ + +#ffffff \ No newline at end of file diff --git a/public/favicon-16x16.png b/public/favicon-16x16.png new file mode 100644 index 0000000..37c538e Binary files /dev/null and b/public/favicon-16x16.png differ diff --git a/public/favicon-32x32.png b/public/favicon-32x32.png new file mode 100644 index 0000000..4e6ba45 Binary files /dev/null and b/public/favicon-32x32.png differ diff --git a/public/favicon-96x96.png b/public/favicon-96x96.png new file mode 100644 index 0000000..048077e Binary files /dev/null and b/public/favicon-96x96.png differ diff --git a/public/favicon.ico b/public/favicon.ico index e69de29..9ce4ef0 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..013d4a6 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,41 @@ +{ + "name": "App", + "icons": [ + { + "src": "\/android-icon-36x36.png", + "sizes": "36x36", + "type": "image\/png", + "density": "0.75" + }, + { + "src": "\/android-icon-48x48.png", + "sizes": "48x48", + "type": "image\/png", + "density": "1.0" + }, + { + "src": "\/android-icon-72x72.png", + "sizes": "72x72", + "type": "image\/png", + "density": "1.5" + }, + { + "src": "\/android-icon-96x96.png", + "sizes": "96x96", + "type": "image\/png", + "density": "2.0" + }, + { + "src": "\/android-icon-144x144.png", + "sizes": "144x144", + "type": "image\/png", + "density": "3.0" + }, + { + "src": "\/android-icon-192x192.png", + "sizes": "192x192", + "type": "image\/png", + "density": "4.0" + } + ] +} \ No newline at end of file diff --git a/public/ms-icon-144x144.png b/public/ms-icon-144x144.png new file mode 100644 index 0000000..92bf261 Binary files /dev/null and b/public/ms-icon-144x144.png differ diff --git a/public/ms-icon-150x150.png b/public/ms-icon-150x150.png new file mode 100644 index 0000000..4f647b0 Binary files /dev/null and b/public/ms-icon-150x150.png differ diff --git a/public/ms-icon-310x310.png b/public/ms-icon-310x310.png new file mode 100644 index 0000000..80fa9c1 Binary files /dev/null and b/public/ms-icon-310x310.png differ diff --git a/public/ms-icon-70x70.png b/public/ms-icon-70x70.png new file mode 100644 index 0000000..007daf6 Binary files /dev/null and b/public/ms-icon-70x70.png differ diff --git a/storage/.keep b/storage/.keep deleted file mode 100644 index e69de29..0000000