diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..be2e5fb6c --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,145 @@ +version: 2.1 + +orbs: + browser-tools: circleci/browser-tools@2.2.0 + node: circleci/node@7.1.0 + +jobs: + build: + parallelism: 1 + resource_class: large + docker: + - image: cimg/ruby:4.0.6-browsers + environment: + BUNDLE_PATH: vendor/bundle + NODE_VERSION: 22.17.1 + PGHOST: 127.0.0.1 + PGUSER: postgres + RAILS_ENV: test + - image: cimg/postgres:10.18 + environment: + POSTGRES_USER: postgres + POSTGRES_DB: app_test + POSTGRES_PASSWORD: + + steps: + - checkout + + - node/install: + node-version: 26.7.0 + + - node/install-packages: + pkg-manager: pnpm + + - browser-tools/install_firefox + + - run: + name: Which versions? + command: | + bundle -v + node --version + pnpm --version + + # https://circleci.com/docs/2.0/caching/ + - restore_cache: + keys: + - bundle-v2-{{ checksum "Gemfile.lock" }} + - bundle-v2 + + - run: # Install Ruby dependencies + name: Bundle Install + command: | + bundle config set --local frozen 'true' + bundle install + bundle clean + + - save_cache: + key: bundle-v2-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + + - run: + name: Wait for DB + command: dockerize -wait tcp://localhost:5432 -timeout 1m + + - run: + name: Database setup + command: bin/rails db:setup --trace + + - run: + name: Typescript + command: pnpm tscheck + + - run: + name: Find Unused ESLint Rules + command: pnpm eslint_find_unused_rules + + - run: + name: ESLint + command: pnpm eslint + + - run: + name: Verify ESLint Autogen + command: bundle exec exe/eslint_autogen + + - run: + name: Vitest + command: pnpm vitest run --coverage + + - run: + name: Brakeman + command: bundle exec brakeman + + - run: + name: Stylelint + command: pnpm stylelint + + - run: + name: Verify Stylelint Autogen + command: bundle exec exe/stylelint_autogen + + - run: + name: Rubocop + command: bundle exec rubocop + + - run: + name: ✨ 🌈 ✨ Run Unit Tests ✨ 🌈 ✨ + command: | + TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \ + grep -v "spec/system" | \ + circleci tests split --split-by=timings)" + + echo "******************** TEST_FILES ************************" + echo "bundle exec rspec -s $TEST_FILES" + echo "********************************************************" + + COVERAGE=true bundle exec rspec \ + --format progress \ + --format RspecJunitFormatter \ + --out /tmp/test-results/unit/rspec.xml \ + $TEST_FILES + + - run: + name: ✨ 🌈 ✨ Run System Tests ✨ 🌈 ✨ + command: | + TEST_FILES="$(circleci tests glob "spec/system/**/*_spec.rb" | \ + circleci tests split --split-by=timings)" + + echo "******************** TEST_FILES ************************" + echo "bundle exec rspec -s $TEST_FILES" + echo "********************************************************" + + mkdir -p tmp/capybara + + COVERAGE=false xvfb-run -a bundle exec rspec \ + --format progress \ + --format RspecJunitFormatter \ + --out /tmp/test-results/system/rspec.xml \ + $TEST_FILES + + - store_test_results: + path: /tmp/test-results + + - store_artifacts: + path: tmp/capybara + destination: capybara diff --git a/.dockerignore b/.dockerignore index 745841df6..f1bf829df 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,8 @@ .git/* .gitignore log/* -tmp/* + +# Generated at runtime and mounted in by compose. A local copy baked into the +# image would be loaded by dotenv, silently overriding the intended config. +.env +.env.*.local diff --git a/.env.development b/.env.development new file mode 100644 index 000000000..7ae8c1e97 --- /dev/null +++ b/.env.development @@ -0,0 +1,7 @@ +# you can use `rails secret` to generate this for production +SECRET_KEY_BASE=dev_secret + +# you can use `rails db:encryption:init` to generate these for production +ENCRYPTION_PRIMARY_KEY=dev_primary_key +ENCRYPTION_DETERMINISTIC_KEY=dev_deterministic_key +ENCRYPTION_KEY_DERIVATION_SALT=dev_derivation_salt diff --git a/.env.test b/.env.test new file mode 100644 index 000000000..b6f983942 --- /dev/null +++ b/.env.test @@ -0,0 +1,7 @@ +# you can use `rails secret` to generate this for production +SECRET_KEY_BASE=test_secret + +# you can use `rails db:encryption:init` to generate these for production +ENCRYPTION_PRIMARY_KEY=test_primary_key +ENCRYPTION_DETERMINISTIC_KEY=test_deterministic_key +ENCRYPTION_KEY_DERIVATION_SALT=test_derivation_salt diff --git a/.eslint_todo.ts b/.eslint_todo.ts new file mode 100644 index 000000000..d65430851 --- /dev/null +++ b/.eslint_todo.ts @@ -0,0 +1,558 @@ +// This configuration was generated by `exe/eslint_autogen` +// on 2026-07-06 17:55:24 UTC. +// The point is for the user to remove these configuration records +// one by one as the offenses are removed from the code base. + +import type {Linter} from "eslint"; + +const config: Linter.Config[] = [ + // Offense count: 6 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "@stylistic/comma-dangle": "off", + }, + }, + // Offense count: 3 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "@stylistic/key-spacing": "off", + }, + }, + // Offense count: 2 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "@stylistic/keyword-spacing": "off", + }, + }, + // Offense count: 20 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + "vitest.config.ts", + ], + rules: { + "@stylistic/max-len": "off", + }, + }, + // Offense count: 2 + { + files: [ + "spec/javascript/setup.ts", + ], + rules: { + "@stylistic/multiline-comment-style": "off", + }, + }, + // Offense count: 4 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "@stylistic/multiline-ternary": "off", + }, + }, + // Offense count: 3 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/spec/models/story_spec.ts", + ], + rules: { + "@stylistic/no-extra-parens": "off", + }, + }, + // Offense count: 40 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "@stylistic/object-curly-spacing": "off", + }, + }, + // Offense count: 3 + { + files: [ + "app/javascript/application.ts", + "stylelint.config.mjs", + ], + rules: { + "@stylistic/quote-props": "off", + }, + }, + // Offense count: 41 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + ], + rules: { + "@stylistic/quotes": "off", + }, + }, + // Offense count: 1 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "@stylistic/semi": "off", + }, + }, + // Offense count: 1 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "@stylistic/space-before-blocks": "off", + }, + }, + // Offense count: 42 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "@stylistic/space-before-function-paren": "off", + }, + }, + // Offense count: 4 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "@typescript-eslint/ban-ts-comment": "off", + }, + }, + // Offense count: 9 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "@typescript-eslint/explicit-function-return-type": "off", + }, + }, + // Offense count: 1 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "@typescript-eslint/no-deprecated": "off", + }, + }, + // Offense count: 5 + { + files: [ + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "@typescript-eslint/no-empty-function": "off", + }, + }, + // Offense count: 5 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "@typescript-eslint/no-unsafe-argument": "off", + }, + }, + // Offense count: 51 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "@typescript-eslint/no-unsafe-assignment": "off", + }, + }, + // Offense count: 181 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "@typescript-eslint/no-unsafe-call": "off", + }, + }, + // Offense count: 266 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "@typescript-eslint/no-unsafe-member-access": "off", + }, + }, + // Offense count: 5 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "@typescript-eslint/no-unsafe-return": "off", + }, + }, + // Offense count: 2 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "@typescript-eslint/prefer-destructuring": "off", + }, + }, + // Offense count: 2 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "@typescript-eslint/prefer-nullish-coalescing": "off", + }, + }, + // Offense count: 1 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "@typescript-eslint/prefer-optional-chain": "off", + }, + }, + // Offense count: 22 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/spec/models/story_spec.ts", + ], + rules: { + "@typescript-eslint/strict-boolean-expressions": "off", + }, + }, + // Offense count: 21 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/controllers/story_refresh_controller_spec.ts", + "spec/javascript/helpers/api_spec.ts", + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "camelcase": "off", + }, + }, + // Offense count: 2 + { + files: [ + "spec/javascript/setup.ts", + ], + rules: { + "capitalized-comments": "off", + }, + }, + // Offense count: 13 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "curly": "off", + }, + }, + // Offense count: 2 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "eqeqeq": "off", + }, + }, + // Offense count: 109 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "func-names": "off", + }, + }, + // Offense count: 3 + { + files: [ + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "func-style": "off", + }, + }, + // Offense count: 10 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "id-length": "off", + }, + }, + // Offense count: 16 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + "spec/javascript/spec/views/story_view_spec.ts", + "vitest.config.ts", + ], + rules: { + "max-len": "off", + }, + }, + // Offense count: 1 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "max-lines": "off", + }, + }, + // Offense count: 3 + { + files: [ + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "max-lines-per-function": "off", + }, + }, + // Offense count: 1 + { + files: [ + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "max-statements": "off", + }, + }, + // Offense count: 2 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + ], + rules: { + "new-cap": "off", + }, + }, + // Offense count: 2 + { + files: [ + "spec/javascript/spec/models/story_spec.ts", + ], + rules: { + "no-implicit-coercion": "off", + }, + }, + // Offense count: 2 + { + files: [ + "spec/javascript/spec/models/story_spec.ts", + ], + rules: { + "no-multi-assign": "off", + }, + }, + // Offense count: 1 + { + files: [ + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "no-negated-condition": "off", + }, + }, + // Offense count: 1 + { + files: [ + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "no-param-reassign": "off", + }, + }, + // Offense count: 2 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "no-plusplus": "off", + }, + }, + // Offense count: 2 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "no-ternary": "off", + }, + }, + // Offense count: 38 + { + files: [ + "app/javascript/application.ts", + ], + rules: { + "object-shorthand": "off", + }, + }, + // Offense count: 1 + { + files: [ + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "one-var": "off", + }, + }, + // Offense count: 64 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "prefer-arrow-callback": "off", + }, + }, + // Offense count: 6 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + ], + rules: { + "prefer-named-capture-group": "off", + }, + }, + // Offense count: 6 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/setup.ts", + ], + rules: { + "require-unicode-regexp": "off", + }, + }, + // Offense count: 1 + { + files: [ + "spec/javascript/setup.ts", + ], + rules: { + "sort-imports": "off", + }, + }, + // Offense count: 11 + { + files: [ + "app/javascript/application.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "vars-on-top": "off", + }, + }, + // Offense count: 6 + { + files: [ + "spec/javascript/controllers/story_refresh_controller_spec.ts", + "spec/javascript/helpers/api_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "vitest/no-hooks": "off", + }, + }, + // Offense count: 11 + { + files: [ + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "vitest/prefer-called-with": "off", + }, + }, + // Offense count: 4 + { + files: [ + "spec/javascript/spec/models/story_spec.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "vitest/prefer-lowercase-title": "off", + }, + }, + // Offense count: 4 + { + files: [ + "spec/javascript/setup.ts", + "spec/javascript/spec/views/story_view_spec.ts", + ], + rules: { + "vitest/require-hook": "off", + }, + }, +]; + +export default config; diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..31eeee0b6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +# See https://git-scm.com/docs/gitattributes for more about git attribute files. + +# Mark the database schema as having been generated. +db/schema.rb linguist-generated + +# Mark any vendored files as having been vendored. +vendor/* linguist-vendored diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..d916cd6ae --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: mockdeep diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..937450997 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: Build Docker image and push to Dockerhub + +on: + push: + pull_request: + workflow_dispatch: + +env: + IMAGE_NAME: stringerrss/stringer + +jobs: + build_docker: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract Docker sha tag + id: get-tag-sha + uses: docker/metadata-action@v4 + with: + images: ${{ env.IMAGE_NAME }} + tags: type=sha + + - name: Extract Docker latest tag + id: get-tag-latest + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_NAME }} + tags: type=raw, value=latest + + - name: Log in to Docker Hub + if: ${{ github.ref_name == 'main' }} + id: login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and Push + id: build-and-push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.ref_name == 'main' }} + tags: | + ${{ steps.get-tag-latest.outputs.tags }} + ${{ steps.get-tag-sha.outputs.tags }} diff --git a/.gitignore b/.gitignore index e35bb576d..75d4d90a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,40 @@ -*.gem -*.rbc -.bundle -.config -.ruby-gemset -coverage -InstalledFiles -lib/bundler/man -pkg -rdoc -spec/reports -test/tmp -test/version_tmp -tmp -log +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' -# YARD artifacts -.yardoc -_yardoc -doc/ -bin/ +# Ignore bundler config. +/.bundle -db/*.sqlite -.DS_Store -.localeapp +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore uploaded files in development. +/storage/* +!/storage/.keep + +/public/assets +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key +spec/examples.txt +/coverage/* + +/public/packs +/public/packs-test +/node_modules +/app/assets/builds/* +!/app/assets/builds/.keep +tsconfig.tsbuildinfo +.eslintcache + +# Ignore local environment variable files. The docker setup generates real +# secrets into .env, so it must never be committed; .env.development and +# .env.test hold placeholders only and are tracked deliberately. +.env +.env.*.local diff --git a/.mcp.json b/.mcp.json new file mode 100644 index 000000000..6fdb146fc --- /dev/null +++ b/.mcp.json @@ -0,0 +1,16 @@ +{ + "mcpServers": { + "playwright": { + "type": "stdio", + "command": "npx", + "args": [ + "-y", + "@playwright/mcp@latest", + "--caps", + "core,tabs,vision", + "--output-dir", + ".playwright-mcp" + ] + } + } +} diff --git a/.node-version b/.node-version new file mode 100644 index 000000000..0fcfe3593 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +v26.7.0 diff --git a/.rspec b/.rspec index cf6add7ea..a35c44f4b 100644 --- a/.rspec +++ b/.rspec @@ -1 +1 @@ ---colour \ No newline at end of file +--require rails_helper diff --git a/.rubocop.yml b/.rubocop.yml index a7403fc37..2a6a297b2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,31 +1,90 @@ +require: + - ./linters/rubocop/cop/rspec/no_before_hook + inherit_from: .rubocop_todo.yml +inherit_mode: { merge: [Exclude] } + +plugins: + - rubocop-capybara + - rubocop-factory_bot + - rubocop-i18n + - rubocop-rails + - rubocop-rake + - rubocop-rspec + - rubocop-rspec_rails AllCops: + DisplayCopNames: true + EnabledByDefault: true Exclude: - 'db/schema.rb' - 'vendor/**/*' - TargetRubyVersion: 2.3 - -Metrics/LineLength: - Max: 120 - -Metrics/MethodLength: - Max: 15 - -Style/Documentation: - Enabled: false -Style/DoubleNegation: - Enabled: false - -Style/IfUnlessModifier: - MaxLineLength: 120 +Layout/LineLength: { Max: 80, Exclude: [db/migrate/*.rb] } +Layout/RedundantLineBreak: { InspectBlocks: true } +Metrics/AbcSize: { Exclude: [db/migrate/*.rb], CountRepeatedAttributes: false } +Metrics/BlockLength: + Exclude: [config/**/*.rb, db/migrate/*.rb, spec/**/*.rb, db/seeds/**/*.rb] +Metrics/MethodLength: { Exclude: [db/migrate/*.rb] } +Rails/SkipsModelValidations: { AllowedMethods: [update_all] } +RSpec/DescribeClass: { Exclude: [spec/system/**/*] } +RSpec/MessageExpectation: + EnforcedStyle: expect + Exclude: [spec/support/matchers/**/*.rb] +RSpec/MessageSpies: { EnforcedStyle: receive } +RSpec/MultipleMemoizedHelpers: + Max: 0 + AllowSubject: false + Exclude: + - spec/linters/rubocop/**/*.rb +Style/ClassAndModuleChildren: { EnforcedStyle: compact } +Style/MethodCallWithArgsParentheses: + AllowedMethods: + - and + - to + - not_to + - describe + - require + - task + Exclude: + - db/**/*.rb +Style/StringLiterals: { EnforcedStyle: double_quotes } +Style/SymbolArray: { EnforcedStyle: brackets } +Style/WordArray: { EnforcedStyle: brackets } -Style/NumericLiterals: - Enabled: false +# want to enable these, but they don't work right when using `.rubocop_todo.yml` +Style/DocumentationMethod: { Enabled: false } +Style/Documentation: { Enabled: false } +I18n/RailsI18n/DecorateString: + Exclude: + - Rakefile + - linters/**/*.rb + - spec/**/*.rb -Style/StringLiterals: - EnforcedStyle: double_quotes +################################################################################ +# +# Rules we don't want to enable +# +################################################################################ -Style/WhileUntilModifier: - MaxLineLength: 120 +Bundler/GemComment: { Enabled: false } +Bundler/GemVersion: { Enabled: false } +Capybara/AmbiguousClick: { Enabled: false } +I18n/GetText: { Enabled: false } +Layout/SingleLineBlockChain: { Enabled: false } +Lint/ConstantResolution: { Enabled: false } +Rails/BulkChangeTable: { Enabled: false } +Rails/RedundantPresenceValidationOnBelongsTo: { Enabled: false } +RSpec/AlignLeftLetBrace: { Enabled: false } +RSpec/AlignRightLetBrace: { Enabled: false } +Rails/HasManyOrHasOneDependent: { Enabled: false } +RSpec/IndexedLet: { Enabled: false } +RSpec/StubbedMock: { Enabled: false } +Rails/SchemaComment: { Enabled: false } +Style/ConstantVisibility: { Enabled: false } +Style/Copyright: { Enabled: false } +Style/InlineComment: { Enabled: false } +Style/MissingElse: { Enabled: false } +Style/RequireOrder: { Enabled: false } +Style/SafeNavigation: { Enabled: false } +Style/StringHashKeys: { Enabled: false } diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0e4ee7524..50c036344 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,14 +1,354 @@ # This configuration was generated by -# `rubocop --auto-gen-config` -# on 2016-03-22 20:52:58 +0100 using RuboCop version 0.38.0. +# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 400` +# on 2026-06-21 23:25:43 UTC using RuboCop version 1.87.0. # 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: 163 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: when_needed, always -Style/FrozenStringLiteralComment: - Enabled: false +# Offense count: 4 +Capybara/RSpec/NegationMatcherAfterVisit: + Exclude: + - 'spec/system/account_setup_spec.rb' + - 'spec/system/stories_index_spec.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'db/migrate/20240314031219_recreate_good_job_cron_indexes_with_conditional.rb' + - 'db/migrate/20240314031221_create_good_job_labels_index.rb' + - 'db/migrate/20240314031223_create_index_good_job_jobs_for_candidate_lookup.rb' + +# Offense count: 19 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultilineFinalElement. +Layout/MultilineMethodArgumentLineBreaks: + Exclude: + - 'db/migrate/20240314031219_recreate_good_job_cron_indexes_with_conditional.rb' + - 'db/migrate/20240314031221_create_good_job_labels_index.rb' + - 'db/migrate/20240314031223_create_index_good_job_jobs_for_candidate_lookup.rb' + +# Offense count: 10 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredClasses. +# AllowedMethods: ago, from_now, second, seconds, minute, minutes, hour, hours, day, days, week, weeks, fortnight, fortnights, in_milliseconds +# IgnoredClasses: Time, DateTime +Lint/NumberConversion: + Exclude: + - 'Rakefile' + - 'app/commands/fever_api/authentication.rb' + - 'app/commands/story/mark_group_as_read.rb' + - 'app/models/feed.rb' + - 'app/models/story.rb' + - 'app/repositories/story_repository.rb' + - 'spec/models/feed_spec.rb' + - 'spec/models/story_spec.rb' + +# Offense count: 1 +# Configuration parameters: CountComments, Max, CountAsOne. +Metrics/ClassLength: + Exclude: + - 'app/repositories/story_repository.rb' + +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns, Max. +Metrics/CyclomaticComplexity: + Exclude: + - 'db/migrate/20240314031219_recreate_good_job_cron_indexes_with_conditional.rb' + +# Offense count: 5 +# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Exclude: + - 'app/models/story.rb' + - 'app/repositories/story_repository.rb' + - 'app/utils/opml_parser.rb' + - 'app/utils/sample_story.rb' + +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns, Max. +Metrics/PerceivedComplexity: + Exclude: + - 'db/migrate/20240314031219_recreate_good_job_cron_indexes_with_conditional.rb' + +# Offense count: 3 +# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates. +# AllowedMethods: call +# WaywardPredicates: infinite?, nonzero? +Naming/PredicateMethod: + Exclude: + - 'app/utils/sample_story.rb' + +# Offense count: 2 +# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs. +# NamePrefix: is_, has_, have_, does_ +# ForbiddenPrefixes: is_, has_, have_, does_ +# AllowedMethods: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicatePrefix: + Exclude: + - 'app/utils/sample_story.rb' + +# Offense count: 4 +RSpec/Be: + Exclude: + - 'spec/commands/feed/import_from_opml_spec.rb' + +# Offense count: 13 +# Configuration parameters: Prefixes, AllowedPatterns. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/commands/feed/create_spec.rb' + - 'spec/commands/feed/fetch_one_spec.rb' + - 'spec/commands/feed/find_new_stories_spec.rb' + - 'spec/commands/feed/import_from_opml_spec.rb' + - 'spec/integration/feed_importing_spec.rb' + +# Offense count: 1 +# Configuration parameters: IgnoredMetadata. +RSpec/DescribeClass: + Exclude: + - 'spec/integration/feed_importing_spec.rb' + +# Offense count: 70 +# Configuration parameters: Max, CountAsOne. +RSpec/ExampleLength: + Exclude: + - 'spec/commands/feed/create_spec.rb' + - 'spec/commands/feed/export_to_opml_spec.rb' + - 'spec/commands/fever_api/read_favicons_spec.rb' + - 'spec/commands/fever_api/read_feeds_groups_spec.rb' + - 'spec/commands/fever_api/read_items_spec.rb' + - 'spec/helpers/url_helpers_spec.rb' + - 'spec/integration/feed_importing_spec.rb' + - 'spec/models/feed_spec.rb' + - 'spec/models/migration_status_spec.rb' + - 'spec/models/story_spec.rb' + - 'spec/repositories/group_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/system/add_feed_spec.rb' + - 'spec/system/archive_spec.rb' + - 'spec/system/feed_edit_spec.rb' + - 'spec/system/feed_show_spec.rb' + - 'spec/system/feeds_index_spec.rb' + - 'spec/system/good_job_spec.rb' + - 'spec/system/import_spec.rb' + - 'spec/system/keyboard_shortcuts_spec.rb' + - 'spec/system/starred_spec.rb' + - 'spec/system/stories_index_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' + - 'spec/utils/opml_parser_spec.rb' + +# Offense count: 16 +RSpec/LeakyLocalVariable: + Exclude: + - 'spec/commands/feed/import_from_opml_spec.rb' + - 'spec/integration/feed_importing_spec.rb' + - 'spec/requests/feeds_controller_spec.rb' + - 'spec/requests/imports_controller_spec.rb' + - 'spec/requests/stories_controller_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' + +# Offense count: 19 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: allow, expect +RSpec/MessageExpectation: + Exclude: + - 'spec/commands/feed/fetch_one_spec.rb' + - 'spec/integration/feed_importing_spec.rb' + - 'spec/models/migration_status_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/system/stories_index_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/i18n_support_spec.rb' + +# Offense count: 34 +# Configuration parameters: Max. +RSpec/MultipleExpectations: + Exclude: + - 'spec/commands/feed/create_spec.rb' + - 'spec/commands/feed/export_to_opml_spec.rb' + - 'spec/commands/feed/import_from_opml_spec.rb' + - 'spec/repositories/feed_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/system/add_feed_spec.rb' + - 'spec/system/keyboard_shortcuts_spec.rb' + - 'spec/system/starred_spec.rb' + - 'spec/system/stories_index_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + - 'spec/utils/feed_discovery_spec.rb' + - 'spec/utils/i18n_support_spec.rb' + - 'spec/utils/opml_parser_spec.rb' + - 'spec/utils/safe_fetch_spec.rb' + +# Offense count: 5 +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only +RSpec/NamedSubject: + Exclude: + - 'spec/commands/fever_api/write_mark_item_spec.rb' + +# Offense count: 2 +# Configuration parameters: Max, AllowedGroups. +RSpec/NestedGroups: + Exclude: + - 'spec/integration/feed_importing_spec.rb' + +# Offense count: 3 +RSpec/NoBeforeHook: + Exclude: + - 'spec/commands/feed/import_from_opml_spec.rb' + - 'spec/system/authentication_spec.rb' + - 'spec/system/profile_spec.rb' + +# Offense count: 6 +# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. +RSpec/VerifiedDoubles: + Exclude: + - 'spec/commands/feed/fetch_one_spec.rb' + - 'spec/commands/feed/find_new_stories_spec.rb' + - 'spec/commands/story/refresh_from_feed_spec.rb' + - 'spec/tasks/remove_old_stories_spec.rb' + +# Offense count: 1 +Rails/Env: + Exclude: + - 'spec/rails_helper.rb' + +# Offense count: 2 +# Configuration parameters: IgnoreScopes. +Rails/InverseOf: + Exclude: + - 'app/models/feed.rb' + +# Offense count: 3 +Rails/ReversibleMigrationMethodDefinition: + Exclude: + - 'db/migrate/20130423001740_drop_email_from_user.rb' + - 'db/migrate/20130423180446_remove_author_from_stories.rb' + - 'db/migrate/20130425222157_add_delayed_job.rb' + +# Offense count: 9 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowImplicitReturn, AllowedReceivers. +Rails/SaveBang: + Exclude: + - 'app/commands/feed/create.rb' + - 'app/commands/feed/import_from_opml.rb' + - 'app/repositories/feed_repository.rb' + - 'app/repositories/story_repository.rb' + - 'app/repositories/user_repository.rb' + - 'db/migrate/20130821020313_update_nil_entry_ids.rb' + +# Offense count: 2 +# Configuration parameters: ForbiddenMethods, AllowedMethods. +# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all +Rails/SkipsModelValidations: + Exclude: + - 'db/migrate/20140421224454_fix_invalid_unicode.rb' + - 'db/migrate/20141102103617_fix_invalid_titles_with_unicode_line_endings.rb' + +# Offense count: 5 +Rails/ThreeStateBooleanColumn: + Exclude: + - 'db/migrate/20130412185253_add_new_fields_to_stories.rb' + - 'db/migrate/20130425211008_add_setup_complete_to_user.rb' + - 'db/migrate/20130513025939_add_keep_unread_to_stories.rb' + - 'db/migrate/20130513044029_add_is_starred_status_for_stories.rb' + - 'db/migrate/20230801025233_create_good_job_executions.rb' + +# Offense count: 6 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/TimeZone: + Exclude: + - 'app/commands/feed/find_new_stories.rb' + - 'app/repositories/story_repository.rb' + - 'app/tasks/remove_old_stories.rb' + - 'app/utils/sample_story.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Rails/Validation: + Exclude: + - 'app/models/story.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules. +# SupportedStyles: nested, compact +# SupportedStylesForClasses: ~, nested, compact +# SupportedStylesForModules: ~, nested, compact +Style/ClassAndModuleChildren: + Exclude: + - 'linters/rubocop/cop/rspec/no_before_hook.rb' + +# Offense count: 23 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: brackets, fetch +Style/HashLookupMethod: + Exclude: + - 'app/commands/story/mark_as_read.rb' + - 'app/commands/story/mark_as_starred.rb' + - 'app/commands/story/mark_as_unread.rb' + - 'app/commands/story/mark_as_unstarred.rb' + - 'app/controllers/application_controller.rb' + - 'app/controllers/feeds_controller.rb' + - 'app/controllers/stories_controller.rb' + - 'config/application.rb' + - 'exe/eslint_autogen' + - 'exe/stylelint_autogen' + - 'spec/repositories/feed_repository_spec.rb' + - 'spec/repositories/story_repository_spec.rb' + - 'spec/repositories/user_repository_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/IfUnlessModifier: + Exclude: + - 'db/migrate/20240314031223_create_index_good_job_jobs_for_candidate_lookup.rb' + +# Offense count: 1 +# Configuration parameters: AllowedClasses. +Style/OneClassPerFile: + Exclude: + - 'config/application.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: return, return_nil +Style/ReturnNil: + Exclude: + - 'app/repositories/user_repository.rb' + +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/StaticClass: + Exclude: + - 'app/repositories/feed_repository.rb' + - 'app/repositories/group_repository.rb' + - 'app/repositories/story_repository.rb' + - 'app/repositories/user_repository.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiteralsInInterpolation: + Exclude: + - 'exe/stylelint_autogen' + +# Offense count: 1 +Style/TopLevelMethodDefinition: + Exclude: + - 'spec/integration/feed_importing_spec.rb' diff --git a/.ruby-version b/.ruby-version index 0bee604df..d13e837c8 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.3 +4.0.6 diff --git a/.stylelint_todo.yml b/.stylelint_todo.yml new file mode 100644 index 000000000..e6959f1fd --- /dev/null +++ b/.stylelint_todo.yml @@ -0,0 +1,66 @@ +# This configuration was generated by `exe/stylelint_autogen` +# on 2026-02-19 04:45:04 UTC. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. + +overrides: + + # Offense count: 5 + - rules: { 'alpha-value-notation': null } + files: + - app/assets/stylesheets/application.css + + # Offense count: 5 + - rules: { 'color-function-alias-notation': null } + files: + - app/assets/stylesheets/application.css + + # Offense count: 5 + - rules: { 'color-function-notation': null } + files: + - app/assets/stylesheets/application.css + + # Offense count: 1 + - rules: { 'color-hex-length': null } + files: + - app/assets/stylesheets/application.css + + # Offense count: 2 + - rules: { 'comment-empty-line-before': null } + files: + - app/assets/stylesheets/application.css + + # Offense count: 3 + - rules: { 'font-family-name-quotes': null } + files: + - app/assets/stylesheets/application.css + + # Offense count: 15 + - rules: { 'length-zero-no-unit': null } + files: + - app/assets/stylesheets/application.css + + # Offense count: 3 + - rules: { 'media-feature-range-notation': null } + files: + - app/assets/stylesheets/application.css + + # Offense count: 21 + - rules: { 'no-descending-specificity': null } + files: + - app/assets/stylesheets/application.css + + # Offense count: 68 + - rules: { 'order/properties-order': null } + files: + - app/assets/stylesheets/application.css + + # Offense count: 19 + - rules: { 'property-no-vendor-prefix': null } + files: + - app/assets/stylesheets/application.css + + # Offense count: 2 + - rules: { 'selector-class-pattern': null } + files: + - app/assets/stylesheets/application.css diff --git a/.tool-versions b/.tool-versions index 69ed28bbf..7e59aec6d 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1,4 @@ -ruby 2.3.3 +ruby 4.0.6 +nodejs 26.7.0 +postgres 16.8 +pnpm 10.5.2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 501560eae..000000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -before_install: - - gem update bundler - - 'echo "RUBY_VERSION: $RUBY_VERSION"' -before_script: - - npm install -g mocha-phantomjs@4.1.0 - - bundle exec rake test_js &> /dev/null & - - sleep 5 -cache: bundler -language: ruby -rvm: - - 2.3.3 - - ruby-head -matrix: - allow_failures: - - rvm: ruby-head -script: - - bundle exec rspec - - mocha-phantomjs http://localhost:4567/test - - bundle exec rubocop -sudo: false diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..4adde9f37 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,54 @@ +# AGENTS.md + +This file provides guidance to coding agents when working with code in this repository. + +## What this is + +Stringer is a self-hosted, anti-social RSS reader: a Rails 8.1 app (Ruby 4.0) backed by PostgreSQL, with feed fetching run as background jobs via GoodJob. The README's mention of Backbone.js is partly outdated — see the frontend notes below. + +## Commands + +Toolchain versions are pinned in `.tool-versions` (Ruby 4.0.5, Node 26.3.0, Postgres 16.8, pnpm 10.5.2). + +- **Setup:** `bin/setup` (runs `bundle install`, `db:prepare`, clears logs/tmp, then launches the dev server). Pass `--skip-server` to stop before launching. +- **Run dev server:** `bin/dev` (foreman against `Procfile.dev` — boots Puma on port 3000 plus `js`/`css` esbuild watchers). The app is at `http://localhost:3000`. +- **Ruby tests:** `bundle exec rspec`. Run a single file/example with `bundle exec rspec spec/path/to/file_spec.rb:LINE`. +- **JS tests:** `pnpm test` (vitest + jsdom with coverage). Specs live in `spec/javascript/**/*_spec.ts`. `pnpm test` runs `pretest` first, which runs `tscheck` and `eslint`. +- **Type check:** `pnpm tscheck` (`tsc --noEmit`). +- **Lint (Ruby):** `bundle exec rubocop`. **Lint (JS):** `pnpm eslint`. **Lint (CSS):** `pnpm stylelint`. +- **Security scan:** `bundle exec brakeman`. +- **Interactive console:** `rake console` (or `bin/rails console`). +- **Asset build (one-off):** `pnpm build` (JS via esbuild) and `pnpm build:css` (CSS via esbuild). + +Feed operations are exposed as rake tasks: `rake fetch_feeds`, `rake fetch_feed[ID]`, `rake lazy_fetch`, `rake cleanup_old_stories[DAYS]` (default 30 days; removes read, unstarred stories). + +## Architecture + +**Command objects (`app/commands/`)** hold the business logic. Each is a module or class with a single `.call` entry point (e.g. `Feed::FetchOne.call(feed)`), grouped by domain (`feed/`, `story/`, `user/`, `fever_api/`). Controllers and jobs stay thin and delegate to commands. When adding behavior, prefer a new command over fattening a controller or model. + +**Repositories (`app/repositories/`)** wrap all ActiveRecord query/persistence logic (`FeedRepository`, `StoryRepository`, `GroupRepository`, `UserRepository`). Commands and controllers go through repositories rather than calling `Feed.where(...)` etc. directly. Keep DB access in the repository layer. + +**Background jobs** funnel through a single `CallableJob`, which just calls any callable: `CallableJob.perform_later(Feed::FetchOne, feed)` enqueues `Feed::FetchOne.call(feed)`. There is rarely a need to write a new `ApplicationJob` subclass — enqueue a command via `CallableJob` instead. Jobs run on GoodJob (Postgres-backed). + +**Feed fetching flow:** `Feed::FetchAll` → enqueues `Feed::FetchOne` per feed → `HTTParty` fetches, `Feedjira` parses → `Feed::FindNewStories` diffs against the latest stored entry → `StoryRepository.add`. Fetch failures set the feed status to `:red` (vs `:green`) and log rather than raise. + +**Admin routes** under `/admin` (GoodJob dashboard, settings, debug) are gated by `AdminConstraint` (`lib/admin_constraint.rb`). Stringer is single-user; auth is password-based (`bcrypt`). + +**Fever API:** Stringer implements a clone of the Fever API (`fever_controller`, `app/commands/fever_api/`) so third-party mobile clients can connect. + +## Frontend + +Assets are bundled with **esbuild**, not Rails' asset pipeline compilation (Propshaft serves the built files). Two distinct JS worlds coexist: + +- **Stimulus controllers** (`app/javascript/controllers/`) — the current approach for new interactive behavior (dialogs, hotkeys, toggles). +- **Backbone** (`app/javascript/application.ts`) — the legacy story-list view (`Story`/`StoryView`/`StoryList`/`AppView`), which talks to `/stories`. Note this file is `@ts-nocheck`. Underscore templates use custom `{{ }}` delimiters (set in `application.ts`), not the default `<% %>`. + +Turbo Drive is explicitly **disabled** (`Turbo.session.drive = false`). + +## Linting baselines + +ESLint, Stylelint, and RuboCop each use a generated "todo" baseline file (`.eslint_todo.ts`, `.stylelint_todo.yml`, `.rubocop_todo.yml`) that suppresses pre-existing offenses. The intent is to ratchet these down over time — fix offenses and remove their entries rather than adding new suppressions. Regenerate via `bundle exec exe/eslint_autogen` / `bundle exec exe/stylelint_autogen` (CI checks that the committed baseline matches). A custom RuboCop cop lives in `linters/rubocop/cop/`. + +## CI + +CircleCI (`.circleci/config.yml`) runs, in order: `tscheck`, eslint (incl. unused-rule check and autogen drift check), vitest, brakeman, stylelint (+ autogen drift), rubocop, then rspec (with `xvfb-run` for system specs). Match this locally before pushing. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..fa581a793 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders 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, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +robert@boon.gl. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/Dockerfile b/Dockerfile index 8ccb1ad59..72e4f3fc3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,21 @@ -FROM ruby:2.3.3 +FROM ruby:4.0.6 ENV RACK_ENV=production +ENV RAILS_ENV=production ENV PORT=8080 +ENV BUNDLER_VERSION=2.6.2 EXPOSE 8080 +SHELL ["/bin/bash", "-c"] + WORKDIR /app ADD Gemfile Gemfile.lock /app/ -RUN bundle install --deployment +RUN gem install bundler:$BUNDLER_VERSION && bundle install RUN apt-get update \ && apt-get install -y --no-install-recommends \ - supervisor locales nodejs \ + supervisor locales nodejs vim nano \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* @@ -19,14 +23,18 @@ RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales \ && locale-gen C.UTF-8 \ && /usr/sbin/update-locale LANG=C.UTF-8 -ENV LC_ALL C.UTF-8 +ENV LC_ALL=C.UTF-8 -ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.3/supercronic-linux-amd64 \ - SUPERCRONIC=supercronic-linux-amd64 \ - SUPERCRONIC_SHA1SUM=96960ba3207756bb01e6892c978264e5362e117e +ARG TARGETARCH +ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.3/supercronic-linux-$TARGETARCH \ + SUPERCRONIC=supercronic-linux-$TARGETARCH \ + SUPERCRONIC_amd64_SHA1SUM=96960ba3207756bb01e6892c978264e5362e117e \ + SUPERCRONIC_arm_SHA1SUM=8c1e7af256ee35a9fcaf19c6a22aa59a8ccc03ef \ + SUPERCRONIC_arm64_SHA1SUM=f0e8049f3aa8e24ec43e76955a81b76e90c02270 \ + SUPERCRONIC_SHA1SUM="SUPERCRONIC_${TARGETARCH}_SHA1SUM" RUN curl -fsSLO "$SUPERCRONIC_URL" \ - && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ + && echo "${!SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ && chmod +x "$SUPERCRONIC" \ && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ && ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic @@ -39,4 +47,6 @@ RUN useradd -m stringer RUN chown -R stringer:stringer /app USER stringer +ENV RAILS_SERVE_STATIC_FILES=true + CMD /app/start.sh diff --git a/Gemfile b/Gemfile index db9447538..dcc9f8573 100644 --- a/Gemfile +++ b/Gemfile @@ -1,49 +1,69 @@ -ruby_version_file = File.join(File.expand_path("..", __FILE__), ".ruby-version") +# frozen_string_literal: true + +ruby_version_file = File.expand_path(".ruby-version", __dir__) ruby File.read(ruby_version_file).chomp if File.readable?(ruby_version_file) source "https://rubygems.org" +git_source(:github) { |repo| "https://github.com/#{repo}.git" } -group :production do - gem "pg", "~> 0.18.4" - gem "unicorn", "~> 4.7" -end +gem "dotenv-rails" + +gem "rails", "~> 8.1.0" + +gem "addressable" +gem "bcrypt" +gem "bootsnap", require: false +gem "cssbundling-rails" +gem "feedbag" +gem "feedjira" +gem "goldiloader" +gem "good_job" +gem "httparty" +gem "jsbundling-rails" +gem "nokogiri" +gem "pg" +gem "private_address_check", require: "private_address_check/tcpsocket_ext" +gem "propshaft" +gem "puma" +gem "rack-ssl" +gem "sass" +gem "stimulus-rails" +gem "stripe" +gem "strong_migrations" +gem "thread" +gem "turbo-rails" +gem "will_paginate" group :development do - gem "sqlite3", "~> 1.3", ">= 1.3.8" + gem "brakeman", require: false + gem "rubocop", require: false + gem "rubocop-capybara", require: false + gem "rubocop-factory_bot", require: false + gem "rubocop-i18n", require: false + gem "rubocop-rails", require: false + gem "rubocop-rake", require: false + gem "rubocop-rspec", require: false + gem "rubocop-rspec_rails", require: false + gem "web-console" end group :development, :test do - gem "capybara", "~> 2.6" - gem "coveralls", "~> 0.7", require: false - gem "faker", "~> 1.2" - gem "pry-byebug", "~> 1.2" - gem "rack-test", "~> 0.6" - gem "rspec", "~> 3.4" - gem "rspec-html-matchers", "~> 0.7" - gem "rubocop", "~> 0.38", require: false - gem "shotgun", "~> 0.9" - gem "timecop", "~> 0.8" + gem "bundler-audit", require: false + gem "capybara" + gem "coveralls_reborn", require: false + gem "debug" + gem "factory_bot" + gem "factory_bot_rails", require: false + gem "pry-byebug" + gem "rspec" + gem "rspec-rails" + gem "simplecov" + gem "webmock", require: false end -gem "activerecord", "~> 4.2.6" -gem "bcrypt", "~> 3.1" -gem "delayed_job", "~> 4.1" -gem "delayed_job_active_record", "~> 4.1" -gem "feedbag", "~> 0.9.5" -gem "feedjira", "~> 2.1.0" -gem "i18n" -gem "loofah", "~> 2.0" -gem "nokogiri", "~> 1.6", ">= 1.6.7.2" -gem "rack-protection", "~> 1.5" -gem "rack-ssl", "~> 1.4" -gem "racksh", "~> 1.0" -gem "rake", "~> 10.1", ">= 10.1.1" -gem "sass" -gem "sinatra", "~> 1.4.8", ">= 1.4.8" -gem "sinatra-activerecord", "~> 1.2", ">= 1.2.3" -gem "sinatra-contrib", "~> 1.4.7" -gem "sinatra-flash", "~> 0.3" -gem "sprockets", "~> 3.0" -gem "sprockets-helpers" -gem "thread", "~> 0.2" -gem "uglifier" -gem "will_paginate", "~> 3.1" +group :test do + gem "axe-core-rspec" + gem "rspec_junit_formatter" + gem "selenium-webdriver" + gem "shoulda-matchers" + gem "with_model" +end diff --git a/Gemfile.lock b/Gemfile.lock index fe40a9405..ed433fe07 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,224 +1,496 @@ GEM remote: https://rubygems.org/ specs: - activemodel (4.2.6) - activesupport (= 4.2.6) + action_text-trix (2.1.19) + railties + actioncable (8.1.3.1) + actionpack (= 8.1.3.1) + activesupport (= 8.1.3.1) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (8.1.3.1) + actionpack (= 8.1.3.1) + activejob (= 8.1.3.1) + activerecord (= 8.1.3.1) + activestorage (= 8.1.3.1) + activesupport (= 8.1.3.1) + mail (>= 2.8.0) + actionmailer (8.1.3.1) + actionpack (= 8.1.3.1) + actionview (= 8.1.3.1) + activejob (= 8.1.3.1) + activesupport (= 8.1.3.1) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (8.1.3.1) + actionview (= 8.1.3.1) + activesupport (= 8.1.3.1) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (8.1.3.1) + action_text-trix (~> 2.1.15) + actionpack (= 8.1.3.1) + activerecord (= 8.1.3.1) + activestorage (= 8.1.3.1) + activesupport (= 8.1.3.1) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (8.1.3.1) + activesupport (= 8.1.3.1) builder (~> 3.1) - activerecord (4.2.6) - activemodel (= 4.2.6) - activesupport (= 4.2.6) - arel (~> 6.0) - activesupport (4.2.6) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - addressable (2.4.0) - arel (6.0.3) - ast (2.2.0) - backports (3.6.8) - bcrypt (3.1.11) - builder (3.2.2) - byebug (2.7.0) - columnize (~> 0.3) - debugger-linecache (~> 1.2) - capybara (2.6.2) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (8.1.3.1) + activesupport (= 8.1.3.1) + globalid (>= 0.3.6) + activemodel (8.1.3.1) + activesupport (= 8.1.3.1) + activerecord (8.1.3.1) + activemodel (= 8.1.3.1) + activesupport (= 8.1.3.1) + timeout (>= 0.4.0) + activestorage (8.1.3.1) + actionpack (= 8.1.3.1) + activejob (= 8.1.3.1) + activerecord (= 8.1.3.1) + activesupport (= 8.1.3.1) + marcel (~> 1.0) + activesupport (8.1.3.1) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + json + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + addressable (2.9.0) + public_suffix (>= 2.0.2, < 8.0) + ast (2.4.3) + axe-core-api (4.13.0) + dumb_delegator + axe-core-rspec (4.13.0) + axe-core-api (= 4.13.0) + base64 (0.3.0) + bcrypt (3.1.22) + bigdecimal (4.1.2) + bindex (0.8.1) + bootsnap (1.25.0) + msgpack (~> 1.5) + brakeman (8.0.6) + racc + builder (3.3.0) + bundler-audit (0.9.3) + bundler (>= 1.2.0) + thor (~> 1.0) + byebug (13.0.0) + reline (>= 0.6.0) + capybara (3.40.0) addressable - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) - coderay (1.1.1) - columnize (0.9.0) - concurrent-ruby (1.0.2) - coveralls (0.8.13) - json (~> 1.8) - simplecov (~> 0.11.0) - term-ansicolor (~> 1.3) - thor (~> 0.19.1) - tins (~> 1.6.0) - debugger-linecache (1.2.0) - delayed_job (4.1.1) - activesupport (>= 3.0, < 5.0) - delayed_job_active_record (4.1.0) - activerecord (>= 3.0, < 5) - delayed_job (>= 3.0, < 5) - diff-lcs (1.2.5) - docile (1.1.5) - execjs (2.7.0) - faker (1.6.3) - i18n (~> 0.5) - faraday (0.11.0) - multipart-post (>= 1.2, < 3) - faraday_middleware (0.11.0.1) - faraday (>= 0.7.4, < 1.0) - feedbag (0.9.5) - nokogiri (~> 1.0) - feedjira (2.1.0) - faraday (>= 0.9) - faraday_middleware (>= 0.9) - loofah (>= 2.0) - sax-machine (>= 1.0) - i18n (0.7.0) - json (1.8.3) - kgio (2.10.0) - loofah (2.0.3) - nokogiri (>= 1.5.9) - method_source (0.8.2) - mime-types (3.0) - mime-types-data (~> 3.2015) - mime-types-data (3.2016.0221) - mini_portile2 (2.0.0) - minitest (5.8.4) - multi_json (1.12.1) - multipart-post (2.0.0) - nokogiri (1.6.7.2) - mini_portile2 (~> 2.0.0.rc2) - parser (2.3.0.6) - ast (~> 2.2) - pg (0.18.4) - powerpack (0.1.1) - pry (0.10.3) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - pry-byebug (1.3.3) - byebug (~> 2.7) - pry (~> 0.10) - rack (1.6.5) - rack-protection (1.5.3) + 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) + coderay (1.1.3) + concurrent-ruby (1.3.8) + connection_pool (3.0.2) + coveralls_reborn (1.0.0) + simplecov (>= 1.0) + term-ansicolor (>= 1.11) + thor (>= 1.5) + tins (>= 1.54) + crack (1.0.1) + bigdecimal + rexml + crass (1.0.7) + cssbundling-rails (1.4.3) + railties (>= 6.0.0) + csv (3.3.6) + date (3.5.1) + debug (1.11.1) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.6.2) + dotenv (3.2.0) + dotenv-rails (3.2.0) + dotenv (= 3.2.0) + railties (>= 6.1) + drb (2.2.3) + dumb_delegator (1.1.0) + erb (6.0.7) + erubi (1.13.1) + et-orbi (1.4.1) + tzinfo + factory_bot (6.6.0) + activesupport (>= 6.1.0) + factory_bot_rails (6.5.1) + factory_bot (~> 6.5) + railties (>= 6.1.0) + feedbag (1.0.2) + addressable (~> 2.8) + nokogiri (~> 1.8, >= 1.8.2) + feedjira (4.0.2) + logger (>= 1.0, < 2) + loofah (>= 2.3.1, < 3) + sax-machine (>= 1.0, < 2) + ffi (1.17.4) + fugit (1.13.0) + et-orbi (~> 1.4) + raabro (~> 1.4) + globalid (1.4.0) + activesupport (>= 6.1) + goldiloader (6.0.0) + activerecord (>= 7.2, < 8.3) + activesupport (>= 7.2, < 8.3) + good_job (4.19.2) + activejob (>= 6.1.0) + activerecord (>= 6.1.0) + concurrent-ruby (>= 1.3.1) + fugit (>= 1.11.0) + railties (>= 6.1.0) + thor (>= 1.0.0) + hashdiff (1.2.1) + httparty (0.24.2) + csv + mini_mime (>= 1.0.0) + multi_xml (>= 0.5.2) + i18n (1.15.2) + concurrent-ruby (~> 1.0) + io-console (0.9.2) + irb (1.18.0) + pp (>= 0.6.0) + prism (>= 1.3.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jsbundling-rails (1.3.1) + railties (>= 6.0.0) + json (2.21.2) + language_server-protocol (3.17.0.6) + lint_roller (1.1.0) + logger (1.7.0) + loofah (2.25.2) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.9.1) + logger + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.2.1) + matrix (0.4.3) + method_source (1.1.0) + mini_mime (1.1.5) + mini_portile2 (2.8.9) + minitest (6.0.6) + drb (~> 2.0) + prism (~> 1.5) + mize (0.6.1) + msgpack (1.8.4) + multi_xml (0.9.1) + bigdecimal (>= 3.1, < 5) + net-imap (0.6.6) + 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.5) + nokogiri (1.19.4) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) + parallel (2.1.0) + parser (3.3.12.0) + ast (~> 2.4.1) + racc + pg (1.6.3) + pp (0.6.4) + prettyprint + prettyprint (0.2.0) + prism (1.9.0) + private_address_check (0.8.0) + propshaft (1.3.2) + actionpack (>= 7.0.0) + activesupport (>= 7.0.0) rack + pry (0.16.0) + coderay (~> 1.1) + method_source (~> 1.0) + reline (>= 0.6.0) + pry-byebug (3.12.0) + byebug (~> 13.0) + pry (>= 0.13, < 0.17) + public_suffix (7.0.5) + puma (8.0.2) + nio4r (~> 2.0) + raabro (1.5.0) + racc (1.8.1) + rack (3.2.7) + rack-session (2.1.2) + base64 (>= 0.1.0) + rack (>= 3.0.0) rack-ssl (1.4.1) rack - rack-test (0.6.3) - rack (>= 1.0) - racksh (1.0.0) - rack (>= 1.0) - rack-test (>= 0.5) - rainbow (2.1.0) - raindrops (0.16.0) - rake (10.5.0) - rspec (3.4.0) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-core (3.4.4) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) + rack-test (2.2.0) + rack (>= 1.3) + rackup (2.3.1) + rack (>= 3) + rails (8.1.3.1) + actioncable (= 8.1.3.1) + actionmailbox (= 8.1.3.1) + actionmailer (= 8.1.3.1) + actionpack (= 8.1.3.1) + actiontext (= 8.1.3.1) + actionview (= 8.1.3.1) + activejob (= 8.1.3.1) + activemodel (= 8.1.3.1) + activerecord (= 8.1.3.1) + activestorage (= 8.1.3.1) + activesupport (= 8.1.3.1) + bundler (>= 1.15.0) + railties (= 8.1.3.1) + rails-dom-testing (2.3.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.7.1) + loofah (~> 2.25, >= 2.25.2) + 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.1.3.1) + actionpack (= 8.1.3.1) + activesupport (= 8.1.3.1) + irb (~> 1.13) + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + tsort (>= 0.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.4.2) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rbs (4.1.3) + logger + prism (>= 1.6.0) + tsort + rdoc (8.0.0) + erb + prism (>= 1.6.0) + rbs (>= 4.0.0) + tsort + readline (0.0.4) + reline + regexp_parser (2.12.0) + reline (0.7.0) + io-console (~> 0.5) + rexml (3.4.4) + rspec (3.13.2) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.6) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-html-matchers (0.7.1) - nokogiri (~> 1) - rspec (>= 3.0.0.a, < 4) - rspec-mocks (3.4.1) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.8) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-support (3.4.1) - rubocop (0.38.0) - parser (>= 2.3.0.6, < 3.0) - powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + rspec-support (~> 3.13.0) + rspec-rails (8.0.4) + actionpack (>= 7.2) + activesupport (>= 7.2) + railties (>= 7.2) + rspec-core (>= 3.13.0, < 5.0.0) + rspec-expectations (>= 3.13.0, < 5.0.0) + rspec-mocks (>= 3.13.0, < 5.0.0) + rspec-support (>= 3.13.0, < 5.0.0) + rspec-support (3.13.7) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (1.89.0) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (>= 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.7.5) - sass (3.4.22) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.50.0) + parser (>= 3.3.7.2) + prism (~> 1.7) + rubocop-capybara (3.0.0) + lint_roller (~> 1.1) + rubocop (~> 1.81) + rubocop-factory_bot (2.28.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-i18n (3.3.0) + lint_roller (~> 1.1) + rubocop (>= 1.72.1) + rubocop-rails (2.37.0) + activesupport (>= 4.2.0) + lint_roller (~> 1.1) + rack (>= 1.1) + rubocop (>= 1.89.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rake (0.7.1) + lint_roller (~> 1.1) + rubocop (>= 1.72.1) + rubocop-rspec (3.10.2) + lint_roller (~> 1.1) + regexp_parser (>= 2.0) + rubocop (~> 1.86, >= 1.86.2) + rubocop-rspec_rails (2.32.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rspec (~> 3.5) + ruby-progressbar (1.13.0) + rubyzip (3.4.1) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) sax-machine (1.3.2) - shotgun (0.9.1) - rack (>= 1.0) - simplecov (0.11.2) - docile (~> 1.1.0) - json (~> 1.8) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) - sinatra (1.4.8) - rack (~> 1.5) - rack-protection (~> 1.4) - tilt (>= 1.3, < 3) - sinatra-activerecord (1.7.0) - activerecord (>= 3.0) - sinatra (~> 1.0) - sinatra-contrib (1.4.7) - backports (>= 2.0) - multi_json - rack-protection - rack-test - sinatra (~> 1.4.0) - tilt (>= 1.3, < 3) - sinatra-flash (0.3.0) - sinatra (>= 1.0.0) - slop (3.6.0) - sprockets (3.7.0) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-helpers (1.2.1) - sprockets (>= 2.2) - sqlite3 (1.3.11) - term-ansicolor (1.3.2) - tins (~> 1.0) - thor (0.19.1) + securerandom (0.4.1) + selenium-webdriver (4.47.0) + base64 (~> 0.2) + logger (~> 1.4) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 4.0) + websocket (~> 1.0) + shoulda-matchers (8.0.1) + activesupport (>= 7.2) + simplecov (1.1.1) + stimulus-rails (1.3.4) + railties (>= 6.0.0) + stripe (19.5.0) + bigdecimal + logger + strong_migrations (2.8.0) + activerecord (>= 7.2) + sync (0.5.0) + term-ansicolor (1.11.3) + tins (~> 1) + thor (1.5.0) thread (0.2.2) - thread_safe (0.3.5) - tilt (1.4.1) - timecop (0.8.0) - tins (1.6.0) - tzinfo (1.2.2) - thread_safe (~> 0.1) - uglifier (3.0.2) - execjs (>= 0.3.0, < 3) - unicode-display_width (1.0.2) - unicorn (4.9.0) - kgio (~> 2.6) - rack - raindrops (~> 0.7) - will_paginate (3.1.0) - xpath (2.0.0) - nokogiri (~> 1.3) + timeout (0.6.1) + tins (1.56.0) + bigdecimal + irb + mize (~> 0.6) + readline + sync + tsort (0.2.0) + turbo-rails (2.0.23) + actionpack (>= 7.1.0) + railties (>= 7.1.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.2.0) + uri (1.1.1) + useragent (0.16.11) + web-console (4.3.0) + actionview (>= 8.0.0) + bindex (>= 0.4.0) + railties (>= 8.0.0) + webmock (3.26.2) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + websocket (1.2.11) + websocket-driver (0.8.2) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + will_paginate (4.0.1) + with_model (2.3.1) + activerecord (>= 7.2) + xpath (3.2.0) + nokogiri (~> 1.8) + zeitwerk (2.8.3) PLATFORMS ruby DEPENDENCIES - activerecord (~> 4.2.6) - bcrypt (~> 3.1) - capybara (~> 2.6) - coveralls (~> 0.7) - delayed_job (~> 4.1) - delayed_job_active_record (~> 4.1) - faker (~> 1.2) - feedbag (~> 0.9.5) - feedjira (~> 2.1.0) - i18n - loofah (~> 2.0) - nokogiri (~> 1.6, >= 1.6.7.2) - pg (~> 0.18.4) - pry-byebug (~> 1.2) - rack-protection (~> 1.5) - rack-ssl (~> 1.4) - rack-test (~> 0.6) - racksh (~> 1.0) - rake (~> 10.1, >= 10.1.1) - rspec (~> 3.4) - rspec-html-matchers (~> 0.7) - rubocop (~> 0.38) + addressable + axe-core-rspec + bcrypt + bootsnap + brakeman + bundler-audit + capybara + coveralls_reborn + cssbundling-rails + debug + dotenv-rails + factory_bot + factory_bot_rails + feedbag + feedjira + goldiloader + good_job + httparty + jsbundling-rails + nokogiri + pg + private_address_check + propshaft + pry-byebug + puma + rack-ssl + rails (~> 8.1.0) + rspec + rspec-rails + rspec_junit_formatter + rubocop + rubocop-capybara + rubocop-factory_bot + rubocop-i18n + rubocop-rails + rubocop-rake + rubocop-rspec + rubocop-rspec_rails sass - shotgun (~> 0.9) - sinatra (~> 1.4.8, >= 1.4.8) - sinatra-activerecord (~> 1.2, >= 1.2.3) - sinatra-contrib (~> 1.4.7) - sinatra-flash (~> 0.3) - sprockets (~> 3.0) - sprockets-helpers - sqlite3 (~> 1.3, >= 1.3.8) - thread (~> 0.2) - timecop (~> 0.8) - uglifier - unicorn (~> 4.7) - will_paginate (~> 3.1) + selenium-webdriver + shoulda-matchers + simplecov + stimulus-rails + stripe + strong_migrations + thread + turbo-rails + web-console + webmock + will_paginate + with_model RUBY VERSION - ruby 2.3.3p222 + ruby 4.0.6 BUNDLED WITH - 1.14.6 + 4.0.13 diff --git a/Procfile b/Procfile index dfa2ae6e9..819eb20a1 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1 @@ -web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb -console: bundle exec racksh +web: bundle exec puma -C ./config/puma.rb diff --git a/Procfile.dev b/Procfile.dev new file mode 100644 index 000000000..bd4b65e62 --- /dev/null +++ b/Procfile.dev @@ -0,0 +1,3 @@ +web: PORT=3000 bundle exec puma -C config/puma.rb +js: pnpm build --watch +css: pnpm build:css --watch diff --git a/README.md b/README.md index f7e0806c2..c5292015b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Stringer -[![Build Status](https://api.travis-ci.org/swanson/stringer.svg?style=flat)](https://travis-ci.org/swanson/stringer) -[![Code Climate](https://codeclimate.com/github/swanson/stringer.svg?style=flat)](https://codeclimate.com/github/swanson/stringer) -[![Coverage Status](https://coveralls.io/repos/swanson/stringer/badge.svg?style=flat)](https://coveralls.io/r/swanson/stringer) -[![Dependency Status](https://gemnasium.com/swanson/stringer.svg)](https://gemnasium.com/swanson/stringer) +[![CircleCI](https://circleci.com/gh/stringer-rss/stringer/tree/main.svg?style=svg)](https://circleci.com/gh/stringer-rss/stringer/tree/main) +[![Code Climate](https://api.codeclimate.com/v1/badges/899c5407c870e541af4e/maintainability)](https://codeclimate.com/github/stringer-rss/stringer/maintainability) +[![Coverage Status](https://coveralls.io/repos/github/stringer-rss/stringer/badge.svg?branch=main)](https://coveralls.io/github/stringer-rss/stringer?branch=main) +[![GitHub Sponsors](https://img.shields.io/github/sponsors/mockdeep?logo=github)](https://github.com/sponsors/mockdeep) ### A self-hosted, anti-social RSS reader. @@ -17,14 +17,14 @@ But it does have keyboard shortcuts and was made with love! ## Installation -Stringer is a Ruby (2.3.0+) app based on Sinatra, ActiveRecord, PostgreSQL, Backbone.js and DelayedJob. +Stringer is a Ruby app based on Rails, PostgreSQL, Hotwire (Turbo and Stimulus) and GoodJob. -[![Deploy to Heroku](https://cdn.herokuapp.com/deploy/button.svg)](https://heroku.com/deploy) +[![Deploy to Heroku](https://cdn.herokuapp.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/stringer-rss/stringer) -Stringer will run just fine on the Heroku free plan. +Stringer will run just fine on the Eco/Basic Heroku plans. Instructions are provided for deploying to [Heroku manually](/docs/Heroku.md), to any Ruby -compatible [Linux-based VPS](/docs/VPS.md), to [Docker](docs/docker.md) and to [OpenShift](/docs/OpenShift.md). +compatible [Linux-based VPS](/docs/VPS.md), to [Docker](docs/Docker.md) and to [OpenShift](/docs/OpenShift.md). ## Niceties @@ -34,7 +34,7 @@ You can access the keyboard shortcuts when using the app by hitting `?`. ![](screenshots/keyboard_shortcuts.png) -### Using you own domain with Heroku +### Using your own domain with Heroku You can run Stringer at `http://reader.yourdomain.com` using a CNAME. @@ -68,8 +68,6 @@ Email: stringer (case-sensitive) Password: {your-stringer-password} ``` -If you have previously setup Stringer, you will need to migrate your database and run `rake change_password` for the API key to be setup properly. - ### Translations Stringer has been translated to [several other languages](config/locales). Your language can be set with the `LOCALE` environment variable. @@ -80,9 +78,6 @@ If you would like to translate Stringer to your preferred language, please use [ ### Clean up old read stories on Heroku -If you are on the Heroku free plan, there is a 10k row limit so you will -eventually run out of space. - You can clean up old stories by running: `rake cleanup_old_stories` By default, this removes read stories that are more than 30 days old (that @@ -91,29 +86,36 @@ task. ## Development -Run the Ruby tests with `rspec`. +### Getting Started -Run the Javascript tests with `rake test_js` and then open a browser to `http://localhost:4567/test`. +You'll need the toolchain versions pinned in `.tool-versions` (Ruby, Node, +PostgreSQL, and pnpm). With those installed, run: -### Getting Started +```sh +bin/setup +``` -To get started using Stringer for development you first need to install `foreman`. +This installs dependencies, prepares the database, and launches the development +server. The application will be running on port `3000`. - gem install foreman +On subsequent runs you can start the server directly with `bin/dev`, which boots +Puma alongside the esbuild watchers for JavaScript and CSS. -Then run the following commands. +You can launch an interactive console (a la `rails c`) using `rake console`. -```sh -bundle install -rake db:migrate -foreman start -``` +### Tests and linting -The application will be running on port `5000`. +Run the Ruby tests with `bundle exec rspec`. Run a single file or example with +`bundle exec rspec spec/path/to/file_spec.rb:LINE`. -You can launch an interactive console (a la `rails c`) using `racksh`. +Run the JavaScript tests with `pnpm test` (Vitest). This also type-checks and +runs ESLint first. -## Acknowledgements +Other checks: `bundle exec rubocop` (Ruby lint), `pnpm eslint` (JS lint), +`pnpm stylelint` (CSS lint), `pnpm tscheck` (type check), and +`bundle exec brakeman` (security scan). + +## Acknowledgments Most of the heavy-lifting is done by [`feedjira`](https://github.com/feedjira/feedjira) and [`feedbag`](https://github.com/dwillis/feedbag). @@ -125,10 +127,13 @@ Lato Font Copyright © 2010-2011 by tyPoland Lukasz Dziedzic (team@latofonts ## Contact -If you have a question, feature idea, or are running into problems, our preferred method of contact is to open an issue on GitHub. This allows multiple people to weigh in and we can keep everything in one place. Thanks! +If you have a question, feature idea, or are running into problems, our preferred method of contact is to open an issue on GitHub. This allows multiple people to weigh in, and we can keep everything in one place. Thanks! ## Maintainers -Matt Swanson, [mdswanson.com](http://mdswanson.com), [@_swanson](http://twitter.com/_swanson) +Robert Fletcher [boon.gl](https://boon.gl) + +## Alumni +Matt Swanson (creator), [mdswanson.com](http://mdswanson.com), [@_swanson](http://twitter.com/_swanson) Victor Koronen, [victor.koronen.se](http://victor.koronen.se/), [@victorkoronen](https://twitter.com/victorkoronen) diff --git a/Rakefile b/Rakefile index 65669e57e..5fc8d463b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,88 +1,35 @@ -require "bundler" -Bundler.setup +# frozen_string_literal: true -require "rubygems" -require "net/http" -require "active_record" -require "delayed_job" -require "delayed_job_active_record" +require_relative "config/application" -require "sinatra/activerecord/rake" -ActiveRecord::Tasks::DatabaseTasks.db_dir = "db" - -require "./app" -require_relative "./app/jobs/fetch_feed_job" -require_relative "./app/tasks/fetch_feeds" -require_relative "./app/tasks/change_password" -require_relative "./app/tasks/remove_old_stories.rb" +Rails.application.load_tasks desc "Fetch all feeds." -task :fetch_feeds do - FetchFeeds.new(Feed.all).fetch_all +task fetch_feeds: :environment do + Feed::FetchAll.call end desc "Lazily fetch all feeds." -task :lazy_fetch do +task lazy_fetch: :environment do if ENV["APP_URL"] uri = URI(ENV["APP_URL"]) + + # warm up server by fetching the root path Net::HTTP.get_response(uri) end FeedRepository.list.each do |feed| - Delayed::Job.enqueue FetchFeedJob.new(feed.id) + CallableJob.perform_later(Feed::FetchOne, feed) end end desc "Fetch single feed" -task :fetch_feed, :id do |_t, args| - FetchFeed.new(Feed.find(args[:id])).fetch -end - -desc "Clear the delayed_job queue." -task :clear_jobs do - Delayed::Job.delete_all -end - -desc "Work the delayed_job queue." -task :work_jobs do - Delayed::Job.delete_all - - worker_retry = Integer(ENV["WORKER_RETRY"] || 3) - worker_retry.times do - Delayed::Worker.new( - min_priority: ENV["MIN_PRIORITY"], - max_priority: ENV["MAX_PRIORITY"] - ).start - end -end - -desc "Change your password" -task :change_password do - ChangePassword.new.change_password +task :fetch_feed, [:id] => :environment do |_t, args| + Feed::FetchOne.call(Feed.find(args[:id])) end desc "Clean up old stories that are read and unstarred" -task :cleanup_old_stories, :number_of_days do |_t, args| +task :cleanup_old_stories, [:number_of_days] => :environment do |_t, args| args.with_defaults(number_of_days: 30) - RemoveOldStories.remove!(args[:number_of_days].to_i) -end - -desc "Start server and serve JavaScript test suite at /test" -task :test_js do - require_relative "./spec/javascript/test_controller" - Stringer.run! -end - -begin - require "rspec/core/rake_task" - - RSpec::Core::RakeTask.new(:speedy_tests) do |t| - t.rspec_opts = "--tag ~speed:slow" - end - - RSpec::Core::RakeTask.new(:spec) - - task default: [:speedy_tests] -rescue LoadError # rubocop:disable Lint/HandleExceptions - # allow for bundle install --without development:test + RemoveOldStories.call(args[:number_of_days].to_i) end diff --git a/app.json b/app.json index 33f03cdaf..342a65f59 100644 --- a/app.json +++ b/app.json @@ -1,19 +1,31 @@ { "name": "Stringer", "description": "A self-hosted, anti-social RSS reader.", - "logo": "https://raw.githubusercontent.com/swanson/stringer/master/screenshots/logo.png", + "logo": "https://raw.githubusercontent.com/stringer-rss/stringer/main/screenshots/logo.png", "keywords": [ "RSS", "Ruby" ], - "website": "https://github.com/swanson/stringer", + "website": "https://github.com/stringer-rss/stringer", "success_url": "/heroku", "scripts": { "postdeploy": "bundle exec rake db:migrate" }, "env": { - "SECRET_TOKEN": { - "description": "Secret key used as the session secret", + "SECRET_KEY_BASE": { + "description": "Secret key used by rails for encryption", + "generator": "secret" + }, + "ENCRYPTION_PRIMARY_KEY": { + "description": "Secret key used by rails for encryption", + "generator": "secret" + }, + "ENCRYPTION_DETERMINISTIC_KEY": { + "description": "Secret key used by rails for encryption", + "generator": "secret" + }, + "ENCRYPTION_KEY_DERIVATION_SALT": { + "description": "Secret key used by rails for encryption", "generator": "secret" }, "LOCALE": { @@ -34,7 +46,7 @@ } }, "addons": [ - "heroku-postgresql:hobby-dev", + "heroku-postgresql:essential-0", "scheduler:standard" ] } diff --git a/app.rb b/app.rb deleted file mode 100644 index 1169a3b32..000000000 --- a/app.rb +++ /dev/null @@ -1,86 +0,0 @@ -require "sinatra/base" -require "sinatra/activerecord" -require "sinatra/flash" -require "sinatra/contrib/all" -require "rack/ssl" -require "json" -require "i18n" -require "will_paginate" -require "will_paginate/active_record" -require "sprockets" -require "sprockets-helpers" -require "securerandom" - -require_relative "app/helpers/authentication_helpers" -require_relative "app/repositories/user_repository" -require_relative "config/asset_pipeline" - -I18n.load_path += Dir[File.join(File.dirname(__FILE__), "config/locales", "*.yml").to_s] -I18n.config.enforce_available_locales = false - -class Stringer < Sinatra::Base - # need to exclude assets for sinatra assetpack, see https://github.com/swanson/stringer/issues/112 - use Rack::SSL, exclude: ->(env) { env["PATH_INFO"] =~ %r{^/(js|css|img)} } if ENV["ENFORCE_SSL"] == "true" - - register Sinatra::ActiveRecordExtension - register Sinatra::Flash - register Sinatra::Contrib - register AssetPipeline - - configure do - set :database_file, "config/database.yml" - set :views, "app/views" - set :public_dir, "app/public" - set :root, File.dirname(__FILE__) - - enable :sessions - set :session_secret, ENV["SECRET_TOKEN"] || SecureRandom.hex(32) - enable :logging - enable :method_override - - ActiveRecord::Base.include_root_in_json = false - end - - helpers do - include Sinatra::AuthenticationHelpers - - def render_partial(name, locals = {}) - erb "partials/_#{name}".to_sym, layout: false, locals: locals - end - - def render_js_template(name) - erb "js/templates/_#{name}.js".to_sym, layout: false - end - - def render_js(name, locals = {}) - erb "js/#{name}.js".to_sym, layout: false, locals: locals - end - - def t(*args) - I18n.t(*args) - end - end - - before do - I18n.locale = ENV["LOCALE"].blank? ? :en : ENV["LOCALE"].to_sym - - if !authenticated? && needs_authentication?(request.path) - session[:redirect_to] = request.fullpath - redirect "/login" - end - end - - get "/" do - if UserRepository.setup_complete? - redirect to("/news") - else - redirect to("/setup/password") - end - end -end - -require_relative "app/controllers/stories_controller" -require_relative "app/controllers/first_run_controller" -require_relative "app/controllers/sessions_controller" -require_relative "app/controllers/feeds_controller" -require_relative "app/controllers/debug_controller" diff --git a/app/assets/builds/.keep b/app/assets/builds/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/assets/javascripts/backbone-min.js b/app/assets/javascripts/backbone-min.js deleted file mode 100644 index 3541019c5..000000000 --- a/app/assets/javascripts/backbone-min.js +++ /dev/null @@ -1,4 +0,0 @@ -(function(){var t=this;var e=t.Backbone;var i=[];var r=i.push;var s=i.slice;var n=i.splice;var a;if(typeof exports!=="undefined"){a=exports}else{a=t.Backbone={}}a.VERSION="1.0.0";var h=t._;if(!h&&typeof require!=="undefined")h=require("underscore");a.$=t.jQuery||t.Zepto||t.ender||t.$;a.noConflict=function(){t.Backbone=e;return this};a.emulateHTTP=false;a.emulateJSON=false;var o=a.Events={on:function(t,e,i){if(!l(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,i){if(!l(this,"once",t,[e,i])||!e)return this;var r=this;var s=h.once(function(){r.off(t,s);e.apply(this,arguments)});s._callback=e;return this.on(t,s,i)},off:function(t,e,i){var r,s,n,a,o,u,c,f;if(!this._events||!l(this,"off",t,[e,i]))return this;if(!t&&!e&&!i){this._events={};return this}a=t?[t]:h.keys(this._events);for(o=0,u=a.length;o").attr(t);this.setElement(e,false)}else{this.setElement(h.result(this,"el"),false)}}});a.sync=function(t,e,i){var r=k[t];h.defaults(i||(i={}),{emulateHTTP:a.emulateHTTP,emulateJSON:a.emulateJSON});var s={type:r,dataType:"json"};if(!i.url){s.url=h.result(e,"url")||U()}if(i.data==null&&e&&(t==="create"||t==="update"||t==="patch")){s.contentType="application/json";s.data=JSON.stringify(i.attrs||e.toJSON(i))}if(i.emulateJSON){s.contentType="application/x-www-form-urlencoded";s.data=s.data?{model:s.data}:{}}if(i.emulateHTTP&&(r==="PUT"||r==="DELETE"||r==="PATCH")){s.type="POST";if(i.emulateJSON)s.data._method=r;var n=i.beforeSend;i.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",r);if(n)return n.apply(this,arguments)}}if(s.type!=="GET"&&!i.emulateJSON){s.processData=false}if(s.type==="PATCH"&&window.ActiveXObject&&!(window.external&&window.external.msActiveXFilteringEnabled)){s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var o=i.xhr=a.ajax(h.extend(s,i));e.trigger("request",e,o,i);return o};var k={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};a.ajax=function(){return a.$.ajax.apply(a.$,arguments)};var S=a.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var $=/\((.*?)\)/g;var T=/(\(\?)?:\w+/g;var H=/\*\w+/g;var A=/[\-{}\[\]+?.,\\\^$|#\s]/g;h.extend(S.prototype,o,{initialize:function(){},route:function(t,e,i){if(!h.isRegExp(t))t=this._routeToRegExp(t);if(h.isFunction(e)){i=e;e=""}if(!i)i=this[e];var r=this;a.history.route(t,function(s){var n=r._extractParameters(t,s);i&&i.apply(r,n);r.trigger.apply(r,["route:"+e].concat(n));r.trigger("route",e,n);a.history.trigger("route",r,e,n)});return this},navigate:function(t,e){a.history.navigate(t,e);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=h.result(this,"routes");var t,e=h.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(A,"\\$&").replace($,"(?:$1)?").replace(T,function(t,e){return e?t:"([^/]+)"}).replace(H,"(.*?)");return new RegExp("^"+t+"$")},_extractParameters:function(t,e){var i=t.exec(e).slice(1);return h.map(i,function(t){return t?decodeURIComponent(t):null})}});var I=a.History=function(){this.handlers=[];h.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var N=/^[#\/]|\s+$/g;var P=/^\/+|\/+$/g;var O=/msie [\w.]+/;var C=/\/$/;I.started=false;h.extend(I.prototype,o,{interval:50,getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=this.location.pathname;var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.substr(i.length)}else{t=this.getHash()}}return t.replace(N,"")},start:function(t){if(I.started)throw new Error("Backbone.history has already been started");I.started=true;this.options=h.extend({},{root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var e=this.getFragment();var i=document.documentMode;var r=O.exec(navigator.userAgent.toLowerCase())&&(!i||i<=7);this.root=("/"+this.root+"/").replace(P,"/");if(r&&this._wantsHashChange){this.iframe=a.$('