Add documentation & download links to mod page
This commit is contained in:
@@ -42,14 +42,15 @@ module.exports = class ModPageController extends BaseController
|
||||
# BaseController Overrides #####################################################################
|
||||
|
||||
onDidRender: ->
|
||||
@$name = @$('.name')
|
||||
@$byline = @$('.byline p')
|
||||
@$description = @$('.description p')
|
||||
@$homePageLink = @$('.homePage')
|
||||
@$items = @$('.items .panel')
|
||||
@$titleImage = @$('.titleImage img')
|
||||
@$versionSelector = @$('select.version')
|
||||
@$wikiLink = @$('.wiki')
|
||||
@$name = @$('.name')
|
||||
@$byline = @$('.byline p')
|
||||
@$description = @$('.description p')
|
||||
@$documentationLink = @$('.documentation')
|
||||
@$downloadLink = @$('.download')
|
||||
@$homePageLink = @$('.homePage')
|
||||
@$items = @$('.items .panel')
|
||||
@$titleImage = @$('.titleImage img')
|
||||
@$versionSelector = @$('select.version')
|
||||
|
||||
super
|
||||
|
||||
@@ -59,7 +60,10 @@ module.exports = class ModPageController extends BaseController
|
||||
@$titleImage.attr 'src', (if @model? then Url.modLogoImage(modSlug:@model.slug) else '')
|
||||
@$description.html if @model? then @model.description else ''
|
||||
|
||||
@_refreshHomePageLink()
|
||||
@_refreshLink @$homePageLink, @model.homePageUrl
|
||||
@_refreshLink @$documentationLink, @model.documentationUrl
|
||||
@_refreshLink @$downloadLink, @model.downloadUrl
|
||||
|
||||
@_refreshItems()
|
||||
@_refreshVersions()
|
||||
super
|
||||
@@ -90,12 +94,12 @@ module.exports = class ModPageController extends BaseController
|
||||
|
||||
return modVersion
|
||||
|
||||
_refreshHomePageLink: ->
|
||||
if @model.homePageUrl?
|
||||
@$homePageLink.fadeIn duration:Duration.fast
|
||||
@$homePageLink.attr 'href', @model.homePageUrl
|
||||
_refreshLink: ($link, url)->
|
||||
if url?
|
||||
$link.fadeIn duration:Duration.fast
|
||||
$link.attr 'href', url
|
||||
else
|
||||
@$homePageLink.fadeOut duration:Duration.fast
|
||||
$link.fadeOut duration:Duration.fast
|
||||
|
||||
_refreshItems: ->
|
||||
controllerIndex = 0
|
||||
|
||||
@@ -16,10 +16,12 @@ module.exports = class Mod extends BaseModel
|
||||
|
||||
constructor: (attributes={}, options={})->
|
||||
if not attributes.slug? then throw new Error 'attributes.slug is required'
|
||||
attributes.author ?= ''
|
||||
attributes.description ?= ''
|
||||
attributes.name ?= ''
|
||||
attributes.homePageUrl ?= null
|
||||
attributes.author ?= ''
|
||||
attributes.description ?= ''
|
||||
attributes.documentationUrl ?= null
|
||||
attributes.downloadUrl ?= null
|
||||
attributes.homePageUrl ?= null
|
||||
attributes.name ?= ''
|
||||
super attributes, options
|
||||
|
||||
@_activeModVersion = null
|
||||
|
||||
@@ -37,6 +37,16 @@ module.exports = class ModParserV2 extends CommandParserVersionBase
|
||||
|
||||
@_rawData.description = description
|
||||
|
||||
_command_documentationUrl: (documentationUrl)->
|
||||
if @_rawData.documentationUrl? then throw new Error 'duplicate declaration of "documentationUrl"'
|
||||
if documentationUrl.length is 0 then throw new Error 'documentationUrl cannot be empty (omit it instead)'
|
||||
@_rawData.documentationUrl = documentationUrl
|
||||
|
||||
_command_downloadUrl: (downloadUrl)->
|
||||
if @_rawData.downloadUrl? then throw new Error 'duplicate declaration of "downloadUrl"'
|
||||
if downloadUrl.length is 0 then throw new Error 'downloadUrl cannot be empty (omit it instead)'
|
||||
@_rawData.downloadUrl = downloadUrl
|
||||
|
||||
_command_name: (name)->
|
||||
if @_rawData.name? then throw new Error 'duplicate declaration of "name"'
|
||||
if name.length is 0 then throw new Error '"name" cannot be empty'
|
||||
@@ -61,10 +71,12 @@ module.exports = class ModParserV2 extends CommandParserVersionBase
|
||||
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.homePageUrl = rawData.homePageUrl
|
||||
model.author = rawData.author if rawData.author?
|
||||
model.description = rawData.description if rawData.description?
|
||||
model.documentationUrl = rawData.documentationUrl if rawData.documentationUrl?
|
||||
model.downloadUrl = rawData.downloadUrl if rawData.downloadUrl?
|
||||
model.name = rawData.name
|
||||
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