├── _banner
├── log
└── .keep
├── storage
└── .keep
├── tmp
├── .keep
├── pids
│ └── .keep
└── storage
│ └── .keep
├── lib
├── assets
│ └── .keep
├── tasks
│ └── .keep
└── templates
│ └── erb
│ └── scaffold
│ └── _form.html.erb
├── public
├── favicon.ico
├── apple-touch-icon.png
├── apple-touch-icon-precomposed.png
├── robots.txt
├── 500.html
├── 422.html
└── 404.html
├── test
├── helpers
│ └── .keep
├── mailers
│ └── .keep
├── models
│ ├── .keep
│ ├── offer_test.rb
│ ├── user_test.rb
│ ├── comment_test.rb
│ ├── filter_test.rb
│ └── challenge_test.rb
├── system
│ └── .keep
├── controllers
│ ├── .keep
│ ├── offers_controller_test.rb
│ ├── users_controller_test.rb
│ ├── filters_controller_test.rb
│ └── challenges_controller_test.rb
├── integration
│ └── .keep
├── fixtures
│ └── files
│ │ └── .keep
├── application_system_test_case.rb
├── policies
│ ├── offer_policy_test.rb
│ └── challenge_policy_test.rb
├── channels
│ └── application_cable
│ │ └── connection_test.rb
└── test_helper.rb
├── .ruby-version
├── app
├── assets
│ ├── builds
│ │ └── .keep
│ ├── images
│ │ ├── .keep
│ │ ├── logo.png
│ │ ├── newlogo.png
│ │ ├── Socialize.png
│ │ ├── ad-1 (1).jpg
│ │ ├── ad-1 (2).jpg
│ │ ├── ad-1 (3).jpg
│ │ ├── userphoto.jpg
│ │ ├── wallpaper.jpg
│ │ ├── dev-work-icon.png
│ │ ├── dev-work-navbar.png
│ │ └── userphoto_square.jpg
│ ├── stylesheets
│ │ ├── pages
│ │ │ ├── _home.scss
│ │ │ ├── _my_offers.scss
│ │ │ ├── _devise.scss
│ │ │ ├── _show.scss
│ │ │ └── _index.scss
│ │ ├── components
│ │ │ ├── _alert.scss
│ │ │ ├── _button.scss
│ │ │ ├── _map.scss
│ │ │ ├── _footer.scss
│ │ │ ├── _address_autocomplete.scss
│ │ │ ├── _index.scss
│ │ │ ├── _form_legend_clear.scss
│ │ │ ├── _avatar.scss
│ │ │ ├── _banner.scss
│ │ │ └── _sidebar.scss
│ │ ├── config
│ │ │ ├── _colors.scss
│ │ │ ├── _fonts.scss
│ │ │ └── _bootstrap_variables.scss
│ │ └── application.scss
│ └── config
│ │ └── manifest.js
├── models
│ ├── concerns
│ │ └── .keep
│ ├── filter.rb
│ ├── application_record.rb
│ ├── comment.rb
│ ├── offer.rb
│ ├── challenge.rb
│ └── user.rb
├── controllers
│ ├── concerns
│ │ └── .keep
│ ├── filters_controller.rb
│ ├── pages_controller.rb
│ ├── callbacks_controller.rb
│ ├── users_controller.rb
│ ├── registrations_controller.rb
│ ├── offers_controller.rb
│ ├── application_controller.rb
│ └── challenges_controller.rb
├── views
│ ├── shared
│ │ ├── _form.html.erb
│ │ ├── _navbar.html.erb
│ │ ├── _button.html.erb
│ │ ├── _banner.html.erb
│ │ ├── _flashes.html.erb
│ │ ├── _index-cards.html.erb
│ │ ├── _sidebar.html.erb
│ │ └── _footer.html.erb
│ ├── layouts
│ │ ├── mailer.text.erb
│ │ ├── mailer.html.erb
│ │ └── application.html.erb
│ ├── pages
│ │ └── home.html.erb
│ ├── offers
│ │ ├── review.html.erb
│ │ ├── show.html.erb
│ │ └── index.html.erb
│ ├── devise
│ │ ├── mailer
│ │ │ ├── password_change.html.erb
│ │ │ ├── confirmation_instructions.html.erb
│ │ │ ├── unlock_instructions.html.erb
│ │ │ ├── email_changed.html.erb
│ │ │ └── reset_password_instructions.html.erb
│ │ ├── shared
│ │ │ ├── _error_messages.html.erb
│ │ │ └── _links.html.erb
│ │ ├── passwords
│ │ │ ├── new.html.erb
│ │ │ └── edit.html.erb
│ │ ├── unlocks
│ │ │ └── new.html.erb
│ │ ├── confirmations
│ │ │ └── new.html.erb
│ │ ├── sessions
│ │ │ └── new.html.erb
│ │ └── registrations
│ │ │ ├── new.html.erb
│ │ │ └── edit.html.erb
│ └── challenges
│ │ ├── _form.html.erb
│ │ ├── edit.html.erb
│ │ ├── new.html.erb
│ │ ├── _info_window.html.erb
│ │ ├── index.html.erb
│ │ └── show.html.erb
├── helpers
│ └── application_helper.rb
├── channels
│ └── application_cable
│ │ ├── channel.rb
│ │ └── connection.rb
├── mailers
│ └── application_mailer.rb
├── javascript
│ ├── application.js
│ └── controllers
│ │ ├── hello_controller.js
│ │ ├── address_autocomplete_controller.js
│ │ ├── application.js
│ │ ├── sidebar_controller.js
│ │ ├── index.js
│ │ └── map_controller.js
├── jobs
│ └── application_job.rb
└── policies
│ ├── offer_policy.rb
│ ├── challenge_policy.rb
│ └── application_policy.rb
├── Procfile.dev
├── bin
├── rake
├── rails
├── dev
├── setup
└── bundle
├── config
├── environment.rb
├── boot.rb
├── cable.yml
├── initializers
│ ├── filter_parameter_logging.rb
│ ├── permissions_policy.rb
│ ├── assets.rb
│ ├── inflections.rb
│ ├── content_security_policy.rb
│ ├── geocoder.rb
│ ├── simple_form.rb
│ └── simple_form_bootstrap.rb
├── credentials.yml.enc
├── routes.rb
├── application.rb
├── locales
│ ├── simple_form.en.yml
│ ├── en.yml
│ └── devise.en.yml
├── storage.yml
├── puma.rb
├── environments
│ ├── test.rb
│ ├── development.rb
│ └── production.rb
└── database.yml
├── .gitattributes
├── db
├── migrate
│ ├── 20220901113442_add_location.rb
│ ├── 20221003065436_add_admin_to_users.rb
│ ├── 20220831100114_add_image_to_users.rb
│ ├── 20220829135415_add_details_to_filters.rb
│ ├── 20220901152701_add_city_to_challenges.rb
│ ├── 20220905200231_add_content_to_comment.rb
│ ├── 20220930220534_add_offers_to_users.rb
│ ├── 20220829123454_create_users.rb
│ ├── 20220902104452_remove_image_url_from_users.rb
│ ├── 20220905200356_rename_comment_to_content.rb
│ ├── 20220930214131_create_offers.rb
│ ├── 20220829123545_create_filters.rb
│ ├── 20220930220602_add_offers_to_challenges.rb
│ ├── 20220930215302_add_price_to_offers.rb
│ ├── 20220829135339_add_details_to_users.rb
│ ├── 20220928211345_add_omniauth_to_users.rb
│ ├── 20220928221019_add_columns_to_users.rb
│ ├── 20220901112950_addingcoordinates.rb
│ ├── 20220905195945_create_comments.rb
│ ├── 20220829135525_add_details_to_challenges.rb
│ ├── 20220829124023_create_challenges.rb
│ ├── 20220829141529_add_devise_to_users.rb
│ └── 20220831095635_create_active_storage_tables.active_storage.rb
├── schema.rb
└── seeds.rb
├── config.ru
├── Rakefile
├── package.json
├── webpack.config.js
├── README.md
├── .rubocop.yml
├── .gitignore
├── Gemfile
└── Gemfile.lock
/_banner:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/log/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/storage/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tmp/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/helpers/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/mailers/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/models/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/system/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tmp/pids/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tmp/storage/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.ruby-version:
--------------------------------------------------------------------------------
1 | 3.1.2
2 |
--------------------------------------------------------------------------------
/app/assets/builds/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/assets/images/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/controllers/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/integration/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/models/concerns/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/fixtures/files/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/controllers/concerns/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/views/shared/_form.html.erb:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/views/shared/_navbar.html.erb:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/apple-touch-icon-precomposed.png:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.text.erb:
--------------------------------------------------------------------------------
1 | <%= yield %>
2 |
--------------------------------------------------------------------------------
/app/views/pages/home.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <%= render "shared/banner" %>
3 |
--------------------------------------------------------------------------------
/Procfile.dev:
--------------------------------------------------------------------------------
1 | web: bin/rails server -p 3000
2 | js: yarn build --watch
3 |
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/models/filter.rb:
--------------------------------------------------------------------------------
1 | class Filter < ApplicationRecord
2 | has_many :challenges
3 | end
4 |
--------------------------------------------------------------------------------
/app/controllers/filters_controller.rb:
--------------------------------------------------------------------------------
1 | class FiltersController < ApplicationController
2 | end
3 |
--------------------------------------------------------------------------------
/app/assets/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EleoXDA/Dev.Work_RB/HEAD/app/assets/images/logo.png
--------------------------------------------------------------------------------
/app/assets/images/newlogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EleoXDA/Dev.Work_RB/HEAD/app/assets/images/newlogo.png
--------------------------------------------------------------------------------
/app/assets/images/Socialize.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EleoXDA/Dev.Work_RB/HEAD/app/assets/images/Socialize.png
--------------------------------------------------------------------------------
/app/assets/images/ad-1 (1).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EleoXDA/Dev.Work_RB/HEAD/app/assets/images/ad-1 (1).jpg
--------------------------------------------------------------------------------
/app/assets/images/ad-1 (2).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EleoXDA/Dev.Work_RB/HEAD/app/assets/images/ad-1 (2).jpg
--------------------------------------------------------------------------------
/app/assets/images/ad-1 (3).jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EleoXDA/Dev.Work_RB/HEAD/app/assets/images/ad-1 (3).jpg
--------------------------------------------------------------------------------
/app/assets/images/userphoto.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EleoXDA/Dev.Work_RB/HEAD/app/assets/images/userphoto.jpg
--------------------------------------------------------------------------------
/app/assets/images/wallpaper.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EleoXDA/Dev.Work_RB/HEAD/app/assets/images/wallpaper.jpg
--------------------------------------------------------------------------------
/app/controllers/pages_controller.rb:
--------------------------------------------------------------------------------
1 | class PagesController < ApplicationController
2 | def home
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/models/application_record.rb:
--------------------------------------------------------------------------------
1 | class ApplicationRecord < ActiveRecord::Base
2 | primary_abstract_class
3 | end
4 |
--------------------------------------------------------------------------------
/app/models/comment.rb:
--------------------------------------------------------------------------------
1 | class Comment < ApplicationRecord
2 | belongs_to :user
3 | belongs_to :challenge
4 | end
5 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require_relative "../config/boot"
3 | require "rake"
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/pages/_home.scss:
--------------------------------------------------------------------------------
1 | // Specific CSS for your home-page
2 | body{
3 | text-align: center;
4 | }
5 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 |
--------------------------------------------------------------------------------
/app/assets/config/manifest.js:
--------------------------------------------------------------------------------
1 | //= link_tree ../images
2 | //= link_directory ../stylesheets .css
3 | //= link_tree ../builds
4 |
--------------------------------------------------------------------------------
/app/assets/images/dev-work-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EleoXDA/Dev.Work_RB/HEAD/app/assets/images/dev-work-icon.png
--------------------------------------------------------------------------------
/app/assets/images/dev-work-navbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EleoXDA/Dev.Work_RB/HEAD/app/assets/images/dev-work-navbar.png
--------------------------------------------------------------------------------
/app/assets/images/userphoto_square.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EleoXDA/Dev.Work_RB/HEAD/app/assets/images/userphoto_square.jpg
--------------------------------------------------------------------------------
/app/views/shared/_button.html.erb:
--------------------------------------------------------------------------------
1 | Primary link
2 |
--------------------------------------------------------------------------------
/app/channels/application_cable/channel.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Channel < ActionCable::Channel::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/components/_alert.scss:
--------------------------------------------------------------------------------
1 | .alert {
2 | position: fixed;
3 | bottom: 16px;
4 | right: 16px;
5 | z-index: 1000;
6 | }
7 |
--------------------------------------------------------------------------------
/app/channels/application_cable/connection.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Connection < ActionCable::Connection::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/mailers/application_mailer.rb:
--------------------------------------------------------------------------------
1 | class ApplicationMailer < ActionMailer::Base
2 | default from: "from@example.com"
3 | layout "mailer"
4 | end
5 |
--------------------------------------------------------------------------------
/app/views/offers/review.html.erb:
--------------------------------------------------------------------------------
1 | <%= simple_form_for([@challenge, @offer]) do |f| %>
2 | <%= f.input :comment %>
3 | <%= f.submit %>
4 | <% end %>
5 |
--------------------------------------------------------------------------------
/app/models/offer.rb:
--------------------------------------------------------------------------------
1 | class Offer < ApplicationRecord
2 | belongs_to :challenge
3 | belongs_to :user
4 |
5 | validates :date, :price, presence: true
6 | end
7 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_PATH = File.expand_path("../config/application", __dir__)
3 | require_relative "../config/boot"
4 | require "rails/commands"
5 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative "application"
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/test/models/offer_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class OfferTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/test/models/user_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class UserTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # See https://git-scm.com/docs/gitattributes for more about git attribute files.
2 |
3 | db/schema.rb linguist-generated
4 |
5 | vendor/* linguist-vendored
6 |
--------------------------------------------------------------------------------
/app/javascript/application.js:
--------------------------------------------------------------------------------
1 | // Entry point for the build script in your package.json
2 | import "@hotwired/turbo-rails"
3 | import "./controllers"
4 | import "bootstrap"
5 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/password_change.html.erb:
--------------------------------------------------------------------------------
1 |
Hello <%= @resource.email %>!
2 |
3 | We're contacting you to notify you that your password has been changed.
4 |
--------------------------------------------------------------------------------
/test/models/comment_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class CommentTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/test/models/filter_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class FilterTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/db/migrate/20220901113442_add_location.rb:
--------------------------------------------------------------------------------
1 | class AddLocation < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :challenges, :location, :string
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20221003065436_add_admin_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddAdminToUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :users, :admin, :boolean
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/test/models/challenge_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class ChallengeTest < ActiveSupport::TestCase
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/db/migrate/20220831100114_add_image_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddImageToUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :users, :image_url, :string
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require_relative "config/environment"
4 |
5 | run Rails.application
6 | Rails.application.load_server
7 |
--------------------------------------------------------------------------------
/db/migrate/20220829135415_add_details_to_filters.rb:
--------------------------------------------------------------------------------
1 | class AddDetailsToFilters < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :filters, :name, :string
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20220901152701_add_city_to_challenges.rb:
--------------------------------------------------------------------------------
1 | class AddCityToChallenges < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :challenges, :cities, :string
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20220905200231_add_content_to_comment.rb:
--------------------------------------------------------------------------------
1 | class AddContentToComment < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :comments, :comment, :string
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20220930220534_add_offers_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddOffersToUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | add_reference :offers, :user, foreign_key: true
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/bin/dev:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | if ! foreman version &> /dev/null
4 | then
5 | echo "Installing foreman..."
6 | gem install foreman
7 | fi
8 |
9 | foreman start -f Procfile.dev "$@"
10 |
--------------------------------------------------------------------------------
/db/migrate/20220829123454_create_users.rb:
--------------------------------------------------------------------------------
1 | class CreateUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :users do |t|
4 |
5 | t.timestamps
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/db/migrate/20220902104452_remove_image_url_from_users.rb:
--------------------------------------------------------------------------------
1 | class RemoveImageUrlFromUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | remove_column :users, :image_url, :string
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20220905200356_rename_comment_to_content.rb:
--------------------------------------------------------------------------------
1 | class RenameCommentToContent < ActiveRecord::Migration[7.0]
2 | def change
3 | rename_column :comments, :comment, :content
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20220930214131_create_offers.rb:
--------------------------------------------------------------------------------
1 | class CreateOffers < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :offers do |t|
4 |
5 | t.timestamps
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/test/controllers/offers_controller_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class OffersControllerTest < ActionDispatch::IntegrationTest
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/test/controllers/users_controller_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class UsersControllerTest < ActionDispatch::IntegrationTest
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/db/migrate/20220829123545_create_filters.rb:
--------------------------------------------------------------------------------
1 | class CreateFilters < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :filters do |t|
4 |
5 | t.timestamps
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/db/migrate/20220930220602_add_offers_to_challenges.rb:
--------------------------------------------------------------------------------
1 | class AddOffersToChallenges < ActiveRecord::Migration[7.0]
2 | def change
3 | add_reference :offers, :challenge, foreign_key: true
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/test/application_system_test_case.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
4 | driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
5 | end
6 |
--------------------------------------------------------------------------------
/test/controllers/filters_controller_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class FiltersControllerTest < ActionDispatch::IntegrationTest
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/test/controllers/challenges_controller_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class ChallengesControllerTest < ActionDispatch::IntegrationTest
4 | # test "the truth" do
5 | # assert true
6 | # end
7 | end
8 |
--------------------------------------------------------------------------------
/db/migrate/20220930215302_add_price_to_offers.rb:
--------------------------------------------------------------------------------
1 | class AddPriceToOffers < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :offers, :price, :integer
4 | add_column :offers, :date, :date
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/app/javascript/controllers/hello_controller.js:
--------------------------------------------------------------------------------
1 | import { Controller } from "@hotwired/stimulus"
2 |
3 | export default class extends Controller {
4 | connect() {
5 | this.element.textContent = "Hello World!"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/db/migrate/20220829135339_add_details_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddDetailsToUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :users, :nickname, :string
4 | add_column :users, :name, :string
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/db/migrate/20220928211345_add_omniauth_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddOmniauthToUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :users, :provider, :string
4 | add_column :users, :uid, :string
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/db/migrate/20220928221019_add_columns_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddColumnsToUsers < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :users, :image, :string
4 | add_column :users, :html_url, :string
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2 |
3 | require "bundler/setup" # Set up gems listed in the Gemfile.
4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations.
5 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/components/_button.scss:
--------------------------------------------------------------------------------
1 | #button{
2 | color: orange;
3 | background-color: black;
4 | border-radius: 15px !important;
5 | }
6 | #button:hover{
7 | color: white;
8 | background-color: #03194e;
9 | }
10 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/components/_map.scss:
--------------------------------------------------------------------------------
1 | .mapboxgl-popup {
2 | max-width: 200px;
3 | }
4 |
5 | .mapboxgl-popup-content {
6 | text-align: center;
7 | font-family: "Open Sans", sans-serif;
8 | width:fit-content;
9 | }
10 |
--------------------------------------------------------------------------------
/db/migrate/20220901112950_addingcoordinates.rb:
--------------------------------------------------------------------------------
1 | class Addingcoordinates < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :challenges, :latitude, :float
4 | add_column :challenges, :longitude, :float
5 |
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/components/_footer.scss:
--------------------------------------------------------------------------------
1 | .footer {
2 | background-color: rgba($color: #ffffff, $alpha: 0.5);
3 | color: #00000099;
4 | text-decoration:none !important;
5 | &-a{
6 | text-decoration:none !important;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/components/_address_autocomplete.scss:
--------------------------------------------------------------------------------
1 | .mapboxgl-ctrl-geocoder {
2 | max-width: none;
3 | width: 100%;
4 | border: 1px solid lightgrey;
5 | box-shadow: none;
6 | background-color: rgba($color: #ffffff, $alpha: 0.5);
7 | }
8 |
--------------------------------------------------------------------------------
/app/javascript/controllers/address_autocomplete_controller.js:
--------------------------------------------------------------------------------
1 | import { Controller } from "@hotwired/stimulus"
2 |
3 | // Connects to data-controller="address-autocomplete"
4 | export default class extends Controller {
5 | connect() {
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: test
6 |
7 | production:
8 | adapter: redis
9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10 | channel_prefix: DevWork_Production
11 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | # Add your own tasks in files placed in lib/tasks ending in .rake,
2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3 |
4 | require_relative "config/application"
5 |
6 | Rails.application.load_tasks
7 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/config/_colors.scss:
--------------------------------------------------------------------------------
1 | // Define variables for your color scheme
2 |
3 | // For example:
4 | $red: #FD1015;
5 | $blue: #0c51b9;
6 | $yellow: #FFC65A;
7 | $orange: #c46512;
8 | $green: #1EDD88;
9 | $gray: #0E0000;
10 | $light-gray: #F4F4F4;
11 |
--------------------------------------------------------------------------------
/app/views/challenges/_form.html.erb:
--------------------------------------------------------------------------------
1 | <%= f.input :address,
2 | input_html: {data: {address_autocomplete_target: "address"}, class: "d-none"},
3 | wrapper_html: {data: {controller: "address-autocomplete", address_autocomplete_api_key_value: ENV["MAPBOX_API_KEY"]}}
4 | %>
5 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/confirmation_instructions.html.erb:
--------------------------------------------------------------------------------
1 | Welcome <%= @email %>!
2 |
3 | You can confirm your account email through the link below:
4 |
5 | <%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>
6 |
--------------------------------------------------------------------------------
/app/javascript/controllers/application.js:
--------------------------------------------------------------------------------
1 | import { Application } from "@hotwired/stimulus"
2 |
3 | const application = Application.start()
4 |
5 | // Configure Stimulus development experience
6 | application.debug = false
7 | window.Stimulus = application
8 |
9 | export { application }
10 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/components/_index.scss:
--------------------------------------------------------------------------------
1 | // Import your components CSS files here.
2 | @import "alert";
3 | @import "avatar";
4 | @import "form_legend_clear";
5 | @import "banner";
6 | @import "button";
7 | @import "map";
8 | @import "sidebar";
9 | @import "address_autocomplete";
10 | @import "footer";
11 |
--------------------------------------------------------------------------------
/test/policies/offer_policy_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class OfferPolicyTest < ActiveSupport::TestCase
4 | def test_scope
5 | end
6 |
7 | def test_show
8 | end
9 |
10 | def test_create
11 | end
12 |
13 | def test_update
14 | end
15 |
16 | def test_destroy
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/app/jobs/application_job.rb:
--------------------------------------------------------------------------------
1 | class ApplicationJob < ActiveJob::Base
2 | # Automatically retry jobs that encountered a deadlock
3 | # retry_on ActiveRecord::Deadlocked
4 |
5 | # Most jobs are safe to ignore if the underlying records are no longer available
6 | # discard_on ActiveJob::DeserializationError
7 | end
8 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/policies/challenge_policy_test.rb:
--------------------------------------------------------------------------------
1 | require 'test_helper'
2 |
3 | class ChallengePolicyTest < ActiveSupport::TestCase
4 | def test_scope
5 | end
6 |
7 | def test_show
8 | end
9 |
10 | def test_create
11 | end
12 |
13 | def test_update
14 | end
15 |
16 | def test_destroy
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/db/migrate/20220905195945_create_comments.rb:
--------------------------------------------------------------------------------
1 | class CreateComments < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :comments do |t|
4 | t.references :user, null: false, foreign_key: true
5 | t.references :challenge, null: false, foreign_key: true
6 | t.timestamps
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/db/migrate/20220829135525_add_details_to_challenges.rb:
--------------------------------------------------------------------------------
1 | class AddDetailsToChallenges < ActiveRecord::Migration[7.0]
2 | def change
3 | add_column :challenges, :title, :string
4 | add_column :challenges, :content, :text
5 | add_column :challenges, :price_max, :integer
6 | add_column :challenges, :deadline, :date
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/app/controllers/callbacks_controller.rb:
--------------------------------------------------------------------------------
1 | # This has been added manually (not in terminal) - could be
2 | # a source of error later on
3 |
4 | class CallbacksController < Devise::OmniauthCallbacksController
5 | def github
6 | @user = User.from_omniauth(request.env["omniauth.auth"])
7 | sign_in_and_redirect @user
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/unlock_instructions.html.erb:
--------------------------------------------------------------------------------
1 | Hello <%= @resource.email %>!
2 |
3 | Your account has been locked due to an excessive number of unsuccessful sign in attempts.
4 |
5 | Click the link below to unlock your account:
6 |
7 | <%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>
8 |
--------------------------------------------------------------------------------
/db/migrate/20220829124023_create_challenges.rb:
--------------------------------------------------------------------------------
1 | class CreateChallenges < ActiveRecord::Migration[7.0]
2 | def change
3 | create_table :challenges do |t|
4 | t.references :filter, null: false, foreign_key: true
5 | t.references :user, null: false, foreign_key: true
6 |
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/test/channels/application_cable/connection_test.rb:
--------------------------------------------------------------------------------
1 | require "test_helper"
2 |
3 | class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
4 | # test "connects with cookies" do
5 | # cookies.signed[:user_id] = 42
6 | #
7 | # connect
8 | #
9 | # assert_equal connection.user_id, "42"
10 | # end
11 | end
12 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/pages/_my_offers.scss:
--------------------------------------------------------------------------------
1 |
2 | .split-card {
3 | display: flex;
4 | flex-direction: row;
5 | align-items: center;
6 | justify-content: center;
7 | }
8 |
9 | .split-items {
10 | padding: 3px 8px;
11 | // display: flex;
12 | // flex-direction: column;
13 | // align-items: center;
14 | // justify-content: center;
15 | }
16 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/email_changed.html.erb:
--------------------------------------------------------------------------------
1 | Hello <%= @email %>!
2 |
3 | <% if @resource.try(:unconfirmed_email?) %>
4 | We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.
5 | <% else %>
6 | We're contacting you to notify you that your email has been changed to <%= @resource.email %>.
7 | <% end %>
8 |
--------------------------------------------------------------------------------
/app/controllers/users_controller.rb:
--------------------------------------------------------------------------------
1 | class UsersController < ApplicationController
2 | def edit
3 | @user = current_user
4 | end
5 |
6 | def update
7 | @user = current_user
8 | @user.update(sign_up_params)
9 | redirect_to users_path
10 | end
11 |
12 | private
13 |
14 | def user_params
15 | params.require(:user).permit(:photo)
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/app/models/challenge.rb:
--------------------------------------------------------------------------------
1 | class Challenge < ApplicationRecord
2 | belongs_to :filter
3 | belongs_to :user
4 | has_many :offers, dependent: :destroy
5 | has_many :comments, dependent: :destroy
6 | has_many_attached :photos
7 |
8 | validates :title, :content, :price_max, :deadline, :location, presence: true
9 |
10 | geocoded_by :location
11 |
12 | after_validation :geocode, if: :location
13 | end
14 |
--------------------------------------------------------------------------------
/app/views/shared/_banner.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
DEV.WORK
5 |
Find solutions to your challenges!
6 | <%= link_to "Learn More", challenges_path, class:"btn btn-primary btn-lg mt-6 learn_more" %>
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "app",
3 | "private": "true",
4 | "dependencies": {
5 | "@hotwired/stimulus": "^3.1.0",
6 | "@hotwired/turbo-rails": "^7.1.3",
7 | "@mapbox/mapbox-gl-geocoder": "^5.0.1",
8 | "@popperjs/core": "^2.11.6",
9 | "bootstrap": "^5.2.0",
10 | "webpack": "^5.74.0",
11 | "webpack-cli": "^4.10.0"
12 | },
13 | "scripts": {
14 | "build": "webpack --config webpack.config.js"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | ENV["RAILS_ENV"] ||= "test"
2 | require_relative "../config/environment"
3 | require "rails/test_help"
4 |
5 | class ActiveSupport::TestCase
6 | # Run tests in parallel with specified workers
7 | parallelize(workers: :number_of_processors)
8 |
9 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
10 | fixtures :all
11 |
12 | # Add more helper methods to be used by all tests here...
13 | end
14 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure parameters to be filtered from the log file. Use this to limit dissemination of
4 | # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
5 | # notations and behaviors.
6 | Rails.application.config.filter_parameters += [
7 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
8 | ]
9 |
--------------------------------------------------------------------------------
/config/initializers/permissions_policy.rb:
--------------------------------------------------------------------------------
1 | # Define an application-wide HTTP permissions policy. For further
2 | # information see https://developers.google.com/web/updates/2018/06/feature-policy
3 | #
4 | # Rails.application.config.permissions_policy do |f|
5 | # f.camera :none
6 | # f.gyroscope :none
7 | # f.microphone :none
8 | # f.usb :none
9 | # f.fullscreen :self
10 | # f.payment :self, "https://secure.example.com"
11 | # end
12 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/reset_password_instructions.html.erb:
--------------------------------------------------------------------------------
1 | Hello <%= @resource.email %>!
2 |
3 | Someone has requested a link to change your password. You can do this through the link below.
4 |
5 | <%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>
6 |
7 | If you didn't request this, please ignore this email.
8 | Your password won't change until you access the link above and create a new one.
9 |
--------------------------------------------------------------------------------
/config/credentials.yml.enc:
--------------------------------------------------------------------------------
1 | 5ZLKyGjngKBvEzFITztcuLYikjLSvgNndBbh71pDCKT122MR67/Zu3msmp+t9Ibe7+6ID19rCeJiVjYLx3gs9gy48f8vJioHXSsLeMIaAeCklirwOKZPXlMUHIM7tiCmhXu4XpeP+9vD7LynljWgFaePGcuRGcqIVgIZ+jjrX83PXMOHfDMTFeRI9FVivf0juiH0TjtfqDr89o3GoSQB6sgT022IYcTXGJby9B0csiCzD0t/iAncg1FyKLmn1AyXhrGEjcC+CfFgGIoSIX0tj4/JTZAOQWTAZJvBnwp+1l06sB/OBJOM775B+htS5P5OTDAxjX/16Fr61999iO8ii5yGkWZLX1hASehPBI83/a175VTWGQE63T/PhIqLsXPriWw7vfw1lgH5mJDmqvP+SHTiKgAiAIf2KdIh--9CHFJNM5Cwo48U+a--1X6r/wHpsWWNR5ujTeW2hg==
--------------------------------------------------------------------------------
/app/views/devise/shared/_error_messages.html.erb:
--------------------------------------------------------------------------------
1 | <% if resource.errors.any? %>
2 |
3 |
4 | <%= I18n.t("errors.messages.not_saved",
5 | count: resource.errors.count,
6 | resource: resource.class.model_name.human.downcase)
7 | %>
8 |
9 |
10 | <% resource.errors.full_messages.each do |message| %>
11 | <%= message %>
12 | <% end %>
13 |
14 |
15 | <% end %>
16 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path")
2 | const webpack = require("webpack")
3 |
4 | module.exports = {
5 | mode: "production",
6 | devtool: "source-map",
7 | entry: {
8 | application: "./app/javascript/application.js"
9 | },
10 | output: {
11 | filename: "[name].js",
12 | sourceMapFilename: "[file].map",
13 | path: path.resolve(__dirname, "app/assets/builds"),
14 | },
15 | plugins: [
16 | new webpack.optimize.LimitChunkCountPlugin({
17 | maxChunks: 1
18 | })
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/app/views/shared/_flashes.html.erb:
--------------------------------------------------------------------------------
1 | <% if notice %>
2 |
3 |
4 | <%= notice %>
5 |
6 | <% end %>
7 | <% if alert %>
8 |
9 |
10 | <%= alert %>
11 |
12 | <% end %>
13 |
--------------------------------------------------------------------------------
/app/javascript/controllers/sidebar_controller.js:
--------------------------------------------------------------------------------
1 | import { Controller } from "@hotwired/stimulus"
2 |
3 | export default class extends Controller {
4 | static targets = ["menu", "search", "sidebar"]
5 |
6 | connect() {
7 | }
8 | change() {
9 | this.sidebarTarget.classList.toggle("open");
10 |
11 | if(this.sidebarTarget.classList.contains("open")){
12 | this.menuTarget.classList.replace("bx-menu", "bx-menu-alt-right");
13 | }else {
14 | this.menuTarget.classList.replace("bx-menu-alt-right","bx-menu");
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/policies/offer_policy.rb:
--------------------------------------------------------------------------------
1 | class OfferPolicy < ApplicationPolicy
2 | class Scope < Scope
3 | # NOTE: Be explicit about which records you allow access to!
4 | def resolve
5 | scope.all
6 | end
7 | end
8 |
9 | def show?
10 | true
11 | end
12 |
13 | def new?
14 | true
15 | end
16 |
17 | def create?
18 | true
19 | end
20 |
21 | def edit?
22 | update?
23 | end
24 |
25 | def update?
26 | user.admin? ? true : record.user == user
27 | end
28 |
29 | def destroy?
30 | update?
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/app/policies/challenge_policy.rb:
--------------------------------------------------------------------------------
1 | class ChallengePolicy < ApplicationPolicy
2 | class Scope < Scope
3 | # NOTE: Be explicit about which records you allow access to!
4 | def resolve
5 | scope.all
6 | end
7 | end
8 |
9 | def show?
10 | true
11 | end
12 |
13 | def new?
14 | true
15 | end
16 |
17 | def create?
18 | true
19 | end
20 |
21 | def edit?
22 | update?
23 | end
24 |
25 | def update?
26 | user.admin? ? true : record.user == user
27 | end
28 |
29 | def destroy?
30 | update?
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/components/_form_legend_clear.scss:
--------------------------------------------------------------------------------
1 | // In bootstrap 5 legend floats left and requires the following element
2 | // to be cleared. In a radio button or checkbox group the element after
3 | // the legend will be the automatically generated hidden input; the fix
4 | // in https://github.com/twbs/bootstrap/pull/30345 applies to the hidden
5 | // input and has no visual effect. Here we try to fix matters by
6 | // applying the clear to the div wrapping the first following radio button
7 | // or checkbox.
8 | legend ~ div.form-check:first-of-type {
9 | clear: left;
10 | }
11 |
--------------------------------------------------------------------------------
/lib/templates/erb/scaffold/_form.html.erb:
--------------------------------------------------------------------------------
1 | <%# frozen_string_literal: true %>
2 | <%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
3 | <%%= f.error_notification %>
4 | <%%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
5 |
6 |
7 | <%- attributes.each do |attribute| -%>
8 | <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
9 | <%- end -%>
10 |
11 |
12 |
13 | <%%= f.button :submit %>
14 |
15 | <%% end %>
16 |
--------------------------------------------------------------------------------
/app/views/devise/passwords/new.html.erb:
--------------------------------------------------------------------------------
1 | Forgot your password?
2 |
3 | <%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
4 | <%= f.error_notification %>
5 |
6 |
7 | <%= f.input :email,
8 | required: true,
9 | autofocus: true,
10 | input_html: { autocomplete: "email" } %>
11 |
12 |
13 |
14 | <%= f.button :submit, "Send me reset password instructions" %>
15 |
16 | <% end %>
17 |
18 | <%= render "devise/shared/links" %>
19 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = "1.0"
5 |
6 | # Add additional assets to the asset load path.
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 |
9 | Rails.application.config.assets.paths << Rails.root.join("node_modules")
10 | # Precompile additional assets.
11 | # application.js, application.css, and all non-JS/CSS in the app/assets
12 | # folder are already added.
13 | # Rails.application.config.assets.precompile += %w( admin.js admin.css )
14 |
--------------------------------------------------------------------------------
/app/views/devise/unlocks/new.html.erb:
--------------------------------------------------------------------------------
1 | Resend unlock instructions
2 |
3 | <%= simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
4 | <%= f.error_notification %>
5 | <%= f.full_error :unlock_token %>
6 |
7 |
8 | <%= f.input :email,
9 | required: true,
10 | autofocus: true,
11 | input_html: { autocomplete: "email" } %>
12 |
13 |
14 |
15 | <%= f.button :submit, "Resend unlock instructions" %>
16 |
17 | <% end %>
18 |
19 | <%= render "devise/shared/links" %>
20 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.scss:
--------------------------------------------------------------------------------
1 | // Graphical variables
2 | @import "config/fonts";
3 | @import "config/colors";
4 | @import "config/bootstrap_variables";
5 |
6 | // External libraries
7 | @import "bootstrap/scss/bootstrap";
8 | @import "font-awesome";
9 | @import "@mapbox/mapbox-gl-geocoder/dist/mapbox-gl-geocoder";
10 |
11 |
12 | // Your CSS partials
13 | @import "components/index";
14 | @import "pages/index";
15 | @import "pages/show";
16 | @import "pages/my_offers";
17 | @import "pages/home";
18 | @import "pages/devise";
19 |
20 | .wrapper {
21 | display: flex;
22 | justify-content: space-between;
23 | flex-direction: column;
24 | min-height: 100vh;
25 | }
26 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/config/_fonts.scss:
--------------------------------------------------------------------------------
1 | // Import Google fonts
2 | @import url('https://fonts.googleapis.com/css?family=Nunito:400,700|Work+Sans:400,700&display=swap');
3 |
4 | // Define fonts for body and headers
5 | $body-font: "Work Sans", "Helvetica", "sans-serif";
6 | $headers-font: "Nunito", "Helvetica", "sans-serif";
7 |
8 | // To use a font file (.woff) uncomment following lines
9 | // @font-face {
10 | // font-family: "Font Name";
11 | // src: font-url('FontFile.eot');
12 | // src: font-url('FontFile.eot?#iefix') format('embedded-opentype'),
13 | // font-url('FontFile.woff') format('woff'),
14 | // font-url('FontFile.ttf') format('truetype')
15 | // }
16 | // $my-font: "Font Name";
17 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, "\\1en"
8 | # inflect.singular /^(ox)en/i, "\\1"
9 | # inflect.irregular "person", "people"
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym "RESTful"
16 | # end
17 |
--------------------------------------------------------------------------------
/app/javascript/controllers/index.js:
--------------------------------------------------------------------------------
1 | // This file is auto-generated by ./bin/rails stimulus:manifest:update
2 | // Run that command whenever you add a new controller or create them with
3 | // ./bin/rails generate stimulus controllerName
4 |
5 | import { application } from "./application"
6 |
7 | import AddressAutocompleteController from "./address_autocomplete_controller"
8 | application.register("address-autocomplete", AddressAutocompleteController)
9 |
10 | import HelloController from "./hello_controller"
11 | application.register("hello", HelloController)
12 |
13 | import MapController from "./map_controller"
14 | application.register("map", MapController)
15 |
16 | import SidebarController from "./sidebar_controller"
17 | application.register("sidebar", SidebarController)
18 |
--------------------------------------------------------------------------------
/app/views/devise/confirmations/new.html.erb:
--------------------------------------------------------------------------------
1 | Resend confirmation instructions
2 |
3 | <%= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
4 | <%= f.error_notification %>
5 | <%= f.full_error :confirmation_token %>
6 |
7 |
8 | <%= f.input :email,
9 | required: true,
10 | autofocus: true,
11 | value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email),
12 | input_html: { autocomplete: "email" } %>
13 |
14 |
15 |
16 | <%= f.button :submit, "Resend confirmation instructions" %>
17 |
18 | <% end %>
19 |
20 | <%= render "devise/shared/links" %>
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Dev.Work
2 |
3 |
4 |
5 | ## A platform where you can find the developer you need for code troubles you have
6 |
7 | With our app you can:
8 | - Create challenges in an award-based approach to tackle them with hundreds of code-hungry programmers in our website
9 | - Find a challenge you can tackle and enter the auction to be the person to fix the bug
10 | and many many more
11 |
12 | ## Usage
13 |
14 | ~~Visit our website and sign up NOW! www.DEVWORK.team~~
15 |
16 | ## !! WARNING !! Due to disappearance of Heroku Free plan, the website is down.
17 |
18 | Don't forget to watch our GitHub repo for updates and never forget:
19 | ## Whatever bug you can't fix, Dev.Work can!
20 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/components/_avatar.scss:
--------------------------------------------------------------------------------
1 | .avatar {
2 | width: 40px;
3 | height: 40px;
4 | border-radius: 50%;
5 | }
6 | .avatar-large {
7 | width: 56px;
8 | border-radius: 50%;
9 | }
10 | .avatar-bordered {
11 | width: 40px;
12 | border-radius: 50%;
13 | box-shadow: 0 1px 2px rgba(0,0,0,0.2);
14 | border: white 1px solid;
15 | }
16 | .avatar-square {
17 | width: 40px;
18 | height: 40px;
19 | border-radius: 0px;
20 | box-shadow: 0 1px 2px rgba(0,0,0,0.2);
21 | border: white 1px solid;
22 | }
23 | .avatar-custom {
24 | width: 40%;
25 | border-radius: 50%;
26 | }
27 |
28 | .avatar-custom2 {
29 | margin: 0px;
30 | width: 90%;
31 | height: 80%;
32 | border-radius: 50%;
33 | }
34 |
35 | .avatar-sidebar {
36 | border-radius: 50%;
37 | }
38 |
39 | .avatar-offer {
40 | width: 100px;
41 | height: 100px;
42 | border-radius: 50%;
43 | }
44 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/config/_bootstrap_variables.scss:
--------------------------------------------------------------------------------
1 | // This is where you override default Bootstrap variables
2 | // 1. All Bootstrap variables are here => https://github.com/twbs/bootstrap/blob/master/scss/_variables.scss
3 | // 2. These variables are defined with default value (see https://robots.thoughtbot.com/sass-default)
4 | // 3. You can override them below!
5 |
6 | // General style
7 | $font-family-sans-serif: $body-font;
8 | $headings-font-family: $headers-font;
9 | $body-bg: $light-gray;
10 | $font-size-base: 1rem;
11 |
12 | // Colors
13 | $body-color: $gray;
14 | $primary: $blue;
15 | $success: $green;
16 | $info: $yellow;
17 | $danger: $red;
18 | $warning: $orange;
19 |
20 | // Buttons & inputs' radius
21 | $border-radius: 2px;
22 | $border-radius-lg: 2px;
23 | $border-radius-sm: 2px;
24 |
25 | // Override other variables below!
26 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | devise_for :users, :controllers => {:registrations => "registrations", omniauth_callbacks: "callbacks"}
3 | root to: "pages#home"
4 | # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
5 |
6 | # Defines the root path route ("/")
7 | # root "articles#index"
8 | resources :challenges, only: %i[show index new create destroy edit update] do
9 | resources :offers, only: %i[show index create update]
10 | resources :comments, only: %i[index create]
11 | end
12 | resources :users, only: [:index, :show, :edit, :update], path: "index" do
13 | end
14 | resources :offers, only: %i[destroy]
15 | # resources :comments, only: %i[edit update destroy]
16 | get '/my_challenges', action: :index, controller: 'challenges'
17 | get '/my_offers', action: :index, controller: 'offers'
18 | end
19 |
--------------------------------------------------------------------------------
/app/policies/application_policy.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ApplicationPolicy
4 | attr_reader :user, :record
5 |
6 | def initialize(user, record)
7 | @user = user
8 | @record = record
9 | end
10 |
11 | def index?
12 | false
13 | end
14 |
15 | def show?
16 | false
17 | end
18 |
19 | def create?
20 | false
21 | end
22 |
23 | def new?
24 | create?
25 | end
26 |
27 | def update?
28 | false
29 | end
30 |
31 | def edit?
32 | update?
33 | end
34 |
35 | def destroy?
36 | false
37 | end
38 |
39 | class Scope
40 | def initialize(user, scope)
41 | @user = user
42 | @scope = scope
43 | end
44 |
45 | def resolve
46 | raise NotImplementedError, "You must define #resolve in #{self.class}"
47 | end
48 |
49 | private
50 |
51 | attr_reader :user, :scope
52 | end
53 | end
54 |
--------------------------------------------------------------------------------
/app/controllers/registrations_controller.rb:
--------------------------------------------------------------------------------
1 | class RegistrationsController < Devise::RegistrationsController
2 | private
3 |
4 | # def signup_params
5 | # params.require(:user).permit( :name,
6 | # :email,
7 | # :password,
8 | # :password_confirmation)
9 | # end
10 |
11 | # def account_update_params
12 | # params.require(:user).permit( :name,
13 | # :email,
14 | # :password,
15 | # :password_confirmation)
16 | # end
17 |
18 | def sign_up_params
19 | params.require(:user).permit(:name, :email, :password, :password_confirmation)
20 | end
21 |
22 | def account_update_params
23 | params.require(:user).permit(:name, :email, :password, :password_confirmation, :current_password)
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/.rubocop.yml:
--------------------------------------------------------------------------------
1 | AllCops:
2 | NewCops: enable
3 | Exclude:
4 | - 'bin/**/*'
5 | - 'db/**/*'
6 | - 'config/**/*'
7 | - 'node_modules/**/*'
8 | - 'script/**/*'
9 | - 'support/**/*'
10 | - 'tmp/**/*'
11 | - 'test/**/*'
12 |
13 | Style/ConditionalAssignment:
14 | Enabled: false
15 | Style/StringLiterals:
16 | Enabled: false
17 | Style/RedundantReturn:
18 | Enabled: false
19 | Style/Documentation:
20 | Enabled: false
21 | Style/WordArray:
22 | Enabled: false
23 | Metrics/AbcSize:
24 | Enabled: false
25 | Style/MutableConstant:
26 | Enabled: false
27 | Style/SignalException:
28 | Enabled: false
29 | Metrics/CyclomaticComplexity:
30 | Enabled: false
31 | Style/MissingRespondToMissing:
32 | Enabled: false
33 | Lint/MissingSuper:
34 | Enabled: false
35 | Style/FrozenStringLiteralComment:
36 | Enabled: false
37 | Layout/LineLength:
38 | Max: 120
39 | Style/EmptyMethod:
40 | Enabled: false
41 | Bundler/OrderedGems:
42 | Enabled: false
43 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative "boot"
2 |
3 | require "rails/all"
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module DevWork
10 | class Application < Rails::Application
11 | config.generators do |generate|
12 | generate.assets false
13 | generate.helper false
14 | generate.test_framework :test_unit, fixture: false
15 | end
16 | # Initialize configuration defaults for originally generated Rails version.
17 | config.load_defaults 7.0
18 |
19 | # Configuration for the application, engines, and railties goes here.
20 | #
21 | # These settings can be overridden in specific environments using the files
22 | # in config/environments, which are processed later.
23 | #
24 | # config.time_zone = "Central Time (US & Canada)"
25 | # config.eager_load_paths << Rails.root.join("extras")
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/config/locales/simple_form.en.yml:
--------------------------------------------------------------------------------
1 | en:
2 | simple_form:
3 | "yes": 'Yes'
4 | "no": 'No'
5 | required:
6 | text: 'required'
7 | mark: '*'
8 | # You can uncomment the line below if you need to overwrite the whole required html.
9 | # When using html, text and mark won't be used.
10 | # html: '* '
11 | error_notification:
12 | default_message: "Please review the problems below:"
13 | # Examples
14 | # labels:
15 | # defaults:
16 | # password: 'Password'
17 | # user:
18 | # new:
19 | # email: 'E-mail to sign in.'
20 | # edit:
21 | # email: 'E-mail.'
22 | # hints:
23 | # defaults:
24 | # username: 'User name to sign in.'
25 | # password: 'No special characters, please.'
26 | # include_blanks:
27 | # defaults:
28 | # age: 'Rather not say'
29 | # prompts:
30 | # defaults:
31 | # age: 'Select your age'
32 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t "hello"
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t("hello") %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # "true": "foo"
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at https://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/app/views/devise/passwords/edit.html.erb:
--------------------------------------------------------------------------------
1 | Change your password
2 |
3 | <%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
4 | <%= f.error_notification %>
5 |
6 | <%= f.input :reset_password_token, as: :hidden %>
7 | <%= f.full_error :reset_password_token %>
8 |
9 |
10 | <%= f.input :password,
11 | label: "New password",
12 | required: true,
13 | autofocus: true,
14 | hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
15 | input_html: { autocomplete: "new-password" } %>
16 | <%= f.input :password_confirmation,
17 | label: "Confirm your new password",
18 | required: true,
19 | input_html: { autocomplete: "new-password" } %>
20 |
21 |
22 |
23 | <%= f.button :submit, "Change my password" %>
24 |
25 | <% end %>
26 |
27 | <%= render "devise/shared/links" %>
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2 | #
3 | # If you find yourself ignoring temporary files generated by your text editor
4 | # or operating system, you probably want to add a global ignore instead:
5 | # git config --global core.excludesfile '~/.gitignore_global'
6 |
7 | # Ignore bundler config.
8 | /.bundle
9 |
10 | # Ignore all logfiles and tempfiles.
11 | /log/*
12 | /tmp/*
13 | !/log/.keep
14 | !/tmp/.keep
15 |
16 | # Ignore pidfiles, but keep the directory.
17 | /tmp/pids/*
18 | !/tmp/pids/
19 | !/tmp/pids/.keep
20 |
21 | # Ignore uploaded files in development.
22 | /storage/*
23 | !/storage/.keep
24 | /tmp/storage/*
25 | !/tmp/storage/
26 | !/tmp/storage/.keep
27 |
28 | /public/assets
29 |
30 | # Ignore master key for decrypting credentials and more.
31 | /config/master.key
32 |
33 | /app/assets/builds/*
34 | !/app/assets/builds/.keep
35 |
36 | /node_modules
37 | # Ignore .env file containing credentials.
38 | .env*
39 |
40 | # Ignore Mac and Linux file system files
41 | *.swp
42 | .DS_Store
43 | .env*
44 | # /config/initializers
45 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require "fileutils"
3 |
4 | # path to your application root.
5 | APP_ROOT = File.expand_path("..", __dir__)
6 |
7 | def system!(*args)
8 | system(*args) || abort("\n== Command #{args} failed ==")
9 | end
10 |
11 | FileUtils.chdir APP_ROOT do
12 | # This script is a way to set up or update your development environment automatically.
13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14 | # Add necessary setup steps to this file.
15 |
16 | puts "== Installing dependencies =="
17 | system! "gem install bundler --conservative"
18 | system("bundle check") || system!("bundle install")
19 |
20 | # puts "\n== Copying sample files =="
21 | # unless File.exist?("config/database.yml")
22 | # FileUtils.cp "config/database.yml.sample", "config/database.yml"
23 | # end
24 |
25 | puts "\n== Preparing database =="
26 | system! "bin/rails db:prepare"
27 |
28 | puts "\n== Removing old logs and tempfiles =="
29 | system! "bin/rails log:clear tmp:clear"
30 |
31 | puts "\n== Restarting application server =="
32 | system! "bin/rails restart"
33 | end
34 |
--------------------------------------------------------------------------------
/config/initializers/content_security_policy.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Define an application-wide content security policy.
4 | # See the Securing Rails Applications Guide for more information:
5 | # https://guides.rubyonrails.org/security.html#content-security-policy-header
6 |
7 | # Rails.application.configure do
8 | # config.content_security_policy do |policy|
9 | # policy.default_src :self, :https
10 | # policy.font_src :self, :https, :data
11 | # policy.img_src :self, :https, :data
12 | # policy.object_src :none
13 | # policy.script_src :self, :https
14 | # policy.style_src :self, :https
15 | # # Specify URI for violation reports
16 | # # policy.report_uri "/csp-violation-report-endpoint"
17 | # end
18 | #
19 | # # Generate session nonces for permitted importmap and inline scripts
20 | # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21 | # config.content_security_policy_nonce_directives = %w(script-src)
22 | #
23 | # # Report violations without enforcing the policy.
24 | # # config.content_security_policy_report_only = true
25 | # end
26 |
--------------------------------------------------------------------------------
/config/initializers/geocoder.rb:
--------------------------------------------------------------------------------
1 | Geocoder.configure(
2 | # Geocoding options
3 | # timeout: 3, # geocoding service timeout (secs)
4 | # lookup: :nominatim, # name of geocoding service (symbol)
5 | # ip_lookup: :ipinfo_io, # name of IP address geocoding service (symbol)
6 | # language: :en, # ISO-639 language code
7 | # use_https: false, # use HTTPS for lookup requests? (if supported)
8 | # http_proxy: nil, # HTTP proxy server (user:pass@host:port)
9 | # https_proxy: nil, # HTTPS proxy server (user:pass@host:port)
10 | # api_key: nil, # API key for geocoding service
11 | # cache: nil, # cache object (must respond to #[], #[]=, and #del)
12 |
13 | # Exceptions that should not be rescued by default
14 | # (if you want to implement custom error handling);
15 | # supports SocketError and Timeout::Error
16 | # always_raise: [],
17 |
18 | # Calculation options
19 | units: :km, # :km for kilometers or :mi for miles
20 | # distances: :linear # :spherical or :linear
21 |
22 | # Cache configuration
23 | # cache_options: {
24 | # expiration: 2.days,
25 | # prefix: 'geocoder:'
26 | # }
27 | )
28 |
--------------------------------------------------------------------------------
/app/javascript/controllers/map_controller.js:
--------------------------------------------------------------------------------
1 | import { Controller } from "@hotwired/stimulus"
2 | import MapboxGeocoder from "@mapbox/mapbox-gl-geocoder"
3 |
4 | export default class extends Controller {
5 | static values = {
6 | apiKey: String,
7 | markers: Array
8 | }
9 |
10 | connect() {
11 | mapboxgl.accessToken = this.apiKeyValue
12 | this.map = new mapboxgl.Map({
13 | container: this.element,
14 | style: "mapbox://styles/mapbox/streets-v11"
15 | })
16 | this.#addMarkersToMap()
17 | this.#fitMapToMarkers()
18 | this.map.addControl(new MapboxGeocoder({ accessToken: mapboxgl.accessToken,
19 | mapboxgl: mapboxgl }))
20 | }
21 |
22 | #addMarkersToMap() {
23 | this.markersValue.forEach((marker) => {
24 | const popup = new mapboxgl.Popup().setHTML(marker.info_window)
25 | new mapboxgl.Marker()
26 | .setLngLat([ marker.lng, marker.lat ])
27 | .setPopup(popup)
28 | .addTo(this.map)
29 | })
30 | }
31 |
32 | #fitMapToMarkers() {
33 | const bounds = new mapboxgl.LngLatBounds()
34 | this.markersValue.forEach(marker => bounds.extend([ marker.lng, marker.lat ]))
35 | this.map.fitBounds(bounds, { padding: 10, maxZoom: 12, duration: 0 })
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/pages/_devise.scss:
--------------------------------------------------------------------------------
1 | .sign-in-container {
2 | display: flex;
3 | flex-direction: column;
4 | justify-items: center;
5 | align-items: center;
6 | }
7 |
8 | .blank-row {
9 | height: 15vh;
10 | }
11 |
12 | .sign-in-header {
13 | margin: 10px 0;
14 | }
15 |
16 | .sign-in-box {
17 | display: flex;
18 | padding: 60px 40px 20px 40px;
19 | width: 25vw;
20 | flex-direction: column;
21 | justify-content: center;
22 | align-items: center;
23 | background-color: #555b6eb9;
24 | border-radius: 15px;
25 | box-shadow: rgba(0, 0, 0, 0.7);
26 | }
27 |
28 | .sign-in-button {
29 | // width: 100%;
30 | margin-top: 2vh;
31 | margin-bottom: 2vh;
32 | color: rgb(255, 255, 255);
33 | // width: 100%;
34 |
35 | &:hover {
36 |
37 | opacity: 0.7;
38 | color: black;
39 | transition: 0.3s;
40 | }
41 | }
42 |
43 |
44 | .devise-buttons {
45 | display: flex;
46 | align-items: center;
47 | justify-content: center;
48 | }
49 |
50 | #github-create-button {
51 | background-color: #787D90;
52 | color: white;
53 | box-shadow: inset 0 0 0 4px #ffffff0b;
54 | text-align: center;
55 |
56 | &:hover {
57 | background-color: white;
58 | opacity: 0.9;
59 | color: black;
60 | transition: 0.3s;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/models/user.rb:
--------------------------------------------------------------------------------
1 | class User < ApplicationRecord
2 | # Include default devise modules. Others available are:
3 | # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
4 | after_create :set_default_avatar
5 | devise :database_authenticatable, :registerable,
6 | :recoverable, :rememberable, :validatable, :omniauthable
7 | has_many :offers, dependent: :destroy
8 | has_many :comments, dependent: :destroy
9 | has_many :challenges
10 | has_one_attached :photo
11 |
12 | validates :nickname, :name, presence: true
13 | def set_default_avatar
14 | return if photo.attached?
15 |
16 | path = "https://res.cloudinary.com/dp6zhyocx/image/upload/v1662046666/pqwya0pvqts4ubv0eqi6.jpg"
17 | file = URI.open(path)
18 | photo.attach(io: file, filename: "userphoto.png", content_type: "image/png")
19 | save
20 | end
21 |
22 | def self.from_omniauth(auth)
23 | where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
24 | user.provider = auth.provider
25 | user.nickname = auth.info.nickname
26 | user.image = auth.info.image
27 | user.html_url = auth.extra.raw_info.html_url
28 | user.name = auth.info.name
29 | user.uid = auth.uid
30 | user.email = auth.info.email
31 | user.password = Devise.friendly_token[0,20]
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/app/views/devise/shared/_links.html.erb:
--------------------------------------------------------------------------------
1 | <%- if devise_mapping.omniauthable? %>
2 | <%- resource_class.omniauth_providers.each do |provider| %>
3 | <%= button_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), data: { 'turbo-method' => :post }, class:"button draw-border mr-2 sign-in-button"%>
4 | <% end %>
5 | <% end %>
6 |
7 | <%- if controller_name != 'sessions' %>
8 | <%#= link_to "Log in", new_session_path(resource_name) %>
9 | <% end %>
10 |
11 | <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
12 | <%#= link_to "Sign up", new_registration_path(resource_name) %>
13 | <% end %>
14 |
15 | <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
16 | <%#= link_to "Forgot your password?", new_password_path(resource_name) %>
17 | <% end %>
18 |
19 | <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
20 | <%#= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
21 | <% end %>
22 |
23 | <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
24 | <%#= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
25 | <% end %>
26 |
--------------------------------------------------------------------------------
/config/storage.yml:
--------------------------------------------------------------------------------
1 | test:
2 | service: Disk
3 | root: <%= Rails.root.join("tmp/storage") %>
4 |
5 | local:
6 | service: Disk
7 | root: <%= Rails.root.join("storage") %>
8 |
9 | # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10 | # amazon:
11 | # service: S3
12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14 | # region: us-east-1
15 | # bucket: your_own_bucket-<%= Rails.env %>
16 |
17 | # Remember not to checkin your GCS keyfile to a repository
18 | # google:
19 | # service: GCS
20 | # project: your_project
21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
22 | # bucket: your_own_bucket-<%= Rails.env %>
23 |
24 | # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25 | # microsoft:
26 | # service: AzureStorage
27 | # storage_account_name: your_account_name
28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
29 | # container: your_container_name-<%= Rails.env %>
30 |
31 | # mirror:
32 | # service: Mirror
33 | # primary: local
34 | # mirrors: [ amazon, google, microsoft ]
35 | cloudinary:
36 | service: Cloudinary
37 | folder: <%= Rails.env %>
38 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/components/_banner.scss:
--------------------------------------------------------------------------------
1 | body{
2 | background-image: linear-gradient(rgba(0,50,0,0.8),rgba(0,0,0,0.8)), url(wallpaper.jpg);
3 | background-repeat: no-repeat;
4 | background-position: center;
5 | background-size: cover;
6 | background-attachment: fixed;
7 | }
8 |
9 |
10 | .banner {
11 | padding-top: 350px ;
12 | }
13 |
14 | // .container {
15 | // margin-bottom: 100px;
16 | // }
17 |
18 | .second {
19 | background-image: linear-gradient(rgba(0,0,0,0.4),rgba(0,0,0,0.4));
20 | width: 50%;
21 | padding-bottom: 10px;
22 | border-radius: 15px;
23 | }
24 |
25 | .learn_more{
26 | border-radius: 15px !important;
27 | }
28 |
29 | .banner h1 {
30 | margin: 0;
31 | color: white;
32 | text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
33 | font-size: 60px;
34 | margin-bottom: 20px;
35 |
36 | }
37 |
38 | .banner p {
39 | font-size: 30px;
40 | color: white;
41 | text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
42 | margin-top: 10px;
43 | font-weight: lighter;
44 | }
45 |
46 |
47 |
48 |
49 | .btn-primary:hover{
50 | background-color: rgb(176, 179, 164);
51 | text-decoration: none;
52 | }
53 | /* try with this image banner{
54 | background-image: url(https://images.unsplash.com/photo-1539627831859-a911cf04d3cd?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MjB8fHB1enpsZXxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=500&q=60);
55 | background-size: cover;
56 | background-position: center; */
57 |
--------------------------------------------------------------------------------
/app/controllers/offers_controller.rb:
--------------------------------------------------------------------------------
1 | class OffersController < ApplicationController
2 | def index
3 | @offers = policy_scope(Offer)
4 | @user_offers = Offer.where(user: current_user)
5 | end
6 |
7 | def show
8 | # @challenge = Challenge.find(params[:id])
9 | @offer = Offer.where(user: current_user).where(challenge: @challenge)
10 | authorize @offer
11 | end
12 |
13 | def create
14 | @challenge = Challenge.find(params[:challenge_id])
15 | @offer = Offer.new(offer_params)
16 | @offer.user = current_user
17 | @offer.challenge = @challenge
18 | authorize @offer
19 | if @offer.save
20 | redirect_to challenge_path(@challenge), notice: "Offer has been made..."
21 | else
22 | render 'challenges/show', status: :unprocessable_entity, locals: { '@offers': @challenge.offers }
23 | end
24 | end
25 | # def comment
26 | # @offer = offer.find(params[:id])
27 | # @challenge = Challenge.find(params[:challenge_id])
28 | # end
29 |
30 | def edit
31 | authorize @offer
32 | end
33 |
34 | def update
35 | authorize @offer
36 | @offer.update(offer_params)
37 | redirect_to offers_path(@offers)
38 | end
39 |
40 | def destroy
41 | authorize @offer
42 | @offer.destroy
43 | redirect_to challenges_path(@challenges), status: :see_other
44 | end
45 |
46 | private
47 |
48 | def offer_params
49 | params.require(:offer).permit(:date, :price)
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/app/views/offers/show.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
Details of Your Offer
6 | <%= simple_form_for @challenge do |f| %>
7 | <%= f.input :title, placeholder: 'Edit the Title' %>
8 | <%= f.input :content, placeholder: 'Edit the description' %>
9 | <%= f.input :location, placeholder: 'Edit Challenge location' %>
10 | <%= f.association :filter, label: "Programming language ¹", collection: Filter.all.order(:name), input_html: { data: { controller: "tom-select" } } %>
11 | <%= f.input :price_max, placeholder: 'Edit price of your project' %>
12 | <%= f.input :deadline, placeholder: 'Edit deadline of your project' %>
13 | <%= f.submit class:"btn btn-dark btn-lg rounded-lg", id: "challenge_buttons" %>
14 | <% end %>
15 |
16 |
17 |
18 |
* All the fields need to be present for successful update
19 |
1 You cannot change the programming language of the challenge - for that you need to create a new one
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | before_action :authenticate_user!
3 | before_action :configure_permitted_parameters, if: :devise_controller?
4 | include Pundit::Authorization
5 |
6 | # def after_sign_in_path_for(resource)
7 | # if current_user.location.nil?
8 | # edit_user_path(current_user)
9 | # else
10 | # users_path
11 | # end
12 | # end
13 |
14 | # Pundit: allow-list approach
15 | after_action :verify_authorized, except: :index, unless: :skip_pundit?
16 | after_action :verify_policy_scoped, only: :index, unless: :skip_pundit?
17 |
18 | # Uncomment when you *really understand* Pundit!
19 | rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
20 | def user_not_authorized
21 | flash[:alert] = "You are not authorized to perform this action."
22 | redirect_to(root_path)
23 | end
24 |
25 | def configure_permitted_parameters
26 | # For additional fields in app/views/devise/registrations/new.html.erb
27 | devise_parameter_sanitizer.permit(:sign_up, keys: [:nickname, :photo])
28 |
29 | # For additional in app/views/devise/registrations/edit.html.erb
30 | devise_parameter_sanitizer.permit(:account_update, keys: [:nickname, :photo])
31 | end
32 |
33 | def default_url_options
34 | { host: ENV["DOMAIN"] || "localhost:3000" }
35 | end
36 |
37 | private
38 |
39 | def skip_pundit?
40 | devise_controller? || params[:controller] =~ /(^(rails_)?admin)|(^pages$)/
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/app/views/devise/sessions/new.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | <%= simple_form_for(resource, as: resource_name, url: session_path(resource_name), data: { turbo: :false }) do |f| %>
8 |
9 | <%= f.hidden_field :email,
10 | required: false,
11 | autofocus: true,
12 | input_html: { autocomplete: "email" } %>
13 | <%= f.hidden_field :password,
14 | required: false,
15 | input_html: { autocomplete: "current-password" } %>
16 | <%= f.hidden_field :remember_me, as: :boolean if devise_mapping.rememberable? %>
17 |
18 |
19 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/views/challenges/edit.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
Update challenge
6 | <%= simple_form_for @challenge do |f| %>
7 | <%= f.input :title, placeholder: 'Edit the Title' %>
8 | <%= f.input :content, placeholder: 'Edit the description' %>
9 | <%= f.input :location, placeholder: 'Edit Challenge location' %>
10 | <%= f.association :filter, label: "Programming language ¹", collection: Filter.all.order(:name), input_html: { data: { controller: "tom-select" } } %>
11 | <%= f.input :price_max, placeholder: 'Edit price of your project' %>
12 | <%= f.input :photos, as: :file, input_html: { multiple: true } %>
13 | <%= f.input :deadline, placeholder: 'Edit deadline of your project' %>
14 | <%= f.submit class:"btn btn-dark btn-lg rounded-lg", id: "challenge_buttons" %>
15 | <% end %>
16 |
17 |
18 |
19 |
* All the fields need to be present for successful update
20 |
1 You cannot change the programming language of the challenge - for that you need to create a new one
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/views/challenges/new.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
Create a new challenge
6 | <%= simple_form_for @challenge do |f| %>
7 | <%= f.input :title, placeholder: 'Add a Title' %>
8 | <%= f.input :content, placeholder: 'Describe in Details' %>
9 | <%= f.input :location, placeholder: 'Specify Challenge location' %>
10 | <%= f.association :filter, label: "Programming language ¹", collection: Filter.all.order(:name), input_html: { data: { controller: "tom-select" } } %>
11 | <%= f.input :price_max, placeholder: 'Put maximum price in Euros' %>
12 | <%= f.input :photos, as: :file, input_html: { multiple: true } %>
13 | <%= f.input :deadline, placeholder: 'Put a deadline for your project' %>
14 | <%= f.submit class:"btn btn-dark btn-lg rounded-lg challenge-buttons", id: "challenge_buttons" %>
15 | <% end %>
16 |
17 |
18 |
19 |
* All the fields need to be present for successful challenge creation
20 |
1 You will not be able to change the programming language of the challenge afterwards - choose wisely
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/views/challenges/_info_window.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | <% if challenge.user.image %>
7 | <%= image_tag challenge.user.image, class: "avatar-custom", style:"height:80px !important; width:80px !important" %>
8 | <% elsif challenge.user.photo %>
9 | <%= cl_image_tag challenge.user.photo.key, class: "avatar-custom", style:"height:80px !important; width:80px !important" %>
10 | <% else %>
11 | <%= image_tag "userphoto_square.jpg", class:"avatar-custom", style: "height:80px; width:67.8px" %>
12 | <% end %>
13 |
14 |
15 |
16 |
17 |
<%= challenge.user.nickname %>: <%= challenge.title %>
18 |
19 | <% if !challenge.user.html_url.nil? %>
20 | <%= link_to "GitHub", challenge.user.html_url, class:"btn rounded-5 btn-sm", style:"background-color:#8d7197; color:white" %>
21 | <% else %>
22 | <%= link_to "GitHub", "https://www.github.com", class:"btn rounded-5 btn-sm", style:"background-color:#8d7197; color:white" %>
23 | <% end %>
24 | <%= link_to "Challenge", challenge_path(challenge), class:"btn rounded-5 btn-sm", style:"background-color:#8d7197; color:white" %>
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/views/devise/registrations/new.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), data: { turbo: :false }) do |f| %>
8 | <%= f.error_notification %>
9 | <% if false %>
10 |
11 | <%= f.hidden_field :nickname,
12 | required: false,
13 | autofocus: true,
14 | input_html: { autocomplete: "nickname" }%>
15 | <%= f.hidden_field :email,
16 | required: true,
17 | autofocus: true,
18 | input_html: { autocomplete: "email" }%>
19 | <%= f.hidden_field :location,
20 | required: false,
21 | autofocus: true,
22 | input_html: { autocomplete: "location" }%>
23 | <%= f.hidden_field :photo, as: :file %>
24 | <%= f.hidden_field :password,
25 | required: true,
26 | hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
27 | input_html: { autocomplete: "new-password" } %>
28 | <%= f.hidden_field :password_confirmation,
29 | required: true,
30 | input_html: { autocomplete: "new-password" } %>
31 |
32 | <% end %>
33 | <% end %>
34 | <%= render "devise/shared/links" %>
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
We're sorry, but something went wrong (500)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
We're sorry, but something went wrong.
62 |
63 |
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/app/views/offers/index.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 | <% @user_offers.each do |offer| %>
22 |
23 |
<%= offer.challenge.title %>
24 |
25 |
26 |
Their maximum price:
27 |
<%= offer.challenge.price_max %>
28 |
The deadline:
29 |
<%= offer.challenge.deadline %>
30 |
31 |
32 |
My offered price:
33 |
<%= offer.price %>
34 |
My proposed date:
35 |
<%= offer.date %>
36 |
37 |
38 | <%= link_to "See challenge", challenge_path(offer.challenge), class:"btn btn-dark btn-lg rounded-lg mx-3", style:"position:absolute;bottom:10px; width:180px", id:"button" %>
39 | <%= link_to "View offer", "#", class:"btn btn-dark btn-lg rounded-lg mx-3", style:"position:absolute;bottom:10px; right:0px; width:180px", id:"button" %>
40 |
41 | <% end %>
42 |
43 | <%# end %>
44 |
45 |
--------------------------------------------------------------------------------
/app/views/devise/registrations/edit.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Edit <%= resource_name.to_s.humanize %>
5 |
6 | <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
7 | <%= f.error_notification %>
8 |
9 |
32 |
33 |
34 | <%= f.button :submit, "Update" %>
35 |
36 | <% end %>
37 |
38 |
Cancel my account
39 |
40 |
Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
41 |
42 | <%= link_to "Back", :back %>
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers: a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum; this matches the default thread size of Active Record.
6 | #
7 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9 | threads min_threads_count, max_threads_count
10 |
11 | # Specifies the `worker_timeout` threshold that Puma will use to wait before
12 | # terminating a worker in development environments.
13 | #
14 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
15 |
16 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
17 | #
18 | port ENV.fetch("PORT") { 3000 }
19 |
20 | # Specifies the `environment` that Puma will run in.
21 | #
22 | environment ENV.fetch("RAILS_ENV") { "development" }
23 |
24 | # Specifies the `pidfile` that Puma will use.
25 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26 |
27 | # Specifies the number of `workers` to boot in clustered mode.
28 | # Workers are forked web server processes. If using threads and workers together
29 | # the concurrency of the application would be max `threads` * `workers`.
30 | # Workers do not work on JRuby or Windows (both of which do not support
31 | # processes).
32 | #
33 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
34 |
35 | # Use the `preload_app!` method when specifying a `workers` number.
36 | # This directive tells Puma to first boot the application and load code
37 | # before forking the application. This takes advantage of Copy On Write
38 | # process behavior so workers use less memory.
39 | #
40 | # preload_app!
41 |
42 | # Allow puma to be restarted by `bin/rails restart` command.
43 | plugin :tmp_restart
44 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
The change you wanted was rejected (422)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The change you wanted was rejected.
62 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/db/migrate/20220829141529_add_devise_to_users.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class AddDeviseToUsers < ActiveRecord::Migration[7.0]
4 | def self.up
5 | change_table :users do |t|
6 | ## Database authenticatable
7 | t.string :email, null: false, default: ""
8 | t.string :encrypted_password, null: false, default: ""
9 |
10 | ## Recoverable
11 | t.string :reset_password_token
12 | t.datetime :reset_password_sent_at
13 |
14 | ## Rememberable
15 | t.datetime :remember_created_at
16 |
17 | ## Trackable
18 | # t.integer :sign_in_count, default: 0, null: false
19 | # t.datetime :current_sign_in_at
20 | # t.datetime :last_sign_in_at
21 | # t.string :current_sign_in_ip
22 | # t.string :last_sign_in_ip
23 |
24 | ## Confirmable
25 | # t.string :confirmation_token
26 | # t.datetime :confirmed_at
27 | # t.datetime :confirmation_sent_at
28 | # t.string :unconfirmed_email # Only if using reconfirmable
29 |
30 | ## Lockable
31 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
32 | # t.string :unlock_token # Only if unlock strategy is :email or :both
33 | # t.datetime :locked_at
34 |
35 |
36 | # Uncomment below if timestamps were not included in your original model.
37 | # t.timestamps null: false
38 | end
39 |
40 | add_index :users, :email, unique: true
41 | add_index :users, :reset_password_token, unique: true
42 | # add_index :users, :confirmation_token, unique: true
43 | # add_index :users, :unlock_token, unique: true
44 | end
45 |
46 | def self.down
47 | # By default, we don't want to make any assumption about how to roll back a migration when your
48 | # model already existed. Please edit below which fields you would like to remove in this migration.
49 | raise ActiveRecord::IrreversibleMigration
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/app/views/shared/_index-cards.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | <% @challenges.each_with_index do |challenge, index| %>
4 | <%#
%>
5 |
6 |
7 |
8 |
9 |
10 | <% if challenge.user.image? %>
11 | <%= image_tag "#{challenge.user.image}" %>
12 | <% elsif challenge.user.photo.attached? %>
13 | <%= cl_image_tag(challenge.user.photo.key) %>
14 | <% end %>
15 |
16 | <%#
17 | 1 days ago
18 |
%>
19 |
20 |
.
21 | <%= challenge.user.name %>
22 |
23 | <%= challenge.location %>
24 |
25 |
26 |
27 |
<%= challenge.filter.name %>
28 |
29 |
30 |
31 |
32 |
<%= challenge.title %>
33 |
34 |
35 |
36 |
Deadline: <%= challenge.deadline.strftime("%B %d, %Y") %>
37 |
38 |
39 |
40 |
41 |
42 | <%= link_to "View details", challenge_path(challenge), class:"btn btn-dark btn-lg rounded-lg", id:"button"%>
43 |
44 | <%#
%>
45 | <% end %>
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | <%# class h-100 sticks the footer at the bottom %>
4 |
5 |
6 | Dev.Work
7 |
8 | <%= csrf_meta_tags %>
9 | <%= csp_meta_tag %>
10 | <%# Bootstrap %>
11 |
12 | <%# Fontawesome %>
13 |
14 | <%# Box Icons %>
15 |
16 |
17 |
20 |
21 |
24 | <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
25 |
26 |
27 | <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
28 |
29 |
30 |
31 |
32 |
33 | <%#
%>
34 |
35 | <% unless current_page?(root_path) %>
36 | <%= render "shared/sidebar" %>
37 | <% end %>
38 | <%= render 'shared/flashes' %>
39 |
40 | <%= yield %>
41 |
42 |
43 |
44 | <% unless current_page?(root_path) %>
45 | <%= render "shared/footer" %>
46 | <% end %>
47 | <%#
%>
48 |
49 |
50 |
51 |
56 |
57 |
--------------------------------------------------------------------------------
/db/migrate/20220831095635_create_active_storage_tables.active_storage.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from active_storage (originally 20170806125915)
2 | class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
3 | def change
4 | # Use Active Record's configured type for primary and foreign keys
5 | primary_key_type, foreign_key_type = primary_and_foreign_key_types
6 |
7 | create_table :active_storage_blobs, id: primary_key_type do |t|
8 | t.string :key, null: false
9 | t.string :filename, null: false
10 | t.string :content_type
11 | t.text :metadata
12 | t.string :service_name, null: false
13 | t.bigint :byte_size, null: false
14 | t.string :checksum
15 |
16 | if connection.supports_datetime_with_precision?
17 | t.datetime :created_at, precision: 6, null: false
18 | else
19 | t.datetime :created_at, null: false
20 | end
21 |
22 | t.index [ :key ], unique: true
23 | end
24 |
25 | create_table :active_storage_attachments, id: primary_key_type do |t|
26 | t.string :name, null: false
27 | t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
28 | t.references :blob, null: false, type: foreign_key_type
29 |
30 | if connection.supports_datetime_with_precision?
31 | t.datetime :created_at, precision: 6, null: false
32 | else
33 | t.datetime :created_at, null: false
34 | end
35 |
36 | t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
37 | t.foreign_key :active_storage_blobs, column: :blob_id
38 | end
39 |
40 | create_table :active_storage_variant_records, id: primary_key_type do |t|
41 | t.belongs_to :blob, null: false, index: false, type: foreign_key_type
42 | t.string :variation_digest, null: false
43 |
44 | t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
45 | t.foreign_key :active_storage_blobs, column: :blob_id
46 | end
47 | end
48 |
49 | private
50 | def primary_and_foreign_key_types
51 | config = Rails.configuration.generators
52 | setting = config.options[config.orm][:primary_key_type]
53 | primary_key_type = setting || :primary_key
54 | foreign_key_type = setting || :bigint
55 | [primary_key_type, foreign_key_type]
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | # The test environment is used exclusively to run your application's
4 | # test suite. You never need to work with it otherwise. Remember that
5 | # your test database is "scratch space" for the test suite and is wiped
6 | # and recreated between test runs. Don't rely on the data there!
7 |
8 | Rails.application.configure do
9 | # Settings specified here will take precedence over those in config/application.rb.
10 |
11 | # Turn false under Spring and add config.action_view.cache_template_loading = true.
12 | config.cache_classes = true
13 |
14 | # Eager loading loads your whole application. When running a single test locally,
15 | # this probably isn't necessary. It's a good idea to do in a continuous integration
16 | # system, or in some way before deploying your code.
17 | config.eager_load = ENV["CI"].present?
18 |
19 | # Configure public file server for tests with Cache-Control for performance.
20 | config.public_file_server.enabled = true
21 | config.public_file_server.headers = {
22 | "Cache-Control" => "public, max-age=#{1.hour.to_i}"
23 | }
24 |
25 | # Show full error reports and disable caching.
26 | config.consider_all_requests_local = true
27 | config.action_controller.perform_caching = false
28 | config.cache_store = :null_store
29 |
30 | # Raise exceptions instead of rendering exception templates.
31 | config.action_dispatch.show_exceptions = false
32 |
33 | # Disable request forgery protection in test environment.
34 | config.action_controller.allow_forgery_protection = false
35 |
36 | # Store uploaded files on the local file system in a temporary directory.
37 | config.active_storage.service = :test
38 |
39 | config.action_mailer.perform_caching = false
40 |
41 | # Tell Action Mailer not to deliver emails to the real world.
42 | # The :test delivery method accumulates sent emails in the
43 | # ActionMailer::Base.deliveries array.
44 | config.action_mailer.delivery_method = :test
45 |
46 | # Print deprecation notices to the stderr.
47 | config.active_support.deprecation = :stderr
48 |
49 | # Raise exceptions for disallowed deprecations.
50 | config.active_support.disallowed_deprecation = :raise
51 |
52 | # Tell Active Support which deprecation messages to disallow.
53 | config.active_support.disallowed_deprecation_warnings = []
54 |
55 | # Raises error for missing translations.
56 | # config.i18n.raise_on_missing_translations = true
57 |
58 | # Annotate rendered view with file names.
59 | # config.action_view.annotate_rendered_view_with_filenames = true
60 | end
61 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | Rails.application.configure do
4 | # Settings specified here will take precedence over those in config/application.rb.
5 |
6 | # In the development environment your application's code is reloaded any time
7 | # it changes. This slows down response time but is perfect for development
8 | # since you don't have to restart the web server when you make code changes.
9 | config.cache_classes = false
10 |
11 | # Do not eager load code on boot.
12 | config.eager_load = false
13 |
14 | # Show full error reports.
15 | config.consider_all_requests_local = true
16 |
17 | # Enable server timing
18 | config.server_timing = true
19 |
20 | # Enable/disable caching. By default caching is disabled.
21 | # Run rails dev:cache to toggle caching.
22 | if Rails.root.join("tmp/caching-dev.txt").exist?
23 | config.action_controller.perform_caching = true
24 | config.action_controller.enable_fragment_cache_logging = true
25 |
26 | config.cache_store = :memory_store
27 | config.public_file_server.headers = {
28 | "Cache-Control" => "public, max-age=#{2.days.to_i}"
29 | }
30 | else
31 | config.action_controller.perform_caching = false
32 |
33 | config.cache_store = :null_store
34 | end
35 |
36 | # Store uploaded files on the local file system (see config/storage.yml for options).
37 | # config.active_storage.service = :local
38 | config.active_storage.service = :cloudinary
39 |
40 | # Don't care if the mailer can't send.
41 | config.action_mailer.raise_delivery_errors = false
42 |
43 | config.action_mailer.perform_caching = false
44 |
45 | # Print deprecation notices to the Rails logger.
46 | config.active_support.deprecation = :log
47 |
48 | # Raise exceptions for disallowed deprecations.
49 | config.active_support.disallowed_deprecation = :raise
50 |
51 | # Tell Active Support which deprecation messages to disallow.
52 | config.active_support.disallowed_deprecation_warnings = []
53 |
54 | # Raise an error on page load if there are pending migrations.
55 | config.active_record.migration_error = :page_load
56 |
57 | # Highlight code that triggered database queries in logs.
58 | config.active_record.verbose_query_logs = true
59 |
60 | # Suppress logger output for asset requests.
61 | config.assets.quiet = true
62 |
63 | # Raises error for missing translations.
64 | # config.i18n.raise_on_missing_translations = true
65 |
66 | # Annotate rendered view with file names.
67 | # config.action_view.annotate_rendered_view_with_filenames = true
68 |
69 | # Uncomment if you wish to allow Action Cable access from any origin.
70 | # config.action_cable.disable_request_forgery_protection = true
71 | end
72 |
--------------------------------------------------------------------------------
/app/views/shared/_sidebar.html.erb:
--------------------------------------------------------------------------------
1 |
78 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3 |
4 | ruby "3.1.2"
5 |
6 | gem "image_processing", ">= 1.2"
7 |
8 | # Random image gem
9 | gem "image_suckr"
10 |
11 |
12 | gem "dotenv-rails", groups: [:development, :test]
13 | # Font-awesome
14 |
15 | gem "font-awesome-rails"
16 |
17 | gem "geocoder"
18 | # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
19 | gem "rails", "~> 7.0.3", ">= 7.0.3.1"
20 |
21 | # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
22 | gem "sprockets-rails"
23 |
24 | # Use postgresql as the database for Active Record
25 | gem "pg", "~> 1.1"
26 |
27 | # Use the Puma web server [https://github.com/puma/puma]
28 | gem "puma", "~> 5.0"
29 |
30 | # Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
31 | gem "jsbundling-rails"
32 |
33 | # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
34 | gem "turbo-rails"
35 |
36 | # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
37 | gem "stimulus-rails"
38 |
39 | # Build JSON APIs with ease [https://github.com/rails/jbuilder]
40 | gem "jbuilder"
41 |
42 |
43 | # Use Redis adapter to run Action Cable in production
44 | # gem "redis", "~> 4.0"
45 |
46 | # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
47 | # gem "kredis"
48 |
49 | # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
50 | # gem "bcrypt", "~> 3.1.7"
51 |
52 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
53 | gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
54 |
55 | # Reduces boot times through caching; required in config/boot.rb
56 | gem "bootsnap", require: false
57 |
58 | # Use Sass to process CSS
59 | gem "sassc-rails"
60 |
61 | # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
62 | # gem "image_processing", "~> 1.2"
63 |
64 | gem "autoprefixer-rails"
65 | gem "font-awesome-sass", "~> 6.1"
66 | gem "simple_form", github: "heartcombo/simple_form"
67 | group :development, :test do
68 | # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
69 | gem "debug", platforms: %i[ mri mingw x64_mingw ]
70 | gem "dotenv-rails"
71 |
72 | end
73 |
74 | gem "pundit"
75 | gem "devise"
76 | # gem 'omniauth'
77 | gem 'omniauth-github'
78 | gem "omniauth-rails_csrf_protection"
79 | gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'master'
80 | gem "cloudinary"
81 |
82 | group :development do
83 | # Use console on exceptions pages [https://github.com/rails/web-console]
84 | gem "web-console"
85 |
86 | # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
87 | # gem "rack-mini-profiler"
88 |
89 | # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
90 | # gem "spring"
91 | end
92 |
93 | group :test do
94 | # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
95 | gem "capybara"
96 | gem "selenium-webdriver"
97 | gem "webdrivers"
98 | end
99 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/pages/_show.scss:
--------------------------------------------------------------------------------
1 | // .offers {
2 | // display: flex;
3 | // justify-content: space-between;
4 | // }
5 | body{
6 | background-image: linear-gradient(rgba(255, 255, 255, 0.8),rgba(221, 193, 193, 0.8)), url(wallpaper.jpg);
7 | background-repeat: no-repeat;
8 | background-position: center;
9 | background-size: cover;
10 | background-attachment: fixed;
11 |
12 | }
13 |
14 | .offers-container {
15 | display: flex;
16 | }
17 |
18 | .offers {
19 | display:grid;
20 | grid-template-columns: 1fr 1fr;
21 | grid-gap: 8px;
22 | justify-content: space-between;
23 | list-style-type: none;
24 | padding-left: none;
25 | list-style-position: inside;
26 | }
27 |
28 | // .offers li:not(:last-child) {
29 | // border-bottom: 1px solid rgba(128, 128, 128, 0.377);
30 | // }
31 |
32 | // .offers-right {
33 | // overflow-y: scroll;
34 | // margin-left: 15px;
35 | // border-radius: 20px;
36 | // box-shadow: 0 0 12px 0 rgba(0,0,0,0.2);
37 | // height: 100%;
38 | // }
39 |
40 | // .offers-right::-webkit-scrollbar {
41 | // display: none; /* Safari and Chrome */
42 | // }
43 |
44 | // .offers-left {
45 | // flex: 1;
46 | // }
47 |
48 | .cardshow {
49 | // overflow: hidden;
50 | height: auto;
51 | padding: 10px 0;
52 | // height: 100%;
53 | display: flex;
54 | background-color: white;
55 | flex-direction: column;
56 | align-items: center;
57 | border: none;
58 | transition: all 500ms cubic-bezier(0.19, 1, 0.22, 1);
59 | overflow: hidden;
60 | border-radius: 15px;
61 | box-shadow: 0 0 12px 0 rgba(0,0,0,0.2);
62 | // margin: 10px;
63 | }
64 |
65 | .card-body {
66 | width: 75%;
67 | }
68 |
69 | .card-image {
70 | text-align: center;
71 | margin-bottom: 10px;
72 | }
73 |
74 | .card-image img {
75 | height: 150px;
76 | width: 150px;
77 | margin-left: 15px;
78 | margin-right: 15px;
79 | border-radius: 50%;
80 | object-fit: cover;
81 | border: 2px solid rgba(43, 44, 43, 0.718);
82 | box-shadow: 2px 2px #05060636;
83 | }
84 |
85 | .comments {
86 | padding-left: none;
87 | }
88 |
89 | .comment {
90 | display: flex;
91 | align-items: center;
92 | }
93 |
94 | .comment img {
95 | margin: 15px;
96 | }
97 |
98 | #offer-alert {
99 | top: 90px;
100 | bottom: auto;
101 | // width: 100%;
102 | opacity: 0.9;
103 | }
104 |
105 |
106 | .show-grid {
107 | display: grid;
108 | grid-template-columns: 4fr 2fr;
109 | grid-gap: 26px;
110 | }
111 |
112 | .grid-left {
113 | height: 80vh;
114 | border-radius: 15px;
115 | display: flex;
116 | flex-direction: column;
117 | }
118 |
119 |
120 | .show-top-left {
121 | border-radius: 15px;
122 | overflow-y: scroll;
123 | flex-grow: 1;
124 | }
125 |
126 | .show-top-left::-webkit-scrollbar {
127 | display: none; /* Safari and Chrome */
128 | }
129 |
130 | .show-top-right {
131 | border-radius: 15px;
132 | }
133 |
134 | .grid-right {
135 | height: 80vh;
136 | overflow-y: scroll;
137 | border-radius: 15px;
138 | }
139 |
140 | .grid-right::-webkit-scrollbar {
141 | display: none; /* Safari and Chrome */
142 | }
143 |
144 | #challenge_buttons {
145 | border-radius: 15px !important;
146 | }
147 |
148 | .form-control {
149 | border-radius: 15px !important;
150 | }
151 |
152 | .form-select{
153 | border-radius: 15px !important;
154 | }
155 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # PostgreSQL. Versions 9.3 and up are supported.
2 | #
3 | # Install the pg driver:
4 | # gem install pg
5 | # On macOS with Homebrew:
6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7 | # On macOS with MacPorts:
8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9 | # On Windows:
10 | # gem install pg
11 | # Choose the win32 build.
12 | # Install PostgreSQL and put its /bin directory on your path.
13 | #
14 | # Configure Using Gemfile
15 | # gem "pg"
16 | #
17 | default: &default
18 | adapter: postgresql
19 | encoding: unicode
20 | # For details on connection pooling, see Rails configuration guide
21 | # https://guides.rubyonrails.org/configuring.html#database-pooling
22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23 |
24 | development:
25 | <<: *default
26 | database: DevWork_Development
27 |
28 | # The specified database role being used to connect to postgres.
29 | # To create additional roles in postgres see `$ createuser --help`.
30 | # When left blank, postgres will use the default role. This is
31 | # the same name as the operating system user running Rails.
32 | #username: rbnb
33 |
34 | # The password associated with the postgres role (username).
35 | #password:
36 |
37 | # Connect on a TCP socket. Omitted by default since the client uses a
38 | # domain socket that doesn't need configuration. Windows does not have
39 | # domain sockets, so uncomment these lines.
40 | #host: localhost
41 |
42 | # The TCP port the server listens on. Defaults to 5432.
43 | # If your server runs on a different port number, change accordingly.
44 | #port: 5432
45 |
46 | # Schema search path. The server defaults to $user,public
47 | #schema_search_path: myapp,sharedapp,public
48 |
49 | # Minimum log levels, in increasing order:
50 | # debug5, debug4, debug3, debug2, debug1,
51 | # log, notice, warning, error, fatal, and panic
52 | # Defaults to warning.
53 | #min_messages: notice
54 |
55 | # Warning: The database defined as "test" will be erased and
56 | # re-generated from your development database when you run "rake".
57 | # Do not set this db to the same as development or production.
58 | test:
59 | <<: *default
60 | database: Devwork_Test
61 |
62 | # As with config/credentials.yml, you never want to store sensitive information,
63 | # like your database password, in your source code. If your source code is
64 | # ever seen by anyone, they now have access to your database.
65 | #
66 | # Instead, provide the password or a full connection URL as an environment
67 | # variable when you boot the app. For example:
68 | #
69 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
70 | #
71 | # If the connection URL is provided in the special DATABASE_URL environment
72 | # variable, Rails will automatically merge its configuration values on top of
73 | # the values provided in this file. Alternatively, you can specify a connection
74 | # URL environment variable explicitly:
75 | #
76 | # production:
77 | # url: <%= ENV["MY_APP_DATABASE_URL"] %>
78 | #
79 | # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
80 | # for a full overview on how database connection configuration can be specified.
81 | #
82 | production:
83 | <<: *default
84 | database: DevWork_Production
85 | username: DevWork
86 | password: <%= ENV["DEVWORK_DATABASE_PASSWORD"] %>
87 |
--------------------------------------------------------------------------------
/app/controllers/challenges_controller.rb:
--------------------------------------------------------------------------------
1 | class ChallengesController < ApplicationController
2 | include ActionView::Helpers::UrlHelper
3 |
4 | before_action :set_challenge, only: %i[show edit update destroy]
5 |
6 | def show
7 | authorize @challenge
8 | @offers = @challenge.offers
9 | @offer = Offer.new
10 | end
11 |
12 | def index
13 | @challenges = policy_scope(Challenge)
14 | @filters = Filter.all
15 | if params[:filter].present? && params[:query].present? && params[:location].present?
16 | @filter = Filter.find_by(name: params[:filter])
17 | @challenges = Challenge.where('filter_id = ?', @filter.id).where("title ILIKE ?", "%#{params[:query]}%").where(location: params[:location])
18 | elsif params[:query].present? && params[:location].present?
19 | @challenges = Challenge.where("title ILIKE ?", "%#{params[:query]}%").where(location: params[:location])
20 | elsif params[:filter].present? && params[:location].present?
21 | @filter = Filter.find_by(name: params[:filter])
22 | @challenges = Challenge.where('filter_id = ?', @filter.id).where(location: params[:location])
23 | elsif params[:filter].present? && params[:query].present?
24 | @filter = Filter.find_by(name: params[:filter])
25 | @challenges = Challenge.where('filter_id = ?', @filter.id).where("title ILIKE ?", "%#{params[:query]}%")
26 | elsif params[:query].present?
27 | @challenges = Challenge.where("title ILIKE ?", "%#{params[:query]}%")
28 | elsif params[:location].present?
29 | @challenges = Challenge.where(location: params[:location])
30 | elsif params[:filter].present?
31 | @filter = Filter.find_by(name: params[:filter])
32 | @challenges = Challenge.where('filter_id = ?', @filter.id)
33 | elsif current_page?(my_challenges_path)
34 | @challenges = current_user.challenges
35 | else
36 | @challenges = Challenge.all
37 | end
38 |
39 | locations = Challenge.distinct.pluck(:location)
40 | @location_filters = []
41 | locations.each do |location|
42 | if !location.nil?
43 | @location_filters << location
44 | end
45 | end
46 |
47 | @markers = @challenges.geocoded.map do |challenge|
48 | {
49 | lat: challenge.latitude,
50 | lng: challenge.longitude,
51 | info_window: render_to_string(partial: "info_window", locals: {challenge: challenge})
52 | }
53 | end
54 | end
55 |
56 | def new
57 | @challenge = Challenge.new
58 | authorize @challenge
59 | end
60 |
61 | def create
62 | @challenge = Challenge.new(challenge_params)
63 | @challenge.user = current_user
64 | @challenge.filter = Filter.find(params[:challenge][:filter_id])
65 | authorize @challenge
66 | if @challenge.save
67 | redirect_to challenge_path(@challenge)
68 | else
69 | render :new, status: :unprocessable_entity
70 | end
71 | end
72 |
73 | def destroy
74 | authorize @challenge
75 | @challenge.destroy
76 | redirect_to challenges_path(@challenges), status: :see_other
77 | end
78 |
79 | def edit
80 | authorize @challenge
81 | end
82 |
83 | def update
84 | authorize @challenge
85 | @challenge.update(challenge_params)
86 | redirect_to challenge_path(@challenge)
87 | end
88 |
89 | private
90 |
91 | def set_challenge
92 | @challenge = Challenge.find(params[:id])
93 | end
94 |
95 | def challenge_params
96 | params.require(:challenge).permit(:title, :content, :price_max, :deadline, :location, photos: [])
97 | end
98 | end
99 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'bundle' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "rubygems"
12 |
13 | m = Module.new do
14 | module_function
15 |
16 | def invoked_as_script?
17 | File.expand_path($0) == File.expand_path(__FILE__)
18 | end
19 |
20 | def env_var_version
21 | ENV["BUNDLER_VERSION"]
22 | end
23 |
24 | def cli_arg_version
25 | return unless invoked_as_script? # don't want to hijack other binstubs
26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27 | bundler_version = nil
28 | update_index = nil
29 | ARGV.each_with_index do |a, i|
30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31 | bundler_version = a
32 | end
33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34 | bundler_version = $1
35 | update_index = i
36 | end
37 | bundler_version
38 | end
39 |
40 | def gemfile
41 | gemfile = ENV["BUNDLE_GEMFILE"]
42 | return gemfile if gemfile && !gemfile.empty?
43 |
44 | File.expand_path("../Gemfile", __dir__)
45 | end
46 |
47 | def lockfile
48 | lockfile =
49 | case File.basename(gemfile)
50 | when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51 | else "#{gemfile}.lock"
52 | end
53 | File.expand_path(lockfile)
54 | end
55 |
56 | def lockfile_version
57 | return unless File.file?(lockfile)
58 | lockfile_contents = File.read(lockfile)
59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60 | Regexp.last_match(1)
61 | end
62 |
63 | def bundler_requirement
64 | @bundler_requirement ||=
65 | env_var_version || cli_arg_version ||
66 | bundler_requirement_for(lockfile_version)
67 | end
68 |
69 | def bundler_requirement_for(version)
70 | return "#{Gem::Requirement.default}.a" unless version
71 |
72 | bundler_gem_version = Gem::Version.new(version)
73 |
74 | requirement = bundler_gem_version.approximate_recommendation
75 |
76 | return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
77 |
78 | requirement += ".a" if bundler_gem_version.prerelease?
79 |
80 | requirement
81 | end
82 |
83 | def load_bundler!
84 | ENV["BUNDLE_GEMFILE"] ||= gemfile
85 |
86 | activate_bundler
87 | end
88 |
89 | def activate_bundler
90 | gem_error = activation_error_handling do
91 | gem "bundler", bundler_requirement
92 | end
93 | return if gem_error.nil?
94 | require_error = activation_error_handling do
95 | require "bundler/version"
96 | end
97 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99 | exit 42
100 | end
101 |
102 | def activation_error_handling
103 | yield
104 | nil
105 | rescue StandardError, LoadError => e
106 | e
107 | end
108 | end
109 |
110 | m.load_bundler!
111 |
112 | if m.invoked_as_script?
113 | load Gem.bin_path("bundler", "bundle")
114 | end
115 |
--------------------------------------------------------------------------------
/app/views/shared/_footer.html.erb:
--------------------------------------------------------------------------------
1 |