• Stars
    star
    568
  • Rank 78,502 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 11 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a tiny and cute social forum based on duoshuo.com

Candy

Candy 是基于多说社交评论的社会化论坛系统,采用 Node.js/Mongodb 构建。营造简洁、实用、具有人情味的下一代论坛系统,是 Candy 的设计目标。

screenshot@0.1.7

安装 Candy

你可以选择两种方式安装 Candy,将 Candy 视为一个 NPM 模块,在外部使用启动脚本启动。或者将整个仓库复制到本地直接运行启动文件。 这两种方式各有各的好处,如果你是个谨慎的使用者,并不希望频繁升级 Candy 核心文件,我推荐你采用第二种方式安装。

在尝试下面两种安装方式前,您首先需要安装Node.js和MongoDB到本地

1.将 Candy 仓库复制到本地并运行启动脚本

$ git clone https://github.com/turingou/candy.git
$ cd candy
$ npm install
$ PORT=3001 node app.js

2.将 Candy 视为 NPM 模块安装,在外部使用启动脚本启动,我已经为你准备了一个现成的启动脚本:

$ mkdir candy && cd candy
$ npm install candy
$ cp node_modules/candy/app.sample.js ./app.js
$ PORT=3001 node app.js

无论你以何种方式启动,你将在默认的端口看到一个全新的 Candy 正在静候你的初次访问。现在,使用浏览器访问 localhost:3000 你将能看到一个全新的 Candy Demo。

升级 Candy

无论你使用何种方式安装 Candy,都可以使用 NPM 或 Git 方便地进行升级。升级操作通常需要在 Candy 的安装目录进行,我们假设你的安装目录是 /www/candy,让我们将 Candy 升级到最新版本吧:

如果你使用 Git clone Candy:

$ cd /www/candy
$ git pull

如果你使用 NPM 安装 Candy,采用这种方法升级可能会导致你在 /www/candy/node_modules/candy/node_modules 文件夹下的自定义主题被覆盖,所以应确保在升级之前,备份你的自定义主题。

$ cd /www/candy
$ npm install candy@latest

配置 Candy

配置 Candy 是一条必经之路,没有一个主题或者配置清单可以适应所有的使用环境。因此,在将你的论坛搭建上生产环境服务器之前,确保通读这份配置指引。

管理员用户

第一个登录的用户会是 Candy 的管理员用户,确保你使用正确的社交网络账户登录 Candy,就可以开始自定义论坛了。 你可以在登录后的右侧菜单找到进入 管理面板 的入口,或者访问 localhost:3000/admin 进入管理面板。

启动脚本 app.js

配置脚本负责启动你的 Candy 论坛。这意味着在变更某些配置之后,你可能需要重新启动配置脚本。这个文件通常是 app.js

注意: 在生产环境启动 candy 时,请配置相应的环境变量以启动服务:

// 在 3001 端口启动服务,配置当前环境为 test:
$ PORT=3001 NODE_ENV='test' node app.js

使用 Docker build 启动镜像

Candy 提供了一份 Dockerfile 以便于使用 Docker 部署服务的使用者可以快速根据 ubuntu:14.04 的原始镜像编译出一份在 3000 端口暴露服务的 Docker Container:

  1. 通过 Candy 提供的 Dockerfile 编译镜像
$ sudo docker build -t <your username>/candy
  1. 启动镜像
// 在宿主机上绑定 8080 端口到此容器的 3000 端口,也就是 Candy 服务的端口
$ sudo docker run -p 8080:3000 -d <your username>/candy
  1. 找到镜像 ID (一串哈希或它的前三位)
$ sudo docker ps -l
  1. 打印镜像活动日志
$ sudo docker logs <container id>

测试 Candy (Debug 模式)

如果你启动的 Candy 实例遇到问题,可以开启 Debug 模式边运行边打印测试结果。你可以通过这样的方式启动 debug 模式:

