about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/pokeviewer/pokemon.js.coffee10
-rw-r--r--app/assets/stylesheets/pokeviewer/pokemon.css.scss94
-rw-r--r--app/controllers/pokeviewer/pokemon_controller.rb18
-rw-r--r--app/views/pokeviewer/pokemon/_embed_code.html.haml1
-rw-r--r--app/views/pokeviewer/pokemon/_pokemon.html.haml135
-rw-r--r--app/views/pokeviewer/pokemon/embed.html.haml15
-rw-r--r--app/views/pokeviewer/pokemon/show.html.haml139
-rw-r--r--config/routes.rb6
8 files changed, 278 insertions, 140 deletions
diff --git a/app/assets/javascripts/pokeviewer/pokemon.js.coffee b/app/assets/javascripts/pokeviewer/pokemon.js.coffee index a6fd326..e80ae77 100644 --- a/app/assets/javascripts/pokeviewer/pokemon.js.coffee +++ b/app/assets/javascripts/pokeviewer/pokemon.js.coffee
@@ -1,3 +1,9 @@
1show_pokemon_tab = (tab) ->
2 $(".pokemon-tab").hide()
3 $(".ptabe-button").removeClass("active")
4 $(".pokemon-" + tab).show()
5 $(".ptabe-" + tab).addClass("active")
6
1$ -> 7$ ->
2 $(".pkv-has-hover").mouseover -> 8 $(".pkv-has-hover").mouseover ->
3 $(this).children(".pkv-hover").show() 9 $(this).children(".pkv-hover").show()
@@ -7,3 +13,7 @@ $ ->
7 $(this).children(".pkv-hover").offset({left: event.pageX + 16, top: event.pageY - 16}) 13 $(this).children(".pkv-hover").offset({left: event.pageX + 16, top: event.pageY - 16})
8 $(".in-emerald .pokemon-image img").mouseover -> 14 $(".in-emerald .pokemon-image img").mouseover ->
9 $(this).attr("src", $(this)[0].src) 15 $(this).attr("src", $(this)[0].src)
16 $(".ptabe-button a").click ->
17 show_pokemon_tab($(this).data("tab"))
18 if $("#pokemon-embed").length > 0
19 show_pokemon_tab("details")
diff --git a/app/assets/stylesheets/pokeviewer/pokemon.css.scss b/app/assets/stylesheets/pokeviewer/pokemon.css.scss index 1b1ce5d..df2a184 100644 --- a/app/assets/stylesheets/pokeviewer/pokemon.css.scss +++ b/app/assets/stylesheets/pokeviewer/pokemon.css.scss
@@ -200,6 +200,15 @@
200 .pokemon-name { 200 .pokemon-name {
201 font-weight: bold; 201 font-weight: bold;
202 white-space: pre; 202 white-space: pre;
203
204 a {
205 color: blue;
206 text-decoration: none;
207
208 &:hover {
209 text-decoration: underline;
210 }
211 }
203 } 212 }
204 213
205 &.in-emerald { 214 &.in-emerald {
@@ -578,3 +587,88 @@
578.clear { 587.clear {
579 clear: both; 588 clear: both;
580} 589}
590
591#pokemon-embed {
592 width: 350px;
593 margin: 1em;
594
595 #pokemon-embed-tabs {
596 margin: 0;
597 padding: 0;
598 text-align: right;
599
600 li {
601 display: inline-block;
602 padding: 3px;
603 border-width: 1px 1px 0 1px;
604 border-style: solid;
605 border-color: #888;
606 border-top-left-radius: 4px;
607 border-top-right-radius: 4px;
608
609 a {
610 font-family: 'Power Green';
611 color: white;
612 text-decoration: none;
613 text-transform: uppercase;
614 }
615
616 &.ptabe-details {
617 background-color: #94c49c;
618
619 &.active, &:hover {
620 background-color: #84ac88;
621 }
622 }
623
624 &.ptabe-stats {
625 background-color: #8890f8;
626
627 &.active, &:hover {
628 background-color: #6870d8;
629 }
630 }
631
632 &.ptabe-moves {
633 background-color: #f7aca6;
634
635 &.active, &:hover {
636 background-color: #ff847c;
637 }
638 }
639
640 &.ptabe-contest {
641 background-color: #b9d7f2;
642
643 &.active, &:hover {
644 background-color: #63aef2;
645 }
646 }
647
648 &.ptabe-ribbons {
649 background-color: #f8d8f8;
650
651 &.active, &:hover {
652 background-color: #f8a0f8;
653 }
654 }
655 }
656 }
657
658 .pokemon {
659 margin: 0;
660 }
661
662 .pokemon-tab {
663 display: none;
664 }
665}
666
667#pk-embed-code {
668 width: 50%;
669
670 textarea {
671 width: 100%;
672 height: 4em;
673 }
674}
diff --git a/app/controllers/pokeviewer/pokemon_controller.rb b/app/controllers/pokeviewer/pokemon_controller.rb index f2d2187..7045807 100644 --- a/app/controllers/pokeviewer/pokemon_controller.rb +++ b/app/controllers/pokeviewer/pokemon_controller.rb
@@ -2,6 +2,8 @@ require_dependency "pokeviewer/application_controller"
2 2
3module Pokeviewer 3module Pokeviewer
4 class PokemonController < ApplicationController 4 class PokemonController < ApplicationController
5 before_action :load_pokemon, only: [:show, :embed]
6
5 def index 7 def index
6 pokemon = Pokemon.order("trainer_id IS NULL DESC"). 8 pokemon = Pokemon.order("trainer_id IS NULL DESC").
7 order(trainer_id: :asc). 9 order(trainer_id: :asc).
@@ -66,10 +68,18 @@ module Pokeviewer
66 end 68 end
67 69
68 def show 70 def show
69 @pokemon = Pokemon.includes(
70 :trainer, :location,
71 current: [:species, :item, :move_1, :move_2, :move_3, :move_4]
72 ).find_by_uuid! params[:id]
73 end 71 end
72
73 def embed
74 render layout: false
75 end
76
77 protected
78 def load_pokemon
79 @pokemon = Pokemon.includes(
80 :trainer, :location,
81 current: [:species, :item, :move_1, :move_2, :move_3, :move_4]
82 ).find_by_uuid! params[:id]
83 end
74 end 84 end
75end 85end
diff --git a/app/views/pokeviewer/pokemon/_embed_code.html.haml b/app/views/pokeviewer/pokemon/_embed_code.html.haml new file mode 100644 index 0000000..6bbff69 --- /dev/null +++ b/app/views/pokeviewer/pokemon/_embed_code.html.haml
@@ -0,0 +1 @@
%iframe{ src: embed_pokemon_url(@pokemon), frameborder: 0, width: 382, height: 298 } \ No newline at end of file
diff --git a/app/views/pokeviewer/pokemon/_pokemon.html.haml b/app/views/pokeviewer/pokemon/_pokemon.html.haml new file mode 100644 index 0000000..573e7eb --- /dev/null +++ b/app/views/pokeviewer/pokemon/_pokemon.html.haml
@@ -0,0 +1,135 @@
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
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 &nbsp;
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/embed.html.haml b/app/views/pokeviewer/pokemon/embed.html.haml new file mode 100644 index 0000000..f4848de --- /dev/null +++ b/app/views/pokeviewer/pokemon/embed.html.haml
@@ -0,0 +1,15 @@
1!!! 5
2%html
3 %head
4 %title Pokeviewer
5 = stylesheet_link_tag "pokeviewer/application", media: "all"
6 = javascript_include_tag "pokeviewer/application"
7 = csrf_meta_tags
8 %body#pokemon-embed
9 %ul#pokemon-embed-tabs
10 %li.ptabe-button.ptabe-details= link_to "Details", "\#", data: {tab: "details"}
11 %li.ptabe-button.ptabe-stats= link_to "Stats", "\#", data: {tab: "stats"}
12 %li.ptabe-button.ptabe-moves= link_to "Moves", "\#", data: {tab: "moves"}
13 %li.ptabe-button.ptabe-contest= link_to "Contest", "\#", data: {tab: "contest"}
14 %li.ptabe-button.ptabe-ribbons= link_to "Ribbons", "\#", data: {tab: "ribbons"}
15 = render @pokemon
diff --git a/app/views/pokeviewer/pokemon/show.html.haml b/app/views/pokeviewer/pokemon/show.html.haml index 3f2750c..f35f9ed 100644 --- a/app/views/pokeviewer/pokemon/show.html.haml +++ b/app/views/pokeviewer/pokemon/show.html.haml
@@ -1,135 +1,4 @@
1.pokemon{ class: (not @pokemon.trainer.nil?) && "in-#{@pokemon.trainer.game}" } 1= render @pokemon
2 .pokemon-basics 2%details#pk-embed-code
3 .pokemon-nameline 3 %summary Embed code
4 = image_tag(@pokemon.pokeball_icon_path, class: "pokemon-ball") 4 %textarea{ readonly: true }= CGI.escapeHTML(render partial: "embed_code").html_safe
5 %span.pokemon-name= @pokemon.current.nickname
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 &nbsp;
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/config/routes.rb b/config/routes.rb index 2d59eea..fc93b1c 100644 --- a/config/routes.rb +++ b/config/routes.rb
@@ -2,7 +2,11 @@ Pokeviewer::Engine.routes.draw do
2 get '/', to: 'pokemon#index' 2 get '/', to: 'pokemon#index'
3 post '/', to: 'uploader#submit' 3 post '/', to: 'uploader#submit'
4 4
5 resources :pokemon, only: [:show] 5 resources :pokemon, only: [:show] do
6 member do
7 get 'embed'
8 end
9 end
6 10
7 resources :pokedex, only: [:index] 11 resources :pokedex, only: [:index]
8 12