Convert site to a single JavaScript archive
* 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
This commit is contained in:
+31
-44
@@ -10,64 +10,47 @@ util = require 'util'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
LIBRARY_ALIAS_MAPPING = [
|
||||
'./node_modules/jquery/dist/jquery.js:jquery'
|
||||
'./node_modules/backbone/backbone.js:backbone'
|
||||
'./node_modules/jade/runtime.js:jade'
|
||||
'./node_modules/markdown/lib/index.js:markdown'
|
||||
'./node_modules/underscore/underscore.js:underscore'
|
||||
'./node_modules/when/when.js:when'
|
||||
]
|
||||
|
||||
LIBRARIES = (s.substring(0, s.indexOf(':')) for s in LIBRARY_ALIAS_MAPPING)
|
||||
ALIASES = (s.substring(s.indexOf(':') + 1) for s in LIBRARY_ALIAS_MAPPING)
|
||||
|
||||
module.exports = (grunt)->
|
||||
|
||||
grunt.loadTasks tasks for tasks in grunt.file.expand './node_modules/grunt-*/tasks'
|
||||
|
||||
grunt.config.init
|
||||
browserify:
|
||||
main:
|
||||
options:
|
||||
ignore: ['http', 'jade', 'underscore', 'when']
|
||||
files:
|
||||
'./dist/js/main.js': ['./build/main.js']
|
||||
|
||||
markdown:
|
||||
dev:
|
||||
options:
|
||||
browserifyOptions:
|
||||
debug: false
|
||||
standalone: 'markdown'
|
||||
files:
|
||||
'./dist/js/markdown.js': ['./node_modules/markdown/lib/index.js']
|
||||
|
||||
when:
|
||||
options:
|
||||
browserifyOptions:
|
||||
debug: false
|
||||
standalone: 'w'
|
||||
files:
|
||||
'./dist/js/when.js': ['./node_modules/when/when.js']
|
||||
debug: true
|
||||
extensions: ['.coffee']
|
||||
transform: ['coffeeify']
|
||||
files: './dist/js/main.js': ['./src/coffee/main.coffee']
|
||||
prod:
|
||||
files: './dist/js/main.js': ['./src/coffee/main.coffee']
|
||||
|
||||
clean:
|
||||
build: ['./build']
|
||||
dist: ['./dist']
|
||||
|
||||
coffee:
|
||||
files:
|
||||
expand: true
|
||||
cwd: './src/coffee'
|
||||
src: '**/*.coffee'
|
||||
dest: './build'
|
||||
ext: '.js'
|
||||
extDot: 'last'
|
||||
|
||||
copy:
|
||||
scripts:
|
||||
files:
|
||||
'./dist/js/backbone.js': ['./node_modules/backbone/backbone.js']
|
||||
'./dist/js/chai.js': ['./node_modules/chai/chai.js']
|
||||
'./dist/js/jade.js': ['./node_modules/jade/runtime.js']
|
||||
'./dist/js/jquery.js': ['./node_modules/jquery/dist/jquery.js']
|
||||
'./dist/js/mocha.js': ['./node_modules/mocha/mocha.js']
|
||||
'./dist/js/underscore.js': ['./node_modules/underscore/underscore.js']
|
||||
styles:
|
||||
files: [expand:true, cwd:'./src/css', src:'**/*.scss', dest:'./dist/src/css']
|
||||
style_extras:
|
||||
files:
|
||||
'./dist/css/mocha.css': ['./node_modules/mocha/mocha.css']
|
||||
views:
|
||||
files:
|
||||
'./build/views.js': ['./src/coffee/views.js']
|
||||
|
||||
exorcise:
|
||||
dev:
|
||||
files: './dist/js/main.js.map': ['./dist/js/main.js']
|
||||
|
||||
jade:
|
||||
pages:
|
||||
@@ -141,19 +124,23 @@ module.exports = (grunt)->
|
||||
tasks: ['rsync:static']
|
||||
coffee:
|
||||
files: ['./src/**/*.coffee']
|
||||
tasks: ['coffee', 'browserify:main']
|
||||
tasks: ['browserify:dev', 'exorcise']
|
||||
jade:
|
||||
files: ['./src/**/*.jade']
|
||||
tasks: ['jade:pages', 'jade:templates', 'copy:views', 'browserify:main']
|
||||
tasks: ['jade:pages', 'jade:templates', 'copy:views', 'browserify:dev', 'exorcise']
|
||||
sass:
|
||||
files: ['./src/**/*.scss']
|
||||
tasks: ['sass', 'copy:styles']
|
||||
|
||||
grunt.registerTask 'default', 'build'
|
||||
|
||||
grunt.registerTask 'build', [ 'rsync', 'sass:build', 'jade', 'coffee', 'copy', 'browserify' ]
|
||||
grunt.registerTask 'build', [
|
||||
'rsync', 'sass:build', 'jade', 'copy', 'browserify:dev', 'exorcise'
|
||||
]
|
||||
|
||||
grunt.registerTask 'dist', ['test', 'clean', 'build', 'sass:dist', 'uglify']
|
||||
grunt.registerTask 'dist', [
|
||||
'clean', 'rsync', 'sass:dist', 'jade', 'copy', 'browserify:prod', 'uglify', 'test'
|
||||
]
|
||||
|
||||
grunt.registerTask 'clean-watch', ['clean', 'build', 'watch']
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
deployment:
|
||||
staging:
|
||||
branch: master
|
||||
commands:
|
||||
- ./scripts/deploy --staging
|
||||
production:
|
||||
branch: production
|
||||
commands:
|
||||
- ./scripts/deploy --production
|
||||
+1
-2
@@ -23,14 +23,13 @@
|
||||
"express": "^4.10.6",
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-browserify": "^3.2.1",
|
||||
"grunt-coffee": "0.0.6",
|
||||
"grunt-contrib-clean": "^0.6.0",
|
||||
"grunt-contrib-coffee": "^0.13.0",
|
||||
"grunt-contrib-copy": "^0.7.0",
|
||||
"grunt-contrib-jade": "^0.13.0",
|
||||
"grunt-contrib-sass": "^0.8.1",
|
||||
"grunt-contrib-uglify": "^0.7.0",
|
||||
"grunt-contrib-watch": "^0.6.1",
|
||||
"grunt-exorcise": "^1.0.1",
|
||||
"grunt-mocha-test": "^0.12.7",
|
||||
"grunt-rename": "^0.1.4",
|
||||
"grunt-rsync": "^0.6.2",
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
ssh [email protected]
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
read -d '' USAGE <<END
|
||||
USAGE: convert-nei-dump <source> <mod_slug> <mod_version>
|
||||
|
||||
Converts output from NEI dump files into a format which can be used by
|
||||
Crafting Guide. In particlar, this script looks for the "Item Panel" dump
|
||||
both in PNG and CSV formats and assumes they contain all the data for the
|
||||
target mod.
|
||||
|
||||
Unfortunate, NEI doesn't generate enough information to fill in all the
|
||||
recipes for each item: only their names. Once this script has converted the
|
||||
data, you will need to manually enter the missing content.
|
||||
|
||||
<source> : the "dumps" directory where NEI dropped its content
|
||||
<mod_slug> : the slug of the mod being converted
|
||||
<mod_version> : the version of the mod being converted
|
||||
END
|
||||
|
||||
|
||||
SOURCE_DIR="$1"; shift
|
||||
MOD_SLUG="$1"; shift
|
||||
MOD_VERSION="$1"; shift
|
||||
|
||||
mkdir -p "./static/data/$MOD_SLUG/$MOD_VERSION"
|
||||
DATA_FILE="./static/data/$MOD_SLUG/$MOD_VERSION/mod-version.cg"
|
||||
touch "$DATA_FILE"
|
||||
|
||||
if [[ "$SOURCE_DIR" == "" || "$MOD_SLUG" == "" || "$MOD_VERSION" == "" ]]; then
|
||||
echo "$USAGE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "./static/browse/$MOD_SLUG/images"
|
||||
ls $SOURCE_DIR/itempanel_icons | while read FILE; do
|
||||
ITEM_NAME="$(echo $FILE | sed 's/.png//')"
|
||||
ITEM_SLUG="$(echo $ITEM_NAME \
|
||||
| sed 's/[^a-zA-Z0-9]/_/g' \
|
||||
| sed 's/__*/_/g' \
|
||||
| sed 's/^_//' \
|
||||
| sed 's/_$//' \
|
||||
| tr '[A-Z]' '[a-z]' \
|
||||
)"
|
||||
mkdir -p "./static/browse/$MOD_SLUG/$ITEM_SLUG"
|
||||
cp "$SOURCE_DIR/itempanel_icons/$FILE" "./static/browse/$MOD_SLUG/$ITEM_SLUG/icon.png"
|
||||
if ! grep -q "item: $ITEM_NAME$" $DATA_FILE; then
|
||||
echo "item: $ITEM_NAME" >> $DATA_FILE
|
||||
echo "" >> $DATA_FILE
|
||||
fi
|
||||
done
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
for FILE in $(ls $1/images); do
|
||||
ITEM=$(basename -s .png $FILE)
|
||||
MOD=$(basename $(dirname $1))
|
||||
TARGET_DIR="./static/browse/$MOD/$ITEM"
|
||||
TARGET_FILE="./static/browse/$MOD/$ITEM/icon.png"
|
||||
|
||||
mkdir -p "$TARGET_DIR"
|
||||
mv "$1/images/$FILE" "$TARGET_FILE"
|
||||
done
|
||||
+25
-17
@@ -1,32 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
export AWS_CONFIG_FILE="aws.config"
|
||||
if [[ -e "./aws.config" ]]; then
|
||||
export AWS_CONFIG_FILE="./aws.config"
|
||||
else
|
||||
export AWS_CONFIG_FILE="$HOME/.aws/config"
|
||||
fi
|
||||
|
||||
ROOT="./dist"
|
||||
SOURCE_DIR="./dist/"
|
||||
SITE="crafting-guide.com"
|
||||
TARGET=""
|
||||
while [[ "$1" != "" ]]; do
|
||||
case "$1" in
|
||||
"--new") TARGET="new";;
|
||||
"--promote") TARGET="promote";;
|
||||
"--staging") TARGET="staging";;
|
||||
"--production") TARGET="production";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ "$TARGET" == "" ]]; then
|
||||
echo "Please choose either --new or --promote for the target."
|
||||
exit
|
||||
echo "Please choose either --staging or --production for the target."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$TARGET" == "staging" ]]; then
|
||||
TARGET_DIR="s3://new.$SITE/"
|
||||
elif [[ "$TARGET" == "production" ]]; then
|
||||
TARGET_DIR="s3://$SITE/"
|
||||
fi
|
||||
|
||||
S3CMD_CFG="$HOME/.s3cfg"
|
||||
if [[ ! -e "$S3CMD_CFG" ]]; then
|
||||
echo "[default]" > "$S3CMD_CFG"
|
||||
cat $AWS_CONFIG_FILE | grep "aws_access_key_id" | sed "s/aws_access_key_id/access_key/" >> "$S3CMD_CFG"
|
||||
cat $AWS_CONFIG_FILE | grep "aws_secret_access_key" | sed "s/aws_secret_access_key/secret_key/" >> "$S3CMD_CFG"
|
||||
fi
|
||||
|
||||
if [[ "$TARGET" == "new" ]]; then
|
||||
find . -name ".DS_Store" 2>/dev/null | xargs rm &>/dev/null
|
||||
if grunt dist; then
|
||||
echo "Preparing to upload to S3..."
|
||||
s3cmd sync -r --add-header="cache-control:max-age=1800" "$ROOT/" "s3://new.$SITE/"
|
||||
grunt clean:dist build
|
||||
else
|
||||
echo "Aborting deployment"
|
||||
fi
|
||||
elif [[ "$TARGET" == "promote" ]]; then
|
||||
aws s3 sync "s3://new.$SITE" "s3://$SITE" --delete
|
||||
fi
|
||||
s3cmd sync -r --add-header="cache-control:max-age=1800" $SOURCE_DIR $TARGET_DIR
|
||||
echo "S3 Upload Complete"
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASE_DIR="$1"
|
||||
for FILE in $(ls $BASE_DIR/images); do
|
||||
NAME=$(basename -s.png $FILE)
|
||||
DIR="$BASE_DIR/$NAME"
|
||||
IMG_DEST="$DIR/icon.png"
|
||||
|
||||
mkdir -p $DIR
|
||||
mv "$BASE_DIR/images/$FILE" "$IMG_DEST"
|
||||
done
|
||||
@@ -1,73 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
USAGE=<<END
|
||||
USAGE: prerender <options>
|
||||
|
||||
Options:
|
||||
|
||||
--force : overwrite existing files (default skips)
|
||||
--clean : remove all files before starting
|
||||
--only <pattern> : restrict rendering to the given pattern
|
||||
--output <dir> : output directory (default: ./static)
|
||||
--sitemap <file> : sitemap file (default: ./static/sitemap.txt
|
||||
|
||||
END
|
||||
|
||||
CLEAN="no"
|
||||
FORCE="no"
|
||||
ONLY=".*"
|
||||
OUTPUT_DIR="./static"
|
||||
SITEMAP_FILE="./static/sitemap.txt"
|
||||
while [[ "$1" != "" ]]; do
|
||||
case "$1" in
|
||||
"--force") FORCE="yes";;
|
||||
"--help") echo $USAGE; exit 0;;
|
||||
"--clean") CLEAN="yes";;
|
||||
"--only") shift; ONLY="$1";;
|
||||
"--output") shift; OUTPUT_DIR="$1";;
|
||||
"--sitemap") shift; SITEMAP_FILE="$1";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
SCRIPT='/tmp/prerender_script.coffee'
|
||||
cat > $SCRIPT <<END
|
||||
url = require('system').args[1]
|
||||
page = require('webpage').create()
|
||||
path = "#{url}".replace(/http:\/\/[^/]*/, '').replace(/^\//, '')
|
||||
localUrl = "http://local.crafting-guide.com:8000/#{path}"
|
||||
|
||||
page.open localUrl, (status)->
|
||||
if status isnt 'success'
|
||||
console.error "Could not load #{url}"
|
||||
phantom.exit(1)
|
||||
|
||||
setTimeout (->
|
||||
console.log page.content
|
||||
phantom.exit(0)
|
||||
), 5000
|
||||
END
|
||||
|
||||
if [[ "$CLEAN" == "yes" ]]; then
|
||||
find "$OUTPUT_DIR/browse" -name "*.html" | xargs rm
|
||||
fi
|
||||
|
||||
cat $SITEMAP_FILE | grep "$ONLY" | while read URL; do
|
||||
OUTPUT_FILE=$(sed 's/http:\/\/[^/]*\///' <<< $URL)
|
||||
OUTPUT_FILE="$OUTPUT_DIR/$OUTPUT_FILE/index.html"
|
||||
OUTPUT_FILE=$(sed 's/\/\//\//' <<< $OUTPUT_FILE)
|
||||
|
||||
if [[ ! -e "$OUTPUT_FILE" || "$FORCE" == "yes" ]]; then
|
||||
mkdir -p $(dirname "$OUTPUT_FILE")
|
||||
echo "prerendering $URL into $OUTPUT_FILE"
|
||||
phantomjs --web-security=false --load-images=false $SCRIPT "$URL" >"$OUTPUT_FILE" 2>/dev/null
|
||||
if [[ "$?" != "0" ]]; then
|
||||
echo "An error occured rendering $URL"
|
||||
rm "$OUTPUT_FILE" 2>/dev/null
|
||||
fi
|
||||
else
|
||||
echo "Skipping $URL..."
|
||||
fi
|
||||
done
|
||||
|
||||
rm $SCRIPT
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env coffee
|
||||
|
||||
global._ = require 'underscore'
|
||||
global.Backbone = require 'backbone'
|
||||
|
||||
ModVersion = require '../src/coffee/models/mod_version'
|
||||
ModVersionParser = require '../src/coffee/models/mod_version_parser'
|
||||
fs = require 'fs'
|
||||
{Logger} = require 'crafting-guide-common'
|
||||
|
||||
require '../src/coffee/underscore_mixins'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
if process.argv.length is 3
|
||||
sourceFileName = process.argv[2]
|
||||
targetFileName = process.argv[2]
|
||||
else if process.argv.length is 4
|
||||
sourceFileName = process.argv[2]
|
||||
targetFileName = process.argv[3]
|
||||
else
|
||||
console.error """
|
||||
|
||||
USAGE: reformat <source> (<target>)
|
||||
|
||||
Reformats a given recipe book into the latest version of the recipe book
|
||||
format. This includes alphabetizing entries, simplifying item lists, and
|
||||
upgrading to the latest version.
|
||||
|
||||
If given a single argument, the named file will be replaced with the
|
||||
reformatted version. If two arguments are given, then the output will be
|
||||
written to the second file. If a "-" is given as the second file, the
|
||||
output will be written to stdout.
|
||||
|
||||
"""
|
||||
process.exit -1
|
||||
|
||||
global.logger = new Logger level:Logger.WARNING
|
||||
|
||||
try
|
||||
text = fs.readFileSync sourceFileName, 'UTF-8'
|
||||
parser = new ModVersionParser model:new ModVersion modSlug:'', version:''
|
||||
modVersion = parser.parse text
|
||||
text = parser.unparse(modVersion).trim().replace(/^\s\s*$/gm, '')
|
||||
|
||||
if targetFileName is '-'
|
||||
console.log text
|
||||
else
|
||||
fs.writeFileSync targetFileName, text, encoding:'UTF-8'
|
||||
catch e
|
||||
console.error e.stack
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/usr/bin/env coffee
|
||||
|
||||
global._ = require 'underscore'
|
||||
global.Backbone = require 'backbone'
|
||||
|
||||
fs = require 'fs'
|
||||
Logger = require '../src/scripts/logger'
|
||||
ModVersionParser = require '../src/scripts/models/mod_version_parser'
|
||||
|
||||
require '../src/scripts/underscore_mixins'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
if process.argv.length is 3
|
||||
sourceFileName = process.argv[2]
|
||||
else
|
||||
console.error """
|
||||
|
||||
USAGE: verify <source>
|
||||
|
||||
Verifies that a recipe book is in the proper format. If there is a problem,
|
||||
then a message will be displayed. Otherwise, the command has no output.
|
||||
|
||||
"""
|
||||
process.exit -1
|
||||
|
||||
global.logger = new Logger level:Logger.WARNING
|
||||
|
||||
try
|
||||
text = fs.readFileSync sourceFileName, 'UTF-8'
|
||||
parser = new ModVersionParser showAllErrors:true
|
||||
modVersion = parser.parse text
|
||||
catch e
|
||||
console.error e.message
|
||||
@@ -5,13 +5,15 @@ Copyright (c) 2014-2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
_ = require 'underscore'
|
||||
|
||||
exports.Adsense = Adsense = {}
|
||||
Adsense.clientId = 'ca-pub-6593013914878730'
|
||||
Adsense.slotIds = ['7613920409', '9574673605', '3388539204']
|
||||
|
||||
# Minecraft must be first
|
||||
exports.DefaultMods =
|
||||
minecraft: { defaultVersion: '1.7.10' }
|
||||
minecraft: { defaultVersion: '1.7.10' } # Minecraft must be first
|
||||
|
||||
applied_energistics_2: { defaultVersion: 'rv1-stable-1' }
|
||||
big_reactors: { defaultVersion: '0.4.2A2' }
|
||||
buildcraft: { defaultVersion: '6.4.6' }
|
||||
@@ -114,6 +116,7 @@ exports.Url = Url = {}
|
||||
Url.crafting = _.template "/craft/<%= inventoryText %>"
|
||||
Url.item = _.template "/browse/<%= modSlug %>/<%= itemSlug %>/"
|
||||
Url.itemData = _.template "/data/<%= modSlug %>/items/<%= itemSlug %>/item.cg"
|
||||
Url.itemImageDir = _.template "/data/<%= modSlug %>/items/<%= itemSlug %>"
|
||||
Url.itemIcon = _.template "/data/<%= modSlug %>/items/<%= itemSlug %>/icon.png"
|
||||
Url.login = _.template "/login"
|
||||
Url.mod = _.template "/browse/<%= modSlug %>/"
|
||||
@@ -124,6 +127,8 @@ Url.root = _.template "/"
|
||||
Url.tutorial = _.template "/browse/<%= modSlug %>/tutorials/<%= tutorialSlug %>/"
|
||||
Url.tutorialData = _.template "/data/<%= modSlug %>/tutorials/<%= tutorialSlug %>/tutorial.cg"
|
||||
Url.tutorialIcon = _.template "/data/<%= modSlug %>/tutorials/<%= tutorialSlug %>/icon.png"
|
||||
Url.tutorialIcon = _.template "/data/<%= modSlug %>/tutorials/<%= tutorialSlug %>/icon.png"
|
||||
Url.tutorialImageDir = _.template "/data/<%= modSlug %>/tutorials/<%= tutorialSlug %>"
|
||||
|
||||
exports.UrlParam = UrlParam = {}
|
||||
UrlParam.quantity = 'count'
|
||||
|
||||
@@ -5,7 +5,9 @@ Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
$ = require 'jquery'
|
||||
BaseController = require './base_controller'
|
||||
_ = require 'underscore'
|
||||
{Adsense} = require '../constants'
|
||||
{Duration} = require '../constants'
|
||||
{ProductionEnvs} = require '../constants'
|
||||
|
||||
@@ -5,13 +5,16 @@ Copyright (c) 2014-2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
backbone = require 'backbone'
|
||||
views = require '../views'
|
||||
{Duration} = require '../constants'
|
||||
{Event} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
module.exports = class BaseController extends Backbone.View
|
||||
module.exports = class BaseController extends backbone.View
|
||||
|
||||
constructor: (options={})->
|
||||
@tryRefresh = _.debounce @_tryRefresh, 100
|
||||
|
||||
@@ -10,6 +10,7 @@ CraftPage = require '../models/craft_page'
|
||||
InventoryController = require './inventory_controller'
|
||||
PageController = require './page_controller'
|
||||
StepController = require './step_controller'
|
||||
_ = require 'underscore'
|
||||
{Event} = require '../constants'
|
||||
{Url} = require '../constants'
|
||||
|
||||
@@ -30,7 +31,7 @@ module.exports = class CraftPageController extends PageController
|
||||
@modPack = options.modPack
|
||||
@storage = options.storage
|
||||
|
||||
@model.plan.on Event.change, => @refresh()
|
||||
@model.plan.on Event.change, => @tryRefresh()
|
||||
|
||||
# Event Methods ################################################################################
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseController = require './base_controller'
|
||||
{Duration} = require '../constants'
|
||||
{Event} = require '../constants'
|
||||
ImageLoader = require './image_loader'
|
||||
MinimalRecipeController = require './minimal_recipe_controller'
|
||||
_ = require 'underscore'
|
||||
{Duration} = require '../constants'
|
||||
{Event} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
|
||||
@@ -5,9 +5,11 @@ Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
$ = require 'jquery'
|
||||
BaseController = require './base_controller'
|
||||
{Duration} = require '../constants'
|
||||
EmailClient = require '../models/email_client'
|
||||
_ = require 'underscore'
|
||||
{Duration} = require '../constants'
|
||||
{Key} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -10,6 +10,7 @@ CraftingGridController = require './crafting_grid_controller'
|
||||
ImageLoader = require './image_loader'
|
||||
Inventory = require '../models/inventory'
|
||||
InventoryController = require './inventory_controller'
|
||||
_ = require 'underscore'
|
||||
{Duration} = require '../constants'
|
||||
{StringBuilder} = require 'crafting-guide-common'
|
||||
|
||||
|
||||
@@ -5,8 +5,10 @@ Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
$ = require 'jquery'
|
||||
BaseController = require './base_controller'
|
||||
ItemSelectorController = require './item_selector_controller'
|
||||
_ = require 'underscore'
|
||||
{Duration} = require '../constants'
|
||||
{Event} = require '../constants'
|
||||
{ProductionEnvs} = require '../constants'
|
||||
|
||||
@@ -7,6 +7,7 @@ All rights reserved.
|
||||
|
||||
AdsenseController = require './adsense_controller'
|
||||
PageController = require './page_controller'
|
||||
_ = require 'underscore'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ ImageLoader = require './image_loader'
|
||||
ItemSelectorController = require './item_selector_controller'
|
||||
NameFinder = require '../models/name_finder'
|
||||
StackController = require './stack_controller'
|
||||
_ = require 'underscore'
|
||||
{Duration} = require '../constants'
|
||||
{Event} = require '../constants'
|
||||
{Key} = require '../constants'
|
||||
|
||||
@@ -6,6 +6,7 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseController = require './base_controller'
|
||||
_ = require 'underscore'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ ItemSlug = require '../models/item_slug'
|
||||
MarkdownSectionController = require './markdown_section_controller'
|
||||
PageController = require './page_controller'
|
||||
VideoController = require './video_controller'
|
||||
_ = require 'underscore'
|
||||
{Duration} = require '../constants'
|
||||
{Event} = require '../constants'
|
||||
{Text} = require '../constants'
|
||||
@@ -88,6 +89,8 @@ module.exports = class ItemPageController extends PageController
|
||||
@imageLoader.load display.iconUrl, @$titleImage
|
||||
@$name.html display.itemName
|
||||
|
||||
@_descriptionController.imageBase = Url.itemImageDir display
|
||||
|
||||
if @model.item.officialUrl?
|
||||
@$officialPageLink.attr 'href', @model.item.officialUrl
|
||||
@show @$officialPageLink
|
||||
|
||||
@@ -5,9 +5,11 @@ Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
$ = require 'jquery'
|
||||
BaseController = require './base_controller'
|
||||
ItemSelector = require '../models/item_selector'
|
||||
ItemSelectorElementController = require './item_selector_element_controller'
|
||||
_ = require 'underscore'
|
||||
{Duration} = require '../constants'
|
||||
{Event} = require '../constants'
|
||||
{Key} = require '../constants'
|
||||
|
||||
@@ -6,6 +6,7 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseController = require './base_controller'
|
||||
_ = require 'underscore'
|
||||
{Event} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -7,6 +7,7 @@ All rights reserved.
|
||||
|
||||
PageController = require './page_controller'
|
||||
User = require '../models/user'
|
||||
_ = require 'underscore'
|
||||
{CraftingGuideClient} = require 'crafting-guide-common'
|
||||
{Event} = require '../constants'
|
||||
{Login} = require '../constants'
|
||||
|
||||
@@ -6,6 +6,8 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseController = require './base_controller'
|
||||
_ = require 'underscore'
|
||||
{markdown} = require 'markdown'
|
||||
{Url} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
@@ -14,11 +16,13 @@ module.exports = class MarkdownSectionController extends BaseController
|
||||
|
||||
constructor: (options={})->
|
||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||
options.imageBase ?= ''
|
||||
options.model ?= ''
|
||||
options.title ?= 'Description'
|
||||
options.templateName = 'markdown_section'
|
||||
super options
|
||||
|
||||
@imageBase = options.imageBase
|
||||
@modPack = options.modPack
|
||||
@title = options.title
|
||||
|
||||
@@ -50,15 +54,17 @@ module.exports = class MarkdownSectionController extends BaseController
|
||||
tree = markdown.parse @model, 'Maruku'
|
||||
|
||||
findLinkRefs = (node)=>
|
||||
logger.verbose "inspecting a #{node[0]}"
|
||||
logger.verbose -> "inspecting a #{node[0]}"
|
||||
if node[0] is 'link_ref'
|
||||
logger.verbose "looking for item named: #{node[2]}"
|
||||
logger.verbose -> "looking for item named: #{node[2]}"
|
||||
item = @modPack.findItemByName node[2]
|
||||
if item?
|
||||
logger.verbose "found item #{item.slug}, updating link"
|
||||
logger.verbose -> "found item #{item.slug}, updating link"
|
||||
node[0] = 'link'
|
||||
node[1].href = Url.item itemSlug:item.slug.item, modSlug:item.slug.mod
|
||||
delete node[1].ref
|
||||
else if node[0] is 'img'
|
||||
node[1].href = "#{@imageBase}/#{node[1].href}"
|
||||
else
|
||||
for index in [1...node.length]
|
||||
if _.isArray node[index]
|
||||
|
||||
@@ -9,6 +9,7 @@ BaseController = require './base_controller'
|
||||
CraftingGridController = require './crafting_grid_controller'
|
||||
ImageLoader = require './image_loader'
|
||||
SlotController = require './slot_controller'
|
||||
_ = require 'underscore'
|
||||
{Duration} = require '../constants'
|
||||
{StringBuilder} = require 'crafting-guide-common'
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseController = require './base_controller'
|
||||
_ = require 'underscore'
|
||||
{Url} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -7,6 +7,7 @@ All rights reserved.
|
||||
|
||||
BaseController = require './base_controller'
|
||||
ModSelectorController = require './mod_selector_controller'
|
||||
_ = require 'underscore'
|
||||
{Duration} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -5,6 +5,7 @@ Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
$ = require 'jquery'
|
||||
AdsenseController = require './adsense_controller'
|
||||
Item = require '../models/item'
|
||||
ItemGroupController = require './item_group_controller'
|
||||
|
||||
@@ -5,9 +5,11 @@ Copyright (c) 2014-2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
$ = require 'jquery'
|
||||
BaseController = require './base_controller'
|
||||
{Event} = require '../constants'
|
||||
Mod = require '../models/mod'
|
||||
_ = require 'underscore'
|
||||
{Event} = require '../constants'
|
||||
{RequiredMods} = require '../constants'
|
||||
{Url} = require '../constants'
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
$ = require 'jquery'
|
||||
BaseController = require './base_controller'
|
||||
{Text} = require '../constants'
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseController = require './base_controller'
|
||||
_ = require 'underscore'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ All rights reserved.
|
||||
|
||||
BaseController = require './base_controller'
|
||||
ImageLoader = require './image_loader'
|
||||
_ = require 'underscore'
|
||||
{Duration} = require '../constants'
|
||||
{Event} = require '../constants'
|
||||
{Key} = require '../constants'
|
||||
|
||||
@@ -8,6 +8,7 @@ All rights reserved.
|
||||
BaseController = require './base_controller'
|
||||
InventoryController = require './inventory_controller'
|
||||
MinimalRecipeController = require './minimal_recipe_controller'
|
||||
_ = require 'underscore'
|
||||
{Event} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -6,6 +6,7 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseController = require './base_controller'
|
||||
_ = require 'underscore'
|
||||
{Url} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -98,6 +98,7 @@ module.exports = class TutorialPageController extends BaseController
|
||||
controller.model = section.model
|
||||
controller.refresh()
|
||||
|
||||
controller.imageBase = Url.tutorialImageDir modSlug:@modSlug, tutorialSlug:@tutorialSlug
|
||||
index += 1
|
||||
|
||||
while @_sectionControllers.length > index
|
||||
|
||||
@@ -5,6 +5,7 @@ Copyright (c) 2014-2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
$ = require 'jquery'
|
||||
BrowsePageController = require './controllers/browse_page_controller'
|
||||
ConfigurePageController = require './controllers/configure_page_controller'
|
||||
CraftPageController = require './controllers/craft_page_controller'
|
||||
@@ -17,20 +18,22 @@ LoginPageController = require './controllers/login_page_controller'
|
||||
Mod = require './models/mod'
|
||||
ModPack = require './models/mod_pack'
|
||||
ModPageController = require './controllers/mod_page_controller'
|
||||
TutorialPageController = require './controllers/tutorial_page_controller'
|
||||
Storage = require './models/storage'
|
||||
TutorialPageController = require './controllers/tutorial_page_controller'
|
||||
UrlParams = require './url_params'
|
||||
User = require './models/user'
|
||||
{ProductionEnvs} = require './constants'
|
||||
_ = require 'underscore'
|
||||
backbone = require 'backbone'
|
||||
{DefaultMods} = require './constants'
|
||||
{Duration} = require './constants'
|
||||
{Event} = require './constants'
|
||||
{Opacity} = require './constants'
|
||||
{ProductionEnvs} = require './constants'
|
||||
{Url} = require './constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
module.exports = class CraftingGuideRouter extends Backbone.Router
|
||||
module.exports = class CraftingGuideRouter extends backbone.Router
|
||||
|
||||
constructor: (options={})->
|
||||
@_page = null
|
||||
|
||||
@@ -5,7 +5,12 @@ Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
_.mixin require './underscore_mixins'
|
||||
_ = require 'underscore'
|
||||
mixins = require './underscore_mixins'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
_.mixin mixins
|
||||
|
||||
module.exports =
|
||||
Mod: require './models/mod'
|
||||
|
||||
+9
-13
@@ -5,11 +5,13 @@ Copyright (c) 2014-2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
require './underscore_mixins'
|
||||
require './polyfill'
|
||||
|
||||
$ = require 'jquery'
|
||||
CraftingGuideRouter = require './crafting_guide_router'
|
||||
FeedbackController = require './controllers/feedback_controller'
|
||||
_ = require './underscore_mixins'
|
||||
backbone = require 'backbone'
|
||||
views = require './views'
|
||||
{CraftingGuideClient} = require 'crafting-guide-common'
|
||||
{Logger} = require 'crafting-guide-common'
|
||||
@@ -38,27 +40,21 @@ switch window.location.hostname
|
||||
else
|
||||
throw new Error "cannot determine the environment of: #{window.location.hostname}"
|
||||
|
||||
client = _.extend new CraftingGuideClient(baseUrl:apiBaseUrl), Backbone.Events
|
||||
client = _.extend new CraftingGuideClient(baseUrl:apiBaseUrl), backbone.Events
|
||||
client.onStatusChanged = (c, oldStatus, newStatus)->
|
||||
logger.info "Crafting Guide server status changed from #{oldStatus} to #{newStatus}"
|
||||
client.trigger 'change:status', client, oldStatus, newStatus
|
||||
client.trigger 'change', client
|
||||
|
||||
# Disabled until required by some feature -- andrewminer 2015-04-06
|
||||
# client.checkStatus()
|
||||
|
||||
global.router = new CraftingGuideRouter client:client
|
||||
global.util = require 'util'
|
||||
global.views = views
|
||||
global.markdown = global.markdown.markdown
|
||||
backbone.$ = $
|
||||
|
||||
global.feedbackController = new FeedbackController el:'.view__feedback'
|
||||
feedbackController.render()
|
||||
|
||||
# Disabled until required by some feature. -- andrewminer 2015-04-06
|
||||
# global.router.loadCurrentUser()
|
||||
|
||||
global.router = new CraftingGuideRouter client:client
|
||||
global.router.loadCurrentUser()
|
||||
global.router.loadDefaultModPack()
|
||||
|
||||
backbone.history.start pushState:true
|
||||
client.checkStatus()
|
||||
logger.info -> "CraftingGuide is ready"
|
||||
Backbone.history.start pushState:true
|
||||
|
||||
@@ -5,12 +5,15 @@ Copyright (c) 2014-2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
$ = require 'jquery'
|
||||
backbone = require 'backbone'
|
||||
w = require 'when'
|
||||
{Event} = require '../constants'
|
||||
{ModelState} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
module.exports = class BaseModel extends Backbone.Model
|
||||
module.exports = class BaseModel extends backbone.Model
|
||||
|
||||
constructor: (attributes={}, options={})->
|
||||
options.logEvents ?= true
|
||||
@@ -70,7 +73,7 @@ module.exports = class BaseModel extends Backbone.Model
|
||||
success: (text, status, xhr)=> resolve @onLoadSucceeded text, status, xhr
|
||||
error: (xhr, status, error)=> reject @onLoadFailed error, status, xhr
|
||||
|
||||
@loading.catch -> # do nothing. prevents unhandled promise warnings
|
||||
@loading.catch (e)-> # do nothing
|
||||
return @loading
|
||||
|
||||
parse: (text)->
|
||||
|
||||
@@ -9,6 +9,7 @@ BaseModel = require './base_model'
|
||||
Inventory = require './inventory'
|
||||
ItemSlug = require './item_slug'
|
||||
Step = require './step'
|
||||
_ = require 'underscore'
|
||||
{Event} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -5,6 +5,8 @@ Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
require 'underscore'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
module.exports = class EmailClient
|
||||
|
||||
@@ -6,10 +6,11 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseModel = require './base_model'
|
||||
{Event} = require '../constants'
|
||||
ItemSlug = require './item_slug'
|
||||
{RequiredMods} = require '../constants'
|
||||
Stack = require './stack'
|
||||
_ = require 'underscore'
|
||||
{Event} = require '../constants'
|
||||
{RequiredMods} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ All rights reserved.
|
||||
|
||||
BaseModel = require './base_model'
|
||||
CraftingPlan = require './crafting_plan'
|
||||
_ = require 'underscore'
|
||||
{Event} = require '../constants'
|
||||
{Url} = require '../constants'
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ All rights reserved.
|
||||
|
||||
BaseModel = require './base_model'
|
||||
ItemSlug = require './item_slug'
|
||||
_ = require 'underscore'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
_ = require 'underscore'
|
||||
{RequiredMods} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -6,6 +6,7 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseModel = require './base_model'
|
||||
_ = require 'underscore'
|
||||
{Event} = require '../constants'
|
||||
{RequiredMods} = require '../constants'
|
||||
{Url} = require '../constants'
|
||||
|
||||
@@ -6,10 +6,11 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseModel = require './base_model'
|
||||
{Event} = require '../constants'
|
||||
Item = require './item'
|
||||
ItemSlug = require './item_slug'
|
||||
Recipe = require './recipe'
|
||||
_ = require 'underscore'
|
||||
{Event} = require '../constants'
|
||||
{RequiredMods} = require '../constants'
|
||||
{Url} = require '../constants'
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
_ = require 'underscore'
|
||||
{StringBuilder} = require 'crafting-guide-common'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -11,6 +11,7 @@ ItemSlug = require '../item_slug'
|
||||
ModVersion = require '../mod_version'
|
||||
Recipe = require '../recipe'
|
||||
Stack = require '../simple_stack'
|
||||
_ = require 'underscore'
|
||||
{StringBuilder} = require 'crafting-guide-common'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -7,6 +7,7 @@ All rights reserved.
|
||||
|
||||
BaseModel = require './base_model'
|
||||
TutorialParser = require './tutorial_parser'
|
||||
_ = require 'underscore'
|
||||
{Url} = require '../constants'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -5,6 +5,8 @@ Copyright (c) 2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
_ = require 'underscore'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
module.exports = class VersionedParserBase
|
||||
|
||||
@@ -5,8 +5,14 @@ Copyright (c) 2014-2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
_.mixin
|
||||
_ = require 'underscore'
|
||||
{stringMixins} = require 'crafting-guide-common'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
module.exports = _
|
||||
|
||||
_.mixin
|
||||
parseMarkdown: (text)->
|
||||
return markdown.parse text, 'Maruku'
|
||||
|
||||
@@ -32,4 +38,4 @@ _.mixin
|
||||
|
||||
return parts
|
||||
|
||||
_.mixin require('crafting-guide-common').stringMixins
|
||||
_.mixin stringMixins
|
||||
|
||||
@@ -5,6 +5,7 @@ Copyright (c) 2014-2015 by Redwood Labs
|
||||
All rights reserved.
|
||||
###
|
||||
|
||||
_ = require 'underscore'
|
||||
url = require 'url'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
@@ -5,10 +5,4 @@
|
||||
//- All rights reserved.
|
||||
//-
|
||||
|
||||
script(src="/js/underscore.js")
|
||||
script(src="/js/jquery.js")
|
||||
script(src="/js/backbone.js")
|
||||
script(src="/js/jade.js")
|
||||
script(src="/js/markdown.js")
|
||||
script(src="/js/when.js")
|
||||
script(src="/js/main.js")
|
||||
|
||||
@@ -57,8 +57,6 @@ All rights reserved.
|
||||
position: absolute; bottom: 5em; height: 3.2em; width: 100%;
|
||||
|
||||
.login {
|
||||
display: none; // Temporarily disable until there's a feature which needs it
|
||||
|
||||
position: absolute; top: 50%; right: 2em;
|
||||
@include transform(translateY(-50%));
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ CommandParserVersionBase = require '../../src/coffee/models/parser_versions/comm
|
||||
ItemSlug = require '../../src/coffee/models/item_slug'
|
||||
ModVersion = require '../../src/coffee/models/mod_version'
|
||||
ModVersionParserV1 = require '../../src/coffee/models/parser_versions/mod_version_parser_v1'
|
||||
_ = require 'underscore'
|
||||
{Logger} = require 'crafting-guide-common'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
Reference in New Issue
Block a user