From 4a3fd658485ed1af4f5f82af4eb394ab04db87cd Mon Sep 17 00:00:00 2001 From: Andrew Miner Date: Mon, 9 Feb 2015 14:28:21 -0800 Subject: [PATCH] Show all recipes for an item on its detail page --- src/css/templates/full_recipe.scss | 2 + src/css/templates/item_page.scss | 7 +++- src/marketing/forum-posts.txt | 19 +++++++++- .../controllers/item_page_controller.coffee | 38 ++++++++++++++----- src/scripts/models/item_page.coffee | 6 ++- src/templates/item_page.jade | 5 +-- 6 files changed, 62 insertions(+), 15 deletions(-) diff --git a/src/css/templates/full_recipe.scss b/src/css/templates/full_recipe.scss index 4e909c65d..1a0f523f5 100644 --- a/src/css/templates/full_recipe.scss +++ b/src/css/templates/full_recipe.scss @@ -6,6 +6,8 @@ All rights reserved. */ .view__full_recipe { + display: block; + & > div { position: relative; width: 33%; display: inline-block; diff --git a/src/css/templates/item_page.scss b/src/css/templates/item_page.scss index a971354c0..b4b4e967c 100644 --- a/src/css/templates/item_page.scss +++ b/src/css/templates/item_page.scss @@ -57,11 +57,16 @@ All rights reserved. } } - .recipe { + .recipes { display: none; .view__full_recipe { width: 100%; + margin-top: 3em; + + &:first-child { + margin-top: 0; + } } } diff --git a/src/marketing/forum-posts.txt b/src/marketing/forum-posts.txt index f2c20e80e..6bad1b163 100644 --- a/src/marketing/forum-posts.txt +++ b/src/marketing/forum-posts.txt @@ -46,4 +46,21 @@ also updated the site to let you select the version you're using. I just pushed up a big new feature! Now, each Mod has a dedicated page of its own which lists all the items available in that mod. Clicking on an item will take you to the crafting guide for that item. It's super fast to switch back and forth to explore the items in any given mod. This is the first of many steps for the new mod pages, so keep an eye out -for more to come! \ No newline at end of file +for more to come! + +######################################################################################################################## + + +I've been working on a project to make it easier to deal with complex recipes, and I recently finished adding all the +core Minecraft recipes. The gist of the site is that you tell it what item(s) you want to make, and it will figure out +all the raw ingredients you need along with step-by-step instructions for any number of whatever items you like. For +example, [http://crafting-guide.com/crafting/16.potion_of_fire_resistance_8_00:16.potion_of_healing_ii here's how you +make] 16 potions of healing II and fire resistance (with extended duration). + +The maintainers of many of the mods I've added (e.g., BuildCraft / Applied Energistics) have found it useful to include +links to Crafting Guide in their official documentation, and I was hoping you would think it a good idea to add links +from this wiki to CraftingGuide as well. I'd be happy to do the work of adding the links myself, but I'd like to make +sure there are no objections first! + +Thanks! +~~~~ \ No newline at end of file diff --git a/src/scripts/controllers/item_page_controller.coffee b/src/scripts/controllers/item_page_controller.coffee index 2f1f9c318..33344a766 100644 --- a/src/scripts/controllers/item_page_controller.coffee +++ b/src/scripts/controllers/item_page_controller.coffee @@ -38,17 +38,17 @@ module.exports = class ItemPageController extends BaseController # BaseController Overrides ##################################################################### onDidRender: -> - @_recipeController = @addChild FullRecipeController, '.view__full_recipe', modPack:@_modPack @_similarItemsController = @addChild ItemGroupController, '.similar .view__item_group', modPack:@_modPack @_usedInMakingController = @addChild ItemGroupController, '.usedInMaking .view__item_group', modPack:@_modPack @$byline = @$('.byline') @$bylineLink = @$('.byline a') - @$usedInMakingContainer = @$('.usedInMaking') @$name = @$('h1.name') - @$recipeContainer = @$('.recipe') + @$recipeContainer = @$('.recipes .panel') + @$recipesSection = @$('.recipes') @$similarContainer = @$('.similar') @$titleImage = @$('.titleImage img') + @$usedInMakingContainer = @$('.usedInMaking') super refresh: -> @@ -63,7 +63,7 @@ module.exports = class ItemPageController extends BaseController @$name.html '' @_refreshByline() - @_refreshRecipe() + @_refreshRecipes() @_refreshSimilarItems() @_refreshComponentIn() @@ -89,12 +89,32 @@ module.exports = class ItemPageController extends BaseController else @$usedInMakingContainer.fadeOut duration:Duration.fast - _refreshRecipe: -> - @_recipeController.model = @model.primaryRecipe - if @_recipeController.model? - @$recipeContainer.fadeIn duration:Duration.fast + _refreshRecipes: -> + @_recipeControllers ?= [] + index = 0 + + recipes = @model.findRecipes() + if recipes? + @$recipesSection.fadeIn duration:Duration.normal + + for recipe in @model.findRecipes() + controller = @_recipeControllers[index] + if not controller? + controller = new FullRecipeController modPack:@_modPack, model:recipe + @_recipeControllers.push controller + controller.render() + controller.$el.hide() + @$recipeContainer.append controller.$el + controller.$el.fadeIn duration:Duration.normal + else + controller.model = recipe + index++ else - @$recipeContainer.fadeOut duration:Duration.fast + @$recipesSection.fadeOut duration:Duration.fast + + while @_recipeControllers.length > index + controller = @_recipeControllers.pop() + controller.fadeOut duration:Duration.fast, complete:-> controller.$el.remove() _refreshSimilarItems: -> group = @model.item?.group diff --git a/src/scripts/models/item_page.coffee b/src/scripts/models/item_page.coffee index 12e63c1f0..cb905bd3a 100644 --- a/src/scripts/models/item_page.coffee +++ b/src/scripts/models/item_page.coffee @@ -25,7 +25,6 @@ module.exports = class ItemPage extends BaseModel Object.defineProperties this, craftingRawMaterials: {get:-> @_plan.need} craftingSteps: {get:-> @_plan.steps} - primaryRecipe: {get:-> @_primaryRecipe} # Property Methods ############################################################################# @@ -56,6 +55,11 @@ module.exports = class ItemPage extends BaseModel return null unless result.length > 0 return result + findRecipes: -> + result = @modPack.findRecipes @item?.slug + return null unless result.length > 0 + return result + # Private Methods ############################################################################## _updateCraftingPlan: -> diff --git a/src/templates/item_page.jade b/src/templates/item_page.jade index b55b68e1d..453b73009 100644 --- a/src/templates/item_page.jade +++ b/src/templates/item_page.jade @@ -14,10 +14,9 @@ .byline: p from .description: p - .recipe.section - h2 Recipe + .recipes.section + h2 Recipes .panel - .view__full_recipe .usedInMaking: .view__item_group .similar: .view__item_group