Browse Source

Use staticDir to load about page

Fixes #414
Closes #406
Zed 4 năm trước cách đây
mục cha
commit
4ec2874008
2 tập tin đã thay đổi với 8 bổ sung5 xóa
  1. 1 0
      src/nitter.nim
  2. 7 5
      src/views/about.nim

+ 1 - 0
src/nitter.nim

@@ -32,6 +32,7 @@ setHmacKey(cfg.hmacKey)
 setProxyEncoding(cfg.base64Media)
 setMaxHttpConns(cfg.httpMaxConns)
 setHttpProxy(cfg.proxy, cfg.proxyAuth)
+initAboutPage(cfg.staticDir)
 
 waitFor initRedisPool(cfg)
 stdout.write &"Connected to Redis at {cfg.redisHost}:{cfg.redisPort}\n"

+ 7 - 5
src/views/about.nim

@@ -8,16 +8,18 @@ const
   link = "https://github.com/zedeus/nitter/commit/" & hash
   version = &"{date}-{hash}"
 
-let about =
+var aboutHtml: string
+
+proc initAboutPage*(dir: string) =
   try:
-    readFile("public/md/about.html")
+    aboutHtml = readFile(&"{dir}/md/about.html")
   except IOError:
-    stderr.write "public/md/about.html not found, please run `nimble md`\n"
-    "<h1>About page is missing</h1><br><br>"
+    stderr.write &"{dir}/about.html not found, please run `nimble md`\n"
+    aboutHtml = "<h1>About page is missing</h1><br><br>"
 
 proc renderAbout*(): VNode =
   buildHtml(tdiv(class="overlay-panel")):
-    verbatim about
+    verbatim aboutHtml
     h2: text "Instance info"
     p:
       text "Version "