Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ docs/_build
/oldlogs
*_settings.py
!default_settings.py
*.log
63 changes: 34 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,51 @@ based on). **Fladgejt** contains the business logic for various AIS2 tasks and
knows where to find which buttons and tables. And **Votrfront** is the web app
that Votr's users interact with.

Running Votr
------------
Installing and running Votr
---------------------------

1. Install Python 3.4+ and virtualenv. On recent Ubuntu or Debian, use:
System requirements:

sudo apt install virtualenv
* Install Python 3.4+ and virtualenv. E.g. on Ubuntu 18.04: `sudo apt install
virtualenv`
* Install [node.js 8+][1]. E.g. on Ubuntu 18.04: `sudo apt install nodejs`
* If your Linux distribution doesn't have node.js >= 8, or if you don't
want to install node.js system-wide, you can use nvm or nodeenv.
[Read more.][2]
* [Install Yarn.][3]

2. Install node.js and npm. (Some Linux distributions bundle them together in
one package.) Check the version: npm 1 and 2 are too old. npm 3 and 4 are
probably OK. npm 5+ is ideal, but most Linux distributions don't have it yet
(including current Ubuntu and Debian). In that case, you can either:
[1]: https://nodejs.org/en/download/package-manager/
[2]: https://github.com/fmfi-svt/votr/wiki/Installation-options
[3]: https://yarnpkg.com/en/docs/install

* Install npm 3 despite its age and hope for the best. E.g. on Ubuntu:
`sudo apt install nodejs-legacy npm`.
* Use the unofficial up to date repositories from
https://nodejs.org/en/download/package-manager/, and install `nodejs`
(not `nodejs-legacy` and `npm`).
Download and set up Votr:

3. Create a virtualenv directory. A virtualenv is an isolated environment that
contains Python libraries, so that you don't have to install them
system-wide, and each project can use different versions without conflicts.
```shell
git clone https://github.com/fmfi-svt/votr.git
cd votr
virtualenv -p python3 venv
```

virtualenv -p python3 venv
Install Votr's dependencies in `votr/venv` and `votr/node_modules`:

4. Activate the virtualenv. (Basically, this just adds `venv/bin` to your
current shell's `$PATH`. Instead, you could just use `venv/bin/python`
instead of `python`, `venv/bin/pip` instead of `pip`, etc.)
```shell
venv/bin/pip install -r requirements.txt
yarn install
```

source venv/bin/activate
(Note: Repeat this step every time you pull a new version of Votr, in case they
were updated.)

5. Install the latest version of `pip` (earlier versions don't support wheels),
and then use it to install Python dependencies.
Run Votr by starting these two commands in separate terminals: \
(They are Votr's web server and Votr's JS/CSS build system.)

pip install -U pip
pip install -r requirements.txt
```shell
venv/bin/python console.py serve --debug
```

6. Start Votr. Remember to activate the virtualenv first if you haven't done it
yet in this terminal.

./console.py serve --debug
```shell
yarn watch
```

Contributing to Votr
--------------------
Expand Down
63 changes: 63 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "votr",
"version": "0.0.0",
"repository": "https://github.com/fmfi-svt/votr",
"license": "Apache-2.0",
"private": true,
"dependencies": {
"@babel/core": "^7.0.1",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/runtime": "^7.0.0",
"babel-loader": "^8.0.2",
"bootstrap-sass": "^3.3.7",
"css-loader": "^1.0.0",
"file-saver": "^1.3.8",
"imports-loader": "^0.8.0",
"jquery": "^3.3.1",
"lodash": "^4.17.10",
"mini-css-extract-plugin": "^0.4.2",
"node-sass": "^4.9.3",
"prop-types": "^15.6.2",
"react": "^16.5.0",
"react-dom": "^16.5.0",
"sass-loader": "^7.1.0",
"url-loader": "^1.1.1",
"webpack": "^4.18.0",
"webpack-cli": "^3.1.0"
},
"scripts": {
"builddev": "webpack --mode=development --progress --display=minimal",
"buildprod": "webpack --mode=production --progress --display=minimal",
"watch": "webpack --mode=development --progress --display=minimal --watch",
"buildboth": "$npm_execpath run builddev && $npm_execpath run buildprod && echo ok_both > votrfront/static/status",
"clean": "rm -rf votrfront/static",
"distclean": "rm -rf votrfront/static node_modules"
},
"browserslist": "defaults, not dead",
"babel": {
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
],
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
[
"@babel/plugin-transform-runtime",
{
"regenerator": false,
"useESModules": true
}
]
]
}
}
1 change: 0 additions & 1 deletion requirements-to-freeze.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
beautifulsoup4
libsass
lxml
requests
werkzeug
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ beautifulsoup4==4.6.0
certifi==2018.1.18
chardet==3.0.4
idna==2.6
libsass==0.13.6
lxml==4.1.1
requests==2.18.4
six==1.11.0
urllib3==1.22
Werkzeug==0.14.1
105 changes: 0 additions & 105 deletions votrfront/buildstatic.sh

