Skip to content

Commit

Permalink
navbar shows git info in debug
Browse files Browse the repository at this point in the history
  • Loading branch information
interrogator committed Aug 23, 2019
1 parent 4f76936 commit daa8042
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
44 changes: 32 additions & 12 deletions buzzword/parts/nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,44 @@
buzzword: navigation bar
"""

import buzzword
import subprocess
import dash_core_components as dcc
import dash_html_components as html
from buzzword.parts import style

LINKS = [
("User guide", "https://buzzword.readthedocs.io/en/latest/guide/"),
("Creating corpora", "https://buzzword.readthedocs.io/en/latest/building/"),
("Depgrep query syntax", "https://buzzword.readthedocs.io/en/latest/depgrep/"),
("About", "https://buzzword.readthedocs.io/en/latest/about/"),
]

hrefs = [html.Li([html.A(name, target="_blank", href=url)]) for name, url in LINKS]
def _make_navbar(debug):
"""
Generate navigation bar. Debug will add version information
"""

navbar = html.Div(
[
if debug:
version = buzzword.__version__
commit = "git rev-parse --short HEAD"
commit = subprocess.check_output(commit.split()).decode("utf-8").strip()
ver_string = "version {}: {}".format(version, commit)
github = "https://github.com/interrogator/buzzword/tree/" + commit
git_sty = {**style.NAV_HEADER, **{"fontSize": "12pt", "paddingLeft": "20px"}}

LINKS = [
("User guide", "https://buzzword.readthedocs.io/en/latest/guide/"),
("Creating corpora", "https://buzzword.readthedocs.io/en/latest/building/"),
("Depgrep query syntax", "https://buzzword.readthedocs.io/en/latest/depgrep/"),
("About", "https://buzzword.readthedocs.io/en/latest/about/"),
]

hrefs = [html.Li([html.A(name, target="_blank", href=url)]) for name, url in LINKS]

components = [
html.Img(src="../assets/bolt.jpg", height=42, width=38, style=style.NAV_HEADER),
dcc.Link("buzzword", href="/", style=style.NAV_HEADER),
html.Div(html.Ul(hrefs, className="nav navbar-nav"), className="pull-right"),
],
className="navbar navbar-default navbar-static-top",
)
]

if debug:
ver = html.A(ver_string, target="_blank", href=github, style=git_sty)
components.insert(2, ver)

navbar = html.Div(components, className="navbar navbar-default navbar-static-top")
return navbar
3 changes: 2 additions & 1 deletion buzzword/parts/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from buzzword.parts.strings import _slug_from_name, _make_description
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate
from buzzword.parts.nav import navbar
from buzzword.parts.nav import _make_navbar
from buzzword.parts import style


Expand Down Expand Up @@ -319,5 +319,6 @@ def show_uploaded(contents, filenames):
content_style = {"display": "inline-block", "width": "1000px", "textAlign": "left"}
content = html.Div(content, style=content_style)
content = html.Div(content, style={"textAlign": "center"})
navbar = _make_navbar(GLOBAL_CONFIG["debug"])
components = [navbar, content]
layout = html.Div(components)

0 comments on commit daa8042

Please sign in to comment.