Merge branch 'dev'
This commit is contained in:
commit
de4823cfc9
2
Gemfile
2
Gemfile
@ -79,6 +79,8 @@ end
|
||||
group :development do
|
||||
# Use console on exceptions pages [https://github.com/rails/web-console]
|
||||
gem "web-console"
|
||||
|
||||
gem 'bullet', '~> 8.0'
|
||||
end
|
||||
|
||||
group :production do
|
||||
|
@ -121,6 +121,9 @@ GEM
|
||||
brakeman (7.0.0)
|
||||
racc
|
||||
builder (3.3.0)
|
||||
bullet (8.0.1)
|
||||
activesupport (>= 3.0.0)
|
||||
uniform_notifier (~> 1.11)
|
||||
capybara (3.40.0)
|
||||
addressable
|
||||
matrix
|
||||
@ -478,6 +481,7 @@ GEM
|
||||
unicode-display_width (3.1.4)
|
||||
unicode-emoji (~> 4.0, >= 4.0.4)
|
||||
unicode-emoji (4.0.4)
|
||||
uniform_notifier (1.16.0)
|
||||
uri (1.0.2)
|
||||
useragent (0.16.11)
|
||||
warden (1.2.9)
|
||||
@ -515,6 +519,7 @@ DEPENDENCIES
|
||||
aws-sdk-s3 (~> 1.170)
|
||||
bootsnap
|
||||
brakeman
|
||||
bullet (~> 8.0)
|
||||
capybara
|
||||
cssbundling-rails
|
||||
debug
|
||||
|
@ -3,7 +3,7 @@ class ArtsController < ApplicationController
|
||||
@regions = Region.all
|
||||
@current_region = Region.find(params[:region]) if params[:region].present?
|
||||
|
||||
@weather_arts = WeatherArt.includes(city: [ :country, { country: :region } ])
|
||||
@weather_arts = WeatherArt.includes(city: [ :country ]).includes(:image_attachment)
|
||||
|
||||
if @current_region
|
||||
@weather_arts = @weather_arts.joins(city: :country)
|
||||
|
@ -3,7 +3,7 @@ class CitiesController < ApplicationController
|
||||
before_action :require_admin, only: [ :generate_weather_art ]
|
||||
|
||||
def index
|
||||
@regions = Region.includes(:countries).order(:name)
|
||||
@regions = Region.order(:name)
|
||||
@cities = City.includes(:country, country: :region).order(:name)
|
||||
|
||||
if params[:query].present?
|
||||
|
@ -1,9 +1,9 @@
|
||||
class HomeController < ApplicationController
|
||||
def index
|
||||
@popular_arts = WeatherArt.by_popularity(3)
|
||||
@random_arts = WeatherArt.random(3)
|
||||
@latest_arts = WeatherArt.latest(6)
|
||||
@featured_arts = WeatherArt.includes(:city).order(created_at: :desc).limit(5)
|
||||
@popular_arts = WeatherArt.includes(:city, :image_attachment).by_popularity(3)
|
||||
@random_arts = WeatherArt.includes(:city, :image_attachment).random(3)
|
||||
@latest_arts = WeatherArt.includes(:city, :image_attachment).latest(6)
|
||||
@featured_arts = WeatherArt.includes(:city, :image_attachment).order(created_at: :desc).limit(5)
|
||||
set_meta_tags(
|
||||
title: "AI-Generated Weather Art",
|
||||
description: "Experience weather through artistic AI visualization. Daily updated weather art for cities worldwide.",
|
||||
|
@ -3,16 +3,6 @@ class WeatherArtsController < ApplicationController
|
||||
@city = City.friendly.find(params[:city_id])
|
||||
@weather_art = @city.weather_arts.friendly.find(params[:slug])
|
||||
|
||||
@previous_weather_art = @city.weather_arts
|
||||
.where("id < ?", @weather_art.id)
|
||||
.order(id: :desc)
|
||||
.first
|
||||
|
||||
@next_weather_art = @city.weather_arts
|
||||
.where("id > ?", @weather_art.id)
|
||||
.order(id: :asc)
|
||||
.first
|
||||
|
||||
ahoy.track "View Weather Art", {
|
||||
weather_art_id: @weather_art.id,
|
||||
city_id: @weather_art.city_id,
|
||||
|
@ -7,8 +7,10 @@ import HelloController from "./hello_controller"
|
||||
import PhotoSwipeLightBoxController from "./photo_swipe_lightbox_controller"
|
||||
import FlashMessageController from "./flash_controller"
|
||||
import SearchController from "./search_controller"
|
||||
import PageLoadTimeController from "./page_load_time_controller"
|
||||
|
||||
application.register("hello", HelloController)
|
||||
application.register("photo-swipe-lightbox", PhotoSwipeLightBoxController)
|
||||
application.register("flash", FlashMessageController)
|
||||
application.register("search", SearchController)
|
||||
application.register("page-load-time", PageLoadTimeController)
|
||||
|
18
app/javascript/controllers/page_load_time_controller.js
Normal file
18
app/javascript/controllers/page_load_time_controller.js
Normal file
@ -0,0 +1,18 @@
|
||||
import {Controller} from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["timer"]
|
||||
|
||||
connect() {
|
||||
// 记录页面加载开始的时间
|
||||
const startTime = performance.now();
|
||||
|
||||
// 监听页面加载完成事件
|
||||
window.addEventListener('load', () => {
|
||||
const endTime = performance.now();
|
||||
const loadTime = endTime - startTime;
|
||||
// 更新显示
|
||||
this.timerTarget.textContent = loadTime;
|
||||
});
|
||||
}
|
||||
}
|
22
app/views/layouts/_footer.html.erb
Normal file
22
app/views/layouts/_footer.html.erb
Normal file
@ -0,0 +1,22 @@
|
||||
<!-- 页脚 -->
|
||||
<footer class="footer footer-center p-8 bg-base-200 text-base-content">
|
||||
<div class="container mx-auto flex flex-col gap-2">
|
||||
<div id="busuanzi_container" class="text-xs opacity-70">
|
||||
<div class="space-x-2">
|
||||
<span>Page: </span>
|
||||
<span>PV <span id="busuanzi_page_pv"></span></span>
|
||||
<span>UV <span id="busuanzi_page_uv"></span></span>
|
||||
<span>Site: </span>
|
||||
<span>PV <span id="busuanzi_site_pv"></span></span>
|
||||
<span>UV <span id="busuanzi_site_uv"></span></span>
|
||||
<span data-controller="page-load-time">
|
||||
Page Load Time: <span data-page-load-time-target="timer">x</span> ms
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="font-display opacity-80">
|
||||
Copyright © 2024 - All rights reserved by AI Weather Art
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
@ -64,26 +64,7 @@
|
||||
<%= yield %>
|
||||
</main>
|
||||
|
||||
<!-- 页脚 -->
|
||||
<footer class="footer footer-center p-8 bg-base-200 text-base-content">
|
||||
<div class="container mx-auto flex flex-col gap-2">
|
||||
<div id="busuanzi_container" class="text-xs opacity-70">
|
||||
<div class="space-x-2">
|
||||
<span>Page Views: <span id="busuanzi_page_pv"></span></span>
|
||||
<span>|</span>
|
||||
<span>Page Visitors: <span id="busuanzi_page_uv"></span></span>
|
||||
<span>|</span>
|
||||
<span>Total Views: <span id="busuanzi_site_pv"></span></span>
|
||||
<span>|</span>
|
||||
<span>Total Visitors: <span id="busuanzi_site_uv"></span></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="font-display opacity-80">
|
||||
Copyright © 2024 - All rights reserved by AI Weather Art
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<%= render 'layouts/footer' %>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -86,34 +86,6 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- 上一个和下一个导航 -->
|
||||
<div class="flex flex-col sm:flex-row justify-between items-center gap-4 mt-8">
|
||||
<% if @previous_weather_art %>
|
||||
<%= link_to city_weather_art_path(@city, @previous_weather_art),
|
||||
class: "btn btn-outline btn-primary w-full sm:w-auto flex items-center justify-center gap-2" do %>
|
||||
<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" />
|
||||
</svg>
|
||||
Previous Weather Art
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @next_weather_art %>
|
||||
<%= link_to city_weather_art_path(@city, @next_weather_art),
|
||||
class: "btn btn-outline btn-primary w-full sm:w-auto flex items-center justify-center gap-2" do %>
|
||||
Next Weather Art
|
||||
<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="M9 5l7 7-7 7" />
|
||||
</svg>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if @previous_weather_art.nil? && @next_weather_art.nil? %>
|
||||
<div class="text-center text-base-content/70 py-4">
|
||||
No more Weather Arts available
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -1,6 +1,15 @@
|
||||
require "active_support/core_ext/integer/time"
|
||||
|
||||
Rails.application.configure do
|
||||
config.after_initialize do
|
||||
Bullet.enable = true
|
||||
Bullet.alert = false
|
||||
Bullet.bullet_logger = true
|
||||
Bullet.console = true
|
||||
Bullet.rails_logger = true
|
||||
Bullet.add_footer = true
|
||||
end
|
||||
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Make code changes take effect immediately without server restart.
|
||||
|
@ -9,7 +9,23 @@ module.exports = {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
'display': ['"Playfair Display"', 'serif'],
|
||||
'sans': ['Raleway', 'sans-serif'],
|
||||
'sans': [
|
||||
'ui-sans-serif',
|
||||
'system-ui',
|
||||
'-apple-system',
|
||||
'BlinkMacSystemFont',
|
||||
'Segoe UI',
|
||||
'Roboto',
|
||||
'Helvetica Neue',
|
||||
'Vazirmatn',
|
||||
'Arial',
|
||||
'Noto Sans',
|
||||
'sans-serif',
|
||||
'Apple Color Emoji',
|
||||
'Segoe UI Emoji',
|
||||
'Segoe UI Symbol',
|
||||
'Noto Color Emoji',
|
||||
],
|
||||
},
|
||||
height: {
|
||||
'screen-90': '90vh',
|
||||
|
Loading…
Reference in New Issue
Block a user