This file was deleted.

3 changes: 1 addition & 2 deletions votrfront/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ $table-condensed-cell-padding: 4px;
@import "votr-bootstrap";
@import "layout";
@import "forms";
@import "spinner";


html, body {
Expand Down Expand Up @@ -89,7 +88,7 @@ a, .btn.btn-link {
}

.loading {
background-image: $spinner;
background-image: url(spinner.svg);
background-repeat: no-repeat;
background-size: contain;
padding-left: 1.5em;
Expand Down
24 changes: 20 additions & 4 deletions votrfront/front.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import os
import json
import time
import traceback
from werkzeug.routing import Rule
from werkzeug.wrappers import Response
Expand Down Expand Up @@ -67,12 +68,27 @@ def app_response(request, **my_data):
if 'csrf_token' not in my_data:
my_data['servers'] = request.app.settings.servers

if not os.path.exists(static_path + 'ok'):
return Response('buildstatic failed!', status=500)
for i in range(60):
try:
with open(static_path + 'status') as f:
status = f.read().strip()
except FileNotFoundError:
return Response('Missing static files.', status=500)
if status != 'busy':
break
time.sleep(0.1)
else:
return Response('Timed out waiting for webpack.', status=500)

debug = request.cookies.get('votr_debug')
with open(static_path + ('jsdeps-dev' if debug else 'jsdeps-prod')) as f:
scripts = f.read().split()
if status == 'failed':
return Response('Webpack build failed.', status=500)
elif status == 'ok_dev' or (status == 'ok_both' and debug):
scripts = ['prologue.dev.js', 'votr.dev.js', 'vendors_votr.dev.js']
elif status == 'ok_prod' or (status == 'ok_both' and not debug):
scripts = ['prologue.min.js', 'votr.min.js', 'vendors_votr.min.js']
else:
return Response('Unexpected webpack status.', status=500)

content = template % dict(
init_json=json.dumps({ 'settings': my_data }).replace('</', '<\\/'),
Expand Down
1 change: 1 addition & 0 deletions votrfront/js/About.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import React from 'react';
import { Modal, PageLayout } from './layout';


Expand Down
1 change: 1 addition & 0 deletions votrfront/js/AnketaPopup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import React from 'react';
import { CacheRequester, Loading } from './ajax';

var dropCookie = true; // false disables the Cookie, allowing you to style the banner
Expand Down
1 change: 1 addition & 0 deletions votrfront/js/DetailPredmetu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

import React from 'react';
import { ZoznamPrihlasenychNaTerminColumns } from './ZoznamPrihlasenychNaTermin';
import { CacheRequester, Loading } from './ajax';
import { Modal } from './layout';
Expand Down
2 changes: 2 additions & 0 deletions votrfront/js/ErrorPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

import React from 'react';
import _ from 'lodash';
import { goLogout, goReset, goResetHome } from './ajax';
import { Modal, ModalBase } from './layout';
import { AnalyticsMixin, FakeLink } from './router';
Expand Down
12 changes: 7 additions & 5 deletions votrfront/js/LogViewer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

import React from 'react';
import _ from 'lodash';
import { LocalSettings } from './LocalSettings';
import { logs } from './ajax';

Expand Down Expand Up @@ -94,18 +96,18 @@ function computeBenchmarks() {
}
});

return _(sums).pairs().sortBy(1).reverse().valueOf();
return _.sortBy(_.toPairs(sums), 1).reverse();
}


export function LogViewerBenchmarkContent() {
var benchmarks = this.computeBenchmarks();
export function LogViewerBenchmarkContent(props) {
var benchmarks = computeBenchmarks();

return (
<div className="log-viewer">
<div className="options">
{this.props.closeButton}
{this.props.modeButton}
{props.closeButton}
{props.modeButton}
</div>

<div className="scroll">
Expand Down
2 changes: 2 additions & 0 deletions votrfront/js/LoginPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

import React from 'react';
import _ from 'lodash';
import { AboutModal } from './About';
import { Modal, ModalBase } from './layout';
import { AnalyticsMixin, FakeLink } from './router';
Expand Down
Loading