Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
feat: Add wishlist import and shutdown notice
Browse files Browse the repository at this point in the history
  • Loading branch information
stephannv committed Dec 26, 2022
1 parent 7b7260d commit 5bf3094
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# nindika is shutting down on 15/01/2023
Thanks for all support. If you need help with nindika code, getting in touch in discussions.


# nindika
[![Releases](https://img.shields.io/github/v/release/stephannv/nindika)](https://github.com/stephannv/nindika/releases)
[![CI](https://github.com/stephannv/nindika/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/stephannv/nindika/actions/workflows/ci.yml?query=branch%3Amain++)
Expand Down
8 changes: 7 additions & 1 deletion app/components/layout/user_menu_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
%>
</div>
</label>
<ul tabindex="0" class="gap-1 mt-3 p-2 shadow menu dropdown-content bg-base-200 rounded-box w-60 border border-gray-700">
<ul tabindex="0" class="gap-1 mt-3 p-2 shadow menu dropdown-content bg-base-200 rounded-box w-72 border border-gray-700">
<li class="menu-title truncate text-center">
<span><%= current_user.name %></span>
</li>
Expand All @@ -17,6 +17,12 @@
<%= t(".wishlist") %>
<% end %>
</li>
<li>
<%= link_to wishlist_path(format: :csv) do %>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3" /> </svg>
Exportar lista de desejo
<% end %>
</li>

<%= button_to destroy_user_session_path, class: "btn btn-block mt-2 gap-3", method: :delete, data: { turbo: false } do %>
<%= t(".logout") %>
Expand Down
13 changes: 12 additions & 1 deletion app/controllers/wishlists_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# frozen_string_literal: true
require "csv"

class WishlistsController < ApplicationController
include HasGamesListPage

before_action :authenticate_user!

def show
render_games_list_page(title: t(".title"), filter_overrides: { wishlisted: true })
respond_to do |format|
format.html do
render_games_list_page(title: t(".title"), filter_overrides: { wishlisted: true })
end

format.csv do
@games = current_user.wishlist.order(:title)
response.headers["Content-Type"] = "text/csv"
response.headers["Content-Disposition"] = "attachment;filename=lista-desejo-nindika.csv"
end
end
end
end
6 changes: 6 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
</head>

<body>
<div class="p-3 text-center bg-error font-medium">
O nindika.com sairá do ar em 15/01/2022. Obrigado pelo apoio!
<% if current_user.present? %>
Exporte sua lista de desejos <%= link_to "aqui", wishlist_path(format: :csv), class: "link", data: { turbo: false } %>.
<% end %>
</div>
<%= render Layout::FrameComponent.new(title: yield(:page_title)) do %>
<%= yield %>
<% end %>
Expand Down
4 changes: 4 additions & 0 deletions app/views/wishlists/show.csv.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%= CSV.generate_line(["Jogo", "Site", "Data de lançamento"]).strip %>
<% @games.each do |game| %>
<%= CSV.generate_line([game.title.gsub(/[^0-9A-Za-z ]/, ' ').strip, game.website_url, game.release_date_display]).strip %>
<% end %>

0 comments on commit 5bf3094

Please sign in to comment.