diff --git a/app/controllers/user_showcases_controller.rb b/app/controllers/user_showcases_controller.rb new file mode 100644 index 00000000..c4b6dbba --- /dev/null +++ b/app/controllers/user_showcases_controller.rb @@ -0,0 +1,5 @@ +class UserShowcasesController < ApplicationController + def show + @user = User.find(params[:id]) + end +end diff --git a/app/models/concerns/event/collaboration.rb b/app/models/concerns/event/collaboration.rb index 950ae585..55202a4d 100644 --- a/app/models/concerns/event/collaboration.rb +++ b/app/models/concerns/event/collaboration.rb @@ -14,7 +14,7 @@ def role_for(user) if user == author :author else - user_event_roles.find_by(user: user).role.to_sym + user_event_roles.find_by(user:)&.role&.to_sym end end end diff --git a/app/views/dashboards/show.html.slim b/app/views/dashboards/show.html.slim index ded77d63..4c9201f7 100644 --- a/app/views/dashboards/show.html.slim +++ b/app/views/dashboards/show.html.slim @@ -22,6 +22,6 @@ h2.mt-2 .sm:grid.sm:grid-cols-3.gap-4.mt-4 - @showcased_public_recipes.each do |recipe| - = render "recipes/recipe_card", recipe:, class: "h-full" + = render "recipes/card", recipe:, classes: "h-full" = link_to("další recepty", published_recipes_path) diff --git a/app/views/published_recipes/index.html.slim b/app/views/published_recipes/index.html.slim index 7463570e..2c56992d 100644 --- a/app/views/published_recipes/index.html.slim +++ b/app/views/published_recipes/index.html.slim @@ -25,4 +25,4 @@ / = "nic nemůžu najít :(" - @published_recipes.each do |recipe| - = render "recipes/recipe_card", recipe:, class: "h-full" + = render "recipes/card", recipe:, classes: "h-full" diff --git a/app/views/recipes/_recipe_card.html.slim b/app/views/recipes/_card.html.slim similarity index 91% rename from app/views/recipes/_recipe_card.html.slim rename to app/views/recipes/_card.html.slim index 55ad5168..c2b13dc7 100644 --- a/app/views/recipes/_recipe_card.html.slim +++ b/app/views/recipes/_card.html.slim @@ -1,5 +1,7 @@ +/# locals: (recipe:, classes: "") + = turbo_frame_tag dom_id(recipe) - = render CardComponent.new(recipe, class: local_assigns[:class]) do |card| + = render CardComponent.new(recipe, class: classes) do |card| = card.with_heading do .grid.grid-cols-2 = link_to(recipe.name, recipe, data: { turbo_frame: "_top" }) diff --git a/app/views/shared/_navbar.html.slim b/app/views/shared/_navbar.html.slim index c3b75710..26d949b6 100644 --- a/app/views/shared/_navbar.html.slim +++ b/app/views/shared/_navbar.html.slim @@ -3,7 +3,7 @@ nav.mb-4.hidden.sm:block a href="/" / img.h-12.mr-1 src=image_url("logos/logo.png") alt="navarit" - ul.flex.font-medium.ms-2.ps-4.cursor-pointer.md:p-0.border.border-gray-100.rounded-lg.md:flex-row.md:space-x-8.md:mt-0.md:border-0.dark:bg-gray-800.md:dark:bg-gray-900.dark:border-gray-700 + ul.flex.font-medium.ms-2.ps-4.cursor-pointer.md:p-0.rounded-lg.md:flex-row.md:space-x-8.md:mt-0.dark:bg-gray-800.md:dark:bg-gray-900 = render "shared/navbar_link", link: dashboard_path, icon: :house, text: "domů" = render "shared/navbar_link", link: events_path, icon: :calendar, text: "akce" = render "shared/navbar_link", link: published_recipes_path, icon: "book-open", text: "databáze receptů" @@ -17,5 +17,5 @@ nav.mb-4.hidden.sm:block div id="dropdown" class="z-10 hidden bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700" ul class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdownDefaultButton" - li.ps-2 - = button_to "odhlásit se", destroy_user_session_path, method: :delete, class: "hover:underline hover:emerald-600 hover:decoration-emerald-700 hover:decoration-4" + li.ps-2.my-2 = link_to "veřejný profil", user_showcase_path(current_user), class: "hover:underline hover:ocean-600 hover:decoration-ocean-700 hover:decoration-4" + li.ps-2 = button_to "odhlásit se", destroy_user_session_path, method: :delete, class: "hover:underline hover:emerald-600 hover:decoration-emerald-700 hover:decoration-4" diff --git a/app/views/shared/_public_navbar.html.slim b/app/views/shared/_public_navbar.html.slim index 14bcf75f..21a1caa9 100644 --- a/app/views/shared/_public_navbar.html.slim +++ b/app/views/shared/_public_navbar.html.slim @@ -1,9 +1,9 @@ -nav.mt-4.mb-4 - .flex.flex-wrap.items-center.py-3.px-4.mx-auto.border.border-0.border-b-2.border-green-900 +nav.mb-4 + .flex.flex-wrap.items-center.py-3.px-4.mx-auto.bg-ocean-800 a href="/" / img.h-12.mr-1 src=image_url("logos/logo.png") alt="navarit" - ul.flex.font-medium.ms-2.ps-4.cursor-pointer.md:p-0.border.border-gray-100.rounded-lg.md:flex-row.md:space-x-8.md:mt-0.md:border-0.dark:bg-gray-800.md:dark:bg-gray-900.dark:border-gray-700 + ul.flex.font-medium.ms-2.ps-4.cursor-pointer.md:p-0.rounded-lg.md:flex-row.md:space-x-8.md:mt-0.md:border-0.dark:bg-gray-800.md:dark:bg-gray-900.dark:border-gray-700 = render "shared/navbar_link", link: new_user_session_path, text: "přihlásit se" = render "shared/navbar_link", link: new_user_registration_path, text: "registrovat se" = render "shared/navbar_link", link: published_recipes_path, icon: "book-open", text: "databáze receptů" diff --git a/app/views/user_showcases/show.html.slim b/app/views/user_showcases/show.html.slim new file mode 100644 index 00000000..11e06eef --- /dev/null +++ b/app/views/user_showcases/show.html.slim @@ -0,0 +1,14 @@ +- content_for :title, "Profil #{@user.full_name}" + += "#{@user.full_name} zveřejnili #{@user.recipes.published.size} receptů!" += icon(:confetti) + +h2 Zveřejněné recepty +.md:grid.md:grid-cols-3.md:gap-4 + - @user.recipes.published.each do |recipe| + = render "recipes/card", recipe:, classes: "h-full" + +h2.mt-4 Zveřejněné akce +.md:grid.md:grid-cols-3.md:gap-4 + - @user.events.published.each do |event| + = render "events/card", event: diff --git a/config/routes.rb b/config/routes.rb index fe00c03a..6cae8a4c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,8 @@ resource :dashboard, only: :show resource :index, only: :show + resources :user_showcases, only: :show + resources :daily_plan_recipes, only: %i[create update destroy] do patch :sort patch :move diff --git a/justfile b/justfile index e7259625..d42a9dd6 100644 --- a/justfile +++ b/justfile @@ -5,6 +5,7 @@ alias c := console console: bundle exec rails c +alias r := run run: bin/dev