mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-12 22:26:08 -04:00
Linter: Fix all lint errors
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
b0a45bdf9c
commit
136d895d15
51 changed files with 2245 additions and 1539 deletions
|
@ -1,28 +1,28 @@
|
|||
'use strict'
|
||||
// response
|
||||
// external modules
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var request = require('request')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const request = require('request')
|
||||
// core
|
||||
var config = require('./config')
|
||||
var logger = require('./logger')
|
||||
var models = require('./models')
|
||||
const config = require('./config')
|
||||
const logger = require('./logger')
|
||||
const models = require('./models')
|
||||
const noteUtil = require('./web/note/util')
|
||||
const errors = require('./errors')
|
||||
|
||||
// public
|
||||
var response = {
|
||||
const response = {
|
||||
showIndex: showIndex,
|
||||
githubActions: githubActions,
|
||||
gitlabActions: gitlabActions
|
||||
}
|
||||
|
||||
function showIndex (req, res, next) {
|
||||
var authStatus = req.isAuthenticated()
|
||||
var deleteToken = ''
|
||||
const authStatus = req.isAuthenticated()
|
||||
const deleteToken = ''
|
||||
|
||||
var data = {
|
||||
const data = {
|
||||
signin: authStatus,
|
||||
infoMessage: req.flash('info'),
|
||||
errorMessage: req.flash('error'),
|
||||
|
@ -49,9 +49,9 @@ function showIndex (req, res, next) {
|
|||
}
|
||||
|
||||
function githubActions (req, res, next) {
|
||||
var noteId = req.params.noteId
|
||||
const noteId = req.params.noteId
|
||||
noteUtil.findNote(req, res, function (note) {
|
||||
var action = req.params.action
|
||||
const action = req.params.action
|
||||
switch (action) {
|
||||
case 'gist':
|
||||
githubActionGist(req, res, note)
|
||||
|
@ -64,41 +64,41 @@ function githubActions (req, res, next) {
|
|||
}
|
||||
|
||||
function githubActionGist (req, res, note) {
|
||||
var code = req.query.code
|
||||
var state = req.query.state
|
||||
const code = req.query.code
|
||||
const state = req.query.state
|
||||
if (!code || !state) {
|
||||
return errors.errorForbidden(res)
|
||||
} else {
|
||||
var data = {
|
||||
const data = {
|
||||
client_id: config.github.clientID,
|
||||
client_secret: config.github.clientSecret,
|
||||
code: code,
|
||||
state: state
|
||||
}
|
||||
var authUrl = 'https://github.com/login/oauth/access_token'
|
||||
const authUrl = 'https://github.com/login/oauth/access_token'
|
||||
request({
|
||||
url: authUrl,
|
||||
method: 'POST',
|
||||
json: data
|
||||
}, function (error, httpResponse, body) {
|
||||
if (!error && httpResponse.statusCode === 200) {
|
||||
var accessToken = body.access_token
|
||||
const accessToken = body.access_token
|
||||
if (accessToken) {
|
||||
var content = note.content
|
||||
var title = models.Note.decodeTitle(note.title)
|
||||
var filename = title.replace('/', ' ') + '.md'
|
||||
var gist = {
|
||||
'files': {}
|
||||
const content = note.content
|
||||
const title = models.Note.decodeTitle(note.title)
|
||||
const filename = title.replace('/', ' ') + '.md'
|
||||
const gist = {
|
||||
files: {}
|
||||
}
|
||||
gist.files[filename] = {
|
||||
'content': content
|
||||
content: content
|
||||
}
|
||||
var gistUrl = 'https://api.github.com/gists'
|
||||
const gistUrl = 'https://api.github.com/gists'
|
||||
request({
|
||||
url: gistUrl,
|
||||
headers: {
|
||||
'User-Agent': 'HedgeDoc',
|
||||
'Authorization': 'token ' + accessToken
|
||||
Authorization: 'token ' + accessToken
|
||||
},
|
||||
method: 'POST',
|
||||
json: gist
|
||||
|
@ -121,9 +121,9 @@ function githubActionGist (req, res, note) {
|
|||
}
|
||||
|
||||
function gitlabActions (req, res, next) {
|
||||
var noteId = req.params.noteId
|
||||
const noteId = req.params.noteId
|
||||
noteUtil.findNote(req, res, function (note) {
|
||||
var action = req.params.action
|
||||
const action = req.params.action
|
||||
switch (action) {
|
||||
case 'projects':
|
||||
gitlabActionProjects(req, res, note)
|
||||
|
@ -143,7 +143,7 @@ function gitlabActionProjects (req, res, note) {
|
|||
}
|
||||
}).then(function (user) {
|
||||
if (!user) { return errors.errorNotFound(res) }
|
||||
var ret = { baseURL: config.gitlab.baseURL, version: config.gitlab.version }
|
||||
const ret = { baseURL: config.gitlab.baseURL, version: config.gitlab.version }
|
||||
ret.accesstoken = user.accessToken
|
||||
ret.profileid = user.profileid
|
||||
request(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue