diff --git a/config.py b/config.py index 63995a1..dc7b343 100644 --- a/config.py +++ b/config.py @@ -6,9 +6,11 @@ Configuration file import logging -## general settings: -PAGES="pages/" -DEMOPAGES="demopages/" +## define the location of rtx pages +## rtx searches all directories and serves the page from the first one (lowest index) +PAGES[0]="pages/" +PAGES[1]="presentation/" +PAGES[2]="demopages/" ## logging settings: # loglevel values: DEBUG (all messages) > INFO > WARNING > ERROR > CRITICAL (only cricital messages) diff --git a/rtxPage.py b/rtxPage.py index 44fbd05..74987e5 100644 --- a/rtxPage.py +++ b/rtxPage.py @@ -35,12 +35,10 @@ class rtxPage: @staticmethod def exists(page): """ checks if the page (i.e. the file) exists """ - if os.path.isfile(config.PAGES + page): + for path in config.PAGES: + if os.path.isfile(path + page): return True - elif os.path.isfile(config.DEMOPAGES + page): - return True - else: - return False + return False def get_page(self): """ returns the page if loaded @@ -78,11 +76,13 @@ class rtxPage: returns False if the page cannot be found returns True if the page has been loaded """ - if os.path.isfile(config.PAGES + page): - filename = config.PAGES + page - elif os.path.isfile(config.DEMOPAGES + page): - filename = config.DEMOPAGES + page + for path in config.PAGES: + if os.path.isfile(path + page): + filename = path + page + """ page has been found, now exit the for loop """ + break else: + """ page does not exist anywhere, so exit the function """ return False with open(filename, "rb") as f: