官网:https://horizon.io/#sequence-platform
openstack的推荐的经验:https://gtcsq.readthedocs.io/en/latest/openstack/horizon_develop.html#horizon-develop
horizon是基于Django的,因此它也有一个最重要的Django文件。
settings.py文件绝对目录为:/usr/share/openstack_dashboard/openstack_dashboard/settings.py
首先,全局安装horizon。
npm install -g horizon
然后,你可以使用hz init创建模板项目。
接着通过hz serve --dev启动Horizon服务器和RethinkDB实例。
RethinkDB需要安装好并且要能在PATH目录访问。
$ hz init myapp
$ hz serve myapp --dev
# localhost:8181 has a demo page on it
# Horizon client connections can be made to ws://localhost:8181/horizon
# The horizon client library is served from localhost:8181/horizon/horizon.js
// Connect to horizon
const horizon = Horizon();
const todoCollection = horizon('todo_items');
const todoApp = document.querySelector('#app')
// Function called when a user adds a todo item in the UI
todoCollection.watch().subscribe( todos => {
const todoHTML = todos.map(todo =>
`<div class="todo" id="${todo.id}">
<input type="checkbox" ${todo.done ? 'checked' : ''}>
${todo.text} -- ${todo.date}
</div>`);
todoApp.innerHTML = todoHTML.join('');
});