From 2c2de801b4481695f3d1b6b14527116092cb1197 Mon Sep 17 00:00:00 2001 From: David Gay Date: Thu, 27 May 2021 18:26:25 -0400 Subject: ItemsController that displays item game data --- app/controllers/items_controller.rb | 9 +++++++++ app/javascript/stylesheets/typography.css | 5 +++++ app/views/activities/_results.html.erb | 2 +- app/views/characters/items/index.html.erb | 2 +- app/views/items/index.html.erb | 8 ++++++++ app/views/items/show.html.erb | 12 ++++++++++++ config/routes.rb | 1 + 7 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 app/controllers/items_controller.rb create mode 100644 app/views/items/index.html.erb create mode 100644 app/views/items/show.html.erb diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb new file mode 100644 index 0000000..a740277 --- /dev/null +++ b/app/controllers/items_controller.rb @@ -0,0 +1,9 @@ +class ItemsController < ApplicationController + def index + @items = Item.all.order(:name) + end + + def show + @item = Item.find(params[:id]) + end +end diff --git a/app/javascript/stylesheets/typography.css b/app/javascript/stylesheets/typography.css index 7bb10ea..9efa03a 100644 --- a/app/javascript/stylesheets/typography.css +++ b/app/javascript/stylesheets/typography.css @@ -4,6 +4,11 @@ font-family: "Montaga", "Open Sans", sans-serif; } +.text-code { + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; + @apply rounded bg-gray-700 px-2 py-1 text-sm; +} + body { font-family: "Open Sans", sans-serif; } diff --git a/app/views/activities/_results.html.erb b/app/views/activities/_results.html.erb index b7728fb..36e8103 100644 --- a/app/views/activities/_results.html.erb +++ b/app/views/activities/_results.html.erb @@ -2,7 +2,7 @@ <% results.each do |result| %> <% case result[:type] %> <% when "item" %> -

You got <%= result[:quantity] %> <%= result[:item].name %> +

You got <%= result[:quantity] %> <%= link_to result[:item].name, item_path(result[:item])%> <% if result[:xp]&.any? %> (<%= result[:xp].map { |award| "#{award[:amount] * result[:quantity]} xp #{award[:skill].name}" }.join(", ") %>) <% end %> diff --git a/app/views/characters/items/index.html.erb b/app/views/characters/items/index.html.erb index 64b58da..14d4b13 100644 --- a/app/views/characters/items/index.html.erb +++ b/app/views/characters/items/index.html.erb @@ -40,7 +40,7 @@ <% @character.character_items.ordered_by_item_name.each do |ci| %> <%= ci.quantity %> - <%= ci.item.name %> + <%= link_to ci.item.name, item_path(ci.item) %> <% if ci.item.equipment? %> <%= button_to "Equip", character_item_equip_path(item_id: ci.item.id) %> diff --git a/app/views/items/index.html.erb b/app/views/items/index.html.erb new file mode 100644 index 0000000..5d004d3 --- /dev/null +++ b/app/views/items/index.html.erb @@ -0,0 +1,8 @@ +

Items

+ +<% @items.each do |item| %> +
+
<%= link_to item.name, item_path(item) %>
+

<%= item.description %>

+
+<% end %> diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb new file mode 100644 index 0000000..675c518 --- /dev/null +++ b/app/views/items/show.html.erb @@ -0,0 +1,12 @@ +

<%= @item.name %>

+

<%= @item.description %>

+ +
+

Game Data

+

GID: <%= @item.gid %>

+ <% if @item.whatnot %> +
<%= JSON.pretty_generate(@item.whatnot) %>
+ <% else %> +

Item has no additional data.

+ <% end %> +
diff --git a/config/routes.rb b/config/routes.rb index 71ba34f..6be4012 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,6 +14,7 @@ Rails.application.routes.draw do resources :chat_messages, only: [:index, :create] resources :locations, only: [:index, :show] resources :activities, only: [:show] + resources :items, only: [:index, :show] resources :hearth_amenities, only: [] do post "/use", to: "hearth_amenities#use" -- cgit v1.2.3