Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
interrogator committed Aug 20, 2019
1 parent 4aa53fd commit 019fc56
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
17 changes: 13 additions & 4 deletions buzzword/parts/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import flask

from buzzword.parts.main import app, CONFIG, CORPORA, CORPUS_META
from buzzword.parts.main import app, CONFIG, CORPORA, CORPUS_META, INITIAL_TABLES

###########
# STORAGE #
Expand Down Expand Up @@ -376,7 +376,10 @@ def _new_table(
table = TABLES[exists]
# if there was a validation problem, juse use last table (?)
elif msg:
table = list(TABLES.values())[-1]
if TABLES:
table = list(TABLES.values())[-1]
else:
table = INITIAL_TABLES[slug]
else:
# generate table
table = corpus.table(
Expand Down Expand Up @@ -414,7 +417,7 @@ def _new_table(
table_name = _make_table_name(this_table)

# todo: slow to do this every time!
csv_path = _make_csv(table, table_name)
csv_path = "todo" # _make_csv(table, table_name)

tfo = table_from_options
if not msg and not updating:
Expand Down Expand Up @@ -481,8 +484,14 @@ def _new_conc(n_clicks, show, search_from, current_cols, current_data, slug):
specs, corpus = _get_from_corpus(
search_from, CORPORA, SEARCHES, slug=slug, tables_extra=TABLES
)
met = ["file", "s", "i"]

# corpus may not be loaded. then how to know what metadata there is?
if isinstance(corpus, pd.DataFrame) and "speaker" in corpus.columns:
met.append("speaker")

conc = corpus.conc(
show=show, metadata=["file", "s", "i", "speaker"], window=(100, 100)
show=show, metadata=met, window=(100, 100)
)
max_row, max_col = CONFIG["table_size"]
cols, data = _update_datatable(
Expand Down
7 changes: 5 additions & 2 deletions buzzword/parts/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ def _downloadable_name(name):
"""
Make a safe filename for CSV download. todo: url safe?
"""
name = name.strip(".,/#").split("-- from ")[0]
return name.replace(" ", "-").strip("- ").lower()
name = name.lower().split("-- from ")[0]
name = name.replace(" ", "-")
for c in [".", ",", "/", "#"]:
name = name.replace(c, "")
return name.strip("- ")


def _slug_from_name(name):
Expand Down
4 changes: 3 additions & 1 deletion buzzword/parts/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,14 @@ def _make_tabs(
**style.HORIZONTAL_PAD_5,
**style.BLOCK_MIDDLE_35,
}
# remove the paddingTop, which is not needed in explore view
nav = {k: v for k, v in style.NAV_HEADER.items() if k != "paddingTop"}

top_bit = [
html.Img(
src="../assets/bolt.jpg", height=42, width=38, style=style.BLOCK_MIDDLE_35
),
dcc.Link("buzzword", href="/", style=style.NAV_HEADER),
dcc.Link("buzzword", href="/", style=nav),
# these spaces are used to flash messages to the user if something is wrong
dcc.ConfirmDialog(id="dialog-search", message=""),
dcc.ConfirmDialog(id="dialog-table", message=""),
Expand Down
5 changes: 4 additions & 1 deletion corpora.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"drop_columns": ["voice_over", "camera_angle"],
"disable": false,
"date": "1989",
"load": true,
"url": "https://en.wikipedia.org/wiki/Do_the_Right_Thing"
},
"Unabomber Manifesto" : {
Expand All @@ -17,5 +18,7 @@
"add_governor": false,
"disable": false,
"date": "1995",
"load": true,
"url": "https://en.wikipedia.org/wiki/Ted_Kaczynski#Industrial_Society_and_Its_Future"
}
}
}

0 comments on commit 019fc56

Please sign in to comment.