* Convert build to use a single JavaScript file on the site (instead of downloading each library separately). This also means that all global variables (e.g., `$` for JQuery, `_` for Underscore.js) can be removed. * Remove unused scripts and/or move them to a more appropriate repo * Update the `deploy` script to work with CircleCI's automation * Update markdown display code to allow images to be located with the markdown data files instead of the pre-rendered index pages
37 lines
1.2 KiB
CoffeeScript
37 lines
1.2 KiB
CoffeeScript
###
|
|
Crafting Guide - tutorial.coffee
|
|
|
|
Copyright (c) 2015 by Redwood Labs
|
|
All rights reserved.
|
|
###
|
|
|
|
BaseModel = require './base_model'
|
|
TutorialParser = require './tutorial_parser'
|
|
_ = require 'underscore'
|
|
{Url} = require '../constants'
|
|
|
|
########################################################################################################################
|
|
|
|
module.exports = class Tutorial extends BaseModel
|
|
|
|
constructor: (attributes={}, options={})->
|
|
if not attributes.name?.length > 0 then throw new Error "attributes.name cannot be empty"
|
|
attributes.modSlug ?= null
|
|
attributes.officialUrl ?= null
|
|
attributes.sections ?= []
|
|
attributes.slug ?= _.slugify attributes.name
|
|
attributes.videos ?= []
|
|
super attributes, options
|
|
|
|
# Backbone.Model Overrides #####################################################################
|
|
|
|
parse: (text)->
|
|
TutorialParser = require './tutorial_parser' # to avoid require cycles
|
|
@_parser ?= new TutorialParser model:this
|
|
@_parser.parse text
|
|
|
|
return null # prevent calling `set`
|
|
|
|
url: ->
|
|
return Url.tutorialData modSlug:@modSlug, tutorialSlug:@slug
|