Skip to content
Permalink
Browse files
fix routing error
  • Loading branch information
sarkarj committed Dec 2, 2019
1 parent 55fbb47 commit f0e0cd1dbd46a29a11559bff9c49fe0b1609083e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
@@ -71,7 +71,7 @@ router.get('/edit/:id', async ctx => {

router.post('/edit', koaBody, async ctx => await editPost(ctx, dbName))

router.get('/categories/:tag', async ctx => await categoriesTagGet(ctx, dbName))
router.get('/:tag', async ctx => await categoriesTagGet(ctx, dbName))

/**
* The user registration page.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -1,25 +1,15 @@
'use strict'

const Article = require('../modules/article')
const ifs = require('../modules/imagefs')
const Image = require('../modules/image')

const categoriesTagGet = async(ctx, dbName) => {
try {
const body = ctx.request.body
const id = body.id
console.log(id)
console.log(body)
const tag = ctx.params.tag
const article = await new Article(dbName)
await article.reupload(id, body.title, body.summary, body.content, body.tag)
const {path, type} = ctx.request.files.image
const image = await new Image(dbName)
await ifs.deletePicture(`public/articleImages/${id}.png`)
await ifs.uploadPicture(path, type, `${id}`, 'public/articleImages/' )
await image.replace(`public/articleImages/${id}.png`)
ctx.redirect(`/?msg=new "${body.title}" uploaded`)
const data = await article.getByTag(tag)
await ctx.render('homepage', {articles: data})
} catch(err) {
await ctx.render('error', {message: err.message})
ctx.body = err.message
}
}

@@ -11,7 +11,6 @@
<body>
<nav class="hotbar">
<a href="/">HOME</a>
<a href="/upload">UPLOAD NEWS</a>

<a href="/logout" class="right">Logout</a>
<a href="/login" class="right">Login</a>
@@ -40,10 +39,6 @@
{{#if account.location}}
<h2> Location: {{account.location}}</h2>
{{else}}
<form id = "account" class = "input-group" enctype="multipart/form-data" action = "/account" method = "post"></form>
<input name = "location" type = "text" class = "input-field" placeholder = "Location">
<button name = "submit" type = "submit" class = "submit-btn" value = "">Confirm details</button>
</form>
{{/if}}
</article>
{{/if}}

0 comments on commit f0e0cd1

Please sign in to comment.