diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f0527e6 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: +- package-ecosystem: bundler + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 diff --git a/.github/workflows/linter_erb.yml b/.github/workflows/linter_erb.yml new file mode 100644 index 0000000..81ba405 --- /dev/null +++ b/.github/workflows/linter_erb.yml @@ -0,0 +1,19 @@ +on: [push] + +name: Linter, ERB + +jobs: + run: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@main + + - name: Set up Ruby + uses: ruby/setup-ruby@master + with: + bundler-cache: true + + - name: Run ERB linter + run: bundle exec erb_lint app diff --git a/.github/workflows/linter_rubocop.yml b/.github/workflows/linter_rubocop.yml new file mode 100644 index 0000000..4549c51 --- /dev/null +++ b/.github/workflows/linter_rubocop.yml @@ -0,0 +1,19 @@ +on: [push] + +name: Linter, Rubocop + +jobs: + run: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@main + + - name: Set up Ruby + uses: ruby/setup-ruby@master + with: + bundler-cache: true + + - name: Run Rubocop linter + run: bundle exec rubocop diff --git a/.github/workflows/scan_ruby_brakeman.yml b/.github/workflows/scan_ruby_brakeman.yml new file mode 100644 index 0000000..37883a2 --- /dev/null +++ b/.github/workflows/scan_ruby_brakeman.yml @@ -0,0 +1,19 @@ +on: [push] + +name: Scan Ruby, Brakeman + +jobs: + scan_ruby: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@main + + - name: Set up Ruby + uses: ruby/setup-ruby@master + with: + bundler-cache: true + + - name: Scan for common Rails security vulnerabilities using static analysis + run: bin/brakeman --no-pager diff --git a/.rubocop.yml b/.rubocop.yml index 5537838..db6c2e5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,100 +1,33 @@ -require: rubocop-rspec +inherit_from: .rubocop_todo.yml -AllCops: - TargetRubyVersion: 2.5 - - Exclude: - - 'db/**/*' - - 'script/*' - - 'bin/*' - - 'log/**/*' - - 'node_modules/**/*' - - 'public/**/*' - - 'vendor/**/*' - - 'tmp/**/*' - - '.git/**/*' - -IndentationConsistency: - EnforcedStyle: 'rails' - -Naming/FileName: - Exclude: - - 'Gemfile' - - 'Guardfile' - - 'Rakefile' - -Rails: - Enabled: true - -Metrics/CyclomaticComplexity: - Max: 15 - -Metrics/PerceivedComplexity: - Max: 15 - -Metrics/ClassLength: - Max: 210 - -Metrics/ParameterLists: - Max: 6 - -Metrics/LineLength: - Max: 200 - -Metrics/MethodLength: - Max: 40 - -Metrics/BlockLength: - Max: 140 +plugins: + - rubocop-capybara + - rubocop-rails + - rubocop-rspec + - rubocop-rspec_rails +AllCops: + NewCops: enable Exclude: - - 'spec/**/*' - -Metrics/AbcSize: - Max: 65 - -Style/Documentation: - Enabled: false + - "db/schema.rb" + - "script/*" + - "bin/*" + - "log/**/*" + - "node_modules/**/*" + - "public/**/*" + - "vendor/**/*" + - "tmp/**/*" + - ".git/**/*" -Style/SymbolArray: - Enabled: false +Layout/HashAlignment: + EnforcedHashRocketStyle: table + EnforcedColonStyle: table -Style/MethodDefParentheses: +Rails/I18nLocaleTexts: Enabled: false -Style/AsciiComments: - Enabled: false - -Style/NestedParenthesizedCalls: - Enabled: false - -# TEMP: private and def foo() are at the same indentation level -# This should NOT cause an offense but it does. ¯\_(ツ)_/¯ -# https://rubocop.readthedocs.io/en/latest/cops_layout/ -Layout/IndentationWidth: +Style/Documentation: Enabled: false Style/FrozenStringLiteralComment: Enabled: false - -Rails/OutputSafety: - Enabled: false - -RSpec/NestedGroups: - Max: 4 - -RSpec/ExampleLength: - Max: 20 - -RSpec/MultipleExpectations: - Max: 10 - -RSpec/VerifiedDoubles: - Enabled: false - -RSpec/MessageSpies: - Enabled: false - -RSpec/DescribeClass: - Exclude: - - 'spec/system/*' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..3749664 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,28 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2025-08-09 04:53:37 UTC using RuboCop version 1.79.2. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Max: 15 + +# Offense count: 5 +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 9 + +# Offense count: 3 +RSpec/MultipleExpectations: + Max: 3 + +# Offense count: 2 +# Configuration parameters: Include. +# Include: db/**/*.rb +Rails/ThreeStateBooleanColumn: + Exclude: + - 'db/migrate/20170516194159_create_submissions.rb' diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..4f5e697 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.4.5 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 0224d95..071f00c 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,74 +1,85 @@ -# Contributor Covenant Code of Conduct +# Contributor Covenant 3.0 Code of Conduct ## Our Pledge -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of experience, -nationality, personal appearance, race, religion, or sexual identity and -orientation. +We pledge to make our community welcoming, safe, and equitable for all. -## Our Standards +We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of characteristics including race, ethnicity, caste, color, age, physical characteristics, neurodiversity, disability, sex or gender, gender identity or expression, sexual orientation, language, philosophy or religion, national or social origin, socio-economic position, level of education, or other status. The same privileges of participation are extended to everyone who participates in good faith and in accordance with this Covenant. -Examples of behavior that contributes to creating a positive environment -include: +## Encouraged Behaviors -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +While acknowledging differences in social norms, we all strive to meet our community's expectations for positive behavior. We also understand that our words and actions may be interpreted differently than we intend based on culture, background, or native language. -Examples of unacceptable behavior by participants include: +With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including: -* The use of sexualized language or imagery and unwelcome sexual attention or -advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +1. Respecting the **purpose of our community**, our activities, and our ways of gathering. +2. Engaging **kindly and honestly** with others. +3. Respecting **different viewpoints** and experiences. +4. **Taking responsibility** for our actions and contributions. +5. Gracefully giving and accepting **constructive feedback**. +6. Committing to **repairing harm** when it occurs. +7. Behaving in other ways that promote and sustain the **well-being of our community**. -## Our Responsibilities +## Restricted Behaviors -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. +We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct. -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. +1. **Harassment.** Violating explicitly expressed boundaries or engaging in unnecessary personal attention after any clear request to stop. +2. **Character attacks.** Making insulting, demeaning, or pejorative comments directed at a community member or group of people. +3. **Stereotyping or discrimination.** Characterizing anyone’s personality or behavior on the basis of immutable identities or traits. +4. **Sexualization.** Behaving in a way that would generally be considered inappropriately intimate in the context or purpose of the community. +5. **Violating confidentiality**. Sharing or acting on someone's personal or private information without their permission. +6. **Endangerment.** Causing, encouraging, or threatening violence or other harm toward any person or group. +7. Behaving in other ways that **threaten the well-being** of our community. -## Scope +### Other Restrictions + +1. **Misleading identity.** Impersonating someone else for any reason, or pretending to be someone else to evade enforcement actions. +2. **Failing to credit sources.** Not properly crediting the sources of content you contribute. +3. **Promotional materials**. Sharing marketing or other commercial content in a way that is outside the norms of the community. +4. **Irresponsible communication.** Failing to responsibly present content which includes, links or describes any other restricted behaviors. + +## Reporting an Issue + +Tensions can occur between community members even when they are trying their best to collaborate. Not every conflict represents a code of conduct violation, and this Code of Conduct reinforces encouraged behaviors and norms that can help avoid conflicts and minimize harm. + +When an incident does occur, it is important to report it promptly. To report a possible violation, **[NOTE: describe your means of reporting here.]** + +Community Moderators take reports of violations seriously and will make every effort to respond in a timely manner. They will investigate all reports of code of conduct violations, reviewing messages, logs, and recordings, or interviewing witnesses and other participants. Community Moderators will keep investigation and enforcement actions as transparent as possible while prioritizing safety and confidentiality. In order to honor these values, enforcement actions are carried out in private with the involved parties, but communicating to the whole community may be part of a mutually agreed upon resolution. -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. +## Addressing and Repairing Harm -## Enforcement +**[NOTE: The remedies and repairs outlined below are suggestions based on best practices in code of conduct enforcement. If your community has its own established enforcement process, be sure to edit this section to describe your own policies.]** -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at veganstraightedge@gmail.com. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. +If an investigation by the Community Moderators finds that this Code of Conduct has been violated, the following enforcement ladder may be used to determine how best to repair harm, based on the incident's impact on the individuals involved and the community as a whole. Depending on the severity of a violation, lower rungs on the ladder may be skipped. -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. +1) Warning + 1) Event: A violation involving a single incident or series of incidents. + 2) Consequence: A private, written warning from the Community Moderators. + 3) Repair: Examples of repair include a private written apology, acknowledgement of responsibility, and seeking clarification on expectations. +2) Temporarily Limited Activities + 1) Event: A repeated incidence of a violation that previously resulted in a warning, or the first incidence of a more serious violation. + 2) Consequence: A private, written warning with a time-limited cooldown period designed to underscore the seriousness of the situation and give the community members involved time to process the incident. The cooldown period may be limited to particular communication channels or interactions with particular community members. + 3) Repair: Examples of repair may include making an apology, using the cooldown period to reflect on actions and impact, and being thoughtful about re-entering community spaces after the period is over. +3) Temporary Suspension + 1) Event: A pattern of repeated violation which the Community Moderators have tried to address with warnings, or a single serious violation. + 2) Consequence: A private written warning with conditions for return from suspension. In general, temporary suspensions give the person being suspended time to reflect upon their behavior and possible corrective actions. + 3) Repair: Examples of repair include respecting the spirit of the suspension, meeting the specified conditions for return, and being thoughtful about how to reintegrate with the community when the suspension is lifted. +4) Permanent Ban + 1) Event: A pattern of repeated code of conduct violations that other steps on the ladder have failed to resolve, or a violation so serious that the Community Moderators determine there is no way to keep the community safe with this person as a member. + 2) Consequence: Access to all community spaces, tools, and communication channels is removed. In general, permanent bans should be rarely used, should have strong reasoning behind them, and should only be resorted to if working through other remedies has failed to change the behavior. + 3) Repair: There is no possible repair in cases of this severity. + +This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping with the best interests of our community. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public or other spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [http://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the Contributor Covenant, version 3.0, permanently available at [https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/). + +Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under CC BY-SA 4.0. To view a copy of this license, visit [https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/) -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ +For answers to common questions about Contributor Covenant, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are provided at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). Additional enforcement and community guideline resources can be found at [https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources). The enforcement ladder was inspired by the work of [Mozilla’s code of conduct team](https://github.com/mozilla/inclusion). diff --git a/Gemfile b/Gemfile index 1e59be6..18b0038 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,9 @@ source 'https://rubygems.org' -ruby '3.2.2' + +ruby file: '.ruby-version' # app server -gem 'rails', '~> 5.2.0' +gem 'rails' # database gem 'pg' @@ -10,50 +11,25 @@ gem 'pg' # webserver gem 'puma' -# webserver -gem 'microformats', '~> 4.0.7' - -# assets -gem 'autoprefixer-rails' -gem 'bootstrap' -gem 'jquery-rails' -gem 'sass-rails' -gem 'uglifier' - -# For codestyle guide and linting -gem 'rubocop', require: false -gem 'rubocop-rspec' +# parser +gem 'microformats' # dev and testing group :development, :test do - gem 'byebug', platform: :mri - gem 'factory_bot_rails' - gem 'guard-rspec' - gem 'nokogiri' + gem 'brakeman', require: false + gem 'erb_lint', require: false + gem 'capybara' gem 'rails-controller-testing' gem 'rspec-rails' - gem 'simplecov', require: false - gem 'spring-commands-rspec' -end - -# dev -group :development do - gem 'listen', '~> 3.1.5' - gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' - gem 'web-console' - - # For measuring page/code performance - gem 'rack-mini-profiler' - - # For memory profiling - gem 'memory_profiler' - - # For call-stack profiling flamegraphs - gem 'fast_stack' - gem 'flamegraph' - gem 'stackprof' + gem 'selenium-webdriver' + + # For codestyle guide and linting + gem 'rubocop', require: false + gem 'rubocop-capybara', require: false + gem 'rubocop-rails', require: false + gem 'rubocop-rspec', require: false + gem 'rubocop-rspec_rails', require: false end # windows dev -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem 'tzinfo-data', platforms: %i[windows jruby] diff --git a/Gemfile.lock b/Gemfile.lock index b825237..65afff2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,294 +1,351 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.0) - actionpack (= 5.2.0) + actioncable (8.0.2) + actionpack (= 8.0.2) + activesupport (= 8.0.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.0) - actionpack (= 5.2.0) - actionview (= 5.2.0) - activejob (= 5.2.0) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (5.2.0) - actionview (= 5.2.0) - activesupport (= 5.2.0) - rack (~> 2.0) + zeitwerk (~> 2.6) + actionmailbox (8.0.2) + actionpack (= 8.0.2) + activejob (= 8.0.2) + activerecord (= 8.0.2) + activestorage (= 8.0.2) + activesupport (= 8.0.2) + mail (>= 2.8.0) + actionmailer (8.0.2) + actionpack (= 8.0.2) + actionview (= 8.0.2) + activejob (= 8.0.2) + activesupport (= 8.0.2) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (8.0.2) + actionview (= 8.0.2) + activesupport (= 8.0.2) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.0) - activesupport (= 5.2.0) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (8.0.2) + actionpack (= 8.0.2) + activerecord (= 8.0.2) + activestorage (= 8.0.2) + activesupport (= 8.0.2) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (8.0.2) + activesupport (= 8.0.2) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.0) - activesupport (= 5.2.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (8.0.2) + activesupport (= 8.0.2) globalid (>= 0.3.6) - activemodel (5.2.0) - activesupport (= 5.2.0) - activerecord (5.2.0) - activemodel (= 5.2.0) - activesupport (= 5.2.0) - arel (>= 9.0) - activestorage (5.2.0) - actionpack (= 5.2.0) - activerecord (= 5.2.0) - marcel (~> 0.3.1) - activesupport (5.2.0) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - arel (9.0.0) - ast (2.4.0) - autoprefixer-rails (9.1.0) - execjs - bindex (0.5.0) - bootstrap (4.1.3) - autoprefixer-rails (>= 6.0.3) - popper_js (>= 1.12.9, < 2) - sass (>= 3.5.2) - builder (3.2.3) - byebug (10.0.2) - coderay (1.1.2) - concurrent-ruby (1.0.5) - crass (1.0.4) - diff-lcs (1.3) - docile (1.3.1) - erubi (1.7.1) - execjs (2.7.0) - factory_bot (4.10.0) - activesupport (>= 3.0.0) - factory_bot_rails (4.10.0) - factory_bot (~> 4.10.0) - railties (>= 3.0.0) - fast_stack (0.2.0) - ffi (1.9.25) - flamegraph (0.9.5) - formatador (0.2.5) - globalid (0.4.1) - activesupport (>= 4.2.0) - guard (2.14.2) - formatador (>= 0.2.4) - listen (>= 2.7, < 4.0) - lumberjack (>= 1.0.12, < 2.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.9.12) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-rspec (4.7.3) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) - i18n (1.0.1) + activemodel (8.0.2) + activesupport (= 8.0.2) + activerecord (8.0.2) + activemodel (= 8.0.2) + activesupport (= 8.0.2) + timeout (>= 0.4.0) + activestorage (8.0.2) + actionpack (= 8.0.2) + activejob (= 8.0.2) + activerecord (= 8.0.2) + activesupport (= 8.0.2) + marcel (~> 1.0) + activesupport (8.0.2) + base64 + benchmark (>= 0.3) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.3) + base64 (0.3.0) + benchmark (0.4.1) + better_html (2.1.1) + actionview (>= 6.0) + activesupport (>= 6.0) + ast (~> 2.0) + erubi (~> 1.4) + parser (>= 2.4) + smart_properties + bigdecimal (3.2.2) + brakeman (7.1.0) + racc + builder (3.3.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + concurrent-ruby (1.3.5) + connection_pool (2.5.3) + crass (1.0.6) + date (3.4.1) + diff-lcs (1.6.2) + drb (2.2.3) + erb (5.0.2) + erb_lint (0.9.0) + activesupport + better_html (>= 2.0.1) + parser (>= 2.7.1.4) + rainbow + rubocop (>= 1) + smart_properties + erubi (1.13.1) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.7) concurrent-ruby (~> 1.0) - jaro_winkler (1.5.1) - jquery-rails (4.3.3) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - json (2.1.0) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - loofah (2.2.2) + io-console (0.8.1) + irb (1.15.2) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + json (2.13.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + logger (1.7.0) + loofah (2.24.1) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - lumberjack (1.0.13) - mail (2.7.0) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (0.3.2) - mimemagic (~> 0.3.2) - memory_profiler (0.9.11) - method_source (0.9.0) - microformats (4.0.7) + net-imap + net-pop + net-smtp + marcel (1.0.4) + matrix (0.4.3) + microformats (4.5.0) json nokogiri - mimemagic (0.3.10) - nokogiri (~> 1) - rake - mini_mime (1.0.0) - mini_portile2 (2.3.0) - minitest (5.11.3) - nenv (0.3.0) - nio4r (2.3.1) - nokogiri (1.8.4) - mini_portile2 (~> 2.3.0) - notiffany (0.1.1) - nenv (~> 0.1) - shellany (~> 0.0) - parallel (1.12.1) - parser (2.5.1.2) - ast (~> 2.4.0) - pg (1.0.0) - popper_js (1.14.3) - powerpack (0.1.2) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - puma (3.12.0) - rack (2.0.5) - rack-mini-profiler (1.0.0) - rack (>= 1.2.0) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (5.2.0) - actioncable (= 5.2.0) - actionmailer (= 5.2.0) - actionpack (= 5.2.0) - actionview (= 5.2.0) - activejob (= 5.2.0) - activemodel (= 5.2.0) - activerecord (= 5.2.0) - activestorage (= 5.2.0) - activesupport (= 5.2.0) - bundler (>= 1.3.0) - railties (= 5.2.0) - sprockets-rails (>= 2.0.0) - rails-controller-testing (1.0.2) - actionpack (~> 5.x, >= 5.0.1) - actionview (~> 5.x, >= 5.0.1) - activesupport (~> 5.x) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + mini_mime (1.1.5) + minitest (5.25.5) + net-imap (0.5.9) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.1) + net-protocol + nio4r (2.7.4) + nokogiri (1.18.9-aarch64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.9-aarch64-linux-musl) + racc (~> 1.4) + nokogiri (1.18.9-arm-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.9-arm-linux-musl) + racc (~> 1.4) + nokogiri (1.18.9-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.9-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.18.9-x86_64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.9-x86_64-linux-musl) + racc (~> 1.4) + parallel (1.27.0) + parser (3.3.9.0) + ast (~> 2.4.1) + racc + pg (1.6.1) + pg (1.6.1-aarch64-linux) + pg (1.6.1-aarch64-linux-musl) + pg (1.6.1-arm64-darwin) + pg (1.6.1-x86_64-darwin) + pg (1.6.1-x86_64-linux) + pg (1.6.1-x86_64-linux-musl) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) + prism (1.4.0) + psych (5.2.6) + date + stringio + public_suffix (6.0.2) + puma (6.6.1) + nio4r (~> 2.0) + racc (1.8.1) + rack (3.2.0) + rack-session (2.1.1) + base64 (>= 0.1.0) + rack (>= 3.0.0) + rack-test (2.2.0) + rack (>= 1.3) + rackup (2.2.1) + rack (>= 3) + rails (8.0.2) + actioncable (= 8.0.2) + actionmailbox (= 8.0.2) + actionmailer (= 8.0.2) + actionpack (= 8.0.2) + actiontext (= 8.0.2) + actionview (= 8.0.2) + activejob (= 8.0.2) + activemodel (= 8.0.2) + activerecord (= 8.0.2) + activestorage (= 8.0.2) + activesupport (= 8.0.2) + bundler (>= 1.15.0) + railties (= 8.0.2) + rails-controller-testing (1.0.5) + actionpack (>= 5.0.1.rc1) + actionview (>= 5.0.1.rc1) + activesupport (>= 5.0.1.rc1) + rails-dom-testing (2.3.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) - railties (5.2.0) - actionpack (= 5.2.0) - activesupport (= 5.2.0) - method_source - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rainbow (3.0.0) - rake (12.3.1) - rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) - rspec (3.8.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-core (3.8.0) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.0) + rails-html-sanitizer (1.6.2) + loofah (~> 2.21) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (8.0.2) + actionpack (= 8.0.2) + activesupport (= 8.0.2) + irb (~> 1.13) + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.3.0) + rdoc (6.14.2) + erb + psych (>= 4.0.0) + regexp_parser (2.11.1) + reline (0.6.2) + io-console (~> 0.5) + rexml (3.4.1) + rspec-core (3.13.5) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (3.8.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.0) - rubocop (0.58.2) - jaro_winkler (~> 1.5.1) + rspec-support (~> 3.13.0) + rspec-rails (8.0.1) + actionpack (>= 7.2) + activesupport (>= 7.2) + railties (>= 7.2) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.4) + rubocop (1.79.2) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) - parser (>= 2.5, != 2.5.1.1) - powerpack (~> 0.1) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.46.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - rubocop-rspec (1.27.0) - rubocop (>= 0.56.0) - ruby-progressbar (1.9.0) - ruby_dep (1.5.0) - sass (3.5.7) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) - railties (>= 4.0.0, < 6) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) - shellany (0.0.1) - simplecov (0.16.1) - docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - spring (2.0.2) - activesupport (>= 4.2) - spring-commands-rspec (1.0.4) - spring (>= 0.9.1) - spring-watcher-listen (2.0.1) - listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) - sprockets (3.7.2) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.46.0) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-capybara (2.22.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rails (2.32.0) + activesupport (>= 4.2.0) + lint_roller (~> 1.1) + rack (>= 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rspec (3.6.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rspec_rails (2.31.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rspec (~> 3.5) + ruby-progressbar (1.13.0) + rubyzip (2.4.1) + securerandom (0.4.1) + selenium-webdriver (4.34.0) + base64 (~> 0.2) + logger (~> 1.4) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + smart_properties (1.17.0) + stringio (3.1.7) + thor (1.4.0) + timeout (0.4.3) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) - sprockets (>= 3.0.0) - stackprof (0.2.12) - thor (0.20.0) - thread_safe (0.3.6) - tilt (2.0.8) - tzinfo (1.2.10) - thread_safe (~> 0.1) - uglifier (4.1.17) - execjs (>= 0.3.0, < 3) - unicode-display_width (1.4.0) - web-console (3.6.2) - actionview (>= 5.0) - activemodel (>= 5.0) - bindex (>= 0.4.0) - railties (>= 5.0) - websocket-driver (0.7.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) + uri (1.0.3) + useragent (0.16.11) + websocket (1.2.11) + websocket-driver (0.8.0) + base64 websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + zeitwerk (2.7.3) PLATFORMS - ruby + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86_64-darwin + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES - autoprefixer-rails - bootstrap - byebug - factory_bot_rails - fast_stack - flamegraph - guard-rspec - jquery-rails - listen (~> 3.1.5) - memory_profiler - microformats (~> 4.0.7) - nokogiri + brakeman + capybara + erb_lint + microformats pg puma - rack-mini-profiler - rails (~> 5.2.0) + rails rails-controller-testing rspec-rails rubocop + rubocop-capybara + rubocop-rails rubocop-rspec - sass-rails - simplecov - spring - spring-commands-rspec - spring-watcher-listen (~> 2.0.0) - stackprof + rubocop-rspec_rails + selenium-webdriver tzinfo-data - uglifier - web-console RUBY VERSION - ruby 2.5.1p57 + ruby 3.4.5p51 BUNDLED WITH - 1.16.2 + 2.7.1 diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 61ad10d..e69de29 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,19 +0,0 @@ -@import "bootstrap"; - -form { - label { - font-weight: bold; - } - - textarea, - input[type=url], - input[type=text] { - font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; - } - - .form-control:disabled { - cursor: default; - background: #efefef; - color: black; - } -} diff --git a/app/controllers/microformats_controller.rb b/app/controllers/microformats_controller.rb index 3025fa6..fb8ac01 100644 --- a/app/controllers/microformats_controller.rb +++ b/app/controllers/microformats_controller.rb @@ -9,7 +9,7 @@ def show results[:debug] = { package: 'https://rubygems.org/gems/microformats', version: Microformats::VERSION, - note: [ + note: [ 'This output was generated from the microformats-ruby gem available at https://github.com/indieweb/microformats-ruby', 'Please file any issues with the parser at https://github.com/indieweb/microformats-rubygems/issues' ] @@ -17,7 +17,7 @@ def show render json: JSON.pretty_generate(results) else - redirect_to new_submission_path + redirect_to :root end end end diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 63f82a2..7cdb458 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -1,10 +1,9 @@ class SubmissionsController < ApplicationController - before_action :set_submission, only: [:show, :edit, :update, :destroy] + before_action :set_submission, only: %i[show edit update destroy] + before_action :redirect_to_root, only: %i[index edit update destroy] # GET /submissions - def index - redirect_to new_submission_path - end + def index; end # GET /submissions/1 def show; end @@ -15,9 +14,7 @@ def new end # GET /submissions/1/edit - def edit - redirect_to new_submission_path - end + def edit; end # POST /submissions def create @@ -40,14 +37,10 @@ def create end # PATCH/PUT /submissions/1 - def update - redirect_to new_submission_path - end + def update; end # DELETE /submissions/1 - def destroy - redirect_to new_submission_path - end + def destroy; end private @@ -56,8 +49,12 @@ def set_submission @submission = Submission.find(params[:id]) end + def redirect_to_root + redirect_to :root + end + # Only allow a trusted parameter "white list" through. def submission_params - params.require(:submission).permit(:url, :html, :base_url, :save_html, :render_html_in_page) + params.expect submission: %i[url html base_url save_html render_html_in_page] end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..68b00c5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,16 @@ module ApplicationHelper + # From: https://getbootstrap.com/docs/5.3/getting-started/download/#cdn-via-jsdelivr + BOOTSTRAP_VERSION = '5.3.7'.freeze + BOOTSTRAP_CSS_INTEGRITY = 'sha384-LN+7fdVzj6u52u30Kp6M/trliBMCMKTyK833zpbD+pXdCLuTusPj697FH4R/5mcr'.freeze + + def bootstrap_stylesheet_link_tag + stylesheet_link_tag "https://cdn.jsdelivr.net/npm/bootstrap@#{BOOTSTRAP_VERSION}/dist/css/bootstrap.min.css", + media: 'all', + integrity: BOOTSTRAP_CSS_INTEGRITY, + crossorigin: 'anonymous' + end + + def on_results_page? + action_name != 'new' + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e4f2361..19cf2f2 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -3,17 +3,28 @@
-