diff --git a/app/controllers/cities_controller.rb b/app/controllers/cities_controller.rb index 1bcf857..6a6367b 100644 --- a/app/controllers/cities_controller.rb +++ b/app/controllers/cities_controller.rb @@ -1,8 +1,9 @@ class CitiesController < ApplicationController def index - @cities = City.friendly.find(params[:id]) + @cities = City.all.order(:name) end def show + @city = City.friendly.find(params[:id]) end end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 95f2992..14cef42 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,4 +1,6 @@ class HomeController < ApplicationController def index + @latest_arts = WeatherArt.includes(:city).order(created_at: :desc).limit(6) + @featured_arts = WeatherArt.includes(:city).order(created_at: :desc).limit(5) end end diff --git a/app/controllers/weather_arts_controller.rb b/app/controllers/weather_arts_controller.rb index 0c1e6f4..1f5a178 100644 --- a/app/controllers/weather_arts_controller.rb +++ b/app/controllers/weather_arts_controller.rb @@ -1,4 +1,6 @@ class WeatherArtsController < ApplicationController def show + @city = City.friendly.find(params[:city_id]) + @weather_art = @city.weather_arts.find(params[:id]) end end diff --git a/app/views/cities/index.html.erb b/app/views/cities/index.html.erb index ecfe641..cbd8c97 100644 --- a/app/views/cities/index.html.erb +++ b/app/views/cities/index.html.erb @@ -1,2 +1,18 @@ -

Cities#index

-

Find me in app/views/cities/index.html.erb

+
+

Cities

+ +
+ <% @cities.each do |city| %> +
+
+

<%= city.name %>

+

Latitude: <%= city.latitude %>

+

Longitude: <%= city.longitude %>

+
+ <%= link_to "View Weather Art", city_path(city), class: "btn btn-primary" %> +
+
+
+ <% end %> +
+
\ No newline at end of file diff --git a/app/views/cities/show.html.erb b/app/views/cities/show.html.erb index 8654a9c..c8407fd 100644 --- a/app/views/cities/show.html.erb +++ b/app/views/cities/show.html.erb @@ -1,2 +1,49 @@ -

Cities#show

-

Find me in app/views/cities/show.html.erb

+
+
+

<%= @city.name %>

+ <%= link_to "Back to Cities", cities_path, class: "btn btn-ghost" %> +
+ +
+
+
Latitude
+
<%= @city.latitude %>
+
+
+
Longitude
+
<%= @city.longitude %>
+
+
+ +
+

Weather Art History

+
+ <% @city.weather_arts.order(weather_date: :desc).each do |art| %> +
+
+ <% if art.image.attached? %> + <%= image_tag art.image, class: "w-full h-48 object-cover" %> + <% end %> +
+
+

<%= art.weather_date.strftime("%Y-%m-%d") %>

+

<%= art.description %>

+
+
+
Temperature
+
<%= art.temperature %>°C
+
+
+
Humidity
+
<%= art.humidity %>%
+
+
+
+ <%= link_to "View Details", city_weather_art_path(@city, art), class: "btn btn-primary" %> +
+
+
+ <% end %> +
+
+
\ No newline at end of file diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 2085730..77503ce 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,2 +1,46 @@ -

Home#index

-

Find me in app/views/home/index.html.erb

+
+ +
+

AI Weather Art

+

Discover the beauty of weather through AI-generated art

+
+ + + + + +
+

Latest Weather Art

+
+ <% WeatherArt.last(6).each do |art| %> +
+
+ <% if art.image.attached? %> + <%= image_tag art.image, class: "w-full h-48 object-cover" %> + <% end %> +
+
+

<%= art.city.name %>

+

<%= art.weather_date.strftime("%Y-%m-%d") %>

+

<%= art.description %>

+
+ <%= link_to "View Details", city_weather_art_path(art.city, art), class: "btn btn-primary" %> +
+
+
+ <% end %> +
+
+
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6df99c1..0579aee 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -18,12 +18,30 @@ <%# Includes all stylesheet files in app/assets/stylesheets %> - <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %> <%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %> <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> - + + + +
<%= yield %> +
+ + diff --git a/app/views/weather_arts/show.html.erb b/app/views/weather_arts/show.html.erb index faedb50..9efacb2 100644 --- a/app/views/weather_arts/show.html.erb +++ b/app/views/weather_arts/show.html.erb @@ -1,2 +1,46 @@ -

WeatherArts#show

-

Find me in app/views/weather_arts/show.html.erb

+
+
+

<%= @weather_art.city.name %> - <%= @weather_art.weather_date.strftime("%Y-%m-%d") %>

+ <%= link_to "Back to City", city_path(@weather_art.city), class: "btn btn-ghost" %> +
+ +
+
+ <% if @weather_art.image.attached? %> + <%= image_tag @weather_art.image, class: "w-full h-full object-cover" %> + <% end %> +
+
+

<%= @weather_art.description %>

+ +
+
+
Temperature
+
<%= @weather_art.temperature %>°C
+
Feels like <%= @weather_art.feeling_temp %>°C
+
+ +
+
Wind
+
<%= @weather_art.wind_scale %>
+
<%= @weather_art.wind_speed %> km/h
+
+ +
+
Humidity
+
<%= @weather_art.humidity %>%
+
+ +
+
Visibility
+
<%= @weather_art.visibility %> km
+
+
+ +
+

AI Prompt:

+

<%= @weather_art.prompt %>

