+#!/usr/bin/env python3
+
+import logging
+import os
+from typing import Dict, Optional, List, Tuple
+
+from pyutils.files import file_utils
+
+import kiosk_constants as constants
+import file_writer
+import globals
+import renderer
+import trigger
+
+
+logger = logging.getLogger(__file__)
+
+RECIPE_PAGE = os.path.join(constants.pages_dir, "recipe_1_82400.html")
+
+
+class RecipeTrigger(trigger.trigger):
+ def get_triggered_page_list(self) -> Optional[List[Tuple[str, int]]]:
+ if globals.get("recipe_page_triggered"):
+ logger.debug("Recipe page is triggered!")
+ return [(RECIPE_PAGE, trigger.trigger.PRIORITY_HIGH)]
+ return None
+
+
+class RecipeRenderer(renderer.abstaining_renderer):
+ def __init__(
+ self,
+ url_location: str,
+ name_to_timeout_dict: Dict[str, int],
+ ) -> None:
+ super().__init__(name_to_timeout_dict)
+ self.url_location = url_location
+
+ def periodic_render(self, key: str) -> bool:
+ triggered = False
+ if file_utils.does_path_exist(self.url_location):
+ with open(self.url_location, "r") as rf:
+ url = rf.read()
+ url.strip()
+ logger.debug(f"Read {url} from {self.url_location}, writing the page")
+
+ if url and len(url) > 0:
+ with file_writer.file_writer(RECIPE_PAGE) as f:
+ f.write('<IFRAME SRC="{url}"></IFRAME>')
+ triggered = True
+
+ if not triggered:
+ file_utils.remove(RECIPE_PAGE)
+ logger.debug("Signaling the trigger")
+ globals.put("recipe_page_triggered", triggered)
+ return True