Giter Site home page Giter Site logo

blog-test's Introduction

个人博客系统 V1.0.0

文件目录

blog-test/
|
+- controllers/ <-- Controller
|
+- views/ <-- html文件
|
+- static/ <-- bootstrap
|
+- controller.js <-- 挂到router的方法
|
+- app.js <-- main
|
+- static-files.js <-- 读取静态资源文件
|
+- templating.js <-- 整合Nunjucks
|
+- package.json
|
+- node_modules/
|
+- sess/ <-- 存放本地cookie
|
+- session-store <-- 对于koa-session存放的测试
|
+- users.js <-- 存放对用户操作的方法
|
+- users.json <-- 存放用户数据

删除文章的操作难点:

不太明白怎么将链接的 herf 指定到本网页的下一级 /articles/:title/delete

解法: nunjucks字符串拼接,此处应该认真学习nunjucks的文档

<a href="{{ "/articles/" + article.title + "/delete" }}">删除</a>

覆盖 Bootstrap 样式,目前唯一解法 -> 内联写样式:

<div class="jumbotron" style="background:orange;"></div>

表单内的提交按钮可以如下操作

<button type="submit" class="btn btn-primary btn-lg">
    登陆
</button>

表单外的按钮,使用a标签

<a class="btn btn-primary btn-lg" href="/" role="button">返回</a>

koa-session相关

1

2

清除session只用 ctx.session = null 无效,需要在fn_signin内使用

JSON.stringify(ctx.session) !== '{}'

判断JS对象是否为空的几个方法

1234

使用了mz,并通过require('mz/fs');导入。mz提供的API和Node.js的fs模块完全相同,但fs模块使用回调,而mz封装了fs对应的函数,并改为Promise。这样,我们就可以非常简单的用await调用mz的函数,而不需要任何回调。

用到的库:

koa(中文网 koa-bodyparser koa-session path fs mz/fs mime的npm文档 使用mime nunjucks(中文

blog-test's People

Contributors

aaronkwong929 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.