Update article model

This commit is contained in:
Alexei Nikitin 2014-03-08 05:05:35 +04:00
parent b6ae73ef29
commit 98b36d299c
3 changed files with 4 additions and 2 deletions

View file

@ -25,7 +25,8 @@ module.exports = class DocsModal extends View
@docs = specific.concat(general)
marked.setOptions {gfm: true, sanitize: false, smartLists: true, breaks: false}
@docs = _.cloneDeep(@docs)
doc.html = marked(doc.body) for doc in @docs
doc.html = marked(doc.i18n?[me.lang()]?.body or doc.body) for doc in @docs
doc.name = (doc.i18n?[me.lang()]?.name or doc.name) for doc in @docs
doc.slug = _.string.slugify(doc.name) for doc in @docs
super()

View file

@ -3,7 +3,7 @@ Handler = require('../commons/Handler')
ArticleHandler = class ArticleHandler extends Handler
modelClass: Article
editableProperties: ['body', 'name']
editableProperties: ['body', 'name', 'i18n']
hasAccess: (req) ->
req.method is 'GET' or req.user?.isAdmin()

View file

@ -4,6 +4,7 @@ ArticleSchema = c.object()
c.extendNamedProperties ArticleSchema # name first
ArticleSchema.properties.body = { type: 'string', title: 'Content', format: 'markdown' }
ArticleSchema.properties.i18n = { type: 'object', title: 'i18n', format: 'i18n', props: ['body'] }
c.extendBasicProperties(ArticleSchema, 'article')
c.extendSearchableProperties(ArticleSchema)