populate_db: Add images in test data.

This isn't quite the right model, because we're not actually going
through the upload code path, but it does at least provide some inline
image previews in the data.

Fixes part of #14991.
This commit is contained in:
Ganesh Pawar
2021-01-26 15:13:04 +05:30
committed by Tim Abbott
parent 4ca66e7278
commit a42f7a67e1
2 changed files with 20 additions and 3 deletions

View File

@@ -54,6 +54,7 @@ def load_generators(config: Dict[str, Any]) -> Dict[str, Any]:
results["inline-code"] = itertools.cycle(cfg["inline-code"]) results["inline-code"] = itertools.cycle(cfg["inline-code"])
results["code-blocks"] = itertools.cycle(cfg["code-blocks"]) results["code-blocks"] = itertools.cycle(cfg["code-blocks"])
results["quote-blocks"] = itertools.cycle(cfg["quote-blocks"]) results["quote-blocks"] = itertools.cycle(cfg["quote-blocks"])
results["images"] = itertools.cycle(cfg["images"])
results["lists"] = itertools.cycle(cfg["lists"]) results["lists"] = itertools.cycle(cfg["lists"])
@@ -120,8 +121,14 @@ def add_flair(paragraphs: List[str], gens: Dict[str, Any]) -> List[str]:
txt = add_emoji(paragraphs[i], next(gens["emojis"])) txt = add_emoji(paragraphs[i], next(gens["emojis"]))
elif key == "link": elif key == "link":
txt = add_link(paragraphs[i], next(gens["links"])) txt = add_link(paragraphs[i], next(gens["links"]))
elif key == "picture": elif key == "images":
txt = txt # TODO: implement pictures # Ideally, this would actually be a 2-step process that
# first hits the `upload` endpoint and then adds that URL;
# this is the hacky version where we just use inline image
# previews of files already in the project (which are the
# only files we can link to as being definitely available
# even when developing offline).
txt = paragraphs[i] + "\n" + next(gens["images"])
results.append(txt) results.append(txt)

View File

@@ -44,6 +44,16 @@
"```quote\nAny sufficiently advanced technology is indistinguishable from magic.\n -- Arthur C. Clarke\n```" "```quote\nAny sufficiently advanced technology is indistinguishable from magic.\n -- Arthur C. Clarke\n```"
], ],
"images": [
"[whale](/static/images/features/whale.png)\n",
"[twitter](/static/images/features/twitter.png)\n",
"[topics](/static/images/story-tutorial/zulip-topic.png)\n",
"[On_it!](/static/images/story-tutorial/zulip-compose.png)\n",
"[streams](/static/images/story-tutorial/zulip-streams.png)\n",
"[stream_selected](/static/images/story-tutorial/zulip-streams-selected-original.png)\n",
"[unreads](/static/images/story-tutorial/zulip-streams-unreads.png)\n"
],
"maths": [ "maths": [
"$$e^{i \\pi } + 1 = 0$$", "$$e^{i \\pi } + 1 = 0$$",
"$$\\frac{1}{\\Gamma(k)\\theta^k x^{k-1} e^{-\\frac{x}{\\theta}}$$" "$$\\frac{1}{\\Gamma(k)\\theta^k x^{k-1} e^{-\\frac{x}{\\theta}}$$"
@@ -67,7 +77,7 @@
"math": 1, "math": 1,
"link" : 8, "link" : 8,
"list": 5, "list": 5,
"picture" : 0 "images" : 5
}, },
"corpus": "corpus":
{ {