项目作者: saalaa

项目描述 :
Diamond wiki, the metadata enabled wiki engine
高级语言: Python
项目地址: git://github.com/saalaa/diamond.git
创建时间: 2016-11-07T20:31:00Z
项目社区:https://github.com/saalaa/diamond

开源协议:Other

下载


Diamond Wiki

The metadata enabled wiki engine.

Working on the Wiki Engine

Envrionment Setup

Follow the official install
instructions
and then install
the necessary plugins:

  1. $ asdf plugin add poetry
  2. $ asdf plugin add pre-commit
  3. $ asdf plugin add python

Now install the required tooling:

  1. $ asdf install

Install Python requirements:

  1. $ poetry install

Prepare the database:

  1. $ poetry run flask -A diamond.app db upgrade
  2. $ poetry run flask -A diamond.app load-fixtures

Run the wiki engine:

  1. $ poetry run flask -A diamond.app run

Testing

  1. $ poetry run pytest

Configuration

Configuration is entirely done through environment variables (which means the
code base is friendly with most PaaS and orchestration solutions).

Here’s a full list of supported environment variables:

  • SQL_DEBUG: Enable output of SQL statements. Set to yes to enable. Should
    not be set on production.
  • FLASK_DEBUG: Enable pretty exceptions and automatic code reloading while
    hacking Diamond Wiki. Set to yes to enable. Must not be set on production.
  • DATABASE_URL: Database connection credentials. Defaults to
    sqlite:///diamond.db.
  • REDIS_URL: Redis connection credentials. Defaults to redis://mock which
    doesn’t require Redis to work.
  • SECRET_KEY: Secret key for encrypting and signing things. Defaults to a
    random value.
  • MAIL_SERVER: SMTP server address and port.
  • MAIL_USE_TLS: Whether or not the SMTP server supports TLS.
  • MAIL_USE_SSL: Whether or not the SMTP server supports SSL.
  • MAIL_USERNAME: SMTP user name.
  • MAIL_PASSWORD: SMTP password.
  • MAIL_DEFAULT_SENDER: Default sender used for all communication with users,
    for example: Diamond Wiki <diamond-wiki@example.com>.

When running Diamond wiki through Gunicorn (on Heroku for example) or directly
through Python (python -m diamond), the following variables are taken into
account: HOST, PORT.

When using scripts/diamond.sh run, the host and port can be configured
through command-line options. Furthermore, scripts/diamond.sh supports an
.env file that is able to export environment variables, making development
easier (it then prints its content):

  1. $ scripts/diamond.sh run
  2. * Reading .env
  3. | export FLASK_DEBUG=
  4. | export SECRET_KEY=xxx
  5. * Serving Flask app "diamond"
  6. * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Testing

Although full code base coverage is the goal, testing is a work in progress.

Manual tests using pytest

The simplest way to run the tests is through calling pytest in which case
whatever environment you have setup is used. This is what developpers do more
often than not, reusing their development environment:

First, a virtual environment with the project’s dependencies is needed:

  1. $ virtualenv env
  2. $ source env/bin/activate
  3. $ pip install -r requirements.txt

Then, pytest can be called:

  1. $ pytest

Manual tests using tox

A more complex way to run the tests is through calling tox in which case
environment and dependencies are handled automatically. In tox.ini several
Python versions can be configured as test environments (currently Python 2.7
and 3.5 are supported).

Using this method still relies on pytest so these must be configured
properly. It also expects the project to be setuptools -ready so that must be
configured properly as well.

You’ll need tox installed (in this case in a virtual environment to avoid
polluting your system):

  1. $ virtualenv env
  2. $ source env/bin/activate
  3. $ pip install tox

Then, tox can be called:

  1. $ tox