2023-08-02 17:55:32 -07:00
|
|
|
require "active_support/core_ext/integer/time"
|
|
|
|
|
2023-08-02 16:17:07 -07:00
|
|
|
Rails.application.configure do
|
|
|
|
# Settings specified here will take precedence over those in config/application.rb.
|
2010-05-14 15:12:31 -07:00
|
|
|
|
2023-10-25 15:05:31 -07:00
|
|
|
# In the development environment your application's code is reloaded any time
|
|
|
|
# it changes. This slows down response time but is perfect for development
|
2023-07-21 19:39:32 -07:00
|
|
|
# since you don't have to restart the web server when you make code changes.
|
2023-10-25 15:05:31 -07:00
|
|
|
config.enable_reloading = true
|
2010-05-14 15:12:31 -07:00
|
|
|
|
2023-07-21 19:39:32 -07:00
|
|
|
# Do not eager load code on boot.
|
|
|
|
config.eager_load = false
|
2010-05-14 15:12:31 -07:00
|
|
|
|
2023-08-02 16:17:07 -07:00
|
|
|
# Show full error reports.
|
|
|
|
config.consider_all_requests_local = true
|
2023-08-03 16:37:45 -07:00
|
|
|
|
|
|
|
# Enable server timing
|
|
|
|
config.server_timing = true
|
2023-10-25 15:05:31 -07:00
|
|
|
|
2023-08-02 16:17:07 -07:00
|
|
|
# Enable/disable caching. By default caching is disabled.
|
|
|
|
# Run rails dev:cache to toggle caching.
|
2023-08-03 16:37:45 -07:00
|
|
|
if Rails.root.join("tmp/caching-dev.txt").exist?
|
2023-08-02 16:17:07 -07:00
|
|
|
config.action_controller.perform_caching = true
|
2023-08-02 17:27:11 -07:00
|
|
|
config.action_controller.enable_fragment_cache_logging = true
|
2023-08-02 16:17:07 -07:00
|
|
|
|
|
|
|
config.cache_store = :memory_store
|
|
|
|
config.public_file_server.headers = {
|
2023-10-25 15:05:31 -07:00
|
|
|
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
2023-08-02 16:17:07 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
config.action_controller.perform_caching = false
|
|
|
|
|
|
|
|
config.cache_store = :null_store
|
|
|
|
end
|
2010-05-14 15:12:31 -07:00
|
|
|
|
2023-10-25 15:05:31 -07:00
|
|
|
# Store uploaded files on the local file system (see config/storage.yml for options).
|
2023-11-11 15:12:41 -08:00
|
|
|
# config.active_storage.service = :local
|
2023-10-25 15:05:31 -07:00
|
|
|
|
2023-07-21 19:39:32 -07:00
|
|
|
# Don't care if the mailer can't send.
|
2010-05-14 15:12:31 -07:00
|
|
|
config.action_mailer.raise_delivery_errors = false
|
2023-08-06 15:52:05 -07:00
|
|
|
config.action_mailer.default_url_options = {host: "localhost", port: 3000}
|
2014-09-10 12:32:54 -07:00
|
|
|
config.action_mailer.delivery_method = :letter_opener
|
2023-08-02 16:17:07 -07:00
|
|
|
config.action_mailer.perform_caching = false
|
2011-07-02 15:02:33 -07:00
|
|
|
|
2023-10-25 15:05:31 -07:00
|
|
|
# Raise exceptions for disallowed deprecations.
|
|
|
|
config.active_support.disallowed_deprecation = :raise
|
2013-03-05 18:08:57 -08:00
|
|
|
|
2023-10-25 15:05:31 -07:00
|
|
|
# Tell Active Support which deprecation messages to disallow.
|
|
|
|
config.active_support.disallowed_deprecation_warnings = []
|
|
|
|
|
|
|
|
# Raise an error on page load if there are pending migrations.
|
2023-07-21 19:39:32 -07:00
|
|
|
config.active_record.migration_error = :page_load
|
2013-03-05 18:08:57 -08:00
|
|
|
|
2023-07-21 19:39:32 -07:00
|
|
|
# Debug mode disables concatenation and preprocessing of assets.
|
|
|
|
# This option may cause significant delays in view rendering with a large
|
|
|
|
# number of complex assets.
|
2013-03-05 18:08:57 -08:00
|
|
|
config.assets.debug = true
|
2014-01-03 13:11:02 -08:00
|
|
|
|
2023-08-02 16:17:07 -07:00
|
|
|
# Highlight code that triggered database queries in logs.
|
|
|
|
config.active_record.verbose_query_logs = true
|
|
|
|
|
2023-10-25 15:05:31 -07:00
|
|
|
# Highlight code that enqueued background job in logs.
|
|
|
|
config.active_job.verbose_enqueue_logs = true
|
|
|
|
|
2023-08-02 16:17:07 -07:00
|
|
|
# Suppress logger output for asset requests.
|
|
|
|
config.assets.quiet = true
|
|
|
|
|
2014-01-03 13:11:02 -08:00
|
|
|
config.react.variant = :development
|
2023-07-29 10:14:58 -07:00
|
|
|
|
2023-10-25 15:05:31 -07:00
|
|
|
# Raises error for missing translations.
|
|
|
|
# config.i18n.raise_on_missing_translations = true
|
|
|
|
|
|
|
|
# Annotate rendered view with file names.
|
|
|
|
# config.action_view.annotate_rendered_view_with_filenames = true
|
|
|
|
|
|
|
|
# Uncomment if you wish to allow Action Cable access from any origin.
|
|
|
|
# config.action_cable.disable_request_forgery_protection = true
|
|
|
|
|
|
|
|
# Raise error when a before_action's only/except options reference missing actions
|
|
|
|
config.action_controller.raise_on_missing_callback_actions = true
|
|
|
|
|
2023-08-19 18:51:46 -07:00
|
|
|
# Don't use the assets precompiled for production; recompile live instead.
|
|
|
|
# HACK: We do this by just telling it that dev assets belong in a special
|
|
|
|
# folder, so if you run precompile in development it'll look there instead,
|
|
|
|
# as recommended by the Rails guide. But I don't actually use that irl!
|
|
|
|
# https://guides.rubyonrails.org/v7.0.7/asset_pipeline.html#local-precompilation
|
|
|
|
config.assets.prefix = "/dev-assets"
|
|
|
|
|
2023-07-29 10:14:58 -07:00
|
|
|
# Fix file reloading in a Vagrant environment.
|
|
|
|
# The `ActiveSupport::EventedFileUpdateChecker` is faster, but doesn't work
|
|
|
|
# correctly for Vagrant's networked folders!
|
|
|
|
# https://stackoverflow.com/a/36616931
|
|
|
|
#
|
|
|
|
# TODO: In the future, if we don't expect the use of Vagrant or similar tech
|
|
|
|
# anymore, we could remove this for a minor dev perf improvement. We're on
|
|
|
|
# Vagrant now because it's hard to get older Ruby running on many modern
|
|
|
|
# systems, but later on that could change!
|
|
|
|
#
|
|
|
|
# NOTE: But I also see that this might be the default anyway in current
|
|
|
|
# Rails? idk when that changed... so maybe just delete this later?
|
|
|
|
config.file_watcher = ActiveSupport::FileUpdateChecker
|
2023-08-02 17:36:32 -07:00
|
|
|
|
|
|
|
# Allow connections on Vagrant's private network.
|
|
|
|
config.web_console.permissions = '10.0.2.2'
|
2024-02-22 13:07:43 -08:00
|
|
|
|
2024-11-10 11:39:51 -08:00
|
|
|
# Allow pets to model new data. (If modeling is ever broken, disable this in
|
|
|
|
# production while we fix it!)
|
|
|
|
config.modeling_enabled = true
|
|
|
|
|
2024-02-22 13:07:43 -08:00
|
|
|
# Use a local copy of Impress 2020, presumably running on port 4000. (Can
|
|
|
|
# override this with the IMPRESS_2020_ORIGIN environment variable!)
|
|
|
|
config.impress_2020_origin = ENV.fetch("IMPRESS_2020_ORIGIN",
|
|
|
|
"http://localhost:4000")
|
Create NeopetsMediaArchive, read the actual manifests for Alt Styles
The Neopets Media Archive is a service that mirrors `images.neopets.com`
over time! Right now we're starting by just loading manifests, and
using them to replace the hacks we used for determining the Alt Style
PNG and SVG URLs; but with time, I want to load *all* customization
media files, to have our own secondary file source that isn't dependent
on Neopets to always be up.
Impress 2020 already caches manifest files, but this strategy is
different in two ways:
1. We're using the filesystem rather than a database column. (That is,
manifest data is kinda duplicated in the system right now!) This is
because I intend to go in a more file-y way long-term anyway, to
load more than just the manifests.
2. Impress 2020 guesses at the manifest URLs by pattern, and reloads
them on a regular basis. Instead, we use the modeling system: when
TNT changes the URL of a manifest by appending a new `?v=` query
string to it, this system will consider it a new URL, and will load
the new copy accordingly.
Fun fact, I actually have been prototyping some of this stuff in a side
project I'd named `impress-media-server`! It's a little Sinatra app
that indeed *does* save all the files needed for customization, and can
generate lightweight lil preview iframes and images pretty easily. I
had initially been planning this as a separate service, but after
thinking over the arch a bit, I think it'll go smoother to just give
the main app all the same access and awareness—and I wrote it all in
Ruby and plain HTML/JS/CSS, so it should be pretty easy to port over
bit-by-bit!
Anyway, only Alt Styles use this for now, but my motivation is to be
able to use more-correct asset URL logic to be able to finally swap
over wardrobe-2020's item search to impress.openneo.net's item search
API endpoint—which will get "Items You Own" searches working again, and
whittle down one of the last big things Impress 2020 can do that the
main app can't. Let's see how it goes!
2024-02-23 12:02:39 -08:00
|
|
|
|
|
|
|
# Save the Neopets Media Archive in the local `tmp` folder. (In production,
|
|
|
|
# we keep this in a long-term location instead!)
|
|
|
|
config.neopets_media_archive_root = Rails.root / "tmp" /
|
|
|
|
"neopets_media_archive" / "development"
|
Create `rails public_data:commit` task, to share public data dumps
I'm starting to port over the functionality that was previously just,
me running `yarn db:export:public-data` in `impress-2020` and
committing it to Git LFS every time.
My immediate motivation is that the `impress-2020` git repository is
getting weirdly large?? Idk how these 40MB files have blown up to a
solid 16GB of Git LFS data (we don't have THAT many!!!), but I guess
there's something about Git LFS's architecture and disk usage that I'm
not understanding.
So, let's move to a simpler system in which we don't bind the public
data to the codebase, but instead just regularly dump it in production
and make it available for download.
This change adds the `rails public_data:commit` task, which when run in
production will make the latest available at
`https://impress.openneo.net/public-data/latest.sql.gz`, and will also
store a running log of previous dumps, viewable at
`https://impress.openneo.net/public-data/`.
Things left to do:
1. Create a `rails public_data:pull` task, to download `latest.sql.gz`
and import it into the local development database.
2. Set up a cron job to dump this out regularly, idk maybe weekly? That
will grow, but not very fast (about 2GB per year), and we can add
logic to rotate out old ones if it starts to grow too far. (If we
wanted to get really intricate, we could do like, daily for the past
week, then weekly for the past 3 months, then monthly for the past
year, idk. There must be tools that do this!)
2024-02-29 14:30:33 -08:00
|
|
|
|
|
|
|
# When developing the `public_data:commit` command, save to the local `tmp`
|
|
|
|
# folder. (In production, we keep this in a long-term location instead!)
|
|
|
|
config.public_data_root = Rails.root / "tmp" / "public_data"
|
2024-03-14 15:34:24 -07:00
|
|
|
|
2024-03-14 16:13:31 -07:00
|
|
|
# Use the local NeoPass development server.
|
2024-03-14 18:11:40 -07:00
|
|
|
config.neopass_origin = "https://localhost:8585"
|
|
|
|
|
|
|
|
# Set the NeoPass redirect callback URL.
|
|
|
|
config.neopass_redirect_uri =
|
2024-03-14 20:34:05 -07:00
|
|
|
"http://localhost:3000/users/auth/neopass/callback"
|
2024-04-01 05:26:00 -07:00
|
|
|
|
|
|
|
# If the "USE_LIVE_NEOPASS=1" environment variable is set, override the
|
|
|
|
# NeoPass config with the production values instead.
|
|
|
|
#
|
|
|
|
# Note that this does *not* allow you to just use NeoPass with the
|
|
|
|
# development server as one might like! Our `localhost:3000` redirect URL is
|
|
|
|
# not registered with live NeoPass, so we have to provide the production
|
|
|
|
# callback, or else NeoPass will reject the initial auth request altogether!
|
|
|
|
#
|
|
|
|
# Instead, you'll need to somehow intercept the flow:
|
|
|
|
# 1. Dress to Impress (development) sends you to NeoPass, with production
|
|
|
|
# configuration in the request.
|
|
|
|
# 2. NeoPass redirects back to Dress to Impress (production).
|
|
|
|
# 3. Use some kind of tool to prevent the above redirect, and rewrite it
|
|
|
|
# to `localhost:3000` instead.
|
|
|
|
# - For me, it's convenient to do this via the Burp Suite's "Proxy"
|
|
|
|
# tool: intercept the request, cancel it, and manually rewrite the
|
|
|
|
# URL and navigate to it.
|
|
|
|
# - Another way I've used for similar things in the past is to edit my
|
|
|
|
# /etc/hosts file to temporarily point `impress.openneo.net` to
|
|
|
|
# `127.0.0.1`. Then, when the request fails, manually rewrite the
|
|
|
|
# URL and navigate to it.
|
|
|
|
# - I suppose you could also have your browser's Network panel persist
|
|
|
|
# logs, then you can see the `/users/auth/neopass/callback` request
|
|
|
|
# that fails and redirects back to the production sign-in page, and
|
|
|
|
# manually rewrite it? (The request should be safe to let through,
|
|
|
|
# because production DTI will reject the callback, because it knows
|
|
|
|
# from the `state` parameter that it didn't initiate this flow.)
|
|
|
|
if ENV["USE_LIVE_NEOPASS"].present?
|
|
|
|
puts "Using live NeoPass, instead of the development server."
|
|
|
|
config.neopass_origin = "https://oidc.neopets.com"
|
|
|
|
config.neopass_redirect_uri =
|
|
|
|
"https://impress.openneo.net/users/auth/neopass/callback"
|
|
|
|
end
|
2010-05-14 15:12:31 -07:00
|
|
|
end
|