(options, name)
| 30 | } |
| 31 | |
| 32 | initialize (options, name) { |
| 33 | this.name = name |
| 34 | super.initialize(options) |
| 35 | if (this.name == null) { this.name = 'index' } |
| 36 | this.content = '' |
| 37 | this.loadingData = true |
| 38 | __guard__(me.getClientCreatorPermissions(), x => x.then(() => (typeof this.render === 'function' ? this.render() : undefined))) |
| 39 | if (!this.cannotAccess()) { |
| 40 | let promise |
| 41 | if (_.string.startsWith(this.name, 'markdown/')) { |
| 42 | if (!_.string.endsWith(this.name, '.md')) { |
| 43 | this.name = this.name + '.md' |
| 44 | } |
| 45 | promise = api.markdown.getMarkdownFile(this.name.replace('markdown/', '')) |
| 46 | } else { |
| 47 | promise = api.apcsp.getAPCSPFile(this.name) |
| 48 | } |
| 49 | |
| 50 | return promise.then(data => { |
| 51 | this.content = marked(data, { sanitize: false }) |
| 52 | this.loadingData = false |
| 53 | return this.render() |
| 54 | }).catch(error => { |
| 55 | this.loadingData = false |
| 56 | if (error.code === 404) { |
| 57 | this.notFound = true |
| 58 | return this.render() |
| 59 | } else { |
| 60 | console.error(error) |
| 61 | this.error = error.message |
| 62 | return this.render() |
| 63 | } |
| 64 | }) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | cannotAccess () { |
| 69 | return false // me.isAnonymous() or !me.isTeacher() or !me.get('verifiedTeacher') |
nothing calls this directly
no test coverage detected