diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-01-14 13:31:19 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-01-14 13:31:19 -0500 |
commit | 69c927c32774c1fbca315254ef0ff2b99138c21f (patch) | |
tree | 73d04f9cb9faa31d0258735a41b5867d6971bc17 /app | |
parent | f1d4da70ccb3d298cc7cf1cdcde2748048238dab (diff) | |
download | pokeviewer-69c927c32774c1fbca315254ef0ff2b99138c21f.tar.gz pokeviewer-69c927c32774c1fbca315254ef0ff2b99138c21f.tar.bz2 pokeviewer-69c927c32774c1fbca315254ef0ff2b99138c21f.zip |
Added revision permalinks
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
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/pokeviewer/pokemon_controller.rb | 22 | ||||
-rw-r--r-- | app/views/pokeviewer/pokemon/_pokemon.html.haml | 135 | ||||
-rw-r--r-- | app/views/pokeviewer/pokemon/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/pokeviewer/revisions/_revision.html.haml | 135 |
4 files changed, 156 insertions, 138 deletions
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 | |||
70 | def show | 70 | def show |
71 | end | 71 | end |
72 | 72 | ||
73 | def show_revision | ||
74 | @revision = Revision. | ||
75 | where( | ||
76 | sequential_id: params[:revision_id], | ||
77 | pokeviewer_pokemon: { uuid: params[:id] } | ||
78 | ).includes( | ||
79 | :species, :item, :move_1, :move_2, :move_3, :move_4, | ||
80 | pokemon: [:trainer, :location] | ||
81 | ).first | ||
82 | |||
83 | @pokemon = @revision.pokemon | ||
84 | |||
85 | render :show | ||
86 | end | ||
87 | |||
73 | def embed | 88 | def embed |
74 | render layout: false | 89 | render layout: false |
75 | end | 90 | end |
@@ -77,9 +92,12 @@ module Pokeviewer | |||
77 | protected | 92 | protected |
78 | def load_pokemon | 93 | def load_pokemon |
79 | @pokemon = Pokemon.includes( | 94 | @pokemon = Pokemon.includes( |
80 | :trainer, :location, | 95 | current: [ |
81 | current: [:species, :item, :move_1, :move_2, :move_3, :move_4] | 96 | :species, :item, :move_1, :move_2, :move_3, :move_4, |
97 | pokemon: [:trainer, :location]] | ||
82 | ).find_by_uuid! params[:id] | 98 | ).find_by_uuid! params[:id] |
99 | |||
100 | @revision = @pokemon.current | ||
83 | end | 101 | end |
84 | end | 102 | end |
85 | end | 103 | 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 @@ | |||
1 | .pokemon{ class: (not @pokemon.trainer.nil?) && "in-#{@pokemon.trainer.game}" } | ||
2 | .pokemon-basics | ||
3 | .pokemon-nameline | ||
4 | = image_tag(@pokemon.pokeball_icon_path, class: "pokemon-ball") | ||
5 | %span.pokemon-name= link_to_unless_current @pokemon.current.nickname, @pokemon, target: "_blank" | ||
6 | %span.pokemon-gender{ class: @pokemon.gender }= @pokemon.gender_symbol | ||
7 | .pokemon-level= "Lv. #{@pokemon.current.level}" | ||
8 | .pokemon-image | ||
9 | .pokemon-image-wrap | ||
10 | = image_tag @pokemon.current.sprite_path, class: "pokemon-sprite" | ||
11 | - if @pokemon.shiny? | ||
12 | = image_tag "pokeviewer/ShinyIVStar.png", class: "pkv-shiny-star" | ||
13 | - if @pokemon.current.item.nil? | ||
14 | .pokemon-item-label Item | ||
15 | .pokemon-item None | ||
16 | - else | ||
17 | .pokemon-item-label.with-item Item | ||
18 | .pokemon-item.pkv-has-hover | ||
19 | = image_tag(@pokemon.current.item.icon_path) | ||
20 | = @pokemon.current.item.name | ||
21 | .pkv-hover | ||
22 | .pc-data-name= @pokemon.current.item.name | ||
23 | - if @pokemon.current.item.tm? | ||
24 | .pc-move-name= @pokemon.current.item.move.name | ||
25 | = @pokemon.current.item.description(@pokemon.trainer.game) | ||
26 | .pokemon-tab.pokemon-details | ||
27 | %table | ||
28 | %tr | ||
29 | %th Pokédex No. | ||
30 | %td | ||
31 | .table-bubble.tb-top= @pokemon.current.species_id | ||
32 | %tr | ||
33 | %th Name | ||
34 | %td | ||
35 | .table-bubble= @pokemon.current.species.name | ||
36 | %tr | ||
37 | %th Type | ||
38 | %td | ||
39 | .table-bubble | ||
40 | = image_for_type @pokemon.current.species.type_1 | ||
41 | - if @pokemon.current.species.type_2 | ||
42 | = image_for_type @pokemon.current.species.type_2 | ||
43 | %tr | ||
44 | %th OT | ||
45 | %td.ot-gender{ class: @pokemon.ot_gender } | ||
46 | .table-bubble= @pokemon.ot_name | ||
47 | %tr | ||
48 | %th ID No. | ||
49 | %td | ||
50 | .table-bubble.tb-bottom= @pokemon.display_ot_number | ||
51 | %tr | ||
52 | %th | ||
53 | %td | ||
54 | .pokemon-met-label Trainer Memo | ||
55 | .pokemon-description= display_met @pokemon | ||
56 | .pokemon-tab.pokemon-stats | ||
57 | %table | ||
58 | %tr | ||
59 | %th HP | ||
60 | %td | ||
61 | .table-bubble.tb-top= @pokemon.current.hp | ||
62 | %tr | ||
63 | %th | ||
64 | Attack | ||
65 | - if @pokemon.nature_benefits?(:attack) | ||
66 | %span.nature-benefit + | ||
67 | - if @pokemon.nature_hinders?(:attack) | ||
68 | %span.nature-hinder - | ||
69 | %td | ||
70 | .table-bubble= @pokemon.current.attack | ||
71 | %tr | ||
72 | %th | ||
73 | Defense | ||
74 | - if @pokemon.nature_benefits?(:defense) | ||
75 | %span.nature-benefit + | ||
76 | - if @pokemon.nature_hinders?(:defense) | ||
77 | %span.nature-hinder - | ||
78 | %td | ||
79 | .table-bubble= @pokemon.current.defense | ||
80 | %tr | ||
81 | %th | ||
82 | Sp. Atk | ||
83 | - if @pokemon.nature_benefits?(:special_attack) | ||
84 | %span.nature-benefit + | ||
85 | - if @pokemon.nature_hinders?(:special_attack) | ||
86 | %span.nature-hinder - | ||
87 | %td | ||
88 | .table-bubble= @pokemon.current.special_attack | ||
89 | %tr | ||
90 | %th | ||
91 | Sp. Def | ||
92 | - if @pokemon.nature_benefits?(:special_defense) | ||
93 | %span.nature-benefit + | ||
94 | - if @pokemon.nature_hinders?(:special_defense) | ||
95 | %span.nature-hinder - | ||
96 | %td | ||
97 | .table-bubble= @pokemon.current.special_defense | ||
98 | %tr | ||
99 | %th | ||
100 | Speed | ||
101 | - if @pokemon.nature_benefits?(:speed) | ||
102 | %span.nature-benefit + | ||
103 | - if @pokemon.nature_hinders?(:speed) | ||
104 | %span.nature-hinder - | ||
105 | %td | ||
106 | .table-bubble.tb-bottom= @pokemon.current.speed | ||
107 | %tr.pokemon-nature-label | ||
108 | %th{ colspan: 2 } Nature | ||
109 | %tr | ||
110 | %th | ||
111 | %td | ||
112 | .tb-only= @pokemon.nature_text | ||
113 | %tr | ||
114 | %th{ colspan: 2 } Ability | ||
115 | %tr | ||
116 | %th | ||
117 | %td | ||
118 | .tb-only.pkv-has-hover | ||
119 | = @pokemon.current.ability.name | ||
120 | .pkv-hover | ||
121 | .pc-data-name= @pokemon.current.ability.name | ||
122 | = @pokemon.current.ability.description | ||
123 | .pokemon-tab.pokemon-moves | ||
124 | %table | ||
125 | - (1..4).each do |i| | ||
126 | = move_details @pokemon.current, i | ||
127 | .pokemon-tab.pokemon-contest= condition_diagram @pokemon.current | ||
128 | .pokemon-tab.pokemon-ribbons | ||
129 | %ul | ||
130 | - @pokemon.current.ribbons.each do |ribbon| | ||
131 | %li.pkv-has-hover | ||
132 | = image_tag("pokeviewer/ribbons/#{ribbon[:filename]}") | ||
133 | .pkv-hover | ||
134 | .pc-data-name= ribbon[:name] | ||
135 | = 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 @@ | |||
1 | = render @pokemon | 1 | = render @revision |
2 | %details#pk-embed-code | 2 | %details#pk-embed-code |
3 | %summary Embed code | 3 | %summary Embed code |
4 | %textarea{ readonly: true }= CGI.escapeHTML(render partial: "embed_code").html_safe | 4 | %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 @@ | |||
1 | .pokemon{ class: (not @revision.pokemon.trainer.nil?) && "in-#{@revision.pokemon.trainer.game}" } | ||
2 | .pokemon-basics | ||
3 | .pokemon-nameline | ||
4 | = image_tag(@revision.pokemon.pokeball_icon_path, class: "pokemon-ball") | ||
5 | %span.pokemon-name= link_to_unless_current @revision.nickname, @revision.pokemon, target: "_blank" | ||
6 | %span.pokemon-gender{ class: @revision.pokemon.gender }= @revision.pokemon.gender_symbol | ||
7 | .pokemon-level= "Lv. #{@revision.level}" | ||
8 | .pokemon-image | ||
9 | .pokemon-image-wrap | ||
10 | = image_tag @revision.sprite_path, class: "pokemon-sprite" | ||
11 | - if @revision.pokemon.shiny? | ||
12 | = image_tag "pokeviewer/ShinyIVStar.png", class: "pkv-shiny-star" | ||
13 | - if @revision.item.nil? | ||
14 | .pokemon-item-label Item | ||
15 | .pokemon-item None | ||
16 | - else | ||
17 | .pokemon-item-label.with-item Item | ||
18 | .pokemon-item.pkv-has-hover | ||
19 | = image_tag(@revision.item.icon_path) | ||
20 | = @revision.item.name | ||
21 | .pkv-hover | ||
22 | .pc-data-name= @revision.item.name | ||
23 | - if @revision.item.tm? | ||
24 | .pc-move-name= @revision.item.move.name | ||
25 | = @revision.item.description(@revision.pokemon.trainer.game) | ||
26 | .pokemon-tab.pokemon-details | ||
27 | %table | ||
28 | %tr | ||
29 | %th Pokédex No. | ||
30 | %td | ||
31 | .table-bubble.tb-top= @revision.species_id | ||
32 | %tr | ||
33 | %th Name | ||
34 | %td | ||
35 | .table-bubble= @revision.species.name | ||
36 | %tr | ||
37 | %th Type | ||
38 | %td | ||
39 | .table-bubble | ||
40 | = image_for_type @revision.species.type_1 | ||
41 | - if @revision.species.type_2 | ||
42 | = image_for_type @revision.species.type_2 | ||
43 | %tr | ||
44 | %th OT | ||
45 | %td.ot-gender{ class: @revision.pokemon.ot_gender } | ||
46 | .table-bubble= @revision.pokemon.ot_name | ||
47 | %tr | ||
48 | %th ID No. | ||
49 | %td | ||
50 | .table-bubble.tb-bottom= @revision.pokemon.display_ot_number | ||
51 | %tr | ||
52 | %th | ||
53 | %td | ||
54 | .pokemon-met-label Trainer Memo | ||
55 | .pokemon-description= display_met @revision.pokemon | ||
56 | .pokemon-tab.pokemon-stats | ||
57 | %table | ||
58 | %tr | ||
59 | %th HP | ||
60 | %td | ||
61 | .table-bubble.tb-top= @revision.hp | ||
62 | %tr | ||
63 | %th | ||
64 | Attack | ||
65 | - if @revision.pokemon.nature_benefits?(:attack) | ||
66 | %span.nature-benefit + | ||
67 | - if @revision.pokemon.nature_hinders?(:attack) | ||
68 | %span.nature-hinder - | ||
69 | %td | ||
70 | .table-bubble= @revision.attack | ||
71 | %tr | ||
72 | %th | ||
73 | Defense | ||
74 | - if @revision.pokemon.nature_benefits?(:defense) | ||
75 | %span.nature-benefit + | ||
76 | - if @revision.pokemon.nature_hinders?(:defense) | ||
77 | %span.nature-hinder - | ||
78 | %td | ||
79 | .table-bubble= @revision.defense | ||
80 | %tr | ||
81 | %th | ||
82 | Sp. Atk | ||
83 | - if @revision.pokemon.nature_benefits?(:special_attack) | ||
84 | %span.nature-benefit + | ||
85 | - if @revision.pokemon.nature_hinders?(:special_attack) | ||
86 | %span.nature-hinder - | ||
87 | %td | ||
88 | .table-bubble= @revision.special_attack | ||
89 | %tr | ||
90 | %th | ||
91 | Sp. Def | ||
92 | - if @revision.pokemon.nature_benefits?(:special_defense) | ||
93 | %span.nature-benefit + | ||
94 | - if @revision.pokemon.nature_hinders?(:special_defense) | ||
95 | %span.nature-hinder - | ||
96 | %td | ||
97 | .table-bubble= @revision.special_defense | ||
98 | %tr | ||
99 | %th | ||
100 | Speed | ||
101 | - if @revision.pokemon.nature_benefits?(:speed) | ||
102 | %span.nature-benefit + | ||
103 | - if @revision.pokemon.nature_hinders?(:speed) | ||
104 | %span.nature-hinder - | ||
105 | %td | ||
106 | .table-bubble.tb-bottom= @revision.speed | ||
107 | %tr.pokemon-nature-label | ||
108 | %th{ colspan: 2 } Nature | ||
109 | %tr | ||
110 | %th | ||
111 | %td | ||
112 | .tb-only= @revision.pokemon.nature_text | ||
113 | %tr | ||
114 | %th{ colspan: 2 } Ability | ||
115 | %tr | ||
116 | %th | ||
117 | %td | ||
118 | .tb-only.pkv-has-hover | ||
119 | = @revision.ability.name | ||
120 | .pkv-hover | ||
121 | .pc-data-name= @revision.ability.name | ||
122 | = @revision.ability.description | ||
123 | .pokemon-tab.pokemon-moves | ||
124 | %table | ||
125 | - (1..4).each do |i| | ||
126 | = move_details @revision, i | ||
127 | .pokemon-tab.pokemon-contest= condition_diagram @revision | ||
128 | .pokemon-tab.pokemon-ribbons | ||
129 | %ul | ||
130 | - @revision.ribbons.each do |ribbon| | ||
131 | %li.pkv-has-hover | ||
132 | = image_tag("pokeviewer/ribbons/#{ribbon[:filename]}") | ||
133 | .pkv-hover | ||
134 | .pc-data-name= ribbon[:name] | ||
135 | = ribbon[:description] | ||