Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethosa committed Aug 9, 2023
1 parent 209be8e commit 6f9993a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/happyx/private/api_doc_template.nim
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ const IndexApiDocPageTemplate* = fmt"""
</div>
</div>
<script>
window.addEventListener('hashchange', (e) => {{
// clean
function changeHash() {{// clean
let elements = document.querySelectorAll("[id]");
elements.forEach((e) => {{
e.classList.remove("highlight-animation");
Expand All @@ -323,7 +322,9 @@ const IndexApiDocPageTemplate* = fmt"""
if (elem) {{
elem.classList.add("highlight-animation");
}}
}});
}}
window.addEventListener('hashchange', changeHash);
let toggled = {{}};
function toggle(identifier, arrow) {{
Expand Down
15 changes: 10 additions & 5 deletions src/happyx/ssr/server.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1069,9 +1069,8 @@ macro routes*(server: Server, body: untyped): untyped =
immutableVars.add(newIdentDefs(ident"acceptLanguage", newEmptyNode(), acceptLanguage))
if stmtList.isIdentUsed(ident"inCookies"):
immutableVars.add(newIdentDefs(ident"inCookies", newEmptyNode(), cookiesInVar))
when defined(debug):
if stmtList.isIdentUsed(ident"reqMethod"):
immutableVars.add(newIdentDefs(ident"reqMethod", newEmptyNode(), reqMethod))
if stmtList.isIdentUsed(ident"reqMethod"):
immutableVars.add(newIdentDefs(ident"reqMethod", newEmptyNode(), reqMethod))


macro initServer*(body: untyped): untyped =
Expand Down Expand Up @@ -1185,9 +1184,15 @@ when enableApiDoc:
var tableConstr = newNimNode(nnkTableConstr)
for k, v in val.pairs():
tableConstr.add(newNimNode(nnkExprColonExpr).add(newStrLitNode(k), newStrLitNode(v)))
res.add(newNimNode(nnkExprColonExpr).add(newStrLitNode(key), newCall("newStringTable", tableConstr)))
if tableConstr.len > 0:
res.add(newNimNode(nnkExprColonExpr).add(newStrLitNode(key), newCall("newStringTable", tableConstr)))

newCall("toTable", res)
if res.len > 0:
newCall("toTable", res)
else:
newCall(newNimNode(nnkBracketExpr).add(
ident"initTable", ident"string", ident"StringTableRef"
))

proc genApiDoc(body: var NimNode): NimNode =
## Returns API route
Expand Down

0 comments on commit 6f9993a

Please sign in to comment.