aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md19
-rw-r--r--app.cfg.example2
-rwxr-xr-xroka.py8
3 files changed, 16 insertions, 13 deletions
diff --git a/README.md b/README.md
index 4d76afe..7a7af22 100644
--- a/README.md
+++ b/README.md
@@ -33,16 +33,18 @@ In addition to running as a server, Roka can also generate a static index and
set of RSS feeds that can be deployed to static hosting. This mode does not
support a username and password.
-1. Run roka.py with `--generate <output_directory> --base_url <url>` parameters
- where `<output_directory>` is a directory to place the generated site and
- `<url>` is the base url where the static site will be uploaded to.
+1. Set `BASE_URL` in app.cfg to the base url where the static site will be
+ uploaded.
+
+2. Run roka.py with the `--generate <output_directory>` parameter, where
+ `<output_directory>` is an output directory to place the generated site.
```bash
- ./roka.py --generate ./static --base_url "https://example.com/"
+ ./roka.py --generate ./static
```
-2. Upload the static site to any static web hosting. Make sure it is accessible
- at the URL previously passed in as `--base_url`
+3. Upload the static site to any static web hosting. Make sure it is accessible
+ at the URL set as `BASE_URL`
## Design decisions
@@ -68,3 +70,8 @@ support a username and password.
4. No rebuild endpoint exists; cache-affecting routines are run externally by
calling roka.py directly
+
+5. Configuration can either be placed in a file named `app.cfg`, or it can be
+ overridden on the terminal by passing a JSON string as the `--config`
+ parameter. I.E. `./roka.py --generate ./static --config '{"ROOT_PATH":
+ "/path/to/audiobooks", "BASE_URL": "https://example.com/"}'`
diff --git a/app.cfg.example b/app.cfg.example
index 94d2ef2..1fe4968 100644
--- a/app.cfg.example
+++ b/app.cfg.example
@@ -1,3 +1,5 @@
ROOT_PATH = '/path/to/audiobooks'
+# BASE_URL is only used for static generation
+BASE_URL = 'https://example.com/'
USERNAME = 'username'
PASSWORD = 'password'
diff --git a/roka.py b/roka.py
index 9ac88d1..b7fc849 100755
--- a/roka.py
+++ b/roka.py
@@ -97,17 +97,11 @@ if __name__ == '__main__':
parser.add_argument('--generate', dest='static_path', type=str, action='store',
help='Output directory to generate static files',
required=False)
- parser.add_argument('--base_url', dest='base_url', type=str, action='store',
- help='Base URL to use in static files',
- required=False)
parser.add_argument('--config', dest='config', type=str, action='store',
help='Json configuration instead of app.cfg',
required=False)
args = parser.parse_args()
- if args.static_path and not args.base_url or args.base_url and not args.static_path:
- parser.error('--generate and --base_url must be included together')
-
if args.config:
class objectview(object):
def __init__(self, d):
@@ -124,6 +118,6 @@ if __name__ == '__main__':
books.scan_books(root_path)
books.write_cache()
elif args.static_path:
- generate(args.static_path, args.base_url, root_path)
+ generate(args.static_path, app.config['BASE_URL'], root_path)
else:
app.run(host='127.0.0.1', port='8085', threaded=True)