~fabrixxm/lesanaweb

1cc9593303ffee0a7d93d51f265ec7cd020cbbd7 — fabrixxm 1 year, 1 month ago 114171a
Move settings in environment vars
3 files changed, 11 insertions(+), 30 deletions(-)

M app.py
D bookmarks/settings.yaml
D settings.py.dist
M app.py => app.py +11 -6
@@ 6,14 6,19 @@ from flask import render_template, request, abort

from lesana.collection import Collection

class ConfigurationError(Exception):
    pass

COLLECTIONPATH = "./bookmarks"
PAGESIZE = 20

try:
    from settings import *
except ImportError as e:
    print("[I] no settings module. using defaults.")
COLLECTIONPATH = os.environ.get('LW_COLLECTION_PATH', None)
PAGESIZE = int(os.environ.get('LW_PAGE_SIZE', 20))

if COLLECTIONPATH is None:
    raise ConfigurationError("LW_COLLECTION_PATH env var is not set")

if not os.path.isdir(COLLECTIONPATH) or \
   not os.path.isfile(os.path.join(COLLECTIONPATH, "settings.yaml")):
    raise ConfigurationError("'{} is not a valid collection".format(COLLECTIONPATH))

collection = Collection(COLLECTIONPATH)


D bookmarks/settings.yaml => bookmarks/settings.yaml +0 -22
@@ 1,22 0,0 @@
name: Bookmarks
lang: italian
entry_label: '{{ eid }}: {{ title }} {{ url }}'
git: true
fields:
- name: title
  type: string
  prefix: S
  index: free
- name: url
  type: url
  index: field
- name: description
  type: text
  index: free
- name: tags
  type: list
  list: string
  index: field
- name: added
  type: datetime
  index: field

D settings.py.dist => settings.py.dist +0 -2
@@ 1,2 0,0 @@
COLLECTIONPATH = "./bookmarks"
PAGESIZE = 20