Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
张杰 committed Jul 4, 2016
0 parents commit 8bd8b97
Show file tree
Hide file tree
Showing 97 changed files with 6,172 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# nodejs-hexo
hexo站点
71 changes: 71 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: Hexo
subtitle:
description:
author: John Doe
language:
timezone:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
enable: true
line_number: true
auto_detect: false
tab_replace:

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: landscape

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type:
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"hexo": {
"version": "3.2.2"
},
"dependencies": {
"hexo": "^3.2.0",
"hexo-generator-archive": "^0.1.4",
"hexo-generator-category": "^0.1.3",
"hexo-generator-index": "^0.2.0",
"hexo-generator-tag": "^0.2.0",
"hexo-renderer-ejs": "^0.2.0",
"hexo-renderer-stylus": "^0.3.1",
"hexo-renderer-marked": "^0.2.10",
"hexo-server": "^0.2.0"
}
}
4 changes: 4 additions & 0 deletions scaffolds/draft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: {{ title }}
tags:
---
4 changes: 4 additions & 0 deletions scaffolds/page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: {{ title }}
date: {{ date }}
---
5 changes: 5 additions & 0 deletions scaffolds/post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: {{ title }}
date: {{ date }}
tags:
---
81 changes: 81 additions & 0 deletions source/_posts/django/django-创建项目.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: django_创建项目
tags:
- django
- 默认
categories: django
kind: django
date: 2016-07-04 15:31:50
---

### django创建项目

创建一个项目:
```{bash}
$ django-admin.py startproject cmdb_web
```

启动web服务
```{bash}
$ python3 manage.py runserver 0.0.0.0:8000
```

### 新建视图

站点根目录 新建view.py
```{bash}
from django.http import HttpResponse
def hello(request):
return HttpResponse("Hello world ! ")
```

### 设置路由

打开文件urls.py
```{bash}
from django.conf.urls import *
from HelloWorld.view import hello
urlpatterns = patterns("",
('^hello/$', hello),
)
```

### 使用模板
根目录下创建templates目录并建立hello.html文件
```{bash}
<h1>{{ hello }}</h1>
```

模板文件可以设置多个文件夹,应该也可以整合其他模板引擎,如jinja2,后面做demo尝试一把
模板文件的路径设置,修改HelloWorld/settings.py,修改 TEMPLATES 中的 DIRS 为 [BASE_DIR+"/templates",],如下所示:
```{bash}
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR+"/templates",],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
```

### view中使用模板
我们使用了渲染器render,变量从context字典中赋值
```{bash}
#from django.http import HttpResponse
from django.shortcuts import render
def hello(request):
context = {}
context['hello'] = 'Hello World!'
return render(request, 'hello.html', context)
```
40 changes: 40 additions & 0 deletions source/_posts/django/django-安装.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: django_安装
tags:
- django
- web框架
- python
categories: django
kind: django
date: 2016-07-04 15:05:39
---

### django的安装
#### windows

[Django下载地址](https://www.djangoproject.com/download/)

解压下载包,安装:
```{bash}
$ python3 setup.py install
```

配置环境变量:
path中添加C:\Python34\Lib\site-packages\django

验证:
```{bash}
python3
import django
django.get_version()
```

创建一个项目:
```{bash}
$ django-admin.py startproject cmdb_web
```

启动web服务
```{bash}
$ python3 manage.py runserver
```
28 changes: 28 additions & 0 deletions source/_posts/git/git-使用2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: git使用(如何将远程库克隆到本地)
date: 2016-07-01 09:40:34
permalink: git_3
tags:
- git
- 开发工具
categories: 开发工具
---

### 如何将远程库克隆到本地
你是一个项目的新加入人员或者你换了一台电脑,想从远程库克隆代码到本地,还是以nodejs-hexo这个项目为例

1.在本地新建一个你想要放代码的目录,如 D:/github/blog

2. cd到D:/github/blog
命令:
```{bash}
$ git clone [email protected]:zjkevin/nodejs-hexo.git
```
你会发现在D:/github/blog下已经有nodejs-hexo项目

###
以上所有操作的前提都是你具体远程库的权限,并且在本地库目录下申明了你自己的账户信息
```{bash}
$ git config --global user.email "<youreamil>"
$ git config --global user.name "<username>"
```
57 changes: 57 additions & 0 deletions source/_posts/git/git_使用1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: git使用(如何将本地已有代码交给git托管)
date: 2016-07-01 08:49:17
permalink: git_2
tags:
- git
- 开发工具
categories: 开发工具
---

我们通过程序员惯用的思维方式展开,从问题出发,看用git该如何操作


### 如何将本地已有代码交给git托管
有一种项目是先有代码后来才想用git进行代码管理,以nodejs-hexo这个项目为例
1.在远程服务器建立相应的repository
2.在本地你的代码根目录H:/github/blog/nodejs-hexo运行
命令:
```{bash}
$ git init
```
Initialized empty Git repository in H:/github/blog/nodejs-hexo/.git/
3.hexo项目有一些动态生成的文件是不需要交给git托管的,我们在代码根目录编辑文件**.gitignore** 添加如下不需要托管的内容
```{bash}
.DS_Store
Thumbs.db
db.json
*.log
node_modules/
public/
.deploy*/
```
4.将文件添加到本地库
```{bash}
$ git add *
$ git add .gitignore
```
5.提交到本地库
```{bash}
git commit -m "第一次签入"
```
6.本地库和远程库关联
```{bash}
git remote add origin [email protected]:zjkevin/nodejs-hexo.git
```
7.由于我们远程库中创建了一个README.md,所有要同步本地库跟远程库
```{bash}
git pull origin master
```
8.将本地的所有已经commit到本地库的文件push到远程库中
```{bash}
git push -u origin master
```

###
push -u参数 Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就不用再使用-u参数。也不必指定origin master

Loading

0 comments on commit 8bd8b97

Please sign in to comment.