Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/data/blooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class Bloom:


def add_bloom(*, sender: User, content: str) -> Bloom:
if len(content) > 280:
raise ValueError("Content exceeds 280 character limit.")

hashtags = [word[1:] for word in content.split(" ") if word.startswith("#")]

now = datetime.datetime.now(tz=datetime.UTC)
Expand Down
1 change: 1 addition & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pycparser==2.22
PyJWT==2.10.1
python-dotenv==1.0.1
Werkzeug==3.1.3
psycopg2==2.9.9
6 changes: 6 additions & 0 deletions front-end/components/bloom-form.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ async function handleBloomSubmit(event) {
const textarea = form.querySelector("textarea");
const content = textarea.value.trim();

const maxLength = 280;
if (content.length > maxLength) {
alert(`Content must be ${maxLength} characters or less.`);
return;
}

try {
// Make form inert while we call the back end
form.inert = true;
Expand Down
10 changes: 5 additions & 5 deletions front-end/components/bloom.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const createBloom = (template, bloom) => {
};

function _formatHashtags(text) {
if (!text) return text;
return text.replace(
/\B#[^#]+/g,
(match) => `<a href="/hashtag/${match.slice(1)}">${match}</a>`
);
if (!text) return text;
return text.replace(/\B#(\w+)/g, (match, tag) => {
const normalizedTag = tag.toLowerCase();
return `<a href="/hashtag/${encodeURIComponent(normalizedTag)}">${match}</a>`;
});
}

function _formatTimestamp(timestamp) {
Expand Down
Loading