From 69c927c32774c1fbca315254ef0ff2b99138c21f Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 14 Jan 2019 13:31:19 -0500 Subject: Added revision permalinks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are now URLs for each revision of a Pokémon. They are not linked to from anywhere yet. There are no embeds for them yet. refs #5 --- app/controllers/pokeviewer/pokemon_controller.rb | 22 +++- app/views/pokeviewer/pokemon/_pokemon.html.haml | 135 --------------------- app/views/pokeviewer/pokemon/show.html.haml | 2 +- app/views/pokeviewer/revisions/_revision.html.haml | 135 +++++++++++++++++++++ 4 files changed, 156 insertions(+), 138 deletions(-) delete mode 100644 app/views/pokeviewer/pokemon/_pokemon.html.haml create mode 100644 app/views/pokeviewer/revisions/_revision.html.haml (limited to 'app') diff --git a/app/controllers/pokeviewer/pokemon_controller.rb b/app/controllers/pokeviewer/pokemon_controller.rb index 7045807..2c38e56 100644 --- a/app/controllers/pokeviewer/pokemon_controller.rb +++ b/app/controllers/pokeviewer/pokemon_controller.rb @@ -70,6 +70,21 @@ module Pokeviewer def show end + def show_revision + @revision = Revision. + where( + sequential_id: params[:revision_id], + pokeviewer_pokemon: { uuid: params[:id] } + ).includes( + :species, :item, :move_1, :move_2, :move_3, :move_4, + pokemon: [:trainer, :location] + ).first + + @pokemon = @revision.pokemon + + render :show + end + def embed render layout: false end @@ -77,9 +92,12 @@ module Pokeviewer protected def load_pokemon @pokemon = Pokemon.includes( - :trainer, :location, - current: [:species, :item, :move_1, :move_2, :move_3, :move_4] + current: [ + :species, :item, :move_1, :move_2, :move_3, :move_4, + pokemon: [:trainer, :location]] ).find_by_uuid! params[:id] + + @revision = @pokemon.current end end end diff --git a/app/views/pokeviewer/pokemon/_pokemon.html.haml b/app/views/pokeviewer/pokemon/_pokemon.html.haml deleted file mode 100644 index 7a5f971..0000000 --- a/app/views/pokeviewer/pokemon/_pokemon.html.haml +++ /dev/null @@ -1,135 +0,0 @@ -.pokemon{ class: (not @pokemon.trainer.nil?) && "in-#{@pokemon.trainer.game}" } - .pokemon-basics - .pokemon-nameline - = image_tag(@pokemon.pokeball_icon_path, class: "pokemon-ball") - %span.pokemon-name= link_to_unless_current @pokemon.current.nickname, @pokemon, target: "_blank" - %span.pokemon-gender{ class: @pokemon.gender }= @pokemon.gender_symbol - .pokemon-level= "Lv. #{@pokemon.current.level}" - .pokemon-image - .pokemon-image-wrap - = image_tag @pokemon.current.sprite_path, class: "pokemon-sprite" - - if @pokemon.shiny? - = image_tag "pokeviewer/ShinyIVStar.png", class: "pkv-shiny-star" - - if @pokemon.current.item.nil? - .pokemon-item-label Item - .pokemon-item None - - else - .pokemon-item-label.with-item Item - .pokemon-item.pkv-has-hover - = image_tag(@pokemon.current.item.icon_path) - = @pokemon.current.item.name - .pkv-hover - .pc-data-name= @pokemon.current.item.name - - if @pokemon.current.item.tm? - .pc-move-name= @pokemon.current.item.move.name - = @pokemon.current.item.description(@pokemon.trainer.game) - .pokemon-tab.pokemon-details - %table - %tr - %th Pokédex No. - %td - .table-bubble.tb-top= @pokemon.current.species_id - %tr - %th Name - %td - .table-bubble= @pokemon.current.species.name - %tr - %th Type - %td - .table-bubble - = image_for_type @pokemon.current.species.type_1 - - if @pokemon.current.species.type_2 - = image_for_type @pokemon.current.species.type_2 - %tr - %th OT - %td.ot-gender{ class: @pokemon.ot_gender } - .table-bubble= @pokemon.ot_name - %tr - %th ID No. - %td - .table-bubble.tb-bottom= @pokemon.display_ot_number - %tr - %th   - %td - .pokemon-met-label Trainer Memo - .pokemon-description= display_met @pokemon - .pokemon-tab.pokemon-stats - %table - %tr - %th HP - %td - .table-bubble.tb-top= @pokemon.current.hp - %tr - %th - Attack - - if @pokemon.nature_benefits?(:attack) - %span.nature-benefit + - - if @pokemon.nature_hinders?(:attack) - %span.nature-hinder - - %td - .table-bubble= @pokemon.current.attack - %tr - %th - Defense - - if @pokemon.nature_benefits?(:defense) - %span.nature-benefit + - - if @pokemon.nature_hinders?(:defense) - %span.nature-hinder - - %td - .table-bubble= @pokemon.current.defense - %tr - %th - Sp. Atk - - if @pokemon.nature_benefits?(:special_attack) - %span.nature-benefit + - - if @pokemon.nature_hinders?(:special_attack) - %span.nature-hinder - - %td - .table-bubble= @pokemon.current.special_attack - %tr - %th - Sp. Def - - if @pokemon.nature_benefits?(:special_defense) - %span.nature-benefit + - - if @pokemon.nature_hinders?(:special_defense) - %span.nature-hinder - - %td - .table-bubble= @pokemon.current.special_defense - %tr - %th - Speed - - if @pokemon.nature_benefits?(:speed) - %span.nature-benefit + - - if @pokemon.nature_hinders?(:speed) - %span.nature-hinder - - %td - .table-bubble.tb-bottom= @pokemon.current.speed - %tr.pokemon-nature-label - %th{ colspan: 2 } Nature - %tr - %th - %td - .tb-only= @pokemon.nature_text - %tr - %th{ colspan: 2 } Ability - %tr - %th - %td - .tb-only.pkv-has-hover - = @pokemon.current.ability.name - .pkv-hover - .pc-data-name= @pokemon.current.ability.name - = @pokemon.current.ability.description - .pokemon-tab.pokemon-moves - %table - - (1..4).each do |i| - = move_details @pokemon.current, i - .pokemon-tab.pokemon-contest= condition_diagram @pokemon.current - .pokemon-tab.pokemon-ribbons - %ul - - @pokemon.current.ribbons.each do |ribbon| - %li.pkv-has-hover - = image_tag("pokeviewer/ribbons/#{ribbon[:filename]}") - .pkv-hover - .pc-data-name= ribbon[:name] - = ribbon[:description] diff --git a/app/views/pokeviewer/pokemon/show.html.haml b/app/views/pokeviewer/pokemon/show.html.haml index f35f9ed..cbd879b 100644 --- a/app/views/pokeviewer/pokemon/show.html.haml +++ b/app/views/pokeviewer/pokemon/show.html.haml @@ -1,4 +1,4 @@ -= render @pokemon += render @revision %details#pk-embed-code %summary Embed code %textarea{ readonly: true }= CGI.escapeHTML(render partial: "embed_code").html_safe diff --git a/app/views/pokeviewer/revisions/_revision.html.haml b/app/views/pokeviewer/revisions/_revision.html.haml new file mode 100644 index 0000000..63ba22c --- /dev/null +++ b/app/views/pokeviewer/revisions/_revision.html.haml @@ -0,0 +1,135 @@ +.pokemon{ class: (not @revision.pokemon.trainer.nil?) && "in-#{@revision.pokemon.trainer.game}" } + .pokemon-basics + .pokemon-nameline + = image_tag(@revision.pokemon.pokeball_icon_path, class: "pokemon-ball") + %span.pokemon-name= link_to_unless_current @revision.nickname, @revision.pokemon, target: "_blank" + %span.pokemon-gender{ class: @revision.pokemon.gender }= @revision.pokemon.gender_symbol + .pokemon-level= "Lv. #{@revision.level}" + .pokemon-image + .pokemon-image-wrap + = image_tag @revision.sprite_path, class: "pokemon-sprite" + - if @revision.pokemon.shiny? + = image_tag "pokeviewer/ShinyIVStar.png", class: "pkv-shiny-star" + - if @revision.item.nil? + .pokemon-item-label Item + .pokemon-item None + - else + .pokemon-item-label.with-item Item + .pokemon-item.pkv-has-hover + = image_tag(@revision.item.icon_path) + = @revision.item.name + .pkv-hover + .pc-data-name= @revision.item.name + - if @revision.item.tm? + .pc-move-name= @revision.item.move.name + = @revision.item.description(@revision.pokemon.trainer.game) + .pokemon-tab.pokemon-details + %table + %tr + %th Pokédex No. + %td + .table-bubble.tb-top= @revision.species_id + %tr + %th Name + %td + .table-bubble= @revision.species.name + %tr + %th Type + %td + .table-bubble + = image_for_type @revision.species.type_1 + - if @revision.species.type_2 + = image_for_type @revision.species.type_2 + %tr + %th OT + %td.ot-gender{ class: @revision.pokemon.ot_gender } + .table-bubble= @revision.pokemon.ot_name + %tr + %th ID No. + %td + .table-bubble.tb-bottom= @revision.pokemon.display_ot_number + %tr + %th   + %td + .pokemon-met-label Trainer Memo + .pokemon-description= display_met @revision.pokemon + .pokemon-tab.pokemon-stats + %table + %tr + %th HP + %td + .table-bubble.tb-top= @revision.hp + %tr + %th + Attack + - if @revision.pokemon.nature_benefits?(:attack) + %span.nature-benefit + + - if @revision.pokemon.nature_hinders?(:attack) + %span.nature-hinder - + %td + .table-bubble= @revision.attack + %tr + %th + Defense + - if @revision.pokemon.nature_benefits?(:defense) + %span.nature-benefit + + - if @revision.pokemon.nature_hinders?(:defense) + %span.nature-hinder - + %td + .table-bubble= @revision.defense + %tr + %th + Sp. Atk + - if @revision.pokemon.nature_benefits?(:special_attack) + %span.nature-benefit + + - if @revision.pokemon.nature_hinders?(:special_attack) + %span.nature-hinder - + %td + .table-bubble= @revision.special_attack + %tr + %th + Sp. Def + - if @revision.pokemon.nature_benefits?(:special_defense) + %span.nature-benefit + + - if @revision.pokemon.nature_hinders?(:special_defense) + %span.nature-hinder - + %td + .table-bubble= @revision.special_defense + %tr + %th + Speed + - if @revision.pokemon.nature_benefits?(:speed) + %span.nature-benefit + + - if @revision.pokemon.nature_hinders?(:speed) + %span.nature-hinder - + %td + .table-bubble.tb-bottom= @revision.speed + %tr.pokemon-nature-label + %th{ colspan: 2 } Nature + %tr + %th + %td + .tb-only= @revision.pokemon.nature_text + %tr + %th{ colspan: 2 } Ability + %tr + %th + %td + .tb-only.pkv-has-hover + = @revision.ability.name + .pkv-hover + .pc-data-name= @revision.ability.name + = @revision.ability.description + .pokemon-tab.pokemon-moves + %table + - (1..4).each do |i| + = move_details @revision, i + .pokemon-tab.pokemon-contest= condition_diagram @revision + .pokemon-tab.pokemon-ribbons + %ul + - @revision.ribbons.each do |ribbon| + %li.pkv-has-hover + = image_tag("pokeviewer/ribbons/#{ribbon[:filename]}") + .pkv-hover + .pc-data-name= ribbon[:name] + = ribbon[:description] -- cgit 1.4.1