You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by ga...@apache.org on 2022/04/16 03:17:52 UTC

[mnemonic-site] branch master updated: MNEMONIC-736: Create markdown loader to parse markdown files from original website

This is an automated email from the ASF dual-hosted git repository.

garyw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mnemonic-site.git


The following commit(s) were added to refs/heads/master by this push:
     new d6d3197  MNEMONIC-736: Create markdown loader to parse markdown files from original website
d6d3197 is described below

commit d6d3197e9601d236fdcee973059494b0e7272772
Author: Yanhui Zhao <wi...@gmail.com>
AuthorDate: Thu Apr 14 19:59:12 2022 -0700

    MNEMONIC-736: Create markdown loader to parse markdown files from original website
---
 mnemonic-fastapi/app/library/helpers.py | 13 +++++++++++++
 mnemonic-fastapi/app/main.py            | 12 ++++--------
 mnemonic-fastapi/app/pages/about.md     |  2 ++
 mnemonic-fastapi/app/pages/home.md      |  2 ++
 mnemonic-fastapi/app/pages/info.md      |  2 ++
 5 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/mnemonic-fastapi/app/library/helpers.py b/mnemonic-fastapi/app/library/helpers.py
new file mode 100644
index 0000000..5a69fc5
--- /dev/null
+++ b/mnemonic-fastapi/app/library/helpers.py
@@ -0,0 +1,13 @@
+import os.path
+import markdown
+
+def openfile(filename):
+    filepath = os.path.join("app/pages/", filename)
+    with open(filepath, "r", encoding="utf-8") as input_file:
+        text = input_file.read()
+
+    html = markdown.markdown(text)
+    data = {
+        "text": html
+    }
+    return data
\ No newline at end of file
diff --git a/mnemonic-fastapi/app/main.py b/mnemonic-fastapi/app/main.py
index f5c4a81..35f1aee 100644
--- a/mnemonic-fastapi/app/main.py
+++ b/mnemonic-fastapi/app/main.py
@@ -4,7 +4,7 @@ from fastapi.responses import HTMLResponse
 from fastapi.staticfiles import StaticFiles
 from fastapi.templating import Jinja2Templates
 
-#from .library.helpers import *
+from .library.helpers import *
 
 app = FastAPI()
 
@@ -13,16 +13,12 @@ app.mount("/static", StaticFiles(directory="static"), name="static")
 
 @app.get("/", response_class=HTMLResponse)
 async def home(request: Request):
-    data = {
-        "page": "Home page"
-    }
+    data = openfile("home.md")
     return templates.TemplateResponse("page.html", {"request": request, "data": data})
 
 @app.get("/page/{page_name}", response_class=HTMLResponse)
 async def page(request: Request, page_name: str):
-    data = {
-        "page": page_name
-    }
+    data = openfile(page_name + ".md")
     return templates.TemplateResponse("page.html", {"request": request, "data": data})
 
 @app.get("/docs", response_class=HTMLResponse)
@@ -41,4 +37,4 @@ if __name__ == "__main__":
             port=443,
         )
     )
-    server.run()
\ No newline at end of file
+    server.run()
diff --git a/mnemonic-fastapi/app/pages/about.md b/mnemonic-fastapi/app/pages/about.md
new file mode 100644
index 0000000..132b944
--- /dev/null
+++ b/mnemonic-fastapi/app/pages/about.md
@@ -0,0 +1,2 @@
+# About
+Apache Mnemonic is a non-volatile hybrid memory storage oriented library, it proposed a non-volatile/durable Java object model and durable computing service that bring several advantages to significantly improve the performance of massive real-time data processing/analytics. developers are able to use this library to design their cache-less and SerDe-less high performance applications.
\ No newline at end of file
diff --git a/mnemonic-fastapi/app/pages/home.md b/mnemonic-fastapi/app/pages/home.md
new file mode 100644
index 0000000..2c1c7aa
--- /dev/null
+++ b/mnemonic-fastapi/app/pages/home.md
@@ -0,0 +1,2 @@
+# Welcome Apache Mnemonic
+This project uses [FastAPI](https://fastapi.tiangolo.com/), [Jinja2](https://jinja.palletsprojects.com/en/2.11.x/), and [Bootstrap4](https://getbootstrap.com/docs/4.1/getting-started/introduction/).
\ No newline at end of file
diff --git a/mnemonic-fastapi/app/pages/info.md b/mnemonic-fastapi/app/pages/info.md
new file mode 100644
index 0000000..5b5b53e
--- /dev/null
+++ b/mnemonic-fastapi/app/pages/info.md
@@ -0,0 +1,2 @@
+# Information
+Apache Mnemonic is a non-volatile hybrid memory storage oriented library, it proposed a non-volatile/durable Java object model and durable computing service that bring several advantages to significantly improve the performance of massive real-time data processing/analytics. developers are able to use this library to design their cache-less and SerDe-less high performance applications.
\ No newline at end of file