diff --git a/classes/comment.js b/classes/comment.js index 61fb70e..d794ba9 100644 --- a/classes/comment.js +++ b/classes/comment.js @@ -1,45 +1,46 @@ - class Comment { - constructor (data = {}) { - this.applyData(data) - } + constructor(data = {}) { + this.applyData(data) + } - applyData (data) { - this.mdBody = data.body - this.htmlBody = window.markdown.toHTML(data.body) - this.title = this.mdBody.match(/^[\*_][\*_]\[(.+)\].+[\*_][\*_][\n\r]/) - this.title = this.title ? this.title[1] : '' - this.link = this.mdBody.match(/^[\*_][\*_].+\((.+)\)[\*_][\*_][\n\r]/) - this.link = this.link ? this.link[1] : '' - this.outline = `${this.title}:
${this.link}
` - this.created_at = data.created_at - this.id = data.id - this.url = data.url - this.author = { - id: data.user.id, - login: data.user.login, - avatar: data.user.avatar_url, - url: data.user.html_url - } - this.applyCategory() + applyData(data) { + this.mdBody = data.body + this.htmlBody = window.markdown.toHTML(data.body) + this.title = this.mdBody.match(/^[\*_][\*_]\[(.+)\].+[\*_][\*_][\n\r]/) + this.title = this.title ? this.title[1] : '' + this.link = this.mdBody.match(/^[\*_][\*_].+\((.+)\)[\*_][\*_][\n\r]/) + this.link = this.link ? this.link[1] : '' + this.outline = `${this.title}:
${this.link}
` + this.created_at = data.created_at + this.id = data.id + this.url = data.url + this.author = { + id: data.user.id, + login: data.user.login, + avatar: data.user.avatar_url, + url: data.user.html_url } + this.applyCategory() + } - applyCategory () { - let cat = this.mdBody.match(/[\n\r][\*_](.+)[\*_]$/m) - cat = cat ? cat[1] : 'Outros' - let testCat = cat.toLowerCase() + applyCategory() { + let cat = this.mdBody.match(/[\n\r][\*_](.+)[\*_]$/m) + let testCat = cat[1].toLowerCase() - if (testCat.match(/(new|not.cia|novidade|an.nci|announc)/)) { - cat = "Notícias" - } else if (testCat.match(/(event|confer.ncia|summit|workshop|congresso)/)) { - cat = "Eventos" - } else if (testCat.match(/(artigo|article|text|post)/)) { - cat = "Artigos" - } else if (testCat.match(/(talk|palestr|aula|curso|v.deo)/)) { - cat = "Vídeos" - } else if (testCat.match(/(tool|demo|experiment|ferrament)/)) { - cat = "Demos e Ferramentas" - } - this.category = cat + if (testCat.match(/(new|not.cia|novidade|an.nci|announc)/)) { + cat = 'Notícias' + } else if (testCat.match(/(event|confer.ncia|summit|workshop|congresso)/)) { + cat = 'Eventos' + } else if (testCat.match(/(artigo|article|text|post)/)) { + cat = 'Artigos' + } else if (testCat.match(/(talk|palestr|aula|curso|v.deo)/)) { + cat = 'Vídeos' + } else if (testCat.match(/(tool|demo|experiment|ferrament)/)) { + cat = 'Demos e Ferramentas' + } else { + cat = 'Outros' } + + this.category = cat + } } diff --git a/classes/github.js b/classes/github.js index 2327ade..852fa79 100644 --- a/classes/github.js +++ b/classes/github.js @@ -38,4 +38,3 @@ class Github { }) } } - diff --git a/classes/markdown.js b/classes/markdown.js index 1815060..27d0e93 100644 --- a/classes/markdown.js +++ b/classes/markdown.js @@ -1,33 +1,33 @@ window.markdown = { - toHTML (str) { - str = markdown.applyLinks(str) - str = markdown.applyBold(str) - str = markdown.applyItalic(str) - str = markdown.applyNewLines(str) - return str - }, - applyNewLines (str) { - return str.trim().replace(/(\n\r?)|(\)/g, '  
') - }, - applyBold (str) { - const boldRX = /[\*_][\*_](.+)[\*_][\*_]/ - while(link = str.match(boldRX)) { - str = str.replace(boldRX, '$1') - } - return str - }, - applyItalic (str) { - const italicRX = /[\*_](.+)[\*_]/ - while(link = str.match(italicRX)) { - str = str.replace(italicRX, '$1') - } - return str - }, - applyLinks (str) { - const linkRX = /\[([^\]]+)\]\(([^\)]+)\)/ - while(link = str.match(linkRX)) { - str = str.replace(linkRX, '$1') - } - return str + toHTML(str) { + str = markdown.applyLinks(str) + str = markdown.applyBold(str) + str = markdown.applyItalic(str) + str = markdown.applyNewLines(str) + return str + }, + applyNewLines(str) { + return str.trim().replace(/(\n\r?)|(\)/g, '  
') + }, + applyBold(str) { + const boldRX = /[\*_][\*_](.+)[\*_][\*_]/ + while ((link = str.match(boldRX))) { + str = str.replace(boldRX, '$1') } -} \ No newline at end of file + return str + }, + applyItalic(str) { + const italicRX = /[\*_](.+)[\*_]/ + while ((link = str.match(italicRX))) { + str = str.replace(italicRX, '$1') + } + return str + }, + applyLinks(str) { + const linkRX = /\[([^\]]+)\]\(([^\)]+)\)/ + while ((link = str.match(linkRX))) { + str = str.replace(linkRX, '$1') + } + return str + } +} diff --git a/classes/ui.js b/classes/ui.js index c3e7f21..6f23c67 100644 --- a/classes/ui.js +++ b/classes/ui.js @@ -1,53 +1,54 @@ -const style = "mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #2BAADF;font-weight: normal;text-decoration: underline;" +const style = + 'mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #2BAADF;font-weight: normal;text-decoration: underline;' const UI = { - currentIssue: null, - currentWeekly: null, - main: document.getElementById('container'), - HTML: { - main: document.getElementById('html-container'), - title: document.getElementById('TAG_title'), - contributors: document.getElementById('TAG_CONTRIBUTORS'), - news: document.getElementById('TAG_NEWS_LIST'), - categories: document.getElementById('TAG_CATEGORIES'), - }, - - update (weekly, type = 'html') { - if (typeof weekly === 'string' && UI.currentWeekly) { - type = weekly - weekly = UI.currentWeekly - } - UI.applyHeader(weekly, type) - UI.HTML.news.innerHTML = 'Tags: ' + UI.applyCategory(weekly, 'Notícias', type).join(' - ') - //UI.applyCartoon(weekly, type) - - $(".comment-item").sortable({ - handle: ".drag-handler", - placeholder: "placeholder" - }) - $(".category-item").disableSelection(); - $(".delete-handler").click(event => { - if (window.confirm('Are you sure you want to remove this item?')) { - let target = event.target.parentNode - target.parentNode.removeChild(target) - } - }) - new Clipboard('.copy-btn') - UI.currentWeekly = weekly - }, - applyHeader (weekly) { - UI.HTML.title.innerHTML = `${weekly.title}` - UI.HTML.contributors.innerHTML = ` + currentIssue: null, + currentWeekly: null, + main: document.getElementById('container'), + HTML: { + main: document.getElementById('html-container'), + title: document.getElementById('TAG_title'), + contributors: document.getElementById('TAG_CONTRIBUTORS'), + news: document.getElementById('TAG_NEWS_LIST'), + categories: document.getElementById('TAG_CATEGORIES') + }, + + update(weekly, type = 'html') { + if (typeof weekly === 'string' && UI.currentWeekly) { + type = weekly + weekly = UI.currentWeekly + } + UI.applyHeader(weekly, type) + UI.HTML.news.innerHTML = 'Tags: ' + UI.applyCategory(weekly, 'Notícias', type).join(' - ') + //UI.applyCartoon(weekly, type) + + $('.comment-item').sortable({ + handle: '.drag-handler', + placeholder: 'placeholder' + }) + $('.category-item').disableSelection() + $('.delete-handler').click(event => { + if (window.confirm('Are you sure you want to remove this item?')) { + let target = event.target.parentNode + target.parentNode.removeChild(target) + } + }) + new Clipboard('.copy-btn') + UI.currentWeekly = weekly + }, + applyHeader(weekly) { + UI.HTML.title.innerHTML = `${weekly.title}` + UI.HTML.contributors.innerHTML = ` Um agradecimento especial aos ${Object.keys(weekly.contributors).length} colaboradores da edição nº ${weekly.edition}!

- ${ - Object.keys(weekly.contributors).map(key => { - let contrib = weekly.contributors[key] - return ` + ${Object.keys(weekly.contributors) + .map(key => { + let contrib = weekly.contributors[key] + return ` ${contrib.login}  ` - }).join(' ') - } + }) + .join(' ')} ` - }, - applyCategory (weekly, filterName, type) { - let outputStr = '' - - const categoriesName = Object.keys(weekly.categories).sort() - const notNews = categoriesName.filter( item => item !== filterName) - const onlyNews = categoriesName.filter( item => item === filterName) - - onlyNews.forEach( item => { - outputStr += UI.applyDesignCategory(weekly, item, type) - }) - - notNews.forEach( item => { - outputStr += UI.applyDesignCategory(weekly, item, type) - }) - - UI.HTML.categories.innerHTML = outputStr - return categoriesName - }, - applyDesignCategory (weekly, cat, type) { - let categoryHTML = ` + }, + applyCategory(weekly, filterName, type) { + let outputStr = '' + + const categoriesName = Object.keys(weekly.categories).sort() + const notNews = categoriesName.filter(item => item !== filterName) + const onlyNews = categoriesName.filter(item => item === filterName) + + onlyNews.forEach(item => { + outputStr += UI.applyDesignCategory(weekly, item, type) + }) + + notNews.forEach(item => { + outputStr += UI.applyDesignCategory(weekly, item, type) + }) + + UI.HTML.categories.innerHTML = outputStr + return categoriesName + }, + applyDesignCategory(weekly, cat, type) { + let categoryHTML = `