web: Move web app to ‘web’ directory.

Ever since we started bundling the app with webpack, there’s been less
and less overlap between our ‘static’ directory (files belonging to
the frontend app) and Django’s interpretation of the ‘static’
directory (files served directly to the web).

Split the app out to its own ‘web’ directory outside of ‘static’, and
remove all the custom collectstatic --ignore rules.  This makes it
much clearer what’s actually being served to the web, and what’s being
bundled by webpack.  It also shrinks the release tarball by 3%.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-02-22 14:03:47 -08:00
parent be0098146c
commit c1675913a2
866 changed files with 978 additions and 993 deletions

29
web/src/message_parser.ts Normal file
View File

@@ -0,0 +1,29 @@
// We only use jquery for parsing.
import $ from "jquery";
// TODO: Move this to message_store when it is
// converted to TypeScript.
interface Message {
content: string;
}
// We need to check if the message content contains the specified HTML
// elements. We wrap the message.content in a <div>; this is
// important because $("Text <a>link</a>").find("a") returns nothing;
// one needs an outer element wrapping an object to use this
// construction.
function is_element_in_message_content(message: Message, element_selector: string): boolean {
return $(`<div>${message.content}</div>`).find(`${element_selector}`).length > 0;
}
export function message_has_link(message: Message): boolean {
return is_element_in_message_content(message, "a");
}
export function message_has_image(message: Message): boolean {
return is_element_in_message_content(message, ".message_inline_image");
}
export function message_has_attachment(message: Message): boolean {
return is_element_in_message_content(message, "a[href^='/user_uploads']");
}