diff options
| -rw-r--r-- | README.mediawiki | 14 | ||||
| -rw-r--r-- | res/client/css/partials/login.scss | 6 | ||||
| -rw-r--r-- | res/templates/index.html | 10 | ||||
| -rw-r--r-- | res/templates/login.html | 5 | ||||
| -rw-r--r-- | src/client/app.js | 2 | ||||
| -rw-r--r-- | src/server/rz_server.py | 40 |
6 files changed, 41 insertions, 36 deletions
diff --git a/README.mediawiki b/README.mediawiki index 1484ffc3..58fda93e 100644 --- a/README.mediawiki +++ b/README.mediawiki @@ -25,13 +25,27 @@ To run Rhizi locally: For testing locally run neo4j locally on the default 7474 port and then launch run-local.sh:<br><code>./run-local.sh</code> Or perform the following tasks by hand: +# Update css files from scss sources using <code>make</code> # Invoke the local deployment Ant target:<br><code>$ cd ./rhizi && ant -f build.ant deploy-local</code> # Assert Neo4J is running and listening on it's default port # Run rhizi-server.py:<br><code>$ cd deploy-local && python bin/rz_server.py --config-dir=etc</code> Command line use documentation can be view with: :$ python rz_server.py -h + +== Installation == + +=== Setup user password file === +The following works in conjunction with run-local.sh, for real deployment place the resulting htpasswd file in the location matching the config you use. +# put a SECRET_KEY entry in the config file: + echo SECRET_KEY=mysecret >> res/etc/rhizi-server.conf +# create an initialization file with email/password separated by a comma: + echo test@example.com,test > res/etc/htpasswd-init-file +# create the htpasswd file: + python src/server/rz_server.py --init-htpasswd-db --htpasswd-init-file res/etc/htpasswd-init-file + = Development = + To update the css files you need [sass](http://sass-lang.com/) The build tool is [make](https://www.gnu.org/software/make/) diff --git a/res/client/css/partials/login.scss b/res/client/css/partials/login.scss index 79c315bb..3c147735 100644 --- a/res/client/css/partials/login.scss +++ b/res/client/css/partials/login.scss @@ -99,7 +99,7 @@ } } &[type="email"] { - background: url(../img/mail-icon.png) no-repeat scroll 20px 15px; + background: url(../static/img/mail-icon.png) no-repeat scroll 20px 15px; background-color:$light-grey; border: 1px solid #dcdcdc; padding: 12px 10px; @@ -109,7 +109,7 @@ } &[type="password"] { - background: url(../img/password-icon.png) no-repeat scroll 20px 15px; + background: url(../static/img/password-icon.png) no-repeat scroll 20px 15px; background-color:$light-grey; border: 1px solid #dcdcdc; padding: 12px 10px; @@ -154,7 +154,7 @@ text-align: center; -moz-box-sizing: border-box; box-sizing: border-box; - background: url(../img/hr-email-icon.png) no-repeat; + background: url(../static/img/hr-email-icon.png) no-repeat; margin-left: auto; display: inline-block; margin-right: auto; diff --git a/res/templates/index.html b/res/templates/index.html index cba394d6..13913ba2 100644 --- a/res/templates/index.html +++ b/res/templates/index.html @@ -2,11 +2,11 @@ <head> <title>Rhizi Prototype </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <link href="/res/css/style.css" rel="stylesheet" type="text/css"> - <link rel="shortcut icon" href="/res/img/favicon2.ico" /> + <link href="/static/css/style.css" rel="stylesheet" type="text/css"> + <link rel="shortcut icon" href="/static/img/favicon2.ico" /> <script src="/static/local_config.js"></script> - <script data-main='/static/app.js' src="/res/lib/require.js"></script> + <script data-main='/static/app.js' src="/static/lib/require.js"></script> </head> @@ -25,7 +25,7 @@ <span class="profile-initials">AN<!-- must be two letters because of css --></span> <div class="profile-username">Welcome <span id="user_id">Anonymous</span>! <span id="logout-button" class="button">Logout</span></div> </div> - <img class="organization-logo" src="/res/img/CRI-logo.png"> + <img class="organization-logo" src="/static/img/CRI-logo.png"> </div> </div> <div class="search-bar"> @@ -123,7 +123,7 @@ </div> <div class="rhizi-logo"><a href="http://www.rhizi.org"> - <img src="/res/img/rhizi-logo.png"/></a> + <img src="/static/img/rhizi-logo.png"/></a> </div> </div> diff --git a/res/templates/login.html b/res/templates/login.html index ac752e99..f35bccdc 100644 --- a/res/templates/login.html +++ b/res/templates/login.html @@ -2,7 +2,7 @@ <head> <meta charset="UTF-8"> <title>Welcome to Rhizi</title> -<link href="/res/css/style.css" rel="stylesheet" type="text/css"> +<link href="/static/css/style.css" rel="stylesheet" type="text/css"> <script src="/static/lib/jquery.js" type="text/javascript"></script> <script type="text/javascript"> function submit_login_form() { @@ -28,7 +28,7 @@ <body class="login-background"> <div class="welcome-box"> - <img src="/res/img/logo-red.png" class="login-rhizi-logo"> + <img src="/static/img/logo-red.png" class="login-rhizi-logo"> <div class="login-text"> <h1 class="login-header"> Welcome to Rhizi!</h1> <p><b>Rhizi is a collaborative knowledge editor.</b></p> @@ -53,7 +53,6 @@ <div class="contact-us-div"><span class="contact-us-icon"></span></div> <p class="login-text contact-us-text"><a class="contact-us-link" href="mailto:dor.garbash@gmail.com">Send us an Email</a> about your experience, especially if you encountered any problem!</p> - </div> </body> </html> diff --git a/src/client/app.js b/src/client/app.js index 4d15f342..4bb762d5 100644 --- a/src/client/app.js +++ b/src/client/app.js @@ -1,5 +1,5 @@ (function() { - var lib_path = '/res/lib/'; + var lib_path = '/static/lib/'; var config = { shim: { 'socketio': { exports: 'io' }, diff --git a/src/server/rz_server.py b/src/server/rz_server.py index 8693ef52..e8fec231 100644 --- a/src/server/rz_server.py +++ b/src/server/rz_server.py @@ -58,6 +58,7 @@ class Config(object): cfg['listen_port'] = 8080 cfg['root_path'] = os.getcwd() cfg['static_url_path'] = '/static' + cfg['htpasswd_path'] = os.path.join(cfg['config_dir'], 'htpasswd') # Flask keys cfg['SECRET_KEY'] = '' @@ -165,19 +166,6 @@ def init_rest_interface(cfg, flask_webapp): redirector.func_name = 'redirector_%s' % path.replace('/', '_') return (path, redirector, flask_args) - def dev_mode__resend_from_static(static_url): - """ - redirect static links while in dev mode: - - /res/<path> -> <path> - """ - static_folder = flask.current_app.static_folder - - new_req_path = None - if request.path.startswith('/res/'): - # turn absolute/res/... URLs to static-folder relative - new_req_path = request.path.replace('/res/', '') - return send_from_directory(static_folder, new_req_path) - def login_decorator(f): """ [!] security boundary: asserd logged-in user before executing REST api call @@ -208,15 +196,6 @@ def init_rest_interface(cfg, flask_webapp): rest_entry('/monitor/server-info', rz_api.monitor__server_info), ] - if cfg.development_mode: - dev_path_set = ['/static', '/res'] - rest_dev_entry_set = [] - for dev_path in dev_path_set: - rest_dev_entry_set.append(rest_entry(dev_path + '/<path:static_url>', - dev_mode__resend_from_static, - {'methods': ['GET']})) - rest_entry_set += rest_dev_entry_set - for re_entry in rest_entry_set: rest_path, f, flask_args = re_entry @@ -230,6 +209,14 @@ def init_rest_interface(cfg, flask_webapp): flask_webapp.f = f # assign decorated function + # install 404 handler to redirect to root - which redirects further to login (index if access disabled) + @flask_webapp.errorhandler(404) + def page_not_found(e): + # FIXME: template for 404 which redirects (html, not http) + log.debug("failed redirection: request = %s" % request) + return redirect('/') + + def init_webapp(cfg, kernel, db_ctl=None): """ Initialize webapp: @@ -262,8 +249,13 @@ def init_config(cfg_dir): return cfg def init_pw_db(cfg, user_pw_list_file): - pass # TODO: stub, will move to tools/ - + if not os.path.exists(user_pw_list_file): + print("error: missing specified htpasswd init file '%s'" % user_pw_list_file) + raise SystemExit + with open(user_pw_list_file) as user_pwd_list_fd: + for line in user_pwd_list_fd: + u, p = [word.strip() for word in line.split(',')] + crypt_util.add_user_login(cfg, u, p) if __name__ == "__main__": |