+
+
+
+
\ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2495b02..80d6dd8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "tailwindcss": "^3.4.17" }, "devDependencies": { + "daisyui": "^4.12.23", "esbuild": "^0.24.2" } }, @@ -545,6 +546,17 @@ "node": ">= 8" } }, + "node_modules/css-selector-tokenizer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.8.0.tgz", + "integrity": "sha512-Jd6Ig3/pe62/qe5SBPTN8h8LeUg/pT4lLgtavPf7updwwHpvFzxvOQBHYj2LZDMjUnBzgvIUSjRcf6oT5HzHFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "fastparse": "^1.1.2" + } + }, "node_modules/cssesc": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", @@ -557,6 +569,36 @@ "node": ">=4" } }, + "node_modules/culori": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/culori/-/culori-3.3.0.tgz", + "integrity": "sha512-pHJg+jbuFsCjz9iclQBqyL3B2HLCBF71BwVNujUYEvCeQMvV97R59MNK3R2+jgJ3a1fcZgI9B3vYgz8lzr/BFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, + "node_modules/daisyui": { + "version": "4.12.23", + "resolved": "https://registry.npmjs.org/daisyui/-/daisyui-4.12.23.tgz", + "integrity": "sha512-EM38duvxutJ5PD65lO/AFMpcw+9qEy6XAZrTpzp7WyaPeO/l+F/Qiq0ECHHmFNcFXh5aVoALY4MGrrxtCiaQCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "css-selector-tokenizer": "^0.8", + "culori": "^3", + "picocolors": "^1", + "postcss-js": "^4" + }, + "engines": { + "node": ">=16.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/daisyui" + } + }, "node_modules/detect-libc": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", @@ -666,6 +708,13 @@ "node": ">=8.6.0" } }, + "node_modules/fastparse": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz", + "integrity": "sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ==", + "dev": true, + "license": "MIT" + }, "node_modules/fastq": { "version": "1.18.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.18.0.tgz", diff --git a/package.json b/package.json index 04feecc..cc4db2d 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "app", "private": true, "devDependencies": { + "daisyui": "^4.12.23", "esbuild": "^0.24.2" }, "scripts": { diff --git a/tailwind.config.js b/tailwind.config.js index 4bca89f..1ff3a4d 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -4,5 +4,8 @@ module.exports = { './app/helpers/**/*.rb', './app/assets/stylesheets/**/*.css', './app/javascript/**/*.js' - ] + ], + plugins: [ + require('daisyui'), + ], } diff --git a/yarn.lock b/yarn.lock index 1f998af..d2214d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -467,11 +467,34 @@ cross-spawn@^7.0.0: shebang-command "^2.0.0" which "^2.0.1" +css-selector-tokenizer@^0.8: + version "0.8.0" + resolved "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.8.0.tgz" + integrity sha512-Jd6Ig3/pe62/qe5SBPTN8h8LeUg/pT4lLgtavPf7updwwHpvFzxvOQBHYj2LZDMjUnBzgvIUSjRcf6oT5HzHFg== + dependencies: + cssesc "^3.0.0" + fastparse "^1.1.2" + cssesc@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz" integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg== +culori@^3: + version "3.3.0" + resolved "https://registry.npmjs.org/culori/-/culori-3.3.0.tgz" + integrity sha512-pHJg+jbuFsCjz9iclQBqyL3B2HLCBF71BwVNujUYEvCeQMvV97R59MNK3R2+jgJ3a1fcZgI9B3vYgz8lzr/BFQ== + +daisyui@^4.12.23: + version "4.12.23" + resolved "https://registry.npmjs.org/daisyui/-/daisyui-4.12.23.tgz" + integrity sha512-EM38duvxutJ5PD65lO/AFMpcw+9qEy6XAZrTpzp7WyaPeO/l+F/Qiq0ECHHmFNcFXh5aVoALY4MGrrxtCiaQCQ== + dependencies: + css-selector-tokenizer "^0.8" + culori "^3" + picocolors "^1" + postcss-js "^4" + detect-libc@^1.0.3: version "1.0.3" resolved "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz" @@ -554,6 +577,11 @@ fast-glob@^3.3.2: merge2 "^1.3.0" micromatch "^4.0.8" +fastparse@^1.1.2: + version "1.1.2" + resolved "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz" + integrity sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ== + fastq@^1.6.0: version "1.18.0" resolved "https://registry.npmjs.org/fastq/-/fastq-1.18.0.tgz" @@ -808,7 +836,7 @@ path-scurry@^1.11.1: lru-cache "^10.2.0" minipass "^5.0.0 || ^6.0.2 || ^7.0.0" -picocolors@^1.0.1, picocolors@^1.1.1: +picocolors@^1, picocolors@^1.0.1, picocolors@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz" integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== @@ -837,7 +865,7 @@ postcss-import@^15.1.0: read-cache "^1.0.0" resolve "^1.1.7" -postcss-js@^4.0.1: +postcss-js@^4, postcss-js@^4.0.1: version "4.0.1" resolved "https://registry.npmjs.org/postcss-js/-/postcss-js-4.0.1.tgz" integrity sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw== @@ -928,7 +956,7 @@ run-parallel@^1.1.9: sass@^1.83.4: version "1.83.4" - resolved "https://registry.yarnpkg.com/sass/-/sass-1.83.4.tgz#5ccf60f43eb61eeec300b780b8dcb85f16eec6d1" + resolved "https://registry.npmjs.org/sass/-/sass-1.83.4.tgz" integrity sha512-B1bozCeNQiOgDcLd33e2Cs2U60wZwjUUXzh900ZyQF5qUasvMdDZYbQ566LJu7cqR+sAHlAfO6RMkaID5s6qpA== dependencies: chokidar "^4.0.0"