Initial version of mod detail pages
This commit is contained in:
@@ -19,7 +19,7 @@ module.exports = class Mod extends BaseModel
|
||||
attributes.author ?= ''
|
||||
attributes.description ?= ''
|
||||
attributes.name ?= ''
|
||||
attributes.primaryUrl ?= null
|
||||
attributes.homePageUrl ?= null
|
||||
super attributes, options
|
||||
|
||||
@_activeModVersion = null
|
||||
@@ -62,9 +62,18 @@ module.exports = class Mod extends BaseModel
|
||||
return unless @_activeModVersion?
|
||||
@_activeModVersion.eachName callback
|
||||
|
||||
findItem: (slug)->
|
||||
return unless @_activeModVersion?
|
||||
@_activeModVersion.findItem slug
|
||||
findItem: (slug, options={})->
|
||||
options.includeDisabled ?= false
|
||||
|
||||
if not options.includeDisabled
|
||||
return unless @_activeModVersion?
|
||||
return @_activeModVersion.findItem slug
|
||||
else
|
||||
for modVersion in @_modVersions
|
||||
item = modVersion.findItem slug
|
||||
return item if item?
|
||||
|
||||
return null
|
||||
|
||||
findItemByName: (name)->
|
||||
return unless @_activeModVersion?
|
||||
@@ -100,6 +109,14 @@ module.exports = class Mod extends BaseModel
|
||||
for modVersion in @_modVersions
|
||||
callback modVersion
|
||||
|
||||
getModVersion: (version)->
|
||||
return null if version is Mod.Version.None
|
||||
return @_modVersions[@_modVersions.length-1] if version is Mod.Version.Latest
|
||||
|
||||
for modVersion in @_modVersions
|
||||
return modVersion if modVersion.version is version
|
||||
return null
|
||||
|
||||
getActiveVersion: ->
|
||||
return @_activeVersion
|
||||
|
||||
|
||||
@@ -22,10 +22,12 @@ module.exports = class ModPack extends BaseModel
|
||||
|
||||
# Public Methods ###############################################################################
|
||||
|
||||
findItem: (slug)->
|
||||
findItem: (slug, options={})->
|
||||
options.includeDisabled ?= false
|
||||
|
||||
for mod in @_mods
|
||||
continue unless mod.enabled
|
||||
item = mod.findItem slug
|
||||
continue unless mod.enabled or options.includeDisabled
|
||||
item = mod.findItem slug, options
|
||||
return item if item?
|
||||
|
||||
return null
|
||||
@@ -42,7 +44,7 @@ module.exports = class ModPack extends BaseModel
|
||||
|
||||
findItemDisplay: (slug)->
|
||||
result = {}
|
||||
item = @findItem slug
|
||||
item = @findItem slug, includeDisabled:true
|
||||
if item?
|
||||
result.modSlug = item.modVersion.modSlug
|
||||
result.modVersion = item.modVersion.version
|
||||
|
||||
@@ -42,11 +42,11 @@ module.exports = class ModParserV2 extends CommandParserVersionBase
|
||||
if name.length is 0 then throw new Error '"name" cannot be empty'
|
||||
@_rawData.name = name
|
||||
|
||||
_command_url: (url='')->
|
||||
if @_rawData.url? then throw new Error 'duplicate declaration of "url"'
|
||||
if url.length is 0 then throw new Error 'url cannot be empty'
|
||||
_command_homePageUrl: (homePageUrl='')->
|
||||
if @_rawData.homePageUrl? then throw new Error 'duplicate declaration of "homePageUrl"'
|
||||
if homePageUrl.length is 0 then throw new Error 'homePageUrl cannot be empty'
|
||||
|
||||
@_rawData.url = url
|
||||
@_rawData.homePageUrl = homePageUrl
|
||||
|
||||
_command_version: (version='')->
|
||||
if version.length is 0 then throw new Error 'version cannot be empty'
|
||||
@@ -58,13 +58,13 @@ module.exports = class ModParserV2 extends CommandParserVersionBase
|
||||
|
||||
_buildMod: (rawData, model)->
|
||||
if not rawData.name? then throw new Error 'the "name" declaration is required'
|
||||
if not rawData.url? then throw new Error 'the "url" declaration is required'
|
||||
if not rawData.homePageUrl? then throw new Error 'the "homePageUrl" declaration is required'
|
||||
if not rawData.versions? then throw new Error 'at least one "version" declaration is required'
|
||||
|
||||
model.author = rawData.author if rawData.author?
|
||||
model.description = rawData.description if rawData.description?
|
||||
model.name = rawData.name
|
||||
model.primaryUrl = rawData.url
|
||||
model.homePageUrl = rawData.homePageUrl
|
||||
|
||||
for version in rawData.versions
|
||||
model.addModVersion new ModVersion modSlug:model.slug, version:version
|
||||
|
||||
Reference in New Issue
Block a user