pretty home page

This commit is contained in:
Emi Matchu 2010-06-08 10:39:23 -04:00
parent df3fcd101f
commit 7b91dd9cef
5 changed files with 145 additions and 15 deletions

View file

@ -1,12 +1,33 @@
module ItemsHelper
StandardSpeciesImageFormat = 'http://pets.neopets.com/cp/%s/1/1.png'
module PetTypeImage
Format = 'http://pets.neopets.com/cp/%s/%i/%i.png'
def standard_species_images(species_list)
pet_types = PetType.random_basic_per_species(species_list.map(&:id))
raw(pet_types.inject('') do |html, pet_type|
src = sprintf(StandardSpeciesImageFormat, pet_type.image_hash)
human_name = pet_type.species.name.humanize
image = image_tag(src, :alt => human_name, :title => human_name)
Emotions = {
:happy => 1,
:sad => 2,
:angry => 3,
:ill => 4
}
Sizes = {
:face => 1,
:thumb => 2,
:zoom => 3,
:full => 4
}
end
def standard_species_search_links
build_on_random_standard_pet_types(Species.all) do |pet_type|
image = pet_type_image(pet_type, :happy, :zoom)
query = "species:#{pet_type.species.name}"
link_to(image, items_path(:q => query))
end
end
def standard_species_images(species)
build_on_random_standard_pet_types(species) do |pet_type|
image = pet_type_image(pet_type, :happy, :face)
attributes = {
'data-id' => pet_type.id,
'data-body-id' => pet_type.body_id
@ -18,11 +39,25 @@ module ItemsHelper
pet_type_attribute.send(subattribute_name)
end
end
html + link_to(
link_to(
image,
'#',
attributes
)
end)
end
end
private
def build_on_random_standard_pet_types(species, &block)
raw(PetType.random_basic_per_species(species.map(&:id)).map(&block).join)
end
def pet_type_image(pet_type, emotion, size)
emotion_id = PetTypeImage::Emotions[emotion]
size_id = PetTypeImage::Sizes[size]
src = sprintf(PetTypeImage::Format, pet_type.image_hash, emotion_id, size_id)
human_name = pet_type.species.name.humanize
image_tag(src, :alt => human_name, :title => human_name)
end
end

View file

@ -0,0 +1,36 @@
form {
margin-bottom: 2em;
}
@mixin main_unit {
float: left;
width: 49%;
h2 {
font-size: 125%;
}
}
#search-help {
@include main_unit;
padding-right: 1%;
dl {
text-align: left;
}
dd {
margin-bottom: 1em;
}
}
#species-search-links {
@include main_unit;
padding-left: 1%;
img {
height: 80px;
width: 80px;
}
}

View file

@ -84,13 +84,15 @@ h1 a {
}
}
a.item {
a {
img {
@include opacity(.9);
}
&:hover img {
&:hover, &:focus {
img {
@include opacity(1);
}
}
}
/* A font by Jos Buivenga (exljbris) -> www.exljbris.nl */
@ -115,4 +117,5 @@ a.item {
src: url('http://impress.openneo.net/assets/fonts/Delicious-Italic.otf');
}
@import "items/index";
@import "items/show";

View file

@ -11,3 +11,19 @@
= will_paginate @results
= render @results
= will_paginate @results
- else
#search-help
%h2 Find what you're looking for
%dl
%dt negg
%dd returns any item with the word "negg" in it
%dt floating doll
%dd returns any item with the words "floating" and "doll" in it
%dt "easter negg"
%dd returns any item with the phrase "easter negg" in it
%dt species:shoyru
%dd returns any item a Shoyru can wear
#species-search-links
%h2 Can't decide? Search by species
= standard_species_search_links

View file

@ -541,7 +541,7 @@ h1 a:hover {
}
/* line 88, ../../../app/stylesheets/screen.scss */
a.item img {
a img {
-moz-opacity: 0.9;
-webkit-opacity: 0.9;
-o-opacity: 0.9;
@ -550,8 +550,8 @@ a.item img {
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=90);
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=90);
}
/* line 91, ../../../app/stylesheets/screen.scss */
a.item:hover img {
/* line 92, ../../../app/stylesheets/screen.scss */
a:hover img, a:focus img {
-moz-opacity: 1;
-webkit-opacity: 1;
-o-opacity: 1;
@ -579,6 +579,46 @@ a.item:hover img {
src: url("http://impress.openneo.net/assets/fonts/Delicious-Italic.otf");
}
/* line 1, ../../../app/stylesheets/items/_index.scss */
form {
margin-bottom: 2em;
}
/* line 14, ../../../app/stylesheets/items/_index.scss */
#search-help {
float: left;
width: 49%;
padding-right: 1%;
}
/* line 9, ../../../app/stylesheets/items/_index.scss */
#search-help h2 {
font-size: 125%;
}
/* line 18, ../../../app/stylesheets/items/_index.scss */
#search-help dl {
text-align: left;
}
/* line 22, ../../../app/stylesheets/items/_index.scss */
#search-help dd {
margin-bottom: 1em;
}
/* line 27, ../../../app/stylesheets/items/_index.scss */
#species-search-links {
float: left;
width: 49%;
padding-left: 1%;
}
/* line 9, ../../../app/stylesheets/items/_index.scss */
#species-search-links h2 {
font-size: 125%;
}
/* line 32, ../../../app/stylesheets/items/_index.scss */
#species-search-links img {
height: 80px;
width: 80px;
}
/* line 2, ../../../app/stylesheets/items/_show.scss */
body.show header {
border-bottom: 1px solid #033e6b;