Refactor website with new design & structure

This commit is contained in:
Andrew Miner
2016-04-03 19:30:15 -07:00
parent ec7e8c883d
commit d69585facd
406 changed files with 7411 additions and 37859 deletions
+36
View File
@@ -0,0 +1,36 @@
//-
//- Crafting Guide - item_page.jade
//-
//- Copyright © 2014-2016 by Redwood Labs
//- All rights reserved.
//-
.content.view__mod_page
.left
.view__adsense
.right
.about
.left
img
.center
.title
.author
.description
.version
span in my mod pack
select
.warning.
<b>PLEASE NOTE:</b> By selecting "no", crafting plans, search, and other features will ignore items
and recipes from this mod.
.right
p Official Links:
a.homePage project page
a.documentation documentation
a.download download
section.tutorials
h2 Tutorials
.panel
.itemGroups
+94
View File
@@ -0,0 +1,94 @@
//
// Crafting Guide - item_page.scss
//
// Copyright © 2014-2016 by Redwood Labs
// All rights reserved.
//
.view__mod_page {
@include layout-body-with-sidebar;
.about {
margin-bottom: $size-margin-xlarge;
display: flex;
.left {
flex: 0 0 auto;
margin-right: $size-margin-large;
img {
height: $size-minecraft-block * 5;
width: $size-minecraft-block * 5;
}
}
.center {
flex: 1 1 100%;
margin-right: $size-margin-large;
.title {
font-family: $font-family-header;
font-size: $font-size-xxlarge;
}
.author {
font-family: $font-family-text;
font-size: $font-size-medium;
&:before {
content: "by: "
}
}
.description {
margin-top: $size-margin-large;
font-family: $font-family-text;
font-size: $font-size-medium;
line-height: $font-size-medium * 1.25;
}
.version {
margin-top: $size-margin-large;
font-family: $font-family-control;
font-size: $font-size-medium;
display: flex;
align-items: baseline;
span {
flex: 0 0 auto;
margin-right: $size-margin-medium;
}
select {
flex: 1 1 100%;
font-family: $font-family-control;
font-size: $font-size-medium;
}
}
.warning {
margin-top: $size-margin-medium;
color: $color-error;
font-family: $font-family-text;
font-size: $font-size-small;
line-height: $font-size-small * 1.25;
b {
font-weight: bold;
}
}
}
.right {
flex: 0 0 auto;
@include layout-link-list;
}
}
}
@@ -0,0 +1,184 @@
#
# Crafting Guide - mod_page_controller.coffee
#
# Copyright © 2014-2016 by Redwood Labs
# All rights reserved.
#
AdsenseController = require '../common/adsense/adsense_controller'
BaseController = require '../base_controller'
Item = require '../../models/game/item'
ItemGroupController = require '../common/item_group/item_group_controller'
Mod = require '../../models/game/mod'
TutorialController = require './tutorial/tutorial_controller'
########################################################################################################################
module.exports = class ModPageController extends BaseController
constructor: (options={})->
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
if not options.modPack? then throw new Error 'options.modPack is required'
if not options.router? then throw new Error 'options.router is required'
options.templateName = 'mod_page'
super options
@_imageLoader = options.imageLoader
@_modPack = options.modPack
@_router = options.router
# Event Methods ################################################################################
onVersionChanged: ->
@model.activeVersion = @$versionSelector.val()
return false
# Property Methods #############################################################################
Object.defineProperties @prototype,
effectiveModVersion:
get: ->
modVersion = @model.activeModVersion
modVersion ?= @model.getModVersion Mod.Version.Latest
modVersion.fetch() if modVersion?
return modVersion
# PageController Overrides #####################################################################
getBreadcrumbs: ->
return [
$('<a href="/browse">Browse</a>')
$("<b>#{@model.name}</b>")
]
getTitle: ->
return @model.name
# BaseController Overrides #####################################################################
onDidRender: ->
@_adsenseController = @addChild AdsenseController, '.view__adsense', model: 'skyscraper'
@$author = @$('.about .author')
@$description = @$('.about .description')
@$documentationLink = @$('.about .documentation')
@$downloadLink = @$('.about .download')
@$homePageLink = @$('.about .homePage')
@$itemGroups = @$(".itemGroups")
@$logo = @$('.about img')
@$title = @$('.about .title')
@$tutorialsContainer = @$('section.tutorials .panel')
@$tutorialsSection = @$('section.tutorials')
@$versionSelector = @$('.version select')
@$warning = @$('.warning')
super
refresh: ->
@_refreshAboutBlock()
@_refreshItemGroups()
@_refreshTutorials()
@_refreshVersionSelector()
super
# Backbone.View Overrides ######################################################################
events: ->
return _.extend super,
'change .version select': 'onVersionChanged'
# Private Methods ##############################################################################
_refreshAboutBlock: ->
if @model?
@$author.text @model.author
@$description.text @model.description
@$documentationLink.attr 'href', @model.documentationUrl
@$downloadLink.attr 'href', @model.downloadUrl
@$homePageLink.attr 'href', @model.homePageUrl
@$logo.attr 'src', c.url.modIcon modSlug:@model.slug
@$title.text @model.name
else
@$author.text ''
@$description.text ''
@$documentationLink.attr 'href', ''
@$downloadLink.attr 'href', ''
@$homePageLink.attr 'href', ''
@$logo.attr 'src', ''
@$title.text ''
_refreshItemGroups: ->
@_groupControllers ?= []
groupIndex = 0
modVersion = @effectiveModVersion
if modVersion?
modVersion.eachGroup (group)=>
controller = @_groupControllers[groupIndex]
items = modVersion.allItemsInGroup group
if not controller?
controller = new ItemGroupController
imageLoader: @_imageLoader
model: items
modPack: @_modPack
router: @_router
title: if group is Item.Group.Other then 'Items' else group
@_groupControllers.push controller
@$itemGroups.append controller.$el
controller.render()
else
controller.modVersion = modVersion
controller.model = items
controller.refresh()
groupIndex++
while @_groupControllers.length > groupIndex + 1
@_groupControllers.pop().remove()
_refreshTutorials: ->
@_tutorialControllers ?= []
index = 0
tutorials = @model.tutorials
if tutorials.length > 0
for tutorial in tutorials
controller = @_tutorialControllers[index]
if not controller?
controller = new TutorialController model: tutorial, router: @_router
@_tutorialControllers.push controller
@$tutorialsContainer.append controller.$el
controller.render()
else
controller.model = tutorial
index += 1
while @_tutorialControllers.length > index
@_tutorialControllers.pop().remove()
@show @$tutorialsSection
else
@hide @$tutorialsSection
_refreshVersionSelector: ->
modVersions = @model.modVersions
selectedModVersion = @effectiveModVersion
@$versionSelector.empty()
$option = $("<option value=\"none\">no</option>")
if not @model.enabled
@$warning.css display:''
selectedModVersion = null
$option.attr 'selected', true
else
@$warning.css display:'none'
@$versionSelector.append $option
for modVersion in @model.modVersions
$option = $("<option value=\"#{modVersion.version}\">#{modVersion.version}</option>")
if modVersion is selectedModVersion
$option.attr 'selected', 'true'
@$versionSelector.append $option
@$versionSelector.css display:''
@@ -0,0 +1,11 @@
//-
//- Crafting Guide - tutorial.jade
//-
//- Copyright © 2014-2016 by Redwood Labs
//- All rights reserved.
//-
.view__tutorial
a
img
p
@@ -0,0 +1,30 @@
//
// Crafting Guide - tutorial.scss
//
// Copyright © 2014-2016 by Redwood Labs
// All rights reserved.
//
.view__tutorial {
display: flex;
flex-wrap: wrap;
a {
flex: 0 0 auto;
display: flex;
flex-direction: column;
align-items: center;
img {
height: $size-minecraft-block * 4;
margin-bottom: $size-margin-xsmall;
width: $size-minecraft-block * 4;
}
p {
font-family: $font-family-text;
font-size: $font-size-medium;
}
}
}
@@ -0,0 +1,38 @@
#
# Crafting Guide - tutorial_controller.coffee
#
# Copyright © 2014-2016 by Redwood Labs
# All rights reserved.
#
BaseController = require '../../base_controller'
########################################################################################################################
module.exports = class TutorialController extends BaseController
constructor: (options={})->
if not options.model? then throw new Error 'options.model is required'
options.templateName = 'mod_page/tutorial'
super options
# BaseController Overrides #####################################################################
onDidRender: ->
@$icon = @$('img')
@$link = @$('a')
@$title = @$('p')
super
refresh: ->
templateData = modSlug:@model.modSlug, tutorialSlug:@model.slug
@$icon.attr 'src', c.url.tutorialIcon templateData
@$link.attr 'href', c.url.tutorial templateData
@$title.html @model.name
super
# Backbone.View Overrides ######################################################################
events: ->
return _.extend super,
'click a': 'routeLinkClick'