// 在 3001 端口启动 debug 模式的 candy 实例:
$ DEBUG=candy PORT=3000 node app.js
// 或者直接使用快捷方式
$ cd candy
$ npm test

配置文件 configs.json

配置文件是启动脚本使用的初始配置,Candy 使用一个 json 文件当做配置文件。这个文件里规定了论坛初始化时的名字,简介,永久链接,运行环境,数据库信息等等内容。

如果你采用直接 clone 仓库的方式安装 Candy,配置文件为 ./configs.json,当然,你也可以将 Candy 视为 NPM 模块安装。这样的话,你可以在启动文件中传入配置参数,这里的配置参数与配置文件中的参数名称、规则相同。

这是配置文件 configs.json 的范例:

{
  "name": 'Candy',
  "desc": 'some description for your very new Candy forum',
  "public": "./public",
  "uploads": "./public/uploads",
  "views": "./node_modules/candy-theme-flat",
  "database": {
    "name": 'candy'
  },
  "session": {
    "store": true
  },
  "duoshuo": {
    "short_name": 'xxx',
    "secret": 'xxx'
  }
});

让我们来看看配置文件 configs.json 中的具体参数

configs#name [String] 站点名称
configs#desc [String] 站点介绍
configs#public [String] 静态资源目录 (默认为 ./public)
configs#uploads [String] 附件上传目录 (默认为 ./public/uploads)
configs#views [String] 默认主题目录 (默认为 ./node_modules/candy-theme-flat)
configs#url [String] 站点永久链接

这是一个以 http 或 https 开头的 URL,这个 URL 只有在你将站点的运行环境设定为 production 时才会变成站点的根。

configs#database [Object] 数据库信息

