def build_page(name, system_config, page_info, menu_list, template_config, i18n=None): content = file.read_file("./document/{0}.md".format(name)) if page_info is None: page_info = {"title": "undefined"} if os.path.exists("./document/{0}.json".format(name)): page_info = json.loads(file.read_file( "document/{0}.json".format(name))) if "time" in page_info: page_info["time"] = str( post_map.build_time(page_info["time"], system_config)) document = markdown.markdown(content) template = env.get_template("./{0}/post.html".format( system_config["Theme"])) result = template.render(page_info=page_info, menu_list=menu_list, content=document, system_config=system_config, template_config=template_config, now_time=time.localtime(), i18n=i18n) return result
def post_list(request_type): file_url = select_type(request_type) if file_url is None: abort(404) page_list = json.loads(file.read_file(file_url)) if request_type == "post": for item in page_list: page_list[page_list.index(item)]["time"] = str(post_map.build_time(item["time"], system_config)) return json.dumps(page_list)
def load_config(): asyncio.set_event_loop(asyncio.new_event_loop()) loop = asyncio.get_event_loop() tasks = [get_system_config(), get_page_list(), get_menu_list()] loop.run_until_complete(asyncio.wait(tasks)) loop.close() global page_list, page_name_list, menu_list, page_list for item in page_list: page_name_list.append(item["name"]) page_list[page_list.index(item)]["time"] = str(post_map.build_time(item["time"], system_config))
def load_config(): console.log("Info", "Loading configuration...") if not os.path.exists("./config/system.json"): console.log("Error", "system.json file not found.") exit(1) asyncio.set_event_loop(asyncio.new_event_loop()) loop = asyncio.get_event_loop() tasks = [ get_system_config(), get_page_list(), get_menu_list(), get_rss_file() ] loop.run_until_complete(asyncio.wait(tasks)) loop.close() global page_list, page_name_list, menu_list, page_list for item in page_list: page_name_list.append(item["name"]) page_list[page_list.index(item)]["time"] = str( post_map.build_time(item["time"], system_config)) console.log("Success", "load the configuration file successfully!")