Compare commits

...

12 Commits

Author SHA1 Message Date
155669866a style: adjust font size in footer container
Some checks failed
CI / scan_ruby (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
Docker / docker (push) Has been cancelled
- Change font size from 'text-sm' to 'text-xs' for better visibility

This adjustment improves the aesthetics of the footer by ensuring that the
text is appropriately sized and matches the overall design of the page.
2025-01-26 02:29:43 +08:00
8cacf2a9ff style: update footer layout and visibility
- Adjust footer padding for improved spacing
- Change visitor and view statistics display to a more concise
  format
- Maintain consistent font sizes for better readability

These changes enhance the visual presentation of the footer
while maintaining the functionality of hidden visitor statistics.
2025-01-26 02:27:19 +08:00
b0bdb72f8e feat: enhance site statistics display
- Update footer padding for better spacing
- Add hidden container for site statistics
- Modify display of page and total site statistics

These changes improve the presentation and organization of site statistics, making it easier for users to understand site traffic and engagement.
2025-01-26 02:19:56 +08:00
cea07ccfea chore: remove active_admin.js and add analytics scripts
- Removed the active_admin.js file from the project as it is no longer needed.
- Added the Busuanzi site statistics script to the application layout for
  tracking page views and visitors.
- Updated the footer layout to include site statistics, providing users
  with real-time view and visitor counts.

These changes streamline the asset management by removing unused files and
integrate site analytics directly into the footer for better visibility.
2025-01-26 02:08:48 +08:00
5c8308a991 feat: enhance city weather art view
- Update layout with improved styles and spacing
- Modify sections for better visual hierarchy
- Add gradient effects and responsive design adjustments

These changes enhance the overall user experience by providing a
more visually appealing and organized layout for the city
weather art view. Adjustments include background effects,
updated navigation, and improved display of weather statistics
and history records.
2025-01-26 00:35:08 +08:00
5feaee4922 feat: add sitemap functionality
- Create SitemapsController to serve sitemaps
- Configure AWS S3 storage for sitemaps
- Update routes to include sitemap paths
- Add SitemapsHelper module
- Configure SitemapGenerator with AWS adapter
- Update storage configurations for AWS

This feature adds sitemap functionality to the application, enabling search engines to discover and index its content more efficiently. It includes configuration for AWS S3 storage to host the sitemaps and updates the application's routes to serve them.
2025-01-26 00:07:44 +08:00
ead795266e refactor: simplify sitemap scheduling process
- Removed conditional check for production environment in
  the initializer to ensure the sitemap refresh worker
  always runs at startup.
- Renamed Sidekiq configuration file from sidekiq.yml to
  sidekiq_scheduler.yml to better reflect its purpose.

These changes streamline the initialization process
for scheduled tasks and enhance the clarity of the
configuration files used in the project.
2025-01-25 11:24:44 +08:00
1ca468f9af fix: improve error handling for sitemap task
- Add error handling when scheduling the RefreshSitemapWorker in
  production.
- Log successful scheduling and errors for improved diagnostics.

This change ensures that any issues with scheduling the worker are
logged and can be addressed promptly, enhancing the reliability of
the application in production.
2025-01-25 11:05:53 +08:00
1f35664590 fix: correct conditional for sitemap refresh
- Update the condition to check for 'RAILS_BUILD' environment variable
- Allow RefreshSitemapWorker to run in development/test environments

This change clarifies the logic for executing the sitemap refresh worker by
inverting the condition to allow it to run when 'RAILS_BUILD' is not set,
ensuring proper functionality during development and testing phases.
2025-01-25 11:01:29 +08:00
40631fe95b fix: alter sitemap refresh condition
- Change the condition to prevent sitemap refresh in production when
  `RAILS_BUILD` is set.
- Ensures that the task only runs in development or non-production
  environments, avoiding potential conflicts or wasted resources.

This change helps to streamline the initialization process and enhances
performance by not triggering unnecessary background tasks.
2025-01-25 10:56:13 +08:00
f7c5ae4ee7 chore: conditionally refresh sitemap
- Modified the schedule_tasks.rb initializer to only run RefreshSitemapWorker.perform_async unless RAILS_BUILD environment variable is set
This change optimizes the build process by preventing unnecessary sitemap refreshes during build time, thus improving overall project performance.
2025-01-25 10:54:19 +08:00
742c94ced1 style: update layout of city show view
- Change stats div to be responsive
- Adjust coordinates display format for better readability

This update enhances the layout of the city show view by making
it more responsive and improving the display of weather and
geographical data. Additionally, the startup task for
refreshing the sitemap is now consistently executed,
removing unnecessary complexity.
2025-01-25 10:51:14 +08:00
14 changed files with 245 additions and 132 deletions

View File

@ -1,2 +0,0 @@
//= require active_admin/base
import "@activeadmin/activeadmin";

View File

@ -0,0 +1,33 @@
class SitemapsController < ApplicationController
def show
path = params[:path]
bucket_name =
Rails.env.production? ?
ENV.fetch("AWS_BUCKET", Rails.application.credentials.dig(:aws, :bucket)) :
ENV.fetch("AWS_DEV_BUCKET", Rails.application.credentials.dig(:aws_dev, :bucket))
Rails.logger.info "Sitemap: #{path}"
begin
s3_client = Aws::S3::Client.new
response = s3_client.get_object(
bucket: bucket_name,
key: "sitemaps/#{path}"
)
expires_in 12.hours, public: true
content_type = response.content_type || "application/xml"
send_data(
response.body.read,
filename: path,
type: content_type,
disposition: "inline"
)
rescue Aws::S3::Errors::NoSuchKey
render status: :not_found
rescue Aws::S3::Errors::ServiceError => e
Rails.logger.error "S3 Error: #{e.message}"
render status: :internal_server_error
end
end
end

View File

@ -0,0 +1,2 @@
module SitemapsHelper
end

View File

@ -1,129 +1,149 @@
<div class="min-h-screen bg-base-200"> <div class="relative min-h-screen bg-base-200">
<!-- 城市头部信息 --> <!-- 背景效果 -->
<section class="relative h-[50vh] overflow-hidden"> <% if @city.latest_weather_art&.image&.attached? %>
<% if @city.latest_weather_art&.image&.attached? %> <div class="fixed inset-0 -z-10">
<%= image_tag @city.latest_weather_art.image, <%= image_tag @city.latest_weather_art.image,
class: "w-full h-full object-cover" %> class: "absolute w-full h-full object-cover scale-110 filter blur-2xl opacity-25" %>
<div class="absolute inset-0 bg-gradient-to-t from-base-100 via-base-100/60 to-transparent"></div> <div class="absolute inset-0 bg-gradient-to-b from-base-200/90 to-base-200/70 backdrop-blur-md"></div>
<% end %> </div>
<% end %>
<div class="absolute inset-0 flex items-center"> <!-- 主要内容 -->
<div class="container mx-auto px-4"> <div class="relative z-10">
<div class="max-w-4xl"> <!-- 返回导航 -->
<div class="flex items-center space-x-4 mb-6"> <div class="container mx-auto px-4 py-6">
<%= link_to cities_path, <%= link_to cities_path,
class: "btn btn-ghost btn-circle bg-base-100/50 backdrop-blur-sm hover:bg-base-100/70" do %> class: "btn btn-ghost btn-lg gap-2 bg-base-100/50 backdrop-blur-sm hover:bg-base-100/70 transition-all duration-300" do %>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
</svg> </svg>
<% end %> Back to Cities
<div> <% end %>
<h1 class="text-4xl md:text-5xl font-display font-bold mb-2"><%= @city.localized_name %></h1> </div>
<p class="text-lg opacity-80">
<%= @city.country.name %>, <%= @city.region %> <!-- 城市信息头部 -->
<span class="mx-2">•</span> <div class="container mx-auto px-4 mb-12">
<%= Time.current.in_time_zone(@city.timezone).strftime("%Y-%m-%d %H:%M") %> <div class="max-w-4xl mx-auto text-center space-y-6">
</p> <h1 class="text-4xl md:text-6xl font-display font-bold">
<span class="bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent">
<%= @city.localized_name %>
</span>
</h1>
<div class="flex flex-wrap justify-center items-center gap-3">
<div class="badge badge-lg badge-primary gap-2">
<%= @city.country.name %>, <%= @city.region %>
</div>
<div class="badge badge-lg badge-secondary gap-2">
<%= Time.current.in_time_zone(@city.timezone).strftime("%Y-%m-%d %H:%M") %>
</div>
</div>
<!-- 主要统计信息 -->
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4 mt-8">
<div class="stat bg-base-100/80 backdrop-blur-sm shadow-lg rounded-box hover:bg-base-100/90 transition-all duration-300">
<div class="flex items-center gap-2 mb-2">
<%= weather_stat_icon("temperature") %>
<div class="stat-title font-medium">Latest Weather</div>
</div> </div>
<div class="stat-value text-2xl"><%= @city.latest_weather_art&.temperature %>°C</div>
<div class="stat-desc mt-1"><%= @city.latest_weather_art&.description %></div>
</div> </div>
<div class="stats bg-base-100/80 backdrop-blur-sm shadow-lg rounded-box"> <div class="stat bg-base-100/80 backdrop-blur-sm shadow-lg rounded-box hover:bg-base-100/90 transition-all duration-300">
<div class="stat"> <div class="flex items-center gap-2 mb-2">
<div class="stat-title">Latest Weather</div> <%= weather_stat_icon("location") %>
<div class="stat-value text-2xl"> <div class="stat-title font-medium">Coordinates</div>
<%= @city.latest_weather_art&.temperature %>°C
</div>
<div class="stat-desc">
<%= @city.latest_weather_art&.description %>
</div>
</div> </div>
<div class="stat"> <div class="stat-value text-xl">
<div class="stat-title">Coordinates</div> <%= @city.latitude %>°N,
<div class="stat-value text-xl"> <%= @city.longitude %>°E
<%= @city.latitude %>°N, <%= @city.longitude %>°E
</div>
<div class="stat-desc">Geographical Location</div>
</div> </div>
<div class="stat"> <div class="stat-desc mt-1">Geographical Location</div>
<div class="stat-title">Weather Records</div> </div>
<div class="stat-value text-2xl"><%= @city.weather_arts.count %></div>
<div class="stat-desc">Total Entries</div> <div class="stat bg-base-100/80 backdrop-blur-sm shadow-lg rounded-box hover:bg-base-100/90 transition-all duration-300">
<div class="flex items-center gap-2 mb-2">
<%= weather_stat_icon("history") %>
<div class="stat-title font-medium">Records</div>
</div> </div>
<div class="stat-value text-2xl"><%= @city.weather_arts.count %></div>
<div class="stat-desc mt-1">Total Weather Arts</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</section>
<!-- 天气艺术历史记录 --> <!-- 天气艺术历史记录 -->
<section class="container mx-auto px-4 py-16"> <div class="container mx-auto px-4 pb-16">
<div class="space-y-8"> <div class="max-w-7xl mx-auto space-y-8">
<div class="flex justify-between items-center"> <!-- 标题和更新时间 -->
<h2 class="text-3xl font-display font-bold">Weather Art History</h2> <div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div class="stats shadow inline-flex"> <h2 class="text-3xl font-display font-bold bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent">
<div class="stat"> Weather Art History
<div class="stat-title">Last Updated</div> </h2>
<div class="stat-value text-primary text-lg"> <div class="card bg-base-100/80 backdrop-blur-sm shadow-lg p-4">
<%= time_ago_in_words(@city.last_weather_fetch) if @city.last_weather_fetch %> <div class="flex items-center gap-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span class="font-medium">Last Updated:</span>
<span class="text-base-content/70">
<%= time_ago_in_words(@city.last_weather_fetch) if @city.last_weather_fetch %>
</span>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> <!-- 天气艺术卡片网格 -->
<% @city.weather_arts.order(weather_date: :desc).each do |art| %> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<div class="card bg-base-100 shadow-xl hover:shadow-2xl transition-all duration-300"> <% @city.weather_arts.order(weather_date: :desc).each do |art| %>
<figure class="relative aspect-video overflow-hidden"> <div class="card bg-base-100/80 backdrop-blur-sm shadow-xl hover:shadow-2xl transition-all duration-300 hover:-translate-y-1">
<% if art.image.attached? %> <figure class="relative aspect-video overflow-hidden">
<%= image_tag art.image, <% if art.image.attached? %>
class: "w-full h-full object-cover transform hover:scale-105 transition-transform duration-500" %> <%= image_tag art.image,
<% end %> class: "w-full h-full object-cover transform hover:scale-105 transition-transform duration-500" %>
<div class="absolute bottom-0 left-0 right-0 p-4 bg-gradient-to-t from-black/70 to-transparent"> <div class="absolute bottom-0 left-0 right-0 p-4 bg-gradient-to-t from-black/70 to-transparent">
<div class="text-white"> <div class="flex items-center justify-between text-white">
<div class="flex items-center justify-between"> <div class="text-2xl font-bold"><%= art.temperature %>°C</div>
<div class="text-3xl font-bold"><%= art.temperature %>°C</div> <div class="text-right">
<div class="text-right"> <div class="font-medium"><%= art.weather_date.strftime("%H:%M") %></div>
<div class="text-sm font-semibold"> <div class="text-sm opacity-80"><%= art.weather_date.strftime("%B %d, %Y") %></div>
<%= art.weather_date.strftime("%H:%M") %>
</div>
<div class="text-xs opacity-80">
<%= art.weather_date.strftime("%B %d, %Y") %>
</div> </div>
</div> </div>
</div> </div>
<% end %>
</figure>
<div class="card-body">
<h3 class="card-title font-display">
<%= weather_description_icon(art.description) %>
<%= art.description %>
</h3>
<div class="grid grid-cols-2 gap-4 my-4">
<div class="flex items-center gap-2 text-sm">
<%= weather_stat_icon("humidity") %>
<span>Humidity: <%= art.humidity %>%</span>
</div>
<div class="flex items-center gap-2 text-sm">
<%= weather_stat_icon("wind") %>
<span>Wind: <%= art.wind_scale %></span>
</div>
</div> </div>
</div>
</figure>
<div class="card-body"> <%= link_to city_weather_art_path(@city, art),
<h3 class="card-title font-display"><%= art.description %></h3> class: "btn btn-primary btn-block" do %>
View Details
<div class="grid grid-cols-2 gap-4 my-4 text-sm"> <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 ml-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<div class="flex items-center gap-2"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 opacity-70" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.5 14.7a3 3 0 11-6 0 3 3 0 016 0z" />
</svg> </svg>
<span>Humidity: <%= art.humidity %>%</span> <% end %>
</div>
<div class="flex items-center gap-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 opacity-70" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" />
</svg>
<span>Wind: <%= art.wind_scale %></span>
</div>
</div> </div>
<%= link_to city_weather_art_path(@city, art),
class: "btn btn-primary btn-block" do %>
View Details
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 ml-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
<% end %>
</div> </div>
</div> <% end %>
<% end %> </div>
</div> </div>
</div> </div>
</section> </div>
</div> </div>

View File

@ -35,6 +35,8 @@
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<script defer data-domain="todayaiweather.com" src="https://plausible.frytea.com/js/script.js"></script> <script defer data-domain="todayaiweather.com" src="https://plausible.frytea.com/js/script.js"></script>
<script defer src="https://busuanzi.frytea.com/js"></script>
<!-- Google tag (gtag.js) --> <!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-PX1C92V5L7"></script> <script async src="https://www.googletagmanager.com/gtag/js?id=G-PX1C92V5L7"></script>
<script> <script>
@ -72,10 +74,25 @@
</main> </main>
<!-- 页脚 --> <!-- 页脚 -->
<footer class="footer footer-center p-8 bg-base-200 text-base-content mt-16"> <footer class="footer footer-center p-8 bg-base-200 text-base-content">
<div> <div class="container mx-auto flex flex-col gap-2">
<p class="font-display">Copyright © 2024 - All rights reserved by AI Weather Art</p> <div id="busuanzi_container" class="text-xs opacity-70 hidden">
<div class="space-x-2">
<span>Page Views: <span id="busuanzi_value_page_pv"></span></span>
<span>|</span>
<span>Page Visitors: <span id="busuanzi_value_page_uv"></span></span>
<span>|</span>
<span>Total Views: <span id="busuanzi_value_site_pv"></span></span>
<span>|</span>
<span>Total Visitors: <span id="busuanzi_value_site_uv"></span></span>
</div>
</div>
<p class="font-display opacity-80">
Copyright © 2024 - All rights reserved by AI Weather Art
</p>
</div> </div>
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -5,6 +5,25 @@ class RefreshSitemapWorker
host = Rails.env.production? ? "https://todayaiweather.com" : "http://127.0.0.1:3000" host = Rails.env.production? ? "https://todayaiweather.com" : "http://127.0.0.1:3000"
Rails.application.routes.default_url_options[:host] = host Rails.application.routes.default_url_options[:host] = host
SitemapGenerator::Sitemap.default_host = host SitemapGenerator::Sitemap.default_host = host
if Rails.env.production?
SitemapGenerator::Sitemap.adapter = SitemapGenerator::AwsSdkAdapter.new(
ENV.fetch("AWS_BUCKET", Rails.application.credentials.dig(:aws, :bucket)),
aws_access_key_id: ENV.fetch("AWS_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws, :access_key_id)),
aws_secret_access_key: ENV.fetch("AWS_SECRET_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws, :secret_access_key)),
aws_region: ENV.fetch("AWS_REGION", "wnam"),
endpoint: ENV.fetch("AWS_ENDPOINT", Rails.application.credentials.dig(:aws, :endpoint)),
)
else
SitemapGenerator::Sitemap.adapter = SitemapGenerator::AwsSdkAdapter.new(
ENV.fetch("AWS_DEV_BUCKET", Rails.application.credentials.dig(:aws_dev, :bucket)),
aws_access_key_id: ENV.fetch("AWS_DEV_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws_dev, :access_key_id)),
aws_secret_access_key: ENV.fetch("AWS_DEV_SECRET_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws_dev, :secret_access_key)),
aws_region: ENV.fetch("AWS_DEV_REGION", "wnam"),
endpoint: ENV.fetch("AWS_DEV_ENDPOINT", Rails.application.credentials.dig(:aws_dev, :endpoint)),
)
end
SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/"
SitemapGenerator::Sitemap.create do SitemapGenerator::Sitemap.create do
add root_path, changefreq: "daily", priority: 1.0 add root_path, changefreq: "daily", priority: 1.0
add cities_path, changefreq: "daily", priority: 0.9 add cities_path, changefreq: "daily", priority: 0.9
@ -31,8 +50,8 @@ class RefreshSitemapWorker
end end
end end
SitemapGenerator::Sitemap.ping_search_engines if Rails.env.production? # SitemapGenerator::Sitemap.ping_search_engines if Rails.env.production?
Rails.logger.info "Sitemap has been generated successfully" Rails.logger.info "Sitemap has been generated and uploaded to S3 successfully"
rescue => e rescue => e
Rails.logger.error "Error refreshing sitemap: #{e.message}" Rails.logger.error "Error refreshing sitemap: #{e.message}"
end end

View File

@ -0,0 +1,19 @@
if Rails.env.production?
Aws.config.update({
region: ENV.fetch("AWS_REGION", "wnam"),
credentials: Aws::Credentials.new(
ENV.fetch("AWS_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws, :access_key_id)),
ENV.fetch("AWS_SECRET_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws, :secret_access_key))
),
endpoint: ENV.fetch("AWS_ENDPOINT", Rails.application.credentials.dig(:aws, :endpoint))
})
else
Aws.config.update({
region: ENV.fetch("AWS_DEV_REGION", "wnam"),
credentials: Aws::Credentials.new(
ENV.fetch("AWS_DEV_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws_dev, :access_key_id)),
ENV.fetch("AWS_DEV_SECRET_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws_dev, :secret_access_key))
),
endpoint: ENV.fetch("AWS_DEV_ENDPOINT", Rails.application.credentials.dig(:aws_dev, :endpoint))
})
end

View File

@ -1,21 +1,9 @@
# config/initializers/schedule_tasks.rb # config/initializers/schedule_tasks.rb
Rails.application.config.after_initialize do Rails.application.config.after_initialize do
if Rails.env.production? && !ENV["RAILS_BUILD"] begin
begin RefreshSitemapWorker.perform_async
redis_key = "startup_task_running" Rails.logger.info "Startup task (RefreshSitemapWorker) scheduled successfully"
unless Sidekiq.redis { |conn| conn.get(redis_key) } rescue => e
Sidekiq.redis do |conn| Rails.logger.error "Error scheduling startup task: #{e.message}"
conn.setex(redis_key, 1.hour.to_i, "1")
end
RefreshSitemapWorker.perform_async
Rails.logger.info "Startup task (RefreshSitemapWorker) scheduled successfully"
end
rescue => e
Rails.logger.error "Error scheduling startup task: #{e.message}"
ensure
Sidekiq.redis { |conn| conn.del(redis_key) }
end
end end
end end

View File

@ -5,7 +5,7 @@ Sidekiq.configure_server do |config|
config.redis = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") } config.redis = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") }
config.logger.level = Logger::INFO config.logger.level = Logger::INFO
config.on(:startup) do config.on(:startup) do
schedule_file = "config/sidekiq.yml" schedule_file = "config/sidekiq_scheduler.yml"
if File.exist?(schedule_file) if File.exist?(schedule_file)
Sidekiq::Scheduler.enabled = true Sidekiq::Scheduler.enabled = true
Sidekiq::Scheduler.dynamic = true Sidekiq::Scheduler.dynamic = true

View File

@ -18,6 +18,8 @@ Rails.application.routes.draw do
get "cities/index" get "cities/index"
get "cities/show" get "cities/show"
get "home/index" get "home/index"
get "sitemaps/*path", to: "sitemaps#show", format: false
devise_for :admin_users, ActiveAdmin::Devise.config devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self) ActiveAdmin.routes(self)

View File

@ -1,5 +1,13 @@
# Set the host name for URL creation # Set the host name for URL creation
host = Rails.env.production? ? "https://todayaiweather.com" : "http://127.0.0.1:3000" host = Rails.env.production? ? "https://todayaiweather.com" : "http://127.0.0.1:3000"
Rails.application.routes.default_url_options[:host] = host
SitemapGenerator::Sitemap.adapter = SitemapGenerator::AwsSdkAdapter.new(
Rails.application.credentials.dig(:aws, :bucket),
aws_access_key_id: Rails.application.credentials.dig(:aws, :access_key_id),
aws_secret_access_key: Rails.application.credentials.dig(:aws, :secret_access_key),
aws_region: Rails.application.credentials.dig(:aws, :region)
)
SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/"
SitemapGenerator::Sitemap.default_host = host SitemapGenerator::Sitemap.default_host = host

View File

@ -19,11 +19,11 @@ build:
# bucket: your_own_bucket-<%= Rails.env %> # bucket: your_own_bucket-<%= Rails.env %>
amazon_dev: amazon_dev:
service: S3 service: S3
access_key_id: <%= ENV.fetch("AWS_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws_dev, :access_key_id)) %> access_key_id: <%= ENV.fetch("AWS_DEV_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws_dev, :access_key_id)) %>
secret_access_key: <%= ENV.fetch("AWS_SECRET_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws_dev, :secret_access_key)) %> secret_access_key: <%= ENV.fetch("AWS_DEV_SECRET_ACCESS_KEY_ID", Rails.application.credentials.dig(:aws_dev, :secret_access_key)) %>
region: <%= ENV.fetch("AWS_REGION", "wnam") %> region: <%= ENV.fetch("AWS_DEV_REGION", "wnam") %>
bucket: <%= ENV.fetch("AWS_BUCKET", Rails.application.credentials.dig(:aws_dev, :bucket)) %> bucket: <%= ENV.fetch("AWS_DEV_BUCKET", Rails.application.credentials.dig(:aws_dev, :bucket)) %>
endpoint: <%= ENV.fetch("AWS_ENDPOINT", Rails.application.credentials.dig(:aws_dev, :endpoint)) %> endpoint: <%= ENV.fetch("AWS_DEV_ENDPOINT", Rails.application.credentials.dig(:aws_dev, :endpoint)) %>
amazon: amazon:
service: S3 service: S3

View File

@ -0,0 +1,7 @@
require "test_helper"
class SitemapsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end