Candy 采用 Mongodb 构建。这是储存论坛数据库信息的对象。包括

  • database.name [String] 数据库名称(必要)
  • database.host [String] 数据库地址
  • database.port [Number] 数据库运行端口
  • database.options [Object] 数据库配置选项(参见 moogoose 文档
configs#session [Object] session 持久化相关信息
  • session.store [Boolean] 是否使用 Conenct-Mongo 做 session 持久化 (默认为 false)
configs#duoshuo [Object] 多说相关信息

Candy 基于多说社交评论构建,因此,你需要提供一个多说 short_name 和相应的 secret

  • duoshuo.short_name [String] 多说 short_name (必要)
  • duoshuo.secret [String] 多说 secret(必要)

Candy 主题系统

Candy 构建于 Theme 主题系统之上。这意味着你可以编写 NPM 模块,作为 Candy 的主题,并发布到 NPM,使所有使用 Candy 的用户受益。

  • 所有主题遵守一套命名约定,必须采用 candy-theme-xxx 的命名规则进行命名,并发布到 NPM。
  • 所有主题都必须按照一定规范书写 package.json 可以参照 Candy 的默认主题 candy-theme-flat 书写你的主题描述文件。
  • 所有主题的静态资源文件夹都推荐放置于主题文件夹下的 static 目录。
  • 所有主题模块均应位于 './node_modules' 文件夹内,小心升级模块时造成的文件覆盖。

欢迎提交 Pull Request

Candy 仍未达到我们期望的完善程度,欢迎一起来完善这个有趣的社会化论坛实验。

  • Fork Candy
  • 在不破坏基本结构的情况下,添加功能。
  • 确保自己添加的功能经过 人工 或者 单元测试
  • 发起 Pull Request

MIT license

Copyright (c) 2013 turing <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

koa-guide

koa guide in Chinese
2,696
star
2

douban.fm

a tiny and smart cli player of douban.fm in Node.js
JavaScript
1,609
star
3

btc

a command-line bitcoin price board for geeks
JavaScript
386
star
4

player

a command line player, supports play mp3 both from uri and local stream.
JavaScript
263
star
5

dailyicons

one icon one day made by Sketch3
186
star
6

o3o

a ascii emoticon generator based on Node.js (>ω<)
JavaScript
145
star
7

atom-guide

the atom guides and docs in Chinese
145
star
8

docor

a smart and tiny README maker using default manifest package.json
Perl
89
star
9

raspberry

Respberry Toolkit & Webpanel based on node, for nodejs apps, makes life easier
JavaScript
84
star
10

kindle

a command line file pusher for your kindle.
JavaScript
73
star
11

ascii

convert pictures to ascii arts based on node-canvas
JavaScript
64
star
12

charts

a chart generator service for easy embed collections of charts in emails
JavaScript
61
star
13

mails

Sending beautiful emails made easy.
JavaScript
50
star
14

express-scaffold

Simple sexy scaffold for Express
JavaScript
44
star
15

houseRocks

houseRocks is a project aims to provide better living space solutions for young people working in Mainland China
38
star
16

Angular-Best-Practices

let's learning Angular
32
star
17

upyun

a pure front-end upyun form upload service, supports both native js and angular.js
JavaScript
30
star
18

sdk

SDK factory, building SDK made easy
JavaScript
26
star
19

gbk

Convert gbk to utf-8 made easy
JavaScript
21
star
20

lazykitten

a cli tool to generate lazy api or html pages for test
JavaScript
21
star
21

go-colors

a colors util written in Go, inspired by Colors.js
Go
16
star
22

consoler

another smart and colorful console logger
JavaScript
15
star
23

handybbs

handybbs wordpress theme
JavaScript
14
star
24

pm2-panel

the missing web and mobile panel of pm2 monitor
JavaScript
13
star
25

avoscloud

a avoscloud service module based on Angular.js and ngResource.
JavaScript
13
star
26

douban-sdk

a simple douban.com sdk, including douban.fm apis.
JavaScript
12
star
27

base64-image

a simple base64 string to image middleware of Express
JavaScript
12
star
28

theme

a smart theme loader for CMS systems
JavaScript
12
star
29

react-native-html

Render html string as react native custom elements
JavaScript
11
star
30

etager

a tiny etag tracker middleware of Express
JavaScript
11
star
31

leanseed

a LeanEngine seed project based on Express and Vue.js
JavaScript
11
star
32

ionic-guide

ionic documentations and guides in Chinese
11
star
33

ionic-leancloud

a ionic-leancloud app seed project
JavaScript
10
star
34

mails-flat

flat email templates for mails
10
star
35

hangjs

the presentation and code snippets for hangJS, jsconf 2014
9
star
36

react-native-leancloud

a react native LeanCloud component
9
star
37

depender

a simple dependency injector based on Node.js
JavaScript
8
star
38

pynotes

let's leaning python, start here with codes
Python
8
star
39

miwifi

Writing miwifi plugins made easy
8
star
40

es6-workflow

Use ES6 today
7
star
41

darkroom

the darkroom game based on wechat
JavaScript
7
star
42

xrp

a smart Ripple / XRP Gateway based on Node.js
7
star
43

visualizing-algorithms

visualizing algorithms 中译文,正在翻译中
7
star
44

koa-scaffold

a simple but sexy MVC wrapper of koa
JavaScript
7
star
45

fuckmylife

我们孤独地写代码,孤独地生活,在深沉的夜里狠狠对这个操蛋的世界骂上一通
7
star
46

cordova-wechat

just another wechat plugin for cordova, which will be always updated with the lastest Wechat Official SDK
Objective-C
7
star
47

fitbit-sdk

a developer friendly node.js sdk of fitbit
JavaScript
7
star
48

malls-in-shenzhen

counting shopping malls in shenzhen
6
star
49

docker-registry

a sdk for docker-registry
JavaScript
6
star
50

23andme

a api wrapper of api.23andme.com
5
star
51

lemonode

a fresh CMS based on Angular/Node.js/Mongodb
JavaScript
5
star
52

dji

a dji drone SDK in Node.js
4
star
53

leancloud

a minimal LeanCloud SDK
JavaScript
4
star
54

yeelink

yeelink apis wrapper for node apps
JavaScript
3
star
55

node.im

a instant messenger based on Node.js and LeanCloud
JavaScript
3
star
56

docker-hub

a docker hub sdk based on Node.js
JavaScript
3
star
57

seesaw

a quick-setup springboard server working around cross-domain requests
JavaScript
3
star
58

sexy-localhost

Sexy layout for Apache localhost lists
3
star
59

kill3k

Just kill process running on port 3000
JavaScript
3
star
60

dogecoin

a dogecoin wallet based on Node.js
3
star
61

term-list-enhanced

a enhancement for term-list, supporting setting or clear labels
JavaScript
3
star
62

poker

a smart signin simulator and testaccounts switcher base on Node
JavaScript
2
star
63

leancloud-logger

a logger service based on LeanCloud
JavaScript
2
star
64

jawbone

a developer friendly node.js sdk of jawbone products
2
star
65

less-guide

less programming guide
2
star
66

doing

a cli todo list designed for geeks
JavaScript
2
star
67

cooker

a minimalism style version manager for static files
JavaScript
2
star
68

keepingbusy

a cli tool which help you pretending to be very very busy
JavaScript
2
star
69

author

a simple token and signature creator for OAuth
JavaScript
2
star
70

paramrule

a simple parameters rules manager
JavaScript
2
star
71

wifi.io

wifi.io node.js sdk
JavaScript
2
star
72

coding-on-iPad-Pro

This is a repo contains resources and articles to show engineers how to code and deploy programs on an iPad Pro with cloud service
2
star
73

upyun-sign

a cli tool for creating upyun form signature by given api_secret
JavaScript
2
star
74

find-me-if-you-can

a littele game to find the real people like a people puzzle
CSS
1
star
75

mails-default

default theme of mails
HTML
1
star
76

geekflow

a sexy workflow for geek/startups based on Node
1
star
77

vue-usecases

some vue.js usecases
JavaScript
1
star
78

mh370.photos

1
star
79

angular-fir

a fir.im SDK based on angular.js
JavaScript
1
star
80

guo-yu

a self intro
1
star
81

startupkit

the startup portal connecting people and workflows
JavaScript
1
star
82

leapdoll

使用 leapmotion 远程控制抓娃娃机
1
star
83

term-animate

animation‎ toolkit in your terminal
1
star
84

express-passport

the passport middleware express-scaffold built-in
JavaScript
1
star
85

knewone

a KnewOne SDK in Node.js
JavaScript
1
star
86

candy-theme-flat

the default theme of candy
JavaScript
1
star
87

DevFest-2014

keynotes on DevFest 2014, GDG Beijing
1
star
88

geomap

a service converting geo longitude and latitude to a real map
CSS
1
star
89

mails-scaffold

the theme scaffold of mails
1
star
90

qiniu

a prue front-end form uploader service for qiniu
JavaScript
1
star
91

charts-theme-sparkline

a jQuery sparklines solution of Charts
1
star
92

tofu

a all in one command line music player.
JavaScript
1
star
93

proxy-in-es2015

a presentation about Proxy() in ES2015
JavaScript
1
star
94

the-little-schemer

<The Little Schemer> 学习笔记
Scheme
1
star
95

Tao

a simple and sexy http server for templates, inspired by serve https://github.com/visionmedia/serve
JavaScript
1
star
96

tesselbot

a chainable tessel rebot made for building simple apps easier
JavaScript
1
star
97

digg

a hacker-news-like digg system based on node
JavaScript
1
star
98

pkghub

a package manager for human, based on NPM iteself.
JavaScript
1
star
99

HackerCookie

cookie for hackers - hacker cookie 是一套hacker 资讯站点的 api 集合和 desktop app,based on node-webkit
JavaScript
1
star
100

angular-pingplusplus

angular version of pingplusplus SDK
1
star