Skip to content
the last BBS
JavaScript Python Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin
dep
package
server
static
test
.gitignore
.gitmodules
README.md

README.md

The Package System

In the old days, we separated the client source codes into three categories: stylesheet, template and javascript. However, it's too flat. It's hard to find relative files for one module. It's hard to specify dependencies. It's not modular and reusable.

Then, I came up with the package system, hoping to make it modular and easier.

Here, we need a description for every package, the 'package.json' file. It defines what's inside the package, what's its dependencies and who should depend on it. The file looks like:

{
    "name": "pkg1",
    "stylesheets": ["pkg1.less"],
    "javascripts": ["pkg1.js"],
    "templates": ["pkg1.dust.html"],
    "depend": ["base"],
    "wanted_by": ["pkg2"]
}

To make it simpler, you don't need to specify all the attributes. Name is default to the directory name, and all .less, .js and .dust.html files are automatically added. However, you still need to specify the file lists if you want your files compiled in a specific order.

We will sort the packages in topological order. Then we collect all the files of each type and compile them into their targets (bbs9.js, stylesheet.css, template.js).

Development

You must have 'node' installed for development. Node is not required for deployment. To install the dependencies:

npm install -g ender less dust uglify-js

All files except 'index.html' in 'static' directory are built by scripts. The 'build.js' will be used to build less/js/dust sources. Use

bin/build.js debug

for debug outputs, which will also watch for source file changes and recompile automatically. Currently we cannot detect new files or package changes. Please interrupt the build process and restart. Omitting the 'debug' flag will output compressed files for production.

'ender.js' is built by:

ender build jeesh dust future

The python module 'jsonapp' can be fetched by:

git submodule update --init

The pymongo dependency should be installed with:

# pip install pymongo3

To debug, run the server module directly:

python -m server

And point your browser to http://localhost:8080.

Deployment

To release, run:

bin/release [target]

It will rsync the required files to target directory. If target is not defined, it will default to 'release'.

Then, you need a server to run the wsgi application. We recommend nginx + uwsgi.

Here comes some scripts:

start:

uwsgi -s /tmp/bbs9.socket -w server --pidfile /tmp/bbs9.pid -M

stop:

kill -SIGINT `cat /tmp/bbs9.pid'

reload:

kill -SIGHUP `cat /tmp/bbs9.pid'

nginx config:

location / {
    include uwsgi_params;
    uwsgi_pass unix:/tmp/bbs9.socket;
}

location /static/ {
    root /path/to/bbs9/;
    if ($query_string) {
        expires max;
    }
}
Something went wrong with that request. Please try again.