Navigation Menu

Skip to content

Commit

Permalink
Finish the site
Browse files Browse the repository at this point in the history
  • Loading branch information
vonconrad committed Apr 25, 2015
1 parent 2bf387d commit 6f9268c
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 27 deletions.
10 changes: 10 additions & 0 deletions config.rb
@@ -1,10 +1,20 @@
require 'lib/helpers'
helpers Helpers

activate :minify_css
activate :minify_javascript
activate :directory_indexes

set :haml, { :ugly => true, :format => :html5 }

data.ingredients.each do |ingredient|
proxy "/ingredients/#{ingredient.slug}.html", '/ingredient_template.html', locals: { ingredient: ingredient, title: "#{ingredient.name} - Skyrim Alchemy Potion Ingredients" }
end

data.effects.each do |effect|
proxy "/effects/#{effect.slug}.html", '/effect_template.html', locals: { effect: effect, title: "#{effect.name} - Skyrim Alchemy Potion Effects" }
end

ignore '/effect_template.html'
ignore '/ingredient_template.html'

42 changes: 32 additions & 10 deletions lib/helpers.rb
Expand Up @@ -7,17 +7,41 @@ def menu_class(item)
klass.join(' ')
end

def headline(obj)
content_tag(:h3, obj.name + uesp_link(obj).gsub('"', "'"))
def effects_for(ingredient)
ingredient.effects.map do |effect|
data.effects.find { |e| effect.id == e.id }
end
end

def uesp_link(obj)
link_to '', obj.uesp_link, class: 'uesp', title: "See #{obj.name} on UESP"
def ingredients_for(effect)
effect.ingredients.map do |ingredient|
data.ingredients.find { |i| ingredient.id == i.id }
end
end

def matching_ingredients_for(ingredient)
unique_matchers = ingredient.ingredient_matchers.uniq do |matching_ingredient|
matching_ingredient.id
end

matchers_with_effects = unique_matchers.map do |matching_ingredient|
data.ingredients.find { |i| matching_ingredient.id == i.id }
end

matchers_with_effects.select do |matching_ingredient|
(ingredient.effects & matching_ingredient.effects).count > 1
end
end

def matching_effects_list(ingredient, matching_ingredient)
(ingredient.effects & matching_ingredient.effects).map do |effect|
link_to(effect.name, "/effects/#{effect.slug}", class: 'effect tooltip')
end.join(', ').html_safe
end

def ingredient_tooltip(ingredient)
[
headline(ingredient),
content_tag(:h3, ingredient.name + uesp_link(ingredient).gsub('"', "'")),
*ingredient.effects.map do |effect|
link_to(effect.name, "/effects/#{effect.slug}").gsub('"', "'")
end.join('<br>')
Expand All @@ -26,17 +50,15 @@ def ingredient_tooltip(ingredient)

def effect_tooltip(effect)
[
headline(effect),
content_tag(:h3, effect.name + uesp_link(effect).gsub('"', "'")),
*effect.ingredients.map do |ingredient|
link_to(ingredient.name, "/ingredients/#{ingredient.slug}").gsub('"', "'")
end.join('<br>')
].join
end

def effect_list(ingredient)
(ingredient.effects & @ingredient.effects).inject([]) do |a, e|
a << link_to(e.name, effect_path(e), class: 'effect tooltip')
end.join(', ').html_safe
def uesp_link(obj)
link_to '', obj.uesp_link, class: 'uesp', title: "See #{obj.name} on UESP"
end

def facebook_like
Expand Down
9 changes: 6 additions & 3 deletions source/effect_template.html.haml
@@ -1,9 +1,12 @@
#top
#main
%h1
#{@effect.name} #{uesp_link(@effect)}
#{effect.name} #{uesp_link(effect)}
%h2 Ingredients:
%p
%i All ingredients for #{@effect.name}:
%i All ingredients for #{effect.name}:
%ul.ingredient-list.no-columns
= render @effect.ingredients
- ingredients_for(effect).each do |ingredient|
%li
%a.tooltip{ href: "/ingredients/#{ingredient.slug}", title: ingredient_tooltip(ingredient), class: ingredient.dlc.present? ? "dlc icon-#{ingredient.dlc.downcase}" : nil }
= ingredient.name
29 changes: 16 additions & 13 deletions source/ingredient_template.html.haml
@@ -1,28 +1,31 @@
#top
#main
%h1
#{@ingredient.name} #{uesp_link(@ingredient)}
%h2 Where to find #{@ingredient.name}:
%p= @ingredient.location
#{ingredient.name} #{uesp_link(ingredient)}
%h2 Where to find #{ingredient.name}:
%p= ingredient.location
%h2 Ideal ingredient matchers:
- if @ingredient.matching_ingredients.any?
- if matching_ingredients_for(ingredient).any?
%p
%i These are ingredients which have two or more effects in common with #{@ingredient.name}:
%i These are ingredients which have two or more effects in common with #{ingredient.name}:
%ul.ingredient-list.no-columns
- @ingredient.matching_ingredients.each do |ingredient_with_effects|
- matching_ingredients_for(ingredient).each do |matching_ingredient|
%li
%a.tooltip{ href: ingredient_path(ingredient_with_effects), title: tooltip(ingredient_with_effects), class: ingredient_with_effects.dlc.present? ? "dlc icon-#{ingredient_with_effects.dlc.name.downcase}" : nil }
= ingredient_with_effects.name
(#{effect_list(ingredient_with_effects)})
%a.tooltip{ href: "/ingredients/#{matching_ingredient.slug}", title: ingredient_tooltip(matching_ingredient), class: matching_ingredient.dlc.present? ? "dlc icon-#{matching_ingredient.dlc.downcase}" : nil }
= matching_ingredient.name
(#{matching_effects_list(ingredient, matching_ingredient)})
- else
%p
%i None
%h2 Effects:
%p
%i All effects of #{@ingredient.name}, together with other ingredients that share the same effect:
- @ingredient.effects.each do |effect|
%i All effects of #{ingredient.name}, together with other ingredients that share the same effect:
- effects_for(ingredient).each do |effect|
%h3<
= link_to effect.name, effect_path(effect), class: 'effect'
= link_to effect.name, "/effects/#{effect.slug}", class: 'effect'
= ':'
%ul.ingredient-list
= render (effect.ingredients - [@ingredient])
- ingredients_for(effect).each do |effect_ingredient|
%li
%a.tooltip{ href: "/ingredients/#{effect_ingredient.slug}", title: ingredient_tooltip(effect_ingredient), class: effect_ingredient.dlc.present? ? "dlc icon-#{effect_ingredient.dlc.downcase}" : nil }
= effect_ingredient.name
2 changes: 1 addition & 1 deletion source/layout.html.haml
@@ -1,7 +1,7 @@
!!!
%html
%head
%title= current_page.data.title
%title= current_page.data.title || title
= stylesheet_link_tag 'application', :media => 'all'
= javascript_include_tag 'application'
%body
Expand Down

0 comments on commit 6f9268c

Please sign in to